Pred Logic
Pred Logic
x y Likes(x,y) y x Likes(x,y)
“Everything likes “Something is liked by
something (possibly itself)” everything (including itself)”
Expressing Number of Objects
• How do we express that there are (at least) two
cubes?
• Note that x y (Cube(x) Cube(y)) doesn’t
work: this will be true in a world with 1 object
(just pick that object for both x and y!)
• So, we have to make sure that x and y are different
objects: x y (xy Cube(x) Cube(y))
‘Exactly One’
• How can we say that “There is exactly one cube”?
• Saying that there is exactly one cube is saying two
things at once:
– There is at least one cube: xCube(x)
– There is at most one cube: xy(Cube(x)Cube(y) xy)
– Thus: xCube(x) xy(Cube(x)Cube(y)xy)
• Alternatively (and simpler):
x(Cube(x) y(Cube(y) xy))
x(Cube(x) y(Cube(y) x=y))
x y(Cube(y) x=y))
‘Exactly Two’
• How do we say “There are exactly two
cubes”?
• Similar set-up:
x y(Cube(x) Cube(y) xy z(Cube(z) zx
zy)) or:
x y(Cube(x) Cube(y) xy z(Cube(z) (z=x
z=y))) or:
x y(xy z(Cube(z) (z=x z=y)))
The Logic of Quantifiers
Quantifier Negation Equivalences
x (x)
(a)
Good and Bad Uses of Elim
x SameSize(x,x) x SameSize(x,x)
Good Bad
SameSize(a,a) SameSize(a,b)
The same individual
constant should be used!
(a)
x (x)
Good and Bad Uses of Intro
SameSize(a,a) SameSize(a,a)
Good Good
x SameSize(x,x) x SameSize(a,x)
Not all occurrences of a
have to be replaced!
SameSize(a,b) x SameSize(a,x)
Bad Bad
x SameSize(x,x) x x SameSize(x,x)
The same individual Doesn’t follow the rule (no
constant should be used! free x’s in x SameSize(x,x))
Universal Proof
• A common proof in mathematics is a universal
proof.
• A universal proof proves something about
everything (of the Universe of Discourse) by proving
it to be true of some arbitrary thing.
• It usually starts with “Let ‘a’ be an arbitrary …”
• It then proves something about ‘a’
• Finally, since ‘a’ was just an arbitrary individual, it
must be true for all individuals.
Intro
• Universal Introduction ( Elim) allows one
to conclude that everything has a certain
property if anything has that property:
a
a may not occur before the subproof,
unless all subproofs in which it occurs
(a) have been closed. a may not occur in
x (x) (x) either.
Good and Bad Uses of Intro
a Tet(a)
a
Good SameSize(a,a) Bad
SameSize(a,a)
x SameSize(x,x)
x SameSize(x,x)
a occurs before subproof!
a
Still a
Good Tet(a)
Bad SameSize(a,a)
x Tet(x)
x SameSize(a,x)
a occurs outside subproof,
but only in a subproof that has a occurs in SameSize(a,x)!
been closed.
Existential Proof
• Sometimes, we know that something has a certain
property, but we don’t know who or what this
something is.
• In order to perform some reasoning, we will give
this something a name, and whatever we can infer
from that point on, we can infer from the original
statement.
• Like the universal proof, the name should be an
arbitrary name, but in this case it denotes a
specific individual: that individual that had the
relevant property.
Elim
• Existential Elimination ( Elim) allows one to
conclude anything that follows from some thing
having a certain property, given that something
has that property.
x (x)
a (a) a may not occur before the subproof,
unless all subproofs in which it occurs
Q have been closed. a may not occur in
Q Q either.
Good and Bad Uses of Elim
x SameSize(x,x) Tet(a)
a SameSize(a,a)
Good x SameSize(x,x)
x Cube(x) Bad a SameSize(a,a)
x Cube(x)
x Large(x)
a Cube(a)
Still x Large(x)
a occurs before subproof!
Good Tet(b)
a SameSize(a,a)
Tet(b) Bad
a occurs before subproof, Large(a)
but only in a subproof Large(a)
which has been closed.
a occurs in Large(a)!
= Intro
• At any point, you can assert any statement of the
form a=a
• = Intro does not require any statements as part of its
justification, and reflects the reflexivity of identity.
a=a = Intro
= Elim
• = Elim: If you have a statement of the form
a=b, and a statement in which a occurs
(written as P(a)), then you may infer P(b),
which is the statement that results when
replacing any number of occurences of a by
b in the statement P(a):
n P(a)
m a=b
P(b) = Elim n,m
Rules for other Predicates
• Of course, one could define inference rules for
predicates other than ‘=‘. For example, given the
reflexivity of the SameSize relationship, one could
make it a rule that SameSize(a,a) can be inferred
at any time.
• However, ‘=‘ is the only predicate for which F has
defined inference rules as it is the only interpreted
predicate.
• We’ll see later how we can deal with logical truths
about other predicates.
Truth Trees for
Predicate Logic
Running Examples
Valid Argument
x (Cube(x) Small(x))
x Cube(x) x Small(x)
Invalid Argument
x Cube(x) x Small(x)
x (Cube(x) Small(x))
Truth-Functional Expansions
• Suppose that our Universe of Discourse (UD) contains
only the objects a and b.
• Given this UD, the claim x Cube(x) is true iff Cube(a)
Cube(b) is true.
• Similarly, the claim x Cube(x) is true iff Cube(a)
Cube(b) is true.
• The truth-functional interpretation of the FO statements
given a fixed UD is called the truth-functional expansion
of the original FO statement with regard to that UD.
Truth-Functional Expansions and
Proving FO Invalidity
• Truth-Functional expansions can be used to
prove FO invalidity. Example:
x Cube(x) x Small(x)
UD = {a,b}
x (Cube(x) Small(x))
T T F T F T T
(Cube(a) Cube(b)) (Small(a) Small(b))
(Cube(a) Small(a)) (Cube(b) Small(b))
T F F F F F T
This shows that there is a world in which the premise is
true and the conclusion false. Hence, the original argument
is FO invalid.
Truth-Functional Expansions and
Proving FO Validity
• If the truth-functional expansion of an FO argument in some UD is
truth-functionally invalid, then the original argument is FO invalid,
but if it is truth-functionally valid, then that does not mean that the
original argument is FO valid.
• For example, with UD = {a}, the expansion of the argument would
be truth-functionally valid. In general, it is always possible that
adding one more object to the UD makes the expansion invalid.
• Thus, we can’t prove validity using the expansion method, as we
would have to show the expansion to be valid in every possible
UD, and there are infinitely many UD’s.
• The expansion method is therefore only good for proving
invalidity. Indeed, it searches for countermodels.
The Expansion Method as a
Systematic Procedure
• Still, what is nice about the expansion method is
that it can be made into a systematic procedure:
– Step 1: Expand FO argument (which can be done
systematically) in UD = {a}.
– Step 2: Use some systematic procedure (e.g. truth-
table method or truth-tree method) to test whether
the expansion is TF invalid. If it is TF invalid, then
stop: the FO argument is FO invalid. Otherwise,
expand FO argument in UD = {a,b}, and repeat step
2.
Incompleteness of
the Expansion Method
• We saw that the expansion method is not a test for
FO validity, but only for invalidity.
• However, even as such it is an incomplete test!
• Proof: Consider the following argument:
xy(xy ((x>y y>x) For any UD with an arbitrarily
(x>y y>x))) large yet finite number of objects,
xyz((x>y y>z) x>z) the expansion of this argument
xy(xy x>y) will be truth-functionally valid.
However, the argument is FO
invalid (consider the natural
numbers)!
A More Focused Search
• A further drawback of the expansion method is that
the search for a counterexample is very inefficient.
• A focused search for a counterexample is more
efficient:
– (for the invalid argument) I want there to be at least one
cube, and at least one small object, but no small cubes.
So, if we have a cube, a, then a cannot be small, so I
need a second object, b, which is small, but not a cube.
Counterexample, so the argument is invalid.
Advantage of a Focused Search
• The focused search method is like the indirect
truth-table method.
• Indeed, like the indirect truth-table method, the
focused search method can prove validity:
– (for the valid argument) I want there to be at least one
small cube. Let us call this small cube a. How, I don’t
want it to be true that there is at least one cube and at
least one small object. However, a is both a cube and
small. Contradiction, so I can’t generate a
counterexample.
Truth-Trees for Predicate Logic
• Like the direct method, the focused search
method needs to be systematized, especially
since the search often involves making
choices.
• Fortunately, the truth-tree method, which
systematized the indirect truth-table method
in truth-functional logic, can be extended
for predicate logic.
Truth-Tree Rules for Quantifiers
x (x) x (x)
x (x) x (x)
x (x) x (x)
(c) (c)
with ‘c’ a with ‘c’ any
new constant constant
in that branch
Truth-Tree Rules for Identity
(c)
aa
c = d (or d = c)
×
(d)
HM H M (R H) (D H)
M
Resolution Example (Cont’d)
{H}
From CNF to
clauses and resolve
{}
Inconsistent, so valid!
Soundness and Completeness of
Resolution
• The method of Resolution is sound and
complete with regard to truth-functional
consistency in the sense that:
– If the method finds a set of statements to be
inconsistent, then that set of statements is indeed
inconsistent (soundness).
– If a set of statements is inconsistent, then the
method can find that set of statements to be
inconsistent by deriving the empty clause
(completeness).
Algorithms for Resolution and
ATP’s
• Algorithms for resolution will differ in the
order in which clauses get resolved.
• Many ATP’s are based on resolution:
– Con mechanisms in Fitch
– Vampire (winner of world-wide ATP
competition last few years)
Prolog
Prolog
• The programming language Prolog is based on Horn
clauses.
• A Prolog program consists of 2 types of lines:
– Facts: Statements of the form P.
– Rules: Statements of the form (P1 … Pn) Q.
• A Prolog program is run by asking whether some
atomic statement Q follows from the facts and rules.
In Prolog: Q?
• The Prolog program will answer ‘Yes’ or ‘No’.
The Prolog Algorithm
• Prolog checks whether Q follows from the facts or
rules as follows:
– 1. Make a set of goals G, starting with Q.
– 2. If G is empty, stop with answer ‘Yes’.
– 3. If a statement P is in G that is a fact, remove P from G.
– 4. If P is in G and there is a rule P :- P1 , … , Pn, then
remove P from G, and add each Pi to G.
– 5. If you get stuck, try a different rule P :- P1 , … , Pn.
– 6. If all options fail, stop with answer ‘No’.
Prolog Example
Putting into Prolog: Query: R?
H H {R}
H E E :- H.
{E, M} {D, E}
H D D :- H.
(E M) R R :- E, M.
{H, M} {H, E}
(D E) R R :- D, E.
{M} {E}
{H}
{} ‘Yes’!
Power and Limitations of Prolog
• Prolog can only handle arguments whose
premises and conclusion are of the type as
discussed.
• So, many logic arguments cannot be
verified.
• However, because of the restriction, Prolog
becomes more efficient than general-
purpose provers.
Prolog and Production Rules
• Prolog’s rules are reminiscent of production
systems (bunch of if … then … statements).
• However, one big difference is:
– production systems are forward chaining
systems (start with given facts, apply rules to
proceed and get new stuff)
– Prolog is a backward chaining system (start
with the goal, and try and satisfy it, working
backwards)