ITPsession2 A PDF
ITPsession2 A PDF
Algorithm
Experimental Evaluation
1 / 101
Introduction
Algorithm
Experimental Evaluation
Motivation
Teaching freshmen how to reason about programs using ACL2s .
2 / 101
Introduction
Algorithm
Experimental Evaluation
Motivation
Teaching freshmen how to reason about programs using ACL2s Success of QuickCheck .
C .
rexa ounte
mple
s!!
3 / 101
Introduction
Algorithm
Experimental Evaluation
Motivation
Teaching freshmen how to reason about programs using ACL2s Success of QuickCheck Combining testing and theorem-proving (ACL2 2011 Workshop) .
C .
rexa ounte
mple
s!!
4 / 101
Introduction
Algorithm
Experimental Evaluation
Motivation
Teaching freshmen how to reason about programs using ACL2s Success of QuickCheck Combining testing and theorem-proving (ACL2 2011 Workshop) Can we do even better? .
C .
rexa ounte
mple
s!!
5 / 101
Introduction
Algorithm
Experimental Evaluation
Motivation
Teaching freshmen how to reason about programs using ACL2s Success of QuickCheck Combining testing and theorem-proving (ACL2 2011 Workshop) Can we do even better? Apply technology behind ACL2 to help the regular programmer .
C .
rexa ounte
mple
s!!
6 / 101
Introduction
Algorithm
Experimental Evaluation
Motivation
Teaching freshmen how to reason about programs using ACL2s Success of QuickCheck Combining testing and theorem-proving (ACL2 2011 Workshop) Can we do even better? Apply technology behind ACL2 to help the regular programmer .
C .
rexa ounte
mple
s!!
.
7 / 101
Introduction
Algorithm
Experimental Evaluation
Overview
Goal
Analyse specifications - Find counterexamples!
8 / 101
Introduction
Algorithm
Experimental Evaluation
Overview
Goal
Analyse specifications - Find counterexamples!
The problem
What to do when the Search Procedure doesnt return an answer?
9 / 101
Introduction
Algorithm
Experimental Evaluation
Overview
Goal
Analyse specifications - Find counterexamples!
QuickCheck .
The problem
What to do when the Search Procedure doesnt return an answer?
10 / 101
Introduction
Algorithm
Experimental Evaluation
Overview
Goal
Analyse specifications - Find counterexamples!
QuickCheck .
The problem
What to do when the Search Procedure doesnt return an answer?
Decision Procedure .
Constraint Solver .
11 / 101
Introduction
Algorithm
Experimental Evaluation
Overview
Goal
Analyse specifications - Find counterexamples!
QuickCheck .
The problem
What to do when the Search Procedure doesnt return an answer?
Decision Procedure .
Constraint Solver .
12 / 101
Introduction
Algorithm
Experimental Evaluation
Property P .
Is P false? .
13 / 101
Introduction
Algorithm
Experimental Evaluation
Property P .
Is P false? .
Yes .
14 / 101
Introduction
Algorithm
Experimental Evaluation
. Yes .
Property P .
Is P false? .
15 / 101
Introduction
Algorithm
Experimental Evaluation
Property P .
Is P false? .
Dont Know .
16 / 101
Introduction
Algorithm
Experimental Evaluation
. Dont Know .
Property P .
Is P false? .
17 / 101
Introduction
Algorithm
Experimental Evaluation
Property P .
Is P false? .
18 / 101
Introduction
Algorithm
Experimental Evaluation
19 / 101
Introduction
Algorithm
Experimental Evaluation
Is P false? .
20 / 101
Introduction
Algorithm
Experimental Evaluation
21 / 101
Introduction
Algorithm
Experimental Evaluation
22 / 101
Introduction
Algorithm
Experimental Evaluation
23 / 101
Introduction
Algorithm
Experimental Evaluation
Inconsistent?
24 / 101
Introduction
Algorithm
Experimental Evaluation
Is P false? . Backtrack!! .
25 / 101
Introduction
Algorithm
Experimental Evaluation
Is P false? .
Is P' false? .
26 / 101
Introduction
Algorithm
Experimental Evaluation
Is P true? .
P .
27 / 101
Introduction
Algorithm
Experimental Evaluation
Yes .
Is P true? .
P .
28 / 101
Introduction
Algorithm
Experimental Evaluation
Is P true? .
P .
29 / 101
Introduction
Algorithm
Experimental Evaluation
Dont Know .
Is P true? .
P .
30 / 101
Introduction
Algorithm
Experimental Evaluation
Is P true? .
P .
31 / 101
Introduction
Algorithm
Experimental Evaluation
Is P true? .
P .
. p1 . p2 . . . . pn .
32 / 101
Introduction
Algorithm
Experimental Evaluation
Is P false? .
Is P true? .
P .
. p1 . p2 . . . . pn .
33 / 101
Introduction
Algorithm
Experimental Evaluation
Assumptions
Specification language L
Multi-sorted first-order logic Extensible Executable
34 / 101
Introduction
Algorithm
Experimental Evaluation
Assumptions
Specification language L
Multi-sorted first-order logic Extensible Executable
35 / 101
Introduction
Algorithm
Experimental Evaluation
Assumptions
Specification language L
Multi-sorted first-order logic Extensible -- can introduce new function and predicate symbols using well-founded recursive definitions Executable
36 / 101
Introduction
Algorithm
Experimental Evaluation
Assumptions
Specification language L
Multi-sorted first-order logic Extensible Executable
37 / 101
Introduction
Algorithm
Experimental Evaluation
Assumptions
Specification language L
Multi-sorted first-order logic Extensible Executable
38 / 101
Introduction
Algorithm
Experimental Evaluation
Assumptions
Specification language L
Multi-sorted first-order logic Extensible Executable
39 / 101
Introduction
Algorithm
Experimental Evaluation
Assumptions
Specification language L
Multi-sorted first-order logic Extensible Executable
40 / 101
Introduction
Algorithm
Experimental Evaluation
Assumptions
Specification language L
Multi-sorted first-order logic Extensible Executable
41 / 101
Introduction
Algorithm
Experimental Evaluation
Assumptions
Specification language L
Multi-sorted first-order logic Extensible Executable
42 / 101
Introduction
Algorithm
Experimental Evaluation
Example
Select ? .
P .
. x + y = v2
z > 10 w < min(x, y) w < z
A . .
43 / 101
Introduction
Algorithm
Experimental Evaluation
Example
Select ? .
X .
P .
W .
Y .
. x + y = v2
z > 10 w < min(x, y) w < z
A . .
44 / 101
Introduction
Algorithm
Experimental Evaluation
Example
Select ? .
X .
P .
W .
Y .
W . V .
. x + y = v2
z > 10 w < min(x, y) w < z
Rest dependency G .
A . .
45 / 101
Introduction
Algorithm
Experimental Evaluation
Example
Select z .
X .
P .
W .
Y .
W . V .
. x + y = v2
z > 10 w < min(x, y) w < z
Rest dependency G .
A . .
46 / 101
Introduction
Algorithm
Experimental Evaluation
Example
Assign ? .
X .
P .
W .
Y .
W . V .
. x + y = v2
z > 10 w < min(x, y) w < z
Rest dependency G .
A . .
47 / 101
Introduction
Algorithm
Experimental Evaluation
Example
Assign z = 34 (decision) .
. P' .
Property x = hash(y) y = hash(34) x + y = v2 w < min(x, y)
A . .
w < 34
48 / 101
Introduction
Algorithm
Experimental Evaluation
Example
Propagate with Simplify .
. P' .
Property x = hash(y) y = hash(34) x + y = v2 w < min(x, y)
A . .
w < 34
49 / 101
Introduction
Algorithm
Experimental Evaluation
Example
Propagate with Simplify .
P' .
A . .
50 / 101
Introduction
Algorithm
Experimental Evaluation
Example
Inconsistent? .
P' .
A . .
51 / 101
Introduction
Algorithm
Experimental Evaluation
Example
Update Assignment .
P' .
z = 34 A . .
52 / 101
Introduction
Algorithm
Experimental Evaluation
53 / 101
Introduction
Algorithm
Experimental Evaluation
54 / 101
Introduction
Algorithm
Experimental Evaluation
55 / 101
Introduction
Algorithm
Experimental Evaluation
56 / 101
Introduction
Algorithm
Experimental Evaluation
57 / 101
Introduction
Algorithm
Experimental Evaluation
58 / 101
Introduction
Algorithm
Experimental Evaluation
59 / 101
Introduction
Algorithm
Experimental Evaluation
60 / 101
Introduction
Algorithm
Experimental Evaluation
61 / 101
Introduction
Algorithm
Experimental Evaluation
62 / 101
Introduction
Algorithm
Experimental Evaluation
63 / 101
Introduction
Algorithm
Experimental Evaluation
Search Algorithm
Input: Property P with at least one free variable Output: A counterexample (assignment) or fail local Stack A of (var, val, # assigns, type, property) Initialize and Select first variable Iteratively construct counterexample or fail
Introduction
Algorithm
Experimental Evaluation
Search Algorithm
Input: Property P with at least one free variable Output: A counterexample (assignment) or fail local Stack A of (var, val, # assigns, type, property) Initialize and Select first variable Iteratively construct counterexample or fail
Introduction
Algorithm
Experimental Evaluation
Search Algorithm
Input: Property P with at least one free variable Output: A counterexample (assignment) or fail local Stack A of (var, val, # assigns, type, property) A, i, x := [], 0, Select(P) Iteratively construct counterexample or fail
Introduction
Algorithm
Experimental Evaluation
Search Algorithm
Input: Property P with at least one free variable Output: A counterexample (assignment) or fail local Stack A of (var, val, # assigns, type, property) A, i, x := [], 0, Select(P) Iteratively construct counterexample or fail
Introduction
Algorithm
Experimental Evaluation
Search Algorithm
Input: Property P with at least one free variable Output: A counterexample (assignment) or fail local Stack A of (var, val, # assigns, type, property) A, i, x := [], 0, Select(P) while true do v, t := Assign(x, P) . P := Propagate(x, v, P) if inconsistent(P ) then Extend A, continue search if not done else if A = [] then backtrack fail if ... .
68 / 101
Introduction
Algorithm
Experimental Evaluation
Search Algorithm
Input: Property P with at least one free variable Output: A counterexample (assignment) or fail local Stack A of (var, val, # assigns, type, property) A, i, x := [], 0, Select(P) while true do v, t := Assign(x, P) . P := Propagate(x, v, P) if inconsistent(P ) then Extend A, continue search if not done else if A = [] then backtrack fail if ... .
69 / 101
Introduction
Algorithm
Experimental Evaluation
Search Algorithm
Input: Property P with at least one free variable Output: A counterexample (assignment) or fail local Stack A of (var, val, # assigns, type, property) A, i, x := [], 0, Select(P) while true do v, t := Assign(x, P) . P := Propagate(x, v, P) if inconsistent(P ) then Extend A, continue search if not done else if A = [] then backtrack fail if ... .
70 / 101
Introduction
Algorithm
Experimental Evaluation
Search Algorithm
Input: Property P with at least one free variable Output: A counterexample (assignment) or fail local Stack A of (var, val, # assigns, type, property) A, i, x := [], 0, Select(P) while true do v, t := Assign(x, P) . P := Propagate(x, v, P) if inconsistent(P ) then Extend A, continue search if not done else if A = [] then backtrack fail if ... .
71 / 101
Introduction
Algorithm
Experimental Evaluation
Search Algorithm
Input: Property P with at least one free variable Output: A counterexample (assignment) or fail local Stack A of (var, val, # assigns, type, property) A, i, x := [], 0, Select(P) while true do v, t := Assign(x, P) P := Propagate(x, v, P) if inconsistent(P ) then . if t = ``decision" then i := i + 1 A := push((x, v, i, t, P), A) if A is complete then return A i, P, x := 0, P , Select(P ) else if A = [] then backtrack fail if ... .
72 / 101
Introduction
Algorithm
Experimental Evaluation
Search Algorithm
Input: Property P with at least one free variable Output: A counterexample (assignment) or fail local Stack A of (var, val, # assigns, type, property) A, i, x := [], 0, Select(P) while true do v, t := Assign(x, P) . P := Propagate(x, v, P) if inconsistent(P ) then Extend A, continue search if not done else if A = [] then backtrack fail if ... .
73 / 101
Introduction
Algorithm
Experimental Evaluation
Search Algorithm
Input: Property P with at least one free variable Output: A counterexample (assignment) or fail local Stack A of (var, val, # assigns, type, property) A, i, x := [], 0, Select(P) while true do v, t := Assign(x, P) P := Propagate(x, v, P) if inconsistent(P ) then . Extend A, continue search if not done else if A = [] then repeat (x, , i, t, P) := head(A) A := pop(A) until (t = ``decision" i blimit) A = [] fail if ... .
74 / 101
Introduction
Algorithm
Experimental Evaluation
Search Algorithm
Input: Property P with at least one free variable Output: A counterexample (assignment) or fail local Stack A of (var, val, # assigns, type, property) A, i, x := [], 0, Select(P) while true do v, t := Assign(x, P) . P := Propagate(x, v, P) if inconsistent(P ) then Extend A, continue search if not done else if A = [] then backtrack fail if ... .
75 / 101
Introduction
Algorithm
Experimental Evaluation
Search Algorithm
Input: Property P with at least one free variable Output: A counterexample (assignment) or fail local Stack A of (var, val, # assigns, type, property) A, i, x := [], 0, Select(P) while true do v, t := Assign(x, P) P := Propagate(x, v, P) . if inconsistent(P ) then Extend A, continue search if not done else if A = [] then backtrack if A = [] (t = ``implied" i > blimit) then return fail .
76 / 101
Introduction
Algorithm
Experimental Evaluation
Select Algorithm
Input: Property P with at least one free variable Output: A free variable in P . . if h hyps(P) of form x = c then return x
77 / 101
Introduction
Algorithm
Experimental Evaluation
Select Algorithm
Input: Property P with at least one free variable Output: A free variable in P . . if h hyps(P) of form x = c then return x
78 / 101
Introduction
Algorithm
Experimental Evaluation
Select Algorithm
Input: Property P with at least one free variable Output: A free variable in P . if h hyps(P) of form x = c then return x . G= := EqualityDependencyGraph(P, vars(P))
1. Case: x = y. Add x y.
79 / 101
Introduction
Algorithm
Experimental Evaluation
Select Algorithm
Input: Property P with at least one free variable Output: A free variable in P if h hyps(P) of form x = c then return x . G= := EqualityDependencyGraph(P, vars(P)) Do SCC on G= , collect the leaf components in L leaves = := pick x from each l L .
80 / 101
Introduction
Algorithm
Experimental Evaluation
Select Algorithm
Input: Property P with at least one free variable Output: A free variable in P if h hyps(P) of form x = c then return x . G= := EqualityDependencyGraph(P, vars(P)) SCC on G= . G := RestDependencyGraph(P, leaves= )
1. x
y where
Introduction
Algorithm
Experimental Evaluation
Select Algorithm
Input: Property P with at least one free variable Output: A free variable in P if h hyps(P) of form x = c then return x . G= := EqualityDependencyGraph(P, vars(P)) SCC on G= G := RestDependencyGraph(P, leaves= ) . Do SCC on G to get dag D
82 / 101
Introduction
Algorithm
Experimental Evaluation
Select Algorithm
Input: Property P with at least one free variable Output: A free variable in P if h hyps(P) of form x = c then return x G= := EqualityDependencyGraph(P, vars(P)) . SCC on G= G := RestDependencyGraph(P, leaves= ) Do SCC on G to get dag D X := the leaf in D with maximum i= value . return X
i= (x) denotes number of nodes that can reach it in G= . i= (X) denotes max value of i= among nodes X
83 / 101
Introduction
Algorithm
Experimental Evaluation
84 / 101
Introduction
Algorithm
Experimental Evaluation
Primary Concern
Avoid resource conflicts (Data/Control hazards)
85 / 101
Introduction
Algorithm
Experimental Evaluation
Primary Concern
Avoid resource conflicts (Data/Control hazards)
Correctness
Show all behaviors of MA are observationally equivalent to behaviors of ISA
86 / 101
Introduction
Algorithm
Experimental Evaluation
Correctness
Show all behaviors of MA are observationally equivalent to behaviors of ISA
87 / 101
Introduction
Algorithm
Experimental Evaluation
Correctness
Show all behaviors of MA are observationally equivalent to behaviors of ISA
Introduction
Algorithm
Experimental Evaluation
Automatic Analysis
Given a bound on # model elements, called scope, Alloy models (and its specifications) translated into Boolean formulas and shipped to off-the-shelf SAT solvers.
89 / 101
Introduction
Algorithm
Experimental Evaluation
90 / 101
Introduction
Algorithm
Experimental Evaluation
Introduction
Algorithm
Experimental Evaluation
92 / 101
Introduction
Algorithm
Experimental Evaluation
93 / 101
Introduction
Algorithm
Experimental Evaluation
.
94 / 101
Introduction
Algorithm
Experimental Evaluation
.
95 / 101
Introduction
Algorithm
Experimental Evaluation
.
96 / 101
Introduction
Algorithm
Experimental Evaluation
.
97 / 101
Introduction
Algorithm
Experimental Evaluation
.
98 / 101
Introduction
Algorithm
Experimental Evaluation
Conclusions
Automatically analyze properties, interleaving ITP and testing in a fine-grained fashion Search algorithm guides testing when it is stuck (Decision Procedures can also benefit) Select algorithm can be used as a starting point by concolic testing Combining automated methods with ITP technology results in a more powerful, yet automated method. Better interactive theorem proving experience
99 / 101
Introduction
Algorithm
Experimental Evaluation
The End
Thank you
100 / 101