20
20
vtr = zoo_vtree (" random.vtree" )
21
21
slc = smooth (sdd)
22
22
plc = propagate_constants (sdd, remove_unary= true )
23
- structplc = compile (StructLogicCircuit, vtr, plc)
23
+ structplc = compile (StructLogicCircuit, vtr, plc)
24
24
sstructplc = smooth (structplc)
25
25
26
26
@test ! issmooth (sdd)
29
29
@test respects_vtree (sstructplc, vtr)
30
30
31
31
@test prob_equiv (slc, sstructplc, 3 )
32
+
33
+ # Case when not all literals appear in the LC. See:
34
+ # https://github.com/Juice-jl/ProbabilisticCircuits.jl/issues/80
35
+ cnf = IOBuffer (b """ c Encodes the following: ϕ = (1 ∨ ¬2) ∧ (3 ∨ ¬4) ∧ (1 ∨ ¬4)
36
+ p cnf 4 3
37
+ 1 -2 0
38
+ 3 -4 0
39
+ 1 -4 0
40
+ """ )
41
+ # Try out with different vtrees.
42
+ for i ∈ 1 : 5
43
+ sdd = compile (SddMgr (Vtree (4 , :random )), read (cnf, LogicCircuit, FnfFormat ()))
44
+ lc = LogicCircuit (sdd)
45
+ slc = smooth (lc)
46
+ plc = propagate_constants (lc, remove_unary= true )
47
+ structplc = compile (StructLogicCircuit, sdd. vtree, plc)
48
+ sstructplc = smooth (structplc)
49
+
50
+ @test ! issmooth (sdd)
51
+ @test ! issmooth (lc)
52
+ @test issmooth (slc)
53
+ @test issmooth (sstructplc)
54
+ @test respects_vtree (sstructplc, sdd. vtree)
55
+
56
+ @test prob_equiv (slc, sstructplc, 3 )
57
+
58
+ # Reset stream pointer
59
+ seekstart (cnf)
60
+ end
32
61
end
33
62
34
63
@testset " Forget test" begin
78
107
79
108
@testset " conjoin test" begin
80
109
c1 = zoo_sdd_random
81
-
110
+
82
111
lit = Lit (num_variables (c1) + 1 )
83
112
@test c1 === conjoin (c1, lit)
84
113
85
114
lit1 = Lit (1 )
86
115
c2 = conjoin (c1, lit1)
87
116
dict = canonical_literals (c2)
88
117
@test haskey (dict, lit1)
89
- @test ! haskey (dict, - lit1)
118
+ @test ! haskey (dict, - lit1)
90
119
c3 = conjoin (c2, - lit1)
91
120
@test isfalse (c3)
92
121
c4 = conjoin (c2, lit1)
@@ -235,11 +264,11 @@ end
235
264
c = compile (PlainLogicCircuit, Lit (3 ))
236
265
d = compile (PlainLogicCircuit, Lit (4 ))
237
266
e = compile (PlainLogicCircuit, - Lit (4 ))
238
-
267
+
239
268
f = disjoin (conjoin (a, b), conjoin (c, d))
240
269
candidates, variable_scope = split_candidates (f)
241
270
@test length (candidates) == 0
242
-
271
+
243
272
g = disjoin (conjoin (disjoin (conjoin (d, b), conjoin (e, b)), a))
244
273
candidates, variable_scope = split_candidates (g)
245
274
@test length (candidates) == 1
@@ -252,13 +281,13 @@ end
252
281
b = compile (PlainLogicCircuit, Lit (2 ))
253
282
c = compile (PlainLogicCircuit, Lit (3 ))
254
283
d = compile (PlainLogicCircuit, Lit (4 ))
255
-
284
+
256
285
e = conjoin (a, b, c)
257
286
circuit = standardize_circuit (e)
258
287
@test circuit. children[1 ]. literal == Lit (1 )
259
288
@test circuit. children[2 ]. children[1 ]. children[1 ]. literal == Lit (2 )
260
289
@test circuit. children[2 ]. children[1 ]. children[2 ]. literal == Lit (3 )
261
-
290
+
262
291
e = disjoin (a, b)
263
292
f = disjoin (c, d)
264
293
g = disjoin (e, f)
0 commit comments