model-driven decision procedures for arithmetic

98
Model-Driven Decision Procedures for Arithmetic SYNASC 2013 Leonardo de Moura Microsoft Research

Upload: others

Post on 07-Dec-2021

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Model-Driven Decision Procedures for Arithmetic

Model-Driven Decision Procedures for Arithmetic

SYNASC 2013

Leonardo de Moura

Microsoft Research

Page 2: Model-Driven Decision Procedures for Arithmetic

Logic Engines as a Service

π‘†π‘π‘Žπ‘™π‘Žπ‘3 SAGE

Page 3: Model-Driven Decision Procedures for Arithmetic

Satisfiability

π‘₯2 + 𝑦2 < 1 π‘Žπ‘›π‘‘ π‘₯𝑦 > 0.1 sat, π‘₯ =1

8, 𝑦 =

7

8

π‘₯2 + 𝑦2 < 1 π‘Žπ‘›π‘‘ π‘₯𝑦 > 1 unsat, Proof

Is execution path P feasible? Is assertion X violated?

SAGE

Is Formula F Satisfiable?

WI TNESS

Solution/Model

Page 4: Model-Driven Decision Procedures for Arithmetic

The RISE of Model-Driven Techniques

Page 5: Model-Driven Decision Procedures for Arithmetic

Saturation x Search

Proof-finding Model-finding

Mo

dels

Pro

ofs

Page 6: Model-Driven Decision Procedures for Arithmetic

SAT

𝑝1 ∨ ¬𝑝2, ¬𝑝1 ∨ 𝑝2 ∨ 𝑝3, 𝑝3

CNF is a set (conjunction) set of clauses

Clause is a disjunction of literals

Literal is an atom or the negation of an atom

𝑝1 = π‘‘π‘Ÿπ‘’π‘’, 𝑝2 = π‘‘π‘Ÿπ‘’π‘’, 𝑝3 = π‘‘π‘Ÿπ‘’π‘’

Page 7: Model-Driven Decision Procedures for Arithmetic

Two procedures

Resolution DPLL

Proof-finder Model-finder

Saturation Search

Page 8: Model-Driven Decision Procedures for Arithmetic

Resolution

Improvements

Delete tautologies 𝑙 ∨ ¬𝑙 ∨ 𝐢

Ordered Resolution

Subsumption (delete redundant clauses)

𝐢 π‘ π‘’π‘π‘ π‘’π‘šπ‘’π‘  𝐢 ∨ 𝐷

…

𝐢 ∨ 𝑙, 𝐷 ∨ ¬𝑙 β‡’ 𝐢 ∨ 𝐷

𝑙, ¬𝑙 β‡’ unsat

Page 9: Model-Driven Decision Procedures for Arithmetic

Resolution: Example

Page 10: Model-Driven Decision Procedures for Arithmetic

Resolution: Example

Page 11: Model-Driven Decision Procedures for Arithmetic

Resolution: Example

Page 12: Model-Driven Decision Procedures for Arithmetic

Resolution: Example

Page 13: Model-Driven Decision Procedures for Arithmetic

Resolution: Example

Page 14: Model-Driven Decision Procedures for Arithmetic

Resolution: Problem

Exponential time and space

Page 15: Model-Driven Decision Procedures for Arithmetic

Unit Resolution

𝐢 ∨ 𝑙, ¬𝑙 β‡’ 𝐢

𝐢 subsumes

𝐢 ∨ 𝑙

Page 16: Model-Driven Decision Procedures for Arithmetic

DPLL

DPLL = Unit Resolution + Split rule

Split rule 𝑆

𝑆, 𝑝 𝑆, ¬𝑝

Page 17: Model-Driven Decision Procedures for Arithmetic

DPLL

π‘₯ ∨ 𝑦, Β¬π‘₯ ∨ 𝑦, π‘₯ ∨ ¬𝑦, Β¬π‘₯ ∨ ¬𝑦

π‘₯ ∨ 𝑦, Β¬π‘₯ ∨ 𝑦, π‘₯ ∨ ¬𝑦, Β¬π‘₯ ∨ ¬𝑦,

