Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in model_count after conjoin of non-smooth and using Lit(2) #21

Open
khosravipasha opened this issue Jun 17, 2020 · 1 comment
Open
Labels
bug Something isn't working
Milestone

Comments

@khosravipasha
Copy link
Collaborator

khosravipasha commented Jun 17, 2020

This should hold for model_count but it does not:

mc(delta | x_1) + mc(delta | not x_1) = mc(delta)

The issue imight be because of conjoin on non-smooth circuits.

@khosravipasha khosravipasha changed the title Potential Bug in model count Potential Bug in model count after conditioning Jun 17, 2020
@khosravipasha khosravipasha self-assigned this Jul 17, 2020
@khosravipasha
Copy link
Collaborator Author

khosravipasha commented Jul 26, 2020

Smooth a circuit and compile to sdd then conjoin and compare model count

using LogicCircuits
random_lc = zoo_sdd("random.sdd");
vtree = zoo_vtree("random.vtree");

plc = propagate_constants(random_lc , remove_unary=true);
structplc = compile(StructLogicCircuit, vtree, plc);
sstructplc = smooth(structplc);
lits = pos_literals(LogicCircuit, num_variables(random_lc))


manager = SddMgr(sstructplc.vtree)
sdd = compile(manager, sstructplc)
sdd_lits = pos_literals(Sdd, manager, num_variables(random_lc))

model_count(random_lc), model_count(sstructplc)

model_count(sdd & sdd_lits[2]), model_count(sdd & -sdd_lits[2])

model_count(conjoin(random_lc, Lit(2))), model_count(conjoin(random_lc, Lit(-2)))

model_count(conjoin(random_lc, lits[2])), model_count(conjoin(random_lc, -lits[2]))

model_count(conjoin(LogicCircuit(sstructplc), Lit(2))), model_count(conjoin(LogicCircuit(sstructplc), Lit(-2)))

model_count(conjoin(LogicCircuit(sstructplc), lits[2])), model_count(conjoin(LogicCircuit(sstructplc), -lits[2]))

Output: First one is withouth conjoining. The others should all be equal but second one is wrong (i.e. conjoin on a non-smooth circuit and then using Lit(2)). All other cases seem correct.

julia> model_count(random_lc), model_count(sstructplc)
(65536, 65536)

julia> model_count(conjoin(random_lc, Lit(2))), model_count(conjoin(random_lc, Lit(-2)))
(55552, 55552)

julia> model_count(sdd & sdd_lits[2]), model_count(sdd & -sdd_lits[2])
(32768, 32768)

julia> model_count(conjoin(random_lc, lits[2])), model_count(conjoin(random_lc, -lits[2]))
(32768, 32768)

julia> model_count(conjoin(LogicCircuit(sstructplc), Lit(2))), model_count(conjoin(LogicCircuit(sstructplc), Lit(-2)))
(32768, 32768)

julia> model_count(conjoin(LogicCircuit(sstructplc), lits[2])), model_count(conjoin(LogicCircuit(sstructplc), -lits[2]))
(32768, 32768)

Doing & with Sdds

Update: now works correctly as expected.

sun, rain, rainbow = pos_literals(LogicCircuit, 3)
circuit = (rainbow & sun & rain) | (-rainbow); # rainbow implies sun and rain
manager = SddMgr(7, :balanced)
circuit = compile(manager, circuit);
sun, rain, rainbow, cloud, snow, belgium, los_angeles = pos_literals(Sdd, manager, 7)
circuit &= (-los_angeles | -belgium) # cannot be in LA and Belgium at the same time
circuit &= (los_angeles ⇒ sun) ∧ (belgium ⇒ cloud) # unicode logical syntax
circuit &= (¬(rain ∨ snow) ⇐ ¬cloud); # no rain or snow without clouds


circuit_sun = circuit & sun # condition(circuit, sun) throws error cannot condition sdd
circuit_nosun = circuit & -sun # condition(circuit, -sun) throws error cannot condition sdd

model_count(circuit) # 29
model_count(circuit_sun)  # 20 
model_count(circuit_nosun) # 9

@khosravipasha khosravipasha added the bug Something isn't working label Jul 26, 2020
@khosravipasha khosravipasha added this to the Version 0.2 milestone Jul 26, 2020
@khosravipasha khosravipasha changed the title Potential Bug in model count after conditioning Bug in model count after transformations conditioning/forgetting Jul 26, 2020
@khosravipasha khosravipasha removed their assignment Jul 28, 2020
@khosravipasha khosravipasha changed the title Bug in model count after transformations conditioning/forgetting Smoothing causes Bug in model count Feb 25, 2021
@khosravipasha khosravipasha changed the title Smoothing causes Bug in model count Smoothing or Conditioning causes Bug in model count Mar 3, 2021
@khosravipasha khosravipasha self-assigned this Mar 21, 2021
@khosravipasha khosravipasha changed the title Smoothing or Conditioning causes Bug in model count Smoothing or Conditioning causes Bug in model_count Mar 22, 2021
@khosravipasha khosravipasha changed the title Smoothing or Conditioning causes Bug in model_count Bug in model_count after conjoin/smoothing Mar 25, 2021
@khosravipasha khosravipasha changed the title Bug in model_count after conjoin/smoothing Bug in model_count after conjoin of non-smooth and using Lit(2) Mar 25, 2021
@khosravipasha khosravipasha removed their assignment Jun 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant