You are on page 1of 32

Artificial Intelligence

Automated Reasoning
Lecture 5

Introduction to Otter
Lets create an input file pets.txt to allow Otter to solve the problem from the in-class assignment. After we get started we can use this as our solution.

Introduction to Otter
Otter is an automated reasoning program that was developed by Argonne National Laboratory. Otter is installed on shell.mathcs.bethel.edu It reads input clauses from standard input then goes about trying to find a contradiction (by deducing the empty clause). The basic command syntax is [mathcs]$ otter < myclauses.txt
3

Introduction to Otter
The most basic Otter input file has three sections: Settings, Usable List, and Set of Support Settings Section
Determines how Otter will operate, for instance, placing set(binary_res). into this section tells Otter to use binary resolution as one of its deduction methods.
4

Introduction to Otter

Usable List
This is the set of clauses that form the general theory of whatever you are trying to work on. For instance with equivalence classes, it is a set of three clauses giving the general properties of equivalence classes: symmetry, transitivity, reflexivity. The section begins with list(usable). and ends with end_of_list. 5

Introduction to Otter

Set of Support
This section contains the special hypotheses of whatever you are trying to prove. It also contains the denial of goal that must be included in order to make the set of sentences inconsistent so that Otter can find a contradiction. This section begins with list(sos). and ends with end_of_list.
6

Unification
Humans prove theorems differently from computers. One important way humans prove theorems is by making clever substitutions for variables in an identity. Computers make bad substitutions since they are not clever and dont know what substitution would likely produce a useful next step in a proof. Instead, AR programs do substitution through unification. 7

Unification
Substitution: Given a clause C with variable x, then we can deduce a new clause C by replacing every occurrence of x with a term t. Example: From
P(x,y) | -Q(f(d,x)). we can conclude P(c,y) | -Q(f(d,c)). using the substitution cgx

Unification
Example: From
P(x,y) | -Q(f(d,x)). we can also conclude P(y,y) | -Q(f(d,y)). using the substitution ygx

Substitution will allow us create clauses that can be combined using binary resolution.
9

Unification
Example: Suppose we have clauses
U(x) | -Q(f(d,x)). -U(d).

We cannot apply binary resolution since we dont have literals of the form A and A. However, using a substitution we can unify the literal U(x) in the first clause with the literal U(d) in the second clause.
10

Unification
Using the substitution: dgx in the first clause we get
U(d) | -Q(f(d,d)). -U(d).

This unification allows us to apply binary resolution to the unified pair of literals to conclude -Q(f(d,d)). Sometimes, multiple variable substitutions are needed to complete a unification. 11

Unification
Example: Unify two literals in the clauses below and then apply binary resolution
U(x,y) | -Q(x, f(c)) | P(y). Q(d,z).

The substitution dgx in the first clause and f(c)gz in the second clause gives
U(d,y) | -Q(d, f(c)) | P(y). Q(d,f(c)). from which we conclude U(d,y) | P(y).

12

Unification
Sometimes the same variable letter appears in two clauses as in
U(x) | -P(c,f(d)). -U(x).

It may look as though the literals U(x) and U(x) are already unified, but they are not as these are two different instances of x.

13

Unification
This can get confusing if we need to substitute variables in for variables as in
-R(x,y) | Q(z). -Q(x).

In this case, making the substitution zgx could be confusing since each clause has a variable named x. As a result, before unifying two clauses, we will always rename the variables so that there are no duplicate names. 14

Unification
So our complete unification/resolution procedure would look like this. From
-R(x,y) | Q(z). -Q(x). we get -R(x,y) | Q(z). -Q(w). by renaming x in the second clause to w.
15

Unification
Now zgw produces the unified
-R(x,y) | Q(z). -Q(z). and binary resolution gives the new clause -R(x,y).

16

Unification
Exercise: Use our complete resolution procedure to draw a conclusion from
P(x) | -U(y,f(x)) | L(d,y). U(f(x),y).

Answer: First we rename variables to get


P(x) | -U(y,f(x)) | L(d,y). U(f(v),w).
17