π‘₯

Page 18: Model-Driven Decision Procedures for Arithmetic

DPLL

π‘₯ ∨ 𝑦, Β¬π‘₯ ∨ 𝑦, π‘₯ ∨ ¬𝑦, Β¬π‘₯ ∨ ¬𝑦

π‘₯ ∨ 𝑦, Β¬π‘₯ ∨ 𝑦, π‘₯ ∨ ¬𝑦, Β¬π‘₯ ∨ ¬𝑦,

π‘₯

Page 19: Model-Driven Decision Procedures for Arithmetic

DPLL

π‘₯ ∨ 𝑦, Β¬π‘₯ ∨ 𝑦, π‘₯ ∨ ¬𝑦, Β¬π‘₯ ∨ ¬𝑦

𝑦, ¬𝑦, π‘₯

Page 20: Model-Driven Decision Procedures for Arithmetic

DPLL

π‘₯ ∨ 𝑦, Β¬π‘₯ ∨ 𝑦, π‘₯ ∨ ¬𝑦, Β¬π‘₯ ∨ ¬𝑦

𝑦, ¬𝑦, π‘₯,

π‘’π‘›π‘ π‘Žπ‘‘

Page 21: Model-Driven Decision Procedures for Arithmetic

DPLL

π‘₯ ∨ 𝑦, Β¬π‘₯ ∨ 𝑦, π‘₯ ∨ ¬𝑦, Β¬π‘₯ ∨ ¬𝑦

𝑦, ¬𝑦, π‘₯,

π‘’π‘›π‘ π‘Žπ‘‘

π‘₯ ∨ 𝑦, Β¬π‘₯ ∨ 𝑦, π‘₯ ∨ ¬𝑦, Β¬π‘₯ ∨ ¬𝑦,

Β¬π‘₯

Page 22: Model-Driven Decision Procedures for Arithmetic

DPLL

π‘₯ ∨ 𝑦, Β¬π‘₯ ∨ 𝑦, π‘₯ ∨ ¬𝑦, Β¬π‘₯ ∨ ¬𝑦

𝑦, ¬𝑦, π‘₯,

π‘’π‘›π‘ π‘Žπ‘‘

π‘₯ ∨ 𝑦, Β¬π‘₯ ∨ 𝑦, π‘₯ ∨ ¬𝑦, Β¬π‘₯ ∨ ¬𝑦,

Β¬π‘₯

Page 23: Model-Driven Decision Procedures for Arithmetic

CDCL: Conflict Driven Clause Learning

Resolution

DPLL

Proof

Model

Page 24: Model-Driven Decision Procedures for Arithmetic

Linear Arithmetic

Fourier-Motzkin Simplex

Proof-finder Model-finder

Saturation Search

Page 25: Model-Driven Decision Procedures for Arithmetic

Fourier-Motzkin

Very similar to Resolution

Exponential time and space

𝑑1 ≀ π‘Žπ‘₯, 𝑏π‘₯ ≀ 𝑑2

𝑏𝑑1 ≀ π‘Žπ‘π‘₯, π‘Žπ‘π‘₯ ≀ π‘Žπ‘‘2

𝑏𝑑1 ≀ π‘Žπ‘‘2

Page 26: Model-Driven Decision Procedures for Arithmetic

Polynomial Constraints

π‘₯2 βˆ’ 4π‘₯ + 𝑦2 βˆ’ 𝑦 + 8 < 1

π‘₯𝑦 βˆ’ 2π‘₯ βˆ’ 2𝑦 + 4 > 1

AKA Existential Theory of the Reals

R

Page 27: Model-Driven Decision Procedures for Arithmetic

Applications

Page 28: Model-Driven Decision Procedures for Arithmetic

CAD β€œBig Picture”

1. Project/Saturate set of polynomials

2. Lift/Search: Incrementally build assignment 𝑣: π‘₯π‘˜ β†’ π›Όπ‘˜

Isolate roots of polynomials 𝑓𝑖(𝜢, π‘₯)

Select a feasible cell 𝐢, and assign π‘₯π‘˜ some π›Όπ‘˜ ∈ 𝐢

