<<

Announcements

First-Order Logic Homework #2 is assigned, it is due Monday, July 7 (1 week from today)

Project proposals are due today Burr H. Settles CS-540, UW-Madison www.cs.wisc.edu/~cs540-1 Read Chapter 9 in AI: A Modern Approach Summer 2003 for next time

1 2

General Logic PL Review: Truth Tables

¢ ¢ ¢ ¢ ¢ ¢ ¢ ¢ ¢ ¢ ¢ ¢ ¢ ¢ ¢

∧ ∨ ¢ ∨ ¢ ¢ ¢ ¢ ¢ ¢ ¢ ¢ ¢ ¢ ¢ ¢ ¢ ¢ ¢

((A C) (A¢ C)) (C B) (A (B C)) ((A B) (A C))

¡

£ £ £ £ £ £ £ £ £ £ £ £ £ £ £

∧ ∨ £ ∨

£ £ £ £ £ £ £ £ £ £ £ £ £ £ £ Logics are characterized by what they consider to A B C ((A C) (A £ C)) (C B) A B C (A (B C)) ((A B) (A C)) be “primitives” T T T T T T T T T T F T T T F T T F T T T F T T T F F T T F F T Logic Primitives Available Knowledge F T T T F T T T Propositional facts true/false/unknown F T F T F T F T F F T T F F T T First-Order facts, objects, relations true/false/unknown F F F F F F F T Temporal facts, objects, relations, true/false/unknown times (A∨B)∧(A∨¬B)∧(¬A∨B)∧(¬A∨¬B) A B (A∨B)∧(A∨¬B)∧(¬A∨B)∧(¬A∨¬B) Probability Theory facts degree of belief 0…1 valid T T F satisfiable, Fuzzy degree of truth degree of belief 0…1 T F F but not valid F T F 3 unsatisfiable F F F 4

PL Review: Inference Rules First-Order Logic ¤

¤

£ ¥

£ £

Modus Ponens £ , Given the following ¥

knowledge base: ¨ Propositional logic has advantages

¤ ¤ ¤ ∧ ∧ ∧ 1 ∧ 2 ∧ … ∧ n

And-Elimination (AE): ¤ 1. P

i – Simple

§ § §

2. P § R ¤ ¤ ¤

1, 2, … , n – Inference is fast and easy

¤ ¤ ¤ § § ¬ § And-Introduction (AI): ∧ ∧ ∧ 3. R § ¬W 1 ∧ 2 ∧ … ∧ n

4. S ∨ R ¨

¤ But PL is limited in key ways

∧ § § ∨ §

i 5. (P ∧ R) § (S ∨ W)

¤ ¤ Or-Introduction (OI): ¤ ∨ ∨ ∨ 1 2 … n – Enumerate all facts as separate propositions Prove S using natural Double-Negation ¬ ¬ ¤ – No concept of individuals or objects ¤ deduction with these rules.

Elimination (DNE): – Can’t express relationships easily ¤

∨ ¬ 6. R (MP: 1,2) ¨ ¥ ∨ ¥ , ¬ Unit Resolution (UR): ¤ 7. ¬W (MP: 3,6) First-Order Logic is a logic language designed to

¤ ∧

¥ ¦ ∨ ¥ , ¬ ∨ 8. P R (AI: 1,6)

Resolution (R): ¤ remedy these problems ∨ ¦ 9. S ∨ W (MP: 5,8)

10. S (UR: 7,9) ¤

deMorgan’s Law (DML): ¬(¬ ∨ ¥ )

¤ ∧ ¬¥ ∧ ¬ 5 6

1

