Solvers Principles and Architecture (SPA) Part 2 SMT Solvers - - PowerPoint PPT Presentation

solvers principles and architecture spa
SMART_READER_LITE
LIVE PREVIEW

Solvers Principles and Architecture (SPA) Part 2 SMT Solvers - - PowerPoint PPT Presentation

Solvers Principles and Architecture (SPA) Part 2 SMT Solvers Master Sciences Informatique (Sif) September, 2019 Rennes Khalil Ghorbal k halil.ghorbal@inria.fr K. Ghorbal (INRIA) 1 SIF M2 1 / 17 Syntax Recall that logic is a pair of


slide-1
SLIDE 1

Solvers Principles and Architecture (SPA)

Part 2

SMT Solvers

Master Sciences Informatique (Sif) September, 2019 Rennes

Khalil Ghorbal khalil.ghorbal@inria.fr

  • K. Ghorbal (INRIA)

1 SIF M2 1 / 17

slide-2
SLIDE 2

Syntax

Recall that logic is a pair of syntax and semantics.

Syntax

  • Alphabet: set of symbols
  • Expressions: sequences of symbols
  • Rules: identifying well-formed expressions

Semantics

  • Meaning: what is meant by well-formed expressions
  • Rules: infer the meaning from subexpressions
  • K. Ghorbal (INRIA)

2 SIF M2 2 / 17

slide-3
SLIDE 3

Extended Alphabet

Syntax

In addition to Logical symbols: ¬, ∧, − →, etc. (alphabet of propositional logic) We will be adding:

  • variables symbols: x, y, etc.
  • parameters, or non-logical symbols: ∃, f , ≤, =, +, π, etc.
  • K. Ghorbal (INRIA)

3 SIF M2 3 / 17

slide-4
SLIDE 4

Quantifiers and Functions

Quantifiers

  • Exists: ∃
  • Forall: ∀

Functions

  • Symbol (or name)
  • Output type (or kind) – (Co-domain)
  • Inputs arity (or cardinality) and their respective types – (Domain)
  • K. Ghorbal (INRIA)

4 SIF M2 4 / 17

slide-5
SLIDE 5

Important Classes

Predicates

  • Sets described by some relations
  • n-arity functions with co-domain {F, T} (False/True in PL)
  • Predicate symbols: =, <, ∈, etc.

Constants

  • Functions with arity zero
  • Usual symbols: π, 1, ∅, etc.
  • Predicates with arity zero are the propositional constants (F, T).
  • K. Ghorbal (INRIA)

5 SIF M2 5 / 17

slide-6
SLIDE 6

First-Order Logic

First-order means quantifiers are only allowed over variables: Qixi.

  • Each quantifier is necessarily related to a variable.
  • A variable is either free or bound by a quantifier.

Examples

  • Function + : (x, y) → x + y
  • Predicate: f (x) = f (y) (for some function f )
  • Predicate: x ≤ f (y)
  • K. Ghorbal (INRIA)

6 SIF M2 6 / 17

slide-7
SLIDE 7

Example of First-order Languages

Basic Set Language

  • Relationship predicate: R
  • Constant: ∅

Elementary Number Language

  • Constant: 0
  • Function: Succ
  • Equality predicate: =
  • K. Ghorbal (INRIA)

7 SIF M2 7 / 17

slide-8
SLIDE 8

Terms, Formulas

Terms

Built inductively from functions’ symbols applied to constants and variables.

  • A variable v is a term
  • A constant 0 is a term
  • The function f applied to terms t1 and t2 is a term named f (t1, t2)

Atomic Formulas

Built by applying predicates on terms.

  • F/T are atomic predicates
  • ≤ v 0 is an atomic predicate (prefix notation)
  • t1 = t2 is an atomic predicate (infix notation)
  • K. Ghorbal (INRIA)

8 SIF M2 8 / 17

slide-9
SLIDE 9

Well-Formed Formulas

