SlideShare a Scribd company logo
Model-counting Approaches For Nonlinear
Numerical Constraints
Mateus Borges1
, Sang Phan2
, Antonio Filieri1
, Corina P˘as˘areanu2,3
1Imperial College London, UK
2Carnegie Mellon University Silicon Valley, USA
3NASA Ames Research Center, USA
NASA Formal Methods Symposium
May 16, 2017
1 / 14
Model Counting
Applications of model counting
probabilistic inference
reliability analysis
quantitative information flow (for side-channel analysis)
. . .
Integrated Symbolic Execution for Space-Time Analysis of Code.
http://www.cmu.edu/silicon-valley/research/isstac
2 / 14
Side channels
H
L
“main” channelprogram
(unintended) side channel
main channel
output of the program, i.e. return value
side channels
execution time
power consumption
number of packets transmitted over a network
number of bytes written to a file
. . .
3 / 14
Symbolic Execution and Symbolic PathFinder
1 int x,y;
2 if(x > y){
3 x = x + y;
4 y = x − y;
5 x = x − y;
6 if(x − y > 0)
7 assert(false);
8 }
{x → X, y → Y }
PC : True
{x → X, y → Y }
PC : X > Y
{x → X + Y, y → Y }
PC : X > Y
{x → X + Y, y → X}
PC : X > Y
{x → Y, y → X}
PC : X > Y
{x → Y, y → X}
PC : X > Y ∧ Y − X > 0
6
{x → Y, y → X}
PC : X > Y ∧ Y − X ≤ 0
6
5
4
3
2
{x → X, y → Y }
PC : X ≤ Y
2
Symbolic PathFinder: symbolic JVM for Java bytecode
4 / 14
Side-channel analysis
Quantifying information leaks
Perform symbolic execution to collect all symbolic paths πi .
Compute the observable of each symbolic path oi = cost(πi ).
Compute the leakage using Shannon entropy
Leakage =
i=1...n
p(oi ) log2
1
p(oi )
Assume the secret h has uniform distribution over the domain ΩH
p(oi ) =
cost(πj )=oi
(πj )
|ΩH|
where (πj ) is computed by using model counting tools.
5 / 14
Motivation
Most previous work limit on programs with linear numerical
constraints (using Latte or barvinok).
Reliability Analysis in SymbolicPathfinder. ICSE’13.
Multi-run Side-Channel Analysis Using Symbolic Execution and
Max-SMT. CSF’16.
String Analysis for Side Channels with Segmented Oracles. FSE’16.
Synthesis of Adaptive Side-Channel Attacks. CSF’17.
⇒ Model counting of path conditions for programs with nonlinear
numerical constraints.
6 / 14
Taxonomy of model counting
Precision
Exact counting
Approximate counting
Level
Bit-level counting
Word-level counting
Others:
Blocking-clause enumeration
BDD-based enumerations
Counting with Gr¨obner bases
Brute force
7 / 14
Evaluation setup
Tool selection
Publicly available implementations of model counting
algorithms
POC’s developed by us
Fixed execution time (1 hour)
Benchmark: Modular exponentiation
Two distinct implementations
Extracted path conditions through symbolic execution
8 / 14
Evaluated Tools
Precision Level
All-SAT exact bit
Dsharp exact bit
SharpCDCL exact bit
SharpSAT exact bit
ApproxMC approximate bit
SMTapproxMC approximate word
Brute force exact word
MathSAT exact word
Z3 (blocking clause) exact word
9 / 14
Modular Exponentiation
Asymmetric cryptographic algorithms
public key: (e,n)
private key: d
message: m
encryption: c = modPow(m, e, n)
decryption: m = modPow(c, d, n)
Experiments with
n = 1717
n = 834443
n = 1964903306
(product of two distinct prime numbers)
modPow(x, y, z) = xy
mod z
int modPow1(int c, int d, int n){
int s = 1, y = c, res=0;
while (d > 0) {
if (d % 2 == 1) {
//reduction:
int tmp = s ∗ y;
if (tmp > n){
tmp = tmp − n;
}
res = tmp % n;
} else {
res=s;
}
s = (res ∗ res) % n;
d /= 2;
}
return res;
}
10 / 14
Modular Exponentiation
SnapBuddy
A photo-sharing web application.
Given by DARPA as one of the engagement problems.
public static BigInteger modPow2(final BigInteger x, final BigInteger y,
final BigInteger z) {
BigInteger s = BigInteger.valueOf(1L);
for (int width = y.bitLength(), i = 0; i < width; ++i) {
s = s.multiply(s).mod(z);
if (y.testBit(width − i − 1)) {
s = fastMultiply(s, x).mod(z);
}
}
return s;
}
}
11 / 14
Symbolic Execution of Modular Exponentiation
modPow(x, y, z) = xy mod z
Perform symbolic execution on
modPow1
Both x and y are symbolic.
z is either 1717, 834443, or 1964903306.
modPow2
x is a concrete 1532-bit value.
y is symbolic BigInteger with 40 bits.
z is a concrete 1536-bit value (hard-coded in SnapBuddy)
12 / 14
Experimental Results
Subject a-1 a-2 a-3 a-4 a-5 a-6 a-7 b-1 b-2 b-3 b-4
N. Ops 11 26 15 37 121 57 117 250 243 1428 1428
Domain Size 10K 10K 10K 25M 25M 59B 59B 4T 4T 32B 32B
N. Solutions 1.7K 7 1.7K 208K 109K 80M 77M 2B 66B 1 1
N. CNF clauses 40K 78K 58K 67K 114K 58K 78K 2K 2K 2K 2K
Execution time
BitBlasting 15s 30s 24s 25s 44s 23s 30s 1s 1s 1s 2s
SharpCDCL 1s 1s 1s 43m - - - - - 1s 1s
All-SAT 1s 8s 2s 31m∗
59m∗
15m∗
19m∗
- - 1s 1s
SharpSAT 5s 2s 11s 29m 53m - - 1s 1s 1s 1s
Dsharp 12m 32s 22m - - - - 1s 1s 1s 1s
ApproxMC (f) 4s 2s 5s 16s 32s 1m 1m 4s 5s 1s 1s
ApproxMC (p) 4s 2s 6s 2m 5m 21m 24m 16s 25s 1s 1s
SMTapproxMC (f) 6m 15m 8m - - - - - - 2m 2m
SMTapproxMC (p) - 15m - - - - - - - 2m 2m
MathSAT 2s 2s 5s 38m 54m - - - - 1s 1s
Z3-BC 12s 3s 18s - - - - - - 1s 1s
Brute Force 1s 1s 1s 1s 1s 8m 8m - - 2m 2m
13 / 14
Conclusion
Small domain: brute force!
Exact counters can be effective when the problem is small
(< 50K clauses) or count is close to domain size.
Most promising: approximate model counting with bit-level
hashing.
Performance can degrade when increased precision is required.
14 / 14