FOL Syntax: Basic FOL Syntax: Basic ¨ A term is used to denote an object in the world ¨ An atom is smallest expression to which a truth – Constant: Bob, 2, Madison, Green, … value can be assigned – Variable: x, y, a, b, c, … – Predicate(term1, …, termn): – Function(term1, …, termn): • e.g. teacher(Burr,You), lte(sqrt(2),sqrt(7)) • e.g. sqrt(9), distance(Madison,Chicago) • Maps one or more objects to a truth value • Maps one or more objects to another object • Represents a user defined relation • Can refer to an unnamed object: e.g. leftLegOf(John) • Represents a user defined functional relation – Term1 = Term2: • e.g. height(Burr) = 73in, 1 = 2

¨ • Represents the equality relation when A ground term is a term with no variables two terms refer to the same object

7 8

FOL Syntax: Basic FOL Syntax: Basic ¡ ¨ A sentence represents a fact in the world that is Sentences are assigned a truth value with respect assigned a truth value to a model and an – Atom

∧ ∨ ¬ ⇔ ¨

∧ ∨ ¬ ⇔

– Complex sentence using connectives: The model contains the objects and the relations ¢

¢ ¢ • e.g. spouse(Burr,Nat) ¢ spouse(Burr,Nat) among them • e.g. less(11,22) ∧ less(22,33) ¨ The interpretation specifies what symbols refer to: – Complex sentence using quantified variables: ∀ ∃ – Constants symbols refer to objects • More about these in a bit… – Predicate symbols refer to relations – Functional symbols refer to functional relations

9 10

FOL Semantics: Assigning Truth FOL Syntax: Quantifiers

¡ ∀ The atom predicate(term1, …, termn) is true iff the The universal : objects referred to by term1, …, termn are in the relation referred to by the predicate ¡ Sentence holds true for all values of x in the domain of variable x

¨ What is the truth value for s(B,N)? ¨ – Model: Main connective typically ¡ forming if-then rules • Objects: Burr, Nat, Thom, Mark in FOL becomes:

• Relation: spouse {,} – “All humans are mammals” ¢

∀ ¢ ¢ – Interpretation: x human(x) ¢ mammal(x) • B means Burr, N means Nat, T means Thom, etc. – Means if x is a human then x is a mammal

• s(term1,term2) means term1 is the spouse of term2 11 12

2

FOL Syntax: Quantifiers FOL Syntax: Quantifiers

¡ ¡

¡ ¨ ∀x human(x) ¡ mammal(x) Common mistake is to use ∧ as main connective – Results in a blanket statement about everything

¨ Equivalent to the conjunction of all the instantiations of variable x: ¨ For example: ∀x human(x) ∧ mammal(x)

∧ (human(Burr) ∧ mammal(Burr)) ∧ ¢ ¢ ¢ (human(Burr) ¢ mammal(Burr)) ∧

∧ (human(Nat) ∧ mammal(Nat)) ∧

¢ ¢ ¢ (human(Nat) ¢ mammal(Nat)) ∧

∧ (human(Thom) ∧ mammal(Thom)) ∧ …

¢ ¢ ¢ (human(Thom) ¢ mammal(Thom)) ∧ … – But this means everything is human and a mammal!

13 14

FOL Syntax: Quantifiers FOL Syntax: Quantifiers

The existential quantifier: ∃ ∃x human(x) ∧ male(x) ¡ Sentence holds true for some value of x in the ¨ Equivalent to the disjunction of all the domain of variable x instantiations of variable x: (human(Burr) ∧ male(Burr)) ∨ ¨ Main connective typically ∧ (human(Nat) ∧ male(Nat)) ∨ – “Some humans are male” in FOL becomes: (human(Thom) ∧ male(Thom)) ∨ … ∃x human(x) ∧ male(x) – Means x is some human and x is a male

15 16

FOL Syntax: Quantifiers FOL Syntax: Quantifiers

¨ ¨ Common mistake is to use ¡ as main connective. Properties of quantifiers: – Results in a weak statement – ∀x ∀y is the same as ∀y ∀x

– ∃x ∃y is the same as ∃y ∃x

¨

¡ ¡ ¡

For example: ∃x human(x) ¡ male(x)

¨ ¢

¢ ∨ ¢