Built inductively from atomic formulas with logic connectives and quantifiers.

  • ¬φ is a formula
  • φ1 −

→ φ2 is a formula

  • Q1v1.Q2v2.φ(t, g(t)) is a formula
  • Terms t and g(t) may or may not contain the variables v1 and v2
  • K. Ghorbal (INRIA)

9 SIF M2 9 / 17

slide-10
SLIDE 10

Free and Bound Variables

A variable in a wff is either free or bound to a quantifier.

  • ∃v1.f (v1) < v2: v2 is free
  • ∀v1.∃v2.P(v1, g(v1, v2)): both variables are bound

A wff with no free variables is called a sentence.

  • K. Ghorbal (INRIA)

10 SIF M2 10 / 17

slide-11
SLIDE 11

Signature

A signature (Σ) contains the parameters of the language, that is all its non-logical symbols: constants, functions, and predicates.

Example: Elementary Numbers Signatures

  • (0, Succ, =)
  • (0, 1, +, −, >)
  • K. Ghorbal (INRIA)

11 SIF M2 11 / 17

slide-12
SLIDE 12

Semantics

An interpretation (M) of a signature is twofold:

  • An underlying domain DM (e.g. natural numbers)
  • An interpretation of all the symbols of Σ over DM

Example: Σ := (0, 1, +, −, >)

  • D is N or Z
  • 0 and 1 are the natural numbers zero and one
  • + : (x, y) → x + y, − : (x, y) → x − y
  • >: (x, y) → x > y
  • wff w : ∃x.∀y.¬(x > y) (sentence)
  • K. Ghorbal (INRIA)

12 SIF M2 12 / 17

slide-13
SLIDE 13

Satisfiability

Let V denote the set of variables. Given an interpretation M, an assignement is a map σ : V → DM. The assignement σ depends on the interpretation M. The interpretation M associates

  • Functions’ symbols (f ) of arity n to actual mathematical functions

(fM : Dn

M → DM)

  • Terms to elements in DM
  • Predicates’ symbols (P) of arity n to subsets PM in Dn

M

Inductive Interpretation of wff

  • Pt1t2M,σ (t1σ, t2σ) ∈ PM.
  • ∀v.wM,σ (∀m ∈ DM. w[v \ m]σ = 1) (m is a fresh variable not

appearing in w).

  • K. Ghorbal (INRIA)

13 SIF M2 13 / 17

slide-14
SLIDE 14

Definitions

Let Σ be a signature. A Σ−Theory T is a set of sentences over Σ. The interpretation M is a model of T if M satisfies all the sentences of T. Let T denote a theory, and σ : V → DM an assignement.

  • σ satisfies w w.r.t. M (model of T) if and only if wM,σ = 1
  • w is T-satisfiable w.r.t. M if there exist M (model of T), σ such

that σ satisfies w w.r.t. M

  • w is T-unsatisfiable if and only if for all models M of T

∀σ. (wM,σ = 0) .

  • K. Ghorbal (INRIA)

14 SIF M2 14 / 17

slide-15
SLIDE 15

Satisfiability Modulo Theory

  • The validity problem for T is the problem of deciding, for each

Σ-formula w, if w is T-valid.

  • The satisfiability problem for T is the problem of deciding, for each

Σ-formula w, if w is T-satisfiable.

Proving Validity

w is T-valid if and only if ¬w is T-unsatisfiable.

  • K. Ghorbal (INRIA)

15 SIF M2 15 / 17

slide-16
SLIDE 16

Examples

  • ∀v1.Pv1 |

= Pv2

  • ∀v1.Pv1 |

= ∃v2.Pv2

  • ∃v1.∀v2.Qv1v2 |

= ∀v2.∃v1.Qv1v2

  • |

= ∃v1(Pv1 − → ∀v2.Pv2)

  • ∀v1.∃v2.Qv1v2 |

= ∃v2.∀v1.Qv1v2

  • Pv1 |

