Atp BW
Atp BW
Theorem Proving
Scott Sanner, Guest Lecture
Topics in Automated Reasoning
Thursday, Jan. 19, 2006
Introduction
1
Applications
• Proofs of Mathematical Conjectures
– Graph theory: Four color theorem
– Boolean algebra: Robbins conjecture
• Query Answering
– Build domain-specific knowledge bases,
use theorem proving to answer queries
• Inference:
– Search through space of valid inferences
• Output:
– Proof (if found, a sequence of steps
deriving conjecture consequence from
axioms and assumptions)
2
Many Logics / Many Theorem
Proving Techniques
Example of Propositional
Logic Sequent Proof
A ∨ ¬A ? (∨R2)
|- A∨¬A, A
(PR)
• Inference: |- A, A∨¬A
(∨R1)
– Gentzen |- A∨¬A, A∨¬A
Sequent (CR)
Calculus |- A∨¬A
3
Example of First-order Logic
Resolution Proof
• Given: • CNF:
¬Man(x) ∨ Mortal(x)
– Axioms: Man(Socrates)
∀x Man(x) ⇒ Mortal(x) ¬Mortal(y) [Neg. conj.]
Man(Socrates)
– Conjecture: • Proof:
∃y Mortal(y) ?
1. ¬Mortal(y) [Neg. conj.]
2. ¬Man(x) ∨ Mortal(x) [Given]
• Inference: 3. Man(Socrates) [Given]
4. Mortal(Socrates) [Res. 2,3]
– Refutation
5. ⊥ [Res. 1,4]
Resolution Contradiction ⇒ Conj. is true
• Given: • Proof:
Check unsatisfiability of
– Axioms: ∃Child.¬Male ∀ Child.Male
None
– Conjecture: x: ∃Child.¬Male ∀ Child.Male
¬∃
∃ Child.¬Male ⇒ x: ∀ Child.Male [ -rule ]
∀ Child.Male ? x: ∃Child.¬Male [ -rule ]
x: Child y [ ∃-rule ]
y: ¬Male [ ∃-rule ]
• Inference: y: Male [ ∀-rule ]
<CLASH>
– Tableaux
Contradiction ⇒ Conj. is true
4
Lecture Outline
• Common Definitions
– Soundness, completeness, decidability
5
Model-theoretic semantics
• Model-theoretic semantics for logics
– An interpretation is a truth assignment to atomic
elements of a KB: I〈C,D〉 = {〈F,F〉, 〈F,T〉, 〈T,F〉, 〈T,T〉}
– A model of a formula is an interpretation where
it is true: I〈C,D〉 = 〈F,T〉 models C∨
∨D,,C⇒
⇒D, but not C∧
∧D
– Two properties of a formula F w.r.t. axioms of KB:
• Validity: F is true in all models of KB
• Satisfiability: F is true in ≥1 model of KB
Models of KB
KB |= C C KB
⊆ Models of C
Soundness, Completeness,
and Decidability
6
Prop. Logic Syntax
• Propositional variables: p, rain, sunny
• Connectives: ⇒ ⇔ ¬ ∧ ∨
• Inductive definition of well-formed
formula (wff):
– Base: All propositional vars are wffs
– Inductive 1: If A is a wff then ¬A is a wff
– Inductive 2: If A and B are wffs then
A ∧ B, A ∨ B, A ⇒ B, A ⇔ B are wffs
• Examples:
– rain, rain ⇒ ¬ sunny
– (rain ⇒ ¬ sunny) ⇔ (sunny ⇒ ¬rain)
7
CNF Normalization
• Many prop. theorem proving techniques req.
KB to be in clausal normal form (CNF):
– Rewrite all C ⇔ D as C ⇒ D ∧ D ⇒ C
– Rewrite all C ⇒ D as ¬C ∨ D
– Push negation through connectives:
• Rewrite ¬(C ∧ D) as ¬C ∨ ¬D
• Rewrite ¬(C ∨ D) as ¬C ∧ ¬D
– Rewrite double negation ¬ ¬ C as C
– Now NNF, to get CNF, distribute ∨ over ∧:
• Rewrite (C ∧ D) ∨ E as (C ∨ E) ∧ (D ∨ E)
• A clause is a disj. of literals (pos/neg vars)
• Can express KB as conj. of a set of clauses
8
Prop. Theorem Proving
• A ⇒ B iff A ∧ ¬B is unsatisfiable
• Decision procedure for propositional
logic is decidable, but NP-complete
(reduction to 3-SAT)
• State-of-the-art prop. unsatisfiability
methods are DPLL-based
A Instantiate prop vars
true false
until all clauses falsified,
B B backtrack and do for all
true false true false instantiations ⇒ unsat!
A ∧ ¬ A β-Rule ¬B ∧ B β-Rule
A α-Rule ¬B α-Rule
¬A α-Rule B α-Rule
〈Clash〉〉 〈Clash〉〉
Note: Inverse method is inverse of tableaux - bottom up
9
Propositional Resolution
• One rule:
Rule: Example application:
A ∨ B ¬B ∨ C ¬precip ∨ ¬freezing ∨ snow ¬snow ∨ slippery
Resolution Strategies
Need strategies to restrict search:
– Unit resolution:
• Only resolve with unit clauses
• Complete for Horn KB
• Intuition: Decrease clause size
– Set of support:
• SOS starts with query clauses
• Only resolve SOS clauses with non-SOS clauses
and put resolvents in SOS
• Intuition: KB should be satisfiable so refutation
should derive from query
– Input resolution:
• At each step resolve only with input (KB or query)
• I.e., don’t resolve non-input clauses
• Linear input: also allow ancestor ⇒ complete
10
Ordering Strategies
• Refutation of a clause requires
refutation of all literals
• Enforce an ordering on proposition
elimination to restrict search
– Example order: p then r then q
– General idea behind Davis-Putnam (DP) &
directional resolution (Dechter & Rish)
11
First-order logic
• Refer to objects and relations b/w them
• Propositional logic requires all
relations to be propositionalized
– Scott-at-home, Scott-at-work,
Jim-at-subway, etc…
• Really want a compact relational form:
– at(Scott, home), at(Scott, work),
at(Jim, subway), etc…
• Then can use variables and quantify
over all objects:
– ∀x person(x) ⇒ ∃y at(x,y) ^ place(y)
12
First-order Logic Semantics
• Interpretation I = (∆
∆I,•I)
– ∆I is a non-empty domain
– •I maps from predicate symbols P of arity n
into a subset of ×1…n ∆I (where P is true)
• Example
– ∆I is {Scott, Jim}
– •I maps at(•,•) into { 〈Scott, loc(Scott)〉〉,
〈Jim,
Jim loc(Jim)〉〉 }
– All other ground predicates are false in I,
e.g. at(Scott, loc(Jim)), at(Scott, Scott)
• NB: FOL has ∞ interpretations/models!
13
Skolemization
• Skolemization is the process of getting rid
of all ∃ quantifiers from a formula while
preserving (un)satisfiability:
– If ∃x quantifier is the outermost quantifier,
remove the ∃ quantifier and substitute a new
constant for x
– If ∃x quantifier occurs inside of ∀ quantifiers,
remove the ∃ quantifier and substitute a new
function of all ∀ quantified variables for x
• Examples:
– Skolemize( ∃w ∃x ∀y ∀z P(w,x,y,z) ) =
∀y ∀z P(c,d,y,z)
– Skolemize( ∀w ∃x ∀y ∃z P(w,x,y,z) ) =
∀w ∀y P(w,f(w),y,f(x,y))
CNF Conversion
14
First-order Theorem Proving
• Tableaux methods
– Preferred for some types of reasoning and for
subsets of FOL (guarded fragment, set theory)
– Highly successful for description and modal
logics which conform to guarded fragment of FOL
• Resolution Methods
– Most successful technique for a variety of KBs
– But… search space grows very quickly
– Need a variety of optimizations in practice
• strategies, ordering, redundancy elimination
• FOL TP complete ☺, but semidecidable
– Will return in finite time if formula entailed
– May run forever if not entailed
First-order Tableaux
15
First-order Resolution
• Binary Resolution Rule
Rule: Example application:
C∨D ¬E ∨ F P(3)∨Q(f(x))∨R(y) ¬Q(y)
θ=MGU(D,E)
(C ∨ F)θ P(3) ∨ R(f(x))
• Factoring Rule
Rule: Example application:
C∨D∨E P(z) ∨ Q(3) ∨ Q(z)
θ=MGU(C,D)
Cθ ∨ E P(3) ∨ Q(3)
• Given: • CNF:
¬Man(x) ∨ Mortal(x)
– Axioms: Man(Socrates)
∀x Man(x) ⇒ Mortal(x) ¬Mortal(y) [Neg. conj.]
Man(Socrates)
– Conjecture: • Proof:
∃y Mortal(y) ?
1. ¬Mortal(y) [Neg. conj.]
2. ¬Man(x) ∨ Mortal(x) [Given]
• Inference: 3. Man(Socrates) [Given]
4. Mortal(Socrates) [Res. 2,3]
– Refutation
5. ⊥ [Res. 1,4]
Resolution Contradiction ⇒ Conj. is true
16
Importance of Factoring
• Without the factoring rule, binary
resolution is incomplete
• For example, take the following
refutable clause set:
– { A(w) v A(z), ~A(y) v ~A(z) }
Search Control
Additional refinements of prop strategies
yield goal-directed / bottom-up search:
– SLD Resolution
• KB of definite clauses (i.e. Horn rules), e.g.
Uncle(?x,?y) := Father(?x,?z) ∧ Brother(?x,?y)
• Resolution backward chains from goal of rules
• With negation-as-failure semantics, SLD-
resolution is logic programming, i.e. Prolog
– Negative and Positive Hyperresolution
• All negative (positive) literals in nucleus clause
are simultaneously resolved with completely
positive (negative) satellite clauses
• Positive hyperres yields backward chaining
• Negative hyperres yields forward chaining
17
Database-style Inference
• Naïve approaches to resolution perform one
inference per step
• For SLD or neg. hyperres and KBs w/ large
numbers of constants / functions, can store
clause terms and perform DB-like res, e.g.
– CNF KB = { R(a,b), R(b,a), R(b,c), R(c,b),
¬R(x,y) ∨ ¬R(y,z) ∨ R(x,z) }
– Use DB join/project during SLD or neg. hyperres:
R(x,y) R(y,z) R(x,z)
{ 〈a,b〉〉, 〈b,a〉〉,
〈b,c〉〉, 〈c,b〉〉 }
× { 〈a,b〉〉, 〈b,a〉〉,
〈b,c〉〉, 〈c,b〉〉 }
⇒ { 〈a,a〉〉, 〈a,c〉〉, 〈b,b〉〉,
〈c,c〉〉, 〈c,a〉〉, 〈c,c〉〉 }
Term Indexing
• Term indexing is another general technique
for fast retrieval of sets of terms / clauses
matching criteria
• Common uses in modern theorem provers:
– Term q is unifiable with term t, i.e., ∃θ s.t. qθ = tθ
– Term t is an instance of q, i.e., ∃θ s.t. qθ = t
– Term t is a generalization of q, i.e., ∃θ s.t. q = tθ
– Clause q subsumes clause t, i.e., ∃θ s.t. qθ ⊆t
– Clause q is subsumed by clause t, i.e., ∃θ s.t. tθ ⊆q
• Techniques: (Google for “term indexing”)
– Path indexing
– Code, context, & discrimination trees
18
Age-weight Ratio
• During a resolution strategy, have two sets:
– Active: Set of active clauses for resolving with
– Frontier: Candidate clauses to resolve with Active
Redundancy Control
• Redundancy of clauses is a huge problem in
FOL resolution
– For clauses C & D, C is redundant if ∃θ s.t. Cθ
θ⊆D
as a multiset, a.k.a. θ-subsumption
– If true, D is redundant and can be removed
• Intuition: If D used in a refutation, Cθ
θ could be
substituted leading to even shorter refutation
19
Saturation Theorem Proving
Simplification Orderings
For complete ordered resolution in FOL,
must use term simplification orderings:
– Well-founded (Noetherian): If there is no
infinitely decreasing chain of terms s.t.
t0 t1 t2 … t∞
– Monotonic: If s t then f[[s]] f [t]] (f[[s]] and
f[[t]] are identical except for [term]])
– Stable under Subst.: If s t then sθ tθ
20
Literal Ordering & Selection
21
Clause Orderings & Redundancy
Equality
• A predicate w/ special interpretation
• Could axiomatize:
– x=x (reflexive)
– x=y ⇒ y=x (symmetric)
– x=y ∧ y=z ⇒ x=z (transitive)
– For each function f:
• x1=y1 ∧ … ∧ xn=yn ⇒ f(x1,…,xn)=f(y1,…,yn)
– For each predicate P:
• x1=y1 ∧ … ∧ xn=yn ∧ P(x1,…,xn) ⇒ P(y1,…,yn)
• Too many axioms… better to reason
about equality in inference rules
22
Inference
Rules for Equality
• Demodulation (incomplete)
Rule: Literal containing z Example application:
x=y L[z] ∨ D x=f(x) P(3) ∨ Q
θ=MGU(x,z) θ={x/3}
L[yθ] ∨ D P(f(3)) ∨ Q
• Paramodulation (complete)
Rule: Literal containing z Example application:
x=y ∨ C L[z] ∨ D x=f(x)∨C P(3)∨Q
θ=MGU(x,z) θ={x/3}
(L[y] ∨ C ∨ D)θ P(f(3))∨C∨Q
Equational Programming
• Used extensively for algebraic group
theory proofs
• All axioms and conjectures are unit
equality predicates with arithmetic
functions on the LHS and RHS, e.g.
– a*(x+y) = a*x+a*y ?
23
First-order theorem
proving software
Many highly optimized first-order
theorem proving implementations:
– Vampire (1st place for many years in
CADE TP competition)
– Otter (Foundation for modern TP, still
very good, usually 2nd place in CADE)
– SPASS (Specialized for sort reasoning)
– SETHEO (Connection tableaux calculus)
– EQP (Equational theorem proving
system, proved Robbins conjecture)
First-order TP Progress
• Ever since the 1970s I at various times investigated
using automated theorem-proving systems. But it
always seemed that extensive human input--typically
from the creators of the system--was needed to make
such systems actually find non-trivial proofs.
• In the late 1990s, however, I decided to try the latest
systems and was surprised to find that some of them
could routinely produce proofs hundreds of steps long
with little or no guidance. … the overall ability to do
proofs--at least in pure operator systems--seemed vastly
to exceed that of any human.
--Steven Wolfram, “A New Kind of Science”
24
On the other hand…
• Success of modern theorem provers
relies largely on heuristic tuning
• Input KBs are analyzed for properties
which determine strategies and
various parameters of inference
• Still an art as much as a science,
much room for more principled tuning
of parameters, e.g.
– Automatic partitioning of KBs to induce
good literal orderings (McIlraith and Amir)
Gödel’s Incompleteness
Theorem
• FOL inference is complete (Gödel)
• So what is Gödel’s incompleteness
theorem (GIT) about?
• GIT: Inference in FOL with arithmetic
(+,*,exp) is incomplete b/c set of
axioms for arithmetic is not
recursively enumerable.
• Read: Inference rules are sound and
complete, but no way to generate all
axioms required for arithmetic!
25
Modal Logic
• Logic of knowledge and/or belief, e.g.
– English: Scott knows that you know that Scott
knows this lecture is boring
– Modal Logic Kn (n agents): KScottKyouKScott LIB
Temporal Logic
• A modal logic where the possible
worlds are linked by time:
– LTL: Linear temporal logic w1 w2 w3
• World states evolve
deterministically w4
• State can involve action w2
w5
– CTL: Computation tree logic w1
w6
• World states can evolve w3
non-deterministically
w7
• Temporal operators specify
conditions on world evolution
• Used for verification, safety checks
26
LTL Temporal Operators
• G f: always f f f f f f f
• F f: eventually f f f
• X f: next state Xf f
• f U r: until f f f f r
• f R r: releases r r r r,f
27
Description Logic
28
Example of Description Logic
Tableaux Proof
• Given: • Proof:
Check unsatisfiability of
– Axioms: ∃Child.¬Male ∀ Child.Male
None
– Conjecture: x: ∃Child.¬Male ∀ Child.Male
¬∃
∃ Child.¬Male ⇒ x: ∀ Child.Male [ -rule ]
∀ Child.Male ? x: ∃Child.¬Male [ -rule ]
x: Child y [ ∃-rule ]
y: ¬Male [ ∃-rule ]
• Inference: y: Male [ ∀-rule ]
<CLASH>
– Tableaux
Contradiction ⇒ Conj. is true
DL Reasoner
Output (FaCT++)
Taxonomy encodes all ⇒ relations
29
Modal, Verification, and
DL Inference Software
• Modal logic
– MSPASS (converts modal formula to FOL)
– By correspondence, also DL reasoners
• Verification (temporal and non-temporal)
– PVS (interactive TP for HW/SW verification)
– ALLOY (first-order HW/SW model checker)
– NuSMV (BDD-based LTL/CTL HW/SW verif.)
• DL Reasoning
– Classic (limited DL, poly-time inference)
– Racer (expressive DL, highly optimized)
– FaCT++ (very expr. DL, highly optimized)
Repositories of TP Problems
30
Concluding Thoughts
• Many logics, inference techniques,
and computational guarantees
• Have to balance expressivity and
computational tradeoffs with task-
specific needs (Brachman & Levesque, 1985)
• Woods (1987): Don’t blame the tool!
– A poor craftsman blames the tool when
their efforts fail
– An experienced craftsman uses the right
tool for the job
31