Unification
The substitution f(v)gy gives
P(x) | -U(f(v),f(x)) | L(d,f(v)). U(f(v),w).

The substitution f(x)gw gives


P(x) | -U(f(v),f(x)) | L(d,f(v)). U(f(v),f(x)).

We now apply binary resolution to conclude


P(x) | L(d,f(v)).
18

Unification
Consider the two clauses
U(c,f(d)) | -P(y). Q(x) | -U(c,f(d)) | -P(y).

No other literals are unified. Why are the last two literals of the clauses not considered to be unified? The formal unification procedure is stated as follows
19

Unification
When unifying literals La in clause A with literal Lb in clause B
1. We form B from B by rewriting variables as needed so that A and B do not have any variables with the same name. 2. We substitute terms for variables as needed to form the clauses A and B with literals La and Lb as the exact same sequence of symbols (except possibly different signs).
20

Unification
Returning to the clauses
U(c,f(d)) | -P(y). Q(x) | -U(c,f(d)) | -P(y).

We rewrite the y as w so that we have


U(c,f(d)) | -P(y). Q(x) | -U(c,f(d)) | -P(w).

We then make the substitution ygw to form


U(c,f(d)) | -P(y). Q(x) | -U(c,f(d)) | -P(y). whence the final two literals are unified.
21

Unification
Unification is a fundamental operation: Most AR techniques start with a unification of literals between two or more clauses.

22

Unification
There may be several unifications possible between two clauses. In
-P(x, f(c)) | Q(x). P(w, z). we can unify with xgw and f(c)gz to get -P(x, f(c)) | Q(x). P(x, f(c)). or with cgw, cgx and f(c)gz to get -P(c, f(c)) | Q(c). P(c, f(c)).
23

Unification
Note that binary resolution allows us to conclude either Q(x) or Q(c) from these two different unifications. Do we need both of these conclusions? No, if we have Q(x), then we can conclude Q(c). We cannot conclude Q(x) from Q(c), however.
24

Unification
So we want the unification that produces Q(x). We will always want to use the most general unification possible which usually means
making as few substitutions as possible preferring to substitute, if possible, variables in for terms involving variables (so as to retain variables in the unified clauses)
25

Unification
A strange problem can cause unification to fail. See what it is in the following clauses.
-P(x, f(x)) | Q(y, x). P(f(x), x).

This is called an occurs check failure. It happens whenever we attempt to substitute into a variable v with a term that contains v.
26

Unification
In some cases, we may only want to unify two terms instead of two literals. Exercise: What is the most general unification possible between two terms in these unit clauses?
EQUAL(sum(x, minus(x)), 0). EQUAL(sum(w, sum(minus(w), y)), y).

27

Binary Resolution
In our earlier examples, we only looked at binary resolution where one clause was a unit clause, as in this example.
From -R(x) | P(x,y) | -Q(f(c)). And -P(x,y) . conclude -R(x) | -Q(f(c)). as the resolvant.

Here is the general definition of binary resolution that applies to non-unit clauses as well. 28

Binary Resolution
Binary Resolution: Given a clause A containing a literal L and a clause B containing a literal K, if there is a substitution for variables in A and B that produces A and B and so that the resulting literals L and K are identical but with opposite signs, then we can form a new clause C by canceling L and K and taking the disjunction of the remaining clauses.

29

Binary Resolution

Example: from
Male(x) | Female(x). -Male(x) | -Parent(x,y) | Father(x,y).

We deduce
Female(x) | -Parent(x,y) | Father(x,y).

30

Binary Resolution

Example: from
Male(x) | Female(x). -Female(tom).

We unify to get
Male(tom) | Female(tom). -Female(tom).

And we deduce
Male(tom).

This also shows that binary resolution is a more general form of Modus Ponens.

31

Binary Resolution
Note that binary resolution can produce a clause longer than the two parent clauses as in
P(c) | -Q(d) | R(c) | U(t). -P(c) | T(d) | -U(d). yields -Q(d) | R(c) | U(t) | T(d) | -U(d).

This can be viewed in some respects as an undesirable property. Why?


32

You might also like