85
15-780: Graduate AI Lecture 2. Proofs & FOL Geoff Gordon (this lecture) Tuomas Sandholm TAs Byron Boots, Sam Ganzfried 1

15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Embed Size (px)

Citation preview

Page 1: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

15-780: Graduate AILecture 2. Proofs & FOL

Geoff Gordon (this lecture)Tuomas Sandholm

TAs Byron Boots, Sam Ganzfried

1

Page 2: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Admin

2

Page 3: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Audits

http://www.cmu.edu/hub/forms/ESG-AUDIT.pdf

3

Page 4: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Matlab tutorial

When is good?

4

Page 5: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Review

5

Page 6: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

What is AI?

Lots of examples: poker, driving robots, RoboCupThings that are easy for us to do, but no obvious algorithmSearch / optimization / summationHandling uncertainty

6

Page 7: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Propositional logic

Syntaxvariables, constants, operatorsliterals, clauses, sentences

Semantics (model ↦ {T, F})

Truth tables, how to evaluate formulasSatisfiable, valid, contradiction

7

Page 8: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Propositional logic

Manipulating formulas (e.g., de Morgan)Normal forms (e.g., CNF)Tseitin transformation to CNFHow to translate informally-specified problems into logic (e.g., 3-coloring)

8

Page 9: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Compositional Semantics

9

Page 10: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Semantics

Recall: meaning of a formula is a functionmodels ↦ {T, F}

Why this choice? So that meanings are compositionalWrite [α] for meaning of formula α[α ∧ β](M) = f(M) = [α](M) ∧ [β](M)

Similarly for ∨, ¬, etc.

10

Page 11: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Structural induction

Why are compositional semantics useful?Can prove properties of FOL formulas by induction on their parse treesProve property P holds for all atomsThen show that P(α), P(β) imply P(α∧β), P(α∨β), P(¬α) for arbitrary formulas α, β

11

Page 12: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Proofs

12

Page 13: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Entailment

Sentence A entails sentence B, A ⊨ B, if B is True in every model where A is

same as saying that (A ⇒ B) is valid

13

Page 14: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Proof tree

A tree with a formula at each nodeAt each internal node, children ⊨ parent

Leaves: assumptions or premisesRoot: consequenceIf we believe assumptions, we should also believe consequence

14

Page 15: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Proof tree example

15

Page 16: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Proof tree example

16

Page 17: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Proof tree example

17

Page 18: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Proof by contradiction

Assume opposite of what we want to prove, show it leads to a contradiction Suppose we want to show KB ⊨ S

Write KB’ for (KB ∧ ¬S)

Build a proof tree withassumptions drawn from clauses of KB’conclusion = Fso, (KB ∧ ¬S) ⊨ F (contradiction)

18

Page 19: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Proof by contradiction

19

Page 20: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Proof by contradiction

20

Page 21: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Inference rules

21

Page 22: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Inference rule

To make a proof tree, we need to be able to figure out new formulas entailed by KBMethod for finding entailed formulas = inference ruleWe’ve implicitly been using one already

22

Page 23: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Modus ponens

Probably most famous inference rule: all men are mortal, Socrates is a man, therefore Socrates is mortalQuantifier-free version: man(Socrates) ∧

(man(Socrates) ⇒ mortal(Socrates))

d(a ∧ b ∧ c ⇒ d) a b c

23

Page 24: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Another inference rule

Modus tollensIf it’s raining the grass is wet; the grass is not wet, so it’s not raining

¬a(a ⇒ b) ¬b

24

Page 25: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

One more…

(a ∨ b ∨ c) (¬c ∨ d ∨ e)a ∨ b ∨ d ∨ e

ResolutionCombines two sentences that contain a literal and its negationNot as commonly known as modus ponens / tollens

25

Page 26: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Resolution example

Modus ponens / tollens are special casesModus tollens:(¬raining ∨ grass-wet) ∧ ¬grass-wet ⊨ ¬raining

26

Page 27: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Resolution

Simple proof by case analysisConsider separately cases where we assign c = True and c = False

(a ∨ b ∨ c) (¬c ∨ d ∨ e)a ∨ b ∨ d ∨ e

27

Page 28: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Resolution case analysis

28

