Documentation

CslibFrontier.Computability.Circuit.Boolean.SemiUnbounded

Layered semi-unbounded Boolean circuits and proof trees #

A layered semi-unbounded Boolean circuit has leaves carrying fixed Boolean values (such as evaluated input literals), AND gates of fan-in one or two, and unbounded fan-in OR gates, with every child strictly one layer below its parent. A circuit is in alternating normal form with an AND first layer (LayeredSemiUnboundedCircuit.InNormalForm) when layer 0 consists of leaves, odd layers consist of AND gates, and positive even layers consist of OR gates.

A proof tree (LayeredSemiUnboundedCircuit.ProofTree) lives in the circuit's tree unfolding: leaves must evaluate to true, AND gates keep all children, and OR gates select one child. This file develops the structural combinatorics of proof trees (part of work package 1 of cslib-frontier #7920; original formalization adapting the layered-digraph isolation framework of Cslib.LayeredDigraph):

Main definitions #

Main results #

inductive Cslib.Circuits.Boolean.AndInputs (G : Type u_1) :
Type u_1

The inputs of an AND gate of fan-in one or two.

  • unary {G : Type u_1} (child : G) : AndInputs G

    A fan-in-one AND gate with a single child.

  • binary {G : Type u_1} (left right : G) : AndInputs G

    A fan-in-two AND gate with ordered left and right children.

def Cslib.Circuits.Boolean.instDecidableEqAndInputs.decEq {G✝ : Type u_1} [DecidableEq G✝] (x✝ x✝¹ : AndInputs G✝) :
Decidable (x✝ = x✝¹)
@[instance_reducible]
inductive Cslib.Circuits.Boolean.GateKind (G : Type u_1) :
Type u_1

The role of a gate in a layered semi-unbounded circuit.

  • leaf {G : Type u_1} (val : Bool) : GateKind G

    A leaf carrying a fixed Boolean truth value (for example an evaluated literal).

  • and {G : Type u_1} (inputs : AndInputs G) : GateKind G

    An AND gate of fan-in one or two.

  • or {G : Type u_1} : GateKind G

    An unbounded fan-in OR gate, whose children are given by orChild.

def Cslib.Circuits.Boolean.instDecidableEqGateKind.decEq {G✝ : Type u_1} [DecidableEq G✝] (x✝ x✝¹ : GateKind G✝) :
Decidable (x✝ = x✝¹)
@[instance_reducible]

A layered semi-unbounded Boolean circuit: leaves carry Boolean values, AND gates have fan-in one or two, OR gates have unbounded fan-in (as a child relation with no duplicate edges), and every child lies strictly one layer below its parent.

Alternating normal form with an AND first layer above the leaves: layer 0 consists of leaves, odd layers consist of AND gates, and positive even layers consist of OR gates.

In normal form, every AND gate sits at an odd layer.

In normal form, every OR gate sits at a positive even layer.

In normal form, every leaf sits at layer zero.

In normal form, every child of an OR gate is an AND gate at an odd layer.

The zero-based AND-level of a gate: for an AND gate at layer 2 * k + 1, this is k.

@[irreducible]

Boolean evaluation of a gate in a layered semi-unbounded circuit, defined by recursion on its layer.

A leaf evaluates to its truth value.

A fan-in-one AND gate evaluates to the value of its child.

A fan-in-two AND gate evaluates to the conjunction of its two children.

An OR gate evaluates to true iff at least one of its children evaluates to true.

A proof tree witnessing that gate g evaluates to true in the tree unfolding of C: leaves are true, AND gates keep all children, and OR gates choose a single child.

