Modeling Data in Formal Verification Bits, Bit Vectors, or Words Karam AbdElkader Based on: Presentations form • Randal E. Bryant - Carnegie Mellon University • Decision Procedures An Algorithmic Point of View D.Kroening – Oxsoford Unversity, O.Strichman - Technion
93
Embed
Modeling Data in Formal Verification Bits, Bit Vectors, or Words Karam AbdElkader Based on: Presentations form Randal E. Bryant - Carnegie Mellon University.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Modeling Data in Formal Verification
Bits, Bit Vectors, or Words
Karam AbdElkaderBased on: Presentations form
• Randal E. Bryant - Carnegie Mellon University• Decision Procedures An Algorithmic Point of View
• Decision procedures for Bit-Vector Logic• Flattening Bit-Vector Logic• Incremental Flattening• Bit-Vector Arithmetic With Abstraction
2
– 3 –
Issue How should data be modeled in formal analysis? Verification, test generation, security analysis, …
Approaches Bits: Every bit is represented individually
Basis for most CAD, model checking Words: View each word as arbitrary value
E.g., unbounded integersHistoric program verification work
Bit Vectors: Finite precision words
Captures true semantics of hardware and softwareMore opportunities for abstraction than with bits
Over ViewOver View
– 4 –
Data PathData Path
Com.Log.
1
Com.Log.
2
Bit-Level ModelingBit-Level Modeling
Represent Every Bit of State Individually Behavior expressed as Boolean next-state over current state Historic method for most CAD, testing, and verification tools
E.g., model checkers
Control LogicControl Logic
– 5 –
Bit-Level Modeling in PracticeBit-Level Modeling in Practice
Strengths Allows precise modeling of system Well developed technology
BDDs & SAT for Boolean reasoning
Limitations Every state bit introduces two Boolean variables
Current state & next state Overly detailed modeling of system functions
Don’t want to capture full details of FPU
Making It Work Use extensive abstraction to reduce bit count Hard to abstract functionality
– 6 –
Word-Level Abstraction #1:Bits → Integers
Word-Level Abstraction #1:Bits → Integers
View Data as Symbolic Words Arbitrary integers
No assumptions about size or encodingClassic model for reasoning about software
Can store in memories & registers
x0x1x2
xn-1
x
– 7 –
Data PathData Path
Com.Log.
1
Com.Log.
2
Abstracting Data BitsAbstracting Data Bits
Control LogicControl Logic
Data PathData Path
Com.Log.
1
Com.Log.
1? ?
What do we do about logic functions?
– 8 –
Word-Level Abstraction #2:Uninterpreted Functions
Word-Level Abstraction #2:Uninterpreted Functions
For any Block that Transforms or Evaluates Data: Replace with generic, unspecified function Only assumed property is functional consistency:
a = x b = y f (a, b) = f (x, y)
ALUf
– 9 –
Abstracting FunctionsAbstracting Functions
For Any Block that Transforms Data: Replace by uninterpreted function Ignore detailed functionality Conservative approximation of actual system
Data PathData Path
Control LogicControl Logic
Com.Log.
1
Com.Log.
1F1 F2
– 10 –
Word-Level Modeling: HistoryWord-Level Modeling: History
Historic Used by theorem provers
More Recently Burch & Dill, CAV ’94
Verify that pipelined processor has same behavior as unpipelined reference model
Use word-level abstractions of data paths and memoriesUse decision procedure to determine equivalence
Bryant, Lahiri, Seshia, CAV ’02UCLID verifierTool for describing & verifying systems at word level
– 11 –
Pipeline Verification ExamplePipeline Verification Example
Brady, TACAS ’07 Use bit blasting as core technique Apply to simplified versions of formula Successive approximations until solve or show unsatisfiable
– 68 –
Iterative Approach Background: Approximating FormulaIterative Approach Background: Approximating Formula
Example Approximation Techniques Underapproximating
Restrict word-level variables to smaller ranges of values Overapproximating
Replace subformula with Boolean variable
Original Formula
+Overapproximation + More solutions:
If unsatisfiable, then so is
Underapproximation−
−
Fewer solutions:Satisfying solution also satisfies
– 69 –
Starting IterationsStarting Iterations
Initial Underapproximation (Greatly) restrict ranges of word-level variables Intuition: Satisfiable formula often has small-domain
solution
1−
– 70 –
First Half of IterationFirst Half of Iteration
SAT Result for 1− Satisfiable
Then have found solution for Unsatisfiable
Use UNSAT proof to generate overapproximation 1+ (Described later)
1−If SAT, then done
1+
UNSAT proof:generate overapproximation
– 71 –
Second Half of IterationSecond Half of Iteration
SAT Result for 1+ Unsatisfiable
Then have shown unsatisfiable Satisfiable
Solution indicates variable ranges that must be expandedGenerate refined underapproximation
1−
If UNSAT, then done1+
SAT:Use solution to generate refined underapproximation
2−
– 72 –
ExampleExample
:= (x = y+2) ^ (x2 > y2)
1− := (x[1] = y[1]+2) ^(x[1]2 > y[1]
2)
2− := (x[2] = y[2]+2) ^ (x[2]2 > y[2]
2)
1+ := (x = y+2)
SAT, done.
UNSATLook at proof
SATx = 2, y = 0
– 73 –
Iterative BehaviorIterative Behavior
Underapproximations Successively more precise
abstractions of Allow wider variable ranges
Overapproximations No predictable relation UNSAT proof not unique
1−
1+
2−
k−
2+
k+
– 74 –
Overall EffectOverall Effect
Soundness Only terminate with solution
on underapproximation Only terminate as UNSAT on
overapproximation
Completeness Successive
underapproximations approach
Finite variable ranges guarantee termination
In worst case, get k−
1−
1+
2−
k−
2+
k+
SAT
UNSAT
– 75 –
Generating Over approximationGenerating Over approximation
Given Underapproximation 1−
Bit-blasted translation of 1− into Boolean formula
Proof that Boolean formula unsatisfiable
Generate Overapproximation 1+
If 1+ satisfiable, must lead to refined underapproximation
1−
1+
UNSAT proof:generate overapproximation
2−
– 76 –
Bit-Vector Formula StructureBit-Vector Formula Structure
DAG representation to allow shared subformulas
x + 2 z 1
x % 26 = v
w & 0xFFFF = x
x = y
Ç
Æ:
Ç
Æ
Ç
a
– 77 –
Structure of UnderapproximationStructure of Underapproximation
Linear complexity translation to CNFEach word-level variable encoded as set of Boolean variablesAdditional Boolean variables represent subformula values
x + 2 z 1
x % 26 = v
w & 0xFFFF = x
x = y
Ç
Æ:
Ç
Æ
Ç
a −
RangeConstraints
wxyz
Æ
– 78 –
Encoding Range ConstraintsEncoding Range ConstraintsExplicit
View as additional predicates in formula
Implicit Reduce number of variables in encoding
Constraint Encoding
0 w 8 0 0 0 ··· 0 w2w1w0
−4 x 4 xsxsxs··· xsxsx1x0
Yields smaller SAT encodings
RangeConstraints
w
x0 w 8 −4 x 4
– 79 –
RangeConstraints
wxyz
Æ
UNSAT ProofUNSAT Proof Subset of clauses that is unsatisfiable Clause variables define portion of DAG Sub graph that cannot be satisfied with given range
constraints
x + 2 z 1
x % 26 = v
w & 0xFFFF = x
x = y
a
Ç
Æ
Æ
Ç
Ç
:
– 80 –
Extracting Circuit from UNSAT ProofExtracting Circuit from UNSAT Proof Subgraph that cannot be satisfied with given range
constraintsEven when replace rest of graph with unconstrained
variables
x + 2 z 1
x = y
a Æ
Æ
Ç
Ç
:
b1
b2
RangeConstraints
wxyz
ÆUNSAT
– 81 –
Generated Over ApproximationGenerated Over Approximation Remove range constraints on word-level variables Creates overapproximation
Ignores correlations between values of subformulas
x + 2 z 1
x = y
a Æ
Æ
Ç
Ç
:
b1
b2
1+
– 82 –
Generated Over ApproximationAlgorithm Generated Over ApproximationAlgorithm
– 83 –
Refinement PropertyRefinement PropertyClaim
1+ has no solutions that satisfy 1−’s range constraintsBecause 1+ contains portion of 1− that was shown to be