Page 29: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Soundness and completeness

An inference procedure is sound if it can only conclude things entailed by KB

common sense; haven’t discussed anything unsound

A procedure is complete if it can conclude everything entailed by KB

29

Page 30: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Completeness

Modus ponens by itself is incompleteResolution is complete for propositional logic

not obvious—famous theorem due to Robinsoncaveat: also need factoring, removal of redundant literals (a ∨ b ∨ a) ⊨ (a ∨ b)

30

Page 31: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Variations

Horn clause inference (faster)Ways of handling uncertainty (slower)CSPs (sometimes more convenient)Quantifiers / first-order logic

31

Page 32: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Horn clauses

Horn clause: (a ∧ b ∧ c ⇒ d)

Equivalently, (¬a ∨ ¬b ∨ ¬c ∨ d)

Disjunction of literals, at most one of which is positivePositive literal = head, rest = body

32

Page 33: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Use of Horn clauses

People find it easy to write Horn clauses (listing out conditions under which we can conclude head)

happy(John) ∧ happy(Mary) ⇒ happy(Sue)

No negative literals in above formula; again, easier to think about

33

Page 34: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Why are Horn clauses important

Modus ponens alone is completeSo is modus tollens aloneInference in a KB of propositional Horn clauses is linear

e.g., by forward chaining

34

Page 35: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Forward chaining

Look for a clause with all body literals satisfiedAdd its head to KB (modus ponens)RepeatSee RN for more details

35

Page 36: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Handling uncertainty

Fuzzy logic / certainty factorssimple, but don’t scale

Nonmonotonic logicalso doesn’t scale

Probabilitiesmay or may not scale—more laterDempster-Shafer (interval probability)

36

Page 37: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Certainty factors

KB assigns a certainty factor in [0, 1] to each propositionInterpret as “degree of belief”When applying an inference rule, certainty factor for consequent is a function of certainty factors for antecedents (e.g., minimum)

37

Page 38: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Problems w/ certainty factors

Famously difficult to debug a KB with certainty factors, because…it’s hard to separate a large KB into mostly-independent chunks that interact only through a well-defined interface, because…certainty factors are not probabilities (i.e., do not obey Bayes’ Rule)

38

Page 39: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Nonmonotonic logic

Suppose we believe all birds can flyMight add a set of sentences to KB

bird(Polly) ⇒ flies(Polly)

bird(Tweety) ⇒ flies(Tweety)

bird(Tux) ⇒ flies(Tux)bird(John) ⇒ flies(John)

…39

Page 40: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Nonmonotonic logic

Fails if there are penguins in the KBFix: instead, add

bird(Polly) ∧ ¬ab(Polly) ⇒ flies(Polly)

bird(Tux) ∧ ¬ab(Tux) ⇒ flies(Tux)

…ab(Tux) is an “abnormality predicate”Need separate abi(x) for each type of rule

40

Page 41: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Nonmonotonic logic

Now set as few abnormality predicates as possibleCan prove flies(Polly) or flies(Tux) with no ab(x) assumptionsIf we assert ¬flies(Tux), must now assume ab(Tux) to maintain consistencyCan’t prove flies(Tux) any more, but can still prove flies(Polly)

41

Page 42: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Nonmonotonic logic

Works well as long as we don’t have to choose between big sets of abnormalities

is it better to have 3 flightless birds or 5 professors that don’t wear jackets with elbow-patches?even worse with nested abnormalities: birds fly, but penguins don’t, but superhero penguins do, but …

42

Page 43: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

First-order logic

43

Page 44: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

First-order logic

So far we’ve been using opaquevars like rains or happy(John)Limits us to statements like “it’s raining” or “if John is happy then Mary is happy”Can’t say “all men are mortal” or “if John is happy then someone else is happy too”

Bertrand Russell1872-1970

44

Page 45: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Predicates and objects

Interpret happy(John) or likes(Joe, pizza) as a predicate applied to some objectsObject = an object in the worldPredicate = boolean-valued function of objectsZero-argument predicate x() plays same role that Boolean variable x did before

45

Page 46: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Distinguished predicates

We will assume three distinguished predicates with fixed meanings:

True / T, False / FEqual(x, y)

We will also write (x = y) and (x ≠ y)

