Conjunctive Normal Form

27 views
Skip to first unread message

Santanu Sarkar

unread,
Apr 20, 2013, 2:39:47 PM4/20/13
to sage-s...@googlegroups.com
Dear all,
  I want to convert the polynomial f into Conjunctive Normal Form (CNF)
in Sage. How can I do this?


B.<a,b,c> = BooleanPolynomialRing()
f=a+b*c

Maarten Derickx

unread,
Apr 20, 2013, 4:43:13 PM4/20/13
to sage-s...@googlegroups.com
sage: import sage.logic.propcalc as propcalc
sage: f = propcalc.formula("a^(b&c)")
sage: f.convert_cnf()
sage: f
(a|b|c)&(a|b|~c)&(a|~b|c)&(~a|~b|~c)

Martin Albrecht

unread,
Apr 20, 2013, 9:32:39 PM4/20/13
to sage-s...@googlegroups.com
sage: B.<a,b,c> = BooleanPolynomialRing()
sage: f=a+b*c
sage: from sage.sat.converters.polybori import CNFEncoder
sage: from sage.sat.solvers.dimacs import DIMACS
sage: solver = DIMACS()
sage: ce = CNFEncoder(solver, B)
sage: ce([f])
[None, a, b, c]
sage: solver.clauses()
[((-2, -3, 1), False, None), ((3, -1), False, None), ((2, -1), False, None)]
Cheers,
Martin

--
name: Martin Albrecht
_pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99
_otr: 47F43D1A 5D68C36F 468BAEBA 640E8856 D7951CCF
_www: http://martinralbrecht.wordpress.com/
_jab: martinr...@jabber.ccc.de

Santanu Sarkar

unread,
Apr 21, 2013, 2:15:06 PM4/21/13
to sage-s...@googlegroups.com
Dear all,
  Thank you very much for your help.

With regards,
Santanu



--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To post to this group, send email to sage-s...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.



Reply all
Reply to author
Forward
0 new messages