Transcript
Page 1: Decision methods for arithmetic Third summer school on formal methods

Decision methods for arithmeticThird summer school on formal methods

Leonardo de Moura Microsoft Research

Page 2: Decision methods for arithmetic Third summer school on formal methods

Software analysis/verification tools need some form of symbolic reasoning

Symbolic Reasoning

Logic is β€œThe Calculus of Computer Science”Zohar Manna

Page 3: Decision methods for arithmetic Third summer school on formal methods

Saturation x Search

Proof-finding Model-finding

Models

Proo

fsConflict

Resolution

Page 4: Decision methods for arithmetic Third summer school on formal methods

SAT

CNF is a set (conjunction) set of clausesClause is a disjunction of literalsLiteral is an atom or the negation of an atom

Page 5: Decision methods for arithmetic Third summer school on formal methods

Two procedures

Resolution DPLLProof-finder Model-finderSaturation Search

Page 6: Decision methods for arithmetic Third summer school on formal methods

Resolution

ImprovementsDelete tautologies Ordered ResolutionSubsumption (delete redundant clauses)

…

unsat

Page 7: Decision methods for arithmetic Third summer school on formal methods

Resolution: Example

Page 8: Decision methods for arithmetic Third summer school on formal methods

Resolution: Example

Page 9: Decision methods for arithmetic Third summer school on formal methods

Resolution: Example

Page 10: Decision methods for arithmetic Third summer school on formal methods

Resolution: Example

Page 11: Decision methods for arithmetic Third summer school on formal methods

Resolution: Example

Page 12: Decision methods for arithmetic Third summer school on formal methods

Resolution: Problem

Exponential time and space

Page 13: Decision methods for arithmetic Third summer school on formal methods

Unit Resolution

Complete for Horn Clauses

subsumes

Page 14: Decision methods for arithmetic Third summer school on formal methods

DPLL

DPLL = Unit Resolution + Split rule

Split rule

𝑆 ,𝑝 𝑆 ,¬𝑝

Page 15: Decision methods for arithmetic Third summer school on formal methods

DPLLπ‘₯∨ 𝑦 ,Β¬π‘₯βˆ¨π‘¦ , π‘₯∨¬ 𝑦 ,Β¬π‘₯∨¬ 𝑦

Page 16: Decision methods for arithmetic Third summer school on formal methods

DPLLπ‘₯∨ 𝑦 ,Β¬π‘₯βˆ¨π‘¦ , π‘₯∨¬ 𝑦 ,Β¬π‘₯∨¬ 𝑦

Page 17: Decision methods for arithmetic Third summer school on formal methods

DPLLπ‘₯∨ 𝑦 ,Β¬π‘₯βˆ¨π‘¦ , π‘₯∨¬ 𝑦 ,Β¬π‘₯∨¬ 𝑦

Page 18: Decision methods for arithmetic Third summer school on formal methods

DPLLπ‘₯∨ 𝑦 ,Β¬π‘₯βˆ¨π‘¦ , π‘₯∨¬ 𝑦 ,Β¬π‘₯∨¬ 𝑦

Page 19: Decision methods for arithmetic Third summer school on formal methods

DPLLπ‘₯∨ 𝑦 ,Β¬π‘₯βˆ¨π‘¦ , π‘₯∨¬ 𝑦 ,Β¬π‘₯∨¬ 𝑦

Page 20: Decision methods for arithmetic Third summer school on formal methods

DPLLπ‘₯∨ 𝑦 ,Β¬π‘₯βˆ¨π‘¦ , π‘₯∨¬ 𝑦 ,Β¬π‘₯∨¬ 𝑦

Page 21: Decision methods for arithmetic Third summer school on formal methods

CDCL: Conflict Driven Clause Learning

Resolution

DPLLConflict

Resolution

Proof

Model

Page 22: Decision methods for arithmetic Third summer school on formal methods

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

Page 23: Decision methods for arithmetic Third summer school on formal methods

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2

Propagations

Page 24: Decision methods for arithmetic Third summer school on formal methods

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2

Propagations

π‘₯β‰₯1

Page 25: Decision methods for arithmetic Third summer school on formal methods

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2

Propagations

π‘₯β‰₯1 𝑦 β‰₯1

Page 26: Decision methods for arithmetic Third summer school on formal methods

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2

Decisions

π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1

Page 27: Decision methods for arithmetic Third summer school on formal methods

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2

Model Assignments

π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1π‘₯β†’2

