Sei sulla pagina 1di 8

Logic

z A formal language with:


z Syntax – what expressions are legal
Logic – the final push z Semantics – what legal expressions mean
z Proofs – get other expressions to tell us
something new
Propositional
First order z Why proofs? Two kinds of inference:
z Multiple percepts – conclusions about the world
z Current state and operator – properties of next
state.

Logic - semantics Terminology


z What A and B and C stand for in the world
will be given by an object called an
"interpretation".
z An interpretation is an assignment of truth
values to the propositional variables. It can
be thought of it as a possible way the world
could be.
z So if the set of variables is P, Q, R, and V,
then P true, Q false, R true, V true, that
would be an interpretation.
z So then, given an interpretation, we can ask
the question, is this sentence true in that
interpretation?

Examples Example

1
Checking interpretations Proofs – natural deduction

Proofs – resolution refutation Resolution refutation

Example Example

2
Example solution Example solution

Propositional logic is a weak language Example


z Hard to identify “individuals” (e.g., Mary, 3) z Consider the problem of representing the following
information:
z Can’t directly talk about properties of individuals or relations
between individuals (e.g., “Bill is tall”) z Every person is mortal.
z Generalizations, patterns, regularities can’t easily be represented z Confucius is a person.
(e.g., “all triangles have 3 sides”)
z Confucius is mortal.
z First-Order Logic (abbreviated FOL or FOPC) is expressive
enough to concisely represent this kind of information z How can these sentences be represented so that
we can infer the third sentence from the first two?
FOL adds relations, variables, and quantifiers, e.g.,

z “Every elephant is gray”: ∀ x (elephant(x) → gray(x))

z “There is a white alligator”: ∃ x (alligator(X) ^ white(X))

Example 2 First order logic - FOL


z In PL we have to create propositional symbols to stand for all or part of
each sentence. For example, we might have:
z Propositional logic only deals with “facts”,
statements that may or may not be true of the
P = “person”; Q = “mortal”; R = “Confucius”
world, e.g. “It is raining”. Variables cannot
z so the above 3 sentences are represented as: exist.
P → Q; R → P; R → Q

z Although the third sentence is entailed by the first two, we needed an z In FOL, variables refer to things in the world.
explicit symbol, R, to represent an individual, Confucius, who is a The variables can be quantified – talk about
member of the classes “person” and “mortal”
all of them or some of them without naming
z To represent other individuals we must introduce separate symbols for
each one, with some way to represent the fact that all individuals who
them specifically.
are “people” are also “mortal”

3
FOL motivation FOL
z Statements that cannot be made in PL:
z When a block is being painted with a green paint,
it becomes green.
z In PL a statement about every single block will be
needed as general statements about all blocks cannot
be made.
z When a jar is sterilized, all bacteria are dead.
z In FOL we talk about all bacteria without naming them
explicitly.
z A person is allowed in the Portal if they have
access.

First-order predicate logic Representation of English Language

Constants are used to name specific objects or properties about the


z Almost any English sentence may be represented in first-
problem.
john, mary
order predicate calculus.
z There is no unique mapping of sentence into predicate
A fact or proposition is divided into two parts: a predicate and an calculus expressions.
argument. The argument represents the object or objects of the Example:
proposition and the predicate an assertion about the object. (1) John’s mother is married to John’s father
John likes Mary likes(john, mary) married(father( john), mother( john))
(2) Chicken is good and chicken is a kind of food,
Variables are used to represent general classes of objects or
properties. good(chicken) ∧ is(chicken, food)
likes(x, y) good(chicken) ∧ food(chicken)
(3) All food are edible
A function denotes a mapping from entities of a set to a unique
∀X food( X) → edible( X)
element of another set.
father(jack) = bob mother(judy) = kathy

Representation of English Language (cont.) Representation of English Language (cont.)

z John lives in a yellow house z All exams are difficult


∀X exam( X) → difficult( X)
∃X house(X) ∧ color(X, yellow) ∧ lives(john, X)

z If the car belongs to John, then it is green. z Winston did not write Hamlet.
~write( winston, hamlet)
∀X car( X) ∧ owns(john, X) → color(X, green)
z Nobody wrote Hamlet.
z John plays the piano or the violin
~∃X write( X, hamlet)
plays(john, piano) ∨ plays(john, violin)

z Some people like snakes. z Every city has a dogcatcher who has been bitten by every
∃X (person(X) ∧ likes(X, snakes)) dog in town
∃X (person(X) ∧ ∀Y (snake(Y) → likes(X, Y))) ∀X {city(X) →∃Y{dogcatcher(Y, Z) ∧ ∀Z{[dog(Z)
z All students take exams ∧ live- in(Z, X)] → bit(Z, Y)}}}
∀X student(X) → take-exam(X) Try X=NY, Y=Dan,
Z=Fido
∀X student(X) → (∃Y exam(Y) ∧ take (X, Y))

