The boolean expression to parse
OptionalreturnAST?: booleanIf true, returns an abstract syntax tree (AST) instead of a string
OptionalreturnJSON?: booleanIf true, returns an AST in JSON instead of a string
OptionalreturnLaTeX?: booleanIf true, returns LaTeX code instead of a string
Optionalvalues?: Record<string, boolean | 0 | 1>Optional object mapping variable names to values
// Simplify expression
const p = Chalkboard.bool.parse("x & !x | y & x | y & !x"); // Returns "y"
const q = Chalkboard.bool.parse("(x & y) | (x & z)"); // Returns "x & (y | z)"
// Evaluate expression with values
const r = Chalkboard.bool.parse("x & y | z", { values: { x: true, y: false, z: true } }); // Returns true
const s = Chalkboard.bool.parse("a & !b", { values: { a: 1, b: 0 } }); // Returns true
// Get AST representation
const t = Chalkboard.bool.parse("x & y", { returnAST: true }); // Returns AST object
Parses, simplifies, and optionally evaluates a boolean expression. When called with values, it evaluates the expression with the provided variable values, and otherwise, it simplifies the expression to its minimal form. Supports variables (a-z, A-Z, 0-9, _), operators (!, &, |), and parentheses.