Page 28: Decision methods for arithmetic Third summer school on formal methods

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2

Model Assignments

π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1π‘₯β†’2

We can’t falsify any fact in the trail.

Page 29: Decision methods for arithmetic Third summer school on formal methods

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2

Conflict

π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1π‘₯β†’2

We can’t find a value of s.t.

Page 30: Decision methods for arithmetic Third summer school on formal methods

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2

Conflict

π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1π‘₯β†’2

We can’t find a value of s.t.

Learning that = 2)is not productive

Page 31: Decision methods for arithmetic Third summer school on formal methods

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2

Conflict

π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1π‘₯β†’2

𝑦

π‘₯

π‘₯2+ 𝑦2≀1 π‘₯β†’2

βˆ’1≀ π‘₯ , π‘₯≀1

Β¬(π‘₯2+ 𝑦2≀1)∨π‘₯≀1

Page 32: Decision methods for arithmetic Third summer school on formal methods

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1 π‘₯≀1

Β¬(π‘₯2+𝑦2≀1)∨π‘₯≀1

Page 33: Decision methods for arithmetic Third summer school on formal methods

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1 π‘₯≀1

Β¬(π‘₯2+𝑦2≀1)∨π‘₯≀1ConflictΒ¬ (π‘₯β‰₯2 )∨¬(π‘₯≀1)

Page 34: Decision methods for arithmetic Third summer school on formal methods

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1

Β¬(π‘₯2+𝑦2≀1)∨π‘₯≀1Learned by resolutionΒ¬ (π‘₯β‰₯2 )∨¬(π‘₯2+𝑦2≀1)

Page 35: Decision methods for arithmetic Third summer school on formal methods

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1Β¬(π‘₯2+𝑦2≀1)

Β¬(π‘₯2+𝑦2≀1)∨π‘₯≀1Β¬ (π‘₯β‰₯2 )∨¬(π‘₯2+𝑦2≀1)

Page 36: Decision methods for arithmetic Third summer school on formal methods

MCSat – Finite BasisEvery theory that admits quantifier elimination has a finite basis (given a fixed assignment order)

𝐹 [π‘₯1 ,…,π‘₯𝑛 , 𝑦1 ,…, π‘¦π‘š]

βˆƒπ‘₯1 ,…, π‘₯𝑛 :𝐹 [π‘₯1 ,…,π‘₯𝑛 , 𝑦 ]

𝐢1[𝑦1 ,…, π‘¦π‘š]βˆ§β€¦βˆ§πΆπ‘˜[𝑦1 ,…, π‘¦π‘š ]

¬𝐹 [π‘₯1 ,…,π‘₯𝑛 , 𝑦1 ,…, π‘¦π‘š ]βˆ¨πΆπ‘˜[𝑦1 ,…, π‘¦π‘š]

Page 37: Decision methods for arithmetic Third summer school on formal methods

MCSat – Finite Basis

𝐹 1[π‘₯1]

𝐹 2[π‘₯1 ,π‘₯2]

𝐹 𝑛[π‘₯1 ,π‘₯2,…, π‘₯π‘›βˆ’1 ,π‘₯𝑛]

𝐹 π‘›βˆ’1[π‘₯1 ,π‘₯2 ,…, π‘₯π‘›βˆ’1]…

Page 38: Decision methods for arithmetic Third summer school on formal methods

MCSat – Finite Basis

𝐹 1[π‘₯1]

𝐹 2[π‘₯1 ,π‘₯2]

𝐹 𝑛[π‘₯1 ,π‘₯2,…, π‘₯π‘›βˆ’1 ,π‘₯𝑛]

𝐹 π‘›βˆ’1[π‘₯1 ,π‘₯2 ,…, π‘₯π‘›βˆ’1]…

Page 39: Decision methods for arithmetic Third summer school on formal methods

MCSat – Finite Basis

𝐹 1[π‘₯1]

𝐹 2[π‘₯1 ,π‘₯2]

𝐹 𝑛[π‘₯1 ,π‘₯2,…, π‘₯π‘›βˆ’1 ,π‘₯𝑛]

𝐹 π‘›βˆ’1[π‘₯1 ,π‘₯2 ,…, π‘₯π‘›βˆ’1]…

Page 40: Decision methods for arithmetic Third summer school on formal methods

MCSat – Finite Basis

𝐹 1[π‘₯1]

𝐹 2[π‘₯1 ,π‘₯2]

𝐹 𝑛[π‘₯1 ,π‘₯2,…, π‘₯π‘›βˆ’1 ,π‘₯𝑛]

