Skip to content

BooleanConvert ​

expr rewritten in the given boolean normal form — "DNF" (default), "CNF", or "NNF".

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageBooleanConvert!
BooleanConvert(expr)expr in disjunctive normal form (an Or of Ands) — same as LogicalExpand
BooleanConvert(expr, "CNF")expr in conjunctive normal form (an And of Ors)
BooleanConvert(expr, "NNF")expr with Not pushed to the leaves, but And/Or left in their original nesting shape (not distributed)
Typed signatures
TypePackageApplies
(any, string?) -> anycombinatoricsalways

Domain: Collections

Details
  • "DNF" and "CNF" are Wolfram's own forms. "NNF" is an extension of ours — Wolfram 15's BooleanConvert has no "NNF" form (BooleanConvert(expr, "NNF") stays unevaluated there); we implement it anyway since it falls straight out of the same elimination pipeline, and it is documented here as a divergence rather than a Wolfram form.
  • Other Wolfram forms ("ESOP", "AC", "BF", …) are left unevaluated rather than approximated.
  • Shares LogicalExpand's elimination of Implies/Equivalent/Xor/Nand/Nor and its deterministic sort/dedup of every And/Or's operands.
  • A CNF clause with both a literal and its negation (a tautology) is dropped; an all-dropped result is True.
  • Clauses that differ only in one literal's polarity merge and absorbed clauses drop, so Implies(b, b) is True and b ∧ ¬b is False, as in Wolfram. This is not a full minimizer.

Examples

Basic #
live ↗
InBooleanConvert(p∧(b∨r))\mathrm{BooleanConvert}(p∧(b∨r))Outb∧p∨p∧r{{b}}∧{{p}}∨{{p}}∧r
live ↗
InBooleanConvert(x  ⟺  y  ⟺  z)\mathrm{BooleanConvert}(x\iff y\iff z)Outx∧y∧z∨¬x∧¬y∧¬z{{x}}∧{{y}}∧{{z}}∨¬{{x}}∧¬{{y}}∧¬{{z}}
Scope #
live ↗
InBooleanConvert(p∨b∧r,CNF)\mathrm{BooleanConvert}(p∨b∧r, \text{CNF})Out(b∨p)∧(p∨r)({{b}}∨{{p}})∧({{p}}∨r)
live ↗
InBooleanConvert(p  ⟹  b,NNF)\mathrm{BooleanConvert}(p\implies b, \text{NNF})Outb∨¬p{{b}}∨¬{{p}}
live ↗
InBooleanConvert(p∨¬p,CNF)\mathrm{BooleanConvert}(p∨¬p, \text{CNF})OutTrue\mathrm{True}
live ↗
InBooleanConvert(p,ESOP)\mathrm{BooleanConvert}(p, \text{ESOP})OutBooleanConvert(p,ESOP)\mathrm{BooleanConvert}(p, \text{ESOP})

A bare symbol is already in normal form

live ↗
InBooleanConvert(f)\mathrm{BooleanConvert}(f)Outff

A lone symbol is its own CNF

live ↗
InBooleanConvert(f,CNF)\mathrm{BooleanConvert}(f, \text{CNF})Outff
live ↗
InBooleanConvert(b  ⟹  b)\mathrm{BooleanConvert}(b\implies b)OutTrue\mathrm{True}
live ↗
InBooleanConvert(b  ⟺  b)\mathrm{BooleanConvert}(b\iff b)OutTrue\mathrm{True}
live ↗
InBooleanConvert(b∧¬b)\mathrm{BooleanConvert}(b∧¬b)OutFalse\mathrm{False}
live ↗
InBooleanConvert(b⊻b)\mathrm{BooleanConvert}(b\veebar b)OutFalse\mathrm{False}
live ↗
InBooleanConvert(a∧b∨a∧¬b)\mathrm{BooleanConvert}(a∧b∨a∧¬b)Outaa
live ↗
InBooleanConvert((a∨b)∧(a∨¬b),CNF)\mathrm{BooleanConvert}((a∨b)∧(a∨¬b), \text{CNF})Outaa
Neat examples #
live ↗
InBooleanConvert(a⊻b⊻c⊻d)\mathrm{BooleanConvert}(a\veebar b\veebar c\veebar d)Outa∧b∧c∧¬d∨a∧b∧d∧¬c∨a∧c∧d∧¬b∨a∧¬b∧¬c∧¬d∨b∧c∧d∧¬a∨b∧¬a∧¬c∧¬d∨c∧¬a∧¬b∧¬d∨d∧¬a∧¬b∧¬c{{a}}∧{{b}}∧{{c}}∧¬{{d}}∨{{a}}∧{{b}}∧{{d}}∧¬{{c}}∨{{a}}∧{{c}}∧{{d}}∧¬{{b}}∨{{a}}∧¬{{b}}∧¬{{c}}∧¬{{d}}∨{{b}}∧{{c}}∧{{d}}∧¬{{a}}∨{{b}}∧¬{{a}}∧¬{{c}}∧¬{{d}}∨{{c}}∧¬{{a}}∧¬{{b}}∧¬{{d}}∨{{d}}∧¬{{a}}∧¬{{b}}∧¬{{c}}
About
Examples15
Checked againstWolfram Language 13 agree1 differ1 unevaluated
CrosswalkWolfram Language

See also: LogicalExpand