Docsity

First-Order Logic: Understanding Objects, Properties, and Relations, Slides of Robotics

Partial preview of the text

Download First-Order Logic: Understanding Objects, Properties, and Relations and more Slides Robotics in PDF only on Docsity!

Basic Knowledge

Representation in

First Order Logic

First Order (Predicate) Logic (FOL)

  • First-order logic is used to model the world in

terms of

  • objects which are things with individual identities

e.g., individual students, lecturers, companies, cars ...

  • properties of objects that distinguish them from other objects

e.g., mortal, blue, oval, even, large, ...

  • classes of objects (often defined by properties)

e.g., human, mammal, machine, red-things...

  • relations that hold among objects

e.g., brother of, bigger than, outside, part of, has color, occurs after, owns, a member of, ...

  • functions which are a subset of the relations in which there is only one value'' for any giveninput''.

e.g., father of, best friend, second half, one more than ...

  • Quantifiers

Universal quantification ∀ (or forall )

  • ( ∀ x)P(x) means that P holds for all values of x in the domain

associated with that variable.

  • E.g., (∀x) dolphin(x) => mammal(x)

(∀x) human(x) => mortal(x)

  • Universal quantifiers often used with "implication (=>)" to form

"rules" about properties of a class

(∀x) student(x) => smart(x) (All students are smart)

  • Often associated with English words “all”, “everyone”, “always”, etc.
  • You rarely use universal quantification to make blanket statements

about every individual in the world (because such statement is

hardly true)

(∀x)student(x)^smart(x)

means everyone in the world is a student and is smart.

Existential quantification ∃

  • (∃x)P(x) means that P holds for some value(s) of x in the domain

associated with that variable.

  • E.g., (∃x) mammal(x) ^ lays-eggs(x)

(∃x) taller(x, Fred)

(∃x) UMBC-Student (x) ^ taller(x, Fred)

  • Existential quantifiers usually used with “^ (and)" to specify a list

of properties about an individual.

(∃x) student(x) ^ smart(x) (there is a student who is smart.)

  • A common mistake is to represent this English sentence as the

FOL sentence:

(∃x) student(x) => smart(x)

It also holds if there no student exists in the domain because

student(x) => smart(x) holds for any individual who is not a student.

  • Often associated with English words “someone”, “sometimes”,

etc.

Sentences are built from terms and atoms

  • A term (denoting a individual in the world) is a

constant symbol, a variable symbol, or a function of

terms.

  • An atom (atomic sentence) is a predicate P(x[1], ...,

x[n])

  • Ground atom: all terms in its arguments are ground terms (does not involve variables)
  • A ground atom has value true or false (like a proposition in PL)
  • A literal is either an atom or a negation of an atom
  • A sentence is an atom, or,
  • ~P, P v Q, P ^ Q, P => Q, P <=> Q, (P) where P and Q are sentences
  • If P is a sentence and x is a variable, then (∀x)P and (∃x)P are sentences
  • A well-formed formula ( wff ) is a sentence

containing no "free" variables. i.e., all variables are

"bound" by universal or existential quantifiers. (∀x)P(x,y) has x bound as a universally quantified variable, but y is free.

A BNF for FOL Sentences

S := ;

:= |

| ,... | ~ | "(" ")";

:= "(" , ... ")" |

"=" ;

:= "(" , ... ")" |

| ;

:= ^ | v | => | <=>;

:= ∃ | ∀;

:= "A" | "X1" | "John" | ... ;

:= "a" | "x" | "s" | ... ;

:= "Before" | "HasColor" | "Raining" | ... ;

:= "Mother" | "LeftLegOf" | ... ;

:= | ~

  • All purple mushrooms are poisonous.

(∀x) (mushroom(x) ^ purple(x)) => poisonous(x)

  • No purple mushroom is poisonous.

~(∃x) purple(x) ^ mushroom(x) ^ poisonous(x)

(∀x) (mushroom(x) ^ purple(x)) => ~poisonous(x)

  • There are exactly two purple mushrooms.

(∃x)(Ey) mushroom(x) ^ purple(x) ^ mushroom(y) ^ purple(y) ^ ~(x=y) ^ (∀z) (mushroom(z) ^ purple(z)) => ((x=z) v (y=z))

  • Clinton is not tall.

~tall(Clinton)

  • X is above Y if X is directly on top of Y or

there is a pile of one or more other objects

directly on top of one another starting

with X and ending with Y.

(∀x)(∀y) above(x,y) <=> (on(x,y) v (∃z) (on(x,z) ^ above(z,y)))

Example: A simple genealogy KB by FOL

  • Build a small genealogy knowledge base by FOL