If there is no feasible cell, then backtrack

Page 29: Model-Driven Decision Procedures for Arithmetic

CAD β€œBig Picture”

π‘₯2 + 𝑦2 βˆ’ 1 < 0

π‘₯ 𝑦 βˆ’ 1 > 0 1. Saturate

π‘₯4 βˆ’ π‘₯2 + 1

π‘₯

π‘₯2 βˆ’ 1

(βˆ’βˆž,βˆ’πŸ) βˆ’πŸ (βˆ’πŸ, 𝟎) 𝟎 (𝟎, 𝟏) 𝟏 (𝟏,∞)

π‘₯4 βˆ’ π‘₯2 + 1 + + + + + + +

π‘₯2 βˆ’ 1 + 0 - - - 0 +

π‘₯ - - - 0 + + +

2. Search

Page 30: Model-Driven Decision Procedures for Arithmetic

CAD β€œBig Picture”

π’™πŸ + π’šπŸ βˆ’ 𝟏 < 0

𝒙 π’š βˆ’ 𝟏 > 0 1. Saturate

π‘₯4 βˆ’ π‘₯2 + 1

π‘₯

π‘₯2 βˆ’ 1

(βˆ’βˆž,βˆ’πŸ) βˆ’πŸ (βˆ’πŸ, 𝟎) 𝟎 (𝟎, 𝟏) 𝟏 (𝟏,∞)

π‘₯4 βˆ’ π‘₯2 + 1 + + + + + + +

π‘₯2 βˆ’ 1 + 0 - - - 0 +

π‘₯ - - - 0 + + +

π’™βˆ’ 𝟐

(βˆ’βˆž,βˆ’πŸ

𝟐) βˆ’

𝟏

𝟐 (βˆ’

𝟏

𝟐,∞)

4 + 𝑦2 βˆ’ 1 + + +

βˆ’2y βˆ’ 1 + 0 -

2. Search

Page 31: Model-Driven Decision Procedures for Arithmetic

CAD β€œBig Picture”

π’™πŸ + π’šπŸ βˆ’ 𝟏 < 𝟎

π‘₯ 𝑦 βˆ’ 1 > 0 1. Saturate

π‘₯4 βˆ’ π‘₯2 + 1

π‘₯

π‘₯2 βˆ’ 1

(βˆ’βˆž,βˆ’πŸ) βˆ’πŸ (βˆ’πŸ, 𝟎) 𝟎 (𝟎, 𝟏) 𝟏 (𝟏,∞)

π‘₯4 βˆ’ π‘₯2 + 1 + + + + + + +

π‘₯2 βˆ’ 1 + 0 - - - 0 +

π‘₯ - - - 0 + + +

π’™βˆ’ 𝟐

(βˆ’βˆž,βˆ’πŸ

𝟐) βˆ’

𝟏

𝟐 (βˆ’

𝟏

𝟐,∞)

πŸ’ + π’šπŸ βˆ’ 𝟏 + + +

βˆ’2y βˆ’ 1 + 0 -

2. Search

CONFLICT

Page 32: Model-Driven Decision Procedures for Arithmetic

NLSAT: Model-Based Search

Static x Dynamic

Optimistic approach

Key ideas

Start the Search before Saturate/Project

We saturate on demand

Model guides the saturation

Mo

dels

Pro

ofs

Page 33: Model-Driven Decision Procedures for Arithmetic

NLSAT (1)

Two kinds of decision

1. case-analysis (Boolean)

π‘₯2 + 𝑦2 < 1 ∨ 𝒙 < 𝟎 ∨ π‘₯ 𝑦 > 1

2. model construction (CAD lifting)

(βˆ’βˆž,βˆ’πŸ) βˆ’πŸ (βˆ’πŸ, 𝟎) 𝟎 (𝟎, 𝟏) 𝟏 (𝟏,∞)

π‘₯4 βˆ’ π‘₯2 + 1 + + + + + + +

π‘₯2 βˆ’ 1 + 0 - - - 0 +

π‘₯ - - - 0 + + +

𝒙 βˆ’ 𝟐

