Finding Minimal Unsatisfiable Cores of Declarative Specifications
Emina Torlak, Felix Chang and Daniel Jackson
Formal Methods ’08 · Turku, Finland · May 30, 2008
Finding Minimal Unsatisfiable Cores of Declarative Specifications - - PowerPoint PPT Presentation
Finding Minimal Unsatisfiable Cores of Declarative Specifications Emina Torlak, Felix Chang and Daniel Jackson Formal Methods 08 Turku, Finland May 30, 2008 Testing alone is not enough to establish correctness testing: a few cases
Finding Minimal Unsatisfiable Cores of Declarative Specifications
Emina Torlak, Felix Chang and Daniel Jackson
Formal Methods ’08 · Turku, Finland · May 30, 2008Testing alone is not enough to establish correctness …
2 testing: a few cases of arbitrary size Testing can be used to show the presence of bugs, but never to show their absence. (EWD249)
(s0 ∧ s1 ∧ … ∧ sn) ∧ ¬p
What about more systematic analyses?
3 model finding and bmc: all cases within a small scope theorem proving and model checking: all cases
system property(s0 ∧ s1 ∧ … ∧ sn) ∧ ¬p
What about more systematic analyses?
3 model finding and bmc: all cases within a small scope theorem proving and model checking: all cases
system propertyif ∧ ¬ is unsatisfiable, is the system correct?
(s0 ∧ s1 ∧ … ∧ sn) ∧ ¬p
What about more systematic analyses?
3 model finding and bmc: all cases within a small scope theorem proving and model checking: all cases the scope may be too small
(s0 ∧ s1 ∧ … ∧ sn) ∧ ¬p
What about more systematic analyses?
3 model finding and bmc: all cases within a small scope theorem proving and model checking: all cases the scope may be too small the system may be too constrained
(s0 ∧ s1 ∧ … ∧ sn) ∧ ¬p
What about more systematic analyses?
3 model finding and bmc: all cases within a small scope theorem proving and model checking: all cases the scope may be too small the system may be too constrained the property may be too weak
(s0 ∧ s1 ∧ … ∧ sn) ∧ ¬p
What about more systematic analyses?
3 model finding and bmc: all cases within a small scope theorem proving and model checking: all cases the scope may be too small the system may be too constrained the property may be too weak
may succeed for the wrong reasons
Expected coverage vs. proof coverage
4 user’s expectation of coverage: “most of” F0 … F3 needed to establish F5. expected coverage how to check if the analysis worked as expected?
F0 F1 F2 F3 F4 F5Expected coverage vs. proof coverage
4 user’s expectation of coverage: “most of” F0 … F3 needed to establish F5. minimal unsatisfiable core: an unsatisfiable subset of the
becomes satisfiable if any of its members are removed. expected coverage proof coverage how to check if the analysis worked as expected? show proof coverage!
F0 F1 F2 F3 F4 F5 F0 F1 F2 F3 F4 F5Exposing coverage bugs with minimal unsatisfiable cores
5 expected coverage axioms too strong property too weak success! minimal cores
property F0 F1 F2 F3 F4 F5 F0 F1 F2 F3 F4 F5 F0 F1 F2 F3 F4 F5 F0 F1 F2 F3 F4 F5Example: minimal cores in Alloy
sig File { } sig Dir { contents: set File + Dir }
fact hierarchy { no contents.Root File + Dir in Root.*contents all obj: File + Dir | one contents.obj } check { all d: Dir | not d in d.^contents } 6
Dir Root File
contents contentsRoot is a singleton subset of Dir. Dir and File are sets. contents maps directories to files or directories.
Example: minimal cores in Alloy
sig File { } sig Dir { contents: set File + Dir }
fact hierarchy { no contents.Root File + Dir in Root.*contents all obj: File + Dir | one contents.obj } check { all d: Dir | not d in d.^contents } 6
Root has no parent.
Example: minimal cores in Alloy
7 sig File { } sig Dir { contents: set File + Dir }
fact hierarchy { no contents.Root File + Dir in Root.*contents all obj: File + Dir | one contents.obj } check { all d: Dir | not d in d.^contents }
Everything is reachable from the Root. sig File { } sig Dir { contents: set File + Dir }
fact hierarchy { no contents.Root File + Dir in Root.*contents all obj: File + Dir | one contents.obj } check { all d: Dir | not d in d.^contents }
Example: minimal cores in Alloy
8
Every file and directory has one parent.
Example: minimal cores in Alloy
9 sig File { } sig Dir { contents: set File + Dir }
fact hierarchy { no contents.Root File + Dir in Root.*contents all obj: File + Dir | one contents.obj } check { all d: Dir | not d in d.^contents }
Check that the containment hierarchy is acyclic.
sig File { } sig Dir { contents: set File + Dir }
fact hierarchy { no contents.Root File + Dir in Root.*contents all obj: File + Dir | one contents.obj } check { all d: Dir | not d in d.^contents }
Example: minimal cores in Alloy
10
Root has no parent. Every file and directory has one parent. sig File { } sig Dir { contents: set File + Dir }
fact hierarchy { no contents.Root File + Dir in Root.*contents all obj: File + Dir | one contents.obj } check { all d: Dir | not d in d.^contents }
Example: minimal cores in Alloy
11
Root has no parent. Every file and directory has one parent. sig File { } sig Dir { contents: set File + Dir }
fact hierarchy { no contents.Root File + Dir in Root.*contents all obj: File + Dir | one contents.obj } check { all d: Dir | not d in d.^contents }
Example: minimal cores in Alloy
11
axioms too strong
Root has no parent. Every file and directory has one parent. sig File { } sig Dir { contents: set File + Dir }
fact hierarchy { no contents.Root File + Dir in Root.*contents all obj: File + Dir | one contents.obj } check { all d: Dir | not d in d.^contents }
Example: minimal cores in Alloy
11
axioms too strong
at most lone
sig File { } sig Dir { contents: set File + Dir }
fact hierarchy { no contents.Root File + Dir in Root.*contents all obj: File + Dir | lone contents.obj } check { all d: Dir | not d in d.^contents }
Example: minimal cores in Alloy
12
success!
A resolution-based analysis framework
13 constraints cnf resolution refutation
F0 F1 F2 F3 F4 F5translate constraints to a clausal logic and use a resolution engine to determine (un)satisfiability
F0 F1 F2 F3 F4 F5 minimal core constraint irrelevant constraint translation clause resolvent (learned) clause conflict resolution relation translation relation unsatisfiable coreMinimal cores in a resolution-based analysis framework
14
F0 F1 F2 F3 F4 F5 F0 F1 F2 F3 F4 F5challenge
how to use the proof at the clause level to find a minimal core at the specification level when
specification core constraints cnf resolution refutation
Minimal cores in a resolution-based analysis framework
14
F0 F1 F2 F3 F4 F5 F0 F1 F2 F3 F4 F5challenge
how to use the proof at the clause level to find a minimal core at the specification level when
specification core constraints cnf resolution refutation
naive core extraction
easy problemsMinimal cores in a resolution-based analysis framework
14
F0 F1 F2 F3 F4 F5 F0 F1 F2 F3 F4 F5challenge
how to use the proof at the clause level to find a minimal core at the specification level when
specification core constraints cnf resolution refutation
naive core extraction simple core extraction
easy problems medium problemsMinimal cores in a resolution-based analysis framework
14
F0 F1 F2 F3 F4 F5 F0 F1 F2 F3 F4 F5challenge
how to use the proof at the clause level to find a minimal core at the specification level when
specification core constraints cnf resolution refutation
naive core extraction simple core extraction recycling core extraction
easy problems medium problems hard problemsNaive core extraction (NCE): prune constraints one at a time
15
Naive core extraction (NCE): prune constraints one at a time
15 K
Naive core extraction (NCE): prune constraints one at a time
15 K
Naive core extraction (NCE): prune constraints one at a time
15 K c
F0K´
Naive core extraction (NCE): prune constraints one at a time
15 K c G
F0K´
Naive core extraction (NCE): prune constraints one at a time
15 K c G
F0K´
Naive core extraction (NCE): prune constraints one at a time
16 K
F0 F1 F3 F5 F4 F0Naive core extraction (NCE): prune constraints one at a time
16 K c
F0 F1 F3 F5 F4 F0 F2K´
Naive core extraction (NCE): prune constraints one at a time
16 K G c
F0 F1 F3 F5 F4 F0 F2K´
Naive core extraction (NCE): prune constraints one at a time
16 K G c
F0 F1 F3 F5 F4 F0 F2K´
Naive core extraction (NCE): prune constraints one at a time
16 K G c
F0 F1 F3 F5 F4 F0 F2K´
Naive core extraction (NCE): prune constraints one at a time
16 K G
F0 F1 F3 F5 F4 F0 F2K´
K { F0 … Fn } M {} K yes no G solve(K') ! ∈ G no K K' yes K ⊆ M M M ∪ {c} c choose(K \ M) K' K \ {c}From naive to simple core extraction: using the core clauses
17 K G
F0 F1 F3 F5 F4 F0 F2c
K´
K { F0 … Fn } M {} K yes no G solve(K') ! ∈ G no K K' yes K ⊆ M M M ∪ {c} c choose(K \ M) K' K \ {c}From naive to simple core extraction: using the core clauses
17 K G
F0 F1 F3 F5 F4 F0F4 not needed to prove the unsatisfiability
c
Simple core extraction (SCE)
18
F0 F1 F3 F5 F2 F4Simple core extraction (SCE)
18
F0 F1 F3 F5 F2 F4G
Simple core extraction (SCE)
18
F0 F1 F3 F5 F2 F4G K
Simple core extraction (SCE)
18
F0 F1 F3 F5 F2 F4K G
Simple core extraction (SCE)
18
F0 F1 F3 F5 F2 F4K G c
F2K´
Simple core extraction (SCE)
18
F0 F1 F3 F5 F2 F4K G c
F2G´ K´
Simple core extraction (SCE)
18
F0 F1 F3 F5 F2 F4K G c
F2G´ K´
Simple core extraction (SCE)
18
F0 F1 F3 F5 F2 F4K c
F2G K´
Simple core extraction (SCE)
18
F0 F1 F3 F5 F2 F4K
F2G
From simple to recycling core extraction: using the resolvents
19 K c
F2G´ G
F0 F1 F3 F5 F4K´
From simple to recycling core extraction: using the resolvents
19 K c
F2G´ G Re-deriving clauses already learned for G.
F0 F1 F3 F5 F4K´
Recycling core extraction (RCE)
20
F0 F1 F3 F5 F2 F4Recycling core extraction (RCE)
20
F0 F1 F3 F5 F2 F4G
Recycling core extraction (RCE)
20
F0 F1 F3 F5 F2 F4G K
Recycling core extraction (RCE)
20
F0 F1 F3 F5 F2 F4G K
K´
Recycling core extraction (RCE)
20
F0 F1 F3 F5 F2 F4G K c
F2K´
Recycling core extraction (RCE)
20
F0 F1 F3 F5 F2 F4G K c
F2learnable(K´, G)
K´
Recycling core extraction (RCE)
20
F0 F1 F3 F5 F2 F4G K G c
F2´ Resolvents of G are sources of G´.
K´
Recycling core extraction (RCE)
20
F0 F1 F3 F5 F2 F4G K G c
F2´ Resolvents of G are sources of G´.
K´
Recycling core extraction (RCE)
20
F0 F1 F3 F5 F2 F4G K G c
F2´ Resolvents of G are sources of G´.
K´
Recycling core extraction (RCE)
20
F0 F1 F3 F5 F2 F4G K G c
F2´ fix(G´, G)
K´
Recycling core extraction (RCE)
20
F0 F1 F3 F5 F2 F4G K c
F2Recycling core extraction (RCE)
20
F0 F1 F3 F5 F2 F4G K
F2Simple / Recycling Log Plot
NUM374 SET943 SET967 Trees COM008 Hotel RingElection ALG212 Lists.empties LAT258 Lists.symmetric GEO092 Lists.reflexive SET948 GEO158 GEO159 TOP020 GEO115 GEO091 MED007 MED009Naive / Recycling Log Plot
Experimental results
21
90.00 29.22 9.49 3.08 0.00 1.48x 2.45x 29.04x 50.00 18.80 7.07 2.66 0.00 1.08x 1.27x 18.41x easy problems medium problems hard problemsConclusions and future work
22
M a y 3 , 2 8
kodkod with RCE Alloy4 ConfigAssure
core extraction
coverage analysis of hand-crafted formal models
heuristics and some imprecision
Kodkod such as code checking (Forge) and declarative configuration (configAssure)
http://web.mit.edu/emina/www/kodkod.html http://alloy.mit.edu/
kodkod.jar SAT binaries javadocs papers examples alloy4.jar tutorial papers courses case studies