Last time we introduced the propositional logic as a way of representing and reasoning about the world. Unfortunately, the propositional knowledge-based agent has some real problems.
The reason for these problems is that propositional logic only believes in one "object" in the world--the fact or proposition.
Today, we introduce first-order logic or FOL, which allows us to describe the world, actions and change much more succinctly.
First-order logic is about objects and relations. This is the ontological commitment that it makes about the world.
In the Wumpus world, the objects are the agent, the Wumpus, the gold, the arrow, the grid of squares, the walls, the pits.
The relations are "pit in square [1,1]", "agent has arrow", "Wumpus is smelly". Notice that a "relation" can involve any number (including one) of objects.
FOL is neutral about many common things in the world such as categories, time and events. But it can express them in different ways, which makes it flexible and powerful.
The components of FOL are the connectives of propositional logic; terms which are constants, variables or functions; predicates which represent the properties of a single object or relationships among two or more objects; and quantifiers.
Let's look at an example. Consider the grandparent relationship:
FORALL g,c Grandparent(g,c) <=> EXISTS p Parent(g,p) AND Parent(p,c)
FORALL and EXISTS are quantifiers.
g, c and p are variables.
Grandparent() and Parent() are predicates.
AND and <=> are connectives.
We can write the Parent() relation as follows:
FORALL x,y Parent(x,y) <=> x=Father(y) OR x=Mother(y)
This introduces the idea of a function. Father() and Mother() here are functions.
FOL has a special, predefined precicate "=" which is true whenever two terms refer to the same object.
Now we will get formal and define the FOL by a grammar:
Sentence -> AtomicSentence | Sentence Connective Sentence | Quantifier Variable,... Sentence | NOT Sentence | (Sentence) AtomicSentence -> Predicate(Term, ...) | Term = Term Term -> Constant | Variable | Function(Term,...) Connective -> AND | OR | => | <=> Quantifier -> FORALL | EXISTS Constant -> A | X_1 | John | ... Variable -> a | x | s ... Predicate -> Before | HasColor | Raining | ... Function -> Smelly | LeftLegOf | Plus | ...
The connectives of FOL are just the familiar ones: and, or, implies and iff.
A constant names a single object, defined by the interpretation. Some objects may have no name or many names.
A predicate specifies a relation between objects in the world. The interpretation and the state of the world (the "model") specify which tuples the relation holds for.
A function refers to an object. For instance, LeftLegOf(x) might refer to the left of object x. Functions give us a powerful way to refer to objects without using a constant symbol to name them.
Terms are ways of refering to objects in the world.
As we see from the grammar, a term can be a constant, a variable or a function. The first two are straightforward. Bear in mind that a function does not mean a "subroutine call" that returns a value. Think of functions as being defined by tuples where the last entry is the value.
Atomic sentences are used to state facts.
IsBird(Tweety) LikesBirds(Sylvester) Married(FatherOf(Richard), MotherOf(John)
"An atomic sentence is true if the relation referred to by the predicate symbol holds between the objects referred to by the arguments."
This in turn depends on the world: the relation holds iff the tuple of objects is in the relation.
Complex sentences are used to state more complicated facts.
The semantics are constructive, just like for propositional logic.
IsBird(Tweety) AND LikesBirds(Sylvester) => Wants(Sylvester,Tweety)
Quantifiers allow us to express properties of groups of objects.
This, together with variables, gives FOL much of its power.
Now we can say when to not to move forward with just one sentence:
FORALL l,a,s HasWumpus(location(Result(a,s))) => NOT a=Forward
(We will talk about sentences like this more next time when we discuss the situation calculus.)
The FORALL quantifier is equivalent to the conjunction of all the sentences gotten by substituting all possible values for the variable.
FORALL Cat(x) => Mammal(x)
The EXISTS quantifier makes statements about some object.
EXISTS x Brother(x,Tweety) AND Bird(x)means Tweety has a brother who is a bird.
Quantifiers can be nested.
"Everybody loves somebody"
FORALL x EXISTS y Loves(x,y)"There is a person whom everyone loves"
EXISTS x FORALL y Loves(x,y)Example: "Not all students take both Art and History"
NOT FORALL x Student(x) => (Takes(x,Art) AND Takes(x,History))
This is equivalent to "There is some student who doesn't take both Art and History"
EXISTS x NOT (Student(x) => (Takes(x,Art) AND Takes(x,History))) EXISTS x NOT (NOT Student(x) OR (Takes(x,Art) AND Takes(x,History))) EXISTS x Student(x) AND NOT (Takes(x,Art) AND Takes(x,History))
This is an application of De Morgans laws. In general,
FORALL x P is equivalent to NOT EXISTS NOT P EXISTS x P is equivalent to NOT FORALL NOT P
Axioms Axioms are rules which attempt to capture all of the (important) facts and concepts about a domain.
We want a set of axioms to completely describe the domain.
Mathematicians don't want any unnecessary (dependent) axioms---ones that can be derived from other axioms. But we might want them because they can make reasoning faster.
Here are eight axioms for set theory in the language of FOL:
FORALL s Set(s) <=> (s=EmptySet) OR (EXISTS x,r Set(r) AND s=Adjoin(s,r)
NOT EXISTS x,s Adjoin(x,s)=EmptySet
FORALL x,s Member(x,s) <=> s=Adjoin(x,s)
FORALL x,s Member(x,s) <=> EXISTS y,r (s=Adjoin(y,r) AND (x=y OR Member(x,r)))
FORALL s,r Subset(s,r) <=> (FORALL x Member(x,s) => Member(x,r)
FORALL s,r (s=r) <=> (subset(s,r) AND Subset(r,s))