More Related Content

DOCX
Dsp model exam qp
PPTX
Building Efficient and Highly Run-Time Adaptable Virtual Machines
PDF
Building blocks for aggregate programming of self-organising applications
PPT
Application of Non-linear Electronics in Digital Communication
PPTX
Thesis Final Presentation
PDF
Q4.11: Using GCC Auto-Vectorizer
DOC
bask, bfsk, bpsk
PDF
Incremental and parallel computation of structural graph summaries for evolvi...
Dsp model exam qp
Building Efficient and Highly Run-Time Adaptable Virtual Machines
Building blocks for aggregate programming of self-organising applications
Application of Non-linear Electronics in Digital Communication
Thesis Final Presentation
Q4.11: Using GCC Auto-Vectorizer
bask, bfsk, bpsk
Incremental and parallel computation of structural graph summaries for evolvi...

What's hot (18)

PPT
Tpr star tree
PDF
Using R in remote computer clusters
TXT
Demodulate bpsk up
PDF
PDF
Matlab bode diagram_instructions
PPT
PREDICTING THE TIME OF OBLIVIOUS PROGRAMS. Euromicro 2001
PPT
PREDICTING THE TIME OF OBLIVIOUS PROGRAMS. Euromicro 2001
PDF
09 bsc-17 dsp lab 10-1
PDF
A Polynomial-Space Exact Algorithm for TSP in Degree-5 Graphs
PPT
Semet Gecco06
PPTX
Федор Поляков (Looksery) “Face Tracking на мобильных устройствах в режиме реа...
PPT
Exploring Petri Net State Spaces
DOCX
Ecet 330 final exam new 2016
PPS
Aae oop xp_06
PDF
Scalability comparison: Traditional fork-join-based parallelism vs. Goroutine...
PDF
workspace_analysis
PPTX
Compiler presention
ODT
Ecet 330 final exam new 2016
Tpr star tree
Using R in remote computer clusters
Demodulate bpsk up
Matlab bode diagram_instructions
PREDICTING THE TIME OF OBLIVIOUS PROGRAMS. Euromicro 2001
PREDICTING THE TIME OF OBLIVIOUS PROGRAMS. Euromicro 2001
09 bsc-17 dsp lab 10-1
A Polynomial-Space Exact Algorithm for TSP in Degree-5 Graphs
Semet Gecco06
Федор Поляков (Looksery) “Face Tracking на мобильных устройствах в режиме реа...
Exploring Petri Net State Spaces
Ecet 330 final exam new 2016
Aae oop xp_06
Scalability comparison: Traditional fork-join-based parallelism vs. Goroutine...
workspace_analysis
Compiler presention
Ecet 330 final exam new 2016
Ad

