Package Exports
- boolean-json-cnf
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (boolean-json-cnf) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
var cnf = require('boolean-json-cnf')The package exports a function of one boolean-json object.
De Morgan's Laws
var assert = require('assert')
assert.deepEqual(
// ¬(p ∨ q)
cnf({ not: { or: [ 'p', 'q' ] } }),
// (¬p ∧ ¬q)
{ and: [ { not: 'p' }, { not: 'q' } ] })
assert.deepEqual(
// ¬(p ∧ q)
cnf({ not: { and: [ 'p', 'q' ] } }),
// (¬p ∨ ¬q)
{ or: [ { not: 'p' }, { not: 'q' } ] })Double Negation
assert.deepEqual(
// ¬¬p
cnf({ not: { not: 'p' } }),
// p
'p')Distribution of Disjunction over Conjunction
assert.deepEqual(
// (p ∨ (q ∧ r))
cnf({ or: [ 'p', { and: [ 'q', 'r' ] } ] }),
// ((p ∨ q) ∧ (p ∨ r))
{ and: [ { or: [ 'p', 'q' ] }, { or: [ 'p', 'r' ] } ] })
assert.deepEqual(
// ((q ∧ r) ∨ p)
cnf({ or: [ { and: [ 'q', 'r' ] }, 'p' ] }),
// ((p ∨ q) ∧ (p ∨ r))
{ and: [ { or: [ 'p', 'q' ] }, { or: [ 'p', 'r' ] } ] })k-ary Conjunctions and Disjunctions
assert.deepEqual(
// ¬(p ∨ q ∨ r)
cnf({ not: { or: [ 'p', 'q', 'r' ] } }),
// (¬p ∧ (¬q ∧ ¬r))
{ and: [ { not: 'p' }, { and: [ { not: 'q' }, { not: 'r' } ] } ] })
assert.deepEqual(
// ¬(p ∧ q ∧ r)
cnf({ not: { and: [ 'p', 'q', 'r' ] } }),
// (¬p ∨ (¬q ∨ ¬r))
{ or: [ { not: 'p' }, { or: [ { not: 'q' }, { not: 'r' } ] } ] })