𝐹 π‘›βˆ’1[π‘₯1 ,π‘₯2 ,…, π‘₯π‘›βˆ’1]…

Page 41: Decision methods for arithmetic Third summer school on formal methods

MCSat – Finite BasisEvery β€œfinite” theory has a finite basis

𝐹 [π‘₯1 ,…,π‘₯𝑛 , 𝑦1 ,…, π‘¦π‘š]

Page 42: Decision methods for arithmetic Third summer school on formal methods

MCSat – Finite BasisTheory of uninterpreted functions has a finite basis

Theory of arrays has a finite basis [Brummayer- Biere 2009]

In both cases the Finite Basis is essentially composed of equalities between existing terms.

Page 43: Decision methods for arithmetic Third summer school on formal methods

MCSat: Termination

Propagations

Decisions

Model Assignments

Page 44: Decision methods for arithmetic Third summer school on formal methods

MCSat

≻Propagations

Decisions

Model Assignments

Page 45: Decision methods for arithmetic Third summer school on formal methods

MCSat

≻

Propagations

Decisions

Model Assignments

Page 46: Decision methods for arithmetic Third summer school on formal methods

MCSat

ΒΏπΉπ‘–π‘›π‘–π‘‘π‘’π΅π‘Žπ‘ π‘–π‘ βˆ¨ΒΏ

…Maximal Elements

Page 47: Decision methods for arithmetic Third summer school on formal methods

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1 π‘₯≀1

Β¬(π‘₯2+𝑦2≀1)∨π‘₯≀1ConflictΒ¬ (π‘₯β‰₯2 )∨¬(π‘₯≀1)

Page 48: Decision methods for arithmetic Third summer school on formal methods

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1 π‘₯≀1

Β¬(π‘₯2+𝑦2≀1)∨π‘₯≀1ConflictΒ¬ (π‘₯β‰₯2 )∨¬(π‘₯≀1)

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1Β¬(π‘₯2+𝑦2≀1)

Β¬(π‘₯2+𝑦2≀1)∨π‘₯≀1Β¬ (π‘₯β‰₯2 )∨¬(π‘₯2+𝑦2≀1)

Page 49: Decision methods for arithmetic Third summer school on formal methods

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1 π‘₯≀1

Β¬(π‘₯2+𝑦2≀1)∨π‘₯≀1ConflictΒ¬ (π‘₯β‰₯2 )∨¬(π‘₯≀1)

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1Β¬(π‘₯2+𝑦2≀1)

Β¬(π‘₯2+𝑦2≀1)∨π‘₯≀1Β¬ (π‘₯β‰₯2 )∨¬(π‘₯2+𝑦2≀1)

Page 50: Decision methods for arithmetic Third summer school on formal methods

π‘₯<1βˆ¨π‘ ,Β¬π‘βˆ¨π‘₯=2

π‘₯β†’1

MCSat

Page 51: Decision methods for arithmetic Third summer school on formal methods

π‘₯<1βˆ¨π‘ ,Β¬π‘βˆ¨π‘₯=2

π‘₯β†’1

MCSat

𝑝

Page 52: Decision methods for arithmetic Third summer school on formal methods

π‘₯<1βˆ¨π‘ ,Β¬π‘βˆ¨π‘₯=2

π‘₯β†’1

MCSat

𝑝

Conflict (evaluates to false)

Page 53: Decision methods for arithmetic Third summer school on formal methods

π‘₯<1βˆ¨π‘ ,Β¬π‘βˆ¨π‘₯=2

π‘₯β†’1

MCSat

𝑝

New clauseπ‘₯<1∨π‘₯=2

Page 54: Decision methods for arithmetic Third summer school on formal methods

π‘₯<1βˆ¨π‘ ,Β¬π‘βˆ¨π‘₯=2

π‘₯β†’1

MCSat

𝑝

New clauseπ‘₯<1∨π‘₯=2

π‘₯<1

Page 55: Decision methods for arithmetic Third summer school on formal methods

π‘₯<1βˆ¨π‘ ,Β¬π‘βˆ¨π‘₯=2

π‘₯β†’1

MCSat

𝑝

New clauseπ‘₯<1∨π‘₯=2

π‘₯<1

Page 56: Decision methods for arithmetic Third summer school on formal methods

MCSat: Architecture

Arithmetic

Boolean Lists

Arrays

Page 57: Decision methods for arithmetic Third summer school on formal methods

MCSat: development


Top Related