knowledge repn. & reasoning lec. #3: consequence finding & prime implicates/implicants uiuc...
TRANSCRIPT
Knowledge Repn. & ReasoningLec. #3: Consequence Finding &
Prime Implicates/ImplicantsUIUC CS 498: Section EA
Professor: Eyal AmirFall Semester 2004
Adapted from slides by Alexandre Klementiev
So Far & Today
• So far: resolution theorem proving
• Today:– Prime implicates, prime implicants– Consequence finding– Slagle’s algorithm (semantic tree)– de Kleer/Tison’s algorithm (resolution variant)– del Val’s algorithm (kernel resolution)
Prime Implicants and Implicates
• Prime implicant α of a formula φ is a conjunction of literals s.t. α |= φ, but deprived of a literal α |≠ φ.
–
• Prime implicate β of a formula φ is a clause s.t. φ |= β and there is no other implicate β’ s.t. β’ |= β.
–
• Thm: Prop. formulae are equivalent iff they have the same set of prime implicates/implicants.
)cabab(a ofimplicant prime a is )c(b
)cabab(a of implicate prime a is b)(a
Prime Implicants and Implicates: Motivation
• Represent φ by disjunction of all its prime implicants (or conjunction of all prime implicates)– Define simplifying φ as finding the simplest equivalent in
some unique normal form.
• Inference from primes is simple• Reduce prop. formula φ to simplest equivalent.
– Many applications: digital circuits, knowledge state
• However, we may not need all prime implicants.–
.ca and ,ba,ba ,cb :implicants prime 4 has )cabab(a
Prime Implicants and Implicates: Computational Objective
• Generate the set of all prime implicates/implicants of φ.– Known to be NP-complete, but we can do much better than
brute force.
• If φ if redundant - get rid of unnecessary prime implicates/implicants.
Consequence Finding: Motivation and Objective
• Given a knowledge base Δ, derive a set of formulas logically implied by Δ.
• May want to derive some subset of the set of all implicates of Δ.– Provide restrictions to guide the search.
• Such task is called consequence finding.
Approach I: Prime Implicants (Slagle et. al. 1970)
1. Start with φ in CNF.
–
2. Remove tautologies. Call new set S.
–
3. Choose literal ordering OS for S
–
)dcb)(adcbd)(acbad)(cb(a
)}dcb(a),dcb(ad),cba(d),cb{(aS
b,a,d,cd,c,b,a,
4. Build a “semantic tree”.• Start with S as a root node.
S
• For each literal in OS, sprout a node from S.
. . .a b c d
d)}cba{(
• For xi, create a set Si by deleting all clauses in S containing xi.
S1
)}dcb(a
),dcb(a
d),cba(
d),cb{(a
S =
S1 = d)}c{(b
– If Si = Ø – create terminal success node.
– Else, delete xi from clauses in Si
and all literals preceding xi in OS.
– If Si contains an empty clause – create terminal failure node.
– Else – create non-terminal node Si.
4. Build a “semantic tree”.S
. . .a b c d
S1
S11 S12 S13
b c d
S21 S22
c d
S31 S32 S33
da d
S1 = d)}c{(b
S2
S2 = d)}{(c
S3
S3 = )}d(d),a{(
S4
S4 = {Ø}
S311
d
S31 = )}d{(
x
v v v v v x x
v
• Start with S as a root node.
• For each literal in OS, sprout a node from S.
• For xi, create a set Si by deleting all clauses in S containing xi.
– If Si = Ø – create terminal success node.
– Else, delete xi from clauses in Si
and all literals preceding xi in OS.
– If Si contains an empty clause – create terminal failure node.
– Else – create non-terminal node Si.
)}dcb(a
),dcb(a
d),cba(
d),cb{(a
S =
4. Build a “semantic tree”.S
. . .a b c d
S1
S11 S12 S13
b c d
S21 S22
c d
S31 S32 S33
da d
S2 S3 S4
S311
d
x
v v v v v x x
v
W(S) = ,...}dcabd, bc, ad,,ca{ab,
• Start with S as a root node.
• For each literal in OS, sprout a node from S.
• For xi, create a set Si by deleting all clauses in S containing xi.
– If Si = Ø – create terminal success node.
– Else, delete from clauses in Si xi and all literals preceding xi in OS.
– If Si contains an empty clause – create terminal failure node.
– Else – create non-terminal node Si.
Theoretical Properties
• Thm (why?):– W(S) is the set of prime implicants of S
• A symmetric algorithm can be used to obtain prime implicates if φ is in DNF (A)
– We don’t need that, though… (why?)
• May still be interested in finding the minimal sum.– Can use the algorithm again…
Approach II: Prime Implicates via Resolution
• Some resolution strategies are refutation complete, others in consequence finding.
• Deduction complete resolution strategies will find all prime implicates of formula φ in CNF.– [Tison, de Kleer, etc.]: use deduction complete
resolution to generate prime implicates of φ.
Approach II: Prime Implicates via Resolution
Brute force attempt:
• Start with Δ in clausal form.
• Repeatedly resolve pairs of clauses of Δ.– Add the result of resolution back to Δ, while
removing all subsumed clauses.
Improving Efficiency: Tison’s Method (order propositions)• Many redundant resolutions.
– E.g. for 3 resolvable clauses α, β, γ there are 3 ways to resolve r(α, r(β, γ)), r(r(α, β), γ), and r(r(α, γ), β).
– Number of ways to derive result grows quickly.
• Key idea [Tison]: place ordering on symbols, and iterate over these symbols in order.– Once all resolutions for a symbol are done, it is never
necessary to resolve with respect to that symbol even for new resolution results produced later.
Improving Efficiency : Tison’s Method (order propositions)
Consider 3 clauses:
and order literals: a, b, c.
d)c( c),b( b),(a
b)(a c)b( d)c(
c)(a d)b(
d)(a d)(a
Algorithm Details
b)(a c)b( d)c(
• S is the current set of clauses, and N is the current set of prime implicates.
• Gist: Pick one clause (C) at a time from S, and for every literal in C (in order) resolve with N. Add new clauses to N.
SN
Algorithm Details: Iteration 2
c)b( d)c(
SNb)(a
• Remove the next C = from S, add to N, and let Σ = {C}.c)b(
• For each literal x in C, create Nx = clauses in N which resolve with x.
b)}{(aNb
{}Nc
Σ
c)b(
c)b(
Algorithm Details: Iteration 2
d)c(
SNb)(a
b)}{(aNb
{}Nc
Σ
c)b(
c)b(
• For each literal x in C:• Resolve each clause in Σ (which is still in N) with each clause in
Nx (which is still in N).
• For every new clause, discard it if it is subsumed by N U S, or remove any clauses it subsumes from N U S. Add it to N and Σ.
c)(a
c)(a
Algorithm Details: Iteration 3
SNb)(a
c)}(ac),b{(Nc
{}Nd
Σ
c)b(
• For each literal x in C:• Resolve each clause in Σ (which is still in N) with each clause in
Nx (which is still in N).
• For every new clause, discard it if it is subsumed by N U S, or remove any clauses it subsumes from N U S. Add it to N and Σ.
c)(a
d)c( d)c(
d)b( d)(a
d)b( d)(a
d)c(
Considers literals in order avoiding many redundant resolution steps
Subsumption
• This algorithm (and many others) uses subsumption checking heavily.
• For clauses subsumption check is a subset check.– e.g. a+b subsumes a+b+c
• However, de Kleer can do better.
Subsumption
For our algorithm, we are interested in three operations:
1. Check if clause x is subsumed by some clause in the Δ.
2. Add clause x to the Δ.
3. Remove all clauses from Δ which are subsumed by x.
Subsumption: Representation
• Order literals, turn clauses into lists of literals according to the chosen order.
c+b+a
d+b
a+d
Choose order : a,b,c,d
db d
c
a b
• Build a discrimination tree (trie).
a
b
a
[
[
[
b
d
d
c
]
]
]
b+da+d
a+b+c
Subsumption: Checking
db d
c
a b
Checking if clause x is subsumed by some clause in Δ can be done in one go.
x = c + b + d
[ b c d ]v
b+da+d
a+b+c
subsumed by b + d
Subsumption: Addition
db d
c
a b
Adding a new (not subsumed) clause x to the knowledge base is easy.
x = a + b + d
[ a b d ]
b+da+dd
a+b+da+b+c
Subsumption: Deletion
b
c
a b
To remove clauses subsumed by clause x - search trie in left-to-right depth-first fashion removing all clauses containing x.
x = b+d
[ d ]d
a+b+da+b+c
a+d
d
b+db
d
Summary So Far: Prime Implicates via Resolution (de Kleer’s + Tison)
• Part 1: Existing [Tison] idea for reducing unnecessary resolutions.
• Part 2: New idea: more efficient subsumption using the trie representation.
Improvement III: Kernel Resolution (del Val 1999)
• Recall Tison’s approach: ordered literals – fewer resolutions.
and order: a, b, c.d)c( c),b( b),(a
b)(a c)b( d)c(
d)b(
d)(a
• Idea: any clause C can be resolved only upon literals (kernel of C) appearing later in the ordering then literal used to obtain C.
(a + c)
a c
skip or s(a+c)
kernel or k(a+c)
Write (a+c) as a[c]
b d
Kernel Resolution
In kernel resolution deductions every literal resolved upon is in its clause’s kernel.
Kernel Resolution: Example
[d]
a[d]
[d]b
[cd]
a[c]
[bd]
c),C,Resolve(C
c),C,Resolve(C
c),C,Resolve(C
b),C,Resolve(C
b),C,Resolve(C
a),C,Resolve(C
(d)C
d)(aC
d)b(C
d)(cC
c)(aC
d)(bC
d]c[
d]a[
c]b[
[ab]
d)c(C
d)a(C
c)b(C
b)(aC
74
64
42
52
21
31
10
9
8
7
6
5
4
3
2
1
After C10 clauses containing d are deleted (subsumed).
Limited Languages (del Val 1999)
• A clausal knowledge base Δ is written over some clausal language L.
• We may be interested in all implicates of Δ or only those that belong to some LT L (LT implicates).
• Consequence finding is the task of finding LT implicates.
Skip-filtered Kernel Resolution
• What about consequence finding (finding implicates or restricted language LT)?
• Extension of kernel resolution.– Produce resolvent C only if skip(C) LT. C is
called LT – acceptable.– For any implicate of Δ in LT, we produce a
logically stronger implicate.
• Need a strategy to find all deductions for LT.
Search Strategy: Bucket Elimination
• Associate buckets with each variable xi: b[xi].
• Each bucket contains clauses Ck containing xi only if resolving Ck upon xi can generate LT – acceptable clause.
• Process buckets in order x1… xn.
– Compute all resolvents on xi for ith bucket.
– LT – acceptable resolvents are added in corresponding buckets.
Search Strategy: Incremental Saturation
• Idea: take one clause at a time, process it until no more unsubsumed LT – acceptable resolvents can be generated.
• Two sets of buckets: active and passive.– Put Δ into passive buckets.– For each clause of Δ
• Put in active buckets, use BE (over active/passive)
• When done, dump active buckets into passive.
del Val: Summary
• Extended the Tison’s approach to consequence finding.
• Approach is agnostic to search strategy of of LT-acceptable deductions.– Two search strategies (BE and IS) suggested.
– IS may be preferred if Δ grows.
•END
Minimal sum
• How do we find the minimum sum?
• Back to example: W(S) =
• Put it in a table [McCluskey, 1956]…
}dcb,dba,dac,caab,bc,ad,{bd,
dcba→ 0000 0001 0011 0100 0110 0111 1001 1010 1011 1101 1110 1111
bd P1 X X X X
ad P2 X X X X
bc P3 X X X X
ab P4 X X X X
ac P5 X X X X
acd P6 X X
abd P7 X X
bcd P8 X X
• McCluskey: Select the fewest rows such that each column has at least one cross in each selected row.
• Slagle: Use the “semantic tree” algorithm again. First, represent table as a product of factors:
– R = (P7+P8)(P5+P8)(P4+P5)(P6+P7)(P3+P6)(P3+P4)(P2+P5)P1
(P1+P2+P4+P5)P2(P1+P3)(P1+P2+P3+P4)
Minimal sum1. Represent table as a product of factors.
(P7+P8)(P5+P8)(P4+P5)(P6+P7)(P3+P6)(P3+P4)(P2+P5)
P1(P1+P2+P4+P5)P2(P1+P3)(P1+P2+P3+P4)
2. Come up with ordering OR using heuristic.
– E.g. lower weight (e.g. fewer literals) – earlier.
3. Use algorithm again to construct tree.
– Each element of W(SR) is a consistent table row set.
– One of the elements corresponds to the minimal sum.
– (P1, P2, P3, P5, P7) or dbacabcad bd
SR
v
v v v v
v
P1
P2
P3 P4
P5P7 P8
P7 P6
P8
P4 P4
P8 P6
P6
P5 P8
P7
only success nodes shown
Slagle: Summary / Remarks
• An algorithm to compute all prime + some non-prime implicates.
• Use subsumption to get rid of non-primes.
• A heuristic attempt to find minimal sum.
• Any ordering OS works, practically frequency ordering generates fewer non-primes.
Appendix A: Slagle for prime implicate generation
back
S
. . .ab
b ee ac
a
x
v v x
x
v
d c
axx x
a
)d c b(
)d c (b
)d a(
)d c (a
)e b (a
e) d b (a