Similar to Model-counting Approaches For Nonlinear Numerical Constraints (20)

PDF
Quantifying Information Leaks via Model Counting Modulo Theories
PDF
Formal Verification
PPTX
Integer security analysis using smt solver
PDF
Mathematical Modeling for Practical Problems
PPTX
Puzzle-Based Automatic Testing: Bringing Humans Into the Loop by Solving Puzz...
PDF
FASTEST: Test Case Generation from Z Specifications
PDF
Model-Driven Software Verification
PPT
Interactive Proof Systems and An Introduction to PCP
PDF
Software Testing:
 A Research Travelogue 
(2000–2014)
PDF
Concurrent Bounded Model Checking
PPTX
Computer Network Homework Help
PDF
zkStudyClub - Improving performance of non-native arithmetic in SNARKs (Ivo K...
PDF
Writing a SAT solver as a hobby project
PDF
Trends In Functional Programming Henrik Nilsson
PPTX
test generation
PPTX
Keynote at IWLS 2017
PDF
Symbolic Quantitative Information Flow
PDF
A Distributed CTL Model Checker
PDF
11_winter_lecture-2023-2024————————-.pdf
PDF
Laser 3-incremental
Quantifying Information Leaks via Model Counting Modulo Theories
Formal Verification
Integer security analysis using smt solver
Mathematical Modeling for Practical Problems
Puzzle-Based Automatic Testing: Bringing Humans Into the Loop by Solving Puzz...
FASTEST: Test Case Generation from Z Specifications
Model-Driven Software Verification
Interactive Proof Systems and An Introduction to PCP
Software Testing:
 A Research Travelogue 
(2000–2014)
Concurrent Bounded Model Checking
Computer Network Homework Help
zkStudyClub - Improving performance of non-native arithmetic in SNARKs (Ivo K...
Writing a SAT solver as a hobby project
Trends In Functional Programming Henrik Nilsson
test generation
Keynote at IWLS 2017
Symbolic Quantitative Information Flow
A Distributed CTL Model Checker
11_winter_lecture-2023-2024————————-.pdf
Laser 3-incremental
Ad

More from Quoc-Sang Phan (6)

PDF
All-Solution Satisfiability Modulo Theories: applications, algorithms and ben...
PDF
Symbolic Execution as DPLL Modulo Theories
PDF
Quantifying Information Leaks using Reliability Analysis
PDF
Quantifying Information Leaks using Reliability Analysis
PDF
Towards an SMT-based approach for Quantitative Information Flow
PDF
Self-composition by Symbolic Execution
All-Solution Satisfiability Modulo Theories: applications, algorithms and ben...
Symbolic Execution as DPLL Modulo Theories
Quantifying Information Leaks using Reliability Analysis
Quantifying Information Leaks using Reliability Analysis
Towards an SMT-based approach for Quantitative Information Flow
Self-composition by Symbolic Execution

Recently uploaded (20)

PPTX
sap open course for s4hana steps from ECC to s4
PDF
Electronic commerce courselecture one. Pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Spectroscopy.pptx food analysis technology
sap open course for s4hana steps from ECC to s4
Electronic commerce courselecture one. Pdf
20250228 LYD VKU AI Blended-Learning.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Chapter 3 Spatial Domain Image Processing.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Advanced methodologies resolving dimensionality complications for autism neur...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Building Integrated photovoltaic BIPV_UPV.pdf
A Presentation on Artificial Intelligence
Unlocking AI with Model Context Protocol (MCP)
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Programs and apps: productivity, graphics, security and other tools
Spectral efficient network and resource selection model in 5G networks
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Spectroscopy.pptx food analysis technology

Model-counting Approaches For Nonlinear Numerical Constraints

  • 1. Model-counting Approaches For Nonlinear Numerical Constraints Mateus Borges1 , Sang Phan2 , Antonio Filieri1 , Corina P˘as˘areanu2,3 1Imperial College London, UK 2Carnegie Mellon University Silicon Valley, USA 3NASA Ames Research Center, USA NASA Formal Methods Symposium May 16, 2017 1 / 14
  • 2. Model Counting Applications of model counting probabilistic inference reliability analysis quantitative information flow (for side-channel analysis) . . . Integrated Symbolic Execution for Space-Time Analysis of Code. http://www.cmu.edu/silicon-valley/research/isstac 2 / 14
  • 3. Side channels H L “main” channelprogram (unintended) side channel main channel output of the program, i.e. return value side channels execution time power consumption number of packets transmitted over a network number of bytes written to a file . . . 3 / 14
  • 4. Symbolic Execution and Symbolic PathFinder 1 int x,y; 2 if(x > y){ 3 x = x + y; 4 y = x − y; 5 x = x − y; 6 if(x − y > 0) 7 assert(false); 8 } {x → X, y → Y } PC : True {x → X, y → Y } PC : X > Y {x → X + Y, y → Y } PC : X > Y {x → X + Y, y → X} PC : X > Y {x → Y, y → X} PC : X > Y {x → Y, y → X} PC : X > Y ∧ Y − X > 0 6 {x → Y, y → X} PC : X > Y ∧ Y − X ≤ 0 6 5 4 3 2 {x → X, y → Y } PC : X ≤ Y 2 Symbolic PathFinder: symbolic JVM for Java bytecode 4 / 14
  • 5. Side-channel analysis Quantifying information leaks Perform symbolic execution to collect all symbolic paths πi . Compute the observable of each symbolic path oi = cost(πi ). Compute the leakage using Shannon entropy Leakage = i=1...n p(oi ) log2 1 p(oi ) Assume the secret h has uniform distribution over the domain ΩH p(oi ) = cost(πj )=oi (πj ) |ΩH| where (πj ) is computed by using model counting tools. 5 / 14
  • 6. Motivation Most previous work limit on programs with linear numerical constraints (using Latte or barvinok). Reliability Analysis in SymbolicPathfinder. ICSE’13. Multi-run Side-Channel Analysis Using Symbolic Execution and Max-SMT. CSF’16. String Analysis for Side Channels with Segmented Oracles. FSE’16. Synthesis of Adaptive Side-Channel Attacks. CSF’17. ⇒ Model counting of path conditions for programs with nonlinear numerical constraints. 6 / 14
  • 7. Taxonomy of model counting Precision Exact counting Approximate counting Level Bit-level counting Word-level counting Others: Blocking-clause enumeration BDD-based enumerations Counting with Gr¨obner bases Brute force 7 / 14
  • 8. Evaluation setup Tool selection Publicly available implementations of model counting algorithms POC’s developed by us Fixed execution time (1 hour) Benchmark: Modular exponentiation Two distinct implementations Extracted path conditions through symbolic execution 8 / 14
  • 9. Evaluated Tools Precision Level All-SAT exact bit Dsharp exact bit SharpCDCL exact bit SharpSAT exact bit ApproxMC approximate bit SMTapproxMC approximate word Brute force exact word MathSAT exact word Z3 (blocking clause) exact word 9 / 14
  • 10. Modular Exponentiation Asymmetric cryptographic algorithms public key: (e,n) private key: d message: m encryption: c = modPow(m, e, n) decryption: m = modPow(c, d, n) Experiments with n = 1717 n = 834443 n = 1964903306 (product of two distinct prime numbers) modPow(x, y, z) = xy mod z int modPow1(int c, int d, int n){ int s = 1, y = c, res=0; while (d > 0) { if (d % 2 == 1) { //reduction: int tmp = s ∗ y; if (tmp > n){ tmp = tmp − n; } res = tmp % n; } else { res=s; } s = (res ∗ res) % n; d /= 2; } return res; } 10 / 14
  • 11. Modular Exponentiation SnapBuddy A photo-sharing web application. Given by DARPA as one of the engagement problems. public static BigInteger modPow2(final BigInteger x, final BigInteger y, final BigInteger z) { BigInteger s = BigInteger.valueOf(1L); for (int width = y.bitLength(), i = 0; i < width; ++i) { s = s.multiply(s).mod(z); if (y.testBit(width − i − 1)) { s = fastMultiply(s, x).mod(z); } } return s; } } 11 / 14
  • 12. Symbolic Execution of Modular Exponentiation modPow(x, y, z) = xy mod z Perform symbolic execution on modPow1 Both x and y are symbolic. z is either 1717, 834443, or 1964903306. modPow2 x is a concrete 1532-bit value. y is symbolic BigInteger with 40 bits. z is a concrete 1536-bit value (hard-coded in SnapBuddy) 12 / 14
  • 13. Experimental Results Subject a-1 a-2 a-3 a-4 a-5 a-6 a-7 b-1 b-2 b-3 b-4 N. Ops 11 26 15 37 121 57 117 250 243 1428 1428 Domain Size 10K 10K 10K 25M 25M 59B 59B 4T 4T 32B 32B N. Solutions 1.7K 7 1.7K 208K 109K 80M 77M 2B 66B 1 1 N. CNF clauses 40K 78K 58K 67K 114K 58K 78K 2K 2K 2K 2K Execution time BitBlasting 15s 30s 24s 25s 44s 23s 30s 1s 1s 1s 2s SharpCDCL 1s 1s 1s 43m - - - - - 1s 1s All-SAT 1s 8s 2s 31m∗ 59m∗ 15m∗ 19m∗ - - 1s 1s SharpSAT 5s 2s 11s 29m 53m - - 1s 1s 1s 1s Dsharp 12m 32s 22m - - - - 1s 1s 1s 1s ApproxMC (f) 4s 2s 5s 16s 32s 1m 1m 4s 5s 1s 1s ApproxMC (p) 4s 2s 6s 2m 5m 21m 24m 16s 25s 1s 1s SMTapproxMC (f) 6m 15m 8m - - - - - - 2m 2m SMTapproxMC (p) - 15m - - - - - - - 2m 2m MathSAT 2s 2s 5s 38m 54m - - - - 1s 1s Z3-BC 12s 3s 18s - - - - - - 1s 1s Brute Force 1s 1s 1s 1s 1s 8m 8m - - 2m 2m 13 / 14
  • 14. Conclusion Small domain: brute force! Exact counters can be effective when the problem is small (< 50K clauses) or count is close to domain size. Most promising: approximate model counting with bit-level hashing. Performance can degrade when increased precision is required. 14 / 14