Title: Automated Theorem Proving
1Automated Theorem Proving
- Automated theorem provers are AI programs that
find proofs for theorems in various domains. This
has been one of the more successful parts of AI. - Thus far we have discussed searching a search
space having the structure of a graph, with the
arrows (directed edges) linking nodes
representing operations that move us from one
state in the space to another. - Theorem proving is naturally regarded as search a
hypergraph, where arrows connect sets of nodes
(the premises of the inference) to individual
nodes (the conclusion of the inference). A proof
is a path through the hypergraph. We can regard
the state spaces of the search space as sets of
conclusions. Traversing a proof takes us to
successively larger sets of conclusions. Our goal
is to be in a set of conclusions containing the
desired conclusion. - Alternatively, we might regard an argument as a
path through the hypergraph from some premises to
a conclusion. Our theorem-proving operations
(inference rules) can be regarded as operations
for extending arguments, making longer
arguments.We might then take the search space to
be the space of arguments, linked by inference
rules used in constructing them from shorter
arguments. This space has the structure of an
ordinary graph, and we can regard the problem of
finding a proof for a theorem as the problem of
finding a sequence of operations that takes us
from an empty argument to an argument whose
conclusion is the desired theorem. We can then
conceptualize theorem proving in terms of our
earlier algorithms for searching a state space.
2Automated Theorem Proving
- Regardless of whether we think of theorem proving
as a matter of searching the space (graph) of
arguments, or the hypergraph of conclusion-sets,
we are searching an infinite space. - In an infinite search space, we cannot
characterize our actions by giving an explicit
list of pairs of state spaces (S1,S2) such that
the action takes us from state S1 to state S2.
(This is what planning conditionals amount to.)
Instead, we must associate a LISP function with
an action. The function, when applied to an
initial state, returns the state we will be in as
a result of applying the action. - For example, in searching the space of arguments,
an inference rule is associated with a function
which, when applied to an argument, returns the
longer argument that results from adding a step
onto the end of the first argument using the
inference rule. - It is simple to modify the code for solve-problem
to make use of this generalized notion of an
action. Go back and look at the code and think
about how to do it.
3Resolution Refutation
- To illustrate automated theorem proving, we will
look at theorem proving in the propostional
calculus. - Most theorem provers in the propositional and
predicate calculi employ resolution-refutation as
their sole inference rule. Resolution-refutation
applies only to formulas in conjunctive normal
form. So we will - Briefly review the propositional calculus.
- Discuss conjunctive normal form.
- Discuss resolution-refutation.
4The Propositional Calculus
- (and, conjunction) v (or, disjunction)
(not,negation) -gt (if ... then, conditional)
lt-gt (if and only if, biconditional) - truth tables and assignments
- tautologies
- implications
- equivalences
- (p -gt q) eq. (p v q)
- (p lt-gt q) eq. ((p -gt q) (q -gt p))
- p eq. p
- (p q) eq. (p v q)
- (p v q) eq. (p q)
- (p v (q r)) eq. ((p v q) (p v r))
- ((q r) v p) eq. ((q v p) (r v p))
- (p (q v r)) eq. ((p q) v (p r))
- ((q v r) p) eq. ((q p) v (r p))
- (p p) eq. p (p v (q v r)) eq. ((p v q) v r)
- (p v p) eq. p (p (q r)) eq. ((p q) r)
5Pretty Formulas
- (p q) for ( p q)
- (p v q) for (v p q)
- p for ( p)
- (p -gt q) for (-gt p q)
- (p lt-gt q) for (lt-gt p q)
- functions pretty, reform, reform-if-string.
These are defined in Syntax.lisp, which requires
OSCAR-TOOLS.lisp.
6Conjunctive Normal Form
- Most automated theorem provers are based on
resolution refutation, which is an inference
procedure that only applies to formulas that have
been reduced to conjunctive normal form. - literals atomic formulas and negations of
atomic formulas - conjunctive normal form conjunction of
disjunctions of literals, or disjunction of
literals, or literal. - Theorem Every formula is equivalent to a
formula in conjunctive normal form. - disjunctive normal form disjunctions of
conjunctions of literals, or disjunction of
literals, or literal. - Convert to CNF
- eliminate-conditionals-and-biconditionals
- drive-negations-in
- distribute-disjunctions
- Formulas in conjunctive normal form can be
represented as lists of lists of literals.
7Conjunctive Normal Form
(defun eliminate-conditionals-and-biconditionals
(P) (cond ((not (listp P)) P)
((conditionalp P) (disj (neg
(eliminate-conditionals-and-biconditionals
(antecedent P)))
(eliminate-conditionals-and-biconditionals
(consequent P)))) ((biconditionalp
P) (conj (disj
(neg (eliminate-conditionals-and-biconditionals
(bicond1 P)))
(eliminate-conditionals-and-biconditionals
(bicond2 P))) (disj (neg
(eliminate-conditionals-and-biconditionals
(bicond2 P)))
(eliminate-conditionals-and-biconditionals
(bicond1 P))))) ((negationp P) (neg
(eliminate-conditionals-and-biconditionals
(negand P)))) ((conjunctionp P)
(conj (eliminate-conditionals-and-bico
nditionals (conjunct1 P))
(eliminate-conditionals-and-biconditionals
(conjunct2 P)))) ((disjunctionp P)
(disj (eliminate-conditionals-and-b
iconditionals (disjunct1 P))
(eliminate-conditionals-and-biconditionals
(disjunct2 P)))) ))
8Conjunctive Normal Form
- (eliminate-conditionals-and-biconditionals
- (reform "(p -gt (q -gt (p lt-gt ((q -gt
p) (p -gt q)))))")) - ( (v ( p) (v q ( (v ( p) ( ( (v ( q) p) (v
( p) q)))) (v ( (v ( q) p) (v ( p) q)) p))))) - This is hard to read. The pretty formula is
- (p v (q v ((p v ((q v p) (p v q)))
(((q v p) (p v q)) v p))))
9Conjunctive Normal Form
- This assumes conditionals and biconditionals
have been eliminated. - (defun drive-negations-in (P)
- (cond ((not (listp P)) P)
- ((negationp P)
- (let ((Q (negand P)))
- (cond ((not (listp Q)) (neg
Q)) - ((negationp Q)
(drive-negations-in (negand Q))) - ((conjunctionp Q)
- (disj
(drive-negations-in (neg (conjunct1 Q))) -
(drive-negations-in (neg (conjunct2 Q))))) - ((disjunctionp Q)
- (conj
(drive-negations-in (neg (disjunct1 Q))) -
(drive-negations-in (neg (disjunct2 Q)))))))) - ((conjunctionp P)
- (conj (drive-negations-in
(conjunct1 P)) - (drive-negations-in
(conjunct2 P)))) - ((disjunctionp P)
- (disj (drive-negations-in
(disjunct1 P)) - (drive-negations-in
(disjunct2 P))))))
10Conjunctive Normal Form
- This assumes negations and biconditionals have
been eliminated, and prints conversion process - (defun drive-negations-in (P optional indent)
- (when (eq indent t) (setf indent 0))
- (when indent (bar-indent indent) (princ P)
(terpri)) - (let ((conversion
- (cond ((not (listp P)) P)
- ((negationp P)
- (let ((Q (negand P)))
- (cond ((not (listp
Q)) (neg Q)) - ((negationp
Q) (drive-negations-in (negand Q) (if indent ( 5
indent)))) -
((conjunctionp Q) - (disj
(drive-negations-in (neg (conjunct1 Q)) (if
indent ( 5 indent))) -
(drive-negations-in (neg (conjunct2 Q)) (if
indent ( 5 indent))))) -
((disjunctionp Q) - (conj
(drive-negations-in (neg (disjunct1 Q)) (if
indent ( 5 indent))) -
(drive-negations-in (neg (disjunct2 Q)) (if
indent ( 5 indent)))))))) - ((conjunctionp P)
- (conj
(drive-negations-in (conjunct1 P) (if indent ( 5
indent))) -
(drive-negations-in (conjunct2 P) (if indent ( 5
indent)))))
Go to LISP
11Conjunctive Normal Form
- This converts formulas without conditionals
and biconditionals - and with negations driven-in to lists of lists of
literals. - (defun convert-to-CNF (P)
- (cond ((literal P) (list (list P)))
- ((conjunctionp P)
- (union (convert-to-CNF (conjunct1
P)) - (convert-to-CNF
(conjunct2 P)) test 'equal)) - ((disjunctionp P)
- (mapcar
- '(lambda (x) (union (first x)
(second x) test 'equal)) - (crossproduct (convert-to-CNF
(disjunct1 P)) -
(convert-to-CNF (disjunct2 P))))))) - Note that ((a v b) (c v d)) v ((e v f) (g
v h)) is equivalent to - ((a v b) v (e v f)) ((a v b) v (g v h)) ((c v
d) v (e v f)) ((c v d) v (g v h)). - (defun CNF (P)
- (convert-to-cnf
- (drive-negations-in (eliminate-conditionals-
and-biconditionals P))))
12Conjunctive Normal Form
- (defun convert-to-CNF (P optional indent)
- (when (eq indent t) (setf indent 0))
- (when indent (bar-indent indent) (princ P)
(terpri)) - (let ((conversion
- (cond ((literal P) (list (list P)))
- ((conjunctionp P)
- (union (convert-to-CNF
(conjunct1 P) (if indent ( 5 indent))) -
(convert-to-CNF (conjunct2 P) (if indent ( 5
indent))) test 'equal)) - ((disjunctionp P)
- (mapcar
- '(lambda (x) (union
(first x) (second x) test 'equal)) - (crossproduct
(convert-to-CNF (disjunct1 P) (if indent ( 5
indent))) -
(convert-to-CNF (disjunct2 P) (if indent ( 5
indent))))))))) - (when indent (bar-indent indent) (princ
conversion) (terpri)) - conversion))
- (defun CNF (P optional indent)
- (remove-duplicates
- (mapcar '(lambda (x) (order x 'lessp))
Go to LISP
13Conjunctive Normal Form
- We can simplify formulas in conjunctive normal
form by removing tautological disjunctions - (defun tautological-disjunction (P)
- (some '(lambda (x)
- (and (not (listp x))
- (some '(lambda (y)
-
(equal y (tilde x))) - P)))
- P))
- (defun remove-tautologies (P)
- (remove-if 'tautological-disjunction P))
- (defun CNF (P optional indent)
- (remove-duplicates
- (remove-tautologies
- (mapcar '(lambda (x) (order x 'lessp))
- (convert-to-cnf
- (drive-negations-in
14Conjunctive Normal Form
- We can simplify further by removing subsumed
disjunctions. - One disjunction subsumes another if every
disjunct of the first is a disjunct of the
second. - (defun subsumes (x y)
- (subsetp x y test 'equal))
- (defun remove-subsumed-disjunctions (P)
- (remove-if '(lambda (x)
- (some '(lambda (y)
- (and
(not (equal x y)) (subsumes y x))) P)) - P))
- (defun CNF (P optional indent)
- (remove-subsumed-disjunctions
- (remove-duplicates
- (remove-tautologies
- (mapcar '(lambda (x) (order x
'lessp)) - (convert-to-cnf
- (drive-negations-in
Go to LISP
15Conjunctive Normal Form
- (CNF (reform "(p -gt (q -gt (p lt-gt ((q -gt p)
(p -gt q)))))")) - ((p) (( q)) (p q) (p ( p)) (p q ( q)) (p ( p)
( q)) (q ( p) ( q)) (p q ( p)) (q ( p))) - ((p) (( q)) (p q) (q ( p)))
- ((p) (( q)) (q ( p)))
- Pretty-formulas (tautologies in red)
- ((p) (q) (p v q) (p v p) (p v q v q) (p v p v
q) (q v p v q) (p v q v p) (q v p)) - ((p) (q) (p v q) (q v p))
- ((p) (q) (q v p)) (p) subsumes (p
v q)
Go to LISP