Documentation

Complexitylib.Circuits.BarringtonCompiler

An executable Barrington compiler #

This module turns the finite Barrington theorem into an explicit recursive compiler. Earlier existence proofs selected S₅ conjugators in Prop; here, allPermutationsFin gives a computable enumeration and firstConjugator5 performs a deterministic finite search. The resulting barringtonCompile contains no choice operation.

For every Boolean formula and target 5-cycle, the compiler returns a width-5 permutation branching program with exact representation semantics and the textbook length bound 4 ^ depth. The remaining work for a fully uniform Barrington theorem is therefore serialization and a resource-bounded generator proof, not extraction of program data from an existential theorem.

Main results #

theorem Complexity.mem_allPermutationsFin {n : ℕ} (permutation : Equiv.Perm (Fin n)) :
permutation ∈ allPermutationsFin n

allPermutationsFin n contains every permutation of Fin n.

theorem Complexity.firstConjugator5_spec (source target : Equiv.Perm (Fin 5)) (hexists : ∃ (g : Equiv.Perm (Fin 5)), g * source * g⁻¹ = target) :
firstConjugator5 source target * source * (firstConjugator5 source target)⁻¹ = target

If two permutations are conjugate, the executable finite search returns a valid conjugator.

The canonical left factor is a 5-cycle for every target value.

The canonical right factor is a 5-cycle for every target value.

theorem Complexity.barrington_commutator (target : Equiv.Perm (Fin 5)) (hcycle : target.IsCycle) (horder : orderOf target = 5) :

The executable factors have commutator equal to any target 5-cycle.

The four-block commutator program has exactly twice the sum of the source lengths.

theorem Complexity.barringtonCompile_computes (formula : BoolFormula) (target : Equiv.Perm (Fin 5)) (hcycle : target.IsCycle) (horder : orderOf target = 5) :
BP.Computes target (barringtonCompile formula target) fun (assignment : ℕ → Bool) => BoolFormula.eval assignment formula

The executable compiler represents a formula through any target 5-cycle.

theorem Complexity.barringtonCompile_length_le (formula : BoolFormula) (target : Equiv.Perm (Fin 5)) :
List.length (barringtonCompile formula target) ≤ 4 ^ formula.depth

The executable compiler satisfies the textbook 4 ^ depth length bound.

theorem Complexity.barringtonCompile_var_bound (formula : BoolFormula) (target : Equiv.Perm (Fin 5)) (bound : ℕ) (hvars : ∀ index ∈ formula.vars, index ≤ bound) (instruction : BPInstr 5) :
instruction ∈ barringtonCompile formula target → instruction.var ≤ bound

The executable compiler reads no formula-external variable: any bound on the source formula's variable indices bounds every emitted instruction. Constant instructions use variable zero, so the bound is stated for a natural upper bound rather than as a literal subset of formula.vars.

The canonical target cycle is nonidentity.

Constructive finite Barrington theorem. The explicit compiled program evaluates to the fixed target barringtonTargetBase exactly when the formula is true (and to the identity otherwise), the target is not the identity, and the program's length is at most 4 ^ depth. That the target is a 5-cycle is the separate theorem barringtonTargetBase_spec; this statement records only that it is nonidentity.