(human(Burr) ¢ male(Burr)) Why?

¢ ¢ ∨ ¢ (human(Nat) ¢ male(Nat)) ∨ – ∀x ∀y likes(x,y)

∨ ¢

¢ ∨ ¢ (human(Thom) ¢ male(Thom)) … the active voice: “Everyone likes everyone.” – Can be true if there is something not human! – ∀y ∀x likes(x,y) the passive voice: “Everyone is liked by everyone.”

17 18

3

FOL Syntax: Quantifiers FOL Syntax: Quantifiers ¨ ¨ Properties of quantifiers: Properties of quantifiers: – ∀x ∃y is not the same as ∃y ∀x – ∀x P(x) is the same as ¬∃x ¬P(x)

– ∃x ∀y is not the same as ∀y ∃x – ∃x P(x) is the same as ¬∀x ¬P(x) ¨ ¨ Why? Why? – ∀x ∃y likes(x,y) – ∀x sleep(x) “Everyone has someone they like.” “Everybody sleeps.” – ∃y ∀x likes(x,y) – ¬∃x ¬sleep(x) “There is someone who is liked by everyone.” double negative: “Nobody don’t sleep.”

19 20

FOL Syntax: Quantifiers FOL Syntax: Basics ¨ Properties of quantifiers: A free variable is a variable that isn’t bound – ∀x P(x) when negated is ∃x ¬P(x) by a quantifier – ∃x P(x) when negated is ∀x ¬P(x) – i.e. ∃y Likes(x,y): x is free, y is bound

¨ Why?

– ∀x sleeps(x) A well-formed formula is a sentence where “Everybody sleeps.” all variables are quantified (none are free) – ∃x ¬sleeps(x) negated: “Somebody doesn’t sleep.”

21 22

Summary So Far Summary So Far

¨ Constants: Bob, 2, Madison, … Term: Constant, variable, or function… denotes an object in the world (a ground term has no variables)

¨ Variables: x, y, a, b, c, …

¨ Functions: Income, Address, Sqrt, … Atom: Is smallest expression assigned a truth value

¨ – e.g. Predicate(term , …, term ), term = term

Predicates: Teacher, Sisters, Even, Prime… 1 n 1 2

¨ ¡ Connectives: ∧ ∨ ¬ ⇔ Sentence: An atom, quantified sentence with variables, or ¨ Equality: = complex sentence using connectives; assigned a truth value

¨ ∀ ∃ Quantifiers: Well-Formed Formula (wff): A sentence where all variables are quantified

23 24

4 Thinking in Logical Sentences Thinking in Logical Sentences

Convert the following sentences into FOL: We can also do this with relations: ¨ ¨ “Bob is a fish.” “America bought Alaska from Russia.” – What is the constant? – What are the constants? • Bob • America, Alaska, Russia – What is the predicate? – What are the relations? • is a fish • bought

– Answer: fish(Bob) – Answer: bought(America, Alaska, Russia) ¨

¨ “Burr and Mark are grad students.” “Warm is between cold and hot.” ¨ ¨ “Burr, Mark, or Nat is not a rat.” “Burr and Nat are married.”

25 26

Thinking in Logical Sentences Thinking in Logical Sentences

Now let’s think about quantification: ¨ All ¨ “Burr likes everything.” – Things: anything, everything, whatever – What is the constant? – Persons: anybody, anyone, everybody, everyone, whoever • Burr ¨ Some (at least one) – How are they variables quantified? – Things: something • All/universal – Persons: somebody, someone ∀ – Answer: x likes(Burr, x) ¨ None – i.e. likes(Burr, IceCream) ∧ likes(Burr, Nat) ∧ likes(Burr, Armadillos) ∧ … – Things: nothing ¨ “Burr likes something.” – Persons: nobody, no one ¨ “Somebody likes Burr.” 27 28

Thinking in Logical Sentences Thinking in Logical Sentences

