Lec 2
Lec 2
Specification Yes
Program Verifier
Implementation
No
The same promise
Model checking
M Ψ
Ψ: Specification
M:
M satisfies Ψ ? Implementation
no yes
counter the system is correct!
example
M satisfies
Ψ
Automated Program Verification: 3
methods
Constraint Solving
Model Checking
A slightly more complex example
Program P
There are many nitty-gritty details that the tools have to face (e.g.,
heaps, stacks, strings, pointer arithmetic, recursion, concurrency,
callbacks, etc.),
Constraint Solving
Model Checking
Program Verification using Constraint
Solving
Input: Program P; Requirement R;
Procedure:
Translate P to a collection of constraints
Add a constraint for negation of R (Requirement)
Use constraint solvers to solve the constraint set
Completely automated
SAT
For any +ve input x,
Constraint
does the program ever For no +ve input x,
Solver
produce a w a witness of w <= 0
which is <= 0? is possible
UNSAT
A not so simple Example
Function f (input x, output y)
y = x + 1;
if (y < 0) then
z = 3 * y;if-then-else (y<0, 3*y, y – 2)
else z = ite(y<0, 3*y,y-2)
z = y - 2;
Endfunction
Requirement: For all positive values of x, we always have a positive z at the end
Formal Verification Query:
(x > 0) AND (y = x + 1) AND [{(y < 0) (z = 3 * y)} OR {(y >= 0) (z = y – 2)}] AND (z <= 0) + Domain
constraints
UNSAT
Using CSP for certification
Given program A and requirement R, does A satisfy R?
Option 1: prove that R holds
Option 2: provide a counter-example showing that it does not
20
CSP for Neural Networks
Can we prove that a given NN satisfies desired properties?
21
CSP for Neural Networks
Input Space I Output Space O
N
y0 Q
x0
ReLU
Certifying Neural Networks
Step 2:
Formally specify the properties of the system
A Simple Example
Encoding Networks
ReLU
ReLU
The ACAS Xu Example
Whenever the intruder is distant, network always answers Clear-of-Conflict (CoC)
5 output labels y0, y1,y2,y3,y4
For all distant inputs, score of y0 is always the highest
31
The ACAS Xu Example
P(X): Distance ≥ 40000
Other input
constraints
Distance ≥
40000
SAT
Constraint
Solver
Pixel matrix
0.1 0.0 0.8..
Input Image 0.5 0.6 0.7.. 28 X 28
(x0)
…
Y0
Y1
Y2
Y3
Y4
Y0
Y1
Y2
Y3
Y4
Other input
constraints
P(X)
SAT
Constraint
Solver
(y0(y0
≤≤y1)y1)
ORV (y0 ≤ y2) OR
V UNSAT
(y0(y0
≤≤y3)y3)
ORV (y0 ≤ y4)
Q(Y):
OR (y[i ] ≤ y[i]), where y[i ] is the desired label
i 0 0
37
All is well?
38
Constraint Solvers
SAT was the original NP-Complete Problem, but decades of research
in SAT solving has led to efficient solvers which can easily handle
thousands of variables and millions of clauses.
Constraint Solving
Model Checking
Model Checking
Model Checkers
Model Checking
For finite-state systems, Model Checking reduces the verification
problem to the reachability problem in transition systems.
Applicable if system generates (finite) behavioral model
Program P
NO
And the answer is…
To contribute to this area: Need to
know
How to extract transition system models from implementations
Software code, hardware code, concurrent systems…
https://www.amazon.science/blog/a-gentle-introduction-to-automated-reasoning
https://www.quantamagazine.org/computer-scientists-attempt-to-corner-the-collatz-conjecture-20200826/
Model Checking by Doron A. Peled, Orna Grumberg, Helmut Veith, Daniel Kroening, Edmund M. Clarke
About the course
Requires knowledge in algorithms + preliminary automata theory