Page 34: Model-Driven Decision Procedures for Arithmetic

NLSAT (1)

Parametric calculus: 𝑒π‘₯π‘π‘™π‘Žπ‘–π‘› 𝐹,𝑀

Finite basis explanation function

Two kinds of decision

1. case-analysis (Boolean)

2. model construction (CAD lifting)

Explanations may contain new literals

They evaluate to false in the current state

Page 35: Model-Driven Decision Procedures for Arithmetic

NLSAT (2)

Key ideas: Use partial solution to guide the search

π‘₯3 + 2π‘₯2 + 3𝑦2 βˆ’ 5 < 0

π‘₯2 + 𝑦2 < 1

βˆ’4π‘₯𝑦 βˆ’ 4π‘₯ + 𝑦 > 1

Feasible Region

Starting search Partial solution: π‘₯ ← 0.5

Can we extend it to 𝑦?

What is the core?

Page 36: Model-Driven Decision Procedures for Arithmetic

NLSAT (2)

Key ideas: Use partial solution to guide the search

π‘₯3 + 2π‘₯2 + 3𝑦2 βˆ’ 5 < 0

π‘₯2 + 𝑦2 < 1

βˆ’4π‘₯𝑦 βˆ’ 4π‘₯ + 𝑦 > 1

Feasible Region

Starting search Partial solution: π‘₯ ← 0.5

Can we extend it to 𝑦?

What is the core?

Page 37: Model-Driven Decision Procedures for Arithmetic

NLSAT (3)

Key ideas: Solution based Project/Saturate

Standard project operators are pessimistic. Coefficients can vanish!

Page 38: Model-Driven Decision Procedures for Arithmetic

NLSAT (4)

Current assignment

π‘₯ β†’ 0.75 𝑦 β†’ 0.75

Conflict π‘₯2 + 𝑦2 + 𝑧2 < 1

Key ideas: Lemma Learning

Prevent a Conflict from happening again.

Lemma

βˆ’1 < π‘₯ < 1 ∧ 𝑦 > π‘Ÿπ‘œπ‘œπ‘‘2 1 βˆ’ 𝑦 2βˆ’ π‘₯2 β‡’ βŠ₯

Current assignments does not satisfy new constraint.

Page 39: Model-Driven Decision Procedures for Arithmetic

NLSAT (5)

Key ideas: Nonchronological Backtracking

𝒙 = 𝟎

π’š = 𝟐

𝒛 = 1

π’˜ Conflict π‘₯ 𝑀 = 1

The values chosen for 𝑧 and 𝑦 are irrelevant.

Page 40: Model-Driven Decision Procedures for Arithmetic

Machinery

Multivariate & univariate Polynomials

Basic operations, Pseudo-division,

GCD, Resultant, PSC, Factorization,

Root isolation algorithms, Sturm sequences

Binary rationals π‘Ž

2π‘˜

Real Algebraic Numbers

Page 41: Model-Driven Decision Procedures for Arithmetic

Experimental Results (1) OUR NEW ENGINE

Page 42: Model-Driven Decision Procedures for Arithmetic

Experimental Results (2)

OUR NEW ENGINE

Page 43: Model-Driven Decision Procedures for Arithmetic

Other examples (for linear arithmetic)

Fourier-Motzkin

Generalizing DPLL to richer logics

[McMillan et al 2009]

Conflict Resolution

[Korovin et al 2009]

X

Page 44: Model-Driven Decision Procedures for Arithmetic

Other examples

Array Theory by

Axiom Instantiation

Lemmas on Demand

For Theory of Array

[Brummayer-Biere 2009]

βˆ€π‘Ž, 𝑖, 𝑣: π‘Ž 𝑖 ≔ 𝑣 𝑖 = 𝑣

βˆ€π‘Ž, 𝑖, 𝑗, 𝑣: 𝑖 = 𝑗 ∨ π‘Ž 𝑖 ≔ 𝑣 𝑗 = π‘Ž[𝑗]

X

Page 45: Model-Driven Decision Procedures for Arithmetic

Saturation: successful instances

Polynomial time procedures

Gaussian Elimination

Congruence Closure

