Theory of Computer Science B3. Predicate Logic I Malte Helmert University of Basel March 7, 2016
Motivation
Limits of Propositional Logic group axioms for G, and neutral element e: 1 For all x, y, z G, (x y) z = x (y z). 2 For all x G, x e = x. 3 For all x G, there is a y G with x y = e. cannot be expressed in propositional logic: objects x, y, z from G object references (x y) with function equality = for all, there is need more expressive logic predicate logic German: Prädikatenlogik
Limits of Propositional Logic group axioms for G, and neutral element e: 1 For all x, y, z G, (x y) z = x (y z). 2 For all x G, x e = x. 3 For all x G, there is a y G with x y = e. cannot be expressed in propositional logic: objects x, y, z from G object references (x y) with function equality = for all, there is need more expressive logic predicate logic German: Prädikatenlogik
Limits of Propositional Logic group axioms for G, and neutral element e: 1 For all x, y, z G, (x y) z = x (y z). 2 For all x G, x e = x. 3 For all x G, there is a y G with x y = e. cannot be expressed in propositional logic: objects x, y, z from G object references (x y) with function equality = for all, there is need more expressive logic predicate logic German: Prädikatenlogik
Syntax of Predicate Logic
Syntax: Building Blocks Signatures define allowed symbols. analogy: variable set A in propositional logic Terms are associated with objects by the semantics. no analogy in propositional logic Formulas are associated with truth values (true or false) by the semantics. analogy: formulas in propositional logic German: Signatur, Term, Formel
Signatures: Definition Definition (Signature) A signature (of predicate logic) is a 4-tuple S = V, C, F, P consisting of the following four disjoint sets: a finite or countable set V of variable symbols a finite or countable set C of constant symbols a finite or countable set F of function symbols a finite or countable set P of predicate symbols (or relation symbols) Every function symbol f F and predicate symbol P P has an associated arity ar(f), ar(p) N 1 (number of arguments). German: Variablen-, Konstanten-, Funktions-, Prädikat- und Relationssymbole; Stelligkeit
Signatures: Terminology and Conventions terminology: k-ary (function or predicate) symbol: symbol s with arity ar(s) = k. also: unary, binary, ternary German: k-stellig, unär, binär, ternär conventions (in this lecture): variable symbols written in italics, other symbols upright. predicate symbols begin with capital letter, other symbols with lower-case letters
Signatures: Examples Example: Arithmetic V = {x, y, z, x 1, x 2, x 3,... } C = {zero, one} F = {sum, product} P = {Positive, SquareNumber} ar(sum) = ar(product) = 2, ar(positive) = ar(squarenumber) = 1
Signatures: Examples Example: Genealogy V = {x, y, z, x 1, x 2, x 3,... } C = {roger-federer, lisa-simpson} F = P = {Female, Male, Parent} ar(female) = ar(male) = 1, ar(parent) = 2
Terms: Definition Definition (Term) Let S = V, C, F, P be a signature. A term (over S) is inductively constructed according to the following rules: Every variable symbol v V is a term. Every constant symbol c C is a term. If t 1,..., t k are terms and f F is a function symbol with arity k, then f(t 1,..., t k ) is a term. German: Term examples: x 4 lisa-simpson sum(x 3, product(one, x 5 ))
Terms: Definition Definition (Term) Let S = V, C, F, P be a signature. A term (over S) is inductively constructed according to the following rules: Every variable symbol v V is a term. Every constant symbol c C is a term. If t 1,..., t k are terms and f F is a function symbol with arity k, then f(t 1,..., t k ) is a term. German: Term examples: x 4 lisa-simpson sum(x 3, product(one, x 5 ))
Formulas: Definition Definition (Formula) For a signature S = V, C, F, P the set of predicate logic formulas (over S) is inductively defined as follows:... If t 1,..., t k are terms (over S) and P P is a k-ary predicate symbol, then the atomic formula (or the atom) P(t 1,..., t k ) is a formula over S. If t 1 and t 2 are terms (over S), then the identity (t 1 = t 2 ) is a formula over S. If x V is a variable symbol and ϕ a formula over S, then the universal quantification x ϕ and the existential quantification x ϕ are formulas over S. German: atomare Formel, Atom, Identität, Allquantifizierung, Existenzquantifizierung
Formulas: Definition Definition (Formula) For a signature S = V, C, F, P the set of predicate logic formulas (over S) is inductively defined as follows:... If ϕ is a formula over S, then so is its negation ϕ. If ϕ and ψ are formulas over S, then so are the conjunction (ϕ ψ) and the disjunction (ϕ ψ). German: Negation, Konjunktion, Disjunktion
Formulas: Examples Examples: Arithmetic and Genealogy Positive(x 2 ) x ( SquareNumber(x) Positive(x)) x 3 (SquareNumber(x 3 ) Positive(x 3 )) x (x = y) x (sum(x, x) = product(x, one)) x y (sum(x, y) = zero) x y (Parent(y, x) Female(y)) Terminology: The symbols and are called quantifiers. German: Quantoren
Abbreviations and Placement of Parentheses by Convention abbreviations: (ϕ ψ) is an abbreviation for ( ϕ ψ). (ϕ ψ) is an abbreviation for ((ϕ ψ) (ψ ϕ)). Sequences of the same quantifier can be abbreviated. For example: x y z ϕ xyz ϕ x y z ϕ xyz ϕ w x y z ϕ w xy z ϕ placement of parentheses by convention: analogous to propositional logic quantifiers and bind more strongly than anything else. example: x P(x) Q(x) corresponds to ( x P(x) Q(x)), example: not x (P(x) Q(x)).
Abbreviations and Placement of Parentheses by Convention abbreviations: (ϕ ψ) is an abbreviation for ( ϕ ψ). (ϕ ψ) is an abbreviation for ((ϕ ψ) (ψ ϕ)). Sequences of the same quantifier can be abbreviated. For example: x y z ϕ xyz ϕ x y z ϕ xyz ϕ w x y z ϕ w xy z ϕ placement of parentheses by convention: analogous to propositional logic quantifiers and bind more strongly than anything else. example: x P(x) Q(x) corresponds to ( x P(x) Q(x)), example: not x (P(x) Q(x)).
Questions Questions?
Semantics of Predicate Logic
Semantics: Motivation interpretations in propositional logic: truth assignments for the propositional variables There are no propositional variables in predicate logic. instead: interpretation determines meaning of the constant, function and predicate symbols. meaning of variable symbols not determined by interpretation but by separate variable assignment.
Interpretations and Variable Assignments Let S = V, C, F, P be a signature. Definition (Interpretation, Variable Assignment) An interpretation (for S) is a pair I = U, I of: a non-empty set U called the universe and a function I that assigns a meaning to the constant, function, and predicate symbols: c I U for constant symbols c C f I : U k U for k-ary function symbols f F P I U k for k-ary predicate symbols P P A variable assignment (for S and universe U) is a function α : V U. German: Interpretation, Variablenzuweisung, Universum (or Grundmenge)
Interpretations and Variable Assignments: Example Example signature: S = V, C, F, P with V = {x, y, z}, C = {zero, one}, F = {sum, product}, P = {SquareNumber} ar(sum) = ar(product) = 2, ar(squarenumber) = 1 I = U, I with U = {u 0, u 1, u 2, u 3, u 4, u 5, u 6 } zero I = u 0 one I = u 1 sum I (u i, u j ) = u (i+j) mod 7 for all i, j {0,..., 6} product I (u i, u j ) = u (i j) mod 7 for all i, j {0,..., 6} SquareNumber I = {u 0, u 1, u 2, u 4 } α = {x u 5, y u 5, z u 0 }
Interpretations and Variable Assignments: Example Example signature: S = V, C, F, P with V = {x, y, z}, C = {zero, one}, F = {sum, product}, P = {SquareNumber} ar(sum) = ar(product) = 2, ar(squarenumber) = 1 I = U, I with U = {u 0, u 1, u 2, u 3, u 4, u 5, u 6 } zero I = u 0 one I = u 1 sum I (u i, u j ) = u (i+j) mod 7 for all i, j {0,..., 6} product I (u i, u j ) = u (i j) mod 7 for all i, j {0,..., 6} SquareNumber I = {u 0, u 1, u 2, u 4 } α = {x u 5, y u 5, z u 0 }
Semantics: Informally Example: ( x(block(x) Red(x)) Block(a)) For all objects x: if x is a block, then x is red. Also, the object called a is a block. Terms are interpreted as objects. Unary predicates denote properties of objects (to be a block, to be red, to be a square number,... ) General predicates denote relations between objects (to be someone s child, to have a common divisor,... ) Universally quantified formulas ( ) are true if they hold for every object in the universe. Existentially quantified formulas ( ) are true if they hold for at least one object in the universe.
Interpretations of Terms Let S = V, C, F, P be a signature. Definition (Interpretation of a Term) Let I = U, I be an interpretation for S, and let α be a variable assignment for S and universe U. Let t be a term over S. The interpretation of t under I and α, written as t I,α, is the element of the universe U defined as follows: If t = x with x V (t is a variable term): x I,α = α(x) If t = c with c C (t is a constant term): c I,α = c I If t = f(t 1,..., t k ) (t is a function term): f(t 1,..., t k ) I,α = f I (t I,α 1,..., t I,α k )
Interpretations of Terms: Example Example signature: S = V, C, F, P with V = {x, y, z}, C = {zero, one}, F = {sum, product}, ar(sum) = ar(product) = 2 I = U, I with U = {u 0, u 1, u 2, u 3, u 4, u 5, u 6 } zero I = u 0 one I = u 1 sum I (u i, u j ) = u (i+j) mod 7 for all i, j {0,..., 6} product I (u i, u j ) = u (i j) mod 7 for all i, j {0,..., 6} α = {x u 5, y u 5, z u 0 }
Interpretations of Terms: Example Example signature: S = V, C, F, P with V = {x, y, z}, C = {zero, one}, F = {sum, product}, ar(sum) = ar(product) = 2 I = U, I with U = {u 0, u 1, u 2, u 3, u 4, u 5, u 6 } zero I = u 0 one I = u 1 sum I (u i, u j ) = u (i+j) mod 7 for all i, j {0,..., 6} product I (u i, u j ) = u (i j) mod 7 for all i, j {0,..., 6} α = {x u 5, y u 5, z u 0 }
Interpretations of Terms: Example (ctd.) Example (ctd.) zero I,α = y I,α = sum(x, y) I,α = product(one, sum(x, zero)) I,α =
Semantics of Predicate Logic Formulas Let S = V, C, F, P be a signature. Definition (Formula is Satisfied or True) Let I = U, I be an interpretation for S, and let α be a variable assignment for S and universe U. We say that I and α satisfy a predicate logic formula ϕ (also: ϕ is true under I and α), written: I, α = ϕ, according to the following inductive rules:... I, α = P(t 1,..., t k ) iff t I,α 1,..., t I,α P I I, α = (t 1 = t 2 ) iff t I,α 1 = t I,α 2 I, α = ϕ iff I, α = ϕ I, α = (ϕ ψ) iff I, α = ϕ and I, α = ψ I, α = (ϕ ψ) iff I, α = ϕ or I, α = ψ k
Semantics of Predicate Logic Formulas Let S = V, C, F, P be a signature. Definition (Formula is Satisfied or True)... I, α = xϕ iff I, α[x := u] = ϕ for all u U I, α = xϕ iff I, α[x := u] = ϕ for at least one u U where α[x := u] is the same variable assignment as α, except that it maps variable x to the value u. Formally: { u if z = x (α[x := u])(z) = α(z) if z x German: I und α erfüllen ϕ (also: ϕ ist wahr unter I und α)
Semantics: Example Example signature: S = V, C, F, P with V = {x, y, z}, C = {a, b}, F =, P = {Block, Red}, ar(block) = ar(red) = 1. I = U, I with U = {u 1, u 2, u 3, u 4, u 5 } a I = u 1 b I = u 3 Block I = {u 1, u 2 } Red I = {u 1, u 2, u 3, u 5 } α = {x u 1, y u 2, z u 1 }
Semantics: Example Example signature: S = V, C, F, P with V = {x, y, z}, C = {a, b}, F =, P = {Block, Red}, ar(block) = ar(red) = 1. I = U, I with U = {u 1, u 2, u 3, u 4, u 5 } a I = u 1 b I = u 3 Block I = {u 1, u 2 } Red I = {u 1, u 2, u 3, u 5 } α = {x u 1, y u 2, z u 1 }
Semantics: Example (ctd.) Example (ctd.) Questions: I, α = (Block(b) Block(b))? I, α = (Block(x) (Block(x) Block(y)))? I, α = (Block(a) Block(b))? I, α = x(block(x) Red(x))?
Semantics: Example (ctd.) Example (ctd.) Questions: I, α = (Block(b) Block(b))?
Semantics: Example (ctd.) Example (ctd.) Questions: I, α = (Block(x) (Block(x) Block(y)))?
Semantics: Example (ctd.) Example (ctd.) Questions: I, α = (Block(a) Block(b))?
Semantics: Example (ctd.) Example (ctd.) Questions: I, α = x(block(x) Red(x))?
Questions Questions?
Summary
Summary Predicate logic is more expressive than propositional logic and allows statements over objects an their properties. Objects are described by terms that are built from variable, constant and function symbols. Properties and relations are described by formulas that are built from predicates, quantifiers and the usual logical operators. As with all logics, we analyze syntax: what is a formula? semantics: how do we interpret a formula?