46

Page 47: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Equality satisfies usual axioms

Reflexive, transitive, symmetricSubstituting equal objects doesn’t change value of expression

(John = Jonathan) ∧ loves(Mary, John) ⇒ loves(Mary, Jonathan)

47

Page 48: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Functions

Functions map zero or more objects to another object

e.g., professor(15-780), last-common-ancestor(John, Mary)

Zero-argument function is the same as an object—John v. John()

48

Page 49: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

The nil object

Functions are untyped: must have a value for any set of argumentsTypically add a nil object to use as value when other answers don’t make sense

49

Page 50: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Types of values

Expressions in propositional logic could only have Boolean (T/F) valuesNow we have two types of expressions: object and Boolean

done(slides(15-780)) ⇒ happy(professor(15-780))

Functions convert objects to objects; predicates convert objects to Booleans; connectives convert Booleans to Booleans

50

Page 51: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Definitions

Term = expression referring to an objectJohnleft-leg-of(father-of(president-of(USA)))

Atom = predicate applied to objectshappy(John)rainingat(robot, Wean-5409, 11AM-Wed)

51

Page 52: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Definitions

Literal = possibly-negated atomhappy(John), ¬happy(John)

Sentence = literals joined by connectives like ∧∨¬⇒

rainingdone(slides(780)) ⇒ happy(professor)

52

Page 53: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Semantics

Models are now much more complicatedList of objects (finite or countable)Table of function values for each function mentioned in formulaTable of predicate values for each predicate mentioned in formula

Meaning of sentence: model ↦ {T, F}

Meaning of term: model ↦ object53

Page 54: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

For example

54

Page 55: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

KB describing example

alive(cat)ear-of(cat) = earin(cat, box) ∧ in(ear, box)

¬in(box, cat) ∧ ¬in(cat, nil) …

ear-of(box) = ear-of(ear) = ear-of(nil) = nilcat ≠ box ∧ cat ≠ ear ∧ cat ≠ nil …

55

Page 56: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Aside: avoiding verbosity

Closed-world assumption: literals not assigned a value in KB are false

avoid stating ¬in(box, cat), etc.Unique names assumption: objects with separate names are separate

avoid box ≠ cat, cat ≠ ear, …

56

Page 57: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Aside: typed variables

KB also illustrates need for data typesDon’t want to have to specify ear-of(box) or ¬in(cat, nil)

Could design a type systemargument of happy() is of type animate

Function instances which disobey type rules have value nil

57

Page 58: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Model of example

Objects: C, B, E, NAssignments:

cat: C, box: B, ear: E, nil: Near-of(C): E, ear-of(B): N, ear-of(E): N, ear-of(N): N

Predicate values:in(C, B), ¬in(C, C), ¬in(C, N), …

58

Page 59: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Failed model

Objects: C, E, NFails because there’s no way to satisfy inequality constraints with only 3 objects

59

Page 60: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Another possible model

Objects: C, B, E, N, XExtra object X could have arbitrary properties since it’s not mentioned in KBE.g., X could be its own ear

60

Page 61: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

An embarrassment of models

In general, can be infinitely many modelsunless KB limits number somehow

Job of KB is to rule out models that don’t match our idea of the worldSaw how to rule out CEN model Can we rule out CBENX model?

61

Page 62: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Getting rid of extra objects

Can use quantifiers to rule out CBENX model:∀x. x = cat ∨ x = box ∨ x = ear ∨ x = nil

Called a domain closure assumption

62

Page 63: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Quantifiers

Want “all men are mortal,” or closureAdd quantifiers and object variables∀x. man(x) ⇒ mortal(x)

¬∃x. lunch(x) ∧ free(x)

∀: no matter how we fill in object variables, formula is still true∃: there is some way to fill in object variables to make formula true

63

Page 64: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Variables

Build atoms from variables x, y, … as well as constants John, Fred, …

man(x), loves(John, z), mortal(brother(y))Build formulas from these atoms

man(x) ⇒ mortal(brother(x))

New syntactic construct: term or formula w/ free variables

64

Page 65: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

New syntax ⇒ new semantics

New part of model: interpretationMaps variables to model objects