Page 46: Model-Driven Decision Procedures for Arithmetic

MCSat

Model-Driven SMT

Lift ideas from CDCL to SMT

Generalize ideas found in model-driven approaches

Easier to implement

Model construction is explicit

Page 47: Model-Driven Decision Procedures for Arithmetic

MCSat

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

Page 48: Model-Driven Decision Procedures for Arithmetic

MCSat

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

π‘₯ β‰₯ 2

Propagations

Page 49: Model-Driven Decision Procedures for Arithmetic

MCSat

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

π‘₯ β‰₯ 2

Propagations

π‘₯ β‰₯ 1

Page 50: Model-Driven Decision Procedures for Arithmetic

MCSat

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

π‘₯ β‰₯ 2

Propagations

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

Page 51: Model-Driven Decision Procedures for Arithmetic

MCSat

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

π‘₯ β‰₯ 2

Boolean Decisions

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

Page 52: Model-Driven Decision Procedures for Arithmetic

MCSat

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

π‘₯ β‰₯ 2

Semantic Decisions

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

Page 53: Model-Driven Decision Procedures for Arithmetic

MCSat

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

π‘₯ β‰₯ 2

Conflict

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

We can’t find a value for 𝑦 s.t. 4 + 𝑦2 ≀ 1

Page 54: Model-Driven Decision Procedures for Arithmetic

MCSat

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

π‘₯ β‰₯ 2

Conflict

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

We can’t find a value for 𝑦 s.t. 4 + 𝑦2 ≀ 1

Learning that Β¬ π‘₯2 + 𝑦2 ≀ 1 ∨ Β¬(π‘₯= 2) is not productive

Page 55: Model-Driven Decision Procedures for Arithmetic

MCSat

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

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

Learning that Β¬ π‘₯2 + 𝑦2 ≀ 1 ∨ Β¬(π‘₯= 2) is not productive

Β¬(π‘₯ = 2)

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

Page 56: Model-Driven Decision Procedures for Arithmetic

MCSat

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

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

Learning that Β¬ π‘₯2 + 𝑦2 ≀ 1 ∨ Β¬(π‘₯= 2) is not productive

Β¬(π‘₯ = 2)

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

π‘₯ β†’ 3

Page 57: Model-Driven Decision Procedures for Arithmetic

MCSat

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

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

Learning that Β¬ π‘₯2 + 𝑦2 ≀ 1 ∨ Β¬(π‘₯= 2) is not productive

Β¬(π‘₯ = 2)

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

π‘₯ β†’ 3

β€œSame” Conflict

We can’t find a value for 𝑦 s.t. 9 + 𝑦2 ≀ 1

Page 58: Model-Driven Decision Procedures for Arithmetic

π‘₯ β‰₯ 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 59: Model-Driven Decision Procedures for Arithmetic

MCSat

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

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

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

Page 60: Model-Driven Decision Procedures for Arithmetic

MCSat

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

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

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

Conflict

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

Page 61: Model-Driven Decision Procedures for Arithmetic

MCSat

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

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

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

Learned by resolution

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

Page 62: Model-Driven Decision Procedures for Arithmetic

MCSat

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

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

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

Page 63: Model-Driven Decision Procedures for Arithmetic

MCSat: FM Example

βˆ’π‘₯ + 𝑧 + 1 ≀ 0, π‘₯ βˆ’ 𝑦 ≀ 0 𝑧 β†’ 0, 𝑦 β†’ 0

𝑧 + 1 ≀ π‘₯, π‘₯ ≀ 𝑦

≑

1 ≀ π‘₯, π‘₯ ≀ 0

βˆ’π‘₯ + 𝑧 + 1 ≀ 0 𝑧 β†’ 0 𝑦 β†’ 0 π‘₯ βˆ’ 𝑦 ≀ 0

We can’t find a value of π‘₯

Page 64: Model-Driven Decision Procedures for Arithmetic

MCSat: FM Example

βˆ’π‘₯ + 𝑧 + 1 ≀ 0, π‘₯ βˆ’ 𝑦 ≀ 0 𝑧 β†’ 0, 𝑦 β†’ 0

