24
First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

  • View
    215

  • Download
    0

Embed Size (px)

Citation preview

Page 1: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

First-Order Logic

Copyright, 1996 © Dale Carnegie & Associates, Inc.

Chapter 8

Spring 2004

Page 2: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 2

Why and whatFOL makes a stronger set of ontological commitments (more than facts) shown in Fig 8.1The world consists of objects and relations. Objects - things with individual identities Properties - sth distinguishing them from others Relations - sth between objects Functions - special relations with one value

Facts refer to objects, properties or relations The D-Backs beat the Cardinals. (When?)

Page 3: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 3

FOLFOL is universal - it can express anything that can be programmed - what else do we want?FOL is the most studied and best understood scheme yet devised.Its syntax and semantics

Page 4: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 4

SyntaxSymbols (Fig 8.4, Page 247) Constant symbols Predicate symbols - relations, tuples Functional symbols - relations

Terms - objects, ground (constant symbols) & complex (functions) termsAtomic sentences Brother(Richard, John),

Married(Father(R),Mother(J))

Complex sentences formed by connectives !Brother(Robin,John)

Page 5: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 5

QuantifiersUniversal quantification () - to avoid enumerating the objects by name combining with variables, we can do that: x Cat(x) Mammal(x) x P(x) Q(x) makes a statement about

everything, but not when P(x) is false x P(x) ^ Q(x) leads to a too strong

statementx King(x) ^Person(x)

Page 6: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 6

Existential quantification () - make a statement about some object without naming it. x P(x) ^ Q(x) - at least one x such

that P(x) and Q(x) is true x P(x) Q(x) leads to a too weak

statement No uniqueness is claimed

is used with , ^ with

Page 7: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 7

Nested quantifiersMultiple quantifiers can be used.The order of quantification is important. x y Loves (y,x) y x Loves (y,x)

When there is confusion, the variable belongs to the innermost quantifier that mentions it. x [Cat(x) v (x Brother(Richard,x))]

Well-formed formula (wff) - sentences that have all their variables properly introduced.

Page 8: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 8

Connections, Equality The two quantifiers are connected via negation. De Morgan’s rules

Do we really need both quantifiers? Some examples

Equality symbol: two terms refer the same object or not the same object Some examples

Page 9: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 9

Using FOLDomain – some part of the world The kinship domain

Axioms - basic factsDefinitions - concepts defined by axioms x,y P(x,y) …

Theorems - that are proved using axioms and definitions, or entailed by axioms x,y Sibling(x,y) Sibling(y,x)

Two important questions in building a KB Are axioms in the KB sufficient? Are all axioms in the KB necessary?

Page 10: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 10

What should be in a KB From a purely logical point of view From a practical point of view

Adding sentences (assertions) to a KB Tell(KB, King(John)) Tell(KB, x King(x) Person(x))

Asking questions and getting answers Ask(KB, King(John)) - True Ask(KB, x Child(x,Spot)) – substitution

x/Wonder

Page 11: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 11

The domain of sets and lists

EpmtySet – constant {}Member , Subset - predicatesIntersection, Union, Adjoin - functionsEight axioms of sets (page 257):

1. the only sets are EmptySet and those made by adjoining something to a set {x|s2} where Set(s2).

The differences between lists and sets Order and repetition of an element

Page 12: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 12

Logical agents for WumpusReflex agents classify percepts and actModel-based agents have an internal representationGoal-based agents form goals and achieve themThe first-order axioms are much more concise than propositional logic axioms

Page 13: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 13

Constructing a logical agentDefine the interface (percepts) between the environment and the agent Including time using a time stamp

Percept([Stench, Breeze,Glitter, None,None], 5)

Define actions Actions: Turn(Right), Forward, Shoot, Grab, Release,

Climb

Provide an action: a BestAction(a, 5) - a/Grab

Modify the environment t,s,b,m,c Percept([s,b,Glitter,m,c],t)Glitter(t) t Glitter(t) BestAction(Grab,t)

This implements a simple reflex behavior

Page 14: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 14

Deducing hidden propertiesSynchronic rules (vs. diachronic) Causal rules specify the assumed

direction of causality - model-based reasoning Squares adjacent to pits are breezy A pit causes …

Diagnostic rules infer hidden properties from the percept-derived information If a location is smelly, the wumpus must either

be in that location or in an adjacent location If there is breeze, …

Page 15: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 15

Representing changeStoring a complete percept sequence is tedious and inefficient to search for actions An internal model allows an agent to know its current status having gold and at home square

Representing change is one of the most important tasks in knowledge representation How to represent change?

Page 16: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 16

Ways of representing change

The latest case only, forget about the past= having a shallow memory and no history= repeating errors

Each state represented by a KB can’t reason about >1 situation simultaneously need to represent different situations/actions in one

KB

Situation calculus (Chapter 10.3) representing situations and actions as representing

objects

Page 17: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 17

Situation calculus A particular way of describing change in FOLEach situation is a snapshot of the state Situations are generated from previous situations

by actions (Fig 10.2, p329)

Give an extra situation argument for every relation/property that can change over time it’s always the last one argument

At(Agent,[1,1],S0)^ At(Agent,[1,2],S1) using Result(action, situation)

Result(Forward, S2) = S3

Page 18: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 18

Special axiomsEffect axioms - actions are described by stating their effects Holding-gold via Grab, !Holing-gold via

Release Are the above enough?

Frame axioms - describing how the world stays the same Holding-sth not releasing it, then holding it

next state !Holding-sth not (grab or present or portable)

The two types of axioms together describe the world in change.

Page 19: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 19

Successor-state (SS) axioms - resulting from the combining of the E- and F- axioms true afterwards [an action made it true v

true already and no action made it false]

One SS axiom is needed for each predicate changing with time

A SS axiom must list all the ways in which the predicate can become true or false

Page 20: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 20

Keep track of locationWhat direction an agent is facing Orientation(Agent,S0) = 0

How locations are arranged (via a map) x,y LocationToward([x,y],90)=[x,y+1] Location l ahead of agent p: p,l,s At(p,l,s) x,y Adjacent(x,y) d

x=LocationToward(y,d)

What’s known about the map x,y Wall([x,y]) (x=0 or x=5 or y=0 or

y=5)

Page 21: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 21

What actions change locations Going forward changes location

What actions change orientations Turning changes orientation

There are still many research issues: frame problems - the property remains unchangedqualification problem - an action guaranteed to workramification problem - implicit consequences of an action

Page 22: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 22

Which actionDifferent actions can achieve the same goal depending on constraintsSeparating facts about actions from facts about goals as goals describe the desirability of outcome states desirability scale: great, good,

medium,risky, deadly

Defining the desirability of actions, leaving the inference to choose an action that has the highest desirability

Page 23: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 23

A goal-based agentCertain actions lead to radical policy change: getting the gold -> returning s Holding(Gold,s) GoalLocation([1,1],s)

Explicit goals allow many ways to work out a sequence of actions Inference Search Planning

Page 24: First-Order Logic Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 8 Spring 2004

CS 471/598 by H. Liu 24

SummaryFOL is a general-purpose representation language based on objects and relationsBNF of FOLA logical agent using FOLSituation calculus to handle changesCausal rules are often more flexible and entail a wider range of consequencesWe’re ready to infer in FOL ...