# Knowledge Repn. & Reasoning Lec. #3: Consequence Finding & Prime Implicates/Implicants UIUC CS 498: Section EA Professor: Eyal Amir Fall Semester 2004.

## Presentation on theme: "Knowledge Repn. & Reasoning Lec. #3: Consequence Finding & Prime Implicates/Implicants UIUC CS 498: Section EA Professor: Eyal Amir Fall Semester 2004."— Presentation transcript:

Knowledge Repn. & Reasoning Lec. #3: Consequence Finding & Prime Implicates/Implicants UIUC CS 498: Section EA Professor: Eyal Amir Fall Semester 2004 Adapted from slides by Alexandre Klementiev

Prime implicants, prime implicates and consequence finding. Material from: A new algorithm for generating prime implicants [J.Slagle et al.]. An improved incremental algorithm for generating prime implicates [J. de Kleer]. A new method for consequence finding and compilation in restricted languages [del Val].

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.

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. –

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.

Outline of the rest of the talk Slagle et. al. (1970) –Generating prime implicants and implicates. –Finding minimal sum. de Kleer (1992) –Generating prime implicates. del Val (1999) –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 O S for S –

4. Build a “semantic tree”. Start with S as a root node. S For each literal in O S, sprout a node from S.... abcd For x i, create a set S i by deleting all clauses in S containing x i. S1S1 S = S 1 = –If S i = Ø – create terminal success node. –Else, delete x i from clauses in S i and all literals preceding x i in O S. –If S i contains an empty clause – create terminal failure node. –Else – create non-terminal node S i.

4. Build a “semantic tree”. S... abcd S1S1 S 11 S 12 S 13 bcd S 21 S 22 cd S 31 S 32 S 33 dad S 1 = S2S2 S 2 = S3S3 S 3 = S4S4 S 4 = S 311 d S 31 = x vvvvv xx v Start with S as a root node. For each literal in O S, sprout a node from S. For x i, create a set S i by deleting all clauses in S containing x i. –If S i = Ø – create terminal success node. –Else, delete x i from clauses in S i and all literals preceding x i in O S. –If S i contains an empty clause – create terminal failure node. –Else – create non-terminal node S i. S =

4. Build a “semantic tree”. S... abcd S1S1 S 11 S 12 S 13 bcd S 21 S 22 cd S 31 S 32 S 33 dad S2S2 S3S3 S4S4 S 311 d x vvvvv xx v W(S) = Start with S as a root node. For each literal in O S, sprout a node from S. For x i, create a set S i by deleting all clauses in S containing x i. –If S i = Ø – create terminal success node. –Else, delete from clauses in S i x i and all literals preceding x i in O S. –If S i contains an empty clause – create terminal failure node. –Else – create non-terminal node S i.

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)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.

Algorithm Details 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. S N

Algorithm Details: Iteration 2 S N Remove the next C = from S, add to N, and let Σ = {C}. For each literal x in C, create N x = clauses in N which resolve with x. Σ

Algorithm Details: Iteration 2 S N Σ For each literal x in C: Resolve each clause in Σ (which is still in N) with each clause in N x (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 Σ.

Algorithm Details: Iteration 3 S N Σ For each literal x in C: Resolve each clause in Σ (which is still in N) with each clause in N x (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 Σ. 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 dbdc ab Build a discrimination tree (trie). abaaba [[[[[[ bddbdd c ]]]] ] b+d a+d a+b+c

Subsumption: Checking dbd c ab 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+d a+d a+b+c subsumed by b + d

Subsumption: Addition dbd c ab Adding a new (not subsumed) clause x to the knowledge base is easy. x = a + b + d [ a b d ] b+d a+d d a+b+d a+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+d a+b+c a+d d b+d b 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. 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) ac skip or s(a+c) kernel or k(a+c) Write (a+c) as a[c] bd

Kernel Resolution In kernel resolution deductions every literal resolved upon is in its clause’s kernel.

Kernel Resolution: Example After C 10 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 L T  L (L T implicates). Consequence finding is the task of finding L T implicates.

Skip-filtered Kernel Resolution What about consequence finding ( finding implicates or restricted language L T ) ? Extension of kernel resolution. –Produce resolvent C only if skip(C)  L T. C is called L T – acceptable. –For any implicate of Δ in L T, we produce a logically stronger implicate. Need a strategy to find all deductions for L T.

Search Strategy: Bucket Elimination Associate buckets with each variable x i : b[x i ]. Each bucket contains clauses C k containing x i only if resolving C k upon x i can generate L T – acceptable clause. Process buckets in order x 1 … x n. –Compute all resolvents on x i for i th bucket. –L T – acceptable resolvents are added in corresponding buckets.

Search Strategy: Incremental Saturation Idea: take one clause at a time, process it until no more unsubsumed L T – 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 L T - 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]…

dcba→ 000000010011010001100111100110101011110111101111 bdP1P1 XXXX adP2P2 XXXX bcP3P3 XXXX abP4P4 XXXX acP5P5 XXXX acdP6P6 XX abdP7P7 XX bcdP8P8 XX 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 = (P 7 +P 8 )(P 5 +P 8 )(P 4 +P 5 )(P 6 +P 7 )(P 3 +P 6 )(P 3 +P 4 )(P 2 +P 5 )P 1 (P 1 +P 2 +P 4 +P 5 )P 2 (P 1 +P 3 )(P 1 +P 2 +P 3 +P 4 )

Minimal sum 1.Represent table as a product of factors. (P 7 +P 8 )(P 5 +P 8 )(P 4 +P 5 )(P 6 +P 7 )(P 3 +P 6 )(P 3 +P 4 )(P 2 +P 5 ) P 1 (P 1 +P 2 +P 4 +P 5 )P 2 (P 1 +P 3 )(P 1 +P 2 +P 3 +P 4 ) 2.Come up with ordering O R using heuristic. –E.g. lower weight (e.g. fewer literals) – earlier. 3.Use algorithm again to construct tree. –Each element of W(S R ) is a consistent table row set. –One of the elements corresponds to the minimal sum. –(P 1, P 2, P 3, P 5, P 7 ) or SRSR v vvvv v P1P1 P2P2 P3P3 P4P4 P5P5 P7P7 P8P8 P7P7 P6P6 P8P8 P4P4 P4P4 P8P8 P6P6 P6P6 P5P5 P8P8 P7P7 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 O S works, practically frequency ordering generates fewer non-primes.

Appendix A: Slagle for prime implicate generation back S... ab beeac a x vv x x v dc a x x x a

Download ppt "Knowledge Repn. & Reasoning Lec. #3: Consequence Finding & Prime Implicates/Implicants UIUC CS 498: Section EA Professor: Eyal Amir Fall Semester 2004."

Similar presentations