Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr....
Transcript of Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr....
![Page 1: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/1.jpg)
Formale Systeme II: Theorie
Theories
SS 2018
Prof. Dr. Bernhard Beckert · Dr. Mattias Ulbrich
KIT – Die Forschungsuniversitat in der Helmholtz-Gemeinschaft www.kit.edu
![Page 2: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/2.jpg)
Theories and Satisfiability –Introduction
Beckert, Ulbrich – Formale Systeme II: Theorie 2/47
![Page 3: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/3.jpg)
Different Questions to Ask
Deciding logics
Question: Is formula φ valid, i.e., φ satisfied in all possiblestructures.
(∀x .p(x))→ p(f (x)) is valid.
x > y → y < x not valid (uninterpreted symbols!)
Deciding theories
Question: Is formula φ satisfied structures with fixedinterpretation for symbols.
∃x . 2 · x2 − x − 1 = 0 ∧ x < 0 holds in R, . . .
. . . but not in Z.
Beckert, Ulbrich – Formale Systeme II: Theorie 3/47
![Page 4: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/4.jpg)
Theories
Given a FOL signature ΣFmlΣ . . . set of closed FOL-formulas over Σ.
Definition: Theory
A theory T ⊂ FmlΣ is a set of formulas such that
1 T is closed under consequence: If T |= φ then φ ∈ T
2 T is consistent: false 6∈ T
A FOL structure (D, I ) is called a T -model of ψ ∈ FmlΣ if
1 D, I |= ψ and
2 D, I |= φ for all φ ∈ T
Beckert, Ulbrich – Formale Systeme II: Theorie 4/47
![Page 5: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/5.jpg)
Theories II
A FOL structure (D, I ) is called a T -structure if D, I |= φ forall φ ∈ T .
A T -structure (D, I ) is a T -model of ψ ∈ FmlΣ if D, I |= ψ.
ψ ∈ FmlΣ is called T -satisfiable if it has a T -model.
ψ ∈ FmlΣ is called T -valid if every T -structure is a T -modelof ψ. ⇐⇒ T |= ψ ⇐⇒ ψ ∈ T
T is called complete if: φ ∈ FmlΣ =⇒ φ ∈ T or ¬φ ∈ T
|=T is used instead of T |=: S |=T φ defined as S ∪ T |= φ
Beckert, Ulbrich – Formale Systeme II: Theorie 5/47
![Page 6: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/6.jpg)
Generating Theories
Axiomatisation
Theory T may be represented by a set Ax ⊂ FmlΣ of axioms.T is the consequential closure of Ax, we write:
T = T (Ax) := {φ | Ax |= φ}
T is “axiomatisable”.
Fixing a structure
Theory T may be represented by one particular structure (D, I ).T is the set of true formulas in (D, I ), we write:
T = T (D, I ) := {φ | (D, I ) |= φ}
Beckert, Ulbrich – Formale Systeme II: Theorie 6/47
![Page 7: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/7.jpg)
Discussion
Every theory T (D, I ) is complete.
If Ax is recursive enumerable, then T (Ax) is recursiveenumerable.
If Ax is decidable, then T (Ax) needs not be decidable.
T (D, I ) needs not be recursive enumerable.
(D, I ) is not the only T (D, I )-model.(In general, two T (D, I )-models are not even isomorphic)
Beckert, Ulbrich – Formale Systeme II: Theorie 7/47
![Page 8: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/8.jpg)
Free variables
When dealing with theories, formulas often have free variables.
Open and closed (reminder)
φ1 = ∀x .∃y .p(x , y) is closed, has no free variables,φ2 = ∃y .p(x , y) is open, has free variables FV (φ2) = {x}
FmloΣ ⊃ FmlΣ . . . set of open formulas
Existential closure ∃[·]For φ ∈ FmloΣ with FV = {x1, ..., xn} define:
∃[φ] := ∃x1. . . .∃xn. φ
φ ∈ FmloΣ is called T-satisfiable if ∃[φ] is T-satisfiable.
Beckert, Ulbrich – Formale Systeme II: Theorie 8/47
![Page 9: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/9.jpg)
Axioms for Equality
Theorem
Equality can be axiomatised in first order logic.
This means: Given signature Σ, there is a set EqΣ ⊂ FmlΣ thataxiomatise equality:
φ≈ is formula φ with interpreted “=” replaced by uninterpred “≈”.
S |= φ ⇐⇒ S≈ |=T (EqΣ) φ≈
FOL with equality cannot be more expressive than FOL withoutbuilt-in equality.
Beckert, Ulbrich – Formale Systeme II: Theorie 9/47
![Page 10: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/10.jpg)
Axioms for Equality
Axioms EqΣ:
∀x . x ≈ x (Reflexivity)
∀x1, x1, . . . , xn, x′n.
x1 ≈ x ′1 ∧ . . . ∧ xn ≈ x ′n → f (x1, ..., xn) ≈ f (x ′1, . . . , x′n)
for any function f in Σ with arity n. (Congruency)
∀x1, x1, . . . , xn, x′n.
x1 ≈ x ′1 ∧ . . . ∧ xn ≈ x ′n → p(x1, ..., xn)↔ p(x ′1, . . . , x′n)
for any predicate p in Σ with arity n. (Congruency)(This includes predicate ≈)
Symmetry and transitivity of ≈ are consequences of EqΣ
Exercise
Beckert, Ulbrich – Formale Systeme II: Theorie 10/47
![Page 11: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/11.jpg)
Satisfiability Modulo Theories
SMT solvers
A lot of research in recent years:(Simplify), Z3, CVC4, Yices, MathSAT, SPT, . . .Some for many theories, others only for a single theory.
(Common input format SMT-Lib 2)
FmlQF ⊂ Fmlo . . . the set of quantifier-free formulas
Interesting questions for a theory T :
SAT: Is φ ∈ Fmlo a T -satisfiable formula?
QF-SAT: Is φ ∈ FmlQF a T -satisfiable formula?
Beckert, Ulbrich – Formale Systeme II: Theorie 11/47
![Page 12: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/12.jpg)
Decision Procedure
Decision Procedure
A decision procedure DPT for a theory T is a deterministicalgorithm that always terminates.It takes a formula φ as input and returns SAT if φ is T -satisfiable,UNSAT otherwise.
N.B.:
φ is T -valid ⇐⇒ ¬φ is not T -satisfiable.
DPT can also be used to decide validity!
Beckert, Ulbrich – Formale Systeme II: Theorie 12/47
![Page 13: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/13.jpg)
Decision Procedures
Theory QF-SAT SATEquality YES YESUninterpreted functions YES co-SEMIInteger arithmeticLinear arithmeticReal arithmeticBitvectors YES YESFloating points YES YES
Beckert, Ulbrich – Formale Systeme II: Theorie 13/47
![Page 14: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/14.jpg)
Natural Arithmetic
Beckert, Ulbrich – Formale Systeme II: Theorie 14/47
![Page 15: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/15.jpg)
Natural Numbers
Standard model of natural numbers
Let ΣN = ({+, ∗, 0, 1}, {<}).
N = (N, IN ) with “obvious” meaning:
IN ({
+∗<
})(a, b) = a
{+·<
}b, IN (0) = 0, IN (1) = 1
T (N ) is the set of all sentences over ΣN which are true in thenatural numbers.
Godel’s Incompleteness Theorem
“Any consistent formal system F within which a certain amount ofelementary arithmetic can be carried out is incomplete.”
Natural number arithmetic is not axiomatisable (w/ a r.e. set of axioms)
Beckert, Ulbrich – Formale Systeme II: Theorie 15/47
![Page 16: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/16.jpg)
Peano Arithmetic
Natural number arithmetic is not axiomatisable . . .Let’s approximate.
The Peano Axioms PA1 ∀x(x + 1 6 .= 0)
2 ∀x∀y(x + 1.
= y + 1→ x.
= y)
3 ∀x(x + 0.
= x)
4 ∀x∀y(x + (y + 1).
= (x + y) + 1)
5 ∀x(x ∗ 0.
= 0)
6 ∀x∀y(x ∗ (y + 1).
= (x ∗ y) + x)
7 For any φ ∈ FmlΣN
(φ(0) ∧ ∀x(φ(x)→ φ(x + 1)))→ ∀x(φ)
That’s an infinite (yet recursive) set of Axioms.
Beckert, Ulbrich – Formale Systeme II: Theorie 16/47
![Page 17: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/17.jpg)
Peano Arithmetic
Peano arithmetic approximates natural arithmetic.
More T (PA)-models than T (N )-models
T (PA) is not complete.
=⇒ There are T (N )-valid formulas that are not T (PA)-validformulas.
There are artificial examples in T (N ) \ T (PA),but also actual mathematical theorems:
Beckert, Ulbrich – Formale Systeme II: Theorie 17/47
![Page 18: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/18.jpg)
Beckert, Ulbrich – Formale Systeme II: Theorie 18/47
![Page 19: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/19.jpg)
from: L. KIRBY and J. PARIS, ’Accessible Independence Results for Peano Arithmetic’ (1982)[2] R. L. GOODSTEIN, ’On the restricted ordinal theorem’, J. Symbolic Logic (1944)
Beckert, Ulbrich – Formale Systeme II: Theorie 19/47
![Page 20: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/20.jpg)
Decision Procedures
Theory QF-SAT SATEquality YES YESUninterpreted functions YES co-SEMIInteger arithmetic NO1 NOLinear arithmeticReal arithmeticBitvectors YES YESFloating points YES YES
1 Yuri Matiyasevich. Enumerable sets are diophantine. Journal of SovieticMathematics, 1970.
Beckert, Ulbrich – Formale Systeme II: Theorie 20/47
![Page 21: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/21.jpg)
Presburger Arithmetic
Let ΣP = ({0, 1,+}, {<}), the signature w/o multiplication.
The Presburger Axioms P
1 ∀x(x + 1 6 .= 0)
2 ∀x∀y(x + 1.
= y + 1→ x.
= y)
3 ∀x(x + 0.
= x)
4 ∀x∀y(x + (y + 1).
= (x + y) + 1)
5 For any φ ∈ FmlΣN
(φ(0) ∧ ∀x(φ(x)→ φ(x + 1)))→ ∀x(φ)
A subset of the Peano axioms (w/o those for multiplication).
Conventions:3
def= 1 + 1 + 1, 3x
def= x + x + x , etc.
Beckert, Ulbrich – Formale Systeme II: Theorie 21/47
![Page 22: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/22.jpg)
Presburger Arithmetic
Mojzesz Presburger. Uber die Vollstandigkeit eines gewissenSystems der Arithmetik, Warsaw 1929
Theorem
He proved Presburger arithmetic to be
consistent,
complete, and
decidable.
We are interested in the 3rd property!
Beckert, Ulbrich – Formale Systeme II: Theorie 22/47
![Page 23: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/23.jpg)
Quantifier Elimination
Definition
A theory T admits quantifier elimination (QE) if any formula
Q1x1 . . .Qnxn. φ(x1, . . . , xn, y1, . . . , ym) ∈ Fmlo
is T -equivalent to a quantifier-free formula
ψ(y1, . . . , ym) ∈ Fmlo .
Qi ∈ {∀,∃}
If T -ground instances in FmlQF ∩ Fml can be decided, QE gives usa decision procedure for T .
Beckert, Ulbrich – Formale Systeme II: Theorie 23/47
![Page 24: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/24.jpg)
Quantifier Elimination
Lemma
If T admits QE for any formula
∃x . φ1(x , y1, . . . , ym) ∧ . . . ∧ φn(x , y1, . . . , ym) ∈ Fmlo
with φi literals, then T admits QE for any formula in Fmlo .
Literal: atomic formula or a negation of one.
Proof: (Easy) exercise.
Beckert, Ulbrich – Formale Systeme II: Theorie 24/47
![Page 25: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/25.jpg)
Presburger and Quantifier Elimination
Does Presburger Arithmetic admits QE?
Almost ... However
∃x .y = x + x has no quantifier-free P-equivalent
Add predicates: {k |· : k ∈ N>0} “k divides ...”
∃x .y = x + x ↔ 2|y is P-valid
Presburger Arithmetic with divisibility admits QE.
Cooper’s algorithm ... Blackboard
Beckert, Ulbrich – Formale Systeme II: Theorie 25/47
![Page 26: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/26.jpg)
Decision Procedures
Theory QF-SAT SATEquality YES YESUninterpreted functions YES co-SEMIInteger arithmetic NO NOLinear arithmetic YES YESReal arithmeticBitvectors YES YESFloating points YES YES
Beckert, Ulbrich – Formale Systeme II: Theorie 26/47
![Page 27: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/27.jpg)
Real Arithmetic
Beckert, Ulbrich – Formale Systeme II: Theorie 27/47
![Page 28: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/28.jpg)
Real arithmetic is decidable
Σ = ({+,−, ·, 0, 1}, {≤}), ϕ ∈ FmlΣ
Reminder:
N |= ϕ is not decidable, not even recursive enumerable (Godel).
Tarski-Seidenberg theorem (c. 1948)
R |= ϕ is decidable.Complexity is double exponential (c. 1988).
Idea: Quantifier elimination
Find formula ψ such that (∃x .ϕ(x , y))↔ ψ(y).Computer algebra systems do this: Redlog, Mathematica, (Z3)
Beckert, Ulbrich – Formale Systeme II: Theorie 28/47
![Page 29: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/29.jpg)
Real arithmetic – Axioms
Real arithmetic has a finite axiomatisation R
+ is an Abelian group, · is an Abelian semigroup:
∀x , y , z . (x + y) + z = x + (y + z) ∀x , y , z . (x · y) · z = x · (y · z)∀x , y . x + y = y + x ∀x , y . x · y = y · x∀x . x + 0 = x ∧ 0 + x = x ∀x . x · 1 = x ∧ 1 · x = x∀x . x + (−x) = 0 ∧ (−x) + x = 0
Distributive Laws∀x , y , z . (x + y) · z = x · z + y · z ∧ z · (x + y) = z · x + z · y
Ordering∀x , y , z . x ≤ y → x + z ≤ y + z∀x , y . 0 ≤ x ∧ 0 ≤ y → 0 ≤ xy
Beckert, Ulbrich – Formale Systeme II: Theorie 29/47
![Page 30: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/30.jpg)
Real closed fields
T (R) = T (R) is the set of FOL sentences that are true in R.
But there are also other interesting models of T (R):
Real numbers R,
Real algebraic numbers R ∩ Q(real numbers that are roots of polynomials with integer coeffs.)
Computable numbers(real numbers that can be approximated arbitrarily precisely.)
. . .
Beckert, Ulbrich – Formale Systeme II: Theorie 30/47
![Page 31: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/31.jpg)
Semialgebraic sets
Semialgebraic set
S ⊆ Rn is called semialgebraic if it defined by a booleancombination of polynomial equations and inequalitites.
Boolean combination means: ∪,∩, {
Observation:
S is semialgebaric iff there is a quantifier-free FOL-formula ϕ(S)with n free variables x1, . . . , xn such that
(s1, . . . , sn) ∈ S ⇐⇒ R, [x1 7→ s1, . . . , xn 7→ sn] |= ϕ(S)
Beckert, Ulbrich – Formale Systeme II: Theorie 31/47
![Page 32: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/32.jpg)
Tarski-Seidenberg Theorem
Definition: Projection πn : Rn → Rn−1
πn((s1, . . . , sn)) := (s1, . . . , sn−1)
πn(S) := {πn(s) | s ∈ S} (extended to 2R)
(s1, . . . , sn−1) ∈ πn(S) ⇐⇒ R, [x1 7→ s1, . . . , xn−1 7→ sn−1] |= ∃xn. ϕ(S)
Tarski-Seidenberg Theorem (Projektionssatz)
Let S ⊆ Rn be semialgebraic.Then πn(S) ∈ Rn−1 is also semialgebraic.
Beckert, Ulbrich – Formale Systeme II: Theorie 32/47
![Page 33: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/33.jpg)
Example
Single variable, single quadratic equation
Let Squad be the solutions of ax2 + bx + c = 0.(is semialgebraic: ax2 + bx + c ∈ R[a, b, c , x ])
Due to Tarski-Seidenberg, there must be an equiv. quantifier-freeformula ϕ(π4(Squad)) with free variables a, b, c .
∃x .ax2 + bx + c = 0
⇐⇒
(a 6= 0 ∧ b2 − 4ac ≥ 0)
∨ (a = 0 ∧ (b = 0→ c = 0))
(∃x .x3 + a2x2 + a1x + a0 = 0 is trivally equivalent to true.
)Beckert, Ulbrich – Formale Systeme II: Theorie 33/47
![Page 34: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/34.jpg)
Quantifier Elimination – Algorithm
1 Sufficient to look at ∃x .∧
i φi (y , x) for atomic φi .→ Excercise
2 Sufficient to consider φi of shape p(y , x){<>=
}0
for p ∈ R[y ][x ] → Why?
3 Every polynomial p ∈ R[x ] has finitely many connectedregions with same sign. → BoardChoose a set Rep of representatives.
4 ∃x .∧i
φi (x , y)↔∨
r∈Rep
∧i
φi (r , y)
Decision Technique
Cylindrical Algebraic Decomposition (CAD)
Beckert, Ulbrich – Formale Systeme II: Theorie 34/47
![Page 35: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/35.jpg)
Quantifier Elimination – Linear Example
In R[z , x ]:ψ := ∃x .x > 2 ∧ x < 3 ∧ x > z
Interesting points for x : I = {2, 3, z}Interesting intervals: (−∞, 2), (2, 3), (3,∞), (2, z), . . .
Representatives:Rep =
{2, 3, z , “−∞”, “+∞”, 2+3
2 , 2+z2 , 3+z
2
}={
i1+i22 | i1, i2 ∈ I
}∪ {“−∞”, “+∞”}
For the example:ψ ↔
∨r∈Rep r > 2 ∧ r < 3 ∧ x > z
↔ 2.5 > z ∨ (z > 2 ∧ z < 4 ∧ 2 > z) ∨ (z > 1 ∧ z < 3 ∧ 3 > z)↔ z < 3
Beckert, Ulbrich – Formale Systeme II: Theorie 35/47
![Page 36: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/36.jpg)
Decision Procedures
Theory QF-SAT SATEquality YES YESUninterpreted functions YES co-SEMIInteger arithmetic NO NOLinear arithmetic YES YESReal arithmetic YES YESBitvectors YES YESFloating points YES YES
Beckert, Ulbrich – Formale Systeme II: Theorie 36/47
![Page 37: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/37.jpg)
Divison
Adding division (the inverse ·−1) does not increse expressive power.
Consider Σdiv = Σ ∪ {·−1}.Let quantifier-free ϕ ∈ FmlqfΣdiv
contain a division by t:
ϕ[t−1] ↔((∃y .y = t−1 ∧ ϕ[y ]) ∨ (t = 0 ∧ ϕ[n])
)(1)
n is a fresh free variable for the value of “0−1”
Let ψ ∈ FmlΣdivcontain divisions.
Obtain ψ′ ∈ FmlΣ by applying (1) to literals in ψ.
R |= ψ ⇐⇒ R |= ∀n.ψ′
Underspecification: ψ is true in R if it is true for all possiblevaluations of “0−1”: R |= 1
0 = 10 , R 6|= 1
0 = 20
Beckert, Ulbrich – Formale Systeme II: Theorie 37/47
![Page 38: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/38.jpg)
Combining Theories
Beckert, Ulbrich – Formale Systeme II: Theorie 38/47
![Page 39: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/39.jpg)
Combining Theories
What if we have two (or more) theories within one formula?
f (a) = g(a + 1) ∧ g(a + b) > f (a) satisfiable?
Decision procedures exist for linear integers, and for uninterpretedfunctions.
Goal
Find decision procedures for combinations of theories.
Combinations of theoriesLet T1 ⊆ FmlΣ1 and T2 ⊆ FmlΣ2 be theories.The combined theory T1,2 ∈ FmlΣ1∪Σ2 is defined as:
T1,2def= T (T1 ∪ T2)
Beckert, Ulbrich – Formale Systeme II: Theorie 39/47
![Page 40: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/40.jpg)
Purification
f (a) = g(a + 1) ∧ g(a + b) > f (a) (1)
Purification
Extract expressions using fresh constants and equalities.Make each atomic formula belong to one theory only.
f (a) = g(y) ∧ y = a + 1 ∧z = g(u) ∧ u = a + b ∧ w = f (a) ∧ z > w
is equisatisfiable to (1).
Note: This resembles the construction of the “short CNF”.
Beckert, Ulbrich – Formale Systeme II: Theorie 40/47
![Page 41: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/41.jpg)
Convex Theories
Definition
A Σ theory T is convex if for every conjunctive ϕ ∈ FmlΣ
(ϕ→⋃
i=1 xi = yi ) is T -valid for some finite n > 1implies that
(ϕ→ xi = yi ) is T -valid for some i ∈ {1, . . . , n}
where xi , yi , for i ∈ {1, . . . , n}, are variables.
Examples:
Linear arithmetic over R is convex.
Linear arithmetic over N is not convex:
x1 = 1 ∧ x2 = 2 ∧ 1 ≤ x3 ∧ x3 ≤ 2→ (x3 = x1 ∨ x3 = x2)
Beckert, Ulbrich – Formale Systeme II: Theorie 41/47
![Page 42: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/42.jpg)
Nelson-Oppen Combination Procedure
In order for the Nelson–Oppen procedure to be applicable, thetheories T1,T2 must comply with the following restrictions:
1 T1,T2 are quantifier-free first-order theories with equality.
2 There is a decision procedure for each of the theories
3 The signatures are disjoint, i.e., for all Σ1 ∩ Σ2 = ∅4 T1,T2 are theories are stably infinite: Every T -satisfiable
formula has an infinite model (e.g., linear arithmetic over R,but not the theory of finite-width bit vectors).
(Generalisation to more than two theories: simple, see literature)
Beckert, Ulbrich – Formale Systeme II: Theorie 42/47
![Page 43: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/43.jpg)
Example
from: D. Kroning, O.Strichman: Decision Procedures, Springer Verlag
Beckert, Ulbrich – Formale Systeme II: Theorie 43/47
![Page 44: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/44.jpg)
Example
Beckert, Ulbrich – Formale Systeme II: Theorie 44/47
![Page 45: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/45.jpg)
Nelsson-Oppen Algorithm – convex case
T1,T2 convex theories with with the Nelsson-Oppen properties.Assume convex (conjunctive) problem.
τ bridges between T1 and T2 and is a conjunction of equalitiesover variables
After purification: ϕ1 ∈ Fml1, ϕ2 ∈ Fml2, τ ⊆ Fml=
1 If ϕ1 ∧∧τ is T1-unsatisfiable, return UNSAT
2 If ϕ2 ∧∧τ is T2-unsatisfiable, return UNSAT
3 “learn” new equalities:τ := τ ∪
⋃{x = y | ϕ1 ∧ τ → x = y is T1-valid}
∪⋃{x = y | ϕ2 ∧ τ → x = y is T2-valid}
4 If nothing was “learnt”, return SAT
5 Go to 1
Beckert, Ulbrich – Formale Systeme II: Theorie 45/47
![Page 46: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/46.jpg)
Soundness
This algorithm is a decision procedure for T1/2.
To show: ϕ1 ∧ ϕ2 is satisfiable ⇐⇒ algorithm returns SAT .
Proof sketch on blackboard
see also: D. Kroning, O. Strichman: Decision Procedures, SpringerVerlag. Section 10.3.3.
Beckert, Ulbrich – Formale Systeme II: Theorie 46/47
![Page 47: Formale Systeme II: Theorie - Theories · Formale Systeme II: Theorie Theories SS 2018 Prof. Dr. Bernhard Beckert Dr. Mattias Ulbrich KIT { Die Forschungsuniversit at in der Helmholtz-Gemeinschaft](https://reader030.fdocument.pub/reader030/viewer/2022041209/5dd071b106d5421854452be9/html5/thumbnails/47.jpg)
Non-convex theories
1 If ϕ1 ∧ τ is T1-unsatisfiable, return UNSAT
2 If ϕ2 ∧ τ is T2-unsatisfiable, return UNSAT
3 “learn” new equalities:τ := τ ∧
∧{x = y | ϕ1 ∧ τ → x = y is T1-valid}
∧∧{x = y | ϕ2 ∧ τ → x = y is T2-valid}
4 If nothing was “learnt”, split: If there exists i such that
ϕi → (x1 = y1 ∨ . . . ∨ xk = yk) andϕi 6→ (xj = yj)
then apply Nelson–Oppen recursively to adding xi = yi to thedifferent τ .If any of these subproblems is satisfiable, return “Satisfiable”.Otherwise, return “Unsatisfiable”.
Beckert, Ulbrich – Formale Systeme II: Theorie 47/47