Encoding CNFs to Enhance Component Analysis Mark Chavira, Adnan Darwiche Computer Science Department University of California, Los Angeles Work With Goal: ***CLASS*** and ***MODEL COUNTING AND KNOWLEDGE COMPILATION*** Do that by applying a restricted form of resolution on the input which takes the form of a CNF Based on observation that syntax can cripple …
Outline Review “search with decomposition” The effect of syntax Preliminary strategy for circuits Generalization of strategy for Bayesian nets
Search with Decomposition CNF A B C A B C A D E A D E 18 A B C D E A B C D E 9 Review SWD Given CNF and Goal Overall Strategy Sometimes for Free In this case Different in important way Trace Main Point D E B C decompose D E B C 3
Syntax Example Syntax 1 A ^ B ^ C => D A ^ B ^ C => D Goal / Algorithm only does this when… / Syntax Critical / Demonstrate Describe Fragments Ought to… Two encodings What happens when we split on A=false Syntax 2 A ^ B ^ C => D A => D B => D C => D A B ^ C => D B ^ C => D B ^ C => D B ^ C => D A D
Syntax Experiments Using Cachet Circuit Syntax 1 Syntax 2 Improv. R.S. 1 s1238 7.48 0.99 7.59 1.03 7.29 s713 4.66 0.5 9.37 0.4 11.61 s526n 2.28 0.18 12.73 12.32 s1196 11.89 0.93 12.81 0.97 12.29 s526 2.27 12.82 12.61 s953 5.34 0.34 15.48 0.33 16.13 s641 5.2 0.32 16.3 15.67 s1488 2.78 0.13 21.24 s1494 2.89 22.43 22.25 s832 3.15 0.1 31.21 0.11 29.19 s838.1 2.95 0.08 38.8 s1423 - 63.78 49.94 s13207.1 186.61 199.49 S35932 2.83 3.09 On this slide Rows What did Columns Main point
Syntactic vs. Semantic Independence CNFs and are syntactically independent iff and do not share variables. CNFs and are semantically independent iff there exist two CNFs ’ and ’ such that ’ is logically equivalent to ’ is logically equivalent to ’ and ’ do not share variables Definitions When we have… Gap Goal
Resolution Strategy 1 … v v X v ¬X … v v ¬X General Idea Simple operation any time Bullets Effectively a restricted form of resolution. Always make some clause smaller We never increase the number of clauses in the CNF. Transforms syntax 1’s encoding of AND gate into syntax 2’s encoding.
The Effect of Syntax Circuit Syntax 1 Syntax 2 Improv. RS 1 s1238 7.48 0.99 7.59 1.03 7.29 s713 4.66 0.5 9.37 0.4 11.61 s526n 2.28 0.18 12.73 12.32 s1196 11.89 0.93 12.81 0.97 12.29 s526 2.27 12.82 12.61 s953 5.34 0.34 15.48 0.33 16.13 s641 5.2 0.32 16.3 15.67 s1488 2.78 0.13 21.24 s1494 2.89 22.43 22.25 s832 3.15 0.1 31.21 0.11 29.19 s838.1 2.95 0.08 38.8 s1423 - 63.78 49.94 s13207.1 186.61 199.49 S35932 2.83 3.09
Encoding Circuit Structure Three ways to encode: Using no Structure Using “global” structure Using global and “local” structure No Structure Global Structure Local Structure Sress: all this very interesting but…everyone already encodes according to syntax 2 for circuits so what is the point of RS1? I’ve been talking about circuits because they have very well understood semantics and provide a great example, but the point is to go beyond circuits, to applications where the semantics are not as well understood and we don’t have templates for how to encode. In general, we see that these ideas can be extended to many systems that are made from components that can be encoded individually
Inference Bayesian Networks Inference is #P-Complete. Decades of research. Most techniques use global structure only and are exponential in treewidth. Recent algorithms attempt to be sensitive to local structure. Weighted model counting is among the most successful. Many networks can only be handled by model counting. A B C
Inference Bayesian Networks Cachet c2d Compile ^ v θa2 λc2 λc1 θc2|a2 b1 θc3|a2 b1 A B C Encode CNF d-DNNF
Encoding Variables Parameter Variables: θ4 A B C Indicator Variables: Pr a1 b1 c1 0.7 (θ1) c2 0.0 (false) c3 0.3 (θ2) b2 0.4 (θ3) a2 0.333 (θ4) 0.2 (θ5) 0.5 (θ6) A B C Indicator Variables: λc1 λc2 λc3 Parameter Variables: θ4
Encoding Clauses Parameter Clause: λa2 ^ λb1 ^ λc1 => θ4 A B C Pr a1 b1 c1 0.7 (θ1) c2 0.0 (false) c3 0.3 (θ2) b2 0.4 (θ3) a2 0.333 (θ4) 0.2 (θ5) 0.5 (θ6) A B C Indicator Clauses: λc1 v λc2 v λc3 ¬λc1 v ¬λc2 ¬λc1 v ¬λc3 ¬λc2 v ¬λc3 Parameter Clause: λa2 ^ λb1 ^ λc1 => θ4
Encoding Groups A B C A B C Pr a1 b1 c1 0.7 (θ1) c2 0.0 (false) c3 0.3 (θ2) b2 0.4 (θ3) a2 0.333 (θ4) 0.2 (θ5) 0.5 (θ6) A B C
Encoding a Single Group a1 b1 c3 a1 b2 c2 a1 b2 c3 a2 b2 c2 λa1 ^ λb1 ^ λc3 => θ2 λa1 ^ λb2 ^ λc2 => θ2 λa1 ^ λb2 ^ λc3 => θ2 λa2 ^ λb2 ^ λc2 => θ2 encode Prime Implicants a1 c3 b2 c2 PI encode λa1 ^ λc3 => θ2 λb2 ^ λc2 => θ2
Old Encoding vs. New
Resolution Strategy 2 Use global structure Encode each table in isolation Use local structure as before Suppress generation of some CNF variables Use local structure to reveal semantic independence For each table, partition rows into encoding groups. For each encoding group, find prime implicants. For each prime implicant, assert a clause
Observations Resolution Strategy 2 applies structured resolution. Finding prime implicants here is efficient. Similarity between two strategies: Remove occurrences of literals Seeks to make clauses more minimal Reveals semantic independence Main idea can be applied more generally Encoding functions over finitely-valued variables e.g., Truth tables, Bayesian networks, Markov networks, influence diagrams.
Resolution Strategy 2 Experiments Previous RS 2 Compile Network TW Time (s) Improv. Size gr-50-16-1 24 137.25 43.95 3.12 14,692,963 5,739,854 2.56 gr-50-16-2 25 - 292.42 35,473,955 gr-50-16-3 65.03 40.45 1.61 7,755,318 5,280,027 1.47 gr-50-16-4 407.6 46.83 8.7 35,950,912 6,128,859 5.87 gr-50-16-5 26.7 3,431,139 gr-50-16-6 44.4 22.99 1.93 4,598,373 3,159,007 1.46 gr-50-16-7 51.68 2.99 17.28 6,413,897 421,060 15.23 gr-50-16-8 86.19 32.29 2.67 10,341,755 4,280,261 2.42 gr-50-16-9 60.55 7,360,872 gr-50-16-10 133.7 287.08 0.47 15,144,602 33,561,672 0.45 gr-50-18-1 27 411.45 48.36 8.51 39,272,847 6,451,916 6.09 gr-50-18-2 28 172.13 19,037,468 gr-50-18-3 362.9 29.18 12.44 32,120,267 2,507,215 12.81 gr-50-18-4 139.81 15,933,651 gr-50-18-5 158.13 18,291,116 gr-50-18-6 403.96 52.55 7.69 37,411,619 7,111,893 5.26 gr-50-18-7 79.97 9,439,318 gr-50-18-8 42.17 5,036,670 gr-50-18-9 68.51 7,890,645 gr-50-18-10 188.66 22,387,841
Resolution Strategy 2 Experiments Previous RS 2 Compile Network TW Time (s) Improv. Size bm-05-03 19 0.29 0.2 1.45 19,190 10,957 1.75 bm-10-03 51 19.57 4.97 3.94 938,371 275,089 3.41 bm-15-03 62 254.96 44.07 5.79 7,351,823 1,460,842 5.03 bm-20-03 90 1,505.24 388.65 3.87 37,916,087 6,195,000 6.12 bm-22-03 107 4,869.64 748.13 6.51 72,169,022 14,405,730 5.01 or-60-20-1 24 338.48 54.47 6.21 6,968,339 7,777,867 0.90 or-60-20-3 25 1.4 0.77 1.82 104,275 119,779 0.87 or-60-20-5 27 728.36 118.17 6.16 17,358,747 14,986,497 1.16 or-60-20-7 26 250.72 97.13 2.58 11,296,613 12,510,488 or-60-20-9 19.58 7.17 2.73 1,011,193 1,060,217 0.95 water 21 2.81 1.73 1.62 101,009 103,631 0.97 pathfinder 15 12.45 2.86 4.35 36,024 33,614 1.07 diabetes 18 6,281.23 3,391.18 1.85 15,426,793 15,751,044 0.98 mildew 6,245.45 1,869.92 3.34 1,693,750 1,696,139 1.00 barley 23 - 14,722.19 37,321,497
Conclusion Syntax of CNF is critical Gap between syntactic and semantic independence Resolution Strategy 1: a resolution strategy Resolution Strategy 2: a generalization of strategy for Bayesian nets Experiments using Cachet and c2d Achieve large time and space improvements
Encoding Times
Implied Variables Syntax 1 A ^ B ^ C => D A v B v C A => D B => D C => D Syntax 1 A ^ B ^ C => D A ^ B ^ C => D A ^ B ^ C => D A ^ B ^ C => D A ^ B ^ C => D A ^ B ^ C => D A ^ B ^ C => D