that

  • contains facts of immediate family relations (spouses, parents, etc.)
  • contains definitions of more complex relations (ancestors, relatives)
  • is able to answer queries about relationships between people
  • Predicates:
  • parent(x, y), child(x, y), father(x, y), daughter(x, y), etc.
  • spouse(x, y), husband(x, y), wife(x,y)
  • ancestor(x, y), descendent(x, y)
  • Male(x), female(y)
  • relative(x, y)
  • Facts:
  • husband(Joe, Mary), son(Fred, Joe)
  • spouse(John, Nancy), male(John), son(Mark, Nancy)
  • father(Jack, Nancy), daughter(Linda, Jack)
  • daughter(Liz, Linda)
  • etc.

Connections between Forall and Exists

  • “It is not the case that everyone is ...” is logically

equivalent to “There is someone who is NOT ...”

  • “No one is ...” is logically equivalent to “All people

are NOT ...”

  • We can relate sentences involving forall and exists

using De Morgan’s laws:

~(∀x)P(x) <=> (∃x) ~P(x)

~(∃x) P(x) <=> (∀x) ~P(x)

(∃x) P(x) <=> ~(∀x) ~P(x)

(∀x) P(x) <=> ~ (∃x) ~P(x)

  • Example: no one likes everyone
    • ~ (∃x)(∀y)likes(x,y)
    • (∀x)(∃y)~likes(x,y)

Semantics of FOL

  • Domain M: the set of all objects in the world (of

interest)

  • Interpretation I: includes
    • Assign each constant to an object in M
    • Define each function of n arguments as a mapping M^n => M
    • Define each predicate of n arguments as a mapping M^n => {T, F}
    • Therefore, every ground predicate with any instantiation will have a truth value
    • In general there are infinite number of interpretations because |M| is infinite
  • Define of logical connectives: ~, ^, v, =>, <=> as in

PL

  • Define semantics of ( ∀ x) and ( ∃ x)
    • (∀x) P(x) is true iff P(x) is true under all interpretations
    • (∃x) P(x) is true iff P(x) is true under some interpretation

Axioms, definitions and theorems

  • Axioms are facts and rules which are known (or

assumed) to be true facts and concepts about a

domain.

  • Mathematicians don't want any unnecessary (dependent) axioms -- ones that can be derived from other axioms.
  • Dependent axioms can make reasoning faster, however.
  • Choosing a good set of axioms for a domain is a kind of design problem.
  • A definition of a predicate is of the form “P(x)

<=> S(x)” (define P(x) by S(x)) and can be

decomposed into two parts

  • Necessary description: “P(x) => S(x)” (only if)
  • Sufficient description “P(x) <= S(x)” (if)
  • Some concepts don’t have complete definitions (e.g. person(x))
  • A theorem S is a sentence that logically follows

the axiom set A, i.e. A |= S.

More on definitions

  • A definition of P(x) by S(x)), denoted (∀x) P(x) <=> S(x), can be decomposed

into two parts

  • Necessary description: “P(x) => S(x)” ( only if , for P(x)

being true, S(x) is necessarily true)

  • Sufficient description “P(x) <= S(x)” ( if , S(x) being true is

sufficient to make P(x) true)

  • Examples: define father(x, y) by parent(x, y) and male(x)
    • parent(x, y) is a necessary ( but not sufficient )

description of father(x, y)

father(x, y) => parent(x, y), parent(x, y) => father(x, y)

  • parent(x, y) ^ male(x) is a necessary and sufficient

description of father(x, y)

parent(x, y) ^ male(x) <=> father(x, y)

  • parent(x, y) ^ male(x) ^ age(x, 35) is a sufficient ( but not

necessary ) description of father(x, y) because

father(x, y) => parent(x, y) ^ male(x) ^ age(x, 35)

Higher order logic (HOL)

  • FOL only allows to quantify over variables.
  • In FOL variables can only range over objects.
  • HOL allows us to quantify over relations
  • Example: (quantify over functions)

“two functions are equal iff they produce the same value for all arguments”

∀f ∀g (f = g) <=> (∀x f(x) = g(x))

  • Example : (quantify over predicates)

∀r transitive( r ) => (∀xyz) r(x,y) ^ r(y,z) => r(x,z))

  • More expressive, but undecidable.

Representing Change

  • Representing change in the world in logic can

be tricky.

  • One way is to change the KB
    • add and delete sentences from the KB to reflect changes.
    • How do we remember the past, or reason about changes?
  • Situation calculus is another way
  • A situation is a snapshot of the world at some

instant in time

  • When the agent performs an action A

in situation S1, the result is a new situation S2.