βˆƒπ‘₯:βˆ’π‘₯ + 𝑧 + 1 ≀ 0 ∧ π‘₯ βˆ’ 𝑦 ≀ 0

𝑧 + 1 βˆ’ 𝑦 ≀ 0

βˆ’π‘₯ + 𝑧 + 1 ≀ 0 𝑧 β†’ 0 𝑦 β†’ 0 π‘₯ βˆ’ 𝑦 ≀ 0

Β¬ βˆ’π‘₯ + 𝑧 + 1 ≀ 0 ∨ Β¬ π‘₯ βˆ’ 𝑦 ≀ 0 ∨ 𝑧 + 1 βˆ’ 𝑦 ≀ 0

Fourier-Motzkin

Page 65: Model-Driven Decision Procedures for Arithmetic

MCSat: FM Example

βˆ’π‘₯ + 𝑧 + 1 ≀ 0 𝑧 β†’ 0 𝑧 + 1 βˆ’ 𝑦 ≀ 0 π‘₯ βˆ’ 𝑦 ≀ 0

Β¬ βˆ’π‘₯ + 𝑧 + 1 ≀ 0 ∨ Β¬ π‘₯ βˆ’ 𝑦 ≀ 0 ∨ 𝑧 + 1 βˆ’ 𝑦 ≀ 0

Page 66: Model-Driven Decision Procedures for Arithmetic

MCSat: FM Example

βˆ’π‘₯ + 𝑧 + 1 ≀ 0 𝑧 β†’ 0 𝑧 + 1 βˆ’ 𝑦 ≀ 0 π‘₯ βˆ’ 𝑦 ≀ 0

Β¬ βˆ’π‘₯ + 𝑧 + 1 ≀ 0 ∨ Β¬ π‘₯ βˆ’ 𝑦 ≀ 0 ∨ 𝑧 + 1 βˆ’ 𝑦 ≀ 0

𝑦 β†’ 1

βˆ’π‘₯ + 𝑧 + 1 ≀ 0, π‘₯ βˆ’ 𝑦 ≀ 0 𝑧 β†’ 0, 𝑦 β†’ 1

𝑧 + 1 ≀ π‘₯, π‘₯ ≀ 𝑦

≑

1 ≀ π‘₯, π‘₯ ≀ 1

Page 67: Model-Driven Decision Procedures for Arithmetic

MCSat: FM Example

βˆ’π‘₯ + 𝑧 + 1 ≀ 0 𝑧 β†’ 0 𝑧 + 1 βˆ’ 𝑦 ≀ 0 π‘₯ βˆ’ 𝑦 ≀ 0

Β¬ βˆ’π‘₯ + 𝑧 + 1 ≀ 0 ∨ Β¬ π‘₯ βˆ’ 𝑦 ≀ 0 ∨ 𝑧 + 1 βˆ’ 𝑦 ≀ 0

𝑦 β†’ 1

βˆ’π‘₯ + 𝑧 + 1 ≀ 0, π‘₯ βˆ’ 𝑦 ≀ 0 𝑧 β†’ 0, 𝑦 β†’ 1

𝑧 + 1 ≀ π‘₯, π‘₯ ≀ 𝑦

≑

1 ≀ π‘₯, π‘₯ ≀ 1

π‘₯ β†’ 1

Page 68: Model-Driven Decision Procedures for Arithmetic

MCSat – Finite Basis

Every theory that admits quantifier elimination has a finite basis (given a fixed assignment order)

𝐹[π‘₯, 𝑦1, … , π‘¦π‘š] 𝑦1 β†’ 𝛼1, … , π‘¦π‘š β†’ π›Όπ‘š

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

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

¬𝐹 π‘₯, 𝑦1, … , π‘¦π‘š ∨ πΆπ‘˜[𝑦1, … , π‘¦π‘š]

Page 69: Model-Driven Decision Procedures for Arithmetic

MCSat – Finite Basis

𝐹1[π‘₯1]

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

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

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

…

Page 70: Model-Driven Decision Procedures for Arithmetic

MCSat – Finite Basis

𝐹1[π‘₯1]

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

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

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