Instances For

    A gate evaluates to true iff it has a proof tree.

    The weight of a proof tree under a gate weighting w, summing over all gate occurrences with multiplicity from the tree unfolding.

    The list of AND-gate occurrences in a proof tree, with multiplicity from the tree unfolding.

    theorem Cslib.Circuits.Boolean.LayeredSemiUnboundedCircuit.ProofTree.andNodes_level_profile {G : Type u_1} {C : LayeredSemiUnboundedCircuit G} (hnorm : C.InNormalForm) {g : G} (t : C.ProofTree g) (k : ℕ) :
    2 * k < C.layer g → (List.filter (fun (x : G) => decide (C.andLevel x = k)) t.andNodes).length ≤ 2 ^ ((C.layer g - 1) / 2 - k)

    In normal form, a proof tree rooted at gate g contains at most 2 ^ ((C.layer g - 1) / 2 - k) copies of AND gates at each AND-level k with 2 * k < C.layer g.

    theorem Cslib.Circuits.Boolean.LayeredSemiUnboundedCircuit.ProofTree.andNodes_and_profile {G : Type u_1} {C : LayeredSemiUnboundedCircuit G} (hnorm : C.InNormalForm) {u : G} {inp : AndInputs G} (hkind : C.kind u = GateKind.and inp) (t : C.ProofTree u) :
    ∃ (rest : List G), t.andNodes = u :: rest ∧ (∀ x ∈ rest, C.andLevel x < C.andLevel u) ∧ ∀ k < C.andLevel u, (List.filter (fun (x : G) => decide (C.andLevel x = k)) rest).length ≤ 2 ^ (C.andLevel u - k)

    In normal form, the AND-gate occurrences of a proof tree rooted at an AND gate u split as u :: rest, where every node in rest sits strictly below C.andLevel u and at most 2 ^ (C.andLevel u - k) nodes sit at each AND-level k < C.andLevel u.

    A gate weighting is min-isolating if every gate evaluating to true has a unique minimum-weight proof tree.

    Minimizing a proof tree of a fan-in-one AND gate is equivalent to minimizing its child's proof tree.

    Minimizing a proof tree of a fan-in-two AND gate is equivalent to minimizing both children's proof trees independently.

    A leaf gate has at most one proof tree.

    A unary AND gate is min-isolated whenever its child has a unique minimum tree.

    A binary AND gate is min-isolated whenever both children have unique minimum trees.

    theorem Cslib.Circuits.Boolean.LayeredSemiUnboundedCircuit.isMinOn_orChoice_iff {G : Type u_1} {C : LayeredSemiUnboundedCircuit G} (w : G → ℕ) {g c : G} (hkind : C.kind g = GateKind.or) (hchild : C.orChild g c) (t : C.ProofTree c) :
    IsMinOn (ProofTree.weight w) Set.univ (ProofTree.orChoice hkind hchild t) ↔ ∀ (u : G), C.orChild g u → ∀ (p : C.ProofTree u), ProofTree.weight w t ≤ ProofTree.weight w p

    An OR proof tree is minimum precisely when its chosen child tree is no heavier than any proof tree of any child. The root weight contributes equally to all the candidates.

    The chosen child subtree of a minimum-weight proof tree at an OR gate is itself a minimum-weight proof tree of that child.

    theorem Cslib.Circuits.Boolean.LayeredSemiUnboundedCircuit.existsUnique_isMinOn_orChoice_iff {G : Type u_1} {C : LayeredSemiUnboundedCircuit G} (w : G → ℕ) {g c : G} (hkind : C.kind g = GateKind.or) (hchild : C.orChild g c) (t : C.ProofTree c) (hle : ∀ (u : G), C.orChild g u → ∀ (p : C.ProofTree u), ProofTree.weight w t ≤ ProofTree.weight w p) (huniq : ∀ (p : C.ProofTree c), IsMinOn (ProofTree.weight w) Set.univ p → p = t) :
    (∃! p : C.ProofTree g, IsMinOn (ProofTree.weight w) Set.univ p) ↔ ∀ (u : G), C.orChild g u → u ≠ c → ∀ (p : C.ProofTree u), ProofTree.weight w t < ProofTree.weight w p

    Given a cheapest child tree and uniqueness at that child, the OR gate is isolated exactly when every tree from another child is strictly heavier.

    theorem Cslib.Circuits.Boolean.LayeredSemiUnboundedCircuit.isMinIsolating_of_separated {G : Type u_1} (w : G → ℕ) (C : LayeredSemiUnboundedCircuit G) (separated : ∀ (g : G), C.kind g = GateKind.or → ∀ ⦃u v : G⦄, C.orChild g u → C.orChild g v → u ≠ v → ∀ ⦃tu : C.ProofTree u⦄ ⦃tv : C.ProofTree v⦄, IsMinOn (ProofTree.weight w) Set.univ tu → IsMinOn (ProofTree.weight w) Set.univ tv → ProofTree.weight w tu ≠ ProofTree.weight w tv) :

    If at every OR gate, distinct satisfied children have distinct minimum proof-tree weights, then the weighting is min-isolating for every gate evaluating to true.