8
of 45 lecture 14: predicate logic of 45 predicate logic a predicate (relation) – is a function that maps its arguments to the truth values 0 or 1 known example: less then (symbol <), for arguments 5 and 8 we have 5<8 is true, and 8<5 is false they can be written as infix like <, or letter(s), for example R(x,y) or mother(x,y) ece 627, winter ‘13 2 of 45 predicate logic predicate logic is not a replacement for propositional logic but an extension or refinement of it ece 627, winter ‘13 3 of 45 predicate logic in propositional logic, the preposition Every peach is fuzzy is represented by a single symbol p, in predicate logic, the statement is shown in finer detail - with universal quantifier ( x)(peach(x) fuzzy(x)) ece 627, winter ‘13 4 of 45 predicate logic - with existential quantifier ~( x)(peach(x) ~fuzzy(x)) ece 627, winter ‘13 5 of 45 predicate logic - with both quantifiers ( x)( y)(integer(x) (prime(y) x<y) ece 627, winter ‘13 6

predicate logic - University of Albertareformat/ece627w2013/lec14_p... · 2013. 3. 4. · of#45# 5 and 8 we have 5

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: predicate logic - University of Albertareformat/ece627w2013/lec14_p... · 2013. 3. 4. · of#45# 5 and 8 we have 5

of#45#

lecture 14: predicate logic

of#45#

predicate logic …

a predicate (relation) – is a function that maps its arguments to the truth values 0 or 1 known example: less then (symbol <), for arguments 5 and 8 we have 5<8 is true, and 8<5 is false they can be written as infix like <, or letter(s), for example R(x,y) or mother(x,y)

ece#627,#winter#‘13# 2#

of#45#

predicate logic …

predicate logic is not a replacement for propositional logic but an extension or refinement of it

ece#627,#winter#‘13# 3# of#45#

predicate logic …

in propositional logic, the preposition Every peach is fuzzy

is represented by a single symbol p, in predicate logic, the statement is shown in finer detail - with universal quantifier

( x)(peach(x) fuzzy(x))

ece#627,#winter#‘13# 4#€

of#45#

predicate logic …

- with existential quantifier

~( x)(peach(x) ~fuzzy(x))

ece#627,#winter#‘13# 5#

of#45#

predicate logic …

- with both quantifiers

( x)( y)(integer(x) (prime(y) x<y)

ece#627,#winter#‘13# 6#

Page 2: predicate logic - University of Albertareformat/ece627w2013/lec14_p... · 2013. 3. 4. · of#45# 5 and 8 we have 5

of#45#

predicate logic …

order of quantifiers

( x)( y) ( man(x) dept(x,account) (woman(y) hometown(y,Boston) married(x,y)) )

ece#627,#winter#‘13# 7#

of#45#

predicate logic …

while …

( y)( x) ( man(x) dept(x,account) (woman(y) hometown(y,Boston) married(x,y)) )

ece#627,#winter#‘13# 8#

of#45#

predicate logic formation rules

vocabulary contains symbols for constants and variables, parenthesis, Boolean operators, and symbols for quantifiers, functions and predicates all of them are combined according to three rules

ece#627,#winter#‘13# 9# of#45#

predicate logic formation rules

a term is either a constant (2 or a, b, c, …), a variable (x, y or x0, x1, x2, …), or a function or an operator symbol applied to its arguments, each of which is itself a term for example: f(x), 2+2

ece#627,#winter#‘13# 10#

of#45#

predicate logic formation rules

an atom is either a single letter (p) representing preposition or a predicate symbol (P, Q, R, …) applied to its arguments, each of which is itself a term for example: P(f(x), 2+2), Q(7)

ece#627,#winter#‘13# 11# of#45#

predicate logic formation rules

a formula is either an atom, a formula preceded by ~, any two formulas A and B together with any two-place Boolean operator op in the combination (A op B), or any formula A and any variable x in either of the combinations ( x)A or ( x)A

ece#627,#winter#‘13# 12#

Page 3: predicate logic - University of Albertareformat/ece627w2013/lec14_p... · 2013. 3. 4. · of#45# 5 and 8 we have 5

of#45#

predicate logic formulas - examples

(P(f(x),2+2) Q(7)) ~(P(f(x),2+2) Q(7))

( y)~(P(f(x),2+2) Q(7)) ( x)( y)~(P(f(x),2+2) Q(7))

the occurrence of x in f(x) is bound by the quantifier ( x), the quantifier ( y) has not effect on the formula, y does not occur as an argument of any function/predicate

ece#627,#winter#‘13# 13#

∀€

⊃€

of#45#

predicate logic formulas - examples

John is tall T(j)

John is taller than Bill TR(j,b)

Everybody sleeps x (S(x))

Somebody likes David x [L(x,d)]

ece#627,#winter#‘13# 14#

of#45#

predicate logic formulas - examples

There are happy people x H(x)

Some books are interesting x [B(x) I(x)]

Some books are interesting and some are easy to read x [B(x) I(x)] x [B(x) E(x)]

No books are good x [B(x) G(x)]

ece#627,#winter#‘13# 15#

∃€

→¬

of#45#

predicate logic rules of inference

rule of inference - is to preserve truth, if we start with formulas that are true, the result of performing a rule of inference on them must also be true

ece#627,#winter#‘13# 16#

of#45#

predicate logic rules of inference

issue of equivalence: ( x)(peach(x) fuzzy(x))

~( x)(peach(x) ~fuzzy(x)) if these formulas were represented by p and q, there would be no way to prove p q, but the rules of predicate logic can show the equivalence

ece#627,#winter#‘13# 17#

≡€

of#45#

predicate logic rules of inference

the rule for relating the quantifiers

( x)A is equivalent to ~( x)~A ( x)A is equivalent to ~( x)~A

ece#627,#winter#‘13# 18#

Page 4: predicate logic - University of Albertareformat/ece627w2013/lec14_p... · 2013. 3. 4. · of#45# 5 and 8 we have 5

of#45#

predicate logic rules of inference

so, the first rule: ~( x)~(peach(x) fuzzy(x))

knowing, that ~(p ~q), then

~( x)~~(peach(x) ~fuzzy(x))

ece#627,#winter#‘13# 19#

∃€

∧€

of#45#

predicate logic rules of inference

and ~( x)(peach(x) ~fuzzy(x))

this shows 1st formula implies 2nd, if we use the inverse of rules to show the 2nd implies 1st – then both formulas are equivalent

ece#627,#winter#‘13# 20#

of#45#

predicate logic rules of inference

Modus ponens: from p and p q, derive q

Modus tollens:

from ~q and p q, derive ~p

ece#627,#winter#‘13# 21#

⊃€

of#45#

predicate logic rules of inference

Hypothetical syllogism: from p q and q r, derive p r

Disjunctive syllogism:

from p q and ~p, derive p

ece#627,#winter#‘13# 22#

of#45#

predicate logic rules of inference

Conjunction: from p and q, derive p q

Addition:

from p, derive p q (any formula may be added to a disjunction)

ece#627,#winter#‘13# 23#

∨€

of#45#

predicate logic rules of inference

Subtraction: from p q, derive p

(extra conjuncts may be thrown away)

ece#627,#winter#‘13# 24#

Page 5: predicate logic - University of Albertareformat/ece627w2013/lec14_p... · 2013. 3. 4. · of#45# 5 and 8 we have 5

of#45#

predicate logic equivalences

Idempotency: p p is equivalent to p, and p p is equivalent to p

Commutativity:

p q is equivalent to q p, and p q is equivalent to q p

ece#627,#winter#‘13# 25#€

of#45#

predicate logic equivalences

Associativity: p (q r) is equivalent to (p q) r, and p (q r) is equivalent to (p q) r

Distributivity:

p (q r) is equivalent to (p q) (p r), and p (q r) is equivalent to (p q) (p r)

ece#627,#winter#‘13# 26#€

of#45#

predicate logic equivalences

Absorption: p (p q) is equivalent to p, and p (p q) is equivalent to p

Double negation:

p is equivalent to ~~p

ece#627,#winter#‘13# 27#

of#45#

predicate logic equivalences

De Morgan�s laws: ~(p q) is equivalent to ~p ~q, and ~(p q) is equivalent to ~p ~q

ece#627,#winter#‘13# 28#

of#45#

predicate logic rules for quantifiers

if A is an atom, then all occurrences of a variable in A are said to be free if a formula C was derived from formulas A and B by combining them with Boolean operators, then all occurrences of variables that are free in A and B are also free in C

ece#627,#winter#‘13# 29# of#45#

predicate logic rules for quantifiers

if a formula C was derived form a formula A by preceding A with either ( x) or ( x), then all free occurrences of x in A are said to be bound in C, all free occurrences of other variables in A remain free in C

ece#627,#winter#‘13# 30#

Page 6: predicate logic - University of Albertareformat/ece627w2013/lec14_p... · 2013. 3. 4. · of#45# 5 and 8 we have 5

of#45#

predicate logic rules for quantifiers

rules for dealing with variables depend on which occurrences are free and bound and which variables must be renamed to avoid name clashes with other variables

ece#627,#winter#‘13# 31# of#45#

predicate logic rules for quantifiers

let Φ(x) be a formula with one or more free occurrences of a variable x, then Φ(t) is the result of substituting every free occurrence of x in Φ with t

ece#627,#winter#‘13# 32#

of#45#

predicate logic rules of quantifier negation

( x)A ~( x)~A ( x)A ~( x)~A ~( x)A ( x)~A ~( x)A ( x)~A

ece#627,#winter#‘13# 33#

of#45#

predicate logic rules of quantifier (in)dependence

( x)( y)A(x,y) ( y)( x)A(x,y) ( x)( y)A(x,y) ( y)( x)A(x,y) ( x)( y)A(x,y) ( y)( x)A(x,y)

ece#627,#winter#‘13# 34#

of#45#

predicate logic rules of quantifier movement

A ( x)(B(x)) ( x)(A B(x)) A ( x)(B(x)) ( x)(A B(x)) ( x)(B(x)) A ( x)(B(x) A) ( x)(B(x)) A ( x)(B(x) A)

ece#627,#winter#‘13# 35#

∀€

of#45#

predicate logic rules of quantifier movement

example:

( x)(P(x)) ( y)(Q(y)) ( y)[( x)(P(x)) (Q(y))] ( y)( x)[(P(x)) (Q(y))]

ece#627,#winter#‘13# 36#

Page 7: predicate logic - University of Albertareformat/ece627w2013/lec14_p... · 2013. 3. 4. · of#45# 5 and 8 we have 5

of#45#

predicate logic rules for quantifiers: permissible substitutions

universal instantiation: from ( x)Φ(x), derive Φ(c) where c is any constant existential generalization: from Φ(c), where c is any constant, derive ( x)Φ(x) provided that every occurrence of x in Φ(x) is free

ece#627,#winter#‘13# 37#

of#45#

predicate logic rules for quantifiers: permissible substitutions

dropping quantifiers: if the variable x does not occur free in Φ, then from ( x)Φ(x) derive Φ, and from ( x)Φ(x) derive adding quantifiers: from Φ derive ( x)Φ or derive ( x)Φ, where x is any variable

ece#627,#winter#‘13# 38#

∃€

of#45#

predicate logic rules for quantifiers: permissible substitutions

substituting equal for equals: for any terms s and t where s=t, derive Φ(t) from Φ(s), provided that all free occurrences of variables in t remain free in Φ(t)

ece#627,#winter#‘13# 39# of#45#

typed predicate logic …

this form is a purely syntactic extension of untyped logic – its semantic identical to untyped logic, as well as ever theorem and proof the only difference – addition of a type label after the quantifier – x:N - (label is a monadic predicate - n(x))

ece#627,#winter#‘13# 40#

of#45#

typed predicate logic …

for knowledge representation typed logic has the advantage of being more concise and readable it can support rules of inference based on inheritance (they do not make logic more expressive, they shorten some proofs)

ece#627,#winter#‘13# 41# of#45#

typed predicate logic …

Universal: ( x:N)Φ(x) ( x)(n(x) Φ(x)) Existential: ( x:N)Φ(x) ( x)(n(x) Φ(x))

ece#627,#winter#‘13# 42#

Page 8: predicate logic - University of Albertareformat/ece627w2013/lec14_p... · 2013. 3. 4. · of#45# 5 and 8 we have 5

of#45#

typed predicate logic …

with a string of multiple quantifiers of the same kind and with the same type label, it is permissible to factor out the common quantifier and type label

( x,y,x:Number) ((x < y y < z) x < z)

ece#627,#winter#‘13# 43#

of#45#

typed predicate logic …

for untyped … ( x)(number(x) ( y)(number(y) ( z)(number(z) ((x < y y < z) x < z) )))

ece#627,#winter#‘13# 44#

∧€

of#45#

typed predicate logic …

Untyped formula as a special case of a typed one Universal: ( x:T)Φ(x) ( x)(T(x) Φ(x))

( x) Φ(x) Existential: ( x:T)Φ(x) ( x)(T(x) Φ(x))

( x) Φ(x)

ece#627,#winter#‘13# 45#

∃€