…

Page 71: Model-Driven Decision Procedures for Arithmetic

MCSat – Finite Basis

𝐹1[π‘₯1]

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

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

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

…

Page 72: Model-Driven Decision Procedures for Arithmetic

MCSat – Finite Basis

𝐹1[π‘₯1]

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

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

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

…

Page 73: Model-Driven Decision Procedures for Arithmetic

MCSat – Finite Basis

Every β€œfinite” theory has a finite basis Example: Fixed size Bit-vectors

𝐹[π‘₯, 𝑦1, … , π‘¦π‘š] 𝑦1 β†’ 𝛼1, … , π‘¦π‘š β†’ π›Όπ‘š

¬𝐹 π‘₯, 𝑦1, … , π‘¦π‘š ∨ Β¬(𝑦1 = 𝛼1) ∨ β‹―βˆ¨ Β¬(π‘¦π‘š= π›Όπ‘š)

Page 74: Model-Driven Decision Procedures for Arithmetic

MCSat – Finite Basis

Theory 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 75: Model-Driven Decision Procedures for Arithmetic

MCSat: Uninterpreted Functions

π‘Ž = 𝑏 + 1, 𝑓 π‘Ž βˆ’ 1 < 𝑐, 𝑓 𝑏 > π‘Ž

π‘Ž = 𝑏 + 1, 𝑓 π‘˜ < 𝑐, 𝑓 𝑏 > π‘Ž, π‘˜ = π‘Ž βˆ’ 1

π‘Ž = 𝑏 + 1, 𝑓 π‘˜ < 𝑐, 𝑓 𝑏 > π‘Ž, π‘˜ = π‘Ž βˆ’ 1

Treat 𝑓(π‘˜) and 𝑓(𝑏) as variables Generalized variables

Page 76: Model-Driven Decision Procedures for Arithmetic

MCSat: Uninterpreted Functions

π‘Ž = 𝑏 + 1, 𝑓 π‘˜ < 𝑐, 𝑓 𝑏 > π‘Ž, π‘˜ = π‘Ž βˆ’ 1

π‘˜ β†’ 0 𝑏 β†’ 0 𝑓(π‘˜) β†’ 0 𝑓(𝑏) β†’ 2

Conflict: 𝑓 π‘˜ and 𝑓 𝑏 must be equal

Β¬ π‘˜ = 𝑏 ∨ 𝑓 π‘˜ = 𝑓(𝑏)

Page 77: Model-Driven Decision Procedures for Arithmetic

MCSat: Uninterpreted Functions

π‘Ž = 𝑏 + 1, 𝑓 π‘˜ < 𝑐, 𝑓 𝑏 > π‘Ž, π‘˜ = π‘Ž βˆ’ 1

π‘˜ β†’ 0 𝑏 β†’ 0 𝑓(π‘˜) β†’ 0

Β¬ π‘˜ = 𝑏 ∨ 𝑓 π‘˜ = 𝑓(𝑏)

π‘˜ = 𝑏

(Semantic) Propagation

Page 78: Model-Driven Decision Procedures for Arithmetic

MCSat: Uninterpreted Functions

π‘Ž = 𝑏 + 1, 𝑓 π‘˜ < 𝑐, 𝑓 𝑏 > π‘Ž, π‘˜ = π‘Ž βˆ’ 1

π‘˜ β†’ 0 𝑏 β†’ 0 𝑓(π‘˜) β†’ 0

Β¬ π‘˜ = 𝑏 ∨ 𝑓 π‘˜ = 𝑓(𝑏)

π‘˜ = 𝑏 𝑓 π‘˜ = 𝑓(𝑏)

Page 79: Model-Driven Decision Procedures for Arithmetic

MCSat: Uninterpreted Functions

π‘Ž = 𝑏 + 1, 𝑓 π‘˜ < 𝑐, 𝑓 𝑏 > π‘Ž, π‘˜ = π‘Ž βˆ’ 1

π‘˜ β†’ 0 𝑏 β†’ 0 𝑓(π‘˜) β†’ 0

