Negation-normal unbounded formulas for AC0 #
AC0Formula N is an unbounded-fan-in formula over exactly N variables.
Negation occurs only in literal polarity, which is the representation needed
by restriction and switching-lemma arguments. Unlike a circuit, this syntax is
a tree and therefore records repeated subcomputations separately.
Children are stored in the mutually inductive AC0Forest. This gives Lean a
direct structural induction principle for unbounded formulas; ofList and
toList provide the usual list interface. Empty conjunctions and disjunctions
denote true and false, respectively.
A negation-normal Boolean formula with unbounded AND and OR gates.
- const
{N : ℕ}
(value : Bool)
: AC0Formula N
A Boolean constant.
- lit
{N : ℕ}
(literal : Literal N)
: AC0Formula N
A signed input variable.
- and
{N : ℕ}
(children : AC0Forest N)
: AC0Formula N
An unbounded conjunction.
- or
{N : ℕ}
(children : AC0Forest N)
: AC0Formula N
An unbounded disjunction.
Instances For
Equations
Equations
Equations
- One or more equations did not get rendered due to their size.
- Complexity.instDecidableEqAC0Formula.decEq_1 (Complexity.AC0Formula.const a) (Complexity.AC0Formula.const b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- Complexity.instDecidableEqAC0Formula.decEq_1 (Complexity.AC0Formula.const value) (Complexity.AC0Formula.lit literal) = isFalse ⋯
- Complexity.instDecidableEqAC0Formula.decEq_1 (Complexity.AC0Formula.const value) (Complexity.AC0Formula.and children) = isFalse ⋯
- Complexity.instDecidableEqAC0Formula.decEq_1 (Complexity.AC0Formula.const value) (Complexity.AC0Formula.or children) = isFalse ⋯
- Complexity.instDecidableEqAC0Formula.decEq_1 (Complexity.AC0Formula.lit literal) (Complexity.AC0Formula.const value) = isFalse ⋯
- Complexity.instDecidableEqAC0Formula.decEq_1 (Complexity.AC0Formula.lit a) (Complexity.AC0Formula.lit b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- Complexity.instDecidableEqAC0Formula.decEq_1 (Complexity.AC0Formula.lit literal) (Complexity.AC0Formula.and children) = isFalse ⋯
- Complexity.instDecidableEqAC0Formula.decEq_1 (Complexity.AC0Formula.lit literal) (Complexity.AC0Formula.or children) = isFalse ⋯
- Complexity.instDecidableEqAC0Formula.decEq_1 (Complexity.AC0Formula.and children) (Complexity.AC0Formula.const value) = isFalse ⋯
- Complexity.instDecidableEqAC0Formula.decEq_1 (Complexity.AC0Formula.and children) (Complexity.AC0Formula.lit literal) = isFalse ⋯
- Complexity.instDecidableEqAC0Formula.decEq_1 (Complexity.AC0Formula.and children) (Complexity.AC0Formula.or children_1) = isFalse ⋯
- Complexity.instDecidableEqAC0Formula.decEq_1 (Complexity.AC0Formula.or children) (Complexity.AC0Formula.const value) = isFalse ⋯
- Complexity.instDecidableEqAC0Formula.decEq_1 (Complexity.AC0Formula.or children) (Complexity.AC0Formula.lit literal) = isFalse ⋯
- Complexity.instDecidableEqAC0Formula.decEq_1 (Complexity.AC0Formula.or children) (Complexity.AC0Formula.and children_1) = isFalse ⋯
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Complexity.instDecidableEqAC0Formula.decEq_2 Complexity.AC0Forest.nil Complexity.AC0Forest.nil = isTrue ⋯
- Complexity.instDecidableEqAC0Formula.decEq_2 Complexity.AC0Forest.nil (Complexity.AC0Forest.cons head tail) = isFalse ⋯
- Complexity.instDecidableEqAC0Formula.decEq_2 (Complexity.AC0Forest.cons head tail) Complexity.AC0Forest.nil = isFalse ⋯
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Complexity.instDecidableEqAC0Forest.decEq_2 Complexity.AC0Forest.nil Complexity.AC0Forest.nil = isTrue ⋯
- Complexity.instDecidableEqAC0Forest.decEq_2 Complexity.AC0Forest.nil (Complexity.AC0Forest.cons head tail) = isFalse ⋯
- Complexity.instDecidableEqAC0Forest.decEq_2 (Complexity.AC0Forest.cons head tail) Complexity.AC0Forest.nil = isFalse ⋯
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Complexity.instDecidableEqAC0Forest.decEq_1 (Complexity.AC0Formula.const a) (Complexity.AC0Formula.const b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- Complexity.instDecidableEqAC0Forest.decEq_1 (Complexity.AC0Formula.const value) (Complexity.AC0Formula.lit literal) = isFalse ⋯
- Complexity.instDecidableEqAC0Forest.decEq_1 (Complexity.AC0Formula.const value) (Complexity.AC0Formula.and children) = isFalse ⋯
- Complexity.instDecidableEqAC0Forest.decEq_1 (Complexity.AC0Formula.const value) (Complexity.AC0Formula.or children) = isFalse ⋯
- Complexity.instDecidableEqAC0Forest.decEq_1 (Complexity.AC0Formula.lit literal) (Complexity.AC0Formula.const value) = isFalse ⋯
- Complexity.instDecidableEqAC0Forest.decEq_1 (Complexity.AC0Formula.lit a) (Complexity.AC0Formula.lit b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- Complexity.instDecidableEqAC0Forest.decEq_1 (Complexity.AC0Formula.lit literal) (Complexity.AC0Formula.and children) = isFalse ⋯
- Complexity.instDecidableEqAC0Forest.decEq_1 (Complexity.AC0Formula.lit literal) (Complexity.AC0Formula.or children) = isFalse ⋯
- Complexity.instDecidableEqAC0Forest.decEq_1 (Complexity.AC0Formula.and children) (Complexity.AC0Formula.const value) = isFalse ⋯
- Complexity.instDecidableEqAC0Forest.decEq_1 (Complexity.AC0Formula.and children) (Complexity.AC0Formula.lit literal) = isFalse ⋯
- Complexity.instDecidableEqAC0Forest.decEq_1 (Complexity.AC0Formula.and children) (Complexity.AC0Formula.or children_1) = isFalse ⋯
- Complexity.instDecidableEqAC0Forest.decEq_1 (Complexity.AC0Formula.or children) (Complexity.AC0Formula.const value) = isFalse ⋯
- Complexity.instDecidableEqAC0Forest.decEq_1 (Complexity.AC0Formula.or children) (Complexity.AC0Formula.lit literal) = isFalse ⋯
- Complexity.instDecidableEqAC0Forest.decEq_1 (Complexity.AC0Formula.or children) (Complexity.AC0Formula.and children_1) = isFalse ⋯
Instances For
Convert a list to the structurally recursive forest representation.
Equations
- Complexity.AC0Forest.ofList [] = Complexity.AC0Forest.nil
- Complexity.AC0Forest.ofList (formula :: formulas) = Complexity.AC0Forest.cons formula (Complexity.AC0Forest.ofList formulas)
Instances For
Convert a formula forest back to a list.
Equations
- Complexity.AC0Forest.nil.toList = []
- (Complexity.AC0Forest.cons formula formulas).toList = formula :: formulas.toList
Instances For
Number of formulas in a forest.
Equations
- Complexity.AC0Forest.nil.length = 0
- (Complexity.AC0Forest.cons formula formulas).length = formulas.length + 1
Instances For
Evaluate an unbounded formula on an N-bit input.
Equations
- Complexity.AC0Formula.eval input (Complexity.AC0Formula.const value) = value
- Complexity.AC0Formula.eval input (Complexity.AC0Formula.lit literal) = literal.eval input
- Complexity.AC0Formula.eval input (Complexity.AC0Formula.and children) = Complexity.AC0Formula.evalAll input children
- Complexity.AC0Formula.eval input (Complexity.AC0Formula.or children) = Complexity.AC0Formula.evalAny input children
Instances For
Evaluate a forest as a conjunction.
Equations
- Complexity.AC0Formula.evalAll input Complexity.AC0Forest.nil = true
- Complexity.AC0Formula.evalAll input (Complexity.AC0Forest.cons formula formulas) = (Complexity.AC0Formula.eval input formula && Complexity.AC0Formula.evalAll input formulas)
Instances For
Evaluate a forest as a disjunction.
Equations
- Complexity.AC0Formula.evalAny input Complexity.AC0Forest.nil = false
- Complexity.AC0Formula.evalAny input (Complexity.AC0Forest.cons formula formulas) = (Complexity.AC0Formula.eval input formula || Complexity.AC0Formula.evalAny input formulas)
Instances For
Total tree size, counting constants, literal occurrences, and gates.
Equations
- (Complexity.AC0Formula.const value).size = 1
- (Complexity.AC0Formula.lit literal).size = 1
- (Complexity.AC0Formula.and children).size = 1 + Complexity.AC0Formula.forestSize children
- (Complexity.AC0Formula.or children).size = 1 + Complexity.AC0Formula.forestSize children
Instances For
Sum of the tree sizes in a forest.
Equations
- Complexity.AC0Formula.forestSize Complexity.AC0Forest.nil = 0
- Complexity.AC0Formula.forestSize (Complexity.AC0Forest.cons formula formulas) = formula.size + Complexity.AC0Formula.forestSize formulas
Instances For
Formula depth. Leaves have depth zero and every unbounded gate adds one.
Equations
- (Complexity.AC0Formula.const value).depth = 0
- (Complexity.AC0Formula.lit literal).depth = 0
- (Complexity.AC0Formula.and children).depth = 1 + Complexity.AC0Formula.forestDepth children
- (Complexity.AC0Formula.or children).depth = 1 + Complexity.AC0Formula.forestDepth children
Instances For
Maximum formula depth in a forest.
Equations
- Complexity.AC0Formula.forestDepth Complexity.AC0Forest.nil = 0
- Complexity.AC0Formula.forestDepth (Complexity.AC0Forest.cons formula formulas) = max formula.depth (Complexity.AC0Formula.forestDepth formulas)
Instances For
Every member of a forest has depth at most the forest maximum.
The finite set of input variables mentioned by a formula.
Equations
- (Complexity.AC0Formula.const value).vars = ∅
- (Complexity.AC0Formula.lit literal).vars = {literal.var}
- (Complexity.AC0Formula.and children).vars = Complexity.AC0Formula.forestVars children
- (Complexity.AC0Formula.or children).vars = Complexity.AC0Formula.forestVars children
Instances For
Union of the variable supports of every formula in a forest.
Equations
- Complexity.AC0Formula.forestVars Complexity.AC0Forest.nil = ∅
- Complexity.AC0Formula.forestVars (Complexity.AC0Forest.cons formula formulas) = formula.vars ∪ Complexity.AC0Formula.forestVars formulas
Instances For
De Morgan negation, retaining negation-normal form.
Equations
- (Complexity.AC0Formula.const value).neg = Complexity.AC0Formula.const !value
- (Complexity.AC0Formula.lit literal).neg = Complexity.AC0Formula.lit literal.neg
- (Complexity.AC0Formula.and children).neg = Complexity.AC0Formula.or (Complexity.AC0Formula.negForest children)
- (Complexity.AC0Formula.or children).neg = Complexity.AC0Formula.and (Complexity.AC0Formula.negForest children)
Instances For
Negate every formula in a forest.
Equations
Instances For
Build the gate selected by an AND/OR operation.
Equations
- Complexity.AC0Formula.ofOp Complexity.AndOrOp.and children = Complexity.AC0Formula.and children
- Complexity.AC0Formula.ofOp Complexity.AndOrOp.or children = Complexity.AC0Formula.or children
Instances For
Build an unbounded conjunction from an ordinary list.
Equations
- Complexity.AC0Formula.andList children = Complexity.AC0Formula.and (Complexity.AC0Forest.ofList children)
Instances For
Build an unbounded disjunction from an ordinary list.
Equations
- Complexity.AC0Formula.orList children = Complexity.AC0Formula.or (Complexity.AC0Forest.ofList children)
Instances For
Every AC0 formula has at least one syntax-tree node.