= ∀v1.Pv1 (Depends on M)

  • K. Ghorbal (INRIA)

16 SIF M2 16 / 17

slide-17
SLIDE 17

Examples

  • ∀v1.Pv1 |

= Pv2

  • ∀v1.Pv1 |

= ∃v2.Pv2

  • ∃v1.∀v2.Qv1v2 |

= ∀v2.∃v1.Qv1v2

  • |

= ∃v1(Pv1 − → ∀v2.Pv2)

  • ∀v1.∃v2.Qv1v2 |

= ∃v2.∀v1.Qv1v2

  • Pv1 |

= ∀v1.Pv1 (Depends on M)

  • K. Ghorbal (INRIA)

16 SIF M2 16 / 17

slide-18
SLIDE 18

Examples

  • ∀v1.Pv1 |

= Pv2

  • ∀v1.Pv1 |

= ∃v2.Pv2

  • ∃v1.∀v2.Qv1v2 |

= ∀v2.∃v1.Qv1v2

  • |

= ∃v1(Pv1 − → ∀v2.Pv2)

  • ∀v1.∃v2.Qv1v2 |

= ∃v2.∀v1.Qv1v2

  • Pv1 |

= ∀v1.Pv1 (Depends on M)

  • K. Ghorbal (INRIA)

16 SIF M2 16 / 17

slide-19
SLIDE 19

Examples

  • ∀v1.Pv1 |

= Pv2

  • ∀v1.Pv1 |

= ∃v2.Pv2

  • ∃v1.∀v2.Qv1v2 |

= ∀v2.∃v1.Qv1v2

  • |

= ∃v1(Pv1 − → ∀v2.Pv2)

  • ∀v1.∃v2.Qv1v2 |

= ∃v2.∀v1.Qv1v2

  • Pv1 |

= ∀v1.Pv1 (Depends on M)

  • K. Ghorbal (INRIA)

16 SIF M2 16 / 17

slide-20
SLIDE 20

Examples

  • ∀v1.Pv1 |

= Pv2

  • ∀v1.Pv1 |

= ∃v2.Pv2

  • ∃v1.∀v2.Qv1v2 |

= ∀v2.∃v1.Qv1v2

  • |

= ∃v1(Pv1 − → ∀v2.Pv2)

  • ∀v1.∃v2.Qv1v2 |

= ∃v2.∀v1.Qv1v2

  • Pv1 |

= ∀v1.Pv1 (Depends on M)

  • K. Ghorbal (INRIA)

16 SIF M2 16 / 17

slide-21
SLIDE 21

Examples

  • ∀v1.Pv1 |

= Pv2

  • ∀v1.Pv1 |

= ∃v2.Pv2

  • ∃v1.∀v2.Qv1v2 |

= ∀v2.∃v1.Qv1v2

  • |

= ∃v1(Pv1 − → ∀v2.Pv2)

  • ∀v1.∃v2.Qv1v2 |

= ∃v2.∀v1.Qv1v2

  • Pv1 |

= ∀v1.Pv1 (Depends on M)

  • K. Ghorbal (INRIA)

16 SIF M2 16 / 17

slide-22
SLIDE 22

DPLL(T) – CDCL(T)

Quantifier free formula: (x ≤ 0 ∨ x + y ≤ 0) ∧ y ≥ 1 ∧ x ≥ 1 Translated into a CNF: (a ∨ b) ∧ c ∧ d SAT gives (a, b, c, d) = (1, 0, 1, 1) But x ≤ 0 ∧ x ≥ 1 is a contradiction: Learn ¯ a ∨ ¯ d SAT gives (a, b, c, d) = (0, 1, 1, 1) But x + y ≤ 0 ∧ y ≥ 1 ∧ x ≥ 1 is a contradiction: Learn ¯ b ∨ ¯ c ∨ ¯ d The problem is UNSAT.

  • K. Ghorbal (INRIA)

17 SIF M2 17 / 17