Download presentation
Presentation is loading. Please wait.
1
Predicate logic 29 Oct. 2007 Jens Nilsson
2
Predicate logic Propositional logic compared to predicate logic
Predicate logic: Syntax Predikate logic: Semantic Aho & Ullman: 14.1 – 14.5 Motivation for predicate logic: One way for a computer to convey meaning Form foundation for some programming languages
3
Introduction Ex 1: If ”Ice cream is cold” → ”There is something that is cold” Ex 2: If ”Everything consists of matter” → ”The car consists of matter” In propositional logic: A := ” Ice cream is cold” och B: ” There is something that is cold” A := ” Everything consists of matter” och B : ”The car consists of matter” A → B is not derivable in propositional logic. In predikate logic: isCold(ice_cream) consistsOfMatter(the_car) isCold(the_sun) consistsOfMatter(the_air)
4
Propostitional logic vs. Predicate Logic (1)
Propostitional logic is a special case of Predicate Logic (everything that can be described in Propostitional logic can be descipbed in predicate logic), which entails these similarities: atomic statements have exactly one of two possible truth values, True or False consistsOfMatter(the_car) = 1 p = 1 isCold(the_sun) = 0 q = 0 expressions can be composed into larger expressions using operators consistsOfMatter(the_car) AND consistsOfMatter(the_air), (compare with p AND q)
5
Propostitional logic vs. Predicate Logic (2)
Similarities (cont.) The same algebraic laws hold: Associativity: (A OR B) OR C A OR (B OR C) (A AND B) AND C A AND (B AND C) Distributivitity: A OR (B AND C) (A OR B) AND (A OR C) A AND (B OR C) (A AND B) OR (A AND C) Commutativity: A OR B B OR A A AND B B AND A DeMorgans law: NOT (A AND B) (NOT A) OR (NOT B) NOT (A OR B) (NOT A) AND (NOT B) Difference: The truth value of composed expressions in propositional logic is unambigouosly determined by its parts. This does not hold for predicate logic, since a interpretation is need (see comming slides about semantic).
6
Predicate logic: Syntax (1)
Symbols: Predicate symbols: p, q, r, ... Symbols of individuals: Individual constants: a, b, c, ... Individual variables: X, Y, Z, ... Domain (set of individuals): D = {a, b, c, ...} (I = {a, b, c, ...}) Inductive definition of logic formulas: Atomic formulas: a predicate symbol followed by zero or more individual symbols, e.g. p, q(a),r(a, b), q(X)
7
Predicate logic: Syntax (2)
Formlulas with operators: If A och B är logical formulas, then the following are also logical formulas: Negation: A (~A, NOT A, ) Conjunction: A B (A & B, A AND B, AB) Disjunction: A B (A OR B, A + B) Implication: A → B (A B) Equivalence: A B (A B) Formulas with quantifications: If A is a logic formula and is an individual variable, then thees are also logical formulas: A (universal quantifier) A (existential quantifier)
8
Predicate logic: Syntax (3)
Example: course(focs) teaching(jens, focs) studying(jens, mathematics) studying(X, computer_science) studying(X, mathematics) X student(X) Y (student(Y) → happy(Y)) X Y (student(Y) knows(X, Y)) Möjlig domän: D = {focs, ... , jens, ... , mathematics, computer_science, ...}
9
Predicate logic: Syntax (4)
Priority of operators Quantifiers (, ) Negation Conjunction Disjunction Implication Equivalence Examples: Is p(X) q(X) the same as: (p(X) q(X)) or ( p(X)) q(X)? ( p(X)) q(X) ? Is X p(X) q(X) the same as : X (p(X) q(X)) or X (p(X)) q(X)? X (p(X)) q(X) ? Is p(X) q(X) → r(X) the same as : p(X) ( q(X) → r(X)) or (p(X) q(X)) → r(X)? (p(X) q(X)) → r(X) ?
10
Predicate logic: Syntax (5)
Scope, bounded and free variables Let Q be an arbitrary quantifier where Q is or , and is an indiviual variable. In formulas with the form Q A, the quantifier has scope over A. The quantifier Q1 binds every occurance of the variable in A that is bounded by another quantifier Q2 within A. A variable that is not bounded is free. A formula without free variables is called a ground formula Can be compared with local and global declaration of variables in C (or Java)
11
Predicate logic: Syntax (6)
Example (which variables are bounded?): X student(X) [ X bounded by X ] X student(X) happy(X) [ X1 bounded, X2 free] X (student(X) happy(X)) [ X1 , X2 bounded] X (student(X) X happy(X)) [ X1 bounded by X, X2 bounded of X ] X happy(Y) [ Y free] happy(Y) Possible domain: D = {The set of all people}
12
Predicate logic: Semantic (1)
Predicate logic in natural language: Predicate: mushroom(), purple() och poisonous() All purple mushrooms are poisonius: X((mushroom(X) purple(X)) → poisonous(X)) No purple mushrooms are poisonius: X((mushroom(X) purple(X)) →poisonous(X)) All mushrooms are either purple or poisonous: X(mushroom(X) → (purple(X) poisonous(X)))
13
Predicate logic: Semantic (2)
Interpretation A non-empty domain One interpretation for each constant: One individual constant is assigned one individual from the domain. One n-ary predicate is assigned a function : Dn → {True, False} (i.e. a function from individuals to truth values)
14
Predicate logic: Semantic (3)
Evaluation rules Atomic formulas: If A is an atomic formula with the predicate p and the arguments a1, ... , ak, and if the current interpretation assigns p the function , then A is true if and only if (a1, ... , ak) = True. Complex formulas: Negation: A is true if and only of A is false. Conjunction: A B is true if and only both A och B are true. Disjunction: A B is true if and only at least one of A och B are true. Implication: A → B is true if and only A is false or B is true. Equivalence: A B is true if and only A and B have the same truth value.
15
Predicate logic: Semantic (4)
Evaluation rules, cont. Formulas with quantifiers A is true if and only if A is true in all interpretations that are exactly the same as in A, except that the variable can be assigned any individual constant in the domain. For all X, it is the case that ... A is true if and only if A is true in any interpretations that is exactly the same as in A, except that the variable can be assigned any individual constant in the domain. Of all X, there is at least one X such that ...
16
Predicate logic: Semantic (5)
Interpretation D = {jens, adam, eve, mathematics, computer_science, da1021, focs} Interpretation of predicates: course = {da1021, focs} student = {adam, eve} happy = {jens, eve} teaching = {(jens, focs)} studying = {(adam, computer_science), (eve, computer_science), (eve, mathematics)} knows = {(adam, eve), (eve, adam), (jens, adam), (adam, jens)} Variable assignment: X = jens, Y = eve
17
Predikatlogik: Semantik (5)
Interpretation(example), cont. Evaluation of formulas: course(focs) (true) course(computer_science) (false) teaching(jens, focs) (true) studying(jens, mathematics) (false) studying(jens, mathematics) (true) studying(X, computer_science) studying(X, mathematics) (false?) X student(X) (true) Y(student(Y) → happy(Y)) (false) XY(student(Y) knows(X, Y)) (false)
18
Predicate logic in language (1)
Translate English to predicate logic: Mary doesn’t jog: jog(mary) j(m) Fred smokes and Mary drinks: smoke(fred) drink(mary) s(f) d (m) Carl, who is a millonaire, is a socialist: millonaire(carl) socialist(carl) m(c) s(c) Jean admires Robert, who is a ganster: admires(jean, robert) ganster(robert) a(j, r) g(r)
19
Predicate logic in language (2)
Predicate logic as meta language: Natural language contains a number of quantifiers: Some students wrote a paper Many students wrote a paper Most students wrote a paper All students wrote a paper Every student wrote a paper No student wrote a paper A lot of students wrote a paper Some students: EX(student(X) AND paper(X, w)) Every student: AX (student(X) -> paper(X, w)) No student: NOT EX(student(X) AND paper(X, w)) AX(student(X) -> NOT paper(X, w))
20
Predicate logic in language (3)
Some advantages with formal semantic in form of predicate logic Amiguous scope for quvantifiers in natural language Example: Everybody loves somone Does it mean: Everyone has someone they love ? or There is some person who is loved by everyone ? In predicate logic: XY loves(X, Y) YX loves(X, Y) Räckvidden för kvantifierare i predikatlogik är otvetydigt Rita liten bild här: fina gubbar i cirkel med pilar bred och smal räckvidd
21
Predicate logic in language (4)
Some advantages with formal semantic in form of predicate logic (cont.) Scope for negation: Everyone didn’t visit London Does it mean: For every person x, it is not the case that x visited London ? or It’s not the case that every person x visited London ? In predicate logic: X visit(X, london) or X visit(X, london) Y visit(X, london) or Y visit(X, london) predikatlogik ger oss möjlighet att disambiguera meningar som innehåller både negation och kvantifierare handar igen om vilken som har bred räckvidd: negationen eller kvantifieraren de två senaste sliden visar att predikatlogik har en fördel vad det gäller klarhet i uttrycket
22
Predicate logic: derivation (1)
Derivation in predicate logic Eliminating universal quantifiers: ”All objects consists of matter” och ”The car is an object” ”All object consists of matter”: X(isObject(X) → consistsOfMatter(X)) ”The car is an object”: isObject(the_car) (1) X(isObject(X) → consistsOfMatter(X)) Premise (2) isObject (the_car) Premise (3) isObject (the_car) → consistsOfMatter(the_car) by -elimination from (1) (4) consistsOfMatter(the_car) from (2) & (3)
23
Predicate logic: derivation (2)
Introducing existential quantifier: ”All object consists of matter”: X(isObject(X) → consistsOfMatter (X)) ” The car is an object with wheels”: isObject (bilen) hasWheels(bilen) (1) X(är_objekt(X) → consistsOfMatter(X)) Premise (2) isObject (the_car) hasWheels (the_car) Premise (3) isObject (the_car) → consistsOfMatter(the_car) by -elimination from (1) (4) isObject (the_car) from (2) (5) consistsOfMatter(the_car) from(3) & (4) (6) hasWheels (the_car) from(2) (7) consistsOfMatter(the_car) hasWheels (the_car) from(5) & (6) (8) X(consistsOfMatter(X) hasWheels (X)) by -introduction from (7)
24
Predicate logic: summary
Predicate logic is an extension of propositional logic Predicates och quantifiers more expressive power Predicate logic can use the same tools for doing derivations as propositional logic
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.