x: C, y: NMeaning of a term or formula: look up its free variables in the interpretation, then continue as beforealive(ear(x)) ↦ alive(ear(C)) ↦ alive(E) ↦ T

65

Page 66: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Working with interpretations

Write (M / x: obj) for the model which is just like M except that variable x is interpreted as the object objM / x: obj is a refinement of M

66

Page 67: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Binding

Adding quantifier for x is called binding xIn (∀x. likes(x, y)), x is bound, y is free

Can add quantifiers and apply logical operations like ∧∨¬ in any order

But must eventually wind up with ground formula (no free variables)

67

Page 68: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Semantics of ∀

A sentence (∀x. S) is true in M if S is true in (M / x: obj) for all objects obj in M

68

Page 69: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Example

M has objects (A, B, C) and predicate happy(x) which is true for A, B, CSentence ∀x. happy(x) is satisfied in M

since happy(A) is satisfied in M/x:A, happy(B) in M/x:B, happy(C) in M:x/C

69

Page 70: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Semantics of ∃

A sentence (∃x. S) is true in M if there is some object obj in M such that S is true in model (M / x: obj)

70

Page 71: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Example

M has objects (A, B, C) and predicatehappy(A) = happy(B) = Truehappy(C) = False

Sentence ∃x. happy(x) is satisfied in M

Since happy(x) is satisfied in, e.g., M/x:B

71

Page 72: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Scoping rules

Portion of formula where quantifier applies = scopeVariable is bound by innermost enclosing scope with matching nameTwo variables in different scopes can have same name—they are still different vars

72

Page 73: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Scoping examples

(∀x. happy(x)) ∨ (∃x. ¬happy(x))

Either everyone’s happy, or someone’s unhappy

∀x. (raining ∧ outside(x) ⇒ (∃x. wet(x)))

The x who is outside may not be the one who is wet

73

Page 74: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Quantifier nesting

English sentence “everybody loves somebody” is ambiguousTranslates to logical sentences∀x. ∃y. loves(x, y)

∃y. ∀x. loves(x, y)

74

Page 75: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Reasoning in FOL

75

Page 76: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Entailment, etc.

As before, entailment, unsatisfiability, validity, equivalence, etc. refer to all possible modelsBut now, can’t determine by enumerating models

since there could be infinitely many

76

Page 77: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Equivalences

All transformation rules for propositional logic still holdIn addition, there is a “De Morgan’s Law” for moving negations through quantifiers

¬∀x. S ≡ ∃x. ¬S

¬∃x. S ≡ ∀x. ¬S

And, rules for getting rid of quantifiers

77

Page 78: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Generalizing CNF

Eliminate ⇒, move ¬ in w/ De Morgan

but ¬ moves through quantifiers too

Get rid of quantifiers (see below)Distribute ∧∨, or use Tseitin

78

Page 79: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Do we really need ∃?

∃x. happy(x)

happy(happy_person())

∀y. ∃x. loves(y, x)

∀y. loves(y, loved_one(y))

79

Page 80: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Skolemization

Called Skolemization (after Thoraf Albert Skolem) Thoraf Albert Skolem

1887–1963

Eliminate ∃ by substituting a function of arguments of all enclosing ∀ quantifiers

Make sure to use a new name!

80

Page 81: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Do we really need ∀?

∀x. happy(x) ∧ ∀y. takes(y, CS780)

happy(x) ∧ takes(y, CS780)

81

Page 82: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Getting rid of quantifiers

Standardize apart (avoid name collisions)SkolemizeDrop ∀ (free variables implicitly universally quantified)Terminology: still called “free” even though quantification is implicit

82

Page 83: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

For example

∀x. man(x) ⇒ mortal(x)

(¬man(x) ∨ mortal(x))

∀x. (honest(x) ⇒ happy(Diogenes))(¬honest(y) ∨ happy(Diogenes))

∀y. ∃x. loves(y, x)

loves(z, f(z))

83

Page 84: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Exercise

(∀x. honest(x)) ⇒ happy(Diogenes)

84

Page 85: 15-780: Graduate AI Lecture 2. Proofs & FOL - cs.cmu.eduggordon/780-spring09/slides/02-proofs+fol... · Search / optimization / summation Handling uncertainty 6. Propositional logic

Exercise

85