Β¬ π‘˜ = 𝑏 ∨ 𝑓 π‘˜ = 𝑓(𝑏)

π‘˜ = 𝑏 𝑓 π‘˜ = 𝑓(𝑏) 𝑓(𝑏) β†’ 0

Page 80: Model-Driven Decision Procedures for Arithmetic

MCSat – Finite Basis

We can also use literals from the finite basis in decisions. Application: simulate branch&bound for bounded linear integer arithmetic

LP solution:

1 2 3 4 5 6 π‘₯1

1

2

3

4

5

6

0

π‘₯2

π‘₯1 β‰₯ 1 π‘₯1 ≀ 0

π‘₯1 = 1 π‘₯2 = 2

π‘₯1 = 0 π‘₯2 = 3

π‘₯1 = 0.8 π‘₯2 = 2.4

Page 81: Model-Driven Decision Procedures for Arithmetic

MCSat: Termination

Propagations

Boolean Decisions

Semantic Decisions

Page 82: Model-Driven Decision Procedures for Arithmetic

MCSat

≻

Propagations

Boolean Decisions

Semantic Decisions

Page 83: Model-Driven Decision Procedures for Arithmetic

MCSat

≻

Propagations

Boolean Decisions

Semantic Decisions

Page 84: Model-Driven Decision Procedures for Arithmetic

MCSat

|πΉπ‘–π‘›π‘–π‘‘π‘’π΅π‘Žπ‘ π‘–π‘ |

…

Maximal Elements

…

Page 85: Model-Driven Decision Procedures for Arithmetic

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

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

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

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

Page 86: Model-Driven Decision Procedures for Arithmetic

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

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

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

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

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

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

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

Page 87: Model-Driven Decision Procedures for Arithmetic

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

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

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

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

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

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

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

Page 88: Model-Driven Decision Procedures for Arithmetic

π‘₯ < 1 ∨ 𝑝, ¬𝑝 ∨ π‘₯ = 2

π‘₯ β†’ 1

MCSat

Page 89: Model-Driven Decision Procedures for Arithmetic

π‘₯ < 1 ∨ 𝑝, ¬𝑝 ∨ π‘₯ = 2

π‘₯ β†’ 1

MCSat

𝑝

Page 90: Model-Driven Decision Procedures for Arithmetic

π‘₯ < 1 ∨ 𝑝, ¬𝑝 ∨ π‘₯ = 2

π‘₯ β†’ 1

MCSat

𝑝

Conflict (evaluates to false)

Page 91: Model-Driven Decision Procedures for Arithmetic

π‘₯ < 1 ∨ 𝑝, ¬𝑝 ∨ π‘₯ = 2

π‘₯ β†’ 1

MCSat

𝑝

New clause

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

Page 92: Model-Driven Decision Procedures for Arithmetic

π‘₯ < 1 ∨ 𝑝, ¬𝑝 ∨ π‘₯ = 2

π‘₯ β†’ 1

MCSat

𝑝

New clause

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

π‘₯ < 1

Page 93: Model-Driven Decision Procedures for Arithmetic

π‘₯ < 1 ∨ 𝑝, ¬𝑝 ∨ π‘₯ = 2

π‘₯ β†’ 1

MCSat

𝑝

New clause

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

π‘₯ < 1

Page 94: Model-Driven Decision Procedures for Arithmetic

MCSat: Architecture

Arithmetic

Boolean Lists

Arrays

Page 95: Model-Driven Decision Procedures for Arithmetic

MCSat prototype: 7k lines of code Deduction Rules

Boolean Resolution

Fourier-Motzkin

Equality Split

Ackermann expansion aka Congruence

Normalization

Page 96: Model-Driven Decision Procedures for Arithmetic

MCSat: preliminary results prototype: 7k lines of code

QF_LRA

Page 97: Model-Driven Decision Procedures for Arithmetic

MCSat: preliminary results prototype: 7k lines of code

QF_UFLRA and QF_UFLIA

Page 98: Model-Driven Decision Procedures for Arithmetic

Conclusion

Logic as a Service

Model-Based techniques are very promising

http://z3.codeplex.com

http://rise4fun.com/z3

MCSat