4
FOL semidecidability
z Semidecidability of predicate logic
z (∀xP(x) ⇒ ∃yP(y)) is a tautology (statement always true
regardless of its components);
z its negation, (∀xP(x) ∧ —∃yP(y)) is an inconsistency.
z A formula is consistent if, and only if, it is true under at least one
interpretation. Every tautology is a consistent formula, but not
vice versa.
z In predicate logic: infinite number of domains; infinite number of
elements; infinite number of interpretations of a formula. Cannot
show that a formula is a tautology or an inconsistency by
evaluating it under all interpretations. In predicate logic there
exists no general proof procedure that will prove a goal G if G is
a theorem, and that will disprove G if G is not a theorem. So
predicate logic is said to be semidecidable.

Question Some Useful Inference Rules (cont.)

z Introduction
if P is true and Q is true
then P ∧ Q is true

z Universal instantiation / ∀-elimination


For any WFF Φ that mentions a variable X,
if we have
∀X Φ(X)
we can conclude Φ(a) for any a from the domain of X.
e. g., ∀X human( X) → mortal( X)
then human(socrates) → mortal(socrates)

Unification Substitution

z In propositional calculus, two expressions match or are the z To make, say p( X, X) and p( Y, Z) match, we may use
same only if they are syntactically identical: X/ Y - X substitute for Y
e. g., P ∧ (Q ∨ R) → S = P ∧ (Q ∨ R) → S X/ Z - X substitute for Z
≠ P ∧ (S ∧ Q) → R

z variables in predicate calculus complicates matters. sometimes, we may need to substitute a function for a variable:
human(X) = human(socrates) if X=socrates e. g., human( X) → mortal( X)
human(father_ of( plato))
z Unification is an algorithm for determining the substitutions father_ of( plato)/ X
needed to make two predicate calculus expressions match.

z Unification and inference rules allows us to make inferences human(father_ of( plato)) → mortal(father_ of( plato))
on a set of logical assertions. To do this, the logical data
base must be expressed in an appropriate form.

5
Substitution (cont.) Substitution (cont.)

z Another example: z Question: Unify q( X, tom) & q( mary, Y)


foo( fred, a, goo( Z)) q( X, tom) & q( mary, Y)
{fred/ X, Z/ Y}
foo( X, a, goo( Y)) {tom/ Y, mary/ X}
{W/ X, jack/ Y}
foo( W, a, goo( jack)) q( mary, tom) q( mary, tom)
{Z/ X, moo( Z)/ Y}
foo( Z, a, goo( moo( Z)))
z A variable must be substituted consistently across all
occurrences of variable in both expressions being
z A variable can be substituted by a constant, but any constant matched.
is a ground instance and may not be replaced p( X) ∧ q( Y, X) p( W) ∧ q( Z, X)
red( X) {W/ X, Y/ Z}
red( square)
p( W) ∧ q( Y, W) p( W) ∧ q( Y, W)

Substitution (cont.)

z A variable cannot be unified with a term containing that


variable:
X p( X)
{P( X)/ X}
p( X) p( p( X))
p( p( X)) p( p( p( X))) … •

z If we apply a series of substitutions, the effect is the same as a


single substitution that is a composition of the series of
substitutions.
p( X) ∧ q( Y, X)
{V/ X, Z/ Y}
p( V) ∧ q( Z, V) {a/ X. f( b)/ Y)
{a/ V, f( b)/ Z}
p( a) ∧ q( f( b), a)

FOL resolution Converting to clausal form

6
Continuation to conversion Conversion
z Step four is to skolemize, named after a logician called Thoralf
Skolem.
z Imagine that you have a sentence that looks like: there exists an
x such that P(x). The goal here is to somehow arrive at a
representation that doesn't have any quantifiers in it.
z The Skolem insight is that when you have an existential
quantification like this, you're saying there is such a thing as a
unicorn, let's say that P means "unicorn". There exists a thing
such that it's a unicorn. You can just say, all right, well, if there is
one, let's call it Fred. That's it. That's what Skolemization is.
z So instead of writing exists an x such that P(x), you say P(Fred).
The trick is that it absolutely must be a new name. It can't be any
other name of any other thing that you know about. If you're in
the process of inferring things about John and Mary, then it's not
good to say, oh, there's a unicorn and it's John --because that's
adding some information to the picture. So to Skolemize, in the
simple case, means to substitute a brand-new name for each
existentially quantified variable.

Conversion Examples for conversion

Substitutions Unifications

7
Most general unifier Unifications
z In unification, we are interested in ways of
making expressions equivalent, in every
interpretation of the constant and function
symbols.

z So, although it might be possible for the


constants A and B to be equal because they
both denote the same object in some
interpretation, we can't unify them, because
they aren't required to be the same in every
interpretation.

Potrebbero piacerti anche