We can also have multiple quantifiers: Let’s allow more complex quantified relations: ¨ ¨ “Somebody heard something.” “All stinky shoes are allowed.” – What are the variables? – How are ideas connected? • being a shoe and being stinky implies that it is allowed • somebody and something

∀ ∧

– Answer: ∀x shoe(x) ∧ stinky(x) allowed(x)

– How are they quantified? ¨ • both are at least one/existential “No stinky shoes are allowed.” ¬∃ ∧ ∧

– Answer: ∃x,y heard(x,y) – Answer: x shoe(x) stinky(x) allowed(x) ¨ ¨ “Everybody heard everything.” The equivalent:

“Stinky shoes are not allowed.” ¨

“Somebody did not hear everything.” ∀ ∧ ¬

– Answer: ∀x shoe(x) ∧ stinky(x) ¬allowed(x)

29 30

5 Thinking in Logical Sentences Thinking in Logical Sentences

And some more complex relations: And some really complex relations: ¨ ¨ “No one sees everything.” “Any good amateur can beat some professional.”

– What are the variables and quantifiers? – Lets break this down: ¢

∀ ¢ ¢ • nothing and everything • x [ (x is a good amateur) ¢ (x can beat some professional) ] • not one (i.e. not existential) and all (universal) • (x can beat some professional) is really: ∃y [ (y is a professional) ∧ (x can beat y) ]

– Answer: ¬∃x ∀y sees(x,y) ¢

∀ ¢ ¢ • x [ (x is a good amateur) ¢ ¨ Equivalent: ∃y [ (y is a professional) ∧ (x can beat y) ]

∀ ∧

¢ ¢ ¢ – Answer: ∀x [{amateur(x) ∧ good(x)} ¢ “Everyone doesn’t see something.” ∃y {professional(y) ∧ beat(x,y)}] ∀ ∃ ¬

– Answer: x y sees(x,y) ¨

¨ “Some professionals can beat all amateurs.” “Everyone sees nothing.” – Answer: ∃x [professional(x) ∧

∀ ¬∃ ¢

x y sees(x,y) ∀ ¢ ¢ – Answer: 31 ∀y {amateur(y) ¢ beat(x,y)}] 32

Thinking in Logical Sentences Thinking in Logical Sentences

We can throw in functions and equalities, too: Interesting words: always, sometimes, never ¨ “Burr and Nat are the same age.” – “Good people always have friends.”

∀ ∧ ∃

– Are functional relations specified? ∀x person(x) ∧ good(x) ∃y(friend(x,y)) – Are equalities specified? – “Busy people sometimes have friends.” – Answer: age(Burr) = age(Nat) ∃x person(x) ∧ busy(x) ∧ ∃y(friend(x,y)) ¨ “There are exactly two shoes.” – “Bad people never have friends.”

∀ ∧ ¬∃

∀ ∧ ¬∃

– Are quantities specified? x person(x) bad(x) y(friend(x,y)) – Are equalities implied?

– Answer: ∃x ∃y shoe(x) ∧ shoe(y) ∧ ¬(x=y) ∧ ¢

∀ ¢ ∨ ¢ z (shoe(z) ¢ (x=z) (y=z))

33 34

Thinking in Logical Sentences First-Order Inference

These are pretty tricky: ¨ Recall that with PL, inference is pretty easy “Assume x is above y if x is directly on the top of y, or else – Enumerate all possibilities (truth tables) there is a pile of one or more other objects directly on top – Apply sound inference rules on facts of on another starting with x and ending with y.” ∀ ∀ ⇔ ∨ – Answer: x y above(x,y) [onTop(x,y) ¨ ∃z{onTop(x,z) ∧ above(z,y)}] But in FOL, we have concepts of variables, relations, and quantification

– This complicates things quite a bit! President Lincoln: “You can fool some of the people all of the time, and you can fool all of the people some of the time, but you cannot fool all of the people all of the time!” ¨ Next time, we’ll discuss how inference procedures for first-order logic work 35 36

6