Download presentation
Presentation is loading. Please wait.
Published byWilfrid Norman Modified over 9 years ago
1
1 First order theories
2
2 Satisfiability The classic SAT problem: given a propositional formula , is satisfiable ? Example: Let x 1,x 2 be propositional variables Let := (x 1 → x 2 ) Æ (x 1 Æ :: x 2 ) Is satisfiable ?
3
3 Satisfiability Modulo Theories Now let the predicates be equalities Example: Let x 1,x 2,x 3 2 Z Let := ((x 1 = x 2 ) → (x 2 = x 3 )) Æ x 1 x 3 Is satisfiable ?
4
4 Satisfiability Modulo Theories Now let the predicates be from linear arithmetic Example: Let x 1,x 2,x 3 2 R Let := ((x 1 + 2x 3 < 5) Ç : (x 3 · 1) Æ (x 1 ¸ 3)) Is satisfiable ?
5
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
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
7 Some useful first-order theories The SMT web page: http://combination.cs.uiowa.edu/smtlib/http://combination.cs.uiowa.edu/smtlib/
8
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
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: xx f(f(x)) g(f(x),g(y,z))) Example of predicates: a p(f(x),g(x,y))
10
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
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
12
12 First-order theories First-order logic is a framework. It gives us a generic syntax and building blocks for constructing restrictions thereof. Each such restriction is called a first-order theory.
13
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
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: 9 y 8 x. p(x, y) Is it true ? depends on the interpretation we give to p. Does there exists a satisfying interpretation?
15
15 Example 2 = {1,p 1,p 2, p 3 } ‘1’ is a constant symbol p 1, p 2 are binary predicates p 3 is a unary predicate An example -formula: 8 n 9 k. p 2 (n,1 ) ! p 3 ( k ) Æ p 1 (n,k ) Æ p 1 (k, 2n). is this formula satisfiable ? i.e., is there an interpretation that makes it true ?
16
16 Example 2, interpreted set p 1 = ‘>’, p 2 = ‘<‘, p 3 = isPrime. So now the formula is: 8 n 9 k. n > 1 ! isprime(k) Æ n < k < 2n. This is Bertrand’s postulate Proven separately by Chhebyshev, Ramanujan, Erdos.
17
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 = 9 x. x + 0 = 1 Q: Is true in N 0 ?
18
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
19 Structures = 9 x. f(x, 0) = 1 Consider the structure S: Domain: N 0 Interpretation: ‘f’ * (multiplication) ‘0’ and ‘1’ are mapped to 0 and 1 in N 0 ‘=‘ = (equality) Now, is true in S ?
20
20 Satisfying structures Definition: A formula is satisfiable if there exists a structure that satisfies it Example: = 9 x. f(x, 0) = 1 is satisfiable Consider the structure S’: Domain: N 0 Interpretation: ‘0’ and ‘1’ are mapped to 0 and 1 in N 0 ‘=’ = (equality) ‘f’ + (addition) is satisfied by S’. S’ is a model of .
21
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
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
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
24 2. Definitions... For a signature : - formula: a formula over symbols + logical symbols. A -theory T is defined by a set of -sentences.
25
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
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
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
28 2. Axioms for some ‘famous’ predicates Let ‘T’ be: (defining ‘<‘) Example: Á : 8 x. 9 y. y < x Is Á T-satisfiable? We will show a model for it. Domain: Z ‘< ‘ < 8 x,y,z. x < y Æ y < z → x < z(transitivity) 8 x,y. x < y → : (y < x)(anti-symmetry)
29
29 2. Axioms for some ‘famous’ predicates Let ‘T’ be: (defining ‘<‘) Example: Á : 8 x. 9 y. y < x Is Á T-valid? 8 x,y,z. x < y Æ y < z → x < z(transitivity) 8 x,y. x < y → : (y < x)(anti-symmetry) We will show a structure to the contrary Domain: N 0 ‘<‘ <
30
30 2. Axioms for some ‘famous’ predicates Let = {‘<‘} Consider the -formula Á : 8 x. 9 y. y < x Consider the theory T: Is Á T-valid? We will show a structure to the contrary Domain: N 0 ‘<‘ < 8 x,y,z. x < y Æ y < z → x < z(transitivity) 8 x,y. x < y → : (y < x)(anti-symmetry)
31
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
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
33 Theories Let = {} (T must be empty: no nonlogical symbols to interpret) Q: What is T ? A: Quantified Boolean Formulas (QBF) Example: 8 x 1 9 x 2 8 x 3. x 1 → (x 2 Ç x 3 )
34
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
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 Æ formula literal: Boolean-variable | : Boolean-variable ( x 1 Ç : x 2 ) Æ ( : x 3 Ç x 2 )
36
36 Expressiveness of a theory Now consider a Propositional Logic formula ( x 1 Ç x 2 Ç x 3 ). Q: Can we express this language with 2-CNF? A: No. Proof: The language accepted by has 7 words: all assignments other than x 1 = x 2 = x 3 = F. The first 2-CNF clause removes ¼ of the assignments, which leaves us with 6 accepted words. Additional clauses only remove more assignments.
37
37 Expressiveness of a theory Claim: 2-CNF Á Propositional Logic Generally there is only a partial order between theories. Languages defined by L 2 Languages defined by L 1 L 2 is more expressive than L 1. Denote: L 1 Á L 2
38
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
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. Induction 4. 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
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. Induction 4. 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
41 Tradeoff: expressiveness/computational hardness. Assume we are given theories L 1 Á … Á L n More expressive Easier to decide UndecidableDecidable Intractable (exponential) Tractable (polynomial) Computational Challenge! LnLn L1L1 Our course
42
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
43 Expressiveness and complexity Q1: Let L 1 and L 2 be two theories whose satisfiability problem is decidable and in the same complexity class. Is the satisfiability problem of an L 1 formula reducible to a satisfiability problem of an L 2 formula?
44
44 Expressiveness and complexity Q2: Let L 1 and L 2 be two theories whose satisfiability problems are reducible to one another. Are L 1 and L 2 in the same complexity class ?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.