Classical First-Order Logic Software Formal Verification
Total Page:16
File Type:pdf, Size:1020Kb
Classical First-Order Logic Software Formal Verification Maria Jo~aoFrade Departmento de Inform´atica Universidade do Minho 2008/2009 Maria Jo~aoFrade (DI-UM) First-Order Logic (Classical) MFES 2008/09 1 / 31 Introduction First-order logic (FOL) is a richer language than propositional logic. Its lexicon contains not only the symbols ^, _, :, and ! (and parentheses) from propositional logic, but also the symbols 9 and 8 for \there exists" and \for all", along with various symbols to represent variables, constants, functions, and relations. There are two sorts of things involved in a first-order logic formula: terms, which denote the objects that we are talking about; formulas, which denote truth values. Examples: \Not all birds can fly." \Every child is younger than its mother." \Andy and Paul have the same maternal grandmother." Maria Jo~aoFrade (DI-UM) First-Order Logic (Classical) MFES 2008/09 2 / 31 Syntax Variables: x; y; z; : : : 2 X (represent arbitrary elements of an underlying set) Constants: a; b; c; : : : 2 C (represent specific elements of an underlying set) Functions: f; g; h; : : : 2 F (every function f as a fixed arity, ar(f)) Predicates: P; Q; R; : : : 2 P (every predicate P as a fixed arity, ar(P )) Fixed logical symbols: >, ?, ^, _, :, 8, 9 Fixed predicate symbol: = for \equals" (“first-order logic with equality") Maria Jo~aoFrade (DI-UM) First-Order Logic (Classical) MFES 2008/09 3 / 31 Syntax Terms The set T , of terms of FOL, is given by the abstract syntax T 3 t ::= x j c j f(t1; : : : ; tar(f)) Formulas The set L, of formulas of FOL, is given by the abstract syntax L 3 φ, ::= ? j > j :φ j φ ^ j φ _ j φ ! j t1 = t2 j 8x: φ j 9x: φ j P (t1; : : : ; tar(P )) :, 8, 9 bind most tightly; then _ and ^; then !, which is right-associative. Maria Jo~aoFrade (DI-UM) First-Order Logic (Classical) MFES 2008/09 4 / 31 Free and bound variables The free variables of a formula φ are those variables occurring in φ that are not quantified. FV(φ) denotes the set of free variables occurring in φ. The bound variables of a formula φ are those variables occurring in φ that do have quantifiers.BV (φ) denote the set of bound variables occurring in φ. Note that variable can have both free and bound occurrences within the same formula. Let φ be (9x: R(x; y) ^ (8y: P (y; x))), then FV(φ) = fyg and BV(φ) = fx; yg. A formula φ is closed if it does not contain any free variables. If FV(φ) = fx1; : : : ; x2g, then I its universal closure is 8x1:::: 8xn: φ I its existential closure is 9x1:::: 9xn: φ Maria Jo~aoFrade (DI-UM) First-Order Logic (Classical) MFES 2008/09 5 / 31 Substitution Convention We write φ(x1; : : : ; xn) to denote a formula having free variables x1; : : : ; xn. We write φ(t1; : : : ; tn) to denote the formula obtained by replacing each free occurrence of xi in φ with the term ti. When using this notation, it should always be assumed that each ti contains none of the variables in BV(φ). E.g., if φ(x) is 9y: x = y then we do not allow the substitution φ(y). A sentence of first-order logic is a formula having no free variables. The presence of free variables distinguishes formulas from sentences. This distinction did not exist in propositional logic. Maria Jo~aoFrade (DI-UM) First-Order Logic (Classical) MFES 2008/09 6 / 31 Semantics Vocabulary A vocabulary (or signature) is a set of function, relation, and constant symbols. C[F[P is a vocabulary. V-structure Let V be a vocabulary. A V-structure consists of a nonempty underlying set U along with an interpretation of V. An interpretation of V assigns: an element of U to each constant in V, a function from U n to U to each n-ary function in V, and a subset of U n to each n-ary relation in V. Model We say that M is a model of (C; F; P) iff M is a (C[F[P)-structure. Maria Jo~aoFrade (DI-UM) First-Order Logic (Classical) MFES 2008/09 7 / 31 Semantics An alternative definition: Model A model M of (C; F; P) consists of the following set of data: a non-empty set U, the universe of concrete values; for each constant symbol c 2 C, a concrete element M(c) 2 U; for each f 2 F, a concrete function M(f): U ar(f) !U; for each P 2 P, a subset M(P ) ⊆ U ar(P ). The set U the interpretation domain (or interpretation universe) of M. Semantically, one recognises the special role of equality by imposing on an interpretation function M(=) to be actual equality on the set U of M. Thus, (a; b) is in the set M(=) iff a and b are the same elements in the set U. Maria Jo~aoFrade (DI-UM) First-Order Logic (Classical) MFES 2008/09 8 / 31 Semantics Assignment An assignment or environment for a universe U of concrete values is a function α : X!U. We denote by α[x := a] the assignment which maps x to a and any other variable y to α(y). Given a model M for (C; F; P) with interpretation domain U, and given an assignment α : X!U, we define an interpretation function for terms, αM : T!U, as follows: αM(x) = α(x) αM(f(t1; : : : ; tn)) = M(f)(αM(t1); : : : ; αM(tn)) Maria Jo~aoFrade (DI-UM) First-Order Logic (Classical) MFES 2008/09 9 / 31 Semantics Satisfaction relation Given a model M for (C; F; P) and given an assignment α : X!U, we define the satisfaction relation M j=α φ for each logical formula φ over (C; F; P) as follows: M j=α > M 6j=α ? M j=α P (t1; : : : ; tn) iff (αM(t1); : : : ; αM(tn)) 2 M(P ) M j=α :φ iff M 6j=α φ M j=α φ ^ iff M j=α φ and A j=α M j=α φ _ iff M j=α φ or A j= M j=α φ ! iff M 6j=α φ or M j=α M j=α 8x: φ iff M j=α[x:=a] φ for all a 2 U M j=α 9x: φ iff M j=α[x:=a] φ for some a 2 U If φ is a sentence we often drop α and write M j= φ. Maria Jo~aoFrade (DI-UM) First-Order Logic (Classical) MFES 2008/09 10 / 31 Validity, satisfiability, and contradiction If M j= φ holds, then we say that M models φ, or that φ holds in M, or simply, that φ is true in M. A sentence φ is valid iff it holds in every model. We write j= φ. A valid sentence is called a tautology. satisfiable iff it holds in some model. unsatisfiable iff there is no model in which φ is true. An unsatisfiable sentence is called a contradiction. Maria Jo~aoFrade (DI-UM) First-Order Logic (Classical) MFES 2008/09 11 / 31 Validity, satisfiability, and contradiction The definition of satisfiability can be extended to apply to all formulas of first-order logic (not just sentences). The formula φ(x1; : : : ; xn) is satisfiable if and only if the sentence 8x1:::: 8xn: φ(x1; : : : ; xn) (its universal closure) is satisfiable. Maria Jo~aoFrade (DI-UM) First-Order Logic (Classical) MFES 2008/09 12 / 31 Consequence and equivalence φ j= iff for every model M, if M j= φ then M j= . We say is a consequence of φ. φ ≡ iff φ j= and φ j= . We say φ and are equivalent. Let Γ = fφ1; φ2; φ3;::: g be a set of sentences. M j= Γ iff M j= φi for each sentence φi in Γ. We say M models Γ. Γ j= iff M j= Γ implies M j= for every model M. We say is a consequence of Γ. Proposition φ j= iff j= φ ! Γ j= and Γ finite iff j= V Γ ! Maria Jo~aoFrade (DI-UM) First-Order Logic (Classical) MFES 2008/09 13 / 31 Consistency Let Γ = fφ1; φ2; φ3;::: g be a set of sentences. Γ is consistent or satisfiable iff there is model for Γ. We say that Γ is inconsistent iff it is not consistent and denote this by Γ j= ?. Proposition fφ, :φg j= ? If Γ j= ? and Γ ⊆ ∆, then ∆ j= ?. Γ j= φ iff Γ; :φ j= ? Maria Jo~aoFrade (DI-UM) First-Order Logic (Classical) MFES 2008/09 14 / 31 Substitution Formula is a subformula of formula φ if it occurs syntactically within φ. Formula is a strict subformula of φ if is a subformula of φ and 6= φ Substitution theorem Suppose φ ≡ . Let θ be a formula that contains φ as a subformula. Let θ0 be the formula obtained by safe replacing (i.e., avoiding the capture of free variables of φ) some occurrence of φ in θ with . Then θ ≡ θ0. Maria Jo~aoFrade (DI-UM) First-Order Logic (Classical) MFES 2008/09 15 / 31 Adquate sets of connectives for FOL As in propositional logic, there is some redundancy among the connectives and quantifiers. Note that in classical first-order logic 8x: φ ≡ :9x: :φ 9x: φ ≡ :8x: :φ Maria Jo~aoFrade (DI-UM) First-Order Logic (Classical) MFES 2008/09 16 / 31 Decidability Given formulas φ and as input, we may ask: Decision problems Validity problem: \Is φ valid ?" Satisfiability problem: \Is φ satisfiable ?" Consequence problem: \Is a consequence of φ ?" Equivalence problem: \Are φ and equivalent ?" These are, in some sense, variations of the same problem.