First-Order Logic Theories
Total Page:16
File Type:pdf, Size:1020Kb
First-order logic theories 20 de Maio de 2019 First-order logic theories Decidability Decision problems Validity \Is the formula ' valid?" Satisfiability \Is the formula ' satisfiable?” Consequence \Is the formula ' a consequence of ?" Equivalence \Is the formula ' equivalent to ?" These problems can be solved as instances of the others: ' is valid iff :' is not satisfiable ' is satisfiable iff :' is not valid ' j= iff :(' ! ) is not satisfiable ' ≡ iff ' j= and j= ' First-order logic theories Decidability A solution to a decision problem is a procedure that, given instances of the problem as input, always terminates with an \yes" or \no" answer as output. We say that a decision problem is decidable if it has a solution, otherwise it is undecidable. In propositional logic (PL) deciding satisfiability can always be done (in theory), using a truth table. Theorem (Church & Turing) The validity/satisfiability in FOL (first-order logic) is undecidable. The validity in FOL implies verifying all the possible models. First-order logic theories Semi-decidability There is a procedure that terminates with a \yes" answer when a FOL formula is valid. Theorem Validity in FOL is semi-decidable. A problem is semi-decidable if there exists a procedure that: • terminates with the answer \yes" if and only if \yes" is the correct answer; • if the correct answer is \no", terminates with a \no" answer or does not terminate. Contrary to a decidable problem, there is only a guarantee of termination when the correct answer is \yes". First-order logic theories Logical fragments One can reduce the validity (satisfiability) of FOL formulas to the existence of appropriate instance of a quantifier free formula (using Herbrandisation/Skolemisation). • If the vocabulary has a finite set of constants and no other functional symbols then the set of terms is finite. • If one restricts to formulas with a prenex normal form of the form 8x9y , then one only introduces constants by Herbrandisation. A FOL formula can be equivalent to a formula satisfying the condition above: 9x8y(P(x) _ Q(y)) ≡ 9xP(x) _ 8yQ(y) ≡ 8y9x(P(x) _ Q(y)) First-order logic theories Decidable fragments There exist decidable fragments of FOL: Monadic predicate logic: • only monadic predicates; • no functional symbols. The Bernays-Schonfinkel class of formulas: • formulas that can be written with all the quantifiers at the beginning of the formulas; • the existential quantifiers appear before the universal quantifiers; • no functional symbols. First-order logic theories FOL with equality There are two approaches when we deal with equality in FOL. FOL without equality We treat the equality predicate (=), as any other predicate, that is, as a non-logical symbol. FOL with equality We treat the equality predicate (=), as a logical symbol, with a fixed interpretation. For a particular structure A and interpretation s: A j=s t1 = t2 iff s(t1) = s(t2) The last approach allows us to fix the cardinality of the domain: 9x1x28y(y = x1 _ y = x2) First-order logic theories First Order Theories The non-logical of FOL do not have a pre-determined meaning: For example, the formula 1 + 1 > 3 is satisfiable. Sometimes we are not interested in validity in general, but with respect to a theory that fixes the interpretation of certain predicates and functional symbols. • Theory of equality • Theory of natural numbers • Theory of real numbers • Theory of arrays or lists, etc... First-order logic theories First-order theories A theory T is a set of formulas closed by logic consequence (i.e. T j= φ iff φ 2 T ) First-order theory A first-order theory T consists of: • a vocabulary V (set of constants, functional and relational symbols) • a set AT of axioms (closed formulas) Note that: • The symbols of V are such symbols without a pre-determined meaning • The axioms of T provide the meaning A theory T is finitely (resp. recursively) axiomatisable if it possesses a finite (resp. recursive) set of axioms. First-order logic theories T -Validity and T -Satisfiability T -structure A T -structure (or T -model) is a structure that satisfies all the axioms of T . Validity-T A T -formula ' is T -valid iff every T -structure satisfies '. Satisfiability-T A T -formula ' is T -satisfiability iff any T -structure satisfies '. Equivalence-T Two T -formulas ' and are T -equivalents iff the same T -structures satisfies ' and . First-order logic theories Theory of equality TE The vocabulary of the theory of equality TE consists of • the equality (=), which is the only interpreted symbol; • constants, functional and predicate symbols, which are not interpreted (except when related to =). Axioms of TE : • 8x:x = x • 8x; y:x = y ! y = x • 8x; y; z:x = y ^ y = z ! x = z • for each positive integer n and n-ary function f , V 8x1;:::; xn; y1;:::; yn: i xi = yi ! f (x1;:::; xn) = f (y1;:::; yn) • for each positive integer n and n-ary predicate symbol P, V 8x1;:::; xn; y1;:::; yn: i xi = yi ! P(x1;:::; xn) $ P(y1;:::; yn) Validity in TE is undecidable, but efficiently decidable in the quantifier-free fragment (qff) of TE . First-order logic theories A decision procedure for satisfiability qff TE Consider a decision procedure for formulas consisting of conjunctions of literals, and allowing functions, but no predicates. Eliminating predicates Consider the following transformation yielding equi-satisfiable formulas with no predicates. For each relational symbol P: 1 introduce a new functional symbol fP ; 2 write P(t1;:::; tn) as fP (t1;:::; tn) = t where t is a new constant. Example Transform x = y ! (P(x) _ P(y)) into an equi-satisfiable formula. First-order logic theories Theory of equality TE Axioms of TE : • 8x:x = x • 8x; y:x = y ! y = x • 8x; y; z:x = y ^ y = z ! x = z • for each positive integer n and n-ary function f , V 8x1;:::; xn; y1;:::; yn: i xi = yi ! f (x1;:::; xn) = f (y1;:::; yn) Example Are the following formulas, satisfiable, unsatisfiable or valid? • x 6= y ^ f (x) = f (y) • x = g(y; z) ! f (x) = f (g(y; z)) • f (a) = a ^ f (f (a)) 6= a • f (f (f (a))) = a ^ f (f (f (f (f (a))))) = a ^ f (a) 6= a First-order logic theories Theory of equality TE We decide satisfiability for TE using the congruence closure algorithm that computes the congruence closure of the binary relation defined by formula. Equivalence relation A binary relation R over A is an equivalence relation if: 1 8a 2 A:aRa (reflexive) 2 8a1; a2 2 A:a1Ra2 ! a2Ra1 (symmetric) 3 8a1; a2; a3 2 A:a1Ra2 ^ a2Ra3 ! a1Ra3 (transitive). Which of the following are equivalence relations: ≡n over Z, ≥ over N, jxj = jyj over R? First-order logic theories Congruence relations Congruence relation A congruence relation R is an equivalence relation over a set A equiped with a set of functions F = ff1;:::; fng, such that, for every f 2 F: ^ 8a1;:::; an; b1;:::; bn: ai Rbi ! f (a1;:::; an) R f (b1;:::; bn) i Are the relations = over N, ≡n over Z and jxj = jyj over R, together with the successor function, congruence relations? Equivalence and Congruence classes For every a 2 A, the equivalence class of a under R is the set: [a]R = fb 2 A : aRbg: In a congruence relation, this set is called the congruence class. First-order logic theories Equivalence and Congruence closures The equivalence closure RE of a binary relation R over A is the smallest equivalence relation that includes R. That is, RE is the the equivalence relation satisfying the following: E 1 R ⊆ R E 2 for every other equivalence relations S: R ⊆ S ! R ⊆ S Similarly one defines the congruence closure RC of a binary relation R over A as the smallest congruence relation that includes R. Example Consider the set A = f1; 2; 3g and function f such that: f (1) = 2, f (2) = 3, f (3) = 3. What is the congruence closure of R = f(1; 2)g? First-order logic theories Satisfiability using Congruence Relations The satisfiability of a TE formula is defined in terms of the congruence closure over the subterm set SF of the formula, that is, the set of all subterms of F . Consider the TE formula: F : s1 = t1 ^ · · · ^ sm = tm ^ sm+1 6= tm+1 ^ · · · ^ sn 6= tn Then considere the relation RF on SF ; RF = f(si ; ti ) j i 2 f1;:::; mgg Theorem F is satisfiable if the congruence closure ∼ of RF satisfies si 6∼ ti ; 8i 2 fm + 1;:::; ng. First-order logic theories Congruence Closure Algorithm Algorithm Consider a formula F in TE and the subset set SF . • Construct the congruence closure ∼ of SF . • If si ∼ ti for any i 2 fm + 1;:::; ng, F is unsatisfiable, otherwise F is satisfiable. Let us represent ∼ as a set of congruence classes: if t1 and t2 are in the same set, then t1 ∼ t2, otherwise t1 6∼ t2: We start by determining the subterm set SF , and ∼ by placing each subterm in a separate set. If s1 = t1, then merge the classes of s1 and t1. First-order logic theories Example For F : f (a; b) = a ^ f (f (a; b); b) 6= a, consider the initial congruence classes: ffa; f (a; b)g; fbg; ff (f (a; b); b)gg From a ∼ f (a; b) and b ∼ b we get ffa; f (a; b); f (f (a; b); b)g; fbgg Since a and f (f (a; b); b) are in the same class, we have a ∼ f (f (a; b); b) This contradicts f (f (a; b); b) 6= a.