Upload
wilfrid-norman
View
224
Download
0
Tags:
Embed Size (px)
Citation preview
1
First order theories
2
Satisfiability
The classic SAT problem: given a propositional formula , is satisfiable ?
Example:
Let x1,x2 be propositional variables
Let := (x1 → x2) Æ (x1 Æ :: x2)
Is satisfiable ?
3
Satisfiability Modulo Theories
Now let the predicates be equalities
Example:
Let x1,x2,x3 2 Z
Let := ((x1 = x2) → (x2 = x3)) Æ x1 x3
Is satisfiable ?
4
Satisfiability Modulo Theories
Now let the predicates be from linear arithmetic
Example:
Let x1,x2,x3 2 R
Let := ((x1 + 2x3 < 5) Ç :(x3 · 1) Æ (x1 ¸ 3))
Is satisfiable ?
5
Satisfiability Modulo Theories
Now let the predicates represent arrays
Example:
Let i,j,a[] 2 Z
Let := (i = j Æ a[j] = 1) Æ a[i] 1
Is satisfiable ?
6
Generalization
Equalities, linear predicates, arrays, ... Is there a general framework to define them ?
Yes ! It is called first-order logic
Each of the above examples is a first-order theory.
7
Some useful first-order theories
The SMT web page: http://combination.cs.uiowa.edu/smtlib/
8
What lies ahead...
As in the case of propositional logic, we need to define Syntax Semantics
But it is more difficult, because: First-order logic is a template for defining theories Semantics cannot be defined with truth-tables
The domains can be infinite !
9
First-order logic: Terms & predicates
Let x,y be variables f,g be function symbols (unary & binary, respectively) a,b,c be propositional variables p be a binary predicate symbol
Example of terms: x f(f(x)) g(f(x),g(y,z)))
Example of predicates: a p(f(x),g(x,y))
10
First-order logic – Grammar
A FOL formula is a predicate, or An application of a propositional connective over FOL
formula(s) An application of a quantifier (9, 8) over a FOL formula
Examples:
11
First-order Logic / scopes
Each quantifier has a scope
If a variable is not quantified, it is called free
A formula without free variables is called a sentence
Here, b is free
13
First order logic
We distinguish between Logical symbols: Æ Ç : 8 9 ( ) Non-logical Symbols :
function symbols (incl. constants) predicate symbols
is the ‘signature’ of the theory restricts the syntax The theory also restricts the semantics of the symbols in
We will see how...
14
Example 1
= {0,1,f,p} ‘0’,’1’ are constant symbols ‘f’ is a binary function symbol ‘p’ is a binary predicate
An example of a -formula:
9y 8x. p(x, y)
Is it true ? depends on the interpretation we give to p. Does there exists a satisfying interpretation?
15
Example 2
= {1,p1,p2, p3} ‘1’ is a constant symbol p1, p2 are binary predicates p3 is a unary predicate
An example -formula:
8n 9k. p2(n,1) ! p3(k) Æ p1(n,k) Æ p1(k, 2n).
is this formula satisfiable ? i.e., is there an interpretation that makes it true ?
16
Example 2, interpreted
set p1 = ‘>’, p2 = ‘<‘, p3 = isPrime.
So now the formula is:
8n 9k. n > 1 ! isprime(k) Æ n < k < 2n.
This is Bertrand’s postulate Proven separately by Chhebyshev, Ramanujan, Erdos.
17
Without interpretations...
Technically, we should also assign interpretation to symbols that are already ‘taken’: ‘+’,’*’, ‘<‘, ... In practice no one in their right mind gives them non-
standard interpretation.
Example: Let = {0,1,+,=} where 0,1 are
constants, + is a binary function and = a predicate.
Let = 9x. x + 0 = 1 Q: Is true in N0 ?
18
An interpretation is given by a structure A structure is given by:
1. A domain to each variable
2. An interpretation of the nonlogical symbols: i.e., Maps each function symbol to a function of the same arity Maps each constant symbol to a domain element Maps each predicate symbol to a predicate of the same arity
3. An assignment of a domain element to each free (unquantified) variable
19
Structures
= 9x. f(x, 0) = 1 Consider the structure S:
Domain: N0
Interpretation: ‘f’ * (multiplication) ‘0’ and ‘1’ are mapped to 0 and 1 in N0
‘=‘ = (equality)
Now, is true in S ?
20
Satisfying structures
Definition: A formula is satisfiable if there exists a structure that satisfies it
Example: = 9x. f(x, 0) = 1 is satisfiable Consider the structure S’:
Domain: N0
Interpretation: ‘0’ and ‘1’ are mapped to 0 and 1 in N0
‘=’ = (equality) ‘f’ + (addition)
is satisfied by S’. S’ is a model of .
21
Two ways to define a theory
We can define a theory
1. The easy, “direct” way, Define the grammar, Assume standard interpretation of the symbols.
2. The hard, “formal” way. Define the signature Restrict possible interpretations with sentences/axioms
Very useful for defining algorithms and proving
general theorems
22
1. Defining a theory: the easy way
Example: The quantifier-free theory of equalities
Grammar: A Boolean combination of predicates of the form “x = y”, where x,y 2 R.
Example: x = y Ç :(y = z ! x = z)
Note that here... we implicitly say that ‘=‘ is the equality predicate, and we predefine the domain of the variables
23
2. Defining a theory: the hard way
Let be a signature
A theory defined over is called a -theory
A -theory restricts the interpretations that we can give the symbols in . How ?
24
2. Definitions...
For a signature :
-formula: a formula over symbols + logical symbols.
A -theory T is defined by a set of -sentences.
25
2. Definitions…
Let T be a -theory
A -formula is T-satisfiable if there exists a structure
that satisfies both and the sentences defining T.
A -formula is T-valid if all structures that satisfy the
sentences defining T also satisfy .
26
2. Theories through axioms
The number of sentences that are necessary for defining a theory might be large or infinite.
Instead, it is common to define a theory through a set of axioms.
The theory is defined by these axioms, and everything that can be inferred from them by a sound
inference system.
27
2. Axioms for some ‘famous’ predicates Let ‘T’ be: (defining ‘=‘):
Example: = ((x = y) Æ :(y = z)) ! :(x = z) Is Á T-valid ?
Every structure that satisfies these axioms, satisfies . Hence is T-valid.
8 x. x = x(reflexivity)
8 x,y. x = y ! y = x (symmetry)
8 x,y,z. x = y Æ y = z ! x = z (transitivity)
28
2. Axioms for some ‘famous’ predicates Let ‘T’ be: (defining ‘<‘)
Example: Á: 8x. 9y. y < x Is Á T-satisfiable?
We will show a model for it. Domain: Z ‘< ‘ <
8x,y,z. x < y Æ y < z → x < z (transitivity)
8x,y. x < y → :(y < x) (anti-symmetry)
29
2. Axioms for some ‘famous’ predicates Let ‘T’ be: (defining ‘<‘)
Example: Á: 8x. 9y. y < x Is Á T-valid?
8x,y,z. x < y Æ y < z → x < z (transitivity)
8x,y. x < y → :(y < x) (anti-symmetry)
We will show a structure to the contrary
Domain: N0
‘<‘ <
30
2. Axioms for some ‘famous’ predicates Let = {‘<‘} Consider the -formula Á: 8x. 9y. y < x Consider the theory T:
Is Á T-valid?
We will show a structure to the contrary Domain: N0
‘<‘ <
8x,y,z. x < y Æ y < z → x < z (transitivity)
8x,y. x < y → :(y < x) (anti-symmetry)
31
Fragments
So far we only restricted the nonlogical symbols. Sometimes we want to
restrict the grammar restrict the allowed logical symbols.
These are called logic fragments.
Examples: The quantifier-free fragment over = {=,+,0,1} The conjunctive fragment over = {=,+,0,1}
32
Fragments
Let = {} (T must be empty: no nonlogical symbols to interpret)
Q: What is the quantifier-free fragment of T ? A: propositional logic
Thus, propositional logic is also a first-order theory. A very degenerate one.
33
Theories
Let = {} (T must be empty: no nonlogical symbols to interpret)
Q: What is T ? A: Quantified Boolean Formulas (QBF)
Example: 8x1 9x2 8x3. x1 → (x2 Ç x3)
34
Some famous theories
Presburger arithmetic: = {0,1,+,=} Peano arithmetic: = {0,1,+,*,=} Theory of reals Theory of integers Theory of arrays Theory of pointers Theory of sets Theory of recursive data structures …
35
Expressiveness of a theory
Each formula defines a language:the set of satisfying assignments (‘models’) are the words accepted by this language.
Consider the fragment ‘2-CNF’formula : ( literal Ç literal ) | formula Æ formulaliteral: Boolean-variable | :Boolean-variable
(x1 Ç :x2) Æ (:x3 Ç x2)
36
Expressiveness of a theory
Now consider a Propositional Logic formula (x1 Ç x2 Ç x3).
Q: Can we express this language with 2-CNF? A: No.
Proof: The language accepted by has 7 words: all assignments
other than x1 = x2 = x3 = F. The first 2-CNF clause removes ¼ of the assignments,
which leaves us with 6 accepted words. Additional clauses only remove more assignments.
37
Expressiveness of a theory
Claim: 2-CNF Á Propositional Logic Generally there is only a partial order between
theories.
Languages defined by L2
Languages defined by L1
L2 is more expressive than L1.
Denote: L1 Á L2
38
The tradeoff
So we see that theories can have different expressive power
Q: why would we want to restrict ourselves to a theory or a fragment ? why not take some ‘maximal theory’…
A: Adding axioms to the theory may make it harder to decide or even undecidable.
39
Example: First Order Peano Arithmetic = {0,1,‘+’, ‘*’, ‘=’} Domain: Natural numbers
Axioms (“semantics”):1. 8 x. (0 x + 1) 2. 8 x, y. (x y) ! (x + 1 y + 1) 3. Induction4. 8 x. x + 0 = x 5. 8 x, y. (x + y) + 1 = x + (y + 1) 6. 8 x. x * 0 = 0 7. 8 x, y. x * (y + 1) = x * y + x
+
*
Undecidable!
These axioms define the semantics of ‘+’
40
Example: First Order Presburger Arithmetic = {0,1,‘+’, ‘*’, ‘=’} Domain: Natural numbers
Axioms (“semantics”):1. 8 x. (0 x + 1) 2. 8 x, y. (x y) ! (x + 1 y + 1) 3. Induction4. 8 x. x + 0 = x 5. 8 x, y. (x + y) + 1 = x + (y + 1) 6. 8 x. x * 0 = 0 7. 8 x, y. x * (y + 1) = x * y + x
+
*
decidable!
These axioms define the semantics of ‘+’
41
Tradeoff: expressiveness/computational hardness. Assume we are given theories L1 Á … Á Ln
More expressiveEasier to decide
UndecidableDecidable
Intractable(exponential)
Tractable(polynomial)
Computational Challenge! LnL1
Our course
42
When is a specific theory useful?
1. Expressible enough to state something interesting.
2. Decidable (or semi-decidable) and more efficiently solvable than richer theories.
3. More expressive, or more natural for expressing some models in comparison to ‘leaner’ theories.
43
Expressiveness and complexity
Q1: Let L1 and L2 be two theories whose satisfiability problem is decidable and in the same complexity class. Is the satisfiability problem of an L1 formula reducible to a satisfiability problem of an L2 formula?
44
Expressiveness and complexity
Q2: Let L1 and L2 be two theories whose satisfiability problems are reducible to one another. Are L1 and L2 in the same complexity class ?