diff --git a/Complexitylib.lean b/Complexitylib.lean index 7126b70d..b0814aeb 100644 --- a/Complexitylib.lean +++ b/Complexitylib.lean @@ -3,15 +3,17 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models -import Complexitylib.Asymptotics -import Complexitylib.TimeConstructible -import Complexitylib.Classes -import Complexitylib.Languages -import Complexitylib.SAT -import Complexitylib.Circuits -import Complexitylib.BooleanAnalysis -import Complexitylib.DescriptiveComplexity + +module +public import Complexitylib.Models +public import Complexitylib.Asymptotics +public import Complexitylib.TimeConstructible +public import Complexitylib.Classes +public import Complexitylib.Languages +public import Complexitylib.SAT +public import Complexitylib.Circuits +public import Complexitylib.BooleanAnalysis +public import Complexitylib.DescriptiveComplexity /-! # Complexitylib diff --git a/Complexitylib/Asymptotics.lean b/Complexitylib/Asymptotics.lean index 0ff86c9b..e5abbfd0 100644 --- a/Complexitylib/Asymptotics.lean +++ b/Complexitylib/Asymptotics.lean @@ -3,15 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Analysis.Asymptotics.Defs -import Mathlib.Analysis.Asymptotics.SpecificAsymptotics -import Mathlib.Analysis.Asymptotics.Lemmas -import Mathlib.Algebra.Polynomial.Eval.Defs -import Mathlib.Algebra.Polynomial.Eval.Degree -import Mathlib.Data.Finset.Lattice.Fold -import Mathlib.Data.Nat.Log -import Mathlib.Data.Nat.Size -import Mathlib.Algebra.Order.Floor.Semiring + +module +public import Mathlib.Analysis.Asymptotics.SpecificAsymptotics +public import Mathlib.Data.Nat.Size /-! # Asymptotic notation for natural number functions @@ -51,6 +46,9 @@ opened and read like standard complexity-theoretic asymptotic notation. - `LittleO.const_mul_left` — constant multiple preserves little-o -/ + +@[expose] public section + open Asymptotics Filter namespace Complexity diff --git a/Complexitylib/Asymptotics/PolynomialComposition.lean b/Complexitylib/Asymptotics/PolynomialComposition.lean index 554da3b2..061b3d05 100644 --- a/Complexitylib/Asymptotics/PolynomialComposition.lean +++ b/Complexitylib/Asymptotics/PolynomialComposition.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Asymptotics + +module +public import Complexitylib.Asymptotics /-! # Polynomial composition bounds @@ -18,6 +20,9 @@ deterministic function computations are connected sequentially. - `BigO.polynomial_composition_time` — the coarse sequential runtime is polynomially bounded -/ + +@[expose] public section + namespace Complexity /-- Composing evaluations of natural-coefficient polynomials gives a function diff --git a/Complexitylib/BooleanAnalysis.lean b/Complexitylib/BooleanAnalysis.lean index d8940c87..d9654007 100644 --- a/Complexitylib/BooleanAnalysis.lean +++ b/Complexitylib/BooleanAnalysis.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.BooleanAnalysis.FourierExpansion + +module +public import Complexitylib.BooleanAnalysis.FourierExpansion /-! # Analysis of Boolean functions diff --git a/Complexitylib/BooleanAnalysis/FourierExpansion.lean b/Complexitylib/BooleanAnalysis/FourierExpansion.lean index a7986df4..08fe20f8 100644 --- a/Complexitylib/BooleanAnalysis/FourierExpansion.lean +++ b/Complexitylib/BooleanAnalysis/FourierExpansion.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.BooleanAnalysis.FourierExpansion.Internal -import Mathlib.Probability.ProbabilityMassFunction.Constructions + +module +public import Complexitylib.BooleanAnalysis.FourierExpansion.Internal +public import Mathlib.Probability.ProbabilityMassFunction.Constructions /-! # Chapter 1: Boolean functions and the Fourier expansion @@ -17,6 +19,9 @@ Functions" by Ryan O'Donnell. * Ryan O'Donnell, *Analysis of Boolean Functions*, Chapter 1. -/ + +@[expose] public section + namespace Complexity namespace BooleanAnalysis diff --git a/Complexitylib/BooleanAnalysis/FourierExpansion/Defs.lean b/Complexitylib/BooleanAnalysis/FourierExpansion/Defs.lean index ede2ac47..c4c0d413 100644 --- a/Complexitylib/BooleanAnalysis/FourierExpansion/Defs.lean +++ b/Complexitylib/BooleanAnalysis/FourierExpansion/Defs.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Algebra.BigOperators.Expect -import Mathlib.Analysis.InnerProductSpace.Basic -import Mathlib.Data.ZMod.Basic + +module +public import Mathlib.Analysis.Complex.Order +public import Mathlib.Analysis.InnerProductSpace.Defs /-! # Chapter 1: Boolean functions and the Fourier expansion — Definitions @@ -42,6 +43,9 @@ the book's conventions: * `Pr₂[P]` — joint uniform probability over pairs -/ + +@[expose] public section + namespace Complexity namespace BooleanAnalysis @@ -154,7 +158,7 @@ noncomputable instance instCore : PreInnerProductSpace.Core ℝ (BooleanFunction toInner := instInner conj_inner_symm f g := by simp [inner_comm f g] re_inner_nonneg f := by simp [inner_self_nonneg' f] - add_left := inner_add_left + add_left := by exact inner_add_left smul_left f g r := by rw [inner_smul_left]; simp -- `instFullCore` adds the definiteness axiom (`‖f‖ = 0 → f = 0`) needed to upgrade @@ -164,7 +168,7 @@ noncomputable instance instCore : PreInnerProductSpace.Core ℝ (BooleanFunction -- from the same inner product, so there is no diamond. noncomputable instance instFullCore : InnerProductSpace.Core ℝ (BooleanFunction n) where toCore := instCore - definite := @inner_self_eq_zero n + definite := by exact @inner_self_eq_zero n noncomputable instance : NormedAddCommGroup (BooleanFunction n) := @InnerProductSpace.Core.toNormedAddCommGroup ℝ _ _ _ _ instFullCore diff --git a/Complexitylib/BooleanAnalysis/FourierExpansion/Internal.lean b/Complexitylib/BooleanAnalysis/FourierExpansion/Internal.lean index 9c7bef9f..185a3db1 100644 --- a/Complexitylib/BooleanAnalysis/FourierExpansion/Internal.lean +++ b/Complexitylib/BooleanAnalysis/FourierExpansion/Internal.lean @@ -3,8 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.BooleanAnalysis.FourierExpansion.Defs -import Mathlib.Analysis.InnerProductSpace.PiL2 + +module +public import Complexitylib.BooleanAnalysis.FourierExpansion.Defs +public import Mathlib.Analysis.InnerProductSpace.PiL2 +public import Std.Tactic.BVDecide.Normalize.Prop /-! # Chapter 1: Boolean functions and the Fourier expansion — Internal lemmas @@ -14,6 +17,9 @@ main results in `BooleanAnalysis.FourierExpansion` but are not intended for direct use by downstream code. -/ + +@[expose] public section + namespace Complexity namespace BooleanAnalysis.Internal diff --git a/Complexitylib/Circuits.lean b/Complexitylib/Circuits.lean index 7d66c1d6..788a4bee 100644 --- a/Complexitylib/Circuits.lean +++ b/Complexitylib/Circuits.lean @@ -3,59 +3,61 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Basic -import Complexitylib.Circuits.BitString -import Complexitylib.Circuits.Composition -import Complexitylib.Circuits.Dependency -import Complexitylib.Circuits.DecisionTree -import Complexitylib.Circuits.DecisionTree.Finite -import Complexitylib.Circuits.DecisionTree.NormalForm -import Complexitylib.Circuits.DecisionTree.Path -import Complexitylib.Circuits.DecisionTree.Restriction -import Complexitylib.Circuits.Formula -import Complexitylib.Circuits.Spira -import Complexitylib.Circuits.FormulaEncoding -import Complexitylib.Circuits.CircuitFormula -import Complexitylib.Circuits.Restriction -import Complexitylib.Circuits.RandomRestriction -import Complexitylib.Circuits.BranchingProgram -import Complexitylib.Circuits.Barrington -import Complexitylib.Circuits.BarringtonS5 -import Complexitylib.Circuits.BarringtonBridge -import Complexitylib.Circuits.BarringtonRepr -import Complexitylib.Circuits.BarringtonLength -import Complexitylib.Circuits.BarringtonCompiler -import Complexitylib.Circuits.BranchingProgramEncoding -import Complexitylib.Circuits.BarringtonCodeGenerator -import Complexitylib.Circuits.BarringtonFamily -import Complexitylib.Circuits.BarringtonConverse -import Complexitylib.Circuits.BarringtonTyped -import Complexitylib.Circuits.CircuitFormula.Family -import Complexitylib.Circuits.MultilinearExtension -import Complexitylib.Circuits.NormalForm -import Complexitylib.Circuits.NormalForm.Operations -import Complexitylib.Circuits.NormalForm.Restriction -import Complexitylib.Circuits.AndOrNot -import Complexitylib.Circuits.BasisHom -import Complexitylib.Circuits.Threshold -import Complexitylib.Circuits.Monotone -import Complexitylib.Circuits.KarchmerWigderson -import Complexitylib.Circuits.Encoding -import Complexitylib.Circuits.Family -import Complexitylib.Circuits.Encoding.Family -import Complexitylib.Circuits.Encoding.Machine -import Complexitylib.Circuits.XOR -import Complexitylib.Circuits.XOR.Restriction -import Complexitylib.Circuits.EssentialInput -import Complexitylib.Circuits.Shannon -import Complexitylib.Circuits.LowerBound -import Complexitylib.Circuits.Schnorr -import Complexitylib.Circuits.DepthClasses -import Complexitylib.Circuits.AC0 -import Complexitylib.Circuits.Nondeterminism -import Complexitylib.Circuits.Hardwiring -import Complexitylib.Circuits.Unrolling -import Complexitylib.Circuits.Valiant + +module +public import Complexitylib.Circuits.Basic +public import Complexitylib.Circuits.BitString +public import Complexitylib.Circuits.Composition +public import Complexitylib.Circuits.Dependency +public import Complexitylib.Circuits.DecisionTree +public import Complexitylib.Circuits.DecisionTree.Finite +public import Complexitylib.Circuits.DecisionTree.NormalForm +public import Complexitylib.Circuits.DecisionTree.Path +public import Complexitylib.Circuits.DecisionTree.Restriction +public import Complexitylib.Circuits.Formula +public import Complexitylib.Circuits.Spira +public import Complexitylib.Circuits.FormulaEncoding +public import Complexitylib.Circuits.CircuitFormula +public import Complexitylib.Circuits.Restriction +public import Complexitylib.Circuits.RandomRestriction +public import Complexitylib.Circuits.BranchingProgram +public import Complexitylib.Circuits.Barrington +public import Complexitylib.Circuits.BarringtonS5 +public import Complexitylib.Circuits.BarringtonBridge +public import Complexitylib.Circuits.BarringtonRepr +public import Complexitylib.Circuits.BarringtonLength +public import Complexitylib.Circuits.BarringtonCompiler +public import Complexitylib.Circuits.BranchingProgramEncoding +public import Complexitylib.Circuits.BarringtonCodeGenerator +public import Complexitylib.Circuits.BarringtonFamily +public import Complexitylib.Circuits.BarringtonConverse +public import Complexitylib.Circuits.BarringtonTyped +public import Complexitylib.Circuits.CircuitFormula.Family +public import Complexitylib.Circuits.MultilinearExtension +public import Complexitylib.Circuits.NormalForm +public import Complexitylib.Circuits.NormalForm.Operations +public import Complexitylib.Circuits.NormalForm.Restriction +public import Complexitylib.Circuits.AndOrNot +public import Complexitylib.Circuits.BasisHom +public import Complexitylib.Circuits.Threshold +public import Complexitylib.Circuits.Monotone +public import Complexitylib.Circuits.KarchmerWigderson +public import Complexitylib.Circuits.Encoding +public import Complexitylib.Circuits.Family +public import Complexitylib.Circuits.Encoding.Family +public import Complexitylib.Circuits.Encoding.Machine +public import Complexitylib.Circuits.XOR +public import Complexitylib.Circuits.XOR.Restriction +public import Complexitylib.Circuits.EssentialInput +public import Complexitylib.Circuits.Shannon +public import Complexitylib.Circuits.LowerBound +public import Complexitylib.Circuits.Schnorr +public import Complexitylib.Circuits.DepthClasses +public import Complexitylib.Circuits.AC0 +public import Complexitylib.Circuits.Nondeterminism +public import Complexitylib.Circuits.Hardwiring +public import Complexitylib.Circuits.Unrolling +public import Complexitylib.Circuits.Valiant /-! # Circuit Complexity Library diff --git a/Complexitylib/Circuits/AC0.lean b/Complexitylib/Circuits/AC0.lean index 34ba765b..182ff783 100644 --- a/Complexitylib/Circuits/AC0.lean +++ b/Complexitylib/Circuits/AC0.lean @@ -3,16 +3,17 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AC0.Defs -import Complexitylib.Circuits.AC0.NormalForm -import Complexitylib.Circuits.AC0.Normalization -import Complexitylib.Circuits.AC0.Restriction -import Complexitylib.Circuits.AC0.Switching -import Complexitylib.Circuits.AC0.Switching.Collection -import Complexitylib.Circuits.AC0.Switching.Parity -import Complexitylib.Circuits.AC0.Iteration -import Complexitylib.Circuits.AC0.Parity -import Complexitylib.Circuits.DepthClasses + +module +public import Complexitylib.Circuits.AC0.Defs +public import Complexitylib.Circuits.AC0.NormalForm +public import Complexitylib.Circuits.AC0.Normalization +public import Complexitylib.Circuits.AC0.Restriction +public import Complexitylib.Circuits.AC0.Switching +public import Complexitylib.Circuits.AC0.Switching.Collection +public import Complexitylib.Circuits.AC0.Switching.Parity +public import Complexitylib.Circuits.AC0.Iteration +public import Complexitylib.Circuits.AC0.Parity /-! # The class AC⁰ diff --git a/Complexitylib/Circuits/AC0/Defs.lean b/Complexitylib/Circuits/AC0/Defs.lean index 693ad72f..0d324529 100644 --- a/Complexitylib/Circuits/AC0/Defs.lean +++ b/Complexitylib/Circuits/AC0/Defs.lean @@ -3,12 +3,17 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.DepthClasses.Defs + +module +public import Mathlib.Data.Finset.Attr +public import Mathlib.Tactic.Bound.Init +public import Mathlib.Tactic.Finiteness.Attr +public import Mathlib.Tactic.SetLike /-! # AC0 -- compatibility import `Complexity.AC0` now lives with the complete `DEPTH`/`NC`/`AC` hierarchy in `Complexitylib.Circuits.DepthClasses.Defs`. This module preserves the original -import path. +public import path. -/ diff --git a/Complexitylib/Circuits/AC0/Iteration.lean b/Complexitylib/Circuits/AC0/Iteration.lean index 71e32f53..447f664e 100644 --- a/Complexitylib/Circuits/AC0/Iteration.lean +++ b/Complexitylib/Circuits/AC0/Iteration.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AC0.Iteration.Defs -import Complexitylib.Circuits.AC0.Iteration.Internal + +module +public import Complexitylib.Circuits.AC0.Iteration.Defs +public import Complexitylib.Circuits.AC0.Iteration.Internal /-! # Iterated switching for finite AC0 formulas @@ -18,6 +20,9 @@ Everything here is a statement about one finite formula and a finite product of restrictions. No uniformity or circuit-generator assumption is present. -/ + +@[expose] public section + namespace Complexity namespace RandomRestriction diff --git a/Complexitylib/Circuits/AC0/Iteration/Defs.lean b/Complexitylib/Circuits/AC0/Iteration/Defs.lean index 5471275e..b5579bf6 100644 --- a/Complexitylib/Circuits/AC0/Iteration/Defs.lean +++ b/Complexitylib/Circuits/AC0/Iteration/Defs.lean @@ -3,12 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AC0.Restriction -import Complexitylib.Circuits.AC0.Switching.Defs -import Complexitylib.Circuits.DecisionTree.NormalForm.Defs -import Complexitylib.Circuits.RandomRestriction.Defs -import Mathlib.Data.Fintype.BigOperators -import Mathlib.Data.Fintype.Card + +module +public import Complexitylib.Circuits.AC0.Switching.Defs +public import Complexitylib.Circuits.DecisionTree.NormalForm.Defs +public import Complexitylib.Circuits.RandomRestriction.Defs +public import Complexitylib.Circuits.AC0.NormalForm.Defs +public import Mathlib.Algebra.BigOperators.Group.Finset.Defs /-! # Iterated switching for AC0 formulas -- definitions @@ -21,6 +22,9 @@ This representation is finite and nonuniform. It contains restrictions and formula trees only; it does not contain or assume a circuit generator. -/ + +@[expose] public section + namespace Complexity open scoped BigOperators diff --git a/Complexitylib/Circuits/AC0/Iteration/Internal.lean b/Complexitylib/Circuits/AC0/Iteration/Internal.lean index b1dd6436..d3961a83 100644 --- a/Complexitylib/Circuits/AC0/Iteration/Internal.lean +++ b/Complexitylib/Circuits/AC0/Iteration/Internal.lean @@ -3,17 +3,22 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AC0.Iteration.Defs -import Complexitylib.Circuits.AC0.Switching.Internal -import Complexitylib.Circuits.DecisionTree.NormalForm.Internal -import Complexitylib.Circuits.RandomRestriction.Internal -import Mathlib.Algebra.BigOperators.Ring.Finset -import Mathlib.Algebra.Order.BigOperators.Group.Finset + +module +public import Complexitylib.Circuits.AC0.Iteration.Defs +public import Complexitylib.Circuits.AC0.Switching.Internal +public import Complexitylib.Circuits.DecisionTree.NormalForm.Internal +public import Mathlib.Algebra.BigOperators.Ring.Finset +public import Mathlib.Algebra.Order.BigOperators.Group.Finset +public import Complexitylib.Circuits.AC0.NormalForm.Internal /-! # Iterated switching for AC0 formulas -- proof internals -/ + +@[expose] public section + namespace Complexity namespace Switching diff --git a/Complexitylib/Circuits/AC0/NormalForm.lean b/Complexitylib/Circuits/AC0/NormalForm.lean index 8f186b65..01f0aba2 100644 --- a/Complexitylib/Circuits/AC0/NormalForm.lean +++ b/Complexitylib/Circuits/AC0/NormalForm.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AC0.NormalForm.Defs -import Complexitylib.Circuits.AC0.NormalForm.Internal + +module +public import Complexitylib.Circuits.AC0.NormalForm.Defs +public import Complexitylib.Circuits.AC0.NormalForm.Internal /-! # Negation-normal unbounded formulas for AC0 @@ -14,6 +16,9 @@ This public surface provides the semantic and quantitative De Morgan laws for restriction arguments. -/ + +@[expose] public section + namespace Complexity namespace AC0Formula diff --git a/Complexitylib/Circuits/AC0/NormalForm/Defs.lean b/Complexitylib/Circuits/AC0/NormalForm/Defs.lean index 0c06593e..f46ad231 100644 --- a/Complexitylib/Circuits/AC0/NormalForm/Defs.lean +++ b/Complexitylib/Circuits/AC0/NormalForm/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AndOrNot.Defs -import Complexitylib.Circuits.NormalForm.Defs + +module +public import Complexitylib.Circuits.AndOrNot.Defs +public import Complexitylib.Circuits.NormalForm.Defs /-! # Negation-normal unbounded formulas for AC0 @@ -20,6 +22,9 @@ direct structural induction principle for unbounded formulas; `ofList` and denote `true` and `false`, respectively. -/ + +@[expose] public section + namespace Complexity mutual diff --git a/Complexitylib/Circuits/AC0/NormalForm/Internal.lean b/Complexitylib/Circuits/AC0/NormalForm/Internal.lean index b22390a9..022a9abd 100644 --- a/Complexitylib/Circuits/AC0/NormalForm/Internal.lean +++ b/Complexitylib/Circuits/AC0/NormalForm/Internal.lean @@ -3,12 +3,17 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AC0.NormalForm.Defs + +module +public import Complexitylib.Circuits.AC0.NormalForm.Defs /-! # Negation-normal unbounded formulas -- proof internals -/ + +@[expose] public section + namespace Complexity namespace AC0Formula diff --git a/Complexitylib/Circuits/AC0/Normalization.lean b/Complexitylib/Circuits/AC0/Normalization.lean index 1fd49502..76e0c8ce 100644 --- a/Complexitylib/Circuits/AC0/Normalization.lean +++ b/Complexitylib/Circuits/AC0/Normalization.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AC0.NormalForm -import Complexitylib.Circuits.AC0.Normalization.Defs -import Complexitylib.Circuits.AC0.Normalization.Internal + +module +public import Complexitylib.Circuits.AC0.Normalization.Defs +public import Complexitylib.Circuits.AC0.Normalization.Internal /-! # AC0 circuit normalization @@ -21,6 +22,9 @@ For constant-depth, polynomial-gate circuit families this bound is polynomial. No uniformity assumption is used. -/ + +@[expose] public section + namespace Complexity /-- A gate has at most two distinct signed occurrences of each available diff --git a/Complexitylib/Circuits/AC0/Normalization/Defs.lean b/Complexitylib/Circuits/AC0/Normalization/Defs.lean index b2328d7d..0f92134e 100644 --- a/Complexitylib/Circuits/AC0/Normalization/Defs.lean +++ b/Complexitylib/Circuits/AC0/Normalization/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AC0.NormalForm.Defs + +module +public import Complexitylib.Circuits.AC0.NormalForm.Defs /-! # Normalizing unbounded AND/OR circuits to negation-normal formulas @@ -15,6 +17,9 @@ model counts gates rather than wire incidences, so duplicate inputs must not inflate the normalized formula. -/ + +@[expose] public section + namespace Complexity /-- The distinct signed source wires read by a gate, after composing every diff --git a/Complexitylib/Circuits/AC0/Normalization/Internal.lean b/Complexitylib/Circuits/AC0/Normalization/Internal.lean index 30d83684..9e46c207 100644 --- a/Complexitylib/Circuits/AC0/Normalization/Internal.lean +++ b/Complexitylib/Circuits/AC0/Normalization/Internal.lean @@ -3,14 +3,35 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AC0.NormalForm.Internal -import Complexitylib.Circuits.AC0.Normalization.Defs -import Mathlib.Tactic + +module +public import Complexitylib.Circuits.AC0.NormalForm.Internal +public import Complexitylib.Circuits.AC0.Normalization.Defs +public import Mathlib.Analysis.SpecialFunctions.Pow.NNReal +public import Mathlib.Tactic.Measurability.Init +public import Mathlib.Tactic.NormNum.BigOperators +public import Mathlib.Tactic.NormNum.Irrational +public import Mathlib.Tactic.NormNum.IsCoprime +public import Mathlib.Tactic.NormNum.IsSquare +public import Mathlib.Tactic.NormNum.LegendreSymbol +public import Mathlib.Tactic.NormNum.ModEq +public import Mathlib.Tactic.NormNum.NatFactorial +public import Mathlib.Tactic.NormNum.NatFib +public import Mathlib.Tactic.NormNum.NatLog +public import Mathlib.Tactic.NormNum.NatSqrt +public import Mathlib.Tactic.NormNum.Ordinal +public import Mathlib.Tactic.NormNum.Parity +public import Mathlib.Tactic.NormNum.Prime +public import Mathlib.Tactic.NormNum.RealSqrt +public import Mathlib.Tactic.ReduceModChar /-! # AC0 circuit normalization -- proof internals -/ + +@[expose] public section + namespace Complexity private theorem foldl_or_eq_true (n : ℕ) (values : Fin n → Bool) : diff --git a/Complexitylib/Circuits/AC0/Parity.lean b/Complexitylib/Circuits/AC0/Parity.lean index c7a3f17c..b7ace146 100644 --- a/Complexitylib/Circuits/AC0/Parity.lean +++ b/Complexitylib/Circuits/AC0/Parity.lean @@ -3,9 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AC0.Iteration -import Complexitylib.Circuits.AC0.Parity.Internal -import Complexitylib.Circuits.XOR.Restriction + +module +public import Complexitylib.Circuits.AC0.Parity.Internal /-! # Parity versus finite AC0 formulas @@ -24,6 +24,9 @@ arithmetic: instantiate the parameters against a polynomial formula-size bound and a fixed depth. -/ + +@[expose] public section + namespace Complexity namespace AC0Formula diff --git a/Complexitylib/Circuits/AC0/Parity/Internal.lean b/Complexitylib/Circuits/AC0/Parity/Internal.lean index 3af84c3a..11383521 100644 --- a/Complexitylib/Circuits/AC0/Parity/Internal.lean +++ b/Complexitylib/Circuits/AC0/Parity/Internal.lean @@ -3,13 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AC0.Iteration.Internal -import Complexitylib.Circuits.XOR.Restriction.Internal + +module +public import Complexitylib.Circuits.AC0.Iteration.Internal +public import Complexitylib.Circuits.XOR.Restriction.Internal /-! # Parity versus finite AC0 formulas -- proof internals -/ + +@[expose] public section + namespace Complexity namespace AC0Formula diff --git a/Complexitylib/Circuits/AC0/Restriction.lean b/Complexitylib/Circuits/AC0/Restriction.lean index eb070f1b..8b2d2de7 100644 --- a/Complexitylib/Circuits/AC0/Restriction.lean +++ b/Complexitylib/Circuits/AC0/Restriction.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AC0.NormalForm -import Complexitylib.Circuits.Restriction + +module +public import Complexitylib.Circuits.Restriction +public import Complexitylib.Circuits.AC0.NormalForm.Defs /-! # Restricting negation-normal AC0 formulas @@ -15,6 +17,9 @@ operation, tree size and depth are preserved exactly, and variable support is filtered to the free variables. -/ + +@[expose] public section + namespace Complexity namespace AC0Formula diff --git a/Complexitylib/Circuits/AC0/Switching.lean b/Complexitylib/Circuits/AC0/Switching.lean index fb2f36aa..d370723d 100644 --- a/Complexitylib/Circuits/AC0/Switching.lean +++ b/Complexitylib/Circuits/AC0/Switching.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AC0.Switching.Defs -import Complexitylib.Circuits.AC0.Switching.Internal + +module +public import Complexitylib.Circuits.AC0.Switching.Defs +public import Complexitylib.Circuits.AC0.Switching.Internal /-! # Switching-lemma substrate @@ -16,6 +18,9 @@ consistent DNFs. The latter replays the canonical complete-block path from bounded literal positions, branch bits, and phase markers. -/ + +@[expose] public section + namespace Complexity namespace Switching diff --git a/Complexitylib/Circuits/AC0/Switching/Collection.lean b/Complexitylib/Circuits/AC0/Switching/Collection.lean index d728482f..7e32c990 100644 --- a/Complexitylib/Circuits/AC0/Switching/Collection.lean +++ b/Complexitylib/Circuits/AC0/Switching/Collection.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AC0.Switching -import Complexitylib.Circuits.AC0.Switching.Collection.Defs -import Complexitylib.Circuits.AC0.Switching.Collection.Internal + +module +public import Complexitylib.Circuits.AC0.Switching.Collection.Defs +public import Complexitylib.Circuits.AC0.Switching.Collection.Internal /-! # Simultaneous switching for finite formula collections @@ -16,6 +17,9 @@ collections are finite nonuniform objects; no generator or uniformity assumption is involved. -/ + +@[expose] public section + namespace Complexity namespace DNF diff --git a/Complexitylib/Circuits/AC0/Switching/Collection/Defs.lean b/Complexitylib/Circuits/AC0/Switching/Collection/Defs.lean index 7c8706d4..2b9f979a 100644 --- a/Complexitylib/Circuits/AC0/Switching/Collection/Defs.lean +++ b/Complexitylib/Circuits/AC0/Switching/Collection/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AC0.Switching.Defs + +module +public import Complexitylib.Circuits.AC0.Switching.Defs /-! # Simultaneous switching for finite formula collections -- definitions @@ -12,6 +14,9 @@ These are finite, nonuniform collections indexed by `Fin formulaCount`; they are unrelated to uniform circuit-family generators. -/ + +@[expose] public section + namespace Complexity namespace DNF diff --git a/Complexitylib/Circuits/AC0/Switching/Collection/Internal.lean b/Complexitylib/Circuits/AC0/Switching/Collection/Internal.lean index db0aaee8..e388c3eb 100644 --- a/Complexitylib/Circuits/AC0/Switching/Collection/Internal.lean +++ b/Complexitylib/Circuits/AC0/Switching/Collection/Internal.lean @@ -3,16 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AC0.Switching.Collection.Defs -import Complexitylib.Circuits.AC0.Switching.Internal -import Complexitylib.Circuits.RandomRestriction.Internal -import Mathlib.Algebra.BigOperators.Ring.Finset -import Mathlib.Algebra.Order.BigOperators.Group.Finset + +module +public import Complexitylib.Circuits.AC0.Switching.Collection.Defs +public import Complexitylib.Circuits.AC0.Switching.Internal +public import Mathlib.Algebra.BigOperators.Ring.Finset +public import Mathlib.Algebra.Order.BigOperators.Group.Finset /-! # Simultaneous switching for finite formula collections -- proof internals -/ + +@[expose] public section + namespace Complexity namespace Switching diff --git a/Complexitylib/Circuits/AC0/Switching/Defs.lean b/Complexitylib/Circuits/AC0/Switching/Defs.lean index b6c1907f..f8251329 100644 --- a/Complexitylib/Circuits/AC0/Switching/Defs.lean +++ b/Complexitylib/Circuits/AC0/Switching/Defs.lean @@ -3,10 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.DecisionTree.Block.Defs -import Complexitylib.Circuits.DecisionTree.Finite.Defs -import Complexitylib.Circuits.NormalForm.Restriction -import Complexitylib.Circuits.RandomRestriction.Defs + +module +public import Complexitylib.Circuits.DecisionTree.Block.Defs +public import Complexitylib.Circuits.NormalForm.Restriction /-! # Switching-lemma substrate -- definitions @@ -22,6 +22,9 @@ with the number of variables in the DNF, and its correctness proof shows that each recursive query removes its variable from support. -/ + +@[expose] public section + namespace Complexity namespace Switching diff --git a/Complexitylib/Circuits/AC0/Switching/Internal.lean b/Complexitylib/Circuits/AC0/Switching/Internal.lean index 5bdb45df..68d69e7a 100644 --- a/Complexitylib/Circuits/AC0/Switching/Internal.lean +++ b/Complexitylib/Circuits/AC0/Switching/Internal.lean @@ -3,16 +3,21 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AC0.Switching.Defs -import Complexitylib.Circuits.DecisionTree.Block -import Complexitylib.Circuits.DecisionTree.Finite -import Complexitylib.Circuits.DecisionTree.Path -import Complexitylib.Circuits.RandomRestriction.Internal + +module +public import Complexitylib.Circuits.AC0.Switching.Defs +public import Complexitylib.Circuits.DecisionTree.Finite +public import Complexitylib.Circuits.RandomRestriction.Internal +public import Complexitylib.Circuits.DecisionTree.Block.Internal +public import Complexitylib.Circuits.DecisionTree.Path.Internal /-! # Switching-lemma substrate -- proof internals -/ + +@[expose] public section + namespace Complexity namespace Switching diff --git a/Complexitylib/Circuits/AC0/Switching/Parity.lean b/Complexitylib/Circuits/AC0/Switching/Parity.lean index 9f03fa33..66d11cbf 100644 --- a/Complexitylib/Circuits/AC0/Switching/Parity.lean +++ b/Complexitylib/Circuits/AC0/Switching/Parity.lean @@ -3,10 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AC0.Switching -import Complexitylib.Circuits.AC0.Switching.Parity.Internal -import Complexitylib.Circuits.RandomRestriction -import Complexitylib.Circuits.XOR.Restriction + +module +public import Complexitylib.Circuits.AC0.Switching.Parity.Internal /-! # Switching lemmas against parity @@ -21,6 +20,9 @@ formulas: contradictory DNF terms and tautological CNF clauses are cleaned without changing semantics or increasing width. -/ + +@[expose] public section + namespace Complexity namespace DNF diff --git a/Complexitylib/Circuits/AC0/Switching/Parity/Internal.lean b/Complexitylib/Circuits/AC0/Switching/Parity/Internal.lean index 1d44134e..aded5128 100644 --- a/Complexitylib/Circuits/AC0/Switching/Parity/Internal.lean +++ b/Complexitylib/Circuits/AC0/Switching/Parity/Internal.lean @@ -3,14 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AC0.Switching.Internal -import Complexitylib.Circuits.RandomRestriction.Internal -import Complexitylib.Circuits.XOR.Restriction.Internal + +module +public import Complexitylib.Circuits.AC0.Switching.Internal +public import Complexitylib.Circuits.XOR.Restriction.Internal /-! # Switching lemmas against parity -- proof internals -/ + +@[expose] public section + namespace Complexity namespace DNF diff --git a/Complexitylib/Circuits/AndOrNot.lean b/Complexitylib/Circuits/AndOrNot.lean index 18b96920..6d679627 100644 --- a/Complexitylib/Circuits/AndOrNot.lean +++ b/Complexitylib/Circuits/AndOrNot.lean @@ -3,9 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AndOrNot.Defs -import Complexitylib.Circuits.Internal.AndOrNot -import Complexitylib.Circuits.Internal.Simulation + +module +public import Complexitylib.Circuits.AndOrNot.Defs +public import Complexitylib.Circuits.Internal.Simulation /-! # AND/OR/NOT Basis @@ -27,6 +28,9 @@ This module provides the AND/OR basis definitions and completeness results. * `CompileAndOr.compileFn_size_le` — its quantitative size overhead -/ + +@[expose] public section + namespace Complexity namespace CompileAndOr diff --git a/Complexitylib/Circuits/AndOrNot/Defs.lean b/Complexitylib/Circuits/AndOrNot/Defs.lean index 5344d7bd..c2702b08 100644 --- a/Complexitylib/Circuits/AndOrNot/Defs.lean +++ b/Complexitylib/Circuits/AndOrNot/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Basic + +module +public import Complexitylib.Circuits.Basic /-! # AND/OR/NOT Basis — Definitions @@ -20,6 +22,9 @@ used throughout the circuit complexity library. * `Basis.andOr2` — fan-in exactly 2 AND/OR basis (used in Shannon/Schnorr bounds) -/ + +@[expose] public section + namespace Complexity /-- Operations in an AND/OR basis. Negation is handled by per-input flags diff --git a/Complexitylib/Circuits/Barrington.lean b/Complexitylib/Circuits/Barrington.lean index b3f4ee46..8ea337ed 100644 --- a/Complexitylib/Circuits/Barrington.lean +++ b/Complexitylib/Circuits/Barrington.lean @@ -3,9 +3,15 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BranchingProgram -import Mathlib.Algebra.Group.Commutator -import Mathlib.Data.List.ModifyLast + +module +public import Complexitylib.Circuits.BranchingProgram +public import Mathlib.Algebra.Group.Commutator +public import Mathlib.Data.List.ModifyLast +public import Mathlib.Algebra.Group.Nat.Defs +public import Mathlib.Data.List.Induction +public import Std.Tactic.BVDecide.Normalize.Bool +public import Std.Tactic.BVDecide.Normalize.Prop /-! # Toward Barrington's theorem: the group-theoretic core @@ -44,6 +50,9 @@ proved here are the moves in Barrington's inductive construction: `BP.Computes_not_compact`, `BP.Computes_and`. -/ + +@[expose] public section + open scoped commutatorElement namespace Complexity diff --git a/Complexitylib/Circuits/BarringtonBridge.lean b/Complexitylib/Circuits/BarringtonBridge.lean index d1b82e0f..10a3c327 100644 --- a/Complexitylib/Circuits/BarringtonBridge.lean +++ b/Complexitylib/Circuits/BarringtonBridge.lean @@ -3,9 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Barrington -import Complexitylib.Circuits.BarringtonS5 -import Mathlib.GroupTheory.Perm.Cycle.Type + +module +public import Complexitylib.Circuits.Barrington +public import Complexitylib.Circuits.BarringtonS5 /-! # Barrington: bridging the abstract move-set to the `S₅` cycle algebra @@ -31,6 +32,9 @@ actually consumes — where the *target* representing cycle is an arbitrary the formula induction needs. -/ + +@[expose] public section + open scoped commutatorElement open Equiv diff --git a/Complexitylib/Circuits/BarringtonCodeGenerator.lean b/Complexitylib/Circuits/BarringtonCodeGenerator.lean index 1883598b..560099ac 100644 --- a/Complexitylib/Circuits/BarringtonCodeGenerator.lean +++ b/Complexitylib/Circuits/BarringtonCodeGenerator.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BarringtonCodeGenerator.Defs -import Complexitylib.Circuits.BarringtonCodeGenerator.Internal + +module +public import Complexitylib.Circuits.BarringtonCodeGenerator.Defs +public import Complexitylib.Circuits.BarringtonCodeGenerator.Internal /-! # Bitstring-level Barrington code generator @@ -27,6 +29,9 @@ evaluation matches the source formula, and its instruction count is at most - `barringtonCompileCode_spec` -- decoded semantics and Barrington length bound. -/ + +@[expose] public section + namespace Complexity /-- Every variable referenced by a formula is at most its canonical code diff --git a/Complexitylib/Circuits/BarringtonCodeGenerator/Defs.lean b/Complexitylib/Circuits/BarringtonCodeGenerator/Defs.lean index af88cf5a..7b3852b6 100644 --- a/Complexitylib/Circuits/BarringtonCodeGenerator/Defs.lean +++ b/Complexitylib/Circuits/BarringtonCodeGenerator/Defs.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BarringtonCompiler.Defs -import Complexitylib.Circuits.BranchingProgramEncoding.Defs -import Complexitylib.Circuits.FormulaEncoding.Defs + +module +public import Complexitylib.Circuits.BranchingProgramEncoding.Defs +public import Complexitylib.Circuits.FormulaEncoding.Defs /-! # Pure bitstring target for the uniform Barrington generator @@ -17,6 +18,9 @@ program. Malformed formula codes map to the empty string; valid program codes are always nonempty because they start with an instruction-count field. -/ + +@[expose] public section + namespace Complexity /-- Decode a formula code and emit the canonical code of its compiled diff --git a/Complexitylib/Circuits/BarringtonCodeGenerator/Internal.lean b/Complexitylib/Circuits/BarringtonCodeGenerator/Internal.lean index cb6e6c2f..b4f0ecc4 100644 --- a/Complexitylib/Circuits/BarringtonCodeGenerator/Internal.lean +++ b/Complexitylib/Circuits/BarringtonCodeGenerator/Internal.lean @@ -3,15 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BarringtonCodeGenerator.Defs -import Complexitylib.Circuits.BarringtonCompiler -import Complexitylib.Circuits.BranchingProgramEncoding -import Complexitylib.Circuits.FormulaEncoding + +module +public import Complexitylib.Circuits.BarringtonCodeGenerator.Defs +public import Complexitylib.Circuits.BranchingProgramEncoding +public import Complexitylib.Circuits.FormulaEncoding /-! # Pure Barrington code-generator internals -/ + +@[expose] public section + namespace Complexity /-- Internal bound placing every referenced variable below the formula-code diff --git a/Complexitylib/Circuits/BarringtonCompiler.lean b/Complexitylib/Circuits/BarringtonCompiler.lean index cbff84d7..b6febc46 100644 --- a/Complexitylib/Circuits/BarringtonCompiler.lean +++ b/Complexitylib/Circuits/BarringtonCompiler.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BarringtonCompiler.Defs -import Complexitylib.Circuits.BarringtonCompiler.Internal + +module +public import Complexitylib.Circuits.BarringtonCompiler.Defs +public import Complexitylib.Circuits.BarringtonCompiler.Internal /-! # An executable Barrington compiler @@ -33,6 +35,9 @@ proof, not extraction of program data from an existential theorem. Barrington theorem for the fixed canonical target cycle. -/ + +@[expose] public section + open scoped commutatorElement open Equiv diff --git a/Complexitylib/Circuits/BarringtonCompiler/Defs.lean b/Complexitylib/Circuits/BarringtonCompiler/Defs.lean index b9ca411b..b1b89d60 100644 --- a/Complexitylib/Circuits/BarringtonCompiler/Defs.lean +++ b/Complexitylib/Circuits/BarringtonCompiler/Defs.lean @@ -3,9 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Barrington -import Complexitylib.Circuits.BarringtonS5 -import Complexitylib.Circuits.Formula + +module +public import Complexitylib.Circuits.Barrington +public import Complexitylib.Circuits.Formula +public import Mathlib.GroupTheory.Perm.Fin +public import Mathlib.Tactic.NormNum.Prime /-! # An executable Barrington compiler -- definitions @@ -15,6 +18,9 @@ The original existence proof chooses conjugators and commutator factors inside the target-cycle decomposition and the resulting formula compiler executable. -/ + +@[expose] public section + open scoped commutatorElement open Equiv diff --git a/Complexitylib/Circuits/BarringtonCompiler/Internal.lean b/Complexitylib/Circuits/BarringtonCompiler/Internal.lean index f1219847..ace6ff1e 100644 --- a/Complexitylib/Circuits/BarringtonCompiler/Internal.lean +++ b/Complexitylib/Circuits/BarringtonCompiler/Internal.lean @@ -3,13 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BarringtonCompiler.Defs -import Complexitylib.Circuits.BarringtonLength + +module +public import Complexitylib.Circuits.BarringtonCompiler.Defs +public import Complexitylib.Circuits.BarringtonLength +public import Std.Tactic.BVDecide.Normalize.BitVec /-! # An executable Barrington compiler -- proof internals -/ + +@[expose] public section + open scoped commutatorElement open Equiv diff --git a/Complexitylib/Circuits/BarringtonConverse.lean b/Complexitylib/Circuits/BarringtonConverse.lean index 6836bb0b..7e0e7bc5 100644 --- a/Complexitylib/Circuits/BarringtonConverse.lean +++ b/Complexitylib/Circuits/BarringtonConverse.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BarringtonConverse.Internal + +module +public import Complexitylib.Circuits.BarringtonConverse.Internal /-! # The converse direction of Barrington's theorem @@ -26,6 +28,9 @@ equivalence under the library's total-assignment family convention. total-assignment equivalence -/ + +@[expose] public section + namespace Complexity /-- Taking a binary ceiling logarithm of a polynomial bound yields an affine diff --git a/Complexitylib/Circuits/BarringtonConverse/Defs.lean b/Complexitylib/Circuits/BarringtonConverse/Defs.lean index 5dd91303..3b5709a9 100644 --- a/Complexitylib/Circuits/BarringtonConverse/Defs.lean +++ b/Complexitylib/Circuits/BarringtonConverse/Defs.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BarringtonFamily -import Mathlib.Data.List.OfFn + +module +public import Complexitylib.Circuits.BarringtonFamily /-! # The converse direction of Barrington's theorem -- definitions @@ -20,6 +21,9 @@ programs are evaluated on total assignments `ℕ → Bool`, while the family ind records the input-length parameter controlling depth and program length. -/ + +@[expose] public section + namespace Complexity namespace BoolFormula diff --git a/Complexitylib/Circuits/BarringtonConverse/Internal.lean b/Complexitylib/Circuits/BarringtonConverse/Internal.lean index 93b2eeb3..2f7d7c8b 100644 --- a/Complexitylib/Circuits/BarringtonConverse/Internal.lean +++ b/Complexitylib/Circuits/BarringtonConverse/Internal.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BarringtonConverse.Defs + +module +public import Complexitylib.Circuits.BarringtonConverse.Defs /-! # The converse direction of Barrington's theorem -- proof internals @@ -12,6 +14,9 @@ This file proves correctness and logarithmic depth for balanced branching-progra evaluation, then lifts that construction to polynomial-length families. -/ + +@[expose] public section + open Equiv namespace Complexity diff --git a/Complexitylib/Circuits/BarringtonFamily.lean b/Complexitylib/Circuits/BarringtonFamily.lean index 4073459e..26153bf7 100644 --- a/Complexitylib/Circuits/BarringtonFamily.lean +++ b/Complexitylib/Circuits/BarringtonFamily.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BarringtonLength -import Mathlib.Data.Nat.Log + +module +public import Complexitylib.Circuits.BarringtonLength +public import Mathlib.Data.Nat.Log /-! # Barrington at the family level: `NC¹ ⊆` polynomial-size width-`5` branching programs @@ -31,6 +33,9 @@ applying the per-formula bound pointwise, together with the arithmetic fact that - `FormulaFamily.logDepth_polyLength_bp` — the family-level containment. -/ + +@[expose] public section + open Equiv namespace Complexity diff --git a/Complexitylib/Circuits/BarringtonLength.lean b/Complexitylib/Circuits/BarringtonLength.lean index 6dfd8df8..110f1550 100644 --- a/Complexitylib/Circuits/BarringtonLength.lean +++ b/Complexitylib/Circuits/BarringtonLength.lean @@ -3,10 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BarringtonBridge -import Complexitylib.Circuits.Formula -import Mathlib.Tactic.Linarith -import Mathlib.Data.Nat.Log + +module +public import Complexitylib.Circuits.BarringtonBridge +public import Complexitylib.Circuits.Formula +public import Mathlib.Tactic.Linarith.Frontend /-! # Barrington's theorem with a length bound @@ -37,6 +38,9 @@ the classical `4 ^ depth` bound. the textbook `4 ^ depth` length bound. -/ + +@[expose] public section + open scoped commutatorElement open Equiv diff --git a/Complexitylib/Circuits/BarringtonRepr.lean b/Complexitylib/Circuits/BarringtonRepr.lean index 5b887f76..73b14356 100644 --- a/Complexitylib/Circuits/BarringtonRepr.lean +++ b/Complexitylib/Circuits/BarringtonRepr.lean @@ -3,12 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Barrington -import Complexitylib.Circuits.BarringtonS5 -import Complexitylib.Circuits.BarringtonBridge -import Complexitylib.Circuits.Formula -import Mathlib.GroupTheory.Perm.Cycle.Type -import Mathlib.GroupTheory.Perm.Fin + +module +public import Complexitylib.Circuits.Barrington +public import Complexitylib.Circuits.BarringtonBridge +public import Complexitylib.Circuits.Formula /-! # Barrington's theorem (representation form) @@ -43,6 +42,9 @@ converse live in `BarringtonFamily.lean` and `BarringtonConverse.lean`. and a query point `x` whose orbit under the program's value decides `φ`. -/ + +@[expose] public section + open scoped commutatorElement open Equiv diff --git a/Complexitylib/Circuits/BarringtonS5.lean b/Complexitylib/Circuits/BarringtonS5.lean index 2d368a36..825690ba 100644 --- a/Complexitylib/Circuits/BarringtonS5.lean +++ b/Complexitylib/Circuits/BarringtonS5.lean @@ -3,12 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.GroupTheory.Perm.Fin -import Mathlib.GroupTheory.Perm.Cycle.Type -import Mathlib.GroupTheory.Perm.Cycle.Concrete -import Mathlib.Algebra.Group.Commutator -import Mathlib.Tactic.NormNum.Prime -import Mathlib.Tactic.Common + +module +public import Mathlib.GroupTheory.Perm.Cycle.Type +public import Mathlib.Tactic.NormNum.Prime +public import Mathlib.Logic.Equiv.Fin.Rotate /-! # The `S₅` five-cycle commutator (Barrington's non-solvability input) @@ -44,6 +43,9 @@ output cycle. commutator of two `5`-cycles. -/ + +@[expose] public section + open scoped commutatorElement open Equiv diff --git a/Complexitylib/Circuits/BarringtonTyped.lean b/Complexitylib/Circuits/BarringtonTyped.lean index 58607595..6582948d 100644 --- a/Complexitylib/Circuits/BarringtonTyped.lean +++ b/Complexitylib/Circuits/BarringtonTyped.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BarringtonTyped.Defs -import Complexitylib.Circuits.BarringtonTyped.Internal + +module +public import Complexitylib.Circuits.BarringtonTyped.Defs +public import Complexitylib.Circuits.BarringtonTyped.Internal /-! # Fixed-arity nonuniform Barrington theorem @@ -22,6 +24,9 @@ model stores the unique zero-input answer separately. * `barrington_equivalence` -- the typed nonuniform class equivalence. -/ + +@[expose] public section + namespace Complexity /-- Every fixed-arity logarithmic-depth formula family has an equivalent diff --git a/Complexitylib/Circuits/BarringtonTyped/Defs.lean b/Complexitylib/Circuits/BarringtonTyped/Defs.lean index b8a61016..ce517826 100644 --- a/Complexitylib/Circuits/BarringtonTyped/Defs.lean +++ b/Complexitylib/Circuits/BarringtonTyped/Defs.lean @@ -3,8 +3,15 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BarringtonConverse.Defs -import Complexitylib.Circuits.BitString + +module +public import Complexitylib.Circuits.BitString +public import Complexitylib.Circuits.BranchingProgram +public import Complexitylib.Circuits.Formula +public import Mathlib.Data.Nat.Log +public import Mathlib.Data.Sym.Sym2.Init +public import Mathlib.Tactic.NormNum.GCD +public import Mathlib.Tactic.NormNum.Prime /-! # Fixed-arity nonuniform Barrington families -- definitions @@ -24,6 +31,9 @@ Both objects denote `BoolFunFamily`, so the eventual equivalence has the correct fixed-arity semantic domain. -/ + +@[expose] public section + namespace Complexity /-- A nonuniform family of formulas with an explicit arity bound on every diff --git a/Complexitylib/Circuits/BarringtonTyped/Internal.lean b/Complexitylib/Circuits/BarringtonTyped/Internal.lean index 886d4740..9694c0b6 100644 --- a/Complexitylib/Circuits/BarringtonTyped/Internal.lean +++ b/Complexitylib/Circuits/BarringtonTyped/Internal.lean @@ -3,14 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BarringtonCompiler -import Complexitylib.Circuits.BarringtonConverse -import Complexitylib.Circuits.BarringtonTyped.Defs + +module +public import Complexitylib.Circuits.BarringtonCompiler +public import Complexitylib.Circuits.BarringtonConverse +public import Complexitylib.Circuits.BarringtonTyped.Defs /-! # Fixed-arity nonuniform Barrington families -- proof internals -/ + +@[expose] public section + namespace Complexity /-- Compile every positive-arity formula through the fixed Barrington target. diff --git a/Complexitylib/Circuits/Basic.lean b/Complexitylib/Circuits/Basic.lean index 47d371f0..a07da0cf 100644 --- a/Complexitylib/Circuits/Basic.lean +++ b/Complexitylib/Circuits/Basic.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Data.Nat.Lattice + +module +public import Mathlib.Data.Nat.Lattice /-! # Boolean Circuit Complexity @@ -29,6 +31,9 @@ establishes the circuit size complexity measure for Boolean functions. * `Circuit.sizeComplexity_pos` — for complete bases, size complexity is positive -/ + +@[expose] public section + namespace Complexity /-- A BitString of length `n`. -/ @@ -239,7 +244,8 @@ over `B` computes it. -/ def Realizable (B : Basis) (f : BitString N → Bool) : Prop := ∃ G, ∃ c : Circuit B N 1 G, (fun x => (c.eval x) 0) = f -private def realizationSizes (B : Basis) (f : BitString N → Bool) : Set Nat := +/-- Sizes of all single-output circuits over `B` that realize `f`. -/ +def realizationSizes (B : Basis) (f : BitString N → Bool) : Set Nat := {s | ∃ G, ∃ c : Circuit B N 1 G, c.size = s ∧ (fun x => (c.eval x) 0) = f} diff --git a/Complexitylib/Circuits/BasisHom.lean b/Complexitylib/Circuits/BasisHom.lean index 788bcc70..d06e92e1 100644 --- a/Complexitylib/Circuits/BasisHom.lean +++ b/Complexitylib/Circuits/BasisHom.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BasisHom.Defs -import Complexitylib.Circuits.BasisHom.Internal + +module +public import Complexitylib.Circuits.BasisHom.Defs +public import Complexitylib.Circuits.BasisHom.Internal /-! # Semantics-preserving maps between circuit bases @@ -14,6 +16,9 @@ Boolean semantics. Circuit transport along a homomorphism preserves semantics, gate count, wiring, and depth exactly. -/ + +@[expose] public section + namespace Complexity namespace Gate diff --git a/Complexitylib/Circuits/BasisHom/Defs.lean b/Complexitylib/Circuits/BasisHom/Defs.lean index 458d71dc..97f128c1 100644 --- a/Complexitylib/Circuits/BasisHom/Defs.lean +++ b/Complexitylib/Circuits/BasisHom/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Family.Defs + +module +public import Complexitylib.Circuits.Family.Defs /-! # Semantics-preserving maps between circuit bases -- definitions @@ -16,6 +18,9 @@ labels; fan-in, wiring, negation flags, gate count, and circuit topology are preserved exactly. -/ + +@[expose] public section + namespace Complexity /-- A semantics-preserving operation map between Boolean bases. -/ diff --git a/Complexitylib/Circuits/BasisHom/Internal.lean b/Complexitylib/Circuits/BasisHom/Internal.lean index 1e681a68..6d67382a 100644 --- a/Complexitylib/Circuits/BasisHom/Internal.lean +++ b/Complexitylib/Circuits/BasisHom/Internal.lean @@ -3,12 +3,17 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BasisHom.Defs + +module +public import Complexitylib.Circuits.BasisHom.Defs /-! # Semantics-preserving maps between circuit bases -- proof internals -/ + +@[expose] public section + namespace Complexity namespace Gate diff --git a/Complexitylib/Circuits/BitString.lean b/Complexitylib/Circuits/BitString.lean index 04b11c00..75f50017 100644 --- a/Complexitylib/Circuits/BitString.lean +++ b/Complexitylib/Circuits/BitString.lean @@ -3,8 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Basic -import Mathlib.Data.List.OfFn + +module +public import Complexitylib.Circuits.Basic /-! # Fixed-length bit strings and lists @@ -17,6 +18,9 @@ The variable-length equivalence is already available from Mathlib as `List.equivSigmaTuple : List Bool ≃ Σ n, BitString n`. -/ + +@[expose] public section + namespace Complexity namespace BitString diff --git a/Complexitylib/Circuits/BranchingProgram.lean b/Complexitylib/Circuits/BranchingProgram.lean index 3230980f..d4c61989 100644 --- a/Complexitylib/Circuits/BranchingProgram.lean +++ b/Complexitylib/Circuits/BranchingProgram.lean @@ -3,9 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.GroupTheory.Perm.Basic -import Mathlib.Algebra.BigOperators.Group.List.Basic -import Mathlib.Data.Finset.Basic + +module +public import Mathlib.Algebra.BigOperators.Group.List.Defs +public import Mathlib.Algebra.Group.End +public import Mathlib.Data.Finset.Attr +public import Mathlib.Data.Finset.Dedup /-! # Permutation branching programs @@ -24,6 +27,9 @@ theorem). Barrington's inductive construction rests on -/ + +@[expose] public section + namespace Complexity /-- A single width-`w` branching-program instruction: read variable `var`, and diff --git a/Complexitylib/Circuits/BranchingProgramEncoding.lean b/Complexitylib/Circuits/BranchingProgramEncoding.lean index c657cf53..172dda8a 100644 --- a/Complexitylib/Circuits/BranchingProgramEncoding.lean +++ b/Complexitylib/Circuits/BranchingProgramEncoding.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BranchingProgramEncoding.Defs -import Complexitylib.Circuits.BranchingProgramEncoding.Internal + +module +public import Complexitylib.Circuits.BranchingProgramEncoding.Defs +public import Complexitylib.Circuits.BranchingProgramEncoding.Internal /-! # Canonical encoding of width-five branching programs @@ -28,6 +30,9 @@ finite permutation proofs on the machine tape. - `BPCode.Program.length_encode` -- exact serialization length. -/ + +@[expose] public section + namespace Complexity namespace BPCode diff --git a/Complexitylib/Circuits/BranchingProgramEncoding/Defs.lean b/Complexitylib/Circuits/BranchingProgramEncoding/Defs.lean index 65938e14..c0d0089b 100644 --- a/Complexitylib/Circuits/BranchingProgramEncoding/Defs.lean +++ b/Complexitylib/Circuits/BranchingProgramEncoding/Defs.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BarringtonCompiler.Defs -import Complexitylib.Circuits.Encoding.Defs -import Complexitylib.Mathlib.NatBits + +module +public import Complexitylib.Circuits.BarringtonCompiler.Defs +public import Complexitylib.Circuits.Encoding.Defs +public import Complexitylib.Mathlib.NatBits /-! # Machine-facing encoding of width-five branching programs @@ -21,6 +23,9 @@ permutation fields. A program starts with its instruction count, so exact decoding rejects truncation and trailing garbage. -/ + +@[expose] public section + namespace Complexity namespace BPCode diff --git a/Complexitylib/Circuits/BranchingProgramEncoding/Internal.lean b/Complexitylib/Circuits/BranchingProgramEncoding/Internal.lean index c00165f0..b06b2348 100644 --- a/Complexitylib/Circuits/BranchingProgramEncoding/Internal.lean +++ b/Complexitylib/Circuits/BranchingProgramEncoding/Internal.lean @@ -3,9 +3,27 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BarringtonCompiler -import Complexitylib.Circuits.BranchingProgramEncoding.Defs -import Complexitylib.Circuits.Encoding + +module +public import Complexitylib.Circuits.BarringtonCompiler +public import Complexitylib.Circuits.BranchingProgramEncoding.Defs +public import Complexitylib.Circuits.Encoding.Internal.Codec +public import Mathlib.Analysis.SpecialFunctions.Pow.NNReal +public import Mathlib.Tactic.Measurability.Init +public import Mathlib.Tactic.NormNum.BigOperators +public import Mathlib.Tactic.NormNum.Irrational +public import Mathlib.Tactic.NormNum.IsCoprime +public import Mathlib.Tactic.NormNum.IsSquare +public import Mathlib.Tactic.NormNum.LegendreSymbol +public import Mathlib.Tactic.NormNum.ModEq +public import Mathlib.Tactic.NormNum.NatFactorial +public import Mathlib.Tactic.NormNum.NatFib +public import Mathlib.Tactic.NormNum.NatLog +public import Mathlib.Tactic.NormNum.NatSqrt +public import Mathlib.Tactic.NormNum.Ordinal +public import Mathlib.Tactic.NormNum.Parity +public import Mathlib.Tactic.NormNum.RealSqrt +public import Mathlib.Tactic.ReduceModChar /-! # Width-five branching-program codec internals @@ -15,6 +33,9 @@ Public statements are re-exported by `Complexitylib.Circuits.BranchingProgramEncoding`. -/ + +@[expose] public section + set_option maxRecDepth 100000 namespace Complexity diff --git a/Complexitylib/Circuits/CircuitFormula.lean b/Complexitylib/Circuits/CircuitFormula.lean index d0db89af..c8cc8b91 100644 --- a/Complexitylib/Circuits/CircuitFormula.lean +++ b/Complexitylib/Circuits/CircuitFormula.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.CircuitFormula.Defs -import Complexitylib.Circuits.CircuitFormula.Internal + +module +public import Complexitylib.Circuits.CircuitFormula.Defs +public import Complexitylib.Circuits.CircuitFormula.Internal /-! # Unfolding fan-in-two circuit outputs into Boolean formulas @@ -30,6 +32,9 @@ size claim. is at most twice the selected output depth. -/ + +@[expose] public section + namespace Complexity namespace BoolFormula diff --git a/Complexitylib/Circuits/CircuitFormula/Defs.lean b/Complexitylib/Circuits/CircuitFormula/Defs.lean index 4515d77f..dca60322 100644 --- a/Complexitylib/Circuits/CircuitFormula/Defs.lean +++ b/Complexitylib/Circuits/CircuitFormula/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AndOrNot.Defs -import Complexitylib.Circuits.Formula + +module +public import Complexitylib.Circuits.AndOrNot.Defs +public import Complexitylib.Circuits.Formula /-! # Unfolding fan-in-two circuit outputs into Boolean formulas -- definitions @@ -14,6 +16,9 @@ output gate. Shared subcircuits are intentionally duplicated in the resulting formula tree; no formula-size claim is implicit in this bridge. -/ + +@[expose] public section + namespace Complexity namespace BoolFormula diff --git a/Complexitylib/Circuits/CircuitFormula/Family.lean b/Complexitylib/Circuits/CircuitFormula/Family.lean index 446dbc94..602c1c91 100644 --- a/Complexitylib/Circuits/CircuitFormula/Family.lean +++ b/Complexitylib/Circuits/CircuitFormula/Family.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BarringtonTyped -import Complexitylib.Circuits.CircuitFormula.Family.Defs -import Complexitylib.Circuits.CircuitFormula.Family.Internal + +module +public import Complexitylib.Circuits.BarringtonTyped +public import Complexitylib.Circuits.CircuitFormula.Family.Defs +public import Complexitylib.Circuits.CircuitFormula.Family.Internal /-! # Circuit-family outputs as formula families @@ -24,6 +26,9 @@ when unfolded. Barrington's construction depends on formula depth, which the translation controls directly. -/ + +@[expose] public section + namespace Complexity namespace Circuit diff --git a/Complexitylib/Circuits/CircuitFormula/Family/Defs.lean b/Complexitylib/Circuits/CircuitFormula/Family/Defs.lean index 07f93415..a8c6a1ec 100644 --- a/Complexitylib/Circuits/CircuitFormula/Family/Defs.lean +++ b/Complexitylib/Circuits/CircuitFormula/Family/Defs.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BarringtonConverse.Defs -import Complexitylib.Circuits.CircuitFormula.Defs -import Complexitylib.Circuits.Family.Defs + +module +public import Complexitylib.Circuits.CircuitFormula.Defs +public import Complexitylib.Circuits.Family.Defs +public import Complexitylib.Circuits.BarringtonFamily /-! # Circuit-family outputs as formula families -- definitions @@ -14,6 +16,9 @@ These definitions connect typed, length-indexed `CircuitFamily` semantics to the total-assignment convention used by the Barrington development. -/ + +@[expose] public section + namespace Complexity namespace BoolFunFamily diff --git a/Complexitylib/Circuits/CircuitFormula/Family/Internal.lean b/Complexitylib/Circuits/CircuitFormula/Family/Internal.lean index 96d6dca5..d523da27 100644 --- a/Complexitylib/Circuits/CircuitFormula/Family/Internal.lean +++ b/Complexitylib/Circuits/CircuitFormula/Family/Internal.lean @@ -3,14 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.CircuitFormula -import Complexitylib.Circuits.CircuitFormula.Family.Defs -import Complexitylib.Circuits.DepthClasses + +module +public import Complexitylib.Circuits.CircuitFormula +public import Complexitylib.Circuits.CircuitFormula.Family.Defs +public import Complexitylib.Circuits.DepthClasses +public import Complexitylib.Circuits.BarringtonConverse.Defs /-! # Circuit-family outputs as formula families -- proof internals -/ + +@[expose] public section + namespace Complexity namespace Circuit diff --git a/Complexitylib/Circuits/CircuitFormula/Internal.lean b/Complexitylib/Circuits/CircuitFormula/Internal.lean index 29e3d4a4..9515413a 100644 --- a/Complexitylib/Circuits/CircuitFormula/Internal.lean +++ b/Complexitylib/Circuits/CircuitFormula/Internal.lean @@ -3,12 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.CircuitFormula.Defs + +module +public import Complexitylib.Circuits.CircuitFormula.Defs +import all Complexitylib.Circuits.CircuitFormula.Defs /-! # Unfolding fan-in-two circuit outputs into Boolean formulas -- proof internals -/ + +@[expose] public section + namespace Complexity namespace BoolFormula @@ -133,11 +139,19 @@ theorem wireDepth_of_not_lt_two_internal (circuit.wireDepth (gate.inputs input₁)) := by rw [Circuit.wireDepth_of_not_lt circuit wire hinput] dsimp only - generalize circuit.gates ⟨wire.val - N, by omega⟩ = gate - obtain ⟨op, fanIn, arityOk, inputs, negated⟩ := gate - change fanIn = 2 at arityOk - subst arityOk - simp [Fin.foldl_succ_last, Fin.foldl_zero] + have hfold (gate : Gate Basis.andOr2 (N + G)) : + Fin.foldl gate.fanIn + (fun acc k => max acc (circuit.wireDepth (gate.inputs k))) 0 = + max + (circuit.wireDepth + (gate.inputs ⟨0, by rw [fanIn_andOr2 gate]; omega⟩)) + (circuit.wireDepth + (gate.inputs ⟨1, by rw [fanIn_andOr2 gate]; omega⟩)) := by + obtain ⟨op, fanIn, arityOk, inputs, negated⟩ := gate + change fanIn = 2 at arityOk + subst arityOk + simp [Fin.foldl_succ_last, Fin.foldl_zero] + rw [hfold] theorem outputDepth_two_internal (circuit : Circuit Basis.andOr2 N M G) (output : Fin M) : @@ -151,11 +165,19 @@ theorem outputDepth_two_internal (circuit.wireDepth (gate.inputs input₁)) := by unfold Circuit.outputDepth dsimp only - generalize circuit.outputs output = gate - obtain ⟨op, fanIn, arityOk, inputs, negated⟩ := gate - change fanIn = 2 at arityOk - subst arityOk - simp [Fin.foldl_succ_last, Fin.foldl_zero] + have hfold (gate : Gate Basis.andOr2 (N + G)) : + Fin.foldl gate.fanIn + (fun acc k => max acc (circuit.wireDepth (gate.inputs k))) 0 = + max + (circuit.wireDepth + (gate.inputs ⟨0, by rw [fanIn_andOr2 gate]; omega⟩)) + (circuit.wireDepth + (gate.inputs ⟨1, by rw [fanIn_andOr2 gate]; omega⟩)) := by + obtain ⟨op, fanIn, arityOk, inputs, negated⟩ := gate + change fanIn = 2 at arityOk + subst arityOk + simp [Fin.foldl_succ_last, Fin.foldl_zero] + rw [hfold] theorem eval_wireFormula_internal (circuit : Circuit Basis.andOr2 N M G) (assignment : ℕ → Bool) diff --git a/Complexitylib/Circuits/Composition.lean b/Complexitylib/Circuits/Composition.lean index e2628963..6d276068 100644 --- a/Complexitylib/Circuits/Composition.lean +++ b/Complexitylib/Circuits/Composition.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Composition.Defs -import Complexitylib.Circuits.Composition.Internal + +module +public import Complexitylib.Circuits.Composition.Defs +public import Complexitylib.Circuits.Composition.Internal /-! # Resource-accounted circuit composition @@ -20,6 +22,9 @@ size, rather than duplicating the inner circuit once per outer use. * `Circuit.depth_compose_le` -- depth is at most the sum of source depths. -/ + +@[expose] public section + namespace Complexity namespace Gate diff --git a/Complexitylib/Circuits/Composition/Defs.lean b/Complexitylib/Circuits/Composition/Defs.lean index 37864c8c..8ef04340 100644 --- a/Complexitylib/Circuits/Composition/Defs.lean +++ b/Complexitylib/Circuits/Composition/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Basic + +module +public import Complexitylib.Circuits.Basic /-! # Circuit composition -- definitions @@ -15,6 +17,9 @@ internal gates, the composite has exactly `G₁ + K + G₂` internal gates. Consequently its library size is the sum of the two source sizes. -/ + +@[expose] public section + namespace Complexity namespace Gate diff --git a/Complexitylib/Circuits/Composition/Internal.lean b/Complexitylib/Circuits/Composition/Internal.lean index 6ba928cc..86444375 100644 --- a/Complexitylib/Circuits/Composition/Internal.lean +++ b/Complexitylib/Circuits/Composition/Internal.lean @@ -3,12 +3,17 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Composition.Defs + +module +public import Complexitylib.Circuits.Composition.Defs /-! # Circuit composition -- proof internals -/ + +@[expose] public section + namespace Complexity namespace Gate diff --git a/Complexitylib/Circuits/DecisionTree.lean b/Complexitylib/Circuits/DecisionTree.lean index 8eecb53e..33b9bbdc 100644 --- a/Complexitylib/Circuits/DecisionTree.lean +++ b/Complexitylib/Circuits/DecisionTree.lean @@ -3,12 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Data.Nat.Basic -import Mathlib.Data.Bool.Basic -import Mathlib.Data.Finset.Basic -import Mathlib.Data.Finset.Union -import Mathlib.Data.Finset.Card -import Complexitylib.Circuits.Formula + +module +public import Mathlib.Data.Finset.Card +public import Complexitylib.Circuits.Formula +public import Std.Tactic.BVDecide.Normalize.Bool /-! # Boolean decision trees @@ -34,6 +33,9 @@ are distinct from the DAG-shaped `Circuit`. equivalent Boolean formula (the decision-tree ⟹ formula direction) -/ + +@[expose] public section + namespace Complexity /-- A Boolean decision tree: a `leaf` carries an output bit; a `node i t₀ t₁` diff --git a/Complexitylib/Circuits/DecisionTree/Block.lean b/Complexitylib/Circuits/DecisionTree/Block.lean index 5a0a4881..94369a16 100644 --- a/Complexitylib/Circuits/DecisionTree/Block.lean +++ b/Complexitylib/Circuits/DecisionTree/Block.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.DecisionTree.Block.Defs -import Complexitylib.Circuits.DecisionTree.Block.Internal + +module +public import Complexitylib.Circuits.DecisionTree.Block.Defs +public import Complexitylib.Circuits.DecisionTree.Block.Internal /-! # Complete query blocks in finite decision trees @@ -14,6 +16,9 @@ queried before control reaches a continuation indexed by the collected finite restriction. -/ + +@[expose] public section + namespace Complexity namespace DecisionTree.On diff --git a/Complexitylib/Circuits/DecisionTree/Block/Defs.lean b/Complexitylib/Circuits/DecisionTree/Block/Defs.lean index 03889526..2a78ca13 100644 --- a/Complexitylib/Circuits/DecisionTree/Block/Defs.lean +++ b/Complexitylib/Circuits/DecisionTree/Block/Defs.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.DecisionTree.Path.Defs -import Complexitylib.Circuits.Restriction + +module +public import Complexitylib.Circuits.DecisionTree.Finite.Defs /-! # Complete query blocks in finite decision trees -- definitions @@ -15,6 +16,9 @@ the resulting finite restriction. This is the block operation used by the canonical switching tree. -/ + +@[expose] public section + namespace Complexity namespace DecisionTree.On diff --git a/Complexitylib/Circuits/DecisionTree/Block/Internal.lean b/Complexitylib/Circuits/DecisionTree/Block/Internal.lean index 2522a4f1..1ff11df5 100644 --- a/Complexitylib/Circuits/DecisionTree/Block/Internal.lean +++ b/Complexitylib/Circuits/DecisionTree/Block/Internal.lean @@ -3,12 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.DecisionTree.Block.Defs + +module +public import Complexitylib.Circuits.DecisionTree.Block.Defs +public import Complexitylib.Circuits.DecisionTree.Path.Defs /-! # Complete query blocks in finite decision trees -- proof internals -/ + +@[expose] public section + namespace Complexity namespace DecisionTree.On diff --git a/Complexitylib/Circuits/DecisionTree/Finite.lean b/Complexitylib/Circuits/DecisionTree/Finite.lean index 5a72647f..e2132d4b 100644 --- a/Complexitylib/Circuits/DecisionTree/Finite.lean +++ b/Complexitylib/Circuits/DecisionTree/Finite.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.DecisionTree.Finite.Defs -import Complexitylib.Circuits.DecisionTree.Finite.Internal + +module +public import Complexitylib.Circuits.DecisionTree.Finite.Defs +public import Complexitylib.Circuits.DecisionTree.Finite.Internal /-! # Finite-arity decision trees @@ -14,6 +16,9 @@ decision-tree representation used by finite switching and restriction arguments; no query can silently fall outside the sampled variable set. -/ + +@[expose] public section + namespace Complexity namespace DecisionTree.On diff --git a/Complexitylib/Circuits/DecisionTree/Finite/Defs.lean b/Complexitylib/Circuits/DecisionTree/Finite/Defs.lean index f675c17d..e48eb342 100644 --- a/Complexitylib/Circuits/DecisionTree/Finite/Defs.lean +++ b/Complexitylib/Circuits/DecisionTree/Finite/Defs.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BitString -import Complexitylib.Circuits.DecisionTree -import Complexitylib.Circuits.Restriction + +module +public import Complexitylib.Circuits.DecisionTree +public import Complexitylib.Circuits.Restriction /-! # Finite-arity decision trees -- definitions @@ -15,6 +16,9 @@ arguments, however, count restrictions on exactly `N` variables. `DecisionTree.O N` makes that arity part of the type and prevents out-of-range queries. -/ + +@[expose] public section + namespace Complexity namespace DecisionTree diff --git a/Complexitylib/Circuits/DecisionTree/Finite/Internal.lean b/Complexitylib/Circuits/DecisionTree/Finite/Internal.lean index bf78f06e..980845d5 100644 --- a/Complexitylib/Circuits/DecisionTree/Finite/Internal.lean +++ b/Complexitylib/Circuits/DecisionTree/Finite/Internal.lean @@ -3,12 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.DecisionTree.Finite.Defs + +module +public import Complexitylib.Circuits.DecisionTree.Finite.Defs +public import Complexitylib.Circuits.BitString /-! # Finite-arity decision trees -- proof internals -/ + +@[expose] public section + namespace Complexity namespace DecisionTree.On diff --git a/Complexitylib/Circuits/DecisionTree/NormalForm.lean b/Complexitylib/Circuits/DecisionTree/NormalForm.lean index 60fd32a4..f05cf822 100644 --- a/Complexitylib/Circuits/DecisionTree/NormalForm.lean +++ b/Complexitylib/Circuits/DecisionTree/NormalForm.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.DecisionTree.Finite -import Complexitylib.Circuits.DecisionTree.NormalForm.Defs -import Complexitylib.Circuits.DecisionTree.NormalForm.Internal + +module +public import Complexitylib.Circuits.DecisionTree.NormalForm.Defs +public import Complexitylib.Circuits.DecisionTree.NormalForm.Internal /-! # Compiling finite decision trees to CNF and DNF @@ -16,6 +17,9 @@ compute exactly the original tree, have at most one component per leaf, and therefore have at most `2 ^ d` terms or clauses. -/ + +@[expose] public section + namespace Complexity namespace DecisionTree.On diff --git a/Complexitylib/Circuits/DecisionTree/NormalForm/Defs.lean b/Complexitylib/Circuits/DecisionTree/NormalForm/Defs.lean index 4dae3e3a..2fa3465e 100644 --- a/Complexitylib/Circuits/DecisionTree/NormalForm/Defs.lean +++ b/Complexitylib/Circuits/DecisionTree/NormalForm/Defs.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.DecisionTree.Finite.Defs -import Complexitylib.Circuits.NormalForm.Defs -import Complexitylib.Circuits.NormalForm.Operations.Defs + +module +public import Complexitylib.Circuits.DecisionTree.Finite.Defs +public import Complexitylib.Circuits.NormalForm.Operations.Defs /-! # Compiling finite decision trees to CNF and DNF -- definitions @@ -16,6 +17,9 @@ The dual CNF is obtained by compiling the leaf-complemented tree and applying De Morgan negation. -/ + +@[expose] public section + namespace Complexity namespace DecisionTree.On diff --git a/Complexitylib/Circuits/DecisionTree/NormalForm/Internal.lean b/Complexitylib/Circuits/DecisionTree/NormalForm/Internal.lean index 47ff1a4e..00428152 100644 --- a/Complexitylib/Circuits/DecisionTree/NormalForm/Internal.lean +++ b/Complexitylib/Circuits/DecisionTree/NormalForm/Internal.lean @@ -3,14 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.DecisionTree.Finite.Internal -import Complexitylib.Circuits.DecisionTree.NormalForm.Defs -import Complexitylib.Circuits.NormalForm.Operations.Internal + +module +public import Complexitylib.Circuits.DecisionTree.Finite.Internal +public import Complexitylib.Circuits.DecisionTree.NormalForm.Defs +public import Complexitylib.Circuits.NormalForm.Operations.Internal /-! # Compiling finite decision trees to CNF and DNF -- proof internals -/ + +@[expose] public section + namespace Complexity namespace DecisionTree.On diff --git a/Complexitylib/Circuits/DecisionTree/Path.lean b/Complexitylib/Circuits/DecisionTree/Path.lean index 675b8f37..738aa457 100644 --- a/Complexitylib/Circuits/DecisionTree/Path.lean +++ b/Complexitylib/Circuits/DecisionTree/Path.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.DecisionTree.Path.Defs -import Complexitylib.Circuits.DecisionTree.Path.Internal + +module +public import Complexitylib.Circuits.DecisionTree.Path.Defs +public import Complexitylib.Circuits.DecisionTree.Path.Internal /-! # Canonical deepest paths in finite decision trees @@ -14,6 +16,9 @@ length is exactly the tree depth. For path-read-once trees, every prefix of that path is an embedding into the input coordinates. -/ + +@[expose] public section + namespace Complexity namespace DecisionTree.On diff --git a/Complexitylib/Circuits/DecisionTree/Path/Defs.lean b/Complexitylib/Circuits/DecisionTree/Path/Defs.lean index 9db36768..32dfa8d2 100644 --- a/Complexitylib/Circuits/DecisionTree/Path/Defs.lean +++ b/Complexitylib/Circuits/DecisionTree/Path/Defs.lean @@ -3,12 +3,17 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.DecisionTree.Finite.Defs + +module +public import Complexitylib.Circuits.DecisionTree.Finite.Defs /-! # Canonical deepest paths in finite decision trees -- definitions -/ + +@[expose] public section + namespace Complexity namespace DecisionTree.On diff --git a/Complexitylib/Circuits/DecisionTree/Path/Internal.lean b/Complexitylib/Circuits/DecisionTree/Path/Internal.lean index 721cb4ca..d7208d5f 100644 --- a/Complexitylib/Circuits/DecisionTree/Path/Internal.lean +++ b/Complexitylib/Circuits/DecisionTree/Path/Internal.lean @@ -3,13 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.DecisionTree.Path.Defs -import Complexitylib.Circuits.DecisionTree.Finite.Internal + +module +public import Complexitylib.Circuits.DecisionTree.Path.Defs +public import Complexitylib.Circuits.DecisionTree.Finite.Internal /-! # Canonical deepest paths in finite decision trees -- proof internals -/ + +@[expose] public section + namespace Complexity namespace DecisionTree.On diff --git a/Complexitylib/Circuits/DecisionTree/Restriction.lean b/Complexitylib/Circuits/DecisionTree/Restriction.lean index 0923e9bc..7be25cf5 100644 --- a/Complexitylib/Circuits/DecisionTree/Restriction.lean +++ b/Complexitylib/Circuits/DecisionTree/Restriction.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.DecisionTree -import Complexitylib.Circuits.Restriction + +module +public import Complexitylib.Circuits.DecisionTree +public import Complexitylib.Circuits.Restriction /-! # Restricting decision trees @@ -23,6 +25,9 @@ simplification used when switching-lemma arguments measure decision-tree depth. left-biased restriction composition. -/ + +@[expose] public section + namespace Complexity namespace DecisionTree diff --git a/Complexitylib/Circuits/Dependency.lean b/Complexitylib/Circuits/Dependency.lean index 02a3ee25..f2b31b28 100644 --- a/Complexitylib/Circuits/Dependency.lean +++ b/Complexitylib/Circuits/Dependency.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Dependency.Defs -import Complexitylib.Circuits.Dependency.Internal + +module +public import Complexitylib.Circuits.Dependency.Defs +public import Complexitylib.Circuits.Dependency.Internal /-! # Circuit dependency graphs @@ -22,6 +24,9 @@ referenced wire to the gate that reads it. bounded by total fan-in. -/ + +@[expose] public section + namespace Complexity namespace Circuit diff --git a/Complexitylib/Circuits/Dependency/Defs.lean b/Complexitylib/Circuits/Dependency/Defs.lean index e9586e2f..d16876d8 100644 --- a/Complexitylib/Circuits/Dependency/Defs.lean +++ b/Complexitylib/Circuits/Dependency/Defs.lean @@ -3,9 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Basic -import Complexitylib.Mathlib.Digraph -import Mathlib.Data.Fintype.BigOperators + +module +public import Complexitylib.Circuits.Basic +public import Mathlib.Algebra.BigOperators.Group.Finset.Defs +public import Mathlib.Combinatorics.Digraph.Basic +public import Mathlib.Data.Fintype.Sigma +public import Mathlib.Data.Fintype.Sum /-! # Circuit dependency graphs -- definitions @@ -17,6 +21,9 @@ of the same wire at the same gate collapse in the graph's edge set, while `Circuit.totalFanIn` continues to count them with multiplicity. -/ + +@[expose] public section + namespace Complexity namespace Circuit diff --git a/Complexitylib/Circuits/Dependency/Internal.lean b/Complexitylib/Circuits/Dependency/Internal.lean index 98666c10..40a78131 100644 --- a/Complexitylib/Circuits/Dependency/Internal.lean +++ b/Complexitylib/Circuits/Dependency/Internal.lean @@ -3,12 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Dependency.Defs + +module +public import Complexitylib.Circuits.Dependency.Defs +public import Complexitylib.Mathlib.Digraph +public import Mathlib.Data.Fintype.BigOperators /-! # Circuit dependency graphs -- proof internals -/ + +@[expose] public section + namespace Complexity namespace Circuit diff --git a/Complexitylib/Circuits/DepthClasses.lean b/Complexitylib/Circuits/DepthClasses.lean index f73afda4..996abb7d 100644 --- a/Complexitylib/Circuits/DepthClasses.lean +++ b/Complexitylib/Circuits/DepthClasses.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.DepthClasses.Defs -import Complexitylib.Circuits.DepthClasses.Internal + +module +public import Complexitylib.Circuits.DepthClasses.Defs +public import Complexitylib.Circuits.DepthClasses.Internal /-! # Circuit depth classes @@ -24,6 +26,9 @@ These definitions are explicitly nonuniform. Generator uniformity is an additional predicate and is not implicit in the names `NC`, `AC`, or `TC`. -/ + +@[expose] public section + namespace Complexity /-- The exponent-zero polylogarithmic envelope is the constant `c`. -/ diff --git a/Complexitylib/Circuits/DepthClasses/Defs.lean b/Complexitylib/Circuits/DepthClasses/Defs.lean index 43284c90..91605a63 100644 --- a/Complexitylib/Circuits/DepthClasses/Defs.lean +++ b/Complexitylib/Circuits/DepthClasses/Defs.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AndOrNot.Defs -import Complexitylib.Circuits.Family.Defs -import Complexitylib.Circuits.Threshold.Defs -import Mathlib.Data.Nat.Log + +module +public import Complexitylib.Circuits.AndOrNot.Defs +public import Complexitylib.Circuits.Family.Defs +public import Complexitylib.Circuits.Threshold.Defs +public import Mathlib.Data.Nat.Log /-! # Circuit depth classes -- definitions @@ -20,6 +22,9 @@ AND/OR circuits. Both require polynomial size and depth `O((log n + 1)^i)` in an explicit pointwise form. -/ + +@[expose] public section + namespace Complexity /-- A concrete `O((log₂ n + 1)^i)` depth envelope with multiplicative diff --git a/Complexitylib/Circuits/DepthClasses/Internal.lean b/Complexitylib/Circuits/DepthClasses/Internal.lean index 5806d185..38e0f883 100644 --- a/Complexitylib/Circuits/DepthClasses/Internal.lean +++ b/Complexitylib/Circuits/DepthClasses/Internal.lean @@ -3,15 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.DepthClasses.Defs -import Complexitylib.Circuits.BasisHom -import Complexitylib.Circuits.Family -import Complexitylib.Circuits.Threshold + +module +public import Complexitylib.Circuits.DepthClasses.Defs +public import Complexitylib.Circuits.BasisHom +public import Complexitylib.Circuits.Family +public import Complexitylib.Circuits.Threshold /-! # Circuit depth classes -- proof internals -/ + +@[expose] public section + namespace Complexity theorem polylogDepth_zero_internal (c n : ℕ) : diff --git a/Complexitylib/Circuits/Encoding.lean b/Complexitylib/Circuits/Encoding.lean index 7ce5ecfd..a015e752 100644 --- a/Complexitylib/Circuits/Encoding.lean +++ b/Complexitylib/Circuits/Encoding.lean @@ -3,14 +3,16 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Defs -import Complexitylib.Circuits.Encoding.Fragment -import Complexitylib.Circuits.Encoding.Formula -import Complexitylib.Circuits.Encoding.Formula.Batch -import Complexitylib.Circuits.Encoding.Formula.Stream -import Complexitylib.Circuits.Encoding.Internal -import Complexitylib.Circuits.Encoding.Threshold -import Complexitylib.Circuits.Encoding.ToCircuit + +module +public import Complexitylib.Circuits.Encoding.Defs +public import Complexitylib.Circuits.Encoding.Fragment +public import Complexitylib.Circuits.Encoding.Formula +public import Complexitylib.Circuits.Encoding.Formula.Batch +public import Complexitylib.Circuits.Encoding.Formula.Stream +public import Complexitylib.Circuits.Encoding.Internal +public import Complexitylib.Circuits.Encoding.Threshold +public import Complexitylib.Circuits.Encoding.ToCircuit /-! # Encoded fan-in-two circuits @@ -52,6 +54,9 @@ This module exposes the machine-facing representation of - `Threshold.evalAux?_compileRaw`: exact threshold-fragment evaluation. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Defs.lean b/Complexitylib/Circuits/Encoding/Defs.lean index 4101fd1f..321bc15d 100644 --- a/Complexitylib/Circuits/Encoding/Defs.lean +++ b/Complexitylib/Circuits/Encoding/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AndOrNot.Defs + +module +public import Complexitylib.Circuits.AndOrNot.Defs /-! # Machine-facing encoding of fan-in-two AND/OR circuits @@ -26,6 +28,9 @@ format polynomially long in the input arity and number of gates; a binary format can be added later without changing the raw circuit semantics. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Family.lean b/Complexitylib/Circuits/Encoding/Family.lean index b4eb1ed7..38e44284 100644 --- a/Complexitylib/Circuits/Encoding/Family.lean +++ b/Complexitylib/Circuits/Encoding/Family.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding -import Complexitylib.Circuits.Family -import Complexitylib.Encoding.Pairing + +module +public import Complexitylib.Circuits.Encoding +public import Complexitylib.Circuits.Family +public import Complexitylib.Encoding.Pairing /-! # Encodings of whole circuit families @@ -15,6 +17,9 @@ codec. A leading tag distinguishes the explicit empty-input answer from an ordinary encoded circuit. -/ + +@[expose] public section + namespace Complexity namespace CircuitFamily diff --git a/Complexitylib/Circuits/Encoding/Formula.lean b/Complexitylib/Circuits/Encoding/Formula.lean index a9128718..b4b4d286 100644 --- a/Complexitylib/Circuits/Encoding/Formula.lean +++ b/Complexitylib/Circuits/Encoding/Formula.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Formula.Internal + +module +public import Complexitylib.Circuits.Encoding.Formula.Internal /-! # Correctness of Boolean-formula raw compilation @@ -26,6 +28,9 @@ circuits; circuit families handle their zero-input member separately. correctness; `evalAux?_compileRaw` is the all-existing-wires corollary. -/ + +@[expose] public section + namespace Complexity namespace BoolFormula diff --git a/Complexitylib/Circuits/Encoding/Formula/Batch.lean b/Complexitylib/Circuits/Encoding/Formula/Batch.lean index 84427cfd..f73c75a8 100644 --- a/Complexitylib/Circuits/Encoding/Formula/Batch.lean +++ b/Complexitylib/Circuits/Encoding/Formula/Batch.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Formula.Batch.Internal + +module +public import Complexitylib.Circuits.Encoding.Formula.Batch.Internal /-! # Batch compilation of Boolean formulas @@ -23,6 +25,9 @@ all results in one contiguous block starting at `rawBatchOutputBase`. - `BoolFormula.evalAux?_compileRawBatch`: exact packed-output semantics. -/ + +@[expose] public section + namespace Complexity namespace BoolFormula diff --git a/Complexitylib/Circuits/Encoding/Formula/Batch/Defs.lean b/Complexitylib/Circuits/Encoding/Formula/Batch/Defs.lean index 6ef118f3..9f311427 100644 --- a/Complexitylib/Circuits/Encoding/Formula/Batch/Defs.lean +++ b/Complexitylib/Circuits/Encoding/Formula/Batch/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Formula.Defs + +module +public import Complexitylib.Circuits.Encoding.Formula.Defs /-! # Batch compilation of Boolean formulas @@ -19,6 +21,9 @@ result by a base wire and an index without retaining the variable-sized offset of every formula tree. -/ + +@[expose] public section + namespace Complexity namespace BoolFormula diff --git a/Complexitylib/Circuits/Encoding/Formula/Batch/Internal.lean b/Complexitylib/Circuits/Encoding/Formula/Batch/Internal.lean index 17cda545..5a76e193 100644 --- a/Complexitylib/Circuits/Encoding/Formula/Batch/Internal.lean +++ b/Complexitylib/Circuits/Encoding/Formula/Batch/Internal.lean @@ -3,8 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Formula.Batch.Defs -import Complexitylib.Circuits.Encoding.Formula.Internal + +module +public import Complexitylib.Circuits.Encoding.Formula.Batch.Defs +public import Complexitylib.Circuits.Encoding.Formula.Internal +public import Std.Tactic.BVDecide.Normalize.BitVec /-! # Internals for batch formula compilation @@ -14,6 +17,9 @@ for `BoolFormula.compileRawBatch`. Public statements are re-exported by `Complexitylib.Circuits.Encoding.Formula.Batch`. -/ + +@[expose] public section + namespace Complexity namespace BoolFormula diff --git a/Complexitylib/Circuits/Encoding/Formula/Defs.lean b/Complexitylib/Circuits/Encoding/Formula/Defs.lean index b9cbef97..68d3e2ec 100644 --- a/Complexitylib/Circuits/Encoding/Formula/Defs.lean +++ b/Complexitylib/Circuits/Encoding/Formula/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Fragment.Defs -import Complexitylib.Circuits.Formula + +module +public import Complexitylib.Circuits.Encoding.Fragment.Defs +public import Complexitylib.Circuits.Formula /-! # Compile Boolean formulas to raw circuit fragments @@ -19,6 +21,9 @@ existing wire together with its negation, while formula negation uses the raw gate's free edge-negation flags. Binary formulas are emitted in postorder. -/ + +@[expose] public section + namespace Complexity namespace BoolFormula diff --git a/Complexitylib/Circuits/Encoding/Formula/Internal.lean b/Complexitylib/Circuits/Encoding/Formula/Internal.lean index d59648b3..ddf2569f 100644 --- a/Complexitylib/Circuits/Encoding/Formula/Internal.lean +++ b/Complexitylib/Circuits/Encoding/Formula/Internal.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Formula.Defs -import Complexitylib.Circuits.Encoding.Fragment + +module +public import Complexitylib.Circuits.Encoding.Formula.Defs +public import Complexitylib.Circuits.Encoding.Internal.Fragment /-! # Boolean-formula raw compiler internals @@ -14,6 +16,9 @@ formula compiler. Public statements are re-exported by `Complexitylib.Circuits.Encoding.Formula`. -/ + +@[expose] public section + namespace Complexity namespace BoolFormula diff --git a/Complexitylib/Circuits/Encoding/Formula/Stream.lean b/Complexitylib/Circuits/Encoding/Formula/Stream.lean index 5d2bf38d..6bf9eecf 100644 --- a/Complexitylib/Circuits/Encoding/Formula/Stream.lean +++ b/Complexitylib/Circuits/Encoding/Formula/Stream.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Formula.Stream.Defs -import Complexitylib.Circuits.Encoding.Formula.Stream.Internal + +module +public import Complexitylib.Circuits.Encoding.Formula.Stream.Defs +public import Complexitylib.Circuits.Encoding.Formula.Stream.Internal /-! # Stack-free streams for finite Boolean folds @@ -26,6 +28,9 @@ recomputation; no executable cursor is claimed here. - `BoolFormula.length_compileRawRightFold` gives its exact gate count. -/ + +@[expose] public section + namespace Complexity namespace BoolFormula diff --git a/Complexitylib/Circuits/Encoding/Formula/Stream/Defs.lean b/Complexitylib/Circuits/Encoding/Formula/Stream/Defs.lean index 747a92d8..a81e3b91 100644 --- a/Complexitylib/Circuits/Encoding/Formula/Stream/Defs.lean +++ b/Complexitylib/Circuits/Encoding/Formula/Stream/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Formula.Batch.Defs + +module +public import Complexitylib.Circuits.Encoding.Formula.Batch.Defs /-! # Stack-free streams for finite Boolean folds — definitions @@ -15,6 +17,9 @@ connectors from right to left. This module names the connector suffix used by that decomposition. -/ + +@[expose] public section + namespace Complexity namespace BoolFormula diff --git a/Complexitylib/Circuits/Encoding/Formula/Stream/Internal.lean b/Complexitylib/Circuits/Encoding/Formula/Stream/Internal.lean index 80ca456a..9f8c5d4f 100644 --- a/Complexitylib/Circuits/Encoding/Formula/Stream/Internal.lean +++ b/Complexitylib/Circuits/Encoding/Formula/Stream/Internal.lean @@ -3,13 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Formula.Batch -import Complexitylib.Circuits.Encoding.Formula.Stream.Defs + +module +public import Complexitylib.Circuits.Encoding.Formula.Batch +public import Complexitylib.Circuits.Encoding.Formula.Stream.Defs /-! # Stack-free streams for finite Boolean folds — proof internals -/ + +@[expose] public section + namespace Complexity namespace BoolFormula diff --git a/Complexitylib/Circuits/Encoding/Fragment.lean b/Complexitylib/Circuits/Encoding/Fragment.lean index 5dabf81c..784ecac7 100644 --- a/Complexitylib/Circuits/Encoding/Fragment.lean +++ b/Complexitylib/Circuits/Encoding/Fragment.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Internal.Fragment + +module +public import Complexitylib.Circuits.Encoding.Internal.Fragment /-! # Appendable raw-circuit fragments @@ -14,6 +16,9 @@ Evaluation passes the memo array from one fragment to the next, and successful evaluation preserves every previously available wire. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Fragment/Defs.lean b/Complexitylib/Circuits/Encoding/Fragment/Defs.lean index c8c6be24..aa7b0434 100644 --- a/Complexitylib/Circuits/Encoding/Fragment/Defs.lean +++ b/Complexitylib/Circuits/Encoding/Fragment/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Defs + +module +public import Complexitylib.Circuits.Encoding.Defs /-! # Primitive raw-circuit fragment gates @@ -14,6 +16,9 @@ existing wire, while a wire paired with its negation supplies either Boolean constant. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Internal.lean b/Complexitylib/Circuits/Encoding/Internal.lean index b0816e4e..d546c5d3 100644 --- a/Complexitylib/Circuits/Encoding/Internal.lean +++ b/Complexitylib/Circuits/Encoding/Internal.lean @@ -3,10 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Internal.Codec -import Complexitylib.Circuits.Encoding.Internal.Fragment -import Complexitylib.Circuits.Encoding.Internal.Semantics -import Complexitylib.Circuits.Encoding.Internal.ToCircuit + +module +public import Complexitylib.Circuits.Encoding.Internal.Codec +public import Complexitylib.Circuits.Encoding.Internal.Fragment +public import Complexitylib.Circuits.Encoding.Internal.Semantics +public import Complexitylib.Circuits.Encoding.Internal.ToCircuit /-! # Encoded-circuit proof internals diff --git a/Complexitylib/Circuits/Encoding/Internal/Codec.lean b/Complexitylib/Circuits/Encoding/Internal/Codec.lean index e9239ce9..a724e0c4 100644 --- a/Complexitylib/Circuits/Encoding/Internal/Codec.lean +++ b/Complexitylib/Circuits/Encoding/Internal/Codec.lean @@ -3,7 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Defs + +module +public import Complexitylib.Circuits.Encoding.Defs +public import Std.Tactic.BVDecide.Normalize.Prop /-! # Correctness of the machine-facing circuit codec @@ -14,6 +17,9 @@ invariants. Semantic agreement with typed circuit evaluation is deliberately kept in a separate proof layer. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Internal/Fragment.lean b/Complexitylib/Circuits/Encoding/Internal/Fragment.lean index 136f37aa..4a8c3da8 100644 --- a/Complexitylib/Circuits/Encoding/Internal/Fragment.lean +++ b/Complexitylib/Circuits/Encoding/Internal/Fragment.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Internal.Codec -import Complexitylib.Circuits.Encoding.Fragment.Defs + +module +public import Complexitylib.Circuits.Encoding.Internal.Codec +public import Complexitylib.Circuits.Encoding.Fragment.Defs /-! # Internal laws for appendable raw-circuit fragments @@ -14,6 +16,9 @@ iterative raw-circuit evaluator. The statements are exposed by `Complexitylib.Circuits.Encoding.Fragment`. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Internal/Semantics.lean b/Complexitylib/Circuits/Encoding/Internal/Semantics.lean index 7d055fcb..3397e634 100644 --- a/Complexitylib/Circuits/Encoding/Internal/Semantics.lean +++ b/Complexitylib/Circuits/Encoding/Internal/Semantics.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BitString -import Complexitylib.Circuits.Encoding.Internal.Codec -import Complexitylib.Circuits.Internal.CircuitToDescriptor + +module +public import Complexitylib.Circuits.BitString +public import Complexitylib.Circuits.Encoding.Internal.Codec +public import Complexitylib.Circuits.Internal.CircuitToDescriptor /-! # Internal: semantics of encoded fan-in-two circuits @@ -17,6 +19,9 @@ ordered gates have run, the evaluator's array contains exactly the values of descriptor wires `0, ..., N + k - 1`. -/ + +@[expose] public section + namespace Complexity open CircDesc diff --git a/Complexitylib/Circuits/Encoding/Internal/ToCircuit.lean b/Complexitylib/Circuits/Encoding/Internal/ToCircuit.lean index cea6ad8d..1dbeeafe 100644 --- a/Complexitylib/Circuits/Encoding/Internal/ToCircuit.lean +++ b/Complexitylib/Circuits/Encoding/Internal/ToCircuit.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Internal.Semantics -import Complexitylib.Circuits.Encoding.ToCircuit.Defs + +module +public import Complexitylib.Circuits.Encoding.Internal.Semantics +public import Complexitylib.Circuits.Encoding.ToCircuit.Defs /-! # Internal correctness of raw-to-typed circuit reconstruction @@ -14,6 +16,9 @@ them is an exact round trip. Semantic correctness is consequently inherited from the existing typed-to-raw evaluator theorem rather than reproved. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine.lean b/Complexitylib/Circuits/Encoding/Machine.lean index 5f8fc754..2e86f405 100644 --- a/Complexitylib/Circuits/Encoding/Machine.lean +++ b/Complexitylib/Circuits/Encoding/Machine.lean @@ -3,12 +3,14 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.Defs -import Complexitylib.Circuits.Encoding.Machine.Core -import Complexitylib.Circuits.Encoding.Machine.Internal.FrontEnd -import Complexitylib.Circuits.Encoding.Machine.GateStream -import Complexitylib.Circuits.Encoding.Machine.NatCode -import Complexitylib.Circuits.Encoding.Machine.RawGate + +module +public import Complexitylib.Circuits.Encoding.Machine.Defs +public import Complexitylib.Circuits.Encoding.Machine.Core +public import Complexitylib.Circuits.Encoding.Machine.Internal.FrontEnd +public import Complexitylib.Circuits.Encoding.Machine.GateStream +public import Complexitylib.Circuits.Encoding.Machine.NatCode +public import Complexitylib.Circuits.Encoding.Machine.RawGate /-! # Serialized circuit-evaluator machine @@ -37,6 +39,9 @@ its final verdict. first-unused-wire counter after one emitted gate. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/Core.lean b/Complexitylib/Circuits/Encoding/Machine/Core.lean index 2ca63edc..ed49f88a 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Core.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Core.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.Core.Defs -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Evaluator -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Hoare + +module +public import Complexitylib.Circuits.Encoding.Machine.Core.Defs +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Evaluator +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Hoare /-! # Verified serialized-circuit evaluator @@ -26,6 +28,9 @@ concrete quadratic bound. - `evalFamilyTime_bigO_quadratic` proves the end-to-end budget is `O(n^2)`. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/Core/Defs.lean b/Complexitylib/Circuits/Encoding/Machine/Core/Defs.lean index 90b484c6..6b224c14 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Core/Defs.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Core/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.Defs + +module +public import Complexitylib.Circuits.Encoding.Machine.Defs /-! # Streaming serialized-circuit evaluator core @@ -19,6 +21,9 @@ each head action. Consequently `evalFamilyCoreTM` satisfies `TM.δ_right_of_start` structurally rather than through a large case proof. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/Core/Internal.lean b/Complexitylib/Circuits/Encoding/Machine/Core/Internal.lean index 5aa930f0..c554862c 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Core/Internal.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Core/Internal.lean @@ -3,22 +3,24 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Action -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.EmptyReject -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.PositiveReject -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate.Attempt -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate.Reject -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate.Loop -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate.LoopReject -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.PositiveLoopReject -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Family -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Evaluator -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Hoare -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Pure -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Stage -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Tape + +module +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Action +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.EmptyReject +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.PositiveReject +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate.Attempt +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate.Reject +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate.Loop +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate.LoopReject +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.PositiveLoopReject +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Family +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Evaluator +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Hoare +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Pure +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Stage +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Tape /-! # Streaming evaluator proof internals diff --git a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Action.lean b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Action.lean index c3edaf77..a20eaed5 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Action.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Action.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.Core.Defs + +module +public import Complexitylib.Circuits.Encoding.Machine.Core.Defs /-! # Projection lemmas for streaming evaluator actions @@ -13,6 +15,9 @@ actions behind the finite-index projections used by `TM.δ`. They keep later one-step proofs independent of the implementation's nested index tests. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Evaluator.lean b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Evaluator.lean index de61db18..40f26d1d 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Evaluator.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Evaluator.lean @@ -3,10 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Asymptotics -import Complexitylib.Circuits.Encoding.Machine.Internal.FrontEnd -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Hoare -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Stage + +module +public import Complexitylib.Circuits.Encoding.Machine.Internal.FrontEnd +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Hoare +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Stage /-! # End-to-end serialized circuit evaluator @@ -17,6 +18,9 @@ machine as a decider for `circuitEvalLanguage`, and records the concrete quadratic running-time bound. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution.lean b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution.lean index 6bde4751..928daf53 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Action -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Tape -import Complexitylib.Models.TuringMachine.Subroutines.Counter + +module +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Action +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Tape +public import Complexitylib.Models.TuringMachine.Subroutines.Counter /-! # Execution seams for the streaming circuit evaluator @@ -17,6 +19,9 @@ reduce one machine step to the corresponding named `CoreAction`, without reopening the finite-index projection plumbing. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/EmptyReject.lean b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/EmptyReject.lean index b13635fe..2f8da2f9 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/EmptyReject.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/EmptyReject.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Pure + +module +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Pure /-! # Malformed empty-family execution @@ -15,6 +17,9 @@ answer bit: a missing answer rejects in two steps, while trailing data rejects in three. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Family.lean b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Family.lean index bbf69b83..a6382aa8 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Family.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Family.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.EmptyReject -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.PositiveLoopReject -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.PositiveReject + +module +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.EmptyReject +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.PositiveLoopReject +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.PositiveReject /-! # Total tagged-family core execution @@ -15,6 +17,9 @@ count, and counted gate-loop branches. The output is the defaulted pure verdict: successful Boolean results are preserved and every malformed stream writes zero. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Gate.lean b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Gate.lean index 0dc1ee57..6949182c 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Gate.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Gate.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution + +module +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution /-! # One-gate execution for the streaming circuit evaluator @@ -19,6 +21,9 @@ within this controller. They are the reusable proof-engineering seam between `CoreAction` and exact named configurations. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Gate/Attempt.lean b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Gate/Attempt.lean index e90832d3..f1383e16 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Gate/Attempt.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Gate/Attempt.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Pure + +module +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Pure /-! # Pure-to-machine gate-attempt bridge @@ -15,6 +17,9 @@ the first reference, so the machine runtime is existential but carries a uniform linear bound in the current wire-memo length. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Gate/Loop.lean b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Gate/Loop.lean index 26b4a844..4fe6ea83 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Gate/Loop.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Gate/Loop.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate.Attempt + +module +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate.Attempt /-! # Successful gate-stream execution @@ -15,6 +17,9 @@ memo length. The resulting budget is quadratic once the maximum memo length is bounded by input length plus gate count. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Gate/LoopReject.lean b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Gate/LoopReject.lean index d9252897..6bd47b68 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Gate/LoopReject.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Gate/LoopReject.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate.Loop -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate.Reject + +module +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate.Loop +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate.Reject /-! # Rejecting gate-stream execution @@ -15,6 +17,9 @@ the same named budget, while preserving a well-formed counter remainder and recording the machine's zero verdict. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Gate/Reject.lean b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Gate/Reject.lean index d35a5298..693da4e5 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Gate/Reject.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/Gate/Reject.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Pure + +module +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Pure /-! # Rejecting gate attempts @@ -15,6 +17,9 @@ the current wire memo. Every path first consumes exactly one gate-count mark and then halts with an explicit zero write. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/PositiveLoopReject.lean b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/PositiveLoopReject.lean index 2fcd3461..c51e3872 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/PositiveLoopReject.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/PositiveLoopReject.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate.LoopReject + +module +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Gate.LoopReject /-! # Rejecting decoded positive-family execution @@ -13,6 +15,9 @@ positive-family header. It shares the successful branch's named budgets while retaining a well-formed counter remainder and an explicit zero verdict. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/PositiveReject.lean b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/PositiveReject.lean index a7f30da7..6e77bf00 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/PositiveReject.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Execution/PositiveReject.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Internal.Codec -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution + +module +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution /-! # Rejecting positive-family setup @@ -15,6 +16,9 @@ blank while the counter prefix is built, then rejected explicitly. The frontier-level wrappers also cover a positive tag paired with the empty input. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Hoare.lean b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Hoare.lean index aef24b77..ce3819d1 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Hoare.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Hoare.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Family -import Complexitylib.Models.TuringMachine.Hoare + +module +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution.Family /-! # Hoare contract for the serialized-family evaluator core @@ -13,6 +14,9 @@ This file packages the total frontier execution theorem behind the public staged-tape precondition and defaulted-verdict postcondition. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Pure.lean b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Pure.lean index b6a9f140..8aebfbde 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Pure.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Pure.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.Core.Defs + +module +public import Complexitylib.Circuits.Encoding.Machine.Core.Defs /-! # Pure semantics for the streaming circuit evaluator @@ -17,6 +19,9 @@ retaining `evalFamilyCode` as their external specification; it is not a transition-level trace model. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Stage.lean b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Stage.lean index 36404af3..aa454ec7 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Stage.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Stage.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.Core.Defs -import Complexitylib.Models.TuringMachine.Hoare + +module +public import Complexitylib.Circuits.Encoding.Machine.Core.Defs +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic /-! # Circuit-evaluator staging seam @@ -13,6 +15,9 @@ This file connects the valid outer-pair staging contract to the streaming core's precondition across the standard sequential-composition tape transition. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Tape.lean b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Tape.lean index ee126d37..6633ff29 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Tape.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Core/Internal/Tape.lean @@ -3,7 +3,28 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.Core.Defs + +module +public import Complexitylib.Models.TuringMachine.Combinators +public import Complexitylib.Models.TuringMachine.Tape.Encoding +public import Mathlib.Analysis.SpecialFunctions.Pow.NNReal +public import Mathlib.Tactic.ENatToNat +public import Mathlib.Tactic.Measurability.Init +public import Mathlib.Tactic.NormNum.BigOperators +public import Mathlib.Tactic.NormNum.Irrational +public import Mathlib.Tactic.NormNum.IsCoprime +public import Mathlib.Tactic.NormNum.IsSquare +public import Mathlib.Tactic.NormNum.LegendreSymbol +public import Mathlib.Tactic.NormNum.ModEq +public import Mathlib.Tactic.NormNum.NatFactorial +public import Mathlib.Tactic.NormNum.NatFib +public import Mathlib.Tactic.NormNum.NatLog +public import Mathlib.Tactic.NormNum.NatSqrt +public import Mathlib.Tactic.NormNum.Ordinal +public import Mathlib.Tactic.NormNum.Parity +public import Mathlib.Tactic.NormNum.Prime +public import Mathlib.Tactic.NormNum.RealSqrt +public import Mathlib.Tactic.ReduceModChar /-! # Tape cursors for the streaming circuit evaluator @@ -14,6 +35,9 @@ the current zero-based read position. This is intentionally internal: the neutral endpoint and suffix predicates remain the public tape API. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/Defs.lean b/Complexitylib/Circuits/Encoding/Machine/Defs.lean index ef9e2e06..d8b96841 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Defs.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Defs.lean @@ -3,12 +3,14 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Family -import Complexitylib.Models.TuringMachine.Lift -import Complexitylib.Models.TuringMachine.Subroutines -import Complexitylib.Models.TuringMachine.Subroutines.PairSplit.Defs -import Complexitylib.Models.TuringMachine.Subroutines.PairValidate.Defs -import Complexitylib.Models.TuringMachine.Tape.Encoding + +module +public import Complexitylib.Circuits.Encoding.Family +public import Complexitylib.Models.TuringMachine.Lift +public import Complexitylib.Models.TuringMachine.Subroutines +public import Complexitylib.Models.TuringMachine.Subroutines.PairSplit.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.PairValidate.Defs +public import Complexitylib.Models.TuringMachine.Tape.Encoding /-! # Serialized circuit-evaluator machine front end @@ -19,6 +21,9 @@ places an evaluator core inside the valid branch, so malformed outer inputs can never fall through into that core. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/GateStream.lean b/Complexitylib/Circuits/Encoding/Machine/GateStream.lean index 224e23cc..0e972bd9 100644 --- a/Complexitylib/Circuits/Encoding/Machine/GateStream.lean +++ b/Complexitylib/Circuits/Encoding/Machine/GateStream.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.GateStream.Defs -import Complexitylib.Circuits.Encoding.Machine.GateStream.Internal + +module +public import Complexitylib.Circuits.Encoding.Machine.GateStream.Defs +public import Complexitylib.Circuits.Encoding.Machine.GateStream.Internal /-! # One streaming raw-gate step @@ -21,6 +23,9 @@ restored to zero and every other tape is preserved literally. - `emitRawGateStepTM_isTransducer` proves append-only-output safety. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/GateStream/Defs.lean b/Complexitylib/Circuits/Encoding/Machine/GateStream/Defs.lean index 6f1ab33f..72aea177 100644 --- a/Complexitylib/Circuits/Encoding/Machine/GateStream/Defs.lean +++ b/Complexitylib/Circuits/Encoding/Machine/GateStream/Defs.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.RawGate.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs + +module +public import Complexitylib.Circuits.Encoding.Machine.RawGate.Defs /-! # One streaming raw-gate step @@ -14,6 +15,9 @@ binary counter that records the first unused circuit wire. It is the atomic append operation used by circuit serializers. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/GateStream/Internal.lean b/Complexitylib/Circuits/Encoding/Machine/GateStream/Internal.lean index 72b81fea..dcb72da9 100644 --- a/Complexitylib/Circuits/Encoding/Machine/GateStream/Internal.lean +++ b/Complexitylib/Circuits/Encoding/Machine/GateStream/Internal.lean @@ -3,10 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.GateStream.Defs -import Complexitylib.Circuits.Encoding.Machine.RawGate -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc + +module +public import Complexitylib.Circuits.Encoding.Machine.GateStream.Defs +public import Complexitylib.Circuits.Encoding.Machine.RawGate /-! # One streaming raw-gate step -- proof internals @@ -17,6 +17,9 @@ ghost while converting successor's full-frame result into an exact work-tape update. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/Internal/FrontEnd.lean b/Complexitylib/Circuits/Encoding/Machine/Internal/FrontEnd.lean index 5124c55c..b847fd81 100644 --- a/Complexitylib/Circuits/Encoding/Machine/Internal/FrontEnd.lean +++ b/Complexitylib/Circuits/Encoding/Machine/Internal/FrontEnd.lean @@ -3,11 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.Defs -import Complexitylib.Models.TuringMachine.Hoare -import Complexitylib.Models.TuringMachine.Subroutines.Internal -import Complexitylib.Models.TuringMachine.Subroutines.PairSplit -import Complexitylib.Models.TuringMachine.Subroutines.PairValidate + +module +public import Complexitylib.Circuits.Encoding.Machine.Defs +public import Complexitylib.Models.TuringMachine.Hoare +public import Complexitylib.Models.TuringMachine.Subroutines.Internal +public import Complexitylib.Models.TuringMachine.Subroutines.PairSplit +public import Complexitylib.Models.TuringMachine.Subroutines.PairValidate /-! # Serialized circuit-evaluator front-end correctness @@ -16,6 +18,9 @@ Proof internals for validating a paired machine input, rewinding it, and staging its code and data components on appendable work tapes. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/NatCode.lean b/Complexitylib/Circuits/Encoding/Machine/NatCode.lean index 462805f9..411d0230 100644 --- a/Complexitylib/Circuits/Encoding/Machine/NatCode.lean +++ b/Complexitylib/Circuits/Encoding/Machine/NatCode.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.NatCode.Defs -import Complexitylib.Circuits.Encoding.Machine.NatCode.Internal + +module +public import Complexitylib.Circuits.Encoding.Machine.NatCode.Defs +public import Complexitylib.Circuits.Encoding.Machine.NatCode.Internal /-! # Machine emission of terminated-unary natural codes @@ -27,6 +29,9 @@ satisfies the one-way-output transducer discipline. - `emitNatCodeTM_isTransducer` proves one-way-output safety. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/NatCode/Defs.lean b/Complexitylib/Circuits/Encoding/Machine/NatCode/Defs.lean index 1fc9b2fc..45d8c2a5 100644 --- a/Complexitylib/Circuits/Encoding/Machine/NatCode/Defs.lean +++ b/Complexitylib/Circuits/Encoding/Machine/NatCode/Defs.lean @@ -3,9 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Defs -import Complexitylib.Models.TuringMachine.Registers.Emit -import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor + +module +public import Complexitylib.Models.TuringMachine.Registers.Emit +public import Complexitylib.Models.TuringMachine.Subroutines +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Defs +public import Mathlib.Tactic.NormNum.Inv +public import Mathlib.Tactic.NormNum.Pow /-! # Machine emission of terminated-unary natural codes — definitions @@ -21,6 +25,9 @@ preserved limit, the restored scratch counter, and every unrelated work tape are intended to be preserved literally. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/NatCode/Internal.lean b/Complexitylib/Circuits/Encoding/Machine/NatCode/Internal.lean index cc39f757..1998ae9a 100644 --- a/Complexitylib/Circuits/Encoding/Machine/NatCode/Internal.lean +++ b/Complexitylib/Circuits/Encoding/Machine/NatCode/Internal.lean @@ -3,12 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.NatCode.Defs -import Complexitylib.Models.TuringMachine.Combinators.Internal.Seq -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Internal.Control -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc -import Complexitylib.Models.TuringMachine.Subroutines.ClearWork + +module +public import Complexitylib.Circuits.Encoding.Machine.NatCode.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc +public import Complexitylib.Models.TuringMachine.Subroutines.ClearWork +public import Complexitylib.Circuits.Encoding.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor /-! # Machine emission of terminated-unary natural codes — proof internals @@ -18,6 +19,9 @@ emission. The proof tracks concrete counter and output tapes at every loop index, then composes scratch clearing and the terminating zero-bit emitter. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode @@ -29,13 +33,13 @@ open TM variable {n : ℕ} /-- Replace the scratch counter by the canonical binary tape for `value`. -/ -private def natCodeWorkAt (work : Fin n → Tape) (counterIdx : Fin n) +def natCodeWorkAt (work : Fin n → Tape) (counterIdx : Fin n) (value : ℕ) : Fin n → Tape := Function.update work counterIdx ((Tape.init (value.bits.map Γ.ofBool)).move Dir3.right) /-- Concrete output tape after appending `count` one-bits. -/ -private def natCodeOutputAt (out : Tape) : ℕ → Tape +def natCodeOutputAt (out : Tape) : ℕ → Tape | 0 => out | count + 1 => (natCodeOutputAt out count).writeAndMove Γ.one Dir3.right diff --git a/Complexitylib/Circuits/Encoding/Machine/RawGate.lean b/Complexitylib/Circuits/Encoding/Machine/RawGate.lean index 382127dd..cd337000 100644 --- a/Complexitylib/Circuits/Encoding/Machine/RawGate.lean +++ b/Complexitylib/Circuits/Encoding/Machine/RawGate.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.RawGate.Defs -import Complexitylib.Circuits.Encoding.Machine.RawGate.Internal + +module +public import Complexitylib.Circuits.Encoding.Machine.RawGate.Defs +public import Complexitylib.Circuits.Encoding.Machine.RawGate.Internal /-! # Machine emission of raw circuit gates @@ -21,6 +23,9 @@ and the reusable zero scratch are restored literally. - `emitRawGateTM_isTransducer` proves one-way-output safety. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/RawGate/Defs.lean b/Complexitylib/Circuits/Encoding/Machine/RawGate/Defs.lean index 5cffc889..7bbe46f9 100644 --- a/Complexitylib/Circuits/Encoding/Machine/RawGate/Defs.lean +++ b/Complexitylib/Circuits/Encoding/Machine/RawGate/Defs.lean @@ -3,7 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.NatCode.Defs + +module +public import Complexitylib.Circuits.Encoding.Machine.NatCode.Defs +public import Complexitylib.Circuits.AndOrNot.Defs /-! # Machine emission of raw circuit gates — definitions @@ -14,6 +17,9 @@ the references are read from preserved canonical binary work tapes. One reusable zero scratch tape drives both natural-code emitters. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Machine/RawGate/Internal.lean b/Complexitylib/Circuits/Encoding/Machine/RawGate/Internal.lean index 20b29807..ee8f4bdb 100644 --- a/Complexitylib/Circuits/Encoding/Machine/RawGate/Internal.lean +++ b/Complexitylib/Circuits/Encoding/Machine/RawGate/Internal.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.NatCode -import Complexitylib.Circuits.Encoding.Machine.RawGate.Defs -import Complexitylib.Models.TuringMachine.Hoare.Space + +module +public import Complexitylib.Circuits.Encoding.Machine.NatCode +public import Complexitylib.Circuits.Encoding.Machine.RawGate.Defs /-! # Machine emission of raw circuit gates — proof internals @@ -15,6 +16,9 @@ emitters. Both dynamic reference tapes and the reusable zero scratch are restored literally at the endpoint. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Threshold.lean b/Complexitylib/Circuits/Encoding/Threshold.lean index b2271bfa..bef0cb1b 100644 --- a/Complexitylib/Circuits/Encoding/Threshold.lean +++ b/Complexitylib/Circuits/Encoding/Threshold.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Threshold.Internal + +module +public import Complexitylib.Circuits.Encoding.Threshold.Internal /-! # Correctness of raw threshold-circuit fragments @@ -28,6 +30,9 @@ higher layer where both APIs are already available. correctness of iterative evaluation. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Threshold/Defs.lean b/Complexitylib/Circuits/Encoding/Threshold/Defs.lean index 29cf762a..23f5846b 100644 --- a/Complexitylib/Circuits/Encoding/Threshold/Defs.lean +++ b/Complexitylib/Circuits/Encoding/Threshold/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Fragment.Defs + +module +public import Complexitylib.Circuits.Encoding.Fragment.Defs /-! # Raw threshold-circuit fragments @@ -22,6 +24,9 @@ row-major order, and ends with a copy of the requested final state. Thus it has exactly `3 + 2 * k * threshold` gates for `k` referenced inputs. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Threshold/Internal.lean b/Complexitylib/Circuits/Encoding/Threshold/Internal.lean index 1e80b08c..d9185780 100644 --- a/Complexitylib/Circuits/Encoding/Threshold/Internal.lean +++ b/Complexitylib/Circuits/Encoding/Threshold/Internal.lean @@ -3,8 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Threshold.Defs -import Complexitylib.Circuits.Encoding.Fragment + +module +public import Complexitylib.Circuits.Encoding.Threshold.Defs +public import Complexitylib.Circuits.Encoding.Fragment +public import Std.Tactic.BVDecide.Normalize.BitVec /-! # Raw threshold-fragment internals @@ -14,6 +17,9 @@ program defined in `Complexitylib.Circuits.Encoding.Threshold.Defs`. Public statements are re-exported by `Complexitylib.Circuits.Encoding.Threshold`. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/ToCircuit.lean b/Complexitylib/Circuits/Encoding/ToCircuit.lean index 558353a6..27d7e62c 100644 --- a/Complexitylib/Circuits/Encoding/ToCircuit.lean +++ b/Complexitylib/Circuits/Encoding/ToCircuit.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Internal.ToCircuit + +module +public import Complexitylib.Circuits.Encoding.Internal.ToCircuit /-! # Typed circuits reconstructed from raw circuit syntax @@ -27,6 +29,9 @@ Boolean evaluation, and exact gate count. - `RawCircuit.size_toCircuit`: typed size equals the raw gate count. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/ToCircuit/Defs.lean b/Complexitylib/Circuits/Encoding/ToCircuit/Defs.lean index 6e18d15a..b2e149f4 100644 --- a/Complexitylib/Circuits/Encoding/ToCircuit/Defs.lean +++ b/Complexitylib/Circuits/Encoding/ToCircuit/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Defs + +module +public import Complexitylib.Circuits.Encoding.Defs /-! # Reconstructing typed circuits from raw circuit syntax @@ -14,6 +16,9 @@ gate becomes the sole output gate; every preceding raw gate becomes an internal gate in the same order. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode diff --git a/Complexitylib/Circuits/Encoding/Validation.lean b/Complexitylib/Circuits/Encoding/Validation.lean index 762d69cc..b9cb6486 100644 --- a/Complexitylib/Circuits/Encoding/Validation.lean +++ b/Complexitylib/Circuits/Encoding/Validation.lean @@ -3,8 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Family -import Complexitylib.Circuits.Encoding.Machine.Core.Internal + +module +public import Complexitylib.Circuits.Encoding.Family +public meta import Complexitylib.Circuits.Encoding.Family +public import Complexitylib.Circuits.Encoding.Machine.Core.Internal +public meta import Complexitylib.Circuits.Encoding.Machine.Core.Internal /-! # Encoded-circuit evaluator — executable validation @@ -18,6 +22,9 @@ This module is not part of the public import graph. Build it explicitly with `lake build --wfail Complexitylib.Circuits.Encoding.Validation`. -/ + +@[expose] public section + namespace Complexity namespace CircuitCode.Validation diff --git a/Complexitylib/Circuits/EssentialInput.lean b/Complexitylib/Circuits/EssentialInput.lean index cf48a964..21f085ec 100644 --- a/Complexitylib/Circuits/EssentialInput.lean +++ b/Complexitylib/Circuits/EssentialInput.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Data.Fintype.BigOperators -import Complexitylib.Circuits.Basic + +module +public import Complexitylib.Circuits.Basic +public import Mathlib.Data.Fintype.Pi /-! # Essential Inputs @@ -17,6 +19,9 @@ for a Boolean function. * `essentialInputs` — the set of essential input variables -/ + +@[expose] public section + namespace Complexity /-- A function `f` depends on input variable `i` if flipping that bit diff --git a/Complexitylib/Circuits/Family.lean b/Complexitylib/Circuits/Family.lean index 8ba083e5..4b418621 100644 --- a/Complexitylib/Circuits/Family.lean +++ b/Complexitylib/Circuits/Family.lean @@ -3,8 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Family.Defs -import Complexitylib.Asymptotics + +module +public import Complexitylib.Circuits.Family.Defs +public import Complexitylib.Asymptotics +public import Complexitylib.Circuits.BitString /-! # Boolean circuit families @@ -14,6 +17,9 @@ size/depth bounds, and the equivalence between pointwise polynomial bounds and the power big-O convention used by complexity classes. -/ + +@[expose] public section + namespace Complexity namespace Circuit diff --git a/Complexitylib/Circuits/Family/Defs.lean b/Complexitylib/Circuits/Family/Defs.lean index dc5b1ff7..cc0626b1 100644 --- a/Complexitylib/Circuits/Family/Defs.lean +++ b/Complexitylib/Circuits/Family/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BitString -import Mathlib.Algebra.Polynomial.Eval.Defs + +module +public import Mathlib.Algebra.Polynomial.Eval.Defs +public import Complexitylib.Circuits.Basic /-! # Boolean circuit families — definitions @@ -18,6 +20,9 @@ The first component of `circuits n` is the number of internal gates. Family free per-edge negation flags. -/ + +@[expose] public section + namespace Complexity namespace Circuit diff --git a/Complexitylib/Circuits/Formula.lean b/Complexitylib/Circuits/Formula.lean index c5670ced..6654fbc5 100644 --- a/Complexitylib/Circuits/Formula.lean +++ b/Complexitylib/Circuits/Formula.lean @@ -3,10 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Data.Nat.Basic -import Mathlib.Data.Bool.Basic -import Mathlib.Data.Finset.Basic -import Mathlib.Data.Finset.Union + +module +public import Mathlib.Algebra.Group.Nat.Defs +public import Mathlib.Algebra.Order.ZeroLEOne +public import Mathlib.Data.Finset.Insert +public import Mathlib.Data.Finset.Lattice.Basic /-! # Boolean formulas and formula size @@ -31,6 +33,9 @@ measures must not be conflated in lower-bound arguments. locality property (evaluation depends only on the variables that occur) -/ + +@[expose] public section + namespace Complexity /-- A Boolean formula: a *tree* over variables, the constants `⊤`/`⊥`, and the diff --git a/Complexitylib/Circuits/FormulaEncoding.lean b/Complexitylib/Circuits/FormulaEncoding.lean index 3116466b..c12234ee 100644 --- a/Complexitylib/Circuits/FormulaEncoding.lean +++ b/Complexitylib/Circuits/FormulaEncoding.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.FormulaEncoding.Defs -import Complexitylib.Circuits.FormulaEncoding.Internal + +module +public import Complexitylib.Circuits.FormulaEncoding.Defs +public import Complexitylib.Circuits.FormulaEncoding.Internal /-! # Canonical postfix encoding of Boolean formulas @@ -26,6 +28,9 @@ serialization is injective, and the code-length equation records every bit. - `FormulaCode.length_encode` -- exact serialized length. -/ + +@[expose] public section + namespace Complexity namespace FormulaCode diff --git a/Complexitylib/Circuits/FormulaEncoding/Defs.lean b/Complexitylib/Circuits/FormulaEncoding/Defs.lean index cb13a09e..87feeab8 100644 --- a/Complexitylib/Circuits/FormulaEncoding/Defs.lean +++ b/Complexitylib/Circuits/FormulaEncoding/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Defs -import Complexitylib.Circuits.Formula + +module +public import Complexitylib.Circuits.Encoding.Defs +public import Complexitylib.Circuits.Formula /-! # Machine-facing encoding of Boolean formulas @@ -20,6 +22,9 @@ on-tape tree parser and gives the later Barrington generator a simple, self-delimiting input language. -/ + +@[expose] public section + namespace Complexity namespace FormulaCode diff --git a/Complexitylib/Circuits/FormulaEncoding/Internal.lean b/Complexitylib/Circuits/FormulaEncoding/Internal.lean index 0a70dd6b..e97d8354 100644 --- a/Complexitylib/Circuits/FormulaEncoding/Internal.lean +++ b/Complexitylib/Circuits/FormulaEncoding/Internal.lean @@ -3,8 +3,27 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding -import Complexitylib.Circuits.FormulaEncoding.Defs + +module +public import Complexitylib.Circuits.FormulaEncoding.Defs +public import Complexitylib.Circuits.Encoding.Internal.Codec +public import Mathlib.Analysis.SpecialFunctions.Pow.NNReal +public import Mathlib.Tactic.Measurability.Init +public import Mathlib.Tactic.NormNum.BigOperators +public import Mathlib.Tactic.NormNum.Irrational +public import Mathlib.Tactic.NormNum.IsCoprime +public import Mathlib.Tactic.NormNum.IsSquare +public import Mathlib.Tactic.NormNum.LegendreSymbol +public import Mathlib.Tactic.NormNum.ModEq +public import Mathlib.Tactic.NormNum.NatFactorial +public import Mathlib.Tactic.NormNum.NatFib +public import Mathlib.Tactic.NormNum.NatLog +public import Mathlib.Tactic.NormNum.NatSqrt +public import Mathlib.Tactic.NormNum.Ordinal +public import Mathlib.Tactic.NormNum.Parity +public import Mathlib.Tactic.NormNum.Prime +public import Mathlib.Tactic.NormNum.RealSqrt +public import Mathlib.Tactic.ReduceModChar /-! # Boolean-formula codec internals @@ -13,6 +32,9 @@ This module proves the stack-machine, round-trip, injectivity, and length properties of the canonical postfix formula encoding. -/ + +@[expose] public section + namespace Complexity namespace FormulaCode diff --git a/Complexitylib/Circuits/Hardwiring.lean b/Complexitylib/Circuits/Hardwiring.lean index 45817906..05906154 100644 --- a/Complexitylib/Circuits/Hardwiring.lean +++ b/Complexitylib/Circuits/Hardwiring.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Nondeterminism + +module +public import Complexitylib.Circuits.Nondeterminism /-! # Hardwiring Prefixes of Circuit Inputs @@ -26,6 +28,9 @@ Circuit families represent the zero-input member separately with `emptyOutput`. - `Circuit.restrictPrefix_size`: hardwiring preserves the exact circuit size. -/ + +@[expose] public section + namespace Complexity namespace Circuit diff --git a/Complexitylib/Circuits/Internal/AndOrNot.lean b/Complexitylib/Circuits/Internal/AndOrNot.lean index d6d8f77c..e9aa3ffe 100644 --- a/Complexitylib/Circuits/Internal/AndOrNot.lean +++ b/Complexitylib/Circuits/Internal/AndOrNot.lean @@ -3,7 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AndOrNot.Defs + +module +public import Complexitylib.Circuits.AndOrNot.Defs +public import Std.Tactic.BVDecide.Normalize.BitVec +public import Std.Tactic.BVDecide.Normalize.Prop /-! # Internal: AND/OR/NOT Completeness Proof @@ -13,6 +17,9 @@ in `Complexitylib.Circuits.AndOrNot.Defs`; this module is re-exported through `Complexitylib.Circuits.AndOrNot`. -/ + +@[expose] public section + namespace Complexity /-- Indicator circuit: outputs `true` iff the input equals `s`. @@ -34,7 +41,7 @@ For each of the `2^N` possible inputs `s` (decoded via `Nat.testBit`), internal gate `i` is the indicator AND for `s` when `f s = true`, or a trivially-false 0-input OR otherwise. The single output OR gate disjoins all internal gates. -/ -private def andOrNotFor.mkGate {N : Nat} (f : BitString N → Bool) (i : Fin (2 ^ N)) : +def andOrNotFor.mkGate {N : Nat} (f : BitString N → Bool) (i : Fin (2 ^ N)) : Gate Basis.unboundedAndOr (N + 2 ^ N) := if f (fun j => i.val.testBit j.val) then { op := .and, fanIn := N, arityOk := trivial, @@ -65,7 +72,8 @@ def andOrNotFor {N : Nat} [NeZero N] (f : BitString N → Bool) : { op := .or, fanIn := 2 ^ N, arityOk := trivial, inputs := fun j => (j.natAdd N), negated := fun _ => false } - acyclic := andOrNotFor.mkGate_acyclic f + acyclic i k := by + exact andOrNotFor.mkGate_acyclic f i k private lemma AONFor_wireValue_gate {N : Nat} [NeZero N] (f : BitString N → Bool) (x : BitString N) (i : Fin (2 ^ N)) : @@ -225,13 +233,18 @@ theorem andOrNotFor_eval {N : Nat} [NeZero N] (f : BitString N → Bool) : /-- Internal gate for the multi-output DNF circuit. Gate `idx` encodes output bit `j = idx / 2^N` and indicator index `i = idx % 2^N`. If `f(bitstring i)[j] = true`, it's an AND indicator gate; otherwise a trivially-false OR gate. -/ -private def AONForM_j {N M : Nat} (idx : Fin (M * 2 ^ N)) : Fin M := +@[nolint defsWithUnderscore] +def AONForM_j {N M : Nat} (idx : Fin (M * 2 ^ N)) : Fin M := ⟨idx.val / 2 ^ N, Nat.div_lt_of_lt_mul (Nat.mul_comm M (2^N) ▸ idx.isLt)⟩ -private def AONForM_i {N : Nat} {M : Nat} (idx : Fin (M * 2 ^ N)) : Fin (2 ^ N) := +/-- Indicator coordinate encoded by a gate index in the multi-output DNF circuit. -/ +@[nolint defsWithUnderscore] +def AONForM_i {N : Nat} {M : Nat} (idx : Fin (M * 2 ^ N)) : Fin (2 ^ N) := ⟨idx.val % 2 ^ N, Nat.mod_lt _ (Nat.two_pow_pos N)⟩ -private def AONForM_mkGate {N M : Nat} (f : BitString N → BitString M) (idx : Fin (M * 2 ^ N)) : +/-- Gate selected by an encoded output and indicator pair in the multi-output DNF circuit. -/ +@[nolint defsWithUnderscore] +def AONForM_mkGate {N M : Nat} (f : BitString N → BitString M) (idx : Fin (M * 2 ^ N)) : Gate Basis.unboundedAndOr (N + M * 2 ^ N) := if f (fun k => (AONForM_i idx).val.testBit k.val) (AONForM_j idx) then { op := .and, fanIn := N, arityOk := trivial, @@ -269,9 +282,11 @@ def andOrNotForM {N M : Nat} [NeZero N] [NeZero M] (f : BitString N → BitStrin gates := AONForM_mkGate f outputs j := { op := .or, fanIn := 2 ^ N, arityOk := trivial, - inputs := fun k => ⟨N + j.val * 2 ^ N + k.val, AONForM_output_bound j k⟩, + inputs := fun k => ⟨N + j.val * 2 ^ N + k.val, by + exact AONForM_output_bound j k⟩, negated := fun _ => false } - acyclic := AONForM_mkGate_acyclic f + acyclic idx k := by + exact AONForM_mkGate_acyclic f idx k private lemma AONForM_wireValue_input {N M : Nat} [NeZero N] [NeZero M] (f : BitString N → BitString M) (x : BitString N) (k : Fin N) : diff --git a/Complexitylib/Circuits/Internal/Bridge.lean b/Complexitylib/Circuits/Internal/Bridge.lean index d634ac56..066d93f5 100644 --- a/Complexitylib/Circuits/Internal/Bridge.lean +++ b/Complexitylib/Circuits/Internal/Bridge.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Internal.ShannonBridge -import Complexitylib.Circuits.Internal.SchnorrBridge + +module +public import Complexitylib.Circuits.Internal.ShannonBridge +public import Complexitylib.Circuits.Internal.SchnorrBridge /-! # Internal circuit-descriptor bridges diff --git a/Complexitylib/Circuits/Internal/CircuitDescriptor.lean b/Complexitylib/Circuits/Internal/CircuitDescriptor.lean index 5dd00a20..c109e366 100644 --- a/Complexitylib/Circuits/Internal/CircuitDescriptor.lean +++ b/Complexitylib/Circuits/Internal/CircuitDescriptor.lean @@ -3,9 +3,28 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Data.Fintype.BigOperators -import Mathlib.Tactic -import Complexitylib.Circuits.Basic + +module +public import Complexitylib.Circuits.Basic +public import Mathlib.Analysis.SpecialFunctions.Pow.NNReal +public import Mathlib.Tactic.ENatToNat +public import Mathlib.Tactic.Measurability.Init +public import Mathlib.Tactic.NormNum.BigOperators +public import Mathlib.Tactic.NormNum.Irrational +public import Mathlib.Tactic.NormNum.IsCoprime +public import Mathlib.Tactic.NormNum.IsSquare +public import Mathlib.Tactic.NormNum.LegendreSymbol +public import Mathlib.Tactic.NormNum.ModEq +public import Mathlib.Tactic.NormNum.NatFactorial +public import Mathlib.Tactic.NormNum.NatFib +public import Mathlib.Tactic.NormNum.NatLog +public import Mathlib.Tactic.NormNum.NatSqrt +public import Mathlib.Tactic.NormNum.Ordinal +public import Mathlib.Tactic.NormNum.Parity +public import Mathlib.Tactic.NormNum.Prime +public import Mathlib.Tactic.NormNum.RealSqrt +public import Mathlib.Tactic.ReduceModChar +public import Std.Tactic.BVDecide.Normalize.Prop /-! # Internal: Circuit Descriptors and Shannon Counting Bound @@ -15,6 +34,9 @@ theorem `shannon_lower_bound_circuit` (which speaks in terms of `Circuit`) is in `Complexitylib.Circuits.Internal.Bridge`. -/ + +@[expose] public section + namespace Complexity /-! ## Gate and Circuit Descriptors -/ diff --git a/Complexitylib/Circuits/Internal/CircuitToDescriptor.lean b/Complexitylib/Circuits/Internal/CircuitToDescriptor.lean index d39c33a4..93936494 100644 --- a/Complexitylib/Circuits/Internal/CircuitToDescriptor.lean +++ b/Complexitylib/Circuits/Internal/CircuitToDescriptor.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AndOrNot.Defs -import Complexitylib.Circuits.Internal.CircuitDescriptor + +module +public import Complexitylib.Circuits.AndOrNot.Defs +public import Complexitylib.Circuits.Internal.CircuitDescriptor /-! # Internal: Typed Circuits as Circuit Descriptors @@ -15,6 +17,9 @@ this bridge do not also acquire the lower-bound and padding machinery from `Internal.Bridge`. -/ + +@[expose] public section + namespace Complexity open CircDesc diff --git a/Complexitylib/Circuits/Internal/LowerBound.lean b/Complexitylib/Circuits/Internal/LowerBound.lean index 3d097361..1bd3660e 100644 --- a/Complexitylib/Circuits/Internal/LowerBound.lean +++ b/Complexitylib/Circuits/Internal/LowerBound.lean @@ -3,10 +3,14 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Algebra.Order.BigOperators.Group.Finset -import Complexitylib.Circuits.EssentialInput -import Complexitylib.Circuits.AndOrNot.Defs -import Complexitylib.Circuits.Dependency.Defs + +module +public import Mathlib.Algebra.Order.BigOperators.Group.Finset +public import Complexitylib.Circuits.EssentialInput +public import Complexitylib.Circuits.AndOrNot.Defs +public import Complexitylib.Circuits.Dependency.Defs +public import Mathlib.Data.Fintype.BigOperators +public import Std.Tactic.BVDecide.Normalize.Prop /-! # Internal: Gate Elimination Lower Bound @@ -21,6 +25,9 @@ are stated in `Complexitylib.Circuits.LowerBound`. -/ + +@[expose] public section + namespace Complexity namespace Circuit diff --git a/Complexitylib/Circuits/Internal/Nondeterminism.lean b/Complexitylib/Circuits/Internal/Nondeterminism.lean index 8835aa8a..0d61e608 100644 --- a/Complexitylib/Circuits/Internal/Nondeterminism.lean +++ b/Complexitylib/Circuits/Internal/Nondeterminism.lean @@ -3,8 +3,26 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Nondeterminism.Defs -import Complexitylib.Circuits.Internal.ShannonUpper + +module +public import Complexitylib.Circuits.Nondeterminism.Defs +public import Complexitylib.Circuits.AndOrNot.Defs +public import Mathlib.Analysis.SpecialFunctions.Pow.NNReal +public import Mathlib.Tactic.Measurability.Init +public import Mathlib.Tactic.NormNum.BigOperators +public import Mathlib.Tactic.NormNum.Irrational +public import Mathlib.Tactic.NormNum.IsCoprime +public import Mathlib.Tactic.NormNum.IsSquare +public import Mathlib.Tactic.NormNum.LegendreSymbol +public import Mathlib.Tactic.NormNum.ModEq +public import Mathlib.Tactic.NormNum.NatFactorial +public import Mathlib.Tactic.NormNum.NatFib +public import Mathlib.Tactic.NormNum.NatLog +public import Mathlib.Tactic.NormNum.NatSqrt +public import Mathlib.Tactic.NormNum.Ordinal +public import Mathlib.Tactic.NormNum.Parity +public import Mathlib.Tactic.NormNum.Prime +public import Mathlib.Tactic.NormNum.RealSqrt /-! # Internal: Nondeterministic Quantification Circuit Constructions @@ -37,6 +55,9 @@ complexity of the OR of two Boolean functions by the sum of their complexities plus one; no OR-specific construction is defined here. -/ + +@[expose] public section + namespace Complexity variable {k m : Nat} @@ -63,7 +84,7 @@ private theorem andOr2_eval_two {W : Nat} (g : Gate Basis.andOr2 W) /-! ## Restriction gate construction -/ /-- A constant-output gate: `OR(x, ¬x) = true` or `AND(x, ¬x) = false`. -/ -private def mkConstGateBounded {G : Nat} [NeZero m] (val : Bool) (bound : Nat) : +def mkConstGateBounded {G : Nat} [NeZero m] (val : Bool) (bound : Nat) : { g : Gate Basis.andOr2 (k + m + G) // ∀ j : Fin g.fanIn, (g.inputs j).val < k + m + bound } := have hW : 0 < k + m + G := by have := NeZero.ne m; omega @@ -80,7 +101,7 @@ private def mkConstGateBounded {G : Nat} [NeZero m] (val : Bool) (bound : Nat) : fun _ => by dsimp; exact hB⟩ /-- An identity/passthrough gate: `OP(w, w)` with negation `neg`. -/ -private def mkIdentGateBounded {G : Nat} (op : AndOrOp) (w : Fin (k + m + G)) (neg : Bool) +def mkIdentGateBounded {G : Nat} (op : AndOrOp) (w : Fin (k + m + G)) (neg : Bool) (bound : Nat) (hw : w.val < k + m + bound) : { g : Gate Basis.andOr2 (k + m + G) // ∀ j : Fin g.fanIn, (g.inputs j).val < k + m + bound } := @@ -112,7 +133,7 @@ private theorem mkIdentGateP_eval {G : Nat} (op : AndOrOp) (w : Fin (k + m + G)) The gate's two inputs are inspected. For each input referencing wire 0, the effective constant `b ^^ negated` is computed. The gate is then simplified: identity, constant, or shifted, depending on the case. -/ -private def restrictGateBounded {G : Nat} [NeZero m] (b : Bool) +def restrictGateBounded {G : Nat} [NeZero m] (b : Bool) (g : Gate Basis.andOr2 ((k + 1) + m + G)) (hfanIn : g.fanIn = 2) (bound : Nat) diff --git a/Complexitylib/Circuits/Internal/NormalForm.lean b/Complexitylib/Circuits/Internal/NormalForm.lean index eda1576e..0fc7b5de 100644 --- a/Complexitylib/Circuits/Internal/NormalForm.lean +++ b/Complexitylib/Circuits/Internal/NormalForm.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.NormalForm.Defs -import Complexitylib.Circuits.AndOrNot.Defs -import Mathlib.Data.Fintype.BigOperators + +module +public import Complexitylib.Circuits.NormalForm.Defs +public import Complexitylib.Circuits.AndOrNot.Defs +public import Mathlib.Data.Fintype.BigOperators /-! # Internal: Normal Form Proof Machinery @@ -23,6 +25,9 @@ This internal module contains the proof infrastructure for CNF/DNF: The public interface re-exports the main theorems from `Complexitylib.Circuits.NormalForm`. -/ + +@[expose] public section + namespace Complexity /-! ## Helper lemmas for toCircuit correctness -/ diff --git a/Complexitylib/Circuits/Internal/Schnorr.lean b/Complexitylib/Circuits/Internal/Schnorr.lean index 3a640075..6f759d57 100644 --- a/Complexitylib/Circuits/Internal/Schnorr.lean +++ b/Complexitylib/Circuits/Internal/Schnorr.lean @@ -3,9 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Tactic -import Complexitylib.Circuits.XOR -import Complexitylib.Circuits.Internal.CircuitDescriptor + +module +public import Complexitylib.Circuits.XOR +public import Complexitylib.Circuits.Internal.CircuitDescriptor + +@[expose] public section namespace Complexity @@ -21,6 +24,8 @@ The public definitions (`Schnorr.xorBool`, `Schnorr.xorBool_flip`, `schnorr_lower_bound_circuit` is accessible through `Complexitylib.Circuits.Schnorr`. -/ + + namespace Schnorr /-- Insert value `b` at position `a` in a BitString. -/ diff --git a/Complexitylib/Circuits/Internal/SchnorrBridge.lean b/Complexitylib/Circuits/Internal/SchnorrBridge.lean index 8a4e52a3..3996a54c 100644 --- a/Complexitylib/Circuits/Internal/SchnorrBridge.lean +++ b/Complexitylib/Circuits/Internal/SchnorrBridge.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Internal.CircuitToDescriptor -import Complexitylib.Circuits.Internal.Schnorr + +module +public import Complexitylib.Circuits.Internal.CircuitToDescriptor +public import Complexitylib.Circuits.Internal.Schnorr /-! # Internal: Schnorr bridge from descriptors to typed circuits @@ -13,6 +15,9 @@ This module transports the descriptor-level gate-elimination theorem to the typed fan-in-two circuit model. -/ + +@[expose] public section + namespace Complexity open CircDesc diff --git a/Complexitylib/Circuits/Internal/ShannonBridge.lean b/Complexitylib/Circuits/Internal/ShannonBridge.lean index c8d633d9..ae27bd2f 100644 --- a/Complexitylib/Circuits/Internal/ShannonBridge.lean +++ b/Complexitylib/Circuits/Internal/ShannonBridge.lean @@ -3,7 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Internal.CircuitToDescriptor + +module +public import Complexitylib.Circuits.Internal.CircuitToDescriptor +public import Std.Tactic.BVDecide.Normalize.Bool /-! # Internal: Shannon bridge from descriptors to typed circuits @@ -13,6 +16,9 @@ size used by the Shannon counting argument and transfers the resulting lower bound back to `Circuit`. -/ + +@[expose] public section + namespace Complexity open CircDesc diff --git a/Complexitylib/Circuits/Internal/ShannonUpper.lean b/Complexitylib/Circuits/Internal/ShannonUpper.lean index 719a1278..5dd37c66 100644 --- a/Complexitylib/Circuits/Internal/ShannonUpper.lean +++ b/Complexitylib/Circuits/Internal/ShannonUpper.lean @@ -3,9 +3,29 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AndOrNot.Defs -import Mathlib.Data.Nat.Log -import Mathlib.Tactic + +module +public import Complexitylib.Circuits.AndOrNot.Defs +public import Mathlib.Analysis.SpecialFunctions.Pow.NNReal +public import Mathlib.Tactic.ENatToNat +public import Mathlib.Tactic.Measurability.Init +public import Mathlib.Tactic.NormNum.BigOperators +public import Mathlib.Tactic.NormNum.Irrational +public import Mathlib.Tactic.NormNum.IsCoprime +public import Mathlib.Tactic.NormNum.IsSquare +public import Mathlib.Tactic.NormNum.LegendreSymbol +public import Mathlib.Tactic.NormNum.ModEq +public import Mathlib.Tactic.NormNum.NatFactorial +public import Mathlib.Tactic.NormNum.NatFib +public import Mathlib.Tactic.NormNum.NatLog +public import Mathlib.Tactic.NormNum.NatSqrt +public import Mathlib.Tactic.NormNum.Ordinal +public import Mathlib.Tactic.NormNum.Parity +public import Mathlib.Tactic.NormNum.Prime +public import Mathlib.Tactic.NormNum.RealSqrt +public import Mathlib.Tactic.ReduceModChar +public import Std.Tactic.BVDecide.Normalize.BitVec +public import Std.Tactic.BVDecide.Normalize.Prop /-! # Internal: Shannon Upper Bound Construction @@ -28,6 +48,9 @@ for column functions, AND/OR combining layers. Total ≤ `18 · 2^N / N` gates for `N ≥ 16`. -/ + +@[expose] public section + namespace Complexity namespace ShannonUpper @@ -43,7 +66,7 @@ def dataBits (N : Nat) : Nat := N - addrBits N /-! ## Gate Construction Helpers -/ /-- Build a fan-in-2 gate bundled with an acyclicity proof. -/ -private def mkGate2' (op : AndOrOp) {W : Nat} (w₀ w₁ : Fin W) (n₀ n₁ : Bool) +def mkGate2' (op : AndOrOp) {W : Nat} (w₀ w₁ : Fin W) (n₀ n₁ : Bool) (bound : Nat) (hw₀ : w₀.val < bound) (hw₁ : w₁.val < bound) : { g : Gate Basis.andOr2 W // ∀ k : Fin g.fanIn, (g.inputs k).val < bound } := ⟨{ op := op, fanIn := 2, arityOk := rfl, @@ -52,7 +75,7 @@ private def mkGate2' (op : AndOrOp) {W : Nat} (w₀ w₁ : Fin W) (n₀ n₁ : B fun k => by dsimp; split_ifs <;> assumption⟩ /-- Remap a wire from c₂'s space into the combined space. -/ -private def remap₂ (N G₁ G₂ : Nat) (w : Fin (N + G₂)) : Fin (N + (G₁ + G₂ + 2)) := +def remap₂ (N G₁ G₂ : Nat) (w : Fin (N + G₂)) : Fin (N + (G₁ + G₂ + 2)) := if h : w.val < N then ⟨w.val, by omega⟩ else ⟨w.val + G₁ + 1, by have := w.isLt; omega⟩ @@ -61,17 +84,20 @@ private lemma remap₂_val_lt (N G₁ G₂ : Nat) (w : Fin (N + G₂)) (remap₂ N G₁ G₂ w).val < N + bound := by unfold remap₂; split_ifs <;> dsimp <;> omega -private def gw (idx : Nat) {W : Nat} (g : Gate Basis.andOr2 W) +/-- The input wire at `idx` of a binary AND/OR gate. -/ +def gw (idx : Nat) {W : Nat} (g : Gate Basis.andOr2 W) (_ : idx < 2 := by omega) : Fin W := g.inputs ⟨idx, by rw [fanIn_andOr2]; omega⟩ -private def gn (idx : Nat) {W : Nat} (g : Gate Basis.andOr2 W) + +/-- Whether the input at `idx` of a binary AND/OR gate is negated. -/ +def gn (idx : Nat) {W : Nat} (g : Gate Basis.andOr2 W) (_ : idx < 2 := by omega) : Bool := g.negated ⟨idx, by rw [fanIn_andOr2]; omega⟩ /-! ## Binary Circuit Composition -/ /-- Gate + acyclicity proof for the binary composition, bundled as a subtype. -/ -private def binopGWP {N G₁ G₂ : Nat} [NeZero N] +def binopGWP {N G₁ G₂ : Nat} [NeZero N] (c₁ : Circuit Basis.andOr2 N 1 G₁) (c₂ : Circuit Basis.andOr2 N 1 G₂) (i : Fin (G₁ + G₂ + 2)) : { g : Gate Basis.andOr2 (N + (G₁ + G₂ + 2)) // @@ -92,18 +118,22 @@ private def binopGWP {N G₁ G₂ : Nat} [NeZero N] let g := c₂.gates ⟨i.val - G₁ - 1, by omega⟩ mkGate2' g.op (remap₂ N G₁ G₂ (gw 0 g)) (remap₂ N G₁ G₂ (gw 1 g)) (gn 0 g) (gn 1 g) (N + i.val) - (remap₂_val_lt N G₁ G₂ (gw 0 g) i.val (by omega) - (c₂.acyclic ⟨i.val-G₁-1, by omega⟩ ⟨0, by rw [fanIn_andOr2]; omega⟩)) - (remap₂_val_lt N G₁ G₂ (gw 1 g) i.val (by omega) - (c₂.acyclic ⟨i.val-G₁-1, by omega⟩ ⟨1, by rw [fanIn_andOr2]; omega⟩)) + (by + exact remap₂_val_lt N G₁ G₂ (gw 0 g) i.val (by omega) + (c₂.acyclic ⟨i.val-G₁-1, by omega⟩ ⟨0, by rw [fanIn_andOr2]; omega⟩)) + (by + exact remap₂_val_lt N G₁ G₂ (gw 1 g) i.val (by omega) + (c₂.acyclic ⟨i.val-G₁-1, by omega⟩ ⟨1, by rw [fanIn_andOr2]; omega⟩)) else let g := c₂.outputs 0 mkGate2' g.op (remap₂ N G₁ G₂ (gw 0 g)) (remap₂ N G₁ G₂ (gw 1 g)) (gn 0 g) (gn 1 g) (N + i.val) - (remap₂_val_lt N G₁ G₂ (gw 0 g) i.val (by omega) - (show (gw 0 g).val < _ by have := (gw 0 g).isLt; omega)) - (remap₂_val_lt N G₁ G₂ (gw 1 g) i.val (by omega) - (show (gw 1 g).val < _ by have := (gw 1 g).isLt; omega)) + (by + exact remap₂_val_lt N G₁ G₂ (gw 0 g) i.val (by omega) + (show (gw 0 g).val < _ by have := (gw 0 g).isLt; omega)) + (by + exact remap₂_val_lt N G₁ G₂ (gw 1 g) i.val (by omega) + (show (gw 1 g).val < _ by have := (gw 1 g).isLt; omega)) /-- Compose two circuits with a binary AND/OR. -/ def binopCircuit (op : AndOrOp) {N G₁ G₂ : Nat} [NeZero N] diff --git a/Complexitylib/Circuits/Internal/Simulation.lean b/Complexitylib/Circuits/Internal/Simulation.lean index 21a8094b..75c3b5d0 100644 --- a/Complexitylib/Circuits/Internal/Simulation.lean +++ b/Complexitylib/Circuits/Internal/Simulation.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Internal.AndOrNot -import Complexitylib.Circuits.Dependency.Defs -import Mathlib.Algebra.BigOperators.Fin + +module +public import Complexitylib.Circuits.Internal.AndOrNot +public import Complexitylib.Circuits.Dependency.Defs +public import Mathlib.Algebra.BigOperators.Fin /-! # Internal: Completeness of fan-in-2 AND/OR @@ -30,6 +32,9 @@ gates followed by chains for all original output gates. The new output gates are trivial passthroughs reading the last wire of each output chain. -/ + +@[expose] public section + namespace Complexity /-! ## AndOrOp extensions -/ @@ -344,11 +349,11 @@ lemma fin2_zero (a b : α) : fin2 a b ⟨0, by omega⟩ = a := rfl lemma fin2_one (a b : α) : fin2 a b ⟨1, by omega⟩ = b := rfl /-- Operation for the chain gate: dual-op for constants, same op otherwise. -/ -private def mkChainOp (op : AndOrOp) (k : Nat) : AndOrOp := +def mkChainOp (op : AndOrOp) (k : Nat) : AndOrOp := if k = 0 then op.dual else op /-- Input wires for the j-th chain gate. -/ -private def mkChainInputs {W : Nat} (hW : 0 < W) (k : Nat) +def mkChainInputs {W : Nat} (hW : 0 < W) (k : Nat) (ri : Fin k → Fin W) (base : Nat) (j : Nat) (hj : j < chainLen k) (hbase : base + chainLen k ≤ W) : Fin 2 → Fin W := if hk0 : k = 0 then fun _ => ⟨0, hW⟩ @@ -362,7 +367,7 @@ private def mkChainInputs {W : Nat} (hW : 0 < W) (k : Nat) fin2 ⟨base + j - 1, by omega⟩ (ri ⟨j + 1, by omega⟩) /-- Negation flags for the j-th chain gate. -/ -private def mkChainNeg (k : Nat) (rn : Fin k → Bool) (j : Nat) +def mkChainNeg (k : Nat) (rn : Fin k → Bool) (j : Nat) (hj : j < chainLen k) : Fin 2 → Bool := if hk0 : k = 0 then fin2 false true else if hk1 : k = 1 then fun _ => rn ⟨0, by omega⟩ @@ -403,7 +408,7 @@ private lemma mkChainInputs_lt {W : Nat} (hW : 0 < W) (k : Nat) /-! ## Compiled circuit -/ /-- Input wires for the compiled gate at flat index `idx`. -/ -private def compileGateInputs (c : Circuit Basis.unboundedAndOr N M G) (idx : Fin (G' c)) : +def compileGateInputs (c : Circuit Basis.unboundedAndOr N M G) (idx : Fin (G' c)) : Fin 2 → Fin (N + G' c) := if h : idx.val < iTotal c then let seg := segLookup G (iChainF c) idx.val h @@ -427,7 +432,7 @@ private def compileGateInputs (c : Circuit Basis.unboundedAndOr N M G) (idx : Fi (by have := oOffset_chain_le_G' c hj; omega) /-- Operation for the compiled gate at flat index `idx`. -/ -private def compileGateOp (c : Circuit Basis.unboundedAndOr N M G) (idx : Fin (G' c)) : AndOrOp := +def compileGateOp (c : Circuit Basis.unboundedAndOr N M G) (idx : Fin (G' c)) : AndOrOp := if h : idx.val < iTotal c then let seg := segLookup G (iChainF c) idx.val h have hi : seg.1 < G := segLookup_fst_lt G _ _ h @@ -440,7 +445,7 @@ private def compileGateOp (c : Circuit Basis.unboundedAndOr N M G) (idx : Fin (G mkChainOp (c.outputs ⟨seg.1, hj⟩).op (c.outputs ⟨seg.1, hj⟩).fanIn /-- Negation flags for the compiled gate at flat index `idx`. -/ -private def compileGateNeg (c : Circuit Basis.unboundedAndOr N M G) (idx : Fin (G' c)) : +def compileGateNeg (c : Circuit Basis.unboundedAndOr N M G) (idx : Fin (G' c)) : Fin 2 → Bool := if h : idx.val < iTotal c then let seg := segLookup G (iChainF c) idx.val h diff --git a/Complexitylib/Circuits/Internal/Spira.lean b/Complexitylib/Circuits/Internal/Spira.lean index b0a5991b..1e46f005 100644 --- a/Complexitylib/Circuits/Internal/Spira.lean +++ b/Complexitylib/Circuits/Internal/Spira.lean @@ -3,9 +3,27 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Formula -import Mathlib.Data.Nat.Log -import Mathlib.Tactic + +module +public import Complexitylib.Circuits.Formula +public import Mathlib.Analysis.SpecialFunctions.Pow.NNReal +public import Mathlib.Tactic.Measurability.Init +public import Mathlib.Tactic.NormNum.BigOperators +public import Mathlib.Tactic.NormNum.Irrational +public import Mathlib.Tactic.NormNum.IsCoprime +public import Mathlib.Tactic.NormNum.IsSquare +public import Mathlib.Tactic.NormNum.LegendreSymbol +public import Mathlib.Tactic.NormNum.ModEq +public import Mathlib.Tactic.NormNum.NatFactorial +public import Mathlib.Tactic.NormNum.NatFib +public import Mathlib.Tactic.NormNum.NatLog +public import Mathlib.Tactic.NormNum.NatSqrt +public import Mathlib.Tactic.NormNum.Ordinal +public import Mathlib.Tactic.NormNum.Parity +public import Mathlib.Tactic.NormNum.Prime +public import Mathlib.Tactic.NormNum.RealSqrt +public import Mathlib.Tactic.ReduceModChar +public import Std.Tactic.BVDecide.Normalize.Bool /-! # Spira formula balancing -- proof internals @@ -15,6 +33,9 @@ balancing theorem. The construction is kept internal; the public surface states only the existence of an equivalent shallow, polynomial-size formula. -/ + +@[expose] public section + namespace Complexity namespace BoolFormula diff --git a/Complexitylib/Circuits/Internal/Valiant.lean b/Complexitylib/Circuits/Internal/Valiant.lean index 0573ebb9..d9eb4d7b 100644 --- a/Complexitylib/Circuits/Internal/Valiant.lean +++ b/Complexitylib/Circuits/Internal/Valiant.lean @@ -3,16 +3,15 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Mathlib.Digraph -import Mathlib.Algebra.BigOperators.Group.Finset.Basic -import Mathlib.Algebra.Order.BigOperators.Group.Finset -import Mathlib.Data.Finset.Card -import Mathlib.Data.Finset.Max -import Mathlib.Data.Fintype.BigOperators -import Mathlib.Data.Fintype.Prod -import Mathlib.Data.Nat.Bitwise -import Mathlib.Data.Nat.Log -import Mathlib.Tactic.Ring + +module +public import Complexitylib.Mathlib.Digraph +public import Mathlib.Algebra.Order.BigOperators.Group.Finset +public import Mathlib.Data.Fintype.BigOperators +public import Mathlib.Data.Nat.Bitwise +public import Mathlib.Algebra.Order.Sub.Basic +public import Mathlib.Tactic.Ring.RingNF +public import Std.Tactic.BVDecide.Normalize.Bool /-! # Internal helpers for Valiant's Depth Reduction Lemma @@ -25,6 +24,9 @@ bounds for `canonicalLabel`), the edge partition by first-differing bit, the averaging step, and the relabeling-after-removal bound. -/ + +@[expose] public section + namespace Complexity namespace Valiant diff --git a/Complexitylib/Circuits/KarchmerWigderson.lean b/Complexitylib/Circuits/KarchmerWigderson.lean index 06dd5880..8d18d4fd 100644 --- a/Complexitylib/Circuits/KarchmerWigderson.lean +++ b/Complexitylib/Circuits/KarchmerWigderson.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.KarchmerWigderson.Defs -import Complexitylib.Circuits.KarchmerWigderson.Internal + +module +public import Complexitylib.Circuits.KarchmerWigderson.Defs +public import Complexitylib.Circuits.KarchmerWigderson.Internal /-! # The monotone Karchmer--Wigderson correspondence @@ -23,6 +25,9 @@ its root Karchmer--Wigderson relation has a depth-`d` protocol in this model. No uniformity condition is present. -/ + +@[expose] public section + namespace Complexity namespace KarchmerWigderson namespace Protocol diff --git a/Complexitylib/Circuits/KarchmerWigderson/Defs.lean b/Complexitylib/Circuits/KarchmerWigderson/Defs.lean index 1b08fa1c..efe094a4 100644 --- a/Complexitylib/Circuits/KarchmerWigderson/Defs.lean +++ b/Complexitylib/Circuits/KarchmerWigderson/Defs.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Data.Set.Basic -import Complexitylib.Circuits.Monotone.Defs + +module +public import Complexitylib.Circuits.Monotone.Defs /-! # Karchmer--Wigderson protocols -- definitions @@ -15,6 +16,9 @@ At a leaf, one coordinate separates every zero input from every one input in the current rectangle. -/ + +@[expose] public section + namespace Complexity namespace KarchmerWigderson diff --git a/Complexitylib/Circuits/KarchmerWigderson/Internal.lean b/Complexitylib/Circuits/KarchmerWigderson/Internal.lean index 92a5c3bb..b511b33d 100644 --- a/Complexitylib/Circuits/KarchmerWigderson/Internal.lean +++ b/Complexitylib/Circuits/KarchmerWigderson/Internal.lean @@ -3,12 +3,17 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.KarchmerWigderson.Defs + +module +public import Complexitylib.Circuits.KarchmerWigderson.Defs /-! # Karchmer--Wigderson protocols -- proof internals -/ + +@[expose] public section + namespace Complexity namespace KarchmerWigderson namespace Protocol diff --git a/Complexitylib/Circuits/LowerBound.lean b/Complexitylib/Circuits/LowerBound.lean index 40f1a235..abbaa3d4 100644 --- a/Complexitylib/Circuits/LowerBound.lean +++ b/Complexitylib/Circuits/LowerBound.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.EssentialInput -import Complexitylib.Circuits.Internal.LowerBound + +module +public import Complexitylib.Circuits.EssentialInput +public import Complexitylib.Circuits.Internal.LowerBound /-! # Gate Elimination Lower Bound @@ -44,6 +46,9 @@ And its corollary for functions that depend on all inputs: N ≤ k * c.size -/ + +@[expose] public section + namespace Complexity namespace Circuit diff --git a/Complexitylib/Circuits/Monotone.lean b/Complexitylib/Circuits/Monotone.lean index ca05784f..dd95ef0d 100644 --- a/Complexitylib/Circuits/Monotone.lean +++ b/Complexitylib/Circuits/Monotone.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Monotone.Defs -import Complexitylib.Circuits.Monotone.Internal + +module +public import Complexitylib.Circuits.Monotone.Defs +public import Complexitylib.Circuits.Monotone.Internal /-! # Monotone Boolean formulas @@ -18,6 +20,9 @@ monotonicity, locality, and two elementary lower bounds: distinct variables and essential variables are both bounded by the number of formula leaves. -/ + +@[expose] public section + namespace Complexity namespace MonotoneFormula diff --git a/Complexitylib/Circuits/Monotone/Defs.lean b/Complexitylib/Circuits/Monotone/Defs.lean index 362c020f..53860bb5 100644 --- a/Complexitylib/Circuits/Monotone/Defs.lean +++ b/Complexitylib/Circuits/Monotone/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BitString -import Complexitylib.Circuits.Formula + +module +public import Complexitylib.Circuits.Formula +public import Complexitylib.Circuits.Basic /-! # Monotone Boolean formulas -- definitions @@ -14,6 +16,9 @@ disjunctions only. Constants and negations are deliberately absent: this is the standard syntax used by the Karchmer--Wigderson correspondence. -/ + +@[expose] public section + namespace Complexity /-- A monotone Boolean formula over exactly `N` input variables. -/ diff --git a/Complexitylib/Circuits/Monotone/Internal.lean b/Complexitylib/Circuits/Monotone/Internal.lean index 04e44566..502def86 100644 --- a/Complexitylib/Circuits/Monotone/Internal.lean +++ b/Complexitylib/Circuits/Monotone/Internal.lean @@ -3,13 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.EssentialInput -import Complexitylib.Circuits.Monotone.Defs + +module +public import Complexitylib.Circuits.EssentialInput +public import Complexitylib.Circuits.Monotone.Defs +public import Complexitylib.Circuits.BitString /-! # Monotone Boolean formulas -- proof internals -/ + +@[expose] public section + namespace Complexity namespace MonotoneFormula diff --git a/Complexitylib/Circuits/MultilinearExtension.lean b/Complexitylib/Circuits/MultilinearExtension.lean index 0c7b25eb..611e8d80 100644 --- a/Complexitylib/Circuits/MultilinearExtension.lean +++ b/Complexitylib/Circuits/MultilinearExtension.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Algebra.Ring.Defs -import Mathlib.Tactic.Ring + +module +public import Mathlib.Tactic.NormNum.Inv +public import Mathlib.Tactic.NormNum.Pow /-! # Multilinear extension (one variable) @@ -23,6 +25,9 @@ arithmetized formulas agree with their Boolean originals on the cube. - `mle₁_bool` — it agrees with `f` at both Boolean points -/ + +@[expose] public section + namespace Complexity /-- The one-variable multilinear extension of `f : Bool → R` into a commutative diff --git a/Complexitylib/Circuits/Nondeterminism.lean b/Complexitylib/Circuits/Nondeterminism.lean index 7d490ca7..f5cf3f68 100644 --- a/Complexitylib/Circuits/Nondeterminism.lean +++ b/Complexitylib/Circuits/Nondeterminism.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Nondeterminism.Defs -import Complexitylib.Circuits.Internal.Nondeterminism -import Complexitylib.Circuits.Shannon + +module +public import Complexitylib.Circuits.Nondeterminism.Defs +public import Complexitylib.Circuits.Internal.Nondeterminism +public import Complexitylib.Circuits.Shannon /-! # Nondeterministic Circuit Complexity Bounds @@ -47,6 +49,9 @@ The naive bound is tighter when `k` is small and `f` has low complexity; the Shannon bound wins when `k` is large, regardless of `f`'s complexity. -/ + +@[expose] public section + namespace Complexity variable {k m : Nat} diff --git a/Complexitylib/Circuits/Nondeterminism/Defs.lean b/Complexitylib/Circuits/Nondeterminism/Defs.lean index 91069ab2..340252a9 100644 --- a/Complexitylib/Circuits/Nondeterminism/Defs.lean +++ b/Complexitylib/Circuits/Nondeterminism/Defs.lean @@ -3,9 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Basic -import Mathlib.Data.Fin.Tuple.Basic -import Mathlib.Data.Fintype.BigOperators + +module +public import Complexitylib.Circuits.Basic +public import Mathlib.Data.Fintype.Pi +public import Std.Tactic.BVDecide.Normalize.BitVec +public import Std.Tactic.BVDecide.Normalize.Prop /-! # Nondeterministic Quantification of Boolean Functions @@ -32,6 +35,9 @@ guesses the first `k` input bits. * `existsQuantify_mono` — monotonicity under pointwise implication -/ + +@[expose] public section + namespace Complexity variable {k m : Nat} diff --git a/Complexitylib/Circuits/NormalForm.lean b/Complexitylib/Circuits/NormalForm.lean index 9a659e7f..2729919d 100644 --- a/Complexitylib/Circuits/NormalForm.lean +++ b/Complexitylib/Circuits/NormalForm.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.NormalForm.Defs -import Complexitylib.Circuits.Internal.NormalForm -import Complexitylib.Circuits.XOR + +module +public import Complexitylib.Circuits.NormalForm.Defs +public import Complexitylib.Circuits.Internal.NormalForm +public import Complexitylib.Circuits.XOR /-! # Normal Forms: CNF/DNF Lower Bound for XOR @@ -31,6 +33,9 @@ De Morgan duality (`CNF.neg`). * `CNF.two_pow_le_complexity_of_xorBool` — any CNF computing XOR has `≥ 2^{N-1}` clauses -/ + +@[expose] public section + namespace Complexity /-- Any DNF computing N-variable XOR requires at least `2^{N-1}` terms. -/ diff --git a/Complexitylib/Circuits/NormalForm/Defs.lean b/Complexitylib/Circuits/NormalForm/Defs.lean index 939bf7fb..08f6e6b2 100644 --- a/Complexitylib/Circuits/NormalForm/Defs.lean +++ b/Complexitylib/Circuits/NormalForm/Defs.lean @@ -3,7 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Basic + +module +public import Complexitylib.Circuits.Basic +public import Std.Tactic.BVDecide.Normalize.Bool +public import Std.Tactic.BVDecide.Normalize.Prop /-! # Normal Forms — Core Definitions @@ -29,6 +33,9 @@ variable count `N` and are used for circuit lower bounds, whereas the `SAT` vers `Nat`-indexed and serve as the language encoding for SAT. -/ + +@[expose] public section + namespace Complexity /-- A literal: a Boolean variable (by index) together with a polarity flag. diff --git a/Complexitylib/Circuits/NormalForm/Operations.lean b/Complexitylib/Circuits/NormalForm/Operations.lean index 6089560c..f80a43ec 100644 --- a/Complexitylib/Circuits/NormalForm/Operations.lean +++ b/Complexitylib/Circuits/NormalForm/Operations.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.NormalForm.Operations.Defs -import Complexitylib.Circuits.NormalForm.Operations.Internal + +module +public import Complexitylib.Circuits.NormalForm.Operations.Defs +public import Complexitylib.Circuits.NormalForm.Operations.Internal /-! # Operations on CNF and DNF @@ -15,6 +17,9 @@ decision trees be assembled into the matching normal form without a distributive expansion. -/ + +@[expose] public section + namespace Complexity namespace DNF diff --git a/Complexitylib/Circuits/NormalForm/Operations/Defs.lean b/Complexitylib/Circuits/NormalForm/Operations/Defs.lean index 21a7c10a..84611c94 100644 --- a/Complexitylib/Circuits/NormalForm/Operations/Defs.lean +++ b/Complexitylib/Circuits/NormalForm/Operations/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.NormalForm.Defs + +module +public import Complexitylib.Circuits.NormalForm.Defs /-! # Operations on CNF and DNF -- definitions @@ -14,6 +16,9 @@ used when one alternating formula layer is assembled from normal forms for its children. -/ + +@[expose] public section + namespace Complexity namespace DNF diff --git a/Complexitylib/Circuits/NormalForm/Operations/Internal.lean b/Complexitylib/Circuits/NormalForm/Operations/Internal.lean index beace94b..4026536d 100644 --- a/Complexitylib/Circuits/NormalForm/Operations/Internal.lean +++ b/Complexitylib/Circuits/NormalForm/Operations/Internal.lean @@ -3,12 +3,17 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.NormalForm.Operations.Defs + +module +public import Complexitylib.Circuits.NormalForm.Operations.Defs /-! # Operations on CNF and DNF -- proof internals -/ + +@[expose] public section + namespace Complexity namespace DNF diff --git a/Complexitylib/Circuits/NormalForm/Restriction.lean b/Complexitylib/Circuits/NormalForm/Restriction.lean index 16792241..09862205 100644 --- a/Complexitylib/Circuits/NormalForm/Restriction.lean +++ b/Complexitylib/Circuits/NormalForm/Restriction.lean @@ -3,8 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.NormalForm.Defs -import Complexitylib.Circuits.Restriction + +module +public import Complexitylib.Circuits.NormalForm.Defs +public import Complexitylib.Circuits.Restriction +public import Std.Tactic.BVDecide.Normalize.BitVec /-! # Restricting CNF and DNF formulas @@ -25,6 +28,9 @@ The result preserves evaluation and cannot increase clause/term count or width. * `CNF.width_restrict_le` / `DNF.width_restrict_le`. -/ + +@[expose] public section + namespace Complexity namespace Literal diff --git a/Complexitylib/Circuits/RandomRestriction.lean b/Complexitylib/Circuits/RandomRestriction.lean index c152d10d..1ce31ba0 100644 --- a/Complexitylib/Circuits/RandomRestriction.lean +++ b/Complexitylib/Circuits/RandomRestriction.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.RandomRestriction.Defs -import Complexitylib.Circuits.RandomRestriction.Internal + +module +public import Complexitylib.Circuits.RandomRestriction.Defs +public import Complexitylib.Circuits.RandomRestriction.Internal /-! # Finite random restrictions @@ -21,6 +23,9 @@ stated in cardinality form so later switching arguments do not depend on rounding or division conventions. -/ + +@[expose] public section + namespace Complexity namespace RandomRestriction diff --git a/Complexitylib/Circuits/RandomRestriction/Defs.lean b/Complexitylib/Circuits/RandomRestriction/Defs.lean index febf0128..f7e5dbf1 100644 --- a/Complexitylib/Circuits/RandomRestriction/Defs.lean +++ b/Complexitylib/Circuits/RandomRestriction/Defs.lean @@ -3,11 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Restriction -import Mathlib.Data.Fintype.Card -import Mathlib.Data.Fintype.Pi -import Mathlib.Data.Fintype.Prod -import Mathlib.Data.Fintype.Sum + +module +public import Complexitylib.Circuits.Restriction +public import Mathlib.Data.Fintype.Pi +public import Mathlib.Data.Fintype.Prod +public import Mathlib.Data.Fintype.Sum /-! # Finite random restrictions @@ -25,6 +26,9 @@ uniform on an honest finite type; no measure-theoretic or rational-probability convention is hidden in later counting arguments. -/ + +@[expose] public section + namespace Complexity namespace RandomRestriction diff --git a/Complexitylib/Circuits/RandomRestriction/Internal.lean b/Complexitylib/Circuits/RandomRestriction/Internal.lean index 35428140..14bcdfa9 100644 --- a/Complexitylib/Circuits/RandomRestriction/Internal.lean +++ b/Complexitylib/Circuits/RandomRestriction/Internal.lean @@ -3,14 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.RandomRestriction.Defs -import Mathlib.Data.Fintype.BigOperators -import Mathlib.Data.Finset.Card + +module +public import Complexitylib.Circuits.RandomRestriction.Defs +public import Mathlib.Data.Fintype.BigOperators /-! # Finite random restrictions -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RandomRestriction diff --git a/Complexitylib/Circuits/Restriction.lean b/Complexitylib/Circuits/Restriction.lean index 15bc1fb3..1b6afd16 100644 --- a/Complexitylib/Circuits/Restriction.lean +++ b/Complexitylib/Circuits/Restriction.lean @@ -3,8 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Basic -import Complexitylib.Circuits.Formula + +module +public import Complexitylib.Circuits.Basic +public import Complexitylib.Circuits.Formula +public import Std.Tactic.BVDecide.Normalize.Prop /-! # Restrictions @@ -26,6 +29,9 @@ assignment (evaluation commutes with restriction). `BoolFormula.restrict_comp` — evaluation and composition laws -/ + +@[expose] public section + namespace Complexity /-- A restriction: a partial assignment fixing some variables (`some b`) and diff --git a/Complexitylib/Circuits/Schnorr.lean b/Complexitylib/Circuits/Schnorr.lean index 9019d61e..fed73221 100644 --- a/Complexitylib/Circuits/Schnorr.lean +++ b/Complexitylib/Circuits/Schnorr.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.XOR -import Complexitylib.Circuits.Internal.SchnorrBridge + +module +public import Complexitylib.Circuits.XOR +public import Complexitylib.Circuits.Internal.SchnorrBridge /-! # Schnorr's Lower Bound for XOR Circuits @@ -38,6 +40,9 @@ When `Basis.andOr2` is known to be complete, this yields a `sizeComplexity` bound via `sizeComplexity_xorBool_ge`. -/ + +@[expose] public section + namespace Complexity /-- **Schnorr's lower bound for circuits**: any fan-in-two AND/OR circuit diff --git a/Complexitylib/Circuits/Shannon.lean b/Complexitylib/Circuits/Shannon.lean index 8b90e935..075bb074 100644 --- a/Complexitylib/Circuits/Shannon.lean +++ b/Complexitylib/Circuits/Shannon.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Internal.ShannonBridge -import Complexitylib.Circuits.Internal.ShannonUpper + +module +public import Complexitylib.Circuits.Internal.ShannonBridge +public import Complexitylib.Circuits.Internal.ShannonUpper /-! # Shannon Bounds @@ -37,6 +39,9 @@ When `Basis.andOr2` is known to be complete, this yields a Together these establish that worst-case circuit complexity is `Θ(2^N / N)`. -/ + +@[expose] public section + namespace Complexity /-- **Shannon lower bound for circuits**: for `N ≥ 6`, there exists a Boolean diff --git a/Complexitylib/Circuits/Spira.lean b/Complexitylib/Circuits/Spira.lean index ee99f49f..e0b86a53 100644 --- a/Complexitylib/Circuits/Spira.lean +++ b/Complexitylib/Circuits/Spira.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Formula -import Complexitylib.Circuits.Internal.Spira + +module +public import Complexitylib.Circuits.Formula +public import Complexitylib.Circuits.Internal.Spira /-! # Spira's formula-balancing theorem @@ -24,6 +26,9 @@ transformation. polynomial-size Boolean formula. -/ + +@[expose] public section + namespace Complexity namespace BoolFormula diff --git a/Complexitylib/Circuits/Threshold.lean b/Complexitylib/Circuits/Threshold.lean index 9a9183ff..236d8116 100644 --- a/Complexitylib/Circuits/Threshold.lean +++ b/Complexitylib/Circuits/Threshold.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Threshold.Defs -import Complexitylib.Circuits.Threshold.Internal + +module +public import Complexitylib.Circuits.Threshold.Defs +public import Complexitylib.Circuits.Threshold.Internal /-! # Threshold circuits @@ -18,6 +20,9 @@ AND/OR circuit becomes a threshold circuit without changing wiring, size, depth, negation flags, or semantics. -/ + +@[expose] public section + namespace Complexity namespace ThresholdOp diff --git a/Complexitylib/Circuits/Threshold/Defs.lean b/Complexitylib/Circuits/Threshold/Defs.lean index 0e7deffe..6822b6bb 100644 --- a/Complexitylib/Circuits/Threshold/Defs.lean +++ b/Complexitylib/Circuits/Threshold/Defs.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.AndOrNot.Defs -import Complexitylib.Circuits.BasisHom.Defs -import Batteries.Data.Fin.Lemmas + +module +public import Complexitylib.Circuits.Basic +public import Mathlib.Tactic.Bound.Init /-! # Threshold circuits -- definitions @@ -17,6 +18,9 @@ standard nonuniform threshold-circuit convention with NOT gates available at no asymptotic cost. -/ + +@[expose] public section + namespace Complexity /-- An unweighted threshold operation with a natural cutoff. -/ diff --git a/Complexitylib/Circuits/Threshold/Internal.lean b/Complexitylib/Circuits/Threshold/Internal.lean index 6f6326af..ebe6c6ab 100644 --- a/Complexitylib/Circuits/Threshold/Internal.lean +++ b/Complexitylib/Circuits/Threshold/Internal.lean @@ -3,13 +3,21 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BasisHom -import Complexitylib.Circuits.Threshold.Defs + +module +public import Complexitylib.Circuits.Threshold.Defs +public import Complexitylib.Circuits.AndOrNot.Defs +public import Complexitylib.Circuits.BasisHom.Defs +public import Std.Tactic.BVDecide.Normalize.BitVec +public import Std.Tactic.BVDecide.Normalize.Prop /-! # Threshold circuits -- proof internals -/ + +@[expose] public section + namespace Complexity private theorem countP_eq_arity_iff (n : ℕ) diff --git a/Complexitylib/Circuits/Unrolling.lean b/Complexitylib/Circuits/Unrolling.lean index 7dd68646..250eb259 100644 --- a/Complexitylib/Circuits/Unrolling.lean +++ b/Complexitylib/Circuits/Unrolling.lean @@ -3,14 +3,16 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Unrolling.Defs -import Complexitylib.Circuits.Unrolling.Acceptance -import Complexitylib.Circuits.Unrolling.Acceptance.Hardwiring -import Complexitylib.Circuits.Unrolling.Amplification -import Complexitylib.Circuits.Unrolling.Internal.Initialization -import Complexitylib.Circuits.Unrolling.Trace -import Complexitylib.Circuits.Unrolling.Transition -import Complexitylib.Circuits.Unrolling.Transition.Fragment + +module +public import Complexitylib.Circuits.Unrolling.Defs +public import Complexitylib.Circuits.Unrolling.Acceptance +public import Complexitylib.Circuits.Unrolling.Acceptance.Hardwiring +public import Complexitylib.Circuits.Unrolling.Amplification +public import Complexitylib.Circuits.Unrolling.Internal.Initialization +public import Complexitylib.Circuits.Unrolling.Trace +public import Complexitylib.Circuits.Unrolling.Transition +public import Complexitylib.Circuits.Unrolling.Transition.Fragment /-! # Circuit unrolling for bounded Turing-machine traces @@ -25,6 +27,9 @@ the data input, consume disjoint choice blocks, and feed a strict-majority threshold with an explicit polynomial gate bound. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Acceptance.lean b/Complexitylib/Circuits/Unrolling/Acceptance.lean index 2e3d9fe3..be19301c 100644 --- a/Complexitylib/Circuits/Unrolling/Acceptance.lean +++ b/Complexitylib/Circuits/Unrolling/Acceptance.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.ToCircuit -import Complexitylib.Circuits.Unrolling.Acceptance.Defs -import Complexitylib.Circuits.Unrolling.Acceptance.Internal.Evaluation -import Complexitylib.Circuits.Unrolling.Acceptance.Internal.Structure + +module +public import Complexitylib.Circuits.Encoding.ToCircuit +public import Complexitylib.Circuits.Unrolling.Acceptance.Defs +public import Complexitylib.Circuits.Unrolling.Acceptance.Internal.Evaluation +public import Complexitylib.Circuits.Unrolling.Acceptance.Internal.Structure /-! # Acceptance circuits for bounded Turing-machine traces @@ -32,6 +34,9 @@ zero-length case separately. accepting paths exactly. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Acceptance/Defs.lean b/Complexitylib/Circuits/Unrolling/Acceptance/Defs.lean index 77ba0869..96e420f6 100644 --- a/Complexitylib/Circuits/Unrolling/Acceptance/Defs.lean +++ b/Complexitylib/Circuits/Unrolling/Acceptance/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BitString -import Complexitylib.Circuits.Unrolling.Trace.Defs + +module +public import Complexitylib.Circuits.BitString +public import Complexitylib.Circuits.Unrolling.Trace.Defs /-! # Acceptance gates for bounded Turing-machine traces @@ -16,6 +18,9 @@ therefore both the raw circuit's designated output and the acceptance bit used when the raw circuit is reconstructed as a typed single-output circuit. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Acceptance/Hardwiring.lean b/Complexitylib/Circuits/Unrolling/Acceptance/Hardwiring.lean index 75da74c1..96e7fda5 100644 --- a/Complexitylib/Circuits/Unrolling/Acceptance/Hardwiring.lean +++ b/Complexitylib/Circuits/Unrolling/Acceptance/Hardwiring.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Hardwiring -import Complexitylib.Circuits.Unrolling.Acceptance + +module +public import Complexitylib.Circuits.Hardwiring +public import Complexitylib.Circuits.Unrolling.Acceptance /-! # Fixed-choice bounded acceptance circuits @@ -21,6 +23,9 @@ single-run analogue of amplified-seed hardwiring. - `fixedChoicesAcceptanceCircuit_size_le`: inherited cubic size bound. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Acceptance/Internal/Evaluation.lean b/Complexitylib/Circuits/Unrolling/Acceptance/Internal/Evaluation.lean index c9394326..264e26ae 100644 --- a/Complexitylib/Circuits/Unrolling/Acceptance/Internal/Evaluation.lean +++ b/Complexitylib/Circuits/Unrolling/Acceptance/Internal/Evaluation.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Unrolling.Acceptance.Defs -import Complexitylib.Circuits.Unrolling.Acceptance.Internal.Structure -import Complexitylib.Circuits.Unrolling.Trace.Internal.Evaluation + +module +public import Complexitylib.Circuits.Unrolling.Acceptance.Defs +public import Complexitylib.Circuits.Unrolling.Acceptance.Internal.Structure +public import Complexitylib.Circuits.Unrolling.Trace.Internal.Evaluation /-! # Evaluation of bounded-trace acceptance circuits @@ -15,6 +17,9 @@ halt-and-output AND gate. The resulting raw circuit's last wire is exactly the Boolean acceptance predicate used by `NTM.acceptCount`. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Acceptance/Internal/Structure.lean b/Complexitylib/Circuits/Unrolling/Acceptance/Internal/Structure.lean index 90134df3..06997fe8 100644 --- a/Complexitylib/Circuits/Unrolling/Acceptance/Internal/Structure.lean +++ b/Complexitylib/Circuits/Unrolling/Acceptance/Internal/Structure.lean @@ -3,11 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Fragment -import Complexitylib.Circuits.Unrolling.Acceptance.Defs -import Complexitylib.Circuits.Unrolling.Trace.Internal.Structure -import Complexitylib.Circuits.Unrolling.Trace.Internal.Topology -import Mathlib.Tactic.Ring + +module +public import Complexitylib.Circuits.Unrolling.Acceptance.Defs +public import Complexitylib.Circuits.Unrolling.Trace.Internal.Topology /-! # Structure of bounded-trace acceptance circuits @@ -17,6 +16,9 @@ exactly one gate, preserves topological well-formedness, and retains a cubic machine-dependent size bound. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Amplification.lean b/Complexitylib/Circuits/Unrolling/Amplification.lean index 47664135..60081f85 100644 --- a/Complexitylib/Circuits/Unrolling/Amplification.lean +++ b/Complexitylib/Circuits/Unrolling/Amplification.lean @@ -3,11 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.ToCircuit -import Complexitylib.Circuits.Unrolling.Amplification.Defs -import Complexitylib.Circuits.Unrolling.Amplification.Internal.Evaluation -import Complexitylib.Circuits.Unrolling.Amplification.Internal.Structure -import Complexitylib.Circuits.Unrolling.Amplification.Internal.Topology + +module +public import Complexitylib.Circuits.Encoding.ToCircuit +public import Complexitylib.Circuits.Unrolling.Amplification.Defs +public import Complexitylib.Circuits.Unrolling.Amplification.Internal.Evaluation +public import Complexitylib.Circuits.Unrolling.Amplification.Internal.Structure +public import Complexitylib.Circuits.Unrolling.Amplification.Internal.Topology /-! # Parallel amplification circuits @@ -32,6 +34,9 @@ the randomized layer's `blockMajority` is supplied by quadratic threshold circuit. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Amplification/Defs.lean b/Complexitylib/Circuits/Unrolling/Amplification/Defs.lean index 09cdabfe..62de2f5f 100644 --- a/Complexitylib/Circuits/Unrolling/Amplification/Defs.lean +++ b/Complexitylib/Circuits/Unrolling/Amplification/Defs.lean @@ -3,10 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Threshold.Defs -import Complexitylib.Circuits.BitString -import Complexitylib.Circuits.Unrolling.Acceptance.Defs -import Mathlib.Data.List.FinRange + +module +public import Complexitylib.Circuits.Encoding.Threshold.Defs +public import Complexitylib.Circuits.Unrolling.Acceptance.Defs /-! # Parallel amplification circuits -- definitions @@ -22,6 +22,9 @@ strict majority. The construction is proof-free. Later modules establish the exact gate count, topological ordering, and evaluation semantics. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Amplification/Internal/Evaluation.lean b/Complexitylib/Circuits/Unrolling/Amplification/Internal/Evaluation.lean index 2407b906..301f1375 100644 --- a/Complexitylib/Circuits/Unrolling/Amplification/Internal/Evaluation.lean +++ b/Complexitylib/Circuits/Unrolling/Amplification/Internal/Evaluation.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Threshold.Internal -import Complexitylib.Circuits.Unrolling.Acceptance.Internal.Evaluation -import Complexitylib.Circuits.Unrolling.Amplification.Internal.Structure + +module +public import Complexitylib.Circuits.Unrolling.Acceptance.Internal.Evaluation +public import Complexitylib.Circuits.Unrolling.Amplification.Internal.Structure /-! # Evaluation internals for parallel amplification circuits @@ -21,6 +22,9 @@ The final result intentionally remains in the dependency-light form circuit layer. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Amplification/Internal/Structure.lean b/Complexitylib/Circuits/Unrolling/Amplification/Internal/Structure.lean index 326ea8c2..41268666 100644 --- a/Complexitylib/Circuits/Unrolling/Amplification/Internal/Structure.lean +++ b/Complexitylib/Circuits/Unrolling/Amplification/Internal/Structure.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Threshold.Internal -import Complexitylib.Circuits.Unrolling.Acceptance.Internal.Structure -import Complexitylib.Circuits.Unrolling.Amplification.Defs -import Mathlib.Tactic.Ring + +module +public import Complexitylib.Circuits.Encoding.Threshold.Internal +public import Complexitylib.Circuits.Unrolling.Acceptance.Internal.Structure +public import Complexitylib.Circuits.Unrolling.Amplification.Defs +public import Mathlib.Algebra.Order.Ring.Nat /-! # Structural internals for parallel amplification circuits @@ -17,6 +19,9 @@ results locate completed verdict wires and bound the complete amplified circuit by one cubic unrolling per run plus a quadratic majority threshold. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Amplification/Internal/Topology.lean b/Complexitylib/Circuits/Unrolling/Amplification/Internal/Topology.lean index 74b93e4a..75d8bc51 100644 --- a/Complexitylib/Circuits/Unrolling/Amplification/Internal/Topology.lean +++ b/Complexitylib/Circuits/Unrolling/Amplification/Internal/Topology.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Unrolling.Amplification.Internal.Structure + +module +public import Complexitylib.Circuits.Unrolling.Amplification.Internal.Structure /-! # Topology internals for parallel amplification circuits @@ -14,6 +16,9 @@ threshold fragment. This file proves that both stages are topologically ordered and that the final nonempty raw circuit is well formed. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Defs.lean b/Complexitylib/Circuits/Unrolling/Defs.lean index 79948d5d..bbbb3f10 100644 --- a/Complexitylib/Circuits/Unrolling/Defs.lean +++ b/Complexitylib/Circuits/Unrolling/Defs.lean @@ -3,11 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Fragment.Defs -import Complexitylib.Models.TuringMachine -import Mathlib.Data.Fintype.Sum -import Mathlib.Logic.Equiv.Fin.Basic -import Mathlib.Tactic.DeriveFintype + +module +public import Complexitylib.Circuits.Encoding.Fragment.Defs +public import Complexitylib.Models.TuringMachine +public import Mathlib.Data.Fintype.Sum +public import Mathlib.Logic.Equiv.Fin.Basic +public import Mathlib.Tactic.DeriveFintype /-! # Circuit layouts for bounded Turing-machine traces @@ -23,6 +25,9 @@ lets later clients place random choices, data, and auxiliary inputs wherever they choose. `prefixInputWires` supplies the canonical choices-first order. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling @@ -97,7 +102,7 @@ def configWidth (tm : NTM k) (T : ℕ) : ℕ := Fintype.card tm.Q + (k + 2) * (T + 1) + 4 * (k + 2) * (T + 2) /-- State/head/cell sum representation used to construct the explicit layout. -/ -private def configAtomSumEquiv (tm : NTM k) (T : ℕ) : +def configAtomSumEquiv (tm : NTM k) (T : ℕ) : ConfigAtom tm T ≃ tm.Q ⊕ ((TapeSlot k × Fin (T + 1)) ⊕ ((TapeSlot k × Fin (T + 2)) × Γ)) where toFun @@ -152,7 +157,7 @@ private theorem TapeSlot.index_surjective : Function.Surjective (@TapeSlot.index /-- Named tapes are explicitly equivalent to their input/work/output indices. -/ noncomputable def tapeSlotEquiv (k : ℕ) : TapeSlot k ≃ Fin (k + 2) := Equiv.ofBijective TapeSlot.index - ⟨TapeSlot.index_injective, TapeSlot.index_surjective⟩ + ⟨by exact TapeSlot.index_injective, by exact TapeSlot.index_surjective⟩ private theorem symbolIndex_injective : Function.Injective symbolIndex := by intro first second h @@ -163,13 +168,16 @@ private theorem symbolIndex_surjective : Function.Surjective symbolIndex := by /-- Alphabet symbols are explicitly equivalent to their four layout indices. -/ noncomputable def symbolEquiv : Γ ≃ Fin 4 := - Equiv.ofBijective symbolIndex ⟨symbolIndex_injective, symbolIndex_surjective⟩ + Equiv.ofBijective symbolIndex + ⟨by exact symbolIndex_injective, by exact symbolIndex_surjective⟩ -private noncomputable def headAtomEquiv (k T : ℕ) : +/-- Tape-head atoms are explicitly equivalent to their contiguous layout indices. -/ +noncomputable def headAtomEquiv (k T : ℕ) : TapeSlot k × Fin (T + 1) ≃ Fin ((k + 2) * (T + 1)) := (Equiv.prodCongr (tapeSlotEquiv k) (Equiv.refl _)).trans finProdFinEquiv -private noncomputable def cellAtomEquiv (k T : ℕ) : +/-- Tape-cell atoms are explicitly equivalent to their contiguous layout indices. -/ +noncomputable def cellAtomEquiv (k T : ℕ) : (TapeSlot k × Fin (T + 2)) × Γ ≃ Fin (4 * (k + 2) * (T + 2)) := ((Equiv.prodCongr ((Equiv.prodCongr (tapeSlotEquiv k) (Equiv.refl _)).trans finProdFinEquiv) diff --git a/Complexitylib/Circuits/Unrolling/Internal/Initialization.lean b/Complexitylib/Circuits/Unrolling/Internal/Initialization.lean index 949a2981..5eb5bc0c 100644 --- a/Complexitylib/Circuits/Unrolling/Internal/Initialization.lean +++ b/Complexitylib/Circuits/Unrolling/Internal/Initialization.lean @@ -3,9 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Fragment -import Complexitylib.Circuits.BitString -import Complexitylib.Circuits.Unrolling.Defs + +module +public import Complexitylib.Circuits.Encoding.Fragment +public import Complexitylib.Circuits.BitString +public import Complexitylib.Circuits.Unrolling.Defs +public import Std.Tactic.BVDecide.Normalize.BitVec /-! # Internal correctness of bounded-trace initialization circuits @@ -14,6 +17,9 @@ This file proves the exact size, topological ordering, and iterative-evaluator semantics of the one-gate-per-atom initialization fragment. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Trace.lean b/Complexitylib/Circuits/Unrolling/Trace.lean index 7baa2d70..5c698ced 100644 --- a/Complexitylib/Circuits/Unrolling/Trace.lean +++ b/Complexitylib/Circuits/Unrolling/Trace.lean @@ -3,11 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Unrolling.Trace.Defs -import Complexitylib.Circuits.Unrolling.Trace.Internal.Evaluation -import Complexitylib.Circuits.Unrolling.Trace.Internal.HeadBounds -import Complexitylib.Circuits.Unrolling.Trace.Internal.Structure -import Complexitylib.Circuits.Unrolling.Trace.Internal.Topology + +module +public import Complexitylib.Circuits.Unrolling.Trace.Defs +public import Complexitylib.Circuits.Unrolling.Trace.Internal.Evaluation +public import Complexitylib.Circuits.Unrolling.Trace.Internal.HeadBounds +public import Complexitylib.Circuits.Unrolling.Trace.Internal.Structure +public import Complexitylib.Circuits.Unrolling.Trace.Internal.Topology /-! # Circuits for bounded Turing-machine traces @@ -27,6 +29,9 @@ arity and has machine-dependent cubic size in the trace horizon. - `traceFragmentSize_le`: a machine-dependent cubic gate-count bound. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Trace/Defs.lean b/Complexitylib/Circuits/Unrolling/Trace/Defs.lean index 104c43b8..79bc641f 100644 --- a/Complexitylib/Circuits/Unrolling/Trace/Defs.lean +++ b/Complexitylib/Circuits/Unrolling/Trace/Defs.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Unrolling.Transition.Fragment.Defs -import Mathlib.Data.List.FinRange + +module +public import Complexitylib.Circuits.Unrolling.Transition.Fragment.Defs /-! # Definitions for tiled bounded-trace circuits @@ -20,6 +21,9 @@ of topology, evaluation, and polynomial size without introducing dependent casts into the circuit construction itself. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Trace/Internal/Evaluation.lean b/Complexitylib/Circuits/Unrolling/Trace/Internal/Evaluation.lean index 3bfa121f..3dc48089 100644 --- a/Complexitylib/Circuits/Unrolling/Trace/Internal/Evaluation.lean +++ b/Complexitylib/Circuits/Unrolling/Trace/Internal/Evaluation.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Unrolling.Trace.Internal.HeadBounds -import Complexitylib.Circuits.Unrolling.Trace.Internal.Structure -import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.ArrayEvaluation + +module +public import Complexitylib.Circuits.Unrolling.Trace.Internal.HeadBounds +public import Complexitylib.Circuits.Unrolling.Trace.Internal.Structure +public import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.ArrayEvaluation /-! # Evaluation of tiled bounded-trace circuits @@ -17,6 +19,9 @@ the current packed block synchronized with the corresponding NTM trace prefix. The complete-trace theorem is the horizon specialization. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Trace/Internal/HeadBounds.lean b/Complexitylib/Circuits/Unrolling/Trace/Internal/HeadBounds.lean index 7d8e97ff..1bf05df0 100644 --- a/Complexitylib/Circuits/Unrolling/Trace/Internal/HeadBounds.lean +++ b/Complexitylib/Circuits/Unrolling/Trace/Internal/HeadBounds.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Unrolling.Transition.Defs -import Complexitylib.Models.TuringMachine.Internal + +module +public import Complexitylib.Circuits.Unrolling.Transition.Defs +public import Complexitylib.Models.TuringMachine.Internal /-! # Head bounds for prefixes of bounded traces @@ -16,6 +18,9 @@ below `T`. It also identifies one `choiceStep` from prefix `i` with prefix `i + 1` of the same full choice sequence. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Trace/Internal/Structure.lean b/Complexitylib/Circuits/Unrolling/Trace/Internal/Structure.lean index 7302dd14..02ae6589 100644 --- a/Complexitylib/Circuits/Unrolling/Trace/Internal/Structure.lean +++ b/Complexitylib/Circuits/Unrolling/Trace/Internal/Structure.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Unrolling.Internal.Initialization -import Complexitylib.Circuits.Unrolling.Trace.Defs -import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.Size + +module +public import Complexitylib.Circuits.Unrolling.Trace.Defs +public import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.Size /-! # Structural properties of tiled bounded-trace circuits @@ -15,6 +16,9 @@ gate count and first unused wire. It also identifies the final packed configuration block and derives a machine-dependent cubic size bound. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Trace/Internal/Topology.lean b/Complexitylib/Circuits/Unrolling/Trace/Internal/Topology.lean index aa604dbb..cda92b32 100644 --- a/Complexitylib/Circuits/Unrolling/Trace/Internal/Topology.lean +++ b/Complexitylib/Circuits/Unrolling/Trace/Internal/Topology.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Fragment -import Complexitylib.Circuits.Unrolling.Trace.Internal.Structure -import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.Topology + +module +public import Complexitylib.Circuits.Unrolling.Trace.Internal.Structure +public import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.Topology /-! # Topology of tiled bounded-trace circuits @@ -16,6 +17,9 @@ tracks the exact circuit length, first unused wire, and end of the current configuration block supplied by the trace-structure layer. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Transition.lean b/Complexitylib/Circuits/Unrolling/Transition.lean index 0ca1f12c..5ff232bb 100644 --- a/Complexitylib/Circuits/Unrolling/Transition.lean +++ b/Complexitylib/Circuits/Unrolling/Transition.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Unrolling.Transition.Defs -import Complexitylib.Circuits.Unrolling.Transition.Internal.Semantics -import Complexitylib.Circuits.Unrolling.Transition.Internal.Support + +module +public import Complexitylib.Circuits.Unrolling.Transition.Defs +public import Complexitylib.Circuits.Unrolling.Transition.Internal.Semantics +public import Complexitylib.Circuits.Unrolling.Transition.Internal.Support /-! # Boolean formulas for one Turing-machine transition @@ -23,6 +25,9 @@ successor machine step. - `vars_nextFormula_lt`: all references lie in a sufficiently large prefix. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Transition/Defs.lean b/Complexitylib/Circuits/Unrolling/Transition/Defs.lean index 34b4b89c..9cc48819 100644 --- a/Complexitylib/Circuits/Unrolling/Transition/Defs.lean +++ b/Complexitylib/Circuits/Unrolling/Transition/Defs.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Formula.Batch.Defs -import Complexitylib.Circuits.Unrolling.Defs -import Mathlib.Data.Fintype.Prod + +module +public import Complexitylib.Circuits.Encoding.Formula.Batch.Defs +public import Complexitylib.Circuits.Unrolling.Defs +public import Mathlib.Data.Fintype.Prod /-! # Boolean formulas for one Turing-machine transition @@ -23,6 +25,9 @@ the largest represented head position has no represented target; clients rule out that case with `HeadsLt` before applying transition correctness. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling @@ -51,7 +56,7 @@ end WritableSlot deriving DecidableEq /-- Product representation used to enumerate complete local views. -/ -private def transitionCaseEquiv (tm : NTM k) : +def transitionCaseEquiv (tm : NTM k) : TransitionCase tm ≃ Bool × tm.Q × Γ × (Fin k → Γ) × Γ where toFun view := (view.choice, view.state, view.inputRead, view.workRead, view.outputRead) diff --git a/Complexitylib/Circuits/Unrolling/Transition/Fragment.lean b/Complexitylib/Circuits/Unrolling/Transition/Fragment.lean index 28f0eae6..7a421c6d 100644 --- a/Complexitylib/Circuits/Unrolling/Transition/Fragment.lean +++ b/Complexitylib/Circuits/Unrolling/Transition/Fragment.lean @@ -3,12 +3,14 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Unrolling.Transition.Fragment.Defs -import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.ArrayEvaluation -import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.Evaluation -import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.Size -import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.Structure -import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.Topology + +module +public import Complexitylib.Circuits.Unrolling.Transition.Fragment.Defs +public import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.ArrayEvaluation +public import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.Evaluation +public import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.Size +public import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.Structure +public import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.Topology /-! # Packed circuit fragments for one Turing-machine transition @@ -26,6 +28,9 @@ machine-dependent quadratic size in the trace horizon. - `stepFragmentSize_le`: a machine-dependent quadratic size bound. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Transition/Fragment/Defs.lean b/Complexitylib/Circuits/Unrolling/Transition/Fragment/Defs.lean index 3a501ef4..dda1d981 100644 --- a/Complexitylib/Circuits/Unrolling/Transition/Fragment/Defs.lean +++ b/Complexitylib/Circuits/Unrolling/Transition/Fragment/Defs.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Formula.Batch.Defs -import Complexitylib.Circuits.Unrolling.Transition.Defs + +module +public import Complexitylib.Circuits.Unrolling.Transition.Defs /-! # Packed circuit fragments for one Turing-machine transition @@ -15,6 +16,9 @@ copied into a contiguous block in configuration-atom order, so that block can serve directly as the input configuration of a later unrolled step. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Transition/Fragment/Internal/ArrayEvaluation.lean b/Complexitylib/Circuits/Unrolling/Transition/Fragment/Internal/ArrayEvaluation.lean index fb58cb15..ed289e34 100644 --- a/Complexitylib/Circuits/Unrolling/Transition/Fragment/Internal/ArrayEvaluation.lean +++ b/Complexitylib/Circuits/Unrolling/Transition/Fragment/Internal/ArrayEvaluation.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.Evaluation + +module +public import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.Evaluation /-! # Array-level evaluation of packed transition fragments @@ -14,6 +16,9 @@ evaluate a packed transition using an encoded configuration and an actual choice wire, without separately constructing a total Boolean assignment. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Transition/Fragment/Internal/Evaluation.lean b/Complexitylib/Circuits/Unrolling/Transition/Fragment/Internal/Evaluation.lean index 390a89d4..afe34a54 100644 --- a/Complexitylib/Circuits/Unrolling/Transition/Fragment/Internal/Evaluation.lean +++ b/Complexitylib/Circuits/Unrolling/Transition/Fragment/Internal/Evaluation.lean @@ -3,11 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Formula.Batch -import Complexitylib.Circuits.Unrolling.Transition.Fragment.Defs -import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.Structure -import Complexitylib.Circuits.Unrolling.Transition.Internal.Semantics -import Complexitylib.Circuits.Unrolling.Transition.Internal.Support + +module +public import Complexitylib.Circuits.Unrolling.Transition.Fragment.Defs +public import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.Structure +public import Complexitylib.Circuits.Unrolling.Transition.Internal.Semantics +public import Complexitylib.Circuits.Unrolling.Transition.Internal.Support /-! # Evaluation of packed one-step circuit fragments @@ -17,6 +18,9 @@ through the formula batch compiler. The packed outputs form a fresh encoded configuration block for the halted-or-successor machine configuration. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Transition/Fragment/Internal/Size.lean b/Complexitylib/Circuits/Unrolling/Transition/Fragment/Internal/Size.lean index ac8d76f7..84c11f9f 100644 --- a/Complexitylib/Circuits/Unrolling/Transition/Fragment/Internal/Size.lean +++ b/Complexitylib/Circuits/Unrolling/Transition/Fragment/Internal/Size.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.Structure -import Mathlib.Algebra.Order.BigOperators.Group.List -import Mathlib.Tactic.Ring + +module +public import Complexitylib.Circuits.Unrolling.Transition.Fragment.Internal.Structure +public import Mathlib.Tactic.Ring.RingNF /-! # Size bounds for packed one-step transition fragments @@ -15,20 +16,27 @@ machine-dependent linear function of the trace horizon. Since a configuration block itself has linear width, the packed one-step fragment has quadratic size. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling -private def caseSizeCoeff (k : ℕ) : ℕ := +/-- Linear coefficient bounding the size of one transition-case formula. -/ +def caseSizeCoeff (k : ℕ) : ℕ := 4 * (k + 2) + 6 -private noncomputable def effectSizeCoeff (tm : NTM k) : ℕ := +/-- Linear coefficient bounding a transition-effect selector. -/ +noncomputable def effectSizeCoeff (tm : NTM k) : ℕ := 1 + (transitionCases tm).length * (caseSizeCoeff k + 1) -private noncomputable def nextSizeCoeff (tm : NTM k) : ℕ := +/-- Linear coefficient bounding a next-configuration formula. -/ +noncomputable def nextSizeCoeff (tm : NTM k) : ℕ := 3 * effectSizeCoeff tm + 20 -private def widthSizeCoeff (tm : NTM k) : ℕ := +/-- Linear coefficient bounding the width of a configuration fragment. -/ +def widthSizeCoeff (tm : NTM k) : ℕ := Fintype.card tm.Q + 5 * (k + 2) private theorem sum_map_le_length_mul {alpha : Type*} (items : List alpha) diff --git a/Complexitylib/Circuits/Unrolling/Transition/Fragment/Internal/Structure.lean b/Complexitylib/Circuits/Unrolling/Transition/Fragment/Internal/Structure.lean index 7ea21457..b5ecaa22 100644 --- a/Complexitylib/Circuits/Unrolling/Transition/Fragment/Internal/Structure.lean +++ b/Complexitylib/Circuits/Unrolling/Transition/Fragment/Internal/Structure.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Formula.Batch -import Complexitylib.Circuits.Unrolling.Internal.Initialization -import Complexitylib.Circuits.Unrolling.Transition.Fragment.Defs + +module +public import Complexitylib.Circuits.Encoding.Formula.Batch +public import Complexitylib.Circuits.Unrolling.Internal.Initialization +public import Complexitylib.Circuits.Unrolling.Transition.Fragment.Defs /-! # Structural properties of packed one-step circuit fragments @@ -15,6 +17,9 @@ the formula batch compiler. It records the exact formula and gate counts, formula lookup order, and arithmetic addresses of packed successor atoms. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Transition/Fragment/Internal/Topology.lean b/Complexitylib/Circuits/Unrolling/Transition/Fragment/Internal/Topology.lean index 76bcac1d..4ccffdc2 100644 --- a/Complexitylib/Circuits/Unrolling/Transition/Fragment/Internal/Topology.lean +++ b/Complexitylib/Circuits/Unrolling/Transition/Fragment/Internal/Topology.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Formula.Batch -import Complexitylib.Circuits.Unrolling.Transition.Fragment.Defs -import Complexitylib.Circuits.Unrolling.Transition.Internal.Support + +module +public import Complexitylib.Circuits.Encoding.Formula.Batch +public import Complexitylib.Circuits.Unrolling.Transition.Fragment.Defs +public import Complexitylib.Circuits.Unrolling.Transition.Internal.Support /-! # Topology of packed one-step circuit fragments @@ -15,6 +17,9 @@ topologically well formed whenever its choice wire and incoming configuration block lie in the existing circuit prefix. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Transition/Internal/Semantics.lean b/Complexitylib/Circuits/Unrolling/Transition/Internal/Semantics.lean index 3839ac02..e4a40800 100644 --- a/Complexitylib/Circuits/Unrolling/Transition/Internal/Semantics.lean +++ b/Complexitylib/Circuits/Unrolling/Transition/Internal/Semantics.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Formula.Batch -import Complexitylib.Circuits.Unrolling.Transition.Defs -import Mathlib.Data.List.OfFn + +module +public import Complexitylib.Circuits.Encoding.Formula.Batch +public import Complexitylib.Circuits.Unrolling.Transition.Defs /-! # Semantic correctness of one-step transition formulas @@ -16,6 +17,9 @@ The proofs first decode reads and complete local transition cases, then verify the head-movement and tape-write formulas atom by atom. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Unrolling/Transition/Internal/Support.lean b/Complexitylib/Circuits/Unrolling/Transition/Internal/Support.lean index dd3115c7..942c9506 100644 --- a/Complexitylib/Circuits/Unrolling/Transition/Internal/Support.lean +++ b/Complexitylib/Circuits/Unrolling/Transition/Internal/Support.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Formula.Batch -import Complexitylib.Circuits.Unrolling.Transition.Defs + +module +public import Complexitylib.Circuits.Unrolling.Transition.Defs /-! # Variable support of transition formulas @@ -15,6 +16,9 @@ The resulting numeric bound is the topological-ordering premise needed by the packed Boolean-formula compiler. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Circuits/Valiant.lean b/Complexitylib/Circuits/Valiant.lean index 49b9e07a..346e7d6a 100644 --- a/Complexitylib/Circuits/Valiant.lean +++ b/Complexitylib/Circuits/Valiant.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Internal.Valiant + +module +public import Complexitylib.Circuits.Internal.Valiant /-! # Valiant's Depth Reduction Lemma @@ -27,6 +29,9 @@ first-differing bit, averaging, and the relabeling-after-removal bound — lives in `Complexitylib.Circuits.Internal.Valiant`. -/ + +@[expose] public section + namespace Complexity namespace Valiant diff --git a/Complexitylib/Circuits/XOR.lean b/Complexitylib/Circuits/XOR.lean index f6ac836a..5a923853 100644 --- a/Complexitylib/Circuits/XOR.lean +++ b/Complexitylib/Circuits/XOR.lean @@ -3,7 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Basic + +module +public import Complexitylib.Circuits.Basic +public import Std.Tactic.BVDecide.Normalize.Bool /-! # XOR (Parity) Function @@ -19,6 +22,9 @@ This module defines the N-input XOR function and its key properties. * `Schnorr.xorBool_essential` — XOR depends on all inputs -/ + +@[expose] public section + namespace Complexity namespace Schnorr diff --git a/Complexitylib/Circuits/XOR/Restriction.lean b/Complexitylib/Circuits/XOR/Restriction.lean index ac43af87..3b286bb2 100644 --- a/Complexitylib/Circuits/XOR/Restriction.lean +++ b/Complexitylib/Circuits/XOR/Restriction.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.XOR.Restriction.Defs -import Complexitylib.Circuits.XOR.Restriction.Internal + +module +public import Complexitylib.Circuits.XOR.Restriction.Defs +public import Complexitylib.Circuits.XOR.Restriction.Internal /-! # Parity under finite restrictions @@ -18,6 +20,9 @@ parity on `support` has depth at least `support.card`. This is the parity-side contradiction needed after a switching argument leaves many variables free. -/ + +@[expose] public section + namespace Complexity namespace Schnorr diff --git a/Complexitylib/Circuits/XOR/Restriction/Defs.lean b/Complexitylib/Circuits/XOR/Restriction/Defs.lean index c4a32ea9..c5edd8ad 100644 --- a/Complexitylib/Circuits/XOR/Restriction/Defs.lean +++ b/Complexitylib/Circuits/XOR/Restriction/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.XOR + +module +public import Complexitylib.Circuits.Basic /-! # Parity on a finite support -- definitions @@ -12,6 +14,9 @@ Random restrictions leave parity on the remaining free coordinates, possibly complemented by the fixed coordinates. `xorOn` makes that support explicit. -/ + +@[expose] public section + namespace Complexity namespace Schnorr diff --git a/Complexitylib/Circuits/XOR/Restriction/Internal.lean b/Complexitylib/Circuits/XOR/Restriction/Internal.lean index f59e3a1f..6fd9804a 100644 --- a/Complexitylib/Circuits/XOR/Restriction/Internal.lean +++ b/Complexitylib/Circuits/XOR/Restriction/Internal.lean @@ -3,13 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.DecisionTree.Finite -import Complexitylib.Circuits.XOR.Restriction.Defs + +module +public import Complexitylib.Circuits.DecisionTree.Finite +public import Complexitylib.Circuits.XOR.Restriction.Defs +public import Complexitylib.Circuits.XOR /-! # Parity on a finite support -- proof internals -/ + +@[expose] public section + namespace Complexity namespace Schnorr diff --git a/Complexitylib/Classes.lean b/Complexitylib/Classes.lean index dc8ceb19..bd57d65f 100644 --- a/Complexitylib/Classes.lean +++ b/Complexitylib/Classes.lean @@ -3,68 +3,70 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.Time -import Complexitylib.Classes.Space -import Complexitylib.Classes.FiniteCounting -import Complexitylib.Classes.EventProb -import Complexitylib.Classes.PropertyDensity -import Complexitylib.Classes.SharpP -import Complexitylib.Classes.Negligible -import Complexitylib.Classes.P -import Complexitylib.Classes.PPoly -import Complexitylib.Classes.PPoly.Advice -import Complexitylib.Classes.PPoly.Unrolling -import Complexitylib.Classes.PPoly.Uniform -import Complexitylib.Classes.PPoly.Uniform.Unrolling -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Padded -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Containment -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Finalization -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Initialization -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.PolynomialOffset -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Program -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Tableau -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Effect -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.MovedHead -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Next -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.PackedCopy -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Predecessor -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Read -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Case -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.WrittenCell -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Stream -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Bounds -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Finalization -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Atomic -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Case -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Effect -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.MovedHead -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Next -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Polynomial -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Step -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.WrittenCell -import Complexitylib.Classes.PPoly.Uniform.Preprocessing -import Complexitylib.Classes.PPoly.Uniform.Containment -import Complexitylib.Classes.NP -import Complexitylib.Classes.Randomized -import Complexitylib.Classes.Randomized.GoodSeed -import Complexitylib.Classes.Randomized.CircuitAmplification -import Complexitylib.Classes.Randomized.PPoly -import Complexitylib.Classes.Pairing -import Complexitylib.Classes.FNP -import Complexitylib.Classes.NP.Witness -import Complexitylib.Classes.NP.Reduction -import Complexitylib.Classes.L -import Complexitylib.Classes.L.PolynomialTime -import Complexitylib.Classes.Exponential -import Complexitylib.Classes.DTISP -import Complexitylib.Classes.Containments -import Complexitylib.Classes.Hierarchy + +module +public import Complexitylib.Classes.Time +public import Complexitylib.Classes.Space +public import Complexitylib.Classes.FiniteCounting +public import Complexitylib.Classes.EventProb +public import Complexitylib.Classes.PropertyDensity +public import Complexitylib.Classes.SharpP +public import Complexitylib.Classes.Negligible +public import Complexitylib.Classes.P +public import Complexitylib.Classes.PPoly +public import Complexitylib.Classes.PPoly.Advice +public import Complexitylib.Classes.PPoly.Unrolling +public import Complexitylib.Classes.PPoly.Uniform +public import Complexitylib.Classes.PPoly.Uniform.Unrolling +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Padded +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Containment +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Finalization +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Initialization +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.PolynomialOffset +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Program +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Tableau +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Effect +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.MovedHead +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Next +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.PackedCopy +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Predecessor +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Read +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Case +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.WrittenCell +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Stream +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Bounds +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Finalization +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Atomic +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Case +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Effect +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.MovedHead +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Next +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Polynomial +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Step +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.WrittenCell +public import Complexitylib.Classes.PPoly.Uniform.Preprocessing +public import Complexitylib.Classes.PPoly.Uniform.Containment +public import Complexitylib.Classes.NP +public import Complexitylib.Classes.Randomized +public import Complexitylib.Classes.Randomized.GoodSeed +public import Complexitylib.Classes.Randomized.CircuitAmplification +public import Complexitylib.Classes.Randomized.PPoly +public import Complexitylib.Classes.Pairing +public import Complexitylib.Classes.FNP +public import Complexitylib.Classes.NP.Witness +public import Complexitylib.Classes.NP.Reduction +public import Complexitylib.Classes.L +public import Complexitylib.Classes.L.PolynomialTime +public import Complexitylib.Classes.Exponential +public import Complexitylib.Classes.DTISP +public import Complexitylib.Classes.Containments +public import Complexitylib.Classes.Hierarchy /-! # Complexity classes diff --git a/Complexitylib/Classes/Containments.lean b/Complexitylib/Classes/Containments.lean index 96f644c5..8103651f 100644 --- a/Complexitylib/Classes/Containments.lean +++ b/Complexitylib/Classes/Containments.lean @@ -3,13 +3,13 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.P -import Complexitylib.Classes.NP -import Complexitylib.Classes.Randomized -import Complexitylib.Classes.L -import Complexitylib.Classes.Exponential -import Complexitylib.Models.TuringMachine.Internal -import Complexitylib.Models.TuringMachine.Combinators.Internal.Complement + +module +public import Complexitylib.Classes.P +public import Complexitylib.Classes.NP +public import Complexitylib.Classes.Randomized +public import Complexitylib.Classes.L +public import Complexitylib.Classes.Exponential /-! # Containment relations between complexity classes @@ -48,6 +48,9 @@ This file collects the standard containment results between complexity classes. - `P_inter` — `L₁ ∈ P → L₂ ∈ P → L₁ ∩ L₂ ∈ P` (P closed under intersection) -/ + +@[expose] public section + namespace Complexity diff --git a/Complexitylib/Classes/DTISP.lean b/Complexitylib/Classes/DTISP.lean index b2251e40..917647ce 100644 --- a/Complexitylib/Classes/DTISP.lean +++ b/Complexitylib/Classes/DTISP.lean @@ -3,10 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine -import Complexitylib.Classes.Space -import Complexitylib.Asymptotics -import Mathlib.Data.Nat.Log + +module +public import Complexitylib.Models.TuringMachine +public import Complexitylib.Asymptotics /-! # Simultaneous time-space complexity classes @@ -18,6 +18,9 @@ The key distinction from intersecting separate time and space classes is that `DTISP` requires a *single* machine satisfying both bounds simultaneously. -/ + +@[expose] public section + namespace Complexity diff --git a/Complexitylib/Classes/EventProb.lean b/Complexitylib/Classes/EventProb.lean index 700347a6..f637eb7b 100644 --- a/Complexitylib/Classes/EventProb.lean +++ b/Complexitylib/Classes/EventProb.lean @@ -3,17 +3,15 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.FiniteCounting -import Complexitylib.Models.TuringMachine -import Mathlib.Algebra.BigOperators.Field -import Mathlib.Algebra.Order.Field.Basic -import Mathlib.Data.Nat.Choose.Sum -import Mathlib.Tactic.FieldSimp -import Mathlib.Tactic.GCongr -import Mathlib.Tactic.Linarith -import Mathlib.Tactic.NormNum -import Mathlib.Tactic.Positivity -import Mathlib.Tactic.Ring + +module +public import Complexitylib.Classes.FiniteCounting +public import Complexitylib.Models.TuringMachine +public import Mathlib.Algebra.BigOperators.Field +public import Mathlib.Algebra.Order.Field.Basic +public import Mathlib.Data.Nat.Choose.Sum +public import Mathlib.Tactic.FieldSimp +public import Mathlib.Tactic.Positivity.Finset /-! # Finite event probability @@ -49,6 +47,9 @@ rational PTM acceptance probability `NTM.acceptProb` (roadmap track N2). bits when a machine's acceptance factors through the compact repetition seed -/ + +@[expose] public section + namespace Complexity /-- The uniform probability of a finite event `E ⊆ (Fin T → Bool)`: the fraction diff --git a/Complexitylib/Classes/Exponential.lean b/Complexitylib/Classes/Exponential.lean index 48d39967..c49be5da 100644 --- a/Complexitylib/Classes/Exponential.lean +++ b/Complexitylib/Classes/Exponential.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.Time + +module +public import Complexitylib.Classes.Time /-! # Exponential time complexity classes @@ -12,6 +14,9 @@ This file defines **EXP** and **NEXP**, the exponential-time analogues of P and NP respectively. -/ + +@[expose] public section + namespace Complexity /-- **EXP** is the class of languages decidable by a deterministic TM in diff --git a/Complexitylib/Classes/FNP.lean b/Complexitylib/Classes/FNP.lean index ffb8900f..6ecf71bc 100644 --- a/Complexitylib/Classes/FNP.lean +++ b/Complexitylib/Classes/FNP.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.FNP.Defs -import Complexitylib.Classes.FNP.Internal + +module +public import Complexitylib.Classes.FNP.Defs +public import Complexitylib.Classes.FNP.Internal /-! # FNP and TFNP @@ -15,6 +17,9 @@ NP ∩ coNP: if a language has both NP and coNP witness relations, the combined certificate-finding problem is in TFNP (Megiddo–Papadimitriou 1991). -/ + +@[expose] public section + namespace Complexity /-- **NP ∩ coNP yields TFNP** (Megiddo–Papadimitriou 1991): given FNP relations diff --git a/Complexitylib/Classes/FNP/Defs.lean b/Complexitylib/Classes/FNP/Defs.lean index 50410802..c74147f9 100644 --- a/Complexitylib/Classes/FNP/Defs.lean +++ b/Complexitylib/Classes/FNP/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.Pairing -import Complexitylib.Classes.P + +module +public import Complexitylib.Classes.Pairing +public import Complexitylib.Classes.P.Defs /-! # FNP and TFNP — Definitions @@ -14,6 +16,9 @@ and the `OrRelation` combinator used to construct TFNP problems from NP ∩ coNP witness pairs. -/ + +@[expose] public section + namespace Complexity /-- **FNP** is the class of search problems defined by NP relations: binary diff --git a/Complexitylib/Classes/FNP/Internal.lean b/Complexitylib/Classes/FNP/Internal.lean index 75a502b7..5fc17277 100644 --- a/Complexitylib/Classes/FNP/Internal.lean +++ b/Complexitylib/Classes/FNP/Internal.lean @@ -3,9 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.FNP.Defs -import Complexitylib.Classes.P -import Mathlib.Analysis.Asymptotics.Defs + +module +public import Complexitylib.Classes.FNP.Defs +public import Complexitylib.Classes.P /-! # FNP and TFNP — Internal proofs @@ -14,6 +15,9 @@ Helper lemmas for `OrRelation` used by the surface-layer theorem `orRelation_mem_TFNP_of_NP_coNP_witnesses`. -/ + +@[expose] public section + namespace Complexity open Complexity Asymptotics Filter diff --git a/Complexitylib/Classes/FiniteCounting.lean b/Complexitylib/Classes/FiniteCounting.lean index 41370621..d74d9afd 100644 --- a/Complexitylib/Classes/FiniteCounting.lean +++ b/Complexitylib/Classes/FiniteCounting.lean @@ -3,18 +3,16 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Data.Fintype.Card -import Mathlib.Data.Fintype.Fin -import Mathlib.Data.Fintype.Sum -import Mathlib.Data.Fintype.BigOperators -import Mathlib.Data.Finset.Card -import Mathlib.Data.Finset.Powerset -import Mathlib.Logic.Equiv.Prod -import Mathlib.Logic.Equiv.Fin.Basic -import Mathlib.Algebra.BigOperators.Group.Finset.Basic -import Mathlib.Algebra.BigOperators.Group.Finset.Piecewise -import Mathlib.Algebra.Ring.Parity -import Mathlib.Order.Interval.Finset.Nat + +module +public import Mathlib.Data.Fintype.Fin +public import Mathlib.Data.Fintype.BigOperators +public import Mathlib.Data.Finset.Powerset +public import Mathlib.Logic.Equiv.Fin.Basic +public import Mathlib.Algebra.Ring.Parity +public import Mathlib.Order.Interval.Finset.Nat +public import Std.Tactic.BVDecide.Normalize.BitVec +public import Std.Tactic.BVDecide.Normalize.Prop /-! # Finite counting toolkit @@ -55,6 +53,9 @@ and interactive proofs (roadmap track N2). negation at odd length -/ + +@[expose] public section + namespace Complexity /-! ### Cardinality of the random-bit sample space -/ @@ -291,7 +292,8 @@ def blocksEquiv (k T : ℕ) : /-! ### Fixed-time repetition schedules -/ -private def repeatStrideIndexEquiv (k T : ℕ) : +/-- Split stride positions into simulation slots and administrative slots. -/ +def repeatStrideIndexEquiv (k T : ℕ) : Fin (k * T) ⊕ Fin (k * (T + 2)) ≃ Fin (k * (2 * T + 2)) := (Equiv.sumCongr finProdFinEquiv.symm finProdFinEquiv.symm).trans <| (Equiv.prodSumDistrib (Fin k) (Fin T) (Fin (T + 2))).symm |>.trans <| @@ -301,13 +303,15 @@ private def repeatStrideIndexEquiv (k T : ℕ) : congr 1 omega) -private def repeatStrideSeedEquiv (k T : ℕ) : +/-- Split a full stride seed into simulation and administrative choices. -/ +def repeatStrideSeedEquiv (k T : ℕ) : (Fin (k * (2 * T + 2)) → Bool) ≃ (Fin (k * T) → Bool) × (Fin (k * (T + 2)) → Bool) := (Equiv.arrowCongr (repeatStrideIndexEquiv k T) (Equiv.refl Bool)).symm.trans (Equiv.sumArrowEquivProdArrow (Fin (k * T)) (Fin (k * (T + 2))) Bool) -private def repeatStrideRandomSeed (k T : ℕ) +/-- Project a repetition stride onto its `k * T` genuine simulation choices. -/ +def repeatStrideRandomSeed (k T : ℕ) (w : Fin (k * (2 * T + 2)) → Bool) : Fin (k * T) → Bool := (repeatStrideSeedEquiv k T w).1 diff --git a/Complexitylib/Classes/Hierarchy.lean b/Complexitylib/Classes/Hierarchy.lean index b518d9c7..5aff0376 100644 --- a/Complexitylib/Classes/Hierarchy.lean +++ b/Complexitylib/Classes/Hierarchy.lean @@ -3,10 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Diagonal -import Complexitylib.Models.TuringMachine.UTM.Universal -import Complexitylib.Classes.Containments -import Mathlib.Analysis.Asymptotics.SpecificAsymptotics + +module +public import Complexitylib.Models.TuringMachine.UTM.Diagonal +public import Complexitylib.Classes.Containments +public import Complexitylib.Models.TuringMachine.Deterministic +public import Complexitylib.Models.TuringMachine.UTM.Internal.Terminated /-! # The deterministic time hierarchy theorem (weak form) @@ -39,6 +41,9 @@ The witness is the diagonal language `diagLang clk` of the diagonalizer `DTIME((n + 1)^a) ⊂ DTIME((n + 1)^(2a + 5))` for `a ≥ 1` -/ + +@[expose] public section + namespace Complexity open Asymptotics Filter Complexity diff --git a/Complexitylib/Classes/L.lean b/Complexitylib/Classes/L.lean index ccc75ffc..38f7da78 100644 --- a/Complexitylib/Classes/L.lean +++ b/Complexitylib/Classes/L.lean @@ -3,11 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine -import Complexitylib.Classes.Time -import Complexitylib.Classes.Pairing -import Complexitylib.Asymptotics -import Mathlib.Data.Nat.Log + +module +public import Complexitylib.Classes.Time +public import Complexitylib.Classes.Pairing /-! # Log-space transducer classes @@ -23,6 +22,9 @@ never moves left. `TM.ComputesInSpace` includes this discipline internally so function output may have unbounded length without becoming read-write workspace. -/ + +@[expose] public section + namespace Complexity diff --git a/Complexitylib/Classes/L/PolynomialTime.lean b/Complexitylib/Classes/L/PolynomialTime.lean index 950065c9..9d08699b 100644 --- a/Complexitylib/Classes/L/PolynomialTime.lean +++ b/Complexitylib/Classes/L/PolynomialTime.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.L.PolynomialTime.Internal + +module +public import Complexitylib.Classes.L.PolynomialTime.Internal /-! # Log-space transducers run in polynomial time @@ -20,6 +22,9 @@ bound. Consequently `L ⊆ P` and `FL ⊆ FP`. - `FL_subset_FP` — deterministic log-space functions are polynomial-time -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Classes/L/PolynomialTime/Internal.lean b/Complexitylib/Classes/L/PolynomialTime/Internal.lean index 59b4ec05..1cedbeb4 100644 --- a/Complexitylib/Classes/L/PolynomialTime/Internal.lean +++ b/Complexitylib/Classes/L/PolynomialTime/Internal.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.L -import Complexitylib.Classes.P.Defs -import Complexitylib.Models.TuringMachine.SpaceTime + +module +public import Complexitylib.Classes.L +public import Complexitylib.Classes.P.Defs +public import Complexitylib.Models.TuringMachine.SpaceTime /-! # Log-space transducers run in polynomial time — proof internals @@ -15,6 +17,9 @@ transducers into a polynomial bound when the auxiliary space is logarithmic. The public results are in `Complexitylib.Classes.L.PolynomialTime`. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Classes/NP.lean b/Complexitylib/Classes/NP.lean index d2569533..9e9a6948 100644 --- a/Complexitylib/Classes/NP.lean +++ b/Complexitylib/Classes/NP.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.Time -import Complexitylib.Classes.Space + +module +public import Complexitylib.Classes.Time +public import Complexitylib.Classes.Space /-! # NP, coNP, and NPSPACE @@ -14,6 +16,9 @@ This file defines **NP** (nondeterministic polynomial time), **coNP**, and `NTIME` and `NSPACE`. -/ + +@[expose] public section + namespace Complexity /-- **NP** is the class of languages decidable by a nondeterministic TM in diff --git a/Complexitylib/Classes/NP/Internal/PairBuildTM.lean b/Complexitylib/Classes/NP/Internal/PairBuildTM.lean index 8f444734..8b401373 100644 --- a/Complexitylib/Classes/NP/Internal/PairBuildTM.lean +++ b/Complexitylib/Classes/NP/Internal/PairBuildTM.lean @@ -3,11 +3,15 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Hoare.Defs -import Complexitylib.Models.TuringMachine.Trace -import Complexitylib.Classes.Pairing + +module +public import Complexitylib.Models.TuringMachine.Combinators +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Models.TuringMachine.Hoare.Defs +public import Complexitylib.Models.TuringMachine.Trace +public import Complexitylib.Encoding.Pairing +public import Mathlib.Algebra.Order.Ring.Nat +public import Mathlib.Tactic.Ring.RingNF /-! # `pairBuildTM`: construct `pair x y` on a work tape @@ -68,6 +72,9 @@ Everything in this file is fully proved (no `sorry`). The main contents: and `pIdx` are untouched), each assuming the tape's head is past `▷`. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Classes/NP/Internal/PairSplitTM.lean b/Complexitylib/Classes/NP/Internal/PairSplitTM.lean index ff069cb2..56bd7132 100644 --- a/Complexitylib/Classes/NP/Internal/PairSplitTM.lean +++ b/Complexitylib/Classes/NP/Internal/PairSplitTM.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.PairSplit + +module +public import Complexitylib.Models.TuringMachine.Subroutines.PairSplit /-! # Pair-split compatibility import diff --git a/Complexitylib/Classes/NP/Reduction.lean b/Complexitylib/Classes/NP/Reduction.lean index df0c19b4..556816b9 100644 --- a/Complexitylib/Classes/NP/Reduction.lean +++ b/Complexitylib/Classes/NP/Reduction.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.NP -import Complexitylib.Classes.P + +module +public import Complexitylib.Classes.NP +public import Complexitylib.Classes.P /-! # Polynomial-time many-one reductions and NP-completeness @@ -21,6 +23,9 @@ The headline application is `SAT.NPComplete_language` (Cook–Levin), in `Complexitylib/SAT/CookLevin.lean`. -/ + +@[expose] public section + namespace Complexity diff --git a/Complexitylib/Classes/NP/Witness.lean b/Complexitylib/Classes/NP/Witness.lean index ace5fac9..0e856c66 100644 --- a/Complexitylib/Classes/NP/Witness.lean +++ b/Complexitylib/Classes/NP/Witness.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.NP -import Complexitylib.Classes.FNP + +module +public import Complexitylib.Classes.NP +public import Complexitylib.Classes.FNP.Defs /-! # NP witness characterization @@ -50,6 +52,9 @@ All downstream consequences (including `SAT ∈ NP` conditional on the SAT verifier being in P) rest only on that single lemma. -/ + +@[expose] public section + namespace Complexity diff --git a/Complexitylib/Classes/Negligible.lean b/Complexitylib/Classes/Negligible.lean index 0de2665f..47644501 100644 --- a/Complexitylib/Classes/Negligible.lean +++ b/Complexitylib/Classes/Negligible.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Data.Real.Basic + +module +public import Mathlib.Data.Real.Basic /-! # Negligible functions @@ -12,6 +14,9 @@ A function `f : ℕ → ℝ` is *negligible* if it vanishes faster than any inve polynomial. This is the standard notion used in cryptographic definitions. -/ + +@[expose] public section + namespace Complexity /-- A function `f : ℕ → ℝ` is negligible if for every `c`, `|f(n)| < 1/n^c` diff --git a/Complexitylib/Classes/P.lean b/Complexitylib/Classes/P.lean index af84b827..b27cf6ae 100644 --- a/Complexitylib/Classes/P.lean +++ b/Complexitylib/Classes/P.lean @@ -3,15 +3,16 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.P.Defs -import Complexitylib.Classes.P.Internal -import Complexitylib.Classes.P.NormalForm -import Complexitylib.Classes.P.Composition -import Complexitylib.Classes.P.PairWithInput -import Complexitylib.Classes.P.Preimage -import Complexitylib.Classes.P.UnaryLength -import Complexitylib.Classes.P.FinsetDomain -import Complexitylib.Models.TuringMachine.Subroutines.CopyOutput +module +public import Complexitylib.Classes.P.Defs +public import Complexitylib.Classes.P.Internal +public import Complexitylib.Classes.P.NormalForm +public import Complexitylib.Classes.P.Composition +public import Complexitylib.Classes.P.PairWithInput +public import Complexitylib.Classes.P.Preimage +public import Complexitylib.Classes.P.UnaryLength +public import Complexitylib.Classes.P.FinsetDomain +public import Complexitylib.Models.TuringMachine.Subroutines.CopyOutput /-! # P — surface layer @@ -37,6 +38,9 @@ This file aggregates the definitions and theorems for P, FP, and PSPACE. - `ite_mem_finset_mem_FP` — functions supported on a finite set belong to `FP` -/ + +@[expose] public section + namespace Complexity diff --git a/Complexitylib/Classes/P/Composition.lean b/Complexitylib/Classes/P/Composition.lean index 1b834d1f..ff13cd14 100644 --- a/Complexitylib/Classes/P/Composition.lean +++ b/Complexitylib/Classes/P/Composition.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.P.Internal.Composition + +module +public import Complexitylib.Classes.P.Internal.Composition /-! # Closure of FP under composition @@ -13,6 +15,9 @@ import Complexitylib.Classes.P.Internal.Composition - `mem_FP_comp` — polynomial-time string functions are closed under composition -/ + +@[expose] public section + namespace Complexity /-- The composition of two polynomial-time string functions is polynomial-time. -/ diff --git a/Complexitylib/Classes/P/Defs.lean b/Complexitylib/Classes/P/Defs.lean index d844be7e..fff0f941 100644 --- a/Complexitylib/Classes/P/Defs.lean +++ b/Complexitylib/Classes/P/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.Time -import Complexitylib.Classes.Space + +module +public import Complexitylib.Classes.Time +public import Complexitylib.Classes.Space /-! # P, FP, and PSPACE @@ -14,6 +16,9 @@ and **PSPACE** (polynomial space) in terms of the base classes `DTIME` and `DSPACE`. -/ + +@[expose] public section + namespace Complexity diff --git a/Complexitylib/Classes/P/FinsetDomain.lean b/Complexitylib/Classes/P/FinsetDomain.lean index b5a0eaff..48712472 100644 --- a/Complexitylib/Classes/P/FinsetDomain.lean +++ b/Complexitylib/Classes/P/FinsetDomain.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Bolton Bailey. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bolton Bailey -/ -import Complexitylib.Classes.P.FinsetDomain.Internal + +module +public import Complexitylib.Classes.P.FinsetDomain.Internal /-! # Finite-deviation functions are polynomial-time @@ -24,6 +26,8 @@ regardless of how the values `g s` are chosen. - `ite_mem_finset_mem_FP` — `fun s => if s ∈ S then g s else []` belongs to `FP` -/ +@[expose] public section + namespace Complexity /-- A function that agrees with the constant empty-output function except on a diff --git a/Complexitylib/Classes/P/FinsetDomain/Internal.lean b/Complexitylib/Classes/P/FinsetDomain/Internal.lean index b14cd854..f718c37d 100644 --- a/Complexitylib/Classes/P/FinsetDomain/Internal.lean +++ b/Complexitylib/Classes/P/FinsetDomain/Internal.lean @@ -3,13 +3,15 @@ Copyright (c) 2026 Bolton Bailey. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bolton Bailey -/ -import Mathlib.Data.Fintype.Sets -import Mathlib.Data.Fintype.Option -import Mathlib.Data.Finset.Lattice.Fold -import Complexitylib.Mathlib.FinsetPrefixes -import Complexitylib.Classes.P.NormalForm -import Complexitylib.Models.TuringMachine.Tape.Encoding -import Complexitylib.Models.TuringMachine.Combinators + +module +public import Mathlib.Data.Fintype.Sets +public import Mathlib.Data.Fintype.Option +public import Mathlib.Data.Finset.Lattice.Fold +public import Complexitylib.Mathlib.FinsetPrefixes +public import Complexitylib.Classes.P.NormalForm +public import Complexitylib.Models.TuringMachine.Tape.Encoding +public import Complexitylib.Models.TuringMachine.Combinators /-! # Finite-domain lookup machine (internal) @@ -38,6 +40,8 @@ The public statement (`ite_mem_finset_mem_FP`) lives in `Complexitylib.Classes.P.FinsetDomain`. -/ +@[expose] public section + namespace Complexity namespace TM.FinsetDomain @@ -90,7 +94,7 @@ inductive LookupState (g : List Bool → List Bool) (S : Finset (List Bool)) : T /-- `LookupState` as a sum of two finite subtypes and two extra states. This equivalence supplies the `DecidableEq` and `Fintype` instances, which cannot be derived because the `read`/`write` constructors have dependent fields. -/ -private def lookupStateEquiv : +def lookupStateEquiv : LookupState g S ≃ (Option {p : List Bool // p ∈ S.prefixes} ⊕ Option {w : List Bool // w ∈ (outputsFinset g S).suffixes}) where diff --git a/Complexitylib/Classes/P/Internal.lean b/Complexitylib/Classes/P/Internal.lean index 3dbd111d..5d02d162 100644 --- a/Complexitylib/Classes/P/Internal.lean +++ b/Complexitylib/Classes/P/Internal.lean @@ -3,10 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.P.Defs -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Combinators.Internal -import Mathlib.Analysis.Asymptotics.Defs + +module +public import Complexitylib.Models.TuringMachine.Combinators +public import Complexitylib.Asymptotics +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Retarget +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Union /-! # P closure properties — proof internals @@ -16,6 +18,9 @@ The key simulation theorem `unionTM_decidesInTime` establishes that the composite machine from `TM.unionTM` correctly decides `L₁ ∪ L₂`. -/ + +@[expose] public section + namespace Complexity open Complexity Asymptotics Filter diff --git a/Complexitylib/Classes/P/Internal/Composition.lean b/Complexitylib/Classes/P/Internal/Composition.lean index 0152f570..851524aa 100644 --- a/Complexitylib/Classes/P/Internal/Composition.lean +++ b/Complexitylib/Classes/P/Internal/Composition.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Asymptotics.PolynomialComposition -import Complexitylib.Classes.P.Internal.NormalForm -import Complexitylib.Models.TuringMachine.Composition + +module +public import Complexitylib.Asymptotics.PolynomialComposition +public import Complexitylib.Classes.P.Internal.NormalForm +public import Complexitylib.Models.TuringMachine.Composition /-! # Closure of FP under composition — proof internals @@ -15,6 +17,9 @@ normal forms for its two component computations. The public theorem is in `Complexitylib.Classes.P.Composition`. -/ + +@[expose] public section + namespace Complexity /-- Internal proof that polynomial-time string functions are closed under diff --git a/Complexitylib/Classes/P/Internal/NormalForm.lean b/Complexitylib/Classes/P/Internal/NormalForm.lean index cd9721c4..417a3142 100644 --- a/Complexitylib/Classes/P/Internal/NormalForm.lean +++ b/Complexitylib/Classes/P/Internal/NormalForm.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.P.Defs + +module +public import Complexitylib.Classes.P.Defs /-! # Polynomial-time normal forms — proof internals @@ -15,6 +17,9 @@ polynomial over the naturals, giving everywhere-valid monotone time bounds. The public theorem is in `Complexitylib.Classes.P.NormalForm`. -/ + +@[expose] public section + namespace Complexity /-- Internal proof that `P` membership is equivalent to decision within the diff --git a/Complexitylib/Classes/P/Internal/Preimage.lean b/Complexitylib/Classes/P/Internal/Preimage.lean index d7eed8ad..a83f339b 100644 --- a/Complexitylib/Classes/P/Internal/Preimage.lean +++ b/Complexitylib/Classes/P/Internal/Preimage.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.P.Internal.NormalForm -import Complexitylib.Models.TuringMachine.Composition + +module +public import Complexitylib.Classes.P.Internal.NormalForm +public import Complexitylib.Models.TuringMachine.Composition /-! # Closure of P under FP preimages — proof internals @@ -15,6 +17,9 @@ decides the preimage language within the polynomial obtained by composing those bounds. -/ + +@[expose] public section + namespace Complexity /-- Internal proof that polynomial-time languages are closed under preimages diff --git a/Complexitylib/Classes/P/NormalForm.lean b/Complexitylib/Classes/P/NormalForm.lean index 54ad369b..89e3d56e 100644 --- a/Complexitylib/Classes/P/NormalForm.lean +++ b/Complexitylib/Classes/P/NormalForm.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.P.Internal.NormalForm + +module +public import Complexitylib.Classes.P.Internal.NormalForm /-! # Polynomial-time normal forms @@ -19,6 +21,9 @@ normalized bounds are valid on every input length and are monotone. - `mem_FP_iff_computesInTime_polynomial` — polynomial-evaluation normal form for `FP` -/ + +@[expose] public section + namespace Complexity /-- A language belongs to `P` exactly when some deterministic machine decides diff --git a/Complexitylib/Classes/P/PairWithInput.lean b/Complexitylib/Classes/P/PairWithInput.lean index 80c18d17..95c22b05 100644 --- a/Complexitylib/Classes/P/PairWithInput.lean +++ b/Complexitylib/Classes/P/PairWithInput.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.P.PairWithInput.Internal + +module +public import Complexitylib.Classes.P.PairWithInput.Internal /-! # Polynomial-time pairing with the original input @@ -13,6 +15,9 @@ import Complexitylib.Classes.P.PairWithInput.Internal - `mem_FP_pairWithInput` — if `f ∈ FP`, then `x ↦ pair (f x) x` is in `FP` -/ + +@[expose] public section + namespace Complexity /-- A polynomial-time function can be evaluated and paired with its unchanged diff --git a/Complexitylib/Classes/P/PairWithInput/Internal.lean b/Complexitylib/Classes/P/PairWithInput/Internal.lean index 5507f8ea..176aeaef 100644 --- a/Complexitylib/Classes/P/PairWithInput/Internal.lean +++ b/Complexitylib/Classes/P/PairWithInput/Internal.lean @@ -3,13 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.P.Internal.NormalForm -import Complexitylib.Models.TuringMachine.Composition.PairWithInput + +module +public import Complexitylib.Classes.P.Internal.NormalForm +public import Complexitylib.Models.TuringMachine.Composition.PairWithInput /-! # Polynomial-time pairing with the original input — proof internals -/ + +@[expose] public section + namespace Complexity /-- Internal closure of `FP` under `x ↦ pair (f x) x`. -/ diff --git a/Complexitylib/Classes/P/Preimage.lean b/Complexitylib/Classes/P/Preimage.lean index 619aef79..779e316b 100644 --- a/Complexitylib/Classes/P/Preimage.lean +++ b/Complexitylib/Classes/P/Preimage.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.P.Internal.Preimage + +module +public import Complexitylib.Classes.P.Internal.Preimage /-! # Closure of P under FP preimages @@ -13,6 +15,9 @@ import Complexitylib.Classes.P.Internal.Preimage - `mem_P_preimage` — polynomial-time preprocessing preserves membership in `P` -/ + +@[expose] public section + namespace Complexity /-- If `f` is polynomial-time computable and `L` is polynomial-time diff --git a/Complexitylib/Classes/P/UnaryLength.lean b/Complexitylib/Classes/P/UnaryLength.lean index e281e913..3d321027 100644 --- a/Complexitylib/Classes/P/UnaryLength.lean +++ b/Complexitylib/Classes/P/UnaryLength.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.P.UnaryLength.Internal + +module +public import Complexitylib.Classes.P.UnaryLength.Internal /-! # Polynomial-time unary input length @@ -13,6 +15,9 @@ import Complexitylib.Classes.P.UnaryLength.Internal - `unaryLength_mem_FP` — `x ↦ 1^|x|` is polynomial-time computable -/ + +@[expose] public section + namespace Complexity /-- Writing one unary mark per input bit is a polynomial-time string diff --git a/Complexitylib/Classes/P/UnaryLength/Internal.lean b/Complexitylib/Classes/P/UnaryLength/Internal.lean index a78e3112..fec5ce63 100644 --- a/Complexitylib/Classes/P/UnaryLength/Internal.lean +++ b/Complexitylib/Classes/P/UnaryLength/Internal.lean @@ -3,13 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.P.Defs -import Complexitylib.Models.TuringMachine.Subroutines.UnaryLength + +module +public import Complexitylib.Classes.P.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.UnaryLength /-! # Polynomial-time unary input length — proof internals -/ + +@[expose] public section + namespace Complexity /-- Internal proof that materializing unary input length is in `FP`. -/ diff --git a/Complexitylib/Classes/PPoly.lean b/Complexitylib/Classes/PPoly.lean index d9eaf285..421d633a 100644 --- a/Complexitylib/Classes/PPoly.lean +++ b/Complexitylib/Classes/PPoly.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Defs -import Complexitylib.Circuits.Family + +module +public import Complexitylib.Classes.PPoly.Defs +public import Complexitylib.Circuits.Family /-! # P/poly and circuit-size classes @@ -14,6 +16,9 @@ the exact pointwise-polynomial definition of `PPoly` to the big-O power convention used elsewhere in the library. -/ + +@[expose] public section + namespace Complexity namespace BoolFunFamily diff --git a/Complexitylib/Classes/PPoly/Advice.lean b/Complexitylib/Classes/PPoly/Advice.lean index 834c57c7..d9d3c2ae 100644 --- a/Complexitylib/Classes/PPoly/Advice.lean +++ b/Complexitylib/Classes/PPoly/Advice.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Advice.Defs -import Complexitylib.Classes.PPoly.Advice.Internal -import Complexitylib.Classes.PPoly.Advice.Reverse + +module +public import Complexitylib.Classes.PPoly.Advice.Defs +public import Complexitylib.Classes.PPoly.Advice.Internal +public import Complexitylib.Classes.PPoly.Advice.Reverse /-! # Polynomial advice and nonuniform circuits @@ -27,6 +29,9 @@ evaluator. - `PAdvice_eq_PPoly`: the two nonuniform formulations coincide. -/ + +@[expose] public section + namespace Complexity /-- The advised input has the exact self-delimiting pairing length. -/ diff --git a/Complexitylib/Classes/PPoly/Advice/Defs.lean b/Complexitylib/Classes/PPoly/Advice/Defs.lean index 1ece65a2..d5456573 100644 --- a/Complexitylib/Classes/PPoly/Advice/Defs.lean +++ b/Complexitylib/Classes/PPoly/Advice/Defs.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Asymptotics -import Complexitylib.Classes.Pairing -import Complexitylib.Classes.PPoly.Defs -import Complexitylib.Circuits.Unrolling.Acceptance.Hardwiring + +module +public import Complexitylib.Asymptotics +public import Complexitylib.Circuits.Unrolling.Acceptance.Hardwiring +public import Complexitylib.Circuits.Family.Defs +public import Complexitylib.Encoding.Pairing /-! # Polynomial advice — definitions @@ -20,6 +22,9 @@ the deterministic choice prefix and the length-dependent advice prefix of a bounded acceptance circuit. -/ + +@[expose] public section + namespace Complexity /-- A binary advice string for every original input length. -/ diff --git a/Complexitylib/Classes/PPoly/Advice/Internal.lean b/Complexitylib/Classes/PPoly/Advice/Internal.lean index 6230c449..8f3ad348 100644 --- a/Complexitylib/Classes/PPoly/Advice/Internal.lean +++ b/Complexitylib/Classes/PPoly/Advice/Internal.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly -import Complexitylib.Classes.PPoly.Advice.Defs -import Complexitylib.Models.TuringMachine.Internal + +module +public import Complexitylib.Classes.PPoly +public import Complexitylib.Classes.PPoly.Advice.Defs +public import Mathlib.Tactic.SetNotationForOrder /-! # Polynomial advice — proof internals @@ -15,6 +17,9 @@ for advised-computation circuit families. Public statements are exposed by `Complexitylib.Classes.PPoly.Advice`. -/ + +@[expose] public section + namespace Complexity namespace Advice diff --git a/Complexitylib/Classes/PPoly/Advice/Reverse.lean b/Complexitylib/Classes/PPoly/Advice/Reverse.lean index a2db82f6..67cbca48 100644 --- a/Complexitylib/Classes/PPoly/Advice/Reverse.lean +++ b/Complexitylib/Classes/PPoly/Advice/Reverse.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Advice.Reverse.Defs -import Complexitylib.Classes.PPoly.Advice.Reverse.Internal + +module +public import Complexitylib.Classes.PPoly.Advice.Reverse.Defs +public import Complexitylib.Classes.PPoly.Advice.Reverse.Internal /-! # Nonuniform circuits as polynomial advice @@ -24,6 +26,9 @@ length-dependent advice for the verified circuit evaluator. - `PPoly_subset_PAdvice`: `P/poly` is contained in polynomial advice. -/ + +@[expose] public section + namespace Complexity namespace CircuitFamily diff --git a/Complexitylib/Classes/PPoly/Advice/Reverse/Defs.lean b/Complexitylib/Classes/PPoly/Advice/Reverse/Defs.lean index ddc56946..2d974724 100644 --- a/Complexitylib/Classes/PPoly/Advice/Reverse/Defs.lean +++ b/Complexitylib/Classes/PPoly/Advice/Reverse/Defs.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Advice.Defs -import Complexitylib.Circuits.Encoding.Machine.Core.Defs + +module +public import Complexitylib.Circuits.Encoding.Machine.Core.Defs /-! # Nonuniform circuits as polynomial advice — definitions @@ -14,6 +15,9 @@ circuit family's canonical member code is supplied as advice to the verified serialized-circuit evaluator. -/ + +@[expose] public section + namespace Complexity namespace CircuitFamily diff --git a/Complexitylib/Classes/PPoly/Advice/Reverse/Internal.lean b/Complexitylib/Classes/PPoly/Advice/Reverse/Internal.lean index 12ab0958..ed25b360 100644 --- a/Complexitylib/Classes/PPoly/Advice/Reverse/Internal.lean +++ b/Complexitylib/Classes/PPoly/Advice/Reverse/Internal.lean @@ -3,9 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly -import Complexitylib.Classes.PPoly.Advice.Reverse.Defs -import Complexitylib.Circuits.Encoding.Machine + +module +public import Complexitylib.Classes.PPoly +public import Complexitylib.Classes.PPoly.Advice.Reverse.Defs +public import Complexitylib.Circuits.Encoding.Machine +public import Complexitylib.Classes.PPoly.Advice.Defs +public import Mathlib.Tactic.SetNotationForOrder /-! # Nonuniform circuits as polynomial advice — proof internals @@ -16,6 +20,9 @@ correctness on that advice, and polynomial time measured in the original input length. -/ + +@[expose] public section + namespace Complexity namespace CircuitFamily diff --git a/Complexitylib/Classes/PPoly/Defs.lean b/Complexitylib/Classes/PPoly/Defs.lean index 35835299..ba7d896b 100644 --- a/Complexitylib/Classes/PPoly/Defs.lean +++ b/Complexitylib/Classes/PPoly/Defs.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Family.Defs -import Complexitylib.Circuits.AndOrNot.Defs -import Complexitylib.Models.TuringMachine + +module +public import Complexitylib.Circuits.Family.Defs +public import Complexitylib.Circuits.AndOrNot.Defs +public import Complexitylib.Models.TuringMachine /-! # Nonuniform circuit classes — definitions @@ -21,6 +23,9 @@ convention-dependent. Basis/size invariance must be proved rather than treated as definitional. -/ + +@[expose] public section + namespace Complexity namespace BoolFunFamily diff --git a/Complexitylib/Classes/PPoly/Uniform.lean b/Complexitylib/Classes/PPoly/Uniform.lean index 57cb38e7..7df3768e 100644 --- a/Complexitylib/Classes/PPoly/Uniform.lean +++ b/Complexitylib/Classes/PPoly/Uniform.lean @@ -3,9 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly -import Complexitylib.Classes.L -import Complexitylib.Circuits.Encoding.Family + +module +public import Complexitylib.Classes.L +public import Complexitylib.Circuits.Encoding.Family +public import Complexitylib.Classes.PPoly.Defs +public import Mathlib.Tactic.SetNotationForOrder /-! # Uniform P/poly @@ -36,6 +39,9 @@ The circuits-to-machines containment is exposed separately as `UniformPPoly_subset_P` in `Complexitylib.Classes.PPoly.Uniform.Containment`. -/ + +@[expose] public section + namespace Complexity /-- The unary encoding of `n` as `1ⁿ` (n `true` bits): the standard generator input diff --git a/Complexitylib/Classes/PPoly/Uniform/Containment.lean b/Complexitylib/Classes/PPoly/Uniform/Containment.lean index 8bef9437..6e3ad5bc 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Containment.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Containment.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Containment.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Containment.Internal /-! # Uniform polynomial-size circuits are in P @@ -18,6 +20,9 @@ polynomial time. A generic fanout combinator then constructs the serialized - `UniformPPoly_subset_P` — logspace-uniform polynomial-size circuits are in `P` -/ + +@[expose] public section + namespace Complexity /-- The language recognized by the verified serialized circuit-family diff --git a/Complexitylib/Classes/PPoly/Uniform/Containment/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Containment/Internal.lean index 8ddda5c0..ce61f574 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Containment/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Containment/Internal.lean @@ -3,16 +3,22 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.L.PolynomialTime -import Complexitylib.Classes.P.Preimage -import Complexitylib.Classes.PPoly.Uniform -import Complexitylib.Classes.PPoly.Uniform.Preprocessing -import Complexitylib.Circuits.Encoding.Machine + +module +public import Complexitylib.Classes.L.PolynomialTime +public import Complexitylib.Classes.P.Preimage +public import Complexitylib.Classes.PPoly.Uniform +public import Complexitylib.Classes.PPoly.Uniform.Preprocessing +public import Complexitylib.Circuits.Encoding.Machine +public import Complexitylib.Classes.PPoly /-! # Uniform polynomial-size circuits are in P — proof internals -/ + +@[expose] public section + namespace Complexity /-- Internal packaging of the verified serialized evaluator as a language in diff --git a/Complexitylib/Classes/PPoly/Uniform/Preprocessing.lean b/Complexitylib/Classes/PPoly/Uniform/Preprocessing.lean index 94ac07ad..69e2803e 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Preprocessing.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Preprocessing.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Preprocessing.Defs -import Complexitylib.Classes.PPoly.Uniform.Preprocessing.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Preprocessing.Defs +public import Complexitylib.Classes.PPoly.Uniform.Preprocessing.Internal /-! # Inputs for uniform circuit-family evaluation @@ -14,6 +16,9 @@ import Complexitylib.Classes.PPoly.Uniform.Preprocessing.Internal - `generatorEvalInput_mem_FP` — construct `pair (gen 1^|x|) x` in `FP` -/ + +@[expose] public section + namespace Complexity /-- A polynomial-time uniformity generator can be run on unary input length diff --git a/Complexitylib/Classes/PPoly/Uniform/Preprocessing/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Preprocessing/Defs.lean index f4ad4e0c..80982cfe 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Preprocessing/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Preprocessing/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Encoding.Pairing + +module +public import Complexitylib.Encoding.Pairing /-! # Inputs for uniform circuit-family evaluation @@ -13,6 +15,9 @@ and the circuit input. A uniformity generator consumes unary length instead. This module names the pure preprocessing map connecting those interfaces. -/ + +@[expose] public section + namespace Complexity /-- On input `x`, run the prospective uniformity generator on `1^|x|` and diff --git a/Complexitylib/Classes/PPoly/Uniform/Preprocessing/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Preprocessing/Internal.lean index 888aa47f..e3c6d040 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Preprocessing/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Preprocessing/Internal.lean @@ -3,16 +3,21 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.P.Composition -import Complexitylib.Classes.P.PairWithInput -import Complexitylib.Classes.P.UnaryLength -import Complexitylib.Classes.PPoly.Uniform -import Complexitylib.Classes.PPoly.Uniform.Preprocessing.Defs + +module +public import Complexitylib.Classes.P.Composition +public import Complexitylib.Classes.P.PairWithInput +public import Complexitylib.Classes.P.UnaryLength +public import Complexitylib.Classes.PPoly.Uniform +public import Complexitylib.Classes.PPoly.Uniform.Preprocessing.Defs /-! # Inputs for uniform circuit-family evaluation — proof internals -/ + +@[expose] public section + namespace Complexity /-- Internal polynomial-time construction of the serialized evaluator input. -/ diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling.lean index 256817b2..3346e9e1 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Internal /-! # Streamable deterministic unrolling families @@ -25,6 +27,9 @@ uniformity emitter. - `TM.directUnrollingCircuitFamily_size_bigO` — cubic-in-time size. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Containment.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Containment.lean index 4bb44b2d..c068a9f1 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Containment.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Containment.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Containment.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Containment.Internal /-! # Deterministic unrolling into uniform P/poly @@ -24,6 +26,9 @@ discharges them unconditionally. - `P_subset_UniformPPoly` and `UniformPPoly_eq_P` are the completed headline. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Containment/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Containment/Internal.lean index b8b97c72..6f70dd4f 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Containment/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Containment/Internal.lean @@ -3,11 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.P.NormalForm -import Complexitylib.Classes.PPoly.Uniform -import Complexitylib.Classes.PPoly.Uniform.Containment -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Tableau -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Padded + +module +public import Complexitylib.Classes.P.NormalForm +public import Complexitylib.Classes.PPoly.Uniform +public import Complexitylib.Classes.PPoly.Uniform.Containment +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Tableau +public import Complexitylib.Classes.PPoly.Uniform.Unrolling /-! # Deterministic unrolling into uniform P/poly -- proof internals @@ -17,6 +19,9 @@ conditional `FL` seams and then through the verified canonical padded serializer, yielding the unconditional machines-to-circuits containment. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Defs.lean index 4f330a56..e75756b3 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Family -import Complexitylib.Circuits.Unrolling.Acceptance + +module +public import Complexitylib.Circuits.Unrolling.Acceptance +public import Complexitylib.Circuits.Family.Defs /-! # Streamable deterministic unrolling families — definitions @@ -21,6 +23,9 @@ typed circuit is reconstructed directly from `acceptanceRawCircuit`, so erasing it recovers exactly the raw list that a streaming generator will emit. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Finalization.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Finalization.lean index aab252b6..28bb42d9 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Finalization.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Finalization.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Finalization.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Finalization.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Finalization.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Finalization.Internal /-! # Direct-unrolling finalization generator @@ -15,6 +17,9 @@ binary `available` counter and the precomputed closed frontier, so the routine uses logarithmic-width work values and performs no preliminary counting pass. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Finalization/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Finalization/Defs.lean index 8e5ab02d..8922e282 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Finalization/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Finalization/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Program.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Finalization.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Program.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Finalization.Defs /-! # Direct-unrolling finalization generator -- definitions @@ -15,6 +17,9 @@ wire. The binary padding driver uses `available` itself as its counter, so no gate-counting pass or unary work fuel is needed. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Finalization/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Finalization/Internal.lean index 516033aa..3f58f1d4 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Finalization/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Finalization/Internal.lean @@ -3,16 +3,21 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Finalization.Defs -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.SpaceBounds + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Finalization.Defs +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.SpaceBounds.Internal /-! # Direct-unrolling finalization generator -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Initialization.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Initialization.lean index 83c8ede6..86413d57 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Initialization.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Initialization.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Initialization.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Initialization.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Initialization.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Initialization.Internal /-! # Verified direct-unrolling initialization generator @@ -14,6 +16,9 @@ effects, exact raw-gate emission, and the positive-input entry contract for the direct initialization phase. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Initialization/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Initialization/Defs.lean index d895cbd2..5024a55b 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Initialization/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Initialization/Defs.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Program.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Program.Defs /-! # Direct-unrolling initialization generator -- definitions @@ -15,6 +16,9 @@ definition time; input-dependent head and cell ranges use canonical binary loops over natural counters. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Initialization/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Initialization/Internal.lean index a5c3d78a..9cb972f4 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Initialization/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Initialization/Internal.lean @@ -3,19 +3,25 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Initialization.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Bounds -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.InputLength -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.SpaceBounds + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Initialization.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Bounds +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.SpaceBounds +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization.Defs +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.InputLength.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryLength /-! # Direct-unrolling initialization generator -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling @@ -867,7 +873,8 @@ private theorem repeatRoutine_emitted_eq_indexedGateBlocks ih _ (hupdate values (values Work.available + step) hinvariant)] simp [indexedGateBlocks, List.flatMap_append] -private def tapeInvariant (T : ℕ) (values : BinaryValues WorkCount) : Prop := +/-- Register invariant maintained while emitting one tape's initialization gates. -/ +def tapeInvariant (T : ℕ) (values : BinaryValues WorkCount) : Prop := values Work.reference₀ = 0 ∧ values Work.loop₀ = 0 ∧ values Work.limit₀ = T + 1 ∧ values Work.horizon = T diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Offset.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Offset.lean index 8fac7d17..a1315354 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Offset.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Offset.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset.Internal /-! # Dynamic recent-wire offsets @@ -13,6 +15,9 @@ Proof-carrying helpers for subtracting a run-time wire offset and emitting a raw gate with one dynamic and one fixed recent-wire reference. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Offset/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Offset/Defs.lean index 8dfec8b6..92b78c65 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Offset/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Offset/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive.Defs /-! # Dynamic recent-wire offsets -- definitions @@ -17,6 +19,9 @@ scratch, reference, and emission registers. They make preservation claims about the dynamic offset and loop counter part of the auditable interface. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Offset/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Offset/Internal.lean index 7b4cb090..bd47d26d 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Offset/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Offset/Internal.lean @@ -3,15 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.SpaceBounds + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control /-! # Dynamic recent-wire offsets -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/PolynomialOffset.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/PolynomialOffset.lean index a46c5d71..b9c1c61e 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/PolynomialOffset.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/PolynomialOffset.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.PolynomialOffset.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.PolynomialOffset.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.PolynomialOffset.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.PolynomialOffset.Internal /-! # Polynomial recent-wire offsets @@ -13,6 +15,9 @@ Proof-carrying evaluation and raw-gate emission for recent-wire offsets that are fixed polynomials in the run-time tableau horizon. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/PolynomialOffset/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/PolynomialOffset/Defs.lean index 2a9536a7..78b89b24 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/PolynomialOffset/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/PolynomialOffset/Defs.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Polynomial.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset.Defs /-! # Polynomial recent-wire offsets -- definitions @@ -15,6 +16,9 @@ evaluate that polynomial into one scratch value, use the dynamic-offset gate emitter, and restore every owned register. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/PolynomialOffset/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/PolynomialOffset/Internal.lean index 6c7f8f74..a2011e08 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/PolynomialOffset/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/PolynomialOffset/Internal.lean @@ -3,13 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.PolynomialOffset.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.PolynomialOffset.Defs /-! # Polynomial recent-wire offsets -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Primitive.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Primitive.lean index fe63de17..4be392d7 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Primitive.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Primitive.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive.Internal /-! # Direct-unrolling generator primitives @@ -13,6 +15,9 @@ Executable fixed-work helpers for recent-wire raw gates and numeric state, head, and cell configuration-wire references. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Primitive/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Primitive/Defs.lean index 23d8f327..481cbcfd 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Primitive/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Primitive/Defs.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Program.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Case.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Program.Defs /-! # Direct-unrolling generator primitives -- definitions @@ -23,6 +24,9 @@ preserved. All framed copy, addition, multiplication, and emission counters are restored by their underlying leaves. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Primitive/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Primitive/Internal.lean index b19dfc2d..cc3bade7 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Primitive/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Primitive/Internal.lean @@ -3,15 +3,23 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive.Defs -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.SpaceBounds + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive.Defs +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.SpaceBounds +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Case.Defs +public import Mathlib.Tactic.ENatToNat +public import Mathlib.Tactic.ReduceModChar /-! # Direct-unrolling generator primitives -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Program.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Program.lean index 18003001..69fadee4 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Program.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Program.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Program.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Program.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Program.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Program.Internal /-! # Direct-unrolling generator program @@ -14,6 +16,9 @@ prefix of the direct-unrolling generator. A later module supplies the positive tableau body and discharges its value-level entry condition. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Program/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Program/Defs.lean index 48b243cf..78219483 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Program/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Program/Defs.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Bounds.Defs -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic.Defs -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control.Defs -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Bounds.Defs +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic.Defs +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control.Defs +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List.Defs /-! # Direct-unrolling generator program -- definitions @@ -18,6 +20,9 @@ hardwired two-bit word; the positive tableau body remains a compositional `BinaryRoutine` parameter at this layer. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Program/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Program/Internal.lean index 9a948902..302ed9f2 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Program/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Program/Internal.lean @@ -3,17 +3,25 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Program.Defs -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.InputLength -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.SpaceBounds + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Program.Defs +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.SpaceBounds +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.InputLength.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryLength +public import Mathlib.Tactic.ENatToNat +public import Mathlib.Tactic.ReduceModChar /-! # Direct-unrolling generator program -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Tableau.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Tableau.lean index 2414bcc4..f6b24262 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Tableau.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Tableau.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Tableau.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Tableau.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Tableau.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Tableau.Internal /-! # Verified direct-tableau generator @@ -15,6 +17,9 @@ exactly the family's tagged circuit code (including the separate zero-length member), and has a verified logarithmic all-prefix auxiliary-space bound. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Tableau/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Tableau/Defs.lean index 17c8cae3..accb0b42 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Tableau/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Tableau/Defs.lean @@ -3,10 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Finalization.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Initialization.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Program.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Finalization.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Defs /-! # Complete direct-unrolling generator -- definitions @@ -18,6 +18,9 @@ body with `program` also handles the separately tagged length-zero family member. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Tableau/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Tableau/Internal.lean index ef2705d6..bc2d50ca 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Tableau/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Tableau/Internal.lean @@ -3,16 +3,15 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Finalization -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Initialization -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Program -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Tableau.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Padded -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Finalization -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Stream -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.InputLength -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.SpaceBounds + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Finalization +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Program +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Tableau.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Padded +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Finalization +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.InputLength /-! # Complete direct-unrolling generator -- proof internals @@ -22,6 +21,9 @@ keeps the step scratch convention reusable, preserves the horizon, and advances the dedicated layer counter exactly once per emitted packed step. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling @@ -297,7 +299,8 @@ private theorem stepLoopValues_numeric_invariant (tm : TM k) refine ⟨hbasic.1, hbasic.2.1, ?_, hnumeric⟩ simpa [hloop] using hbasic.2.2 -private noncomputable def stepLoopIndexPolynomial +/-- Polynomial space envelope for indexing one tableau-step iteration. -/ +noncomputable def stepLoopIndexPolynomial (tm : NTM k) : Polynomial ℕ := Polynomial.C (Fintype.card tm.Q) + Polynomial.C (k + 2) * (Polynomial.X + Polynomial.C 2) + @@ -307,7 +310,8 @@ private noncomputable def stepLoopIndexPolynomial (Polynomial.X + Polynomial.C 2) + Polynomial.C (2 * (k + 2) + 8) -private noncomputable def stepLoopEvaluatorPolynomial +/-- Polynomial space envelope for evaluating one tableau-step iteration. -/ +noncomputable def stepLoopEvaluatorPolynomial (tm : NTM k) : Polynomial ℕ := TM.binaryPolynomialSpaceWidthPolynomial predecessorHeadSchedulePolynomial + @@ -331,7 +335,8 @@ private noncomputable def stepLoopEvaluatorPolynomial (writtenNextFormulaPolynomial tm tape symbol)) + TM.binaryPolynomialSpaceWidthPolynomial (Polynomial.C 1) -private noncomputable def stepLoopEndPolynomial +/-- Polynomial endpoint bound after the tableau-step loop. -/ +noncomputable def stepLoopEndPolynomial (tm : TM k) (q : Polynomial ℕ) : Polynomial ℕ := let horizon := TM.directSerializerHorizonPolynomial q Polynomial.X + @@ -341,7 +346,8 @@ private noncomputable def stepLoopEndPolynomial (Polynomial.C (stepSizeCoeff tm.toNTM) * (horizon + Polynomial.C 2) ^ 2) -private noncomputable def stepLoopWidthPolynomial +/-- Polynomial work-width envelope for the complete tableau-step loop. -/ +noncomputable def stepLoopWidthPolynomial (tm : TM k) (q : Polynomial ℕ) : Polynomial ℕ := let horizon := TM.directSerializerHorizonPolynomial q let endpoint := stepLoopEndPolynomial tm q diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Case.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Case.lean index 32d684d9..89b9ba1d 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Case.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Case.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Case.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Case.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Case.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Case.Internal /-! # Direct-unrolling transition-case generator @@ -13,6 +15,9 @@ Exact contracts for the forward stream of a fixed transition case, together with soundness of the complete case-formula emitter. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Case/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Case/Defs.lean index b053883d..c8bf3813 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Case/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Case/Defs.lean @@ -3,10 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Initialization.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Read.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Case.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Initialization.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Read.Defs /-! # Direct-unrolling transition-case generator -- definitions @@ -19,6 +20,9 @@ read-formula size, then by the final one-gate state member. No formula stack is materialized on a work tape. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Case/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Case/Internal.lean index c550e1fd..1facd31f 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Case/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Case/Internal.lean @@ -3,18 +3,21 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Initialization -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Case.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Read -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Case -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Initialization +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Case.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Read +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization /-! # Direct-unrolling transition-case generator -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling @@ -159,7 +162,8 @@ private theorem emitCopyGate_reference₀_requires refine ⟨⟨by decide, by decide, by decide, by decide, by decide⟩, ?_⟩ simpa [Work.emitCounter] using hemit -private def caseReadStartValues (values : BinaryValues WorkCount) +/-- Register state used to begin reading one transition case. -/ +def caseReadStartValues (values : BinaryValues WorkCount) (tapeIndex symbolIndex : ℕ) : BinaryValues WorkCount := Function.update (Function.update values Work.tapeIndex tapeIndex) diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Effect.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Effect.lean index f5c4e80b..ec8cbeaa 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Effect.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Effect.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Effect.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Effect.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Effect.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Effect.Internal /-! # Direct-unrolling transition-effect generator @@ -13,6 +15,9 @@ Exact contracts for the generated disjunction over a machine's finite transition table. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Effect/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Effect/Defs.lean index c5dc19db..16129d76 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Effect/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Effect/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Case.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Effect.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Case.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Effect.Defs /-! # Direct-unrolling transition-effect generator -- definitions @@ -15,6 +17,9 @@ one false gate. The suffix traverses the hardwired case table in reverse and rolls one output reference backward by each intervening case size. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Effect/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Effect/Internal.lean index 5fc15d82..09481faa 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Effect/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Effect/Internal.lean @@ -3,17 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Case -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Read -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Effect.Defs -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Case +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Effect.Defs /-! # Direct-unrolling transition-effect generator -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling @@ -24,7 +25,7 @@ namespace DirectGenerator /-- Scratch invariant while a rolling effect-member output reference moves backward through the variable-width case stream. -/ -private structure EffectConnectorClean +structure EffectConnectorClean (values : BinaryValues WorkCount) : Prop where reference₁ : values Work.reference₁ = 0 loop₃ : values Work.loop₃ = 0 diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/MovedHead.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/MovedHead.lean index b83168b2..325f588a 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/MovedHead.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/MovedHead.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.MovedHead.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.MovedHead.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.MovedHead.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.MovedHead.Internal /-! # Verified direct moved-head formula generation @@ -14,6 +16,9 @@ with its clean entry domain, restored work-vector effect, and exact encoded numeric schedule. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/MovedHead/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/MovedHead/Defs.lean index 0b13bbf0..25ee1df5 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/MovedHead/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/MovedHead/Defs.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.PolynomialOffset.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Effect.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Predecessor.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.MovedHead.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.PolynomialOffset.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Effect.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Predecessor.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Polynomial.Defs /-! # Direct-unrolling moved-head generator -- definitions @@ -18,6 +20,9 @@ unused enclosing register, so the final three-way disjunction needs no dynamic size recomputation. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/MovedHead/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/MovedHead/Internal.lean index 38390cce..d5af1b54 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/MovedHead/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/MovedHead/Internal.lean @@ -3,18 +3,21 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.PolynomialOffset -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Effect -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.MovedHead.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Predecessor -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.MovedHead -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Polynomial -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.PolynomialOffset +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Effect +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.MovedHead.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Predecessor +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Polynomial /-! # Direct-unrolling moved-head generator -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling @@ -24,7 +27,7 @@ namespace Serializer namespace DirectGenerator /-- Numeric direction code used by the canonical moved-head schedule. -/ -private def movedHeadDirectionCode : Dir3 → ℕ +def movedHeadDirectionCode : Dir3 → ℕ | .left => 0 | .right => 1 | .stay => 2 @@ -32,7 +35,7 @@ private def movedHeadDirectionCode : Dir3 → ℕ /-- Scratch owned by the conjunction between an effect child and a predecessor-head child. The run-time target and tape selector are deliberately excluded because the predecessor routine preserves them. -/ -private structure MovedHeadConjunctionClean +structure MovedHeadConjunctionClean (values : BinaryValues WorkCount) : Prop where temporary₃ : values Work.temporary₃ = 0 polynomialScratch : values Work.polynomialScratch = 0 @@ -263,7 +266,8 @@ theorem saveMovedHeadMemberOutput_sound_internal (save : Fin WorkCount) : (saveMovedHeadMemberOutput save).Sound := prepareRecentReference_sound save 1 -private def movedHeadMemberResult (values : BinaryValues WorkCount) +/-- Register state after emitting and saving one moved-head disjunction member. -/ +def movedHeadMemberResult (values : BinaryValues WorkCount) (save : Fin WorkCount) (effectSize : ℕ) : BinaryValues WorkCount := Function.update (Function.update diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Next.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Next.lean index 1afe77e8..51f5a593 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Next.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Next.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Next.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Next.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Next.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Next.Internal /-! # Verified direct next-atom generation @@ -17,6 +19,9 @@ Input cells and writable marker cells share the same copy routine because their canonical raw schedules are literally identical. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Next/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Next/Defs.lean index 26ce4777..3bc22552 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Next/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Next/Defs.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.MovedHead.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.WrittenCell.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Next.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.MovedHead.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.WrittenCell.Defs /-! # Direct-unrolling next-atom generator -- definitions @@ -16,6 +17,9 @@ fixed child-size polynomial after child emission. Immutable input cells and writable marker cells use a direct old-cell copy. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Next/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Next/Internal.lean index e0218a71..95aebf2e 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Next/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Next/Internal.lean @@ -3,18 +3,21 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.PolynomialOffset -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Next.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Effect -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.MovedHead -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.WrittenCell -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Polynomial + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Next.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.MovedHead +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.WrittenCell +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.MovedHead +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.WrittenCell /-! # Direct-unrolling next-atom generator -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling @@ -23,7 +26,8 @@ namespace Serializer namespace DirectGenerator -private def advanceAvailableValues (values : BinaryValues WorkCount) +/-- Advances the generator's available-wire register by `amount`. -/ +def advanceAvailableValues (values : BinaryValues WorkCount) (amount : ℕ) : BinaryValues WorkCount := Function.update values Work.available (values Work.available + amount) diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/PackedCopy.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/PackedCopy.lean index a1e9b3f0..a741d6f8 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/PackedCopy.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/PackedCopy.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.PackedCopy.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.PackedCopy.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.PackedCopy.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.PackedCopy.Internal /-! # Delayed packed-formula copies @@ -13,6 +15,9 @@ An executable proof-carrying primitive that advances the rolling formula cursor and emits the corresponding packed-output copy gate. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/PackedCopy/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/PackedCopy/Defs.lean index 10f1f5cf..c14d0296 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/PackedCopy/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/PackedCopy/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.PolynomialOffset.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.PolynomialOffset.Defs /-! # Delayed packed-formula copies -- definitions @@ -18,6 +20,9 @@ That deliberately rules out empty formula blocks independently of the old cursor value. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/PackedCopy/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/PackedCopy/Internal.lean index 3c93220a..4b24564b 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/PackedCopy/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/PackedCopy/Internal.lean @@ -3,13 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.PolynomialOffset -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.PackedCopy.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.PolynomialOffset +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.PackedCopy.Defs /-! # Delayed packed-formula copies -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Predecessor.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Predecessor.lean index 25452871..0aad7fd9 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Predecessor.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Predecessor.lean @@ -3,8 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Predecessor.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Predecessor.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Predecessor.Defs +public import + Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Predecessor.Internal /-! # Verified direct predecessor-head formula generation @@ -15,6 +18,9 @@ schedule. Direction codes zero and one mean left and right; all other codes mean stay, matching `movedHeadPositionCode`. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Predecessor/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Predecessor/Defs.lean index 681feaef..1026aaa5 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Predecessor/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Predecessor/Defs.lean @@ -3,10 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Initialization.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.MovedHead.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Initialization.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset.Defs /-! # Direct predecessor-head formula generation -- definitions @@ -18,6 +18,9 @@ head-wire copies. The right-fold suffix uses a dynamic recent-wire offset offset one selects the preceding identity or connector. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Predecessor/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Predecessor/Internal.lean index 89c58906..a6f02a54 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Predecessor/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Predecessor/Internal.lean @@ -3,19 +3,22 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Initialization -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Predecessor.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Initialization +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Predecessor.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.MovedHead.Defs /-! # Direct predecessor-head formula generation -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Read.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Read.lean index 4044b928..74658741 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Read.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Read.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Read.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Read.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Read.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Read.Internal /-! # Direct-unrolling read-formula generator @@ -13,6 +15,9 @@ A stack-free proof-carrying routine that emits the exact numeric gate schedule for reading one symbol from a bounded encoded configuration. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Read/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Read/Defs.lean index d567a1b8..9a4e30d1 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Read/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Read/Defs.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive.Defs /-! # Direct-unrolling read-formula generator -- definitions @@ -20,6 +21,9 @@ temporaries zero through two are owned as scratch. In particular, `temporary₃` remains available to an enclosing transition generator. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Read/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Read/Internal.lean index 5b9ef294..b86797d8 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Read/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Read/Internal.lean @@ -3,18 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Read.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List -import Mathlib.Data.Nat.Pairing + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Read.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control /-! # Direct-unrolling read-formula generator -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step.lean index bbe8739b..d598a432 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step.lean @@ -3,8 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Step /-! # Verified direct packed-step generation @@ -15,6 +18,9 @@ register effect, restored scratch convention, and byte-for-byte emitted packed transition fragment. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Defs.lean index 76565cda..0db1f11e 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Defs.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Next.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.PackedCopy.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Step.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Next.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.PackedCopy.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Step.Defs /-! # Direct-unrolling packed-step generator -- definitions @@ -18,6 +20,9 @@ is reused, after its header has already been emitted, as the rolling source cursor. Neither requires a new work tape. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal.lean index cbef5ff4..1e5049d0 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal.lean @@ -3,24 +3,28 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.PackedCopy -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Next -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Effect -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Emitted -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Packed -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Requires -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Sound -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Space -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Top -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Step -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Defs +public import + Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Effect +public import + Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Emitted +public import + Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Packed +public import + Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Requires +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Sound +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Space +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Top /-! # Direct-unrolling packed-step generator -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Effect.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Effect.lean index 267536f8..07529269 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Effect.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Effect.lean @@ -3,12 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Next -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.PackedCopy -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Defs -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Next +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.PackedCopy +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Defs /-! # Exact effects of the direct packed-step generator @@ -19,6 +18,9 @@ they do not assume that the saved formula cursor or either gate register is initially zero. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Emitted.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Emitted.lean index 408eded2..3d1b0364 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Emitted.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Emitted.lean @@ -3,7 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Effect + +module +public import + Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Effect /-! # Exact output of the direct packed-step generator @@ -13,6 +16,9 @@ schedule byte for byte. The intermediate results identify each nested enumeration with its contiguous slice of the global configuration-atom order. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling @@ -750,7 +756,8 @@ private theorem stepFormulaBlockSpecialized_internal_writtenCell (tm : NTM k) nextWritableCellAtomKind, nextAtomTapeIndex, nextAtomPosition, nextAtomSymbolIndex, nextAtomEffectSelectedAt, hpositive.ne'] -private def stepCellStart (tm : NTM k) (T : ℕ) (tape : TapeSlot k) +/-- First flattened configuration index for the four symbols at a tape cell. -/ +def stepCellStart (tm : NTM k) (T : ℕ) (tape : TapeSlot k) (position : ℕ) : ℕ := Fintype.card tm.Q + (k + 2) * (T + 1) + (tape.index.val * (T + 2) + position) * 4 diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/FormulaSpace.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/FormulaSpace.lean index ddeb455c..6143a3e0 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/FormulaSpace.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/FormulaSpace.lean @@ -3,7 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Space.Common + +module +public import + Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Space.Common /-! # Formula-phase space bound for one direct transition step @@ -12,6 +15,9 @@ This module follows the exact state, head, and cell formula trajectories and certifies every nested routine against the shared packed-step width envelope. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Packed.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Packed.lean index 46dd23f7..d7269c80 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Packed.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Packed.lean @@ -3,7 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Emitted + +module +public import + Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Emitted /-! # Exact packed-copy output of the direct step generator @@ -13,6 +16,9 @@ numeric packed-copy suffix. Formula emission and the outer deterministic step are intentionally handled by separate modules. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Requires.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Requires.lean index 6cfda40e..e9c8412b 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Requires.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Requires.lean @@ -3,11 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Next -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.PackedCopy -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Defs -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Next +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.PackedCopy +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Defs /-! # Packed-step generator domains @@ -16,6 +16,9 @@ Reachable-position loop invariants and exact scratch-domain proofs for the formula and delayed-copy phases of one packed transition step. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Sound.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Sound.lean index 820aec0e..a75821a5 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Sound.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Sound.lean @@ -3,12 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Next -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.PackedCopy -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Defs -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Next +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.PackedCopy +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Defs /-! # Packed-step generator soundness @@ -17,6 +16,9 @@ Soundness proofs for the compositional formula and delayed-copy routines used by one direct-unrolling transition step. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Space.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Space.lean index bfc76336..37ff9c73 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Space.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Space.lean @@ -3,8 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.FormulaSpace -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Space.Packed + +module +public import + Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.FormulaSpace +public import + Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Space.Packed /-! # Whole-step space bound for direct transition generation @@ -13,6 +17,9 @@ This module composes the formula and delayed-copy certificates through the seven exact register phases of `emitStep`. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Space/Common.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Space/Common.lean index 99abd723..36b20600 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Space/Common.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Space/Common.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Emitted -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.SpaceBounds + +module +public import + Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Emitted /-! # Common packed-step width helpers @@ -13,6 +15,9 @@ This module supplies the shared list-trajectory and position-limit certificates used to assemble the auxiliary-space proof for direct packed-step generation. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Space/Packed.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Space/Packed.lean index 9d969196..fbed2149 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Space/Packed.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Space/Packed.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Emitted -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Space.Common + +module +public import + Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Space.Common /-! # Packed-copy space bound for one direct transition step @@ -15,6 +17,9 @@ state, head, and cell regions and bounds every loop prefix by the shared step width envelope. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Top.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Top.lean index b7a41916..bc0f15ab 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Top.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/Step/Internal/Top.lean @@ -3,7 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Packed + +module +public import + Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Step.Internal.Packed /-! # Whole-step direct-generator contracts @@ -12,6 +15,9 @@ This file composes the exact per-region contracts into byte-for-byte contracts for the complete formula phase, packed-copy phase, and deterministic step. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/WrittenCell.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/WrittenCell.lean index 807f2270..cc27a26d 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/WrittenCell.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/WrittenCell.lean @@ -3,8 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.WrittenCell.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.WrittenCell.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.WrittenCell.Defs +public import + Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.WrittenCell.Internal /-! # Verified direct written-cell formula generation @@ -14,6 +17,9 @@ its clean entry domain, restored work-vector effect, and exact encoded numeric schedule. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/WrittenCell/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/WrittenCell/Defs.lean index 8a81c738..f8b08150 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/WrittenCell/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/WrittenCell/Defs.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Effect.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.WrittenCell.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Effect.Defs /-! # Direct-unrolling written-cell generator -- definitions @@ -16,6 +17,9 @@ references. The final represented cell has no head wire, detected by a bounded subtraction from `horizon + 1` rather than a general equality routine. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/WrittenCell/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/WrittenCell/Internal.lean index 7ffe43ba..a9ade416 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/WrittenCell/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Generator/Transition/WrittenCell/Internal.lean @@ -3,15 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Initialization -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Offset -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Primitive -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Effect -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Read -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.WrittenCell.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.WrittenCell -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.Effect +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Generator.Transition.WrittenCell.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.WrittenCell.Defs /-! # Direct-unrolling written-cell generator -- proof internals @@ -21,6 +17,9 @@ on both sides of a written-cell formula. The enclosing effect-formula proof is intentionally deferred until that generator's public contracts are available. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Internal.lean index 2e09e3d6..b593f240 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Internal.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Defs -import Complexitylib.Classes.PPoly.Unrolling -import Complexitylib.Models.TuringMachine.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Defs +public import Complexitylib.Classes.PPoly.Unrolling +public import Complexitylib.Circuits.Encoding.Family /-! # Streamable deterministic unrolling families — proof internals @@ -15,6 +17,9 @@ semantics and cubic size bound as the fixed-choice family, while exposing an exact positive-length serialization theorem. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Padded.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Padded.lean index 1d27f1b5..c51c78ea 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Padded.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Padded.lean @@ -3,8 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Padded.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Padded.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Padded.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Padded.Internal +public import Complexitylib.Circuits.Encoding.Family +public import Complexitylib.Classes.PPoly.Unrolling /-! # Regularly padded deterministic unrolling families @@ -24,6 +28,9 @@ library's explicit answer-bit convention. - `TM.paddedDirectUnrollingCircuitFamily_size_bigO` retains the cubic size bound. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Padded/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Padded/Defs.lean index c99c9c7c..9fbf3300 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Padded/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Padded/Defs.lean @@ -3,7 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling + +module +public import Complexitylib.Circuits.Nondeterminism +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Defs /-! # Regularly padded deterministic unrolling families -- definitions @@ -15,6 +18,9 @@ closed expression of the time horizon while retaining the original acceptance wire. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Padded/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Padded/Internal.lean index e9a89612..24a2b910 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Padded/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Padded/Internal.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Padded.Defs -import Complexitylib.Circuits.Encoding.Fragment + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Padded.Defs /-! # Regularly padded deterministic unrolling families -- proof internals @@ -14,6 +15,9 @@ cubic budget, constant gates remain topological at every later frontier, and the terminal copy reads the original acceptance wire through the dead padding. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer.lean index 55724f09..68965615 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Internal /-! # Numeric schedules for streaming tableau serialization @@ -34,6 +36,9 @@ They isolate the exact arithmetic that the later finite controller must realize. numeric copy schedule. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Bounds.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Bounds.lean index b7d010b9..59db93a4 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Bounds.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Bounds.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Bounds.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Bounds.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Bounds.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Bounds.Internal /-! # Polynomial counters for direct tableau serialization @@ -23,6 +25,9 @@ padding frontier without first counting the emitted raw gates. - `DecidesInTime.directSerializerHorizon` safely enlarges a time witness. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Bounds/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Bounds/Defs.lean index 7622e739..6b4599d6 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Bounds/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Bounds/Defs.lean @@ -3,8 +3,25 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Padded.Defs -import Mathlib.Algebra.Polynomial.Eval.Defs + +module +public import Complexitylib.Circuits.Unrolling.Acceptance.Defs +public import Mathlib.Analysis.SpecialFunctions.Pow.NNReal +public import Mathlib.Tactic.Measurability.Init +public import Mathlib.Tactic.NormNum.BigOperators +public import Mathlib.Tactic.NormNum.Irrational +public import Mathlib.Tactic.NormNum.IsCoprime +public import Mathlib.Tactic.NormNum.IsSquare +public import Mathlib.Tactic.NormNum.LegendreSymbol +public import Mathlib.Tactic.NormNum.ModEq +public import Mathlib.Tactic.NormNum.NatFactorial +public import Mathlib.Tactic.NormNum.NatFib +public import Mathlib.Tactic.NormNum.NatLog +public import Mathlib.Tactic.NormNum.NatSqrt +public import Mathlib.Tactic.NormNum.Ordinal +public import Mathlib.Tactic.NormNum.Parity +public import Mathlib.Tactic.NormNum.Prime +public import Mathlib.Tactic.NormNum.RealSqrt /-! # Polynomial counters for direct tableau serialization -- definitions @@ -16,6 +33,9 @@ the positive member's gate-count header. Keeping these values as polynomials lets the binary polynomial subroutine compute them in logarithmic workspace. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Bounds/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Bounds/Internal.lean index 809f1980..f8faa409 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Bounds/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Bounds/Internal.lean @@ -3,12 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Bounds.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Bounds.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Padded.Defs /-! # Polynomial counters for direct tableau serialization -- proof internals -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Defs.lean index 2c32dcd2..756ed596 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Formula.Stream.Defs + +module +public import Complexitylib.Circuits.Encoding.Fragment.Defs /-! # Numeric schedules for streaming tableau serialization @@ -19,6 +21,9 @@ members in reverse order. The batch-copy schedule counts source formulas forward and reconstructs each delayed output reference from a prefix-size sum. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Finalization.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Finalization.lean index 4e9103cd..154b3580 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Finalization.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Finalization.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Finalization.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Finalization.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Finalization.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Finalization.Internal /-! # Numeric finalization schedule for direct tableau serialization @@ -23,6 +25,9 @@ specifies the raw gate stream without run-time configuration atoms or formulas. list decomposition. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Finalization/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Finalization/Defs.lean index 6d6415eb..02133e1a 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Finalization/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Finalization/Defs.lean @@ -3,9 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Padded.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Stream.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Stream.Defs /-! # Numeric finalization schedule for direct tableau serialization @@ -17,6 +17,9 @@ fixed compile-time parameters in the bridge theorems; no run-time schedule value contains a configuration atom or formula tree. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Finalization/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Finalization/Internal.lean index bfa7d818..7d9c7b86 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Finalization/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Finalization/Internal.lean @@ -3,15 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Finalization.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Stream -import Complexitylib.Circuits.Unrolling + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Finalization.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Stream +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Padded.Defs /-! # Numeric direct-tableau finalization -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Initialization.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Initialization.lean index 32ab21da..5a7fa178 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Initialization.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Initialization.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization.Internal /-! # Numeric initialization schedule for direct tableau serialization @@ -25,6 +27,9 @@ does not yet construct a Turing machine that emits those gates. existing positive-input initialization fragment. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Initialization/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Initialization/Defs.lean index 891f9529..d330f925 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Initialization/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Initialization/Defs.lean @@ -3,8 +3,26 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Defs + +module +public import Complexitylib.Circuits.Encoding.Fragment.Defs +public import Complexitylib.Models.TuringMachine +public import Mathlib.Analysis.SpecialFunctions.Pow.NNReal +public import Mathlib.Tactic.Measurability.Init +public import Mathlib.Tactic.NormNum.BigOperators +public import Mathlib.Tactic.NormNum.Irrational +public import Mathlib.Tactic.NormNum.IsCoprime +public import Mathlib.Tactic.NormNum.IsSquare +public import Mathlib.Tactic.NormNum.LegendreSymbol +public import Mathlib.Tactic.NormNum.ModEq +public import Mathlib.Tactic.NormNum.NatFactorial +public import Mathlib.Tactic.NormNum.NatFib +public import Mathlib.Tactic.NormNum.NatLog +public import Mathlib.Tactic.NormNum.NatSqrt +public import Mathlib.Tactic.NormNum.Ordinal +public import Mathlib.Tactic.NormNum.Parity +public import Mathlib.Tactic.NormNum.Prime +public import Mathlib.Tactic.NormNum.RealSqrt /-! # Numeric initialization schedule for direct tableau serialization @@ -19,6 +37,9 @@ and the blank tail. Work and output tapes share one blank-tape schedule. No run-time schedule value stores a configuration atom or formula tree. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Initialization/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Initialization/Internal.lean index 6645520e..7c4afcec 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Initialization/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Initialization/Internal.lean @@ -3,14 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization.Defs -import Complexitylib.Circuits.Unrolling + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization.Defs +public import Complexitylib.Circuits.Unrolling +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Defs /-! # Numeric initialization schedule -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Internal.lean index b81361cd..f0e4991f 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Internal.lean @@ -3,13 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Defs -import Complexitylib.Circuits.Encoding.Formula.Stream + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Defs +public import Complexitylib.Circuits.Encoding.Formula.Stream /-! # Numeric schedules for streaming tableau serialization -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition.lean index 36f6b6e7..acfc507a 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Internal /-! # Numeric transition-formula schedules @@ -23,6 +25,9 @@ proof adapters. - The length and `getElem` theorems expose their exact numeric phases. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Atomic.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Atomic.lean index 8a02bf8d..8929fb2d 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Atomic.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Atomic.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Atomic.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Atomic.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Atomic.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Atomic.Internal /-! # Numeric schedules for atomic transition formulas @@ -13,6 +15,9 @@ This module exposes the one-gate numeric head-at-cell schedule and the fixed postorder halted-or wrapper used by state, head, and writable-cell successors. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Atomic/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Atomic/Defs.lean index 0ad8ba92..2d227f96 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Atomic/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Atomic/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Defs /-! # Numeric schedules for atomic transition formulas -- definitions @@ -14,6 +16,9 @@ indices, while `haltedOrSchedule` gives the fixed postorder wrapper around already scheduled old-value and next-value fragments. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Atomic/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Atomic/Internal.lean index 2f011178..d1aeec92 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Atomic/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Atomic/Internal.lean @@ -3,14 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Atomic.Defs -import Complexitylib.Circuits.Encoding.Formula + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Atomic.Defs +public import Complexitylib.Circuits.Encoding.Formula +public import Complexitylib.Circuits.Unrolling.Transition.Defs /-! # Numeric schedules for atomic transition formulas -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Case.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Case.lean index 9d6e8056..039e9374 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Case.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Case.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Case.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Case.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Case.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Case.Internal /-! # Numeric transition-case schedules @@ -21,6 +23,9 @@ only in the final compilation adapter. - `compileRaw_caseFormula_eq_schedule` identifies the complete raw stream. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Case/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Case/Defs.lean index 1740fd0a..e3ca490b 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Case/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Case/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Defs /-! # Numeric schedules for transition-case formulas @@ -16,6 +18,9 @@ No formula tree, configuration atom, tape slot, symbol, or bounded position is stored by the schedule. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Case/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Case/Internal.lean index 36b27354..26b2f5f8 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Case/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Case/Internal.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Case.Defs -import Complexitylib.Circuits.Unrolling.Transition + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Case.Defs +public import Complexitylib.Circuits.Encoding.Formula /-! # Numeric transition-case schedules -- proof internals @@ -15,6 +17,9 @@ as compile-time parameters. It erases them to numeric state, tape, and symbol indices before identifying the emitted stream with the definitions layer. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Defs.lean index b07bf4f8..fe801e38 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Defs.lean @@ -3,7 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Defs /-! # Numeric transition-formula schedules @@ -20,6 +23,9 @@ head-wire copy or false. Both streams finish with the existing numeric right-fold disjunction suffix. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Effect.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Effect.lean index 749bfb29..8cf89c5d 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Effect.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Effect.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Effect.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Effect.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Effect.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Effect.Internal /-! # Numeric schedules for transition-effect formulas @@ -23,6 +25,9 @@ the disjunction. - `compileRaw_effectFormula_eq_schedule` proves literal raw-list equality. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Effect/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Effect/Defs.lean index 215ca275..79909f03 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Effect/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Effect/Defs.lean @@ -3,7 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Case.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Case.Defs +public import Complexitylib.Circuits.Unrolling.Transition.Defs /-! # Numeric schedules for transition-effect formulas @@ -19,6 +22,9 @@ extractors. The streaming schedule itself carries no transition case, effect, formula tree, bounded index, or list traversal state. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Effect/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Effect/Internal.lean index 76c4abf7..62665a3b 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Effect/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Effect/Internal.lean @@ -3,14 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Case -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Effect.Defs -import Complexitylib.Circuits.Encoding.Formula + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Case +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Effect.Defs /-! # Numeric transition-effect schedules -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Internal.lean index ce3570e8..8960185a 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Internal.lean @@ -3,10 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization.Internal -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Defs -import Complexitylib.Circuits.Unrolling.Transition + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization.Internal +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Defs /-! # Numeric transition-formula schedules -- proof internals @@ -17,6 +18,9 @@ bounded positions, tape slots, and symbols appear only in the final adapter theorems. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/MovedHead.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/MovedHead.lean index e1ab44ce..441c8461 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/MovedHead.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/MovedHead.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.MovedHead.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.MovedHead.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.MovedHead.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.MovedHead.Internal /-! # Numeric moved-head schedules @@ -21,6 +23,9 @@ reverse disjunction connectors complete the stream. - `compileRaw_movedHeadFormula_eq_schedule` proves literal raw-list equality. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/MovedHead/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/MovedHead/Defs.lean index f195e86b..0e87158d 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/MovedHead/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/MovedHead/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Effect.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Effect.Defs /-! # Numeric schedules for moved-head formulas -- definitions @@ -18,6 +20,9 @@ tape slots, directions, bounded indices, formula trees, and list cursors occur only in the compile-time extractor or the proof adapter. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/MovedHead/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/MovedHead/Internal.lean index e647288f..c4154c40 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/MovedHead/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/MovedHead/Internal.lean @@ -3,14 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Effect -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.MovedHead.Defs -import Complexitylib.Circuits.Unrolling.Transition + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Effect +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.MovedHead.Defs /-! # Numeric moved-head schedules -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Next.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Next.lean index 244ebd15..755a4e32 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Next.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Next.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Next.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Next.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Next.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Next.Internal /-! # Numeric schedules for next-configuration atoms @@ -24,6 +26,9 @@ public transition schedule. common numeric count. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Next/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Next/Defs.lean index 85187e25..fa53b9a7 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Next/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Next/Defs.lean @@ -3,10 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Atomic.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Effect.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.MovedHead.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.WrittenCell.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.MovedHead.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.WrittenCell.Defs /-! # Numeric schedules for next-configuration atoms @@ -22,6 +22,9 @@ machine and `ConfigAtom` appear solely in compile-time extractors used by the literal proof adapter. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Next/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Next/Internal.lean index 105e8ea9..17c3c4f1 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Next/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Next/Internal.lean @@ -3,17 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Atomic -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Effect -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.MovedHead -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Next.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.WrittenCell -import Complexitylib.Circuits.Encoding.Formula + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.MovedHead +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Next.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.WrittenCell /-! # Numeric next-atom schedules -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Polynomial.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Polynomial.lean index 85c6a3e8..bfc93fdd 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Polynomial.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Polynomial.lean @@ -3,8 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Polynomial.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Polynomial.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Polynomial.Defs +public import + Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Polynomial.Internal /-! # Fixed transition-schedule size polynomials @@ -13,6 +16,9 @@ This module exposes literal evaluation theorems for the fixed polynomials that measure nested transition schedules as functions of the tableau horizon. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Polynomial/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Polynomial/Defs.lean index 15e6c2e7..3b83d70d 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Polynomial/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Polynomial/Defs.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Next.Defs -import Mathlib.Algebra.Polynomial.Eval.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Next.Defs /-! # Fixed transition-schedule size polynomials -- definitions @@ -16,6 +17,9 @@ with the verified binary polynomial evaluator instead of replaying a formula tree or counting emitted gates. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Polynomial/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Polynomial/Internal.lean index ace05a7b..4fde4ed0 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Polynomial/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Polynomial/Internal.lean @@ -3,13 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Polynomial.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Polynomial.Defs /-! # Fixed transition-schedule size polynomials -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Step.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Step.lean index c0e53fca..f2372e2f 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Step.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Step.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Step.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Step.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Step.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Step.Internal /-! # Numeric schedules for one packed transition step @@ -26,6 +28,9 @@ one packed-output copy per atom in that same order. public successor-configuration layout. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Step/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Step/Defs.lean index ba4a3543..ebac2407 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Step/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Step/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Next.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Next.Defs /-! # Numeric schedules for one packed transition step @@ -19,6 +21,9 @@ numeric atom fields, numeric transition-case fields, prefix sizes, and Boolean selection oracles. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Step/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Step/Internal.lean index 49d4413b..bc385cc5 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Step/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/Step/Internal.lean @@ -3,15 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Next -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Step.Defs -import Complexitylib.Circuits.Unrolling.Transition.Fragment + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Next +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Step.Defs /-! # Numeric packed-step schedules -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/WrittenCell.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/WrittenCell.lean index 37d40667..398790f6 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/WrittenCell.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/WrittenCell.lean @@ -3,8 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.WrittenCell.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.WrittenCell.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.WrittenCell.Defs +public import + Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.WrittenCell.Internal /-! # Numeric schedules for written-cell formulas @@ -21,6 +24,9 @@ six-gate suffix combines the selected write with the old cell value. - `compileRaw_writtenCellFormula_eq_schedule` proves literal raw-list equality. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/WrittenCell/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/WrittenCell/Defs.lean index 5cb1634a..a1ee27d8 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/WrittenCell/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/WrittenCell/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Atomic.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Effect.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Atomic.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Effect.Defs /-! # Numeric schedules for written-cell formulas @@ -20,6 +22,9 @@ compile-time selection oracle. No run-time schedule value contains a formula, bounded index, transition case, tape slot, symbol, or list cursor. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/WrittenCell/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/WrittenCell/Internal.lean index a3d80ee2..2e21b5c1 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/WrittenCell/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Serializer/Transition/WrittenCell/Internal.lean @@ -3,16 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Atomic -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Effect -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.WrittenCell.Defs -import Complexitylib.Circuits.Encoding.Formula + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Initialization +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Atomic +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.Effect +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Serializer.Transition.WrittenCell.Defs /-! # Numeric written-cell schedules -- proof internals -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Stream.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Stream.lean index e23c061d..bb6d3f90 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Stream.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Stream.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Stream.Defs -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Stream.Internal + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Stream.Defs +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Stream.Internal /-! # Streamable deterministic unrolling arithmetic @@ -30,6 +32,9 @@ that serializer reproduce the recursive `TraceBuild` arithmetic at run time. circuit is initialization, a flat canonical layer list, and acceptance. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Stream/Defs.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Stream/Defs.lean index 728b4118..0f48d456 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Stream/Defs.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Stream/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Defs + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Defs /-! # Streamable deterministic unrolling arithmetic — definitions @@ -18,6 +20,9 @@ The direct deterministic prefix build fixes the primary-wire layout used by no Turing-machine generator is defined here. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Stream/Internal.lean b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Stream/Internal.lean index 97ede67e..ae27498f 100644 --- a/Complexitylib/Classes/PPoly/Uniform/Unrolling/Stream/Internal.lean +++ b/Complexitylib/Classes/PPoly/Uniform/Unrolling/Stream/Internal.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Uniform.Unrolling.Stream.Defs -import Complexitylib.Circuits.Unrolling.Trace.Internal.Structure + +module +public import Complexitylib.Classes.PPoly.Uniform.Unrolling.Stream.Defs /-! # Streamable deterministic unrolling arithmetic — proof internals @@ -14,6 +15,9 @@ tree sizes, then solves the deterministic trace-prefix recurrences using the resulting constant packed-layer size. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/PPoly/Unrolling.lean b/Complexitylib/Classes/PPoly/Unrolling.lean index e9a171ab..c4a15d96 100644 --- a/Complexitylib/Classes/PPoly/Unrolling.lean +++ b/Complexitylib/Classes/PPoly/Unrolling.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Unrolling.Defs -import Complexitylib.Classes.PPoly.Unrolling.Internal + +module +public import Complexitylib.Classes.PPoly.Unrolling.Defs +public import Complexitylib.Classes.PPoly.Unrolling.Internal /-! # Deterministic time has nonuniform circuits @@ -23,6 +25,9 @@ and concludes `P ⊆ P/poly` directly from the unrolling construction. - `P_subset_PPoly`: deterministic polynomial time has polynomial-size circuits. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Classes/PPoly/Unrolling/Defs.lean b/Complexitylib/Classes/PPoly/Unrolling/Defs.lean index 307813f6..90cb5c91 100644 --- a/Complexitylib/Classes/PPoly/Unrolling/Defs.lean +++ b/Complexitylib/Classes/PPoly/Unrolling/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Family.Defs -import Complexitylib.Circuits.Unrolling.Acceptance.Hardwiring + +module +public import Complexitylib.Circuits.Family.Defs +public import Complexitylib.Circuits.Unrolling.Acceptance.Hardwiring /-! # Deterministic unrolling families — definitions @@ -18,6 +20,9 @@ the construction therefore depends only on the machine and time horizon, not on a target language or correctness proof. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Classes/PPoly/Unrolling/Internal.lean b/Complexitylib/Classes/PPoly/Unrolling/Internal.lean index d8fe5325..7e506b10 100644 --- a/Complexitylib/Classes/PPoly/Unrolling/Internal.lean +++ b/Complexitylib/Classes/PPoly/Unrolling/Internal.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.P -import Complexitylib.Classes.PPoly -import Complexitylib.Classes.PPoly.Unrolling.Defs -import Complexitylib.Models.TuringMachine.Internal + +module +public import Complexitylib.Classes.PPoly +public import Complexitylib.Classes.PPoly.Unrolling.Defs +public import Complexitylib.Classes.P.Defs +public import Mathlib.Tactic.SetNotationForOrder /-! # Deterministic unrolling families — proof internals @@ -16,6 +18,9 @@ by unrolling a deterministic machine. Public statements are exposed by `Complexitylib.Classes.PPoly.Unrolling`. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Classes/Pairing.lean b/Complexitylib/Classes/Pairing.lean index fc01421d..88cce781 100644 --- a/Complexitylib/Classes/Pairing.lean +++ b/Complexitylib/Classes/Pairing.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Encoding.Pairing -import Complexitylib.Models.TuringMachine -import Mathlib.Algebra.Polynomial.Eval.Defs + +module +public import Complexitylib.Encoding.Pairing +public import Complexitylib.Models.TuringMachine +public import Mathlib.Algebra.Polynomial.Eval.Defs /-! # Paired relation predicates @@ -14,6 +16,9 @@ This file adds the complexity-class predicates built on the neutral binary pairing codec from `Complexitylib.Encoding.Pairing`. -/ + +@[expose] public section + namespace Complexity /-- A binary relation is **polynomially balanced** if witness length is bounded diff --git a/Complexitylib/Classes/PropertyDensity.lean b/Complexitylib/Classes/PropertyDensity.lean index 11b9dd3c..52fe23cb 100644 --- a/Complexitylib/Classes/PropertyDensity.lean +++ b/Complexitylib/Classes/PropertyDensity.lean @@ -3,11 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.FiniteCounting -import Mathlib.Algebra.Order.Field.Basic -import Mathlib.Tactic.FieldSimp -import Mathlib.Tactic.GCongr -import Mathlib.Tactic.Positivity + +module +public import Complexitylib.Classes.FiniteCounting +public import Mathlib.Algebra.Order.Field.Basic +public import Mathlib.Tactic.Positivity.Finset /-! # Property density @@ -23,6 +23,9 @@ random-bit `eventProb` layer but over the sample space of all Boolean functions. `density_compl`, and the union bound `density_union_le` -/ + +@[expose] public section + namespace Complexity /-- The density of a property `P` of `n`-bit Boolean functions: the fraction of diff --git a/Complexitylib/Classes/Randomized.lean b/Complexitylib/Classes/Randomized.lean index c7c5b192..054bd7be 100644 --- a/Complexitylib/Classes/Randomized.lean +++ b/Complexitylib/Classes/Randomized.lean @@ -3,9 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine -import Complexitylib.Asymptotics -import Complexitylib.Classes.Time + +module +public import Complexitylib.Classes.Time /-! # Randomized complexity classes @@ -25,6 +25,9 @@ The acceptance-probability conditions shared across classes are factored into `NTM.RejectsWithProb` (upper-bounding acceptance on no-instances). -/ + +@[expose] public section + namespace Complexity diff --git a/Complexitylib/Classes/Randomized/CircuitAmplification.lean b/Complexitylib/Classes/Randomized/CircuitAmplification.lean index 6307a6ed..5d6694ef 100644 --- a/Complexitylib/Classes/Randomized/CircuitAmplification.lean +++ b/Complexitylib/Classes/Randomized/CircuitAmplification.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Hardwiring -import Complexitylib.Circuits.Unrolling.Amplification -import Complexitylib.Models.TuringMachine.Repetition.Defs + +module +public import Complexitylib.Circuits.Hardwiring +public import Complexitylib.Circuits.Unrolling.Amplification +public import Complexitylib.Models.TuringMachine.Repetition.Defs /-! # Probabilistic semantics of circuit amplification @@ -18,6 +20,9 @@ provides the fixed-seed wrapper that hardwires every choice input while leaving the positive-length data suffix live. -/ + +@[expose] public section + namespace Complexity namespace CircuitUnrolling diff --git a/Complexitylib/Classes/Randomized/GoodSeed.lean b/Complexitylib/Classes/Randomized/GoodSeed.lean index f780307a..06f57c68 100644 --- a/Complexitylib/Classes/Randomized/GoodSeed.lean +++ b/Complexitylib/Classes/Randomized/GoodSeed.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.BitString -import Complexitylib.Classes.Randomized -import Complexitylib.Models.TuringMachine.Repetition.Correctness + +module +public import Complexitylib.Circuits.BitString +public import Complexitylib.Classes.Randomized +public import Complexitylib.Models.TuringMachine.Repetition.Correctness /-! # Uniform good seeds for bounded-error machines @@ -18,6 +20,9 @@ The result only concerns the fixed-time acceptance event, so it does not need an all-paths-halting hypothesis. -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Classes/Randomized/PPoly.lean b/Complexitylib/Classes/Randomized/PPoly.lean index 9c5909f7..b6523f79 100644 --- a/Complexitylib/Classes/Randomized/PPoly.lean +++ b/Complexitylib/Classes/Randomized/PPoly.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly.Advice.Reverse -import Complexitylib.Classes.Randomized.PPoly.Defs -import Complexitylib.Classes.Randomized.PPoly.Internal + +module +public import Complexitylib.Classes.PPoly.Advice.Reverse +public import Complexitylib.Classes.Randomized.PPoly.Defs +public import Complexitylib.Classes.Randomized.PPoly.Internal /-! # Bounded-error probabilistic computation has polynomial-size circuits @@ -26,6 +28,9 @@ decider. - `BPP_subset_PAdvice`: every language in `BPP` has a polynomial-advice decider. -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Classes/Randomized/PPoly/Defs.lean b/Complexitylib/Classes/Randomized/PPoly/Defs.lean index f6c6a3c7..680669f2 100644 --- a/Complexitylib/Classes/Randomized/PPoly/Defs.lean +++ b/Complexitylib/Classes/Randomized/PPoly/Defs.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.Randomized.CircuitAmplification -import Complexitylib.Classes.Randomized.GoodSeed -import Complexitylib.Circuits.Family.Defs + +module +public import Complexitylib.Classes.Randomized.CircuitAmplification +public import Complexitylib.Classes.Randomized.GoodSeed +public import Complexitylib.Circuits.Family.Defs /-! # Nonuniform derandomization — definitions @@ -18,6 +20,9 @@ Correctness, size bounds, and the containment theorem are proved in the internal and surface modules. -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Classes/Randomized/PPoly/Internal.lean b/Complexitylib/Classes/Randomized/PPoly/Internal.lean index 81922ed5..1eace0bd 100644 --- a/Complexitylib/Classes/Randomized/PPoly/Internal.lean +++ b/Complexitylib/Classes/Randomized/PPoly/Internal.lean @@ -3,8 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.PPoly -import Complexitylib.Classes.Randomized.PPoly.Defs + +module +public import Complexitylib.Classes.PPoly +public import Complexitylib.Classes.Randomized.PPoly.Defs +public import Mathlib.Tactic.SetNotationForOrder /-! # Nonuniform derandomization — proof internals @@ -14,6 +17,9 @@ hardwires a uniformly correct amplified seed at each input length. Public statements are exposed by `Complexitylib.Classes.Randomized.PPoly`. -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Classes/SharpP.lean b/Complexitylib/Classes/SharpP.lean index 8549a5b3..508408ef 100644 --- a/Complexitylib/Classes/SharpP.lean +++ b/Complexitylib/Classes/SharpP.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine -import Complexitylib.Asymptotics -import Complexitylib.Classes.FiniteCounting + +module +public import Complexitylib.Models.TuringMachine +public import Complexitylib.Asymptotics +public import Complexitylib.Classes.FiniteCounting /-! # The counting class `#P` @@ -23,6 +25,9 @@ existing `NTM.acceptCount` path semantics (roadmap track L5). polynomial clock `T` -/ + +@[expose] public section + namespace Complexity /-- The number of accepting choice sequences is at most the total number of diff --git a/Complexitylib/Classes/Space.lean b/Complexitylib/Classes/Space.lean index f0ea04c9..98c598f3 100644 --- a/Complexitylib/Classes/Space.lean +++ b/Complexitylib/Classes/Space.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine -import Complexitylib.Asymptotics + +module +public import Complexitylib.Models.TuringMachine +public import Complexitylib.Asymptotics /-! # Base space complexity classes @@ -19,6 +21,9 @@ output verdict cell is free, while farther two-way output-head travel is also charged. This prevents either infinite named tape from becoming hidden workspace. -/ + +@[expose] public section + namespace Complexity diff --git a/Complexitylib/Classes/Time.lean b/Complexitylib/Classes/Time.lean index 533e64a0..07704fc8 100644 --- a/Complexitylib/Classes/Time.lean +++ b/Complexitylib/Classes/Time.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine -import Complexitylib.Asymptotics + +module +public import Complexitylib.Models.TuringMachine +public import Complexitylib.Asymptotics /-! # Base time complexity classes @@ -17,6 +19,9 @@ Both use `=O` (Mathlib's `IsBigO` lifted to `ℕ → ℕ`) to express asymptotic bounds. -/ + +@[expose] public section + namespace Complexity diff --git a/Complexitylib/DescriptiveComplexity.lean b/Complexitylib/DescriptiveComplexity.lean index 33a76719..5d7ec287 100644 --- a/Complexitylib/DescriptiveComplexity.lean +++ b/Complexitylib/DescriptiveComplexity.lean @@ -3,19 +3,21 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.DescriptiveComplexity.Vocabulary -import Complexitylib.DescriptiveComplexity.Structure -import Complexitylib.DescriptiveComplexity.Isomorphism -import Complexitylib.DescriptiveComplexity.Query -import Complexitylib.DescriptiveComplexity.Env -import Complexitylib.DescriptiveComplexity.FirstOrder -import Complexitylib.DescriptiveComplexity.SecondOrder -import Complexitylib.DescriptiveComplexity.Definable -import Complexitylib.DescriptiveComplexity.Reduction -import Complexitylib.DescriptiveComplexity.Encoding -import Complexitylib.DescriptiveComplexity.ModelChecking -import Complexitylib.DescriptiveComplexity.Language -import Complexitylib.DescriptiveComplexity.Examples + +module +public import Complexitylib.DescriptiveComplexity.Vocabulary +public import Complexitylib.DescriptiveComplexity.Structure +public import Complexitylib.DescriptiveComplexity.Isomorphism +public import Complexitylib.DescriptiveComplexity.Query +public import Complexitylib.DescriptiveComplexity.Env +public import Complexitylib.DescriptiveComplexity.FirstOrder +public import Complexitylib.DescriptiveComplexity.SecondOrder +public import Complexitylib.DescriptiveComplexity.Definable +public import Complexitylib.DescriptiveComplexity.Reduction +public import Complexitylib.DescriptiveComplexity.Encoding +public import Complexitylib.DescriptiveComplexity.ModelChecking +public import Complexitylib.DescriptiveComplexity.Language +public import Complexitylib.DescriptiveComplexity.Examples /-! # Descriptive complexity diff --git a/Complexitylib/DescriptiveComplexity/Definable.lean b/Complexitylib/DescriptiveComplexity/Definable.lean index 0a36f749..c145fde2 100644 --- a/Complexitylib/DescriptiveComplexity/Definable.lean +++ b/Complexitylib/DescriptiveComplexity/Definable.lean @@ -3,10 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.DescriptiveComplexity.Query -import Complexitylib.DescriptiveComplexity.FirstOrder -import Complexitylib.DescriptiveComplexity.Reduction -import Complexitylib.DescriptiveComplexity.SecondOrder + +module +public import Complexitylib.DescriptiveComplexity.Reduction +public import Complexitylib.DescriptiveComplexity.SecondOrder.Isomorphism /-! # First-order definable queries @@ -33,6 +33,9 @@ bounds. - `FODefinable.toSODefinable` — `FO ⊆ SO` at the query level. -/ + +@[expose] public section + open scoped Complexity.DescriptiveComplexity namespace Complexity diff --git a/Complexitylib/DescriptiveComplexity/Encoding.lean b/Complexitylib/DescriptiveComplexity/Encoding.lean index d382c860..1bf72628 100644 --- a/Complexitylib/DescriptiveComplexity/Encoding.lean +++ b/Complexitylib/DescriptiveComplexity/Encoding.lean @@ -3,12 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.DescriptiveComplexity.Structure -import Mathlib.Data.Fintype.Pi -import Mathlib.Data.Fintype.BigOperators -import Mathlib.Data.List.FinRange -import Mathlib.Data.Fin.Tuple.Basic -import Mathlib.Data.List.TakeWhile + +module +public import Complexitylib.DescriptiveComplexity.Structure +public import Mathlib.Data.Fintype.Pi +public import Mathlib.Data.Fintype.BigOperators +public import Std.Tactic.BVDecide.Normalize.Prop /-! # Encoding finite structures as bit strings @@ -31,6 +31,9 @@ relational part of that encoding and computes its length; it is step 5 (structur Fagin bridge). -/ + +@[expose] public section + namespace Complexity namespace DescriptiveComplexity diff --git a/Complexitylib/DescriptiveComplexity/Env.lean b/Complexitylib/DescriptiveComplexity/Env.lean index 8c27d970..0b52a3d5 100644 --- a/Complexitylib/DescriptiveComplexity/Env.lean +++ b/Complexitylib/DescriptiveComplexity/Env.lean @@ -3,7 +3,8 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.DescriptiveComplexity.Vocabulary + +module /-! Variable environments for first-order logic. @@ -12,6 +13,9 @@ import Complexitylib.DescriptiveComplexity.Vocabulary environment machinery for mapping de Bruijn variables to universe elements. -/ + +@[expose] public section + namespace Complexity namespace DescriptiveComplexity diff --git a/Complexitylib/DescriptiveComplexity/Examples.lean b/Complexitylib/DescriptiveComplexity/Examples.lean index 0a5a2871..bb1a78fa 100644 --- a/Complexitylib/DescriptiveComplexity/Examples.lean +++ b/Complexitylib/DescriptiveComplexity/Examples.lean @@ -3,8 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.DescriptiveComplexity.Query -import Complexitylib.DescriptiveComplexity.FirstOrder + +module +public import Complexitylib.DescriptiveComplexity.FirstOrder.Isomorphism /-! # Examples of Finite Structures @@ -15,6 +16,9 @@ import Complexitylib.DescriptiveComplexity.FirstOrder - An isomorphism between two concrete graphs -/ + +@[expose] public section + namespace Complexity namespace DescriptiveComplexity @@ -51,7 +55,7 @@ def cycle3' : FinStruct graph where const := Fin.elim0 /-- The permutation 0↦0, 1↦2, 2↦1 on Fin 3 (an involution). -/ -private def perm3 : Fin 3 → Fin 3 +def perm3 : Fin 3 → Fin 3 | ⟨0, _⟩ => ⟨0, by omega⟩ | ⟨1, _⟩ => ⟨2, by omega⟩ | ⟨2, _⟩ => ⟨1, by omega⟩ diff --git a/Complexitylib/DescriptiveComplexity/FirstOrder.lean b/Complexitylib/DescriptiveComplexity/FirstOrder.lean index ddad63a7..77d14213 100644 --- a/Complexitylib/DescriptiveComplexity/FirstOrder.lean +++ b/Complexitylib/DescriptiveComplexity/FirstOrder.lean @@ -3,10 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.DescriptiveComplexity.FirstOrder.Syntax -import Complexitylib.DescriptiveComplexity.FirstOrder.Semantics -import Complexitylib.DescriptiveComplexity.FirstOrder.Isomorphism -import Complexitylib.DescriptiveComplexity.FirstOrder.Substitution + +module +public import Complexitylib.DescriptiveComplexity.FirstOrder.Syntax +public import Complexitylib.DescriptiveComplexity.FirstOrder.Semantics +public import Complexitylib.DescriptiveComplexity.FirstOrder.Isomorphism +public import Complexitylib.DescriptiveComplexity.FirstOrder.Substitution /-! # First-order logic over finite structures diff --git a/Complexitylib/DescriptiveComplexity/FirstOrder/Isomorphism.lean b/Complexitylib/DescriptiveComplexity/FirstOrder/Isomorphism.lean index 3b6d7cee..2912d7a6 100644 --- a/Complexitylib/DescriptiveComplexity/FirstOrder/Isomorphism.lean +++ b/Complexitylib/DescriptiveComplexity/FirstOrder/Isomorphism.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.DescriptiveComplexity.Query -import Complexitylib.DescriptiveComplexity.FirstOrder.Semantics + +module +public import Complexitylib.DescriptiveComplexity.Query +public import Complexitylib.DescriptiveComplexity.FirstOrder.Semantics /-! Isomorphism preservation for first-order logic. @@ -15,6 +17,9 @@ import Complexitylib.DescriptiveComplexity.FirstOrder.Semantics 3. FO sentences are order-independent (Immerman Proposition 1.16) -/ + +@[expose] public section + namespace Complexity namespace DescriptiveComplexity diff --git a/Complexitylib/DescriptiveComplexity/FirstOrder/Semantics.lean b/Complexitylib/DescriptiveComplexity/FirstOrder/Semantics.lean index 41b8a9be..18e06c35 100644 --- a/Complexitylib/DescriptiveComplexity/FirstOrder/Semantics.lean +++ b/Complexitylib/DescriptiveComplexity/FirstOrder/Semantics.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.DescriptiveComplexity.Structure -import Complexitylib.DescriptiveComplexity.Env -import Complexitylib.DescriptiveComplexity.FirstOrder.Syntax + +module +public import Complexitylib.DescriptiveComplexity.Structure +public import Complexitylib.DescriptiveComplexity.Env +public import Complexitylib.DescriptiveComplexity.FirstOrder.Syntax /-! First-order logic semantics: term evaluation, formula satisfaction, models. @@ -13,6 +15,9 @@ import Complexitylib.DescriptiveComplexity.FirstOrder.Syntax Follows Immerman Definition 1.11 (semantics part). -/ + +@[expose] public section + namespace Complexity namespace DescriptiveComplexity diff --git a/Complexitylib/DescriptiveComplexity/FirstOrder/Substitution.lean b/Complexitylib/DescriptiveComplexity/FirstOrder/Substitution.lean index 6fd3031b..3e9c7831 100644 --- a/Complexitylib/DescriptiveComplexity/FirstOrder/Substitution.lean +++ b/Complexitylib/DescriptiveComplexity/FirstOrder/Substitution.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.DescriptiveComplexity.FirstOrder.Semantics + +module +public import Complexitylib.DescriptiveComplexity.FirstOrder.Semantics /-! # First-order substitution @@ -29,6 +31,9 @@ formula along an `FOInterpretation`. - `Formula.subst_sat` — the substitution theorem. -/ + +@[expose] public section + namespace Complexity namespace DescriptiveComplexity diff --git a/Complexitylib/DescriptiveComplexity/FirstOrder/Syntax.lean b/Complexitylib/DescriptiveComplexity/FirstOrder/Syntax.lean index 77a4c5f1..da711a93 100644 --- a/Complexitylib/DescriptiveComplexity/FirstOrder/Syntax.lean +++ b/Complexitylib/DescriptiveComplexity/FirstOrder/Syntax.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.DescriptiveComplexity.Vocabulary + +module +public import Complexitylib.DescriptiveComplexity.Vocabulary /-! First-order logic syntax: terms, formulas, sentences, derived connectives. @@ -13,6 +15,9 @@ import Complexitylib.DescriptiveComplexity.Vocabulary Formulas are indexed by the number of free variables. -/ + +@[expose] public section + namespace Complexity namespace DescriptiveComplexity diff --git a/Complexitylib/DescriptiveComplexity/Isomorphism.lean b/Complexitylib/DescriptiveComplexity/Isomorphism.lean index f7fee9d3..1cdf67b1 100644 --- a/Complexitylib/DescriptiveComplexity/Isomorphism.lean +++ b/Complexitylib/DescriptiveComplexity/Isomorphism.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.DescriptiveComplexity.Structure + +module +public import Complexitylib.DescriptiveComplexity.Structure /-! # Isomorphisms, Embeddings, and Substructures @@ -13,6 +15,9 @@ import Complexitylib.DescriptiveComplexity.Structure cardinality. We also define embeddings and substructures. -/ + +@[expose] public section + namespace Complexity namespace DescriptiveComplexity diff --git a/Complexitylib/DescriptiveComplexity/Language.lean b/Complexitylib/DescriptiveComplexity/Language.lean index 75d4442e..0146596e 100644 --- a/Complexitylib/DescriptiveComplexity/Language.lean +++ b/Complexitylib/DescriptiveComplexity/Language.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.DescriptiveComplexity.Encoding -import Complexitylib.DescriptiveComplexity.Query -import Complexitylib.Models.TuringMachine + +module +public import Complexitylib.DescriptiveComplexity.Encoding +public import Complexitylib.DescriptiveComplexity.Query +public import Complexitylib.Models.TuringMachine /-! # The language induced by a Boolean query @@ -24,6 +26,9 @@ ultimately rest on. is in `Q`'s language. -/ + +@[expose] public section + namespace Complexity namespace DescriptiveComplexity diff --git a/Complexitylib/DescriptiveComplexity/ModelChecking.lean b/Complexitylib/DescriptiveComplexity/ModelChecking.lean index d3ea5f3d..3929bfd5 100644 --- a/Complexitylib/DescriptiveComplexity/ModelChecking.lean +++ b/Complexitylib/DescriptiveComplexity/ModelChecking.lean @@ -3,10 +3,15 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.DescriptiveComplexity.Structure -import Complexitylib.DescriptiveComplexity.Env -import Complexitylib.DescriptiveComplexity.FirstOrder.Semantics -import Mathlib.Data.List.FinRange + +module +public import Complexitylib.DescriptiveComplexity.FirstOrder.Semantics +public import Aesop.BuiltinRules +public import Mathlib.Tactic.Attr.Core +public import Mathlib.Tactic.Basic +public import Mathlib.Tactic.Finiteness.Attr +public import Mathlib.Tactic.ToAdditive +public import Mathlib.Tactic.ToDual /-! # Computable first-order model checking @@ -29,6 +34,9 @@ characterization, and the `FO ⊆ AC⁰` bridge. form. -/ + +@[expose] public section + namespace Complexity namespace DescriptiveComplexity diff --git a/Complexitylib/DescriptiveComplexity/Query.lean b/Complexitylib/DescriptiveComplexity/Query.lean index 0d83ffcc..ed60f10d 100644 --- a/Complexitylib/DescriptiveComplexity/Query.lean +++ b/Complexitylib/DescriptiveComplexity/Query.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.DescriptiveComplexity.Isomorphism + +module +public import Complexitylib.DescriptiveComplexity.Isomorphism /-! # Boolean Queries @@ -13,6 +15,9 @@ import Complexitylib.DescriptiveComplexity.Isomorphism (Definition 1.16 in Immerman). -/ + +@[expose] public section + namespace Complexity namespace DescriptiveComplexity diff --git a/Complexitylib/DescriptiveComplexity/Reduction.lean b/Complexitylib/DescriptiveComplexity/Reduction.lean index d17c858b..e2cfe518 100644 --- a/Complexitylib/DescriptiveComplexity/Reduction.lean +++ b/Complexitylib/DescriptiveComplexity/Reduction.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.DescriptiveComplexity.Query -import Complexitylib.DescriptiveComplexity.FirstOrder + +module +public import Complexitylib.DescriptiveComplexity.Query +public import Complexitylib.DescriptiveComplexity.FirstOrder.Substitution /-! # First-order reductions and projections @@ -36,6 +38,9 @@ string-level FO-reduction (an FO map on encodings) is a further step on track L6 reflexivity/transitivity. -/ + +@[expose] public section + namespace Complexity namespace DescriptiveComplexity diff --git a/Complexitylib/DescriptiveComplexity/SecondOrder.lean b/Complexitylib/DescriptiveComplexity/SecondOrder.lean index 5b865397..493a9def 100644 --- a/Complexitylib/DescriptiveComplexity/SecondOrder.lean +++ b/Complexitylib/DescriptiveComplexity/SecondOrder.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.DescriptiveComplexity.SecondOrder.Syntax -import Complexitylib.DescriptiveComplexity.SecondOrder.Semantics -import Complexitylib.DescriptiveComplexity.SecondOrder.Isomorphism + +module +public import Complexitylib.DescriptiveComplexity.SecondOrder.Syntax +public import Complexitylib.DescriptiveComplexity.SecondOrder.Semantics +public import Complexitylib.DescriptiveComplexity.SecondOrder.Isomorphism /-! # Second-order logic over finite structures diff --git a/Complexitylib/DescriptiveComplexity/SecondOrder/Isomorphism.lean b/Complexitylib/DescriptiveComplexity/SecondOrder/Isomorphism.lean index d6da5348..e34a0f3a 100644 --- a/Complexitylib/DescriptiveComplexity/SecondOrder/Isomorphism.lean +++ b/Complexitylib/DescriptiveComplexity/SecondOrder/Isomorphism.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.DescriptiveComplexity.SecondOrder.Semantics -import Complexitylib.DescriptiveComplexity.FirstOrder.Isomorphism + +module +public import Complexitylib.DescriptiveComplexity.SecondOrder.Semantics +public import Complexitylib.DescriptiveComplexity.FirstOrder.Isomorphism /-! # Second-order logic: isomorphism invariance @@ -30,6 +32,9 @@ witnessing relations through the isomorphism. are order-independent. -/ + +@[expose] public section + namespace Complexity namespace DescriptiveComplexity diff --git a/Complexitylib/DescriptiveComplexity/SecondOrder/Semantics.lean b/Complexitylib/DescriptiveComplexity/SecondOrder/Semantics.lean index a4d0a5f8..5a82f8b8 100644 --- a/Complexitylib/DescriptiveComplexity/SecondOrder/Semantics.lean +++ b/Complexitylib/DescriptiveComplexity/SecondOrder/Semantics.lean @@ -3,10 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.DescriptiveComplexity.SecondOrder.Syntax -import Complexitylib.DescriptiveComplexity.Structure -import Complexitylib.DescriptiveComplexity.Env -import Complexitylib.DescriptiveComplexity.FirstOrder.Semantics + +module +public import Complexitylib.DescriptiveComplexity.SecondOrder.Syntax +public import Complexitylib.DescriptiveComplexity.FirstOrder.Semantics /-! # Second-order logic: semantics @@ -30,6 +30,9 @@ so first-order truth is a special case of second-order truth truth-preserving. -/ + +@[expose] public section + namespace Complexity namespace DescriptiveComplexity diff --git a/Complexitylib/DescriptiveComplexity/SecondOrder/Syntax.lean b/Complexitylib/DescriptiveComplexity/SecondOrder/Syntax.lean index 2cd94d1c..1742b7fa 100644 --- a/Complexitylib/DescriptiveComplexity/SecondOrder/Syntax.lean +++ b/Complexitylib/DescriptiveComplexity/SecondOrder/Syntax.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.DescriptiveComplexity.FirstOrder.Syntax + +module +public import Complexitylib.DescriptiveComplexity.FirstOrder.Syntax /-! # Second-order logic: syntax @@ -27,6 +29,9 @@ syntax is the one Fagin's theorem characterizes as `NP`. - `SOFormula.size` — the syntactic size. -/ + +@[expose] public section + namespace Complexity namespace DescriptiveComplexity diff --git a/Complexitylib/DescriptiveComplexity/Structure.lean b/Complexitylib/DescriptiveComplexity/Structure.lean index c2bd1a06..02636417 100644 --- a/Complexitylib/DescriptiveComplexity/Structure.lean +++ b/Complexitylib/DescriptiveComplexity/Structure.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.DescriptiveComplexity.Vocabulary + +module +public import Complexitylib.DescriptiveComplexity.Vocabulary /-! # Finite Structures @@ -19,6 +21,9 @@ import Complexitylib.DescriptiveComplexity.Vocabulary structure but computed from the `Fin` ordering (Proviso 1.14). -/ + +@[expose] public section + namespace Complexity namespace DescriptiveComplexity diff --git a/Complexitylib/DescriptiveComplexity/Vocabulary.lean b/Complexitylib/DescriptiveComplexity/Vocabulary.lean index 57dfdc0b..ef2f435b 100644 --- a/Complexitylib/DescriptiveComplexity/Vocabulary.lean +++ b/Complexitylib/DescriptiveComplexity/Vocabulary.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ +module + /-! # Vocabularies (Signatures) @@ -13,6 +15,9 @@ Authors: Samuel Schlesinger `relArity`, and `numConsts` constant symbols. -/ + +@[expose] public section + namespace Complexity namespace DescriptiveComplexity diff --git a/Complexitylib/Encoding/Pairing.lean b/Complexitylib/Encoding/Pairing.lean index 68070786..c09dfea6 100644 --- a/Complexitylib/Encoding/Pairing.lean +++ b/Complexitylib/Encoding/Pairing.lean @@ -3,9 +3,15 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Data.List.Basic -import Mathlib.Data.Nat.Init -import Lean.Elab.Tactic.Omega + +module +public import Mathlib.Data.Nat.Init +public import Aesop.BuiltinRules +public import Mathlib.Tactic.Attr.Core +public import Mathlib.Tactic.Basic +public import Mathlib.Tactic.Push +public import Mathlib.Tactic.Widget.Calc +public import Std.Tactic.BVDecide.Normalize.Prop /-! # Pairing binary strings @@ -16,6 +22,9 @@ machine or complexity-class layers, so parsers and encoders can reuse it without introducing an import cycle. -/ + +@[expose] public section + namespace Complexity /-- Encode a pair of binary strings as a single binary string. diff --git a/Complexitylib/Languages.lean b/Complexitylib/Languages.lean index e1ba0214..59d84a05 100644 --- a/Complexitylib/Languages.lean +++ b/Complexitylib/Languages.lean @@ -3,17 +3,19 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Languages.Trivial -import Complexitylib.Languages.FirstCell -import Complexitylib.Languages.LengthParity -import Complexitylib.Languages.AnBn -import Complexitylib.Languages.ZeroPrefix -import Complexitylib.Languages.Balanced -import Complexitylib.Languages.AllSymbol -import Complexitylib.Languages.Contains -import Complexitylib.Languages.LengthDivBy -import Complexitylib.Languages.LastBit -import Complexitylib.Languages.Palindromes + +module +public import Complexitylib.Languages.Trivial +public import Complexitylib.Languages.FirstCell +public import Complexitylib.Languages.LengthParity +public import Complexitylib.Languages.AnBn +public import Complexitylib.Languages.ZeroPrefix +public import Complexitylib.Languages.Balanced +public import Complexitylib.Languages.AllSymbol +public import Complexitylib.Languages.Contains +public import Complexitylib.Languages.LengthDivBy +public import Complexitylib.Languages.LastBit +public import Complexitylib.Languages.Palindromes /-! # Concrete languages and their complexity — aggregation diff --git a/Complexitylib/Languages/AllSymbol.lean b/Complexitylib/Languages/AllSymbol.lean index cab92ea1..ae258ca2 100644 --- a/Complexitylib/Languages/AllSymbol.lean +++ b/Complexitylib/Languages/AllSymbol.lean @@ -3,10 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Languages.Trivial -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Combinators.Internal.Scanner -import Complexitylib.Models.TuringMachine.Combinators.Internal.Complement + +module +public import Complexitylib.Models.TuringMachine.Combinators +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Scanner +public import Complexitylib.Classes.Containments /-! # `allZeros` and `allOnes`: single-symbol languages @@ -26,6 +27,9 @@ single `Bool` tracking "every bit so far equals target". - `allZeros_mem_P`, `allOnes_mem_P`. -/ + +@[expose] public section + namespace Complexity open Complexity diff --git a/Complexitylib/Languages/AnBn.lean b/Complexitylib/Languages/AnBn.lean index 978cd619..828c86af 100644 --- a/Complexitylib/Languages/AnBn.lean +++ b/Complexitylib/Languages/AnBn.lean @@ -3,9 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Languages.Trivial -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Combinators.Internal.Complement + +module +public import Complexitylib.Models.TuringMachine.Combinators +public import Complexitylib.Classes.Containments /-! # `{0ⁿ 1ⁿ : n ≥ 0}`: the canonical push-down language @@ -30,6 +31,9 @@ via the permanently-`▷` cell 0. - `anbn_in_DTIME`, `anbn_mem_P`. -/ + +@[expose] public section + namespace Complexity open Complexity diff --git a/Complexitylib/Languages/Balanced.lean b/Complexitylib/Languages/Balanced.lean index 75ba5d27..79816f89 100644 --- a/Complexitylib/Languages/Balanced.lean +++ b/Complexitylib/Languages/Balanced.lean @@ -3,9 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Languages.Trivial -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Combinators.Internal.Complement + +module +public import Complexitylib.Models.TuringMachine.Combinators +public import Complexitylib.Classes.Containments /-! # `{x : #false x = #true x}`: equal-count / "balanced" language @@ -35,6 +36,9 @@ Emptiness (`h = 0`) is detected structurally by the work head reading - `balanced_in_DTIME`, `balanced_mem_P`. -/ + +@[expose] public section + namespace Complexity open Complexity diff --git a/Complexitylib/Languages/Contains.lean b/Complexitylib/Languages/Contains.lean index 37bfac59..f3171a67 100644 --- a/Complexitylib/Languages/Contains.lean +++ b/Complexitylib/Languages/Contains.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Languages.Trivial -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Combinators.Internal.Scanner + +module +public import Complexitylib.Models.TuringMachine.Combinators +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Scanner +public import Complexitylib.Classes.Containments /-! # `containsZero` and `containsOne`: "contains-a-bit" languages @@ -25,6 +27,9 @@ The strings containing at least one `0`-bit (resp. `1`-bit). Decided by a - `containsZero_mem_P`, `containsOne_mem_P`. -/ + +@[expose] public section + namespace Complexity open Complexity diff --git a/Complexitylib/Languages/FirstCell.lean b/Complexitylib/Languages/FirstCell.lean index 137c20d0..47302fa4 100644 --- a/Complexitylib/Languages/FirstCell.lean +++ b/Complexitylib/Languages/FirstCell.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Languages.Trivial -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Combinators.Internal.Complement + +module +public import Complexitylib.Models.TuringMachine.Combinators +public import Complexitylib.Classes.Containments +public import Std.Tactic.BVDecide.Normalize.BitVec /-! # Languages determined by the first input cell @@ -41,6 +43,9 @@ languages. used to present `nonempty` as a union. -/ + +@[expose] public section + namespace Complexity open Complexity diff --git a/Complexitylib/Languages/LastBit.lean b/Complexitylib/Languages/LastBit.lean index 5f2d4c99..ea88d5da 100644 --- a/Complexitylib/Languages/LastBit.lean +++ b/Complexitylib/Languages/LastBit.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Languages.Trivial -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Combinators.Internal.Scanner + +module +public import Complexitylib.Models.TuringMachine.Combinators +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Scanner +public import Complexitylib.Classes.Containments /-! # `lastBitOne` and `lastBitZero`: final-symbol languages @@ -25,6 +27,9 @@ is the last bit seen so far, or `none` if no bit has been read. - `lastBitOne_mem_P`, `lastBitZero_mem_P`. -/ + +@[expose] public section + namespace Complexity open Complexity diff --git a/Complexitylib/Languages/LengthDivBy.lean b/Complexitylib/Languages/LengthDivBy.lean index 440f06de..34ec8d11 100644 --- a/Complexitylib/Languages/LengthDivBy.lean +++ b/Complexitylib/Languages/LengthDivBy.lean @@ -3,10 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Languages.Trivial -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Combinators.Internal.Scanner -import Mathlib.Data.ZMod.Basic + +module +public import Complexitylib.Models.TuringMachine.Combinators +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Scanner +public import Complexitylib.Classes.Containments /-! # `lengthDivBy k`: length-divisibility language family @@ -28,6 +29,9 @@ This generalizes `evenLength` (which is `lengthDivBy 2`). - `lengthDivBy_mem_P`. -/ + +@[expose] public section + namespace Complexity open Complexity diff --git a/Complexitylib/Languages/LengthParity.lean b/Complexitylib/Languages/LengthParity.lean index a943dbbb..c1ff3cb8 100644 --- a/Complexitylib/Languages/LengthParity.lean +++ b/Complexitylib/Languages/LengthParity.lean @@ -3,9 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Languages.Trivial -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Combinators.Internal.Complement + +module +public import Complexitylib.Models.TuringMachine.Combinators +public import Complexitylib.Classes.Containments /-! # Languages determined by the parity of the input length @@ -29,6 +30,9 @@ the input. - `oddLength_eq_compl_evenLength` — explicit Boolean identity. -/ + +@[expose] public section + namespace Complexity open Complexity diff --git a/Complexitylib/Languages/Palindromes.lean b/Complexitylib/Languages/Palindromes.lean index 45197bbf..38463689 100644 --- a/Complexitylib/Languages/Palindromes.lean +++ b/Complexitylib/Languages/Palindromes.lean @@ -3,9 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Languages.Trivial -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Combinators.Internal.Complement + +module +public import Complexitylib.Models.TuringMachine.Combinators +public import Complexitylib.Classes.Containments /-! # `palindromes`: strings equal to their reverse @@ -40,6 +41,9 @@ Phases (see comments on `PalindromePhase`): 5. `reject`: consume remaining input, then halt with output `0`. -/ + +@[expose] public section + namespace Complexity open Complexity diff --git a/Complexitylib/Languages/Trivial.lean b/Complexitylib/Languages/Trivial.lean index b3637a94..020d1827 100644 --- a/Complexitylib/Languages/Trivial.lean +++ b/Complexitylib/Languages/Trivial.lean @@ -3,9 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.P -import Complexitylib.Classes.Containments -import Complexitylib.Models.TuringMachine.Subroutines.Internal + +module +public import Complexitylib.Classes.Containments /-! # Trivial languages: `∅` and `Set.univ` @@ -30,6 +30,9 @@ complexity class. - `empty_mem_EXP`, `univ_mem_EXP` -/ + +@[expose] public section + namespace Complexity open Complexity diff --git a/Complexitylib/Languages/ZeroPrefix.lean b/Complexitylib/Languages/ZeroPrefix.lean index d6be63b3..2d0d43a7 100644 --- a/Complexitylib/Languages/ZeroPrefix.lean +++ b/Complexitylib/Languages/ZeroPrefix.lean @@ -3,9 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Languages.Trivial -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Combinators.Internal.Complement + +module +public import Complexitylib.Models.TuringMachine.Combinators +public import Complexitylib.Classes.Containments /-! # `{0ⁿ 1ᵐ : n ≥ m}`: a push-down language with inequality counter @@ -33,6 +34,9 @@ via the permanently-`▷` cell 0. - `zeroPrefix_in_DTIME`, `zeroPrefix_mem_P`. -/ + +@[expose] public section + namespace Complexity open Complexity diff --git a/Complexitylib/Mathlib/Digraph.lean b/Complexitylib/Mathlib/Digraph.lean index b938302f..080e0f8d 100644 --- a/Complexitylib/Mathlib/Digraph.lean +++ b/Complexitylib/Mathlib/Digraph.lean @@ -3,9 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Combinatorics.Digraph.Basic -import Mathlib.Data.Fintype.Prod -import Mathlib.Data.Nat.Lattice + +module +public import Mathlib.Combinatorics.Digraph.Basic +public import Mathlib.Data.Fintype.Prod +public import Mathlib.Data.Nat.Lattice +public import Std.Tactic.BVDecide.Normalize.Prop /-! # Digraph extensions for Mathlib @@ -31,6 +34,9 @@ arguments, edge partitions by first-differing bit, etc.) lives in `Complexitylib.Circuits.Internal.Valiant`. -/ + +@[expose] public section + namespace Digraph variable {V : Type*} diff --git a/Complexitylib/Mathlib/FinsetPrefixes.lean b/Complexitylib/Mathlib/FinsetPrefixes.lean index f3ae5f15..fc5a3013 100644 --- a/Complexitylib/Mathlib/FinsetPrefixes.lean +++ b/Complexitylib/Mathlib/FinsetPrefixes.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Bolton Bailey. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bolton Bailey -/ -import Mathlib.Data.Finset.Union -import Mathlib.Data.List.Infix + +module +public import Mathlib.Data.Finset.Union +public import Mathlib.Data.List.Infix /-! # Finsets of prefixes and suffixes @@ -20,6 +22,8 @@ type in its home namespace — the sanctioned exception to the `Complexity` root-namespace rule. Its contents are candidates for upstreaming to Mathlib. -/ +@[expose] public section + namespace Finset variable {α : Type*} [DecidableEq α] {S : Finset (List α)} diff --git a/Complexitylib/Mathlib/NatBits.lean b/Complexitylib/Mathlib/NatBits.lean index 83c3d131..25a9cbf8 100644 --- a/Complexitylib/Mathlib/NatBits.lean +++ b/Complexitylib/Mathlib/NatBits.lean @@ -3,10 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Data.Nat.Log -import Mathlib.Data.Nat.Size -import Mathlib.Tactic.Ring -import Mathlib.Tactic.Lemma + +module +public import Mathlib.Data.Nat.Log +public import Mathlib.Data.Nat.Size +public import Mathlib.Tactic.NormNum.Inv +public import Mathlib.Tactic.NormNum.Pow /-! # Fixed-width binary encodings of natural numbers @@ -23,6 +25,9 @@ type in its home (root) namespace — the sanctioned exception to the upstreaming to Mathlib. -/ + +@[expose] public section + /-- Encode a natural number as a big-endian binary list of exactly `w` bits. Numbers larger than `2^w - 1` are truncated (mod 2^w). -/ def Nat.toBits : ℕ → ℕ → List Bool diff --git a/Complexitylib/Models.lean b/Complexitylib/Models.lean index 49b039cb..ae8ecc48 100644 --- a/Complexitylib/Models.lean +++ b/Complexitylib/Models.lean @@ -3,71 +3,73 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine -import Complexitylib.Models.TuringMachine.Trace -import Complexitylib.Models.TuringMachine.SingleTape -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Combinators.ForBinaryWork -import Complexitylib.Models.TuringMachine.Combinators.ForInput -import Complexitylib.Models.TuringMachine.Combinators.ForWorkOnes -import Complexitylib.Models.TuringMachine.Combinators.RetargetCompute -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch -import Complexitylib.Models.TuringMachine.Combinators.WorkSymbolBranch -import Complexitylib.Models.TuringMachine.Hoare -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Experimental.Routine -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.InputLength -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.SpaceBounds -import Complexitylib.Models.TuringMachine.Tape.Encoding -import Complexitylib.Models.TuringMachine.Subroutines -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAdd -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy -import Complexitylib.Models.TuringMachine.Subroutines.BinaryEq -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub -import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul -import Complexitylib.Models.TuringMachine.Subroutines.BinaryMulAdd -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPolynomial -import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor -import Complexitylib.Models.TuringMachine.Subroutines.BinaryLength -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc -import Complexitylib.Models.TuringMachine.Subroutines.ClearWork -import Complexitylib.Models.TuringMachine.Subroutines.CopyOutput -import Complexitylib.Models.TuringMachine.Subroutines.CopyWorkOutput -import Complexitylib.Models.TuringMachine.Subroutines.PairEmit -import Complexitylib.Models.TuringMachine.Subroutines.PairValidate -import Complexitylib.Models.TuringMachine.Subroutines.PairSplit -import Complexitylib.Models.TuringMachine.Subroutines.ScanRight -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany -import Complexitylib.Models.TuringMachine.Subroutines.UnaryLength -import Complexitylib.Models.TuringMachine.OutputBounds -import Complexitylib.Models.TuringMachine.SpaceTime -import Complexitylib.Models.TuringMachine.Placement -import Complexitylib.Models.TuringMachine.Composition -import Complexitylib.Models.TuringMachine.Composition.PairWithInput -import Complexitylib.Models.TuringMachine.Deterministic -import Complexitylib.Models.TuringMachine.Lift -import Complexitylib.Models.TuringMachine.Repetition -import Complexitylib.Models.TuringMachine.Repetition.Correctness -import Complexitylib.Models.TuringMachine.UTM.Encoding -import Complexitylib.Models.TuringMachine.UTM.Machine -import Complexitylib.Models.TuringMachine.UTM.Universal -import Complexitylib.Models.TuringMachine.UTM.Clock -import Complexitylib.Models.TuringMachine.UTM.ClockConstructible -import Complexitylib.Models.TuringMachine.UTM.ClockedUtm -import Complexitylib.Models.TuringMachine.UTM.HierarchySupport -import Complexitylib.Models.TuringMachine.UTM.Diagonal -import Complexitylib.Models.RandomAccessMachine -import Complexitylib.Models.RoseTreeMachine.Data -import Complexitylib.Models.RoseTreeMachine.DataEncode -import Complexitylib.Models.RoseTreeMachine.Prog + +module +public import Complexitylib.Models.TuringMachine +public import Complexitylib.Models.TuringMachine.Trace +public import Complexitylib.Models.TuringMachine.SingleTape +public import Complexitylib.Models.TuringMachine.Combinators +public import Complexitylib.Models.TuringMachine.Combinators.ForBinaryWork +public import Complexitylib.Models.TuringMachine.Combinators.ForInput +public import Complexitylib.Models.TuringMachine.Combinators.ForWorkOnes +public import Complexitylib.Models.TuringMachine.Combinators.RetargetCompute +public import Complexitylib.Models.TuringMachine.Combinators.WorkBranch +public import Complexitylib.Models.TuringMachine.Combinators.WorkSymbolBranch +public import Complexitylib.Models.TuringMachine.Hoare +public import Complexitylib.Models.TuringMachine.Hoare.Space +public import Complexitylib.Models.TuringMachine.Experimental.Routine +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.InputLength +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.SpaceBounds +public import Complexitylib.Models.TuringMachine.Tape.Encoding +public import Complexitylib.Models.TuringMachine.Subroutines +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryAdd +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryEq +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryMulAdd +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPolynomial +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryLength +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc +public import Complexitylib.Models.TuringMachine.Subroutines.ClearWork +public import Complexitylib.Models.TuringMachine.Subroutines.CopyOutput +public import Complexitylib.Models.TuringMachine.Subroutines.CopyWorkOutput +public import Complexitylib.Models.TuringMachine.Subroutines.PairEmit +public import Complexitylib.Models.TuringMachine.Subroutines.PairValidate +public import Complexitylib.Models.TuringMachine.Subroutines.PairSplit +public import Complexitylib.Models.TuringMachine.Subroutines.ScanRight +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany +public import Complexitylib.Models.TuringMachine.Subroutines.UnaryLength +public import Complexitylib.Models.TuringMachine.OutputBounds +public import Complexitylib.Models.TuringMachine.SpaceTime +public import Complexitylib.Models.TuringMachine.Placement +public import Complexitylib.Models.TuringMachine.Composition +public import Complexitylib.Models.TuringMachine.Composition.PairWithInput +public import Complexitylib.Models.TuringMachine.Deterministic +public import Complexitylib.Models.TuringMachine.Lift +public import Complexitylib.Models.TuringMachine.Repetition +public import Complexitylib.Models.TuringMachine.Repetition.Correctness +public import Complexitylib.Models.TuringMachine.UTM.Encoding +public import Complexitylib.Models.TuringMachine.UTM.Machine +public import Complexitylib.Models.TuringMachine.UTM.Universal +public import Complexitylib.Models.TuringMachine.UTM.Clock +public import Complexitylib.Models.TuringMachine.UTM.ClockConstructible +public import Complexitylib.Models.TuringMachine.UTM.ClockedUtm +public import Complexitylib.Models.TuringMachine.UTM.HierarchySupport +public import Complexitylib.Models.TuringMachine.UTM.Diagonal +public import Complexitylib.Models.RandomAccessMachine +public import Complexitylib.Models.RoseTreeMachine.Data +public import Complexitylib.Models.RoseTreeMachine.DataEncode +public import Complexitylib.Models.RoseTreeMachine.Prog /-! # Computation models diff --git a/Complexitylib/Models/RandomAccessMachine.lean b/Complexitylib/Models/RandomAccessMachine.lean index f55eb819..d435e814 100644 --- a/Complexitylib/Models/RandomAccessMachine.lean +++ b/Complexitylib/Models/RandomAccessMachine.lean @@ -3,71 +3,67 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Internal -import Complexitylib.Models.RandomAccessMachine.Soundness -import Complexitylib.Models.RandomAccessMachine.Classes -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.ABI -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Containment -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.DenseOverlay -import + +module +public import Complexitylib.Models.RandomAccessMachine.Internal +public import Complexitylib.Models.RandomAccessMachine.Soundness +public import Complexitylib.Models.RandomAccessMachine.Classes +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.ABI +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Containment +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.DenseOverlay +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.DenseInputLookup -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Containment -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.AddressEq -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryAppend -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryDecode -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryEncode -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryCleanup -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryLookup -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryLookupRestore -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMissCopy -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMatch -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryReplace -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScanStep -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScan -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Containment +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.AddressEq +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryAppend +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryDecode +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryEncode +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryCleanup +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryLookup +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryLookupRestore +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMissCopy +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMatch +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryReplace +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScanStep +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScan +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Dense -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Dispatch -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Initialization -import -Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseInit -import +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseInit +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseDecision -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseBounds -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Decision -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordDecode -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordEncode -import Complexitylib.Models.TuringMachine.Subroutines.BinaryEq -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub -import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul -import Complexitylib.Models.RandomAccessMachine.Structured -import Complexitylib.Models.RandomAccessMachine.Structured.Switch.Compiled -import Complexitylib.Models.RandomAccessMachine.Structured.Hamming -import Complexitylib.Models.RandomAccessMachine.Structured.GateEval -import Complexitylib.Models.RandomAccessMachine.Structured.GateStep -import Complexitylib.Models.RandomAccessMachine.Structured.GateStreamStep -import Complexitylib.Models.RandomAccessMachine.Structured.Scanner -import Complexitylib.Models.RandomAccessMachine.Structured.PairValidate -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary -import Complexitylib.Models.RandomAccessMachine.Structured.LastBit -import Complexitylib.Models.RandomAccessMachine.Structured.ThreeSATSyntax -import Complexitylib.Models.RandomAccessMachine.Structured.UnaryDecode -import Complexitylib.Asymptotics -import Complexitylib.Classes.Time +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordDecode +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordEncode +public import Complexitylib.Models.RandomAccessMachine.Structured +public import Complexitylib.Models.RandomAccessMachine.Structured.Switch.Compiled +public import Complexitylib.Models.RandomAccessMachine.Structured.Hamming +public import Complexitylib.Models.RandomAccessMachine.Structured.GateEval +public import Complexitylib.Models.RandomAccessMachine.Structured.GateStep +public import Complexitylib.Models.RandomAccessMachine.Structured.GateStreamStep +public import Complexitylib.Models.RandomAccessMachine.Structured.Scanner +public import Complexitylib.Models.RandomAccessMachine.Structured.PairValidate +public import Complexitylib.Models.RandomAccessMachine.Structured.LastBit +public import Complexitylib.Models.RandomAccessMachine.Structured.ThreeSATSyntax +public import Complexitylib.Models.RandomAccessMachine.Structured.UnaryDecode /-! # Random access machines (surface) @@ -306,6 +302,9 @@ transfers every `RAM.P` decider to `P`; together with the fixed sparse forward simulator this proves `RAM.RegisterStore.Machine.RAM_P_eq_P`. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Classes.lean b/Complexitylib/Models/RandomAccessMachine/Classes.lean index 9cda73b5..0d79e4df 100644 --- a/Complexitylib/Models/RandomAccessMachine/Classes.lean +++ b/Complexitylib/Models/RandomAccessMachine/Classes.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Classes.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Classes.Defs /-! # Random-access-machine complexity classes @@ -12,6 +14,9 @@ This surface exposes the logarithmic-cost RAM time and space classes and their elementary monotonicity properties. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Classes/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Classes/Defs.lean index 811638a5..c1368d2e 100644 --- a/Complexitylib/Models/RandomAccessMachine/Classes/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Classes/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Defs -import Complexitylib.Asymptotics + +module +public import Complexitylib.Models.RandomAccessMachine.Defs +public import Complexitylib.Asymptotics /-! # Random-access-machine complexity classes: definitions @@ -14,6 +16,9 @@ This definitions layer places the logarithmic-cost RAM classes over the same independent of either simulation direction. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Defs.lean index e0614799..1f662d44 100644 --- a/Complexitylib/Models/RandomAccessMachine/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Defs.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Data.Nat.Size -import Mathlib.Algebra.BigOperators.Finprod -import Complexitylib.Models.TuringMachine + +module +public import Mathlib.Algebra.BigOperators.Finprod +public import Complexitylib.Models.TuringMachine +public import Mathlib.Data.Nat.Bits /-! # Random access machines: model and cost measures @@ -74,6 +76,9 @@ two-way simulation bounds are recorded in the surface module program, so a program need not end in `halt` and jumps may target the end. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Internal.lean index 8cff8933..2b7e0ee2 100644 --- a/Complexitylib/Models/RandomAccessMachine/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Internal.lean @@ -3,7 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Defs +public import Mathlib.Tactic.Ring.RingNF /-! # Random access machines: operational metatheory (proof internals) @@ -28,6 +31,9 @@ Not intended for human audit: the definitions in `Defs.lean` and the theorem statements in the surface module carry the mathematical content. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore.lean index a1ef0306..c802a98c 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Defs -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Internal + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Defs +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Internal /-! # Sparse RAM register stores on Turing tapes @@ -21,6 +23,9 @@ bit-width at most `w`, a snapshot with `m` entries occupies at most `(m + 1) * (4 * w + 2)` tape cells. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Containment.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Containment.lean index a7c9fc0c..c41791c1 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Containment.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Containment.lean @@ -3,10 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Containment.Internal -import - Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Containment + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Containment.Internal +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Containment /-! # RAM-to-TM time-class containment @@ -18,6 +18,9 @@ parametric containment. Together with the sparse TM-to-RAM compiler, these establish machine-model robustness of polynomial time. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Containment/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Containment/Defs.lean index cd1d8bc0..42b77368 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Containment/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Containment/Defs.lean @@ -3,10 +3,28 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Bounds.Defs -import Mathlib.Algebra.Polynomial.Eval.Defs -import Mathlib.Tactic +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Defs +public import Mathlib.Analysis.SpecialFunctions.Pow.NNReal +public import Mathlib.Tactic.Measurability.Init +public import Mathlib.Tactic.NormNum.BigOperators +public import Mathlib.Tactic.NormNum.Irrational +public import Mathlib.Tactic.NormNum.IsCoprime +public import Mathlib.Tactic.NormNum.IsSquare +public import Mathlib.Tactic.NormNum.LegendreSymbol +public import Mathlib.Tactic.NormNum.ModEq +public import Mathlib.Tactic.NormNum.NatFactorial +public import Mathlib.Tactic.NormNum.NatFib +public import Mathlib.Tactic.NormNum.NatLog +public import Mathlib.Tactic.NormNum.NatSqrt +public import Mathlib.Tactic.NormNum.Ordinal +public import Mathlib.Tactic.NormNum.Parity +public import Mathlib.Tactic.NormNum.Prime +public import Mathlib.Tactic.NormNum.RealSqrt /-! # RAM-to-TM time-class containment -- definitions @@ -15,6 +33,9 @@ This layer fixes the twenty-work-tape concrete simulator and packages its fourth-degree resource envelope as a natural polynomial. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Containment/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Containment/Internal.lean index d6171cbb..1d457498 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Containment/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Containment/Internal.lean @@ -3,17 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.P.NormalForm -import Complexitylib.Models.RandomAccessMachine.Classes -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Containment.Defs -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Bounds -import + +module +public import Complexitylib.Classes.P.NormalForm +public import Complexitylib.Models.RandomAccessMachine.Classes +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Containment.Defs +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseBounds -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseDecision -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Decision +public import Mathlib.Tactic.ENatToNat +public import Mathlib.Tactic.ReduceModChar +public import Mathlib.Tactic.SetNotationForOrder /-! # RAM-to-TM time-class containment -- proof internals @@ -24,6 +27,9 @@ time. This discharges the quantitative side condition of the checked runtime envelope and lifts the simulation to deterministic polynomial time. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Defs.lean index 9de94006..ea124ef1 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Defs.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Mathlib.NatBits -import Complexitylib.Models.RandomAccessMachine.Defs -import Mathlib.Data.Finset.Sort + +module +public import Complexitylib.Mathlib.NatBits +public import Complexitylib.Models.RandomAccessMachine.Defs +public import Mathlib.Data.Finset.Sort /-! # Sparse RAM register stores on Turing tapes: definitions @@ -25,6 +27,9 @@ Proofs that the store operations implement functional register reads/writes and that every codec round-trips live in the internal module. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/DenseOverlay.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/DenseOverlay.lean index 4c47d18b..dcf31452 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/DenseOverlay.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/DenseOverlay.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.DenseOverlay.Internal /-! @@ -15,6 +17,9 @@ mutable snapshot; positive tags make explicit writes of zero distinguishable from an absent overlay entry. -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/DenseOverlay/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/DenseOverlay/Defs.lean index e5cbbc75..880164f7 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/DenseOverlay/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/DenseOverlay/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Defs /-! # Dense public input with a sparse mutable overlay -- definitions @@ -19,6 +21,9 @@ an explicit write of zero (`tag = 1`). Absent reads fall through to the dense public-input ABI `RAM.initRegs input`. -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/DenseOverlay/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/DenseOverlay/Internal.lean index 769f387d..ed5221bc 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/DenseOverlay/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/DenseOverlay/Internal.lean @@ -3,14 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.DenseOverlay.Defs -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Internal + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.DenseOverlay.Defs +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Internal /-! # Dense public input with a sparse mutable overlay -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Internal.lean index 3fd6a714..4ce0bfb7 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Internal.lean @@ -3,8 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Defs -import Complexitylib.Models.RandomAccessMachine.Internal + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Defs +public import Complexitylib.Models.RandomAccessMachine.Internal +public import Mathlib.Algebra.Order.Ring.Nat /-! # Sparse RAM register stores on Turing tapes: proof internals @@ -13,6 +16,9 @@ This module proves the finite-store semantics and codec round trips exposed by the surface module. It is not part of the human-audited definitions layer. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/AddressEq.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/AddressEq.lean index e8bd9fca..798e8585 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/AddressEq.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/AddressEq.lean @@ -3,10 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.AddressEq.Internal -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Subroutines.ClearWork +public import Complexitylib.Models.TuringMachine.Subroutines.ClearWork /-! # Decoded sparse-address equality @@ -15,6 +16,9 @@ This module exposes the framed linear-time semantics of address rewind and comparison used by the concrete sparse register-store scan. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/AddressEq/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/AddressEq/Defs.lean index 1a8f4fa2..a12b03cc 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/AddressEq/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/AddressEq/Defs.lean @@ -3,7 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryEq.Defs + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryEq.Defs +public import Complexitylib.Models.TuringMachine.Subroutines /-! # Decoded sparse-address equality — definitions @@ -13,6 +16,9 @@ rewinds it and compares it against a canonical query address, writing the Boolean result on a third work tape. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/AddressEq/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/AddressEq/Internal.lean index 2b924732..5c731e11 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/AddressEq/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/AddressEq/Internal.lean @@ -3,16 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.AddressEq.Defs -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordDecode -import Complexitylib.Models.TuringMachine.Combinators.Internal.Seq -import Complexitylib.Models.TuringMachine.Internal -import Complexitylib.Models.TuringMachine.Subroutines.BinaryEq + +module +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.AddressEq.Defs +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordDecode +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryEq /-! # Decoded sparse-address equality — proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/DenseInputLookup.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/DenseInputLookup.lean index 0567de32..9e901056 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/DenseInputLookup.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/DenseInputLookup.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.DenseInputLookup.Internal /-! @@ -13,6 +15,9 @@ This module exposes the fixed leaves used to look through a sparse tagged overlay into the immutable public-input bank. -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/DenseInputLookup/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/DenseInputLookup/Defs.lean index a79f5b79..1e192954 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/DenseInputLookup/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/DenseInputLookup/Defs.lean @@ -3,12 +3,15 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Defs -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch.Defs -import Complexitylib.Models.TuringMachine.Combinators.ForInput.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Defs +public import Complexitylib.Models.TuringMachine.Combinators.WorkBranch.Defs +public import Complexitylib.Models.TuringMachine.Combinators.ForInput.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs /-! # Dense public-input lookup -- definitions @@ -19,6 +22,9 @@ a binary countdown on a work tape. When that countdown first reaches zero, the preceding input symbol is copied to a canonical Boolean result tape. -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/DenseInputLookup/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/DenseInputLookup/Internal.lean index b47dba37..7d332804 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/DenseInputLookup/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/DenseInputLookup/Internal.lean @@ -3,22 +3,23 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.DenseInputLookup.Defs -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch -import Complexitylib.Models.TuringMachine.Combinators.ForInput.Internal -import Complexitylib.Models.TuringMachine.Registers -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc -import Complexitylib.Models.TuringMachine.Subroutines.Internal -import Complexitylib.Models.TuringMachine.Tape.Encoding +public import Complexitylib.Models.TuringMachine.Combinators.WorkBranch +public import Complexitylib.Models.TuringMachine.Combinators.ForInput.Internal +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary /-! # Dense public-input lookup -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryAppend.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryAppend.lean index f9a7cef0..a84d9120 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryAppend.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryAppend.lean @@ -3,16 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryAppend.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryAppend.Internal -import Complexitylib.Models.TuringMachine.Hoare.Space /-! # Sparse-entry final append -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryAppend/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryAppend/Defs.lean index 5cd5583d..f5f0b766 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryAppend/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryAppend/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryReplace.Defs /-! @@ -14,6 +16,9 @@ appended using the preserved query and replacement tapes. Both sources are then restored exactly so the caller retains its canonical work frame. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryAppend/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryAppend/Internal.lean index 57d49ff0..19e0f35f 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryAppend/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryAppend/Internal.lean @@ -3,18 +3,23 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryAppend.Defs -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryEncode -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScan -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryEncode +public import Mathlib.Data.Rat.Cast.Order +public import Mathlib.Tactic.NormNum.Abs +public import Mathlib.Tactic.NormNum.DivMod +public import Mathlib.Tactic.NormNum.OfScientific /-! # Sparse-entry final append — proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryCleanup.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryCleanup.lean index 32144961..9c8691e1 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryCleanup.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryCleanup.lean @@ -3,11 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryCleanup.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryCleanup.Internal -import Complexitylib.Models.TuringMachine.Hoare.Space /-! # Sparse-entry miss cleanup @@ -16,6 +17,9 @@ This module exposes the exact invariant-restoring miss branch used by the bounded sparse register-store scan. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryCleanup/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryCleanup/Defs.lean index baad57c6..9d757102 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryCleanup/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryCleanup/Defs.lean @@ -3,10 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMatch.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany.Defs -import Mathlib.Data.List.FinRange +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany.Defs /-! # Sparse-entry miss cleanup — definitions @@ -16,6 +17,9 @@ scratch tapes while preserving the consumed source cursor and query address. This restores the exact invariant needed to inspect the next encoded entry. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryCleanup/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryCleanup/Internal.lean index 990386d5..104e8c4c 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryCleanup/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryCleanup/Internal.lean @@ -3,17 +3,25 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryCleanup.Defs -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMatch -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany -import Mathlib.Tactic.FinCases +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany +public import Mathlib.Tactic.FinCases +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc +public import Mathlib.Data.Rat.Cast.Order +public import Mathlib.Tactic.NormNum.Abs +public import Mathlib.Tactic.NormNum.DivMod +public import Mathlib.Tactic.NormNum.OfScientific /-! # Sparse-entry miss cleanup — proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryDecode.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryDecode.lean index b742ba71..d7a15400 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryDecode.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryDecode.lean @@ -3,10 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryDecode.Defs -import + +module +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryDecode.Defs +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryDecode.Internal -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryDecode.LinearInternal /-! @@ -16,6 +19,9 @@ This module exposes the exact framed semantics of the concrete two-word sparse address/value decoder. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryDecode/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryDecode/Defs.lean index 1e6442b1..8ba090cf 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryDecode/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryDecode/Defs.lean @@ -3,8 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Defs -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordDecode.Defs + +module +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordDecode.Defs +public import Complexitylib.Models.RandomAccessMachine.Defs +public import Mathlib.Tactic.NormNum.Inv +public import Mathlib.Tactic.NormNum.Pow /-! # RAM sparse-entry decoder — definitions @@ -14,6 +19,9 @@ address and value. `entryDecodeTM` gives each word its own target, counter, and width tapes so the two checked word decoders compose without a clearing phase. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryDecode/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryDecode/Internal.lean index 481bf60f..be6c2e96 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryDecode/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryDecode/Internal.lean @@ -3,15 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryDecode.Defs -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordDecode -import Complexitylib.Models.TuringMachine.Combinators.Internal.Seq -import Complexitylib.Models.TuringMachine.Internal + +module +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryDecode.Defs +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordDecode /-! # RAM sparse-entry decoder — proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryDecode/LinearInternal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryDecode/LinearInternal.lean index 36f9444f..928c4cbf 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryDecode/LinearInternal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryDecode/LinearInternal.lean @@ -3,10 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryDecode.Defs -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordDecode -import Complexitylib.Models.TuringMachine.Combinators.Internal.Seq -import Complexitylib.Models.TuringMachine.Internal + +module +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryDecode.Defs +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordDecode /-! # Linear RAM sparse-entry decoder -- proof internals @@ -16,6 +17,9 @@ The established counter tapes become markers, while the width tapes remain framed for compatibility with the existing sparse-store work-tape layout. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryEncode.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryEncode.lean index 5cda9069..8ebf48c3 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryEncode.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryEncode.lean @@ -3,17 +3,21 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryEncode.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryEncode.Internal -import Complexitylib.Models.TuringMachine.Hoare.RetargetOutput -import Complexitylib.Models.TuringMachine.Hoare.Space +public import Complexitylib.Models.TuringMachine.Hoare.RetargetOutput /-! # Sparse entry emission -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryEncode/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryEncode/Defs.lean index a41f3a50..1fa32cd3 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryEncode/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryEncode/Defs.lean @@ -3,13 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordEncode.Defs +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Defs /-! # Sparse entry emission — definitions -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryEncode/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryEncode/Internal.lean index 9db9c0b1..85e942c6 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryEncode/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryEncode/Internal.lean @@ -3,16 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryEncode.Defs -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordEncode -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordEncode /-! # Sparse entry emission — proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryLookup.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryLookup.lean index 66afca8c..cd14f6ad 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryLookup.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryLookup.lean @@ -3,17 +3,22 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryLookup.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryLookup.Internal -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Source /-! # Sparse register lookup -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryLookup/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryLookup/Defs.lean index 29f20335..7db57953 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryLookup/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryLookup/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScan.Defs /-! @@ -13,6 +15,9 @@ The bounded scanner is already the concrete lookup machine. This module names its semantic endpoint in terms of the pure sparse-store `read` operation. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryLookup/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryLookup/Internal.lean index dd5e4b0e..6f8aafc1 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryLookup/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryLookup/Internal.lean @@ -3,16 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryLookup.Defs -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScan -import Mathlib.Data.Nat.Bitwise +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScan +public import Mathlib.Data.Nat.Bitwise /-! # Sparse register lookup — proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryLookupRestore.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryLookupRestore.lean index d8bb2158..c63f6789 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryLookupRestore.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryLookupRestore.lean @@ -3,11 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Internal.Static -import -Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.DenseInternal -import Complexitylib.Models.TuringMachine.Subroutines.ClearWork + +module +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.DenseInternal /-! # Reusable sparse-register operand lookup @@ -18,6 +17,9 @@ semantic value out, resets every scanner-owned tape, rewinds the read-only source, restores the runtime entry count, and returns to the same scanner ABI. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMatch.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMatch.lean index 38282e55..26aa0055 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMatch.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMatch.lean @@ -3,11 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMatch.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMatch.Internal -import Complexitylib.Models.TuringMachine.Hoare.Space /-! # RAM sparse-entry matching @@ -16,6 +17,9 @@ This module exposes the exact framed semantics of the concrete decode-and-match unit used by a bounded sparse register-store scan. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMatch/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMatch/Defs.lean index 48e830f2..e4afbe88 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMatch/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMatch/Defs.lean @@ -3,11 +3,14 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.AddressEq.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryDecode.Defs -import Complexitylib.Models.TuringMachine.Registers +public import Complexitylib.Models.TuringMachine.Registers +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Defs /-! # RAM sparse-entry matching — definitions @@ -17,6 +20,9 @@ It decodes one address/value entry and compares the decoded address with a preserved canonical query. The result is appended to a dedicated work tape. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMatch/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMatch/Internal.lean index 46b400eb..f8fcd854 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMatch/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMatch/Internal.lean @@ -3,19 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.AddressEq -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryDecode -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.AddressEq +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryDecode +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMatch.Defs -import Complexitylib.Models.TuringMachine.Combinators.Internal.Seq -import Complexitylib.Models.TuringMachine.Internal /-! # RAM sparse-entry matching — proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMissCopy.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMissCopy.lean index 3e94ce1a..9ddd0b71 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMissCopy.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMissCopy.lean @@ -3,11 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMissCopy.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMissCopy.Internal -import Complexitylib.Models.TuringMachine.Hoare.Space /-! # Sparse-entry miss copy @@ -16,6 +17,9 @@ This module exposes the update-scan branch that appends one unmatched entry to the new store and restores the exact invariant needed to inspect the next one. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMissCopy/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMissCopy/Defs.lean index 21d8608e..3b5a639b 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMissCopy/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMissCopy/Defs.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryCleanup.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryEncode.Defs /-! @@ -16,6 +18,9 @@ emits the decoded address/value pair to the output stream and then restores the ordinary next-entry scan invariant. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMissCopy/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMissCopy/Internal.lean index 165f68e9..4c9f0d75 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMissCopy/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryMissCopy/Internal.lean @@ -3,17 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMissCopy.Defs -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryCleanup -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryEncode +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryCleanup +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryEncode /-! # Sparse-entry miss copy — proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryReplace.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryReplace.lean index 607218c3..d0e6b9fb 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryReplace.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryReplace.lean @@ -3,16 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryReplace.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryReplace.Internal -import Complexitylib.Models.TuringMachine.Hoare.Space /-! # Sparse-entry replacement -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryReplace/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryReplace/Defs.lean index f18b7ca2..643da7f9 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryReplace/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryReplace/Defs.lean @@ -3,11 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryCleanup.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryEncode.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary.Defs /-! # Sparse-entry replacement — definitions @@ -17,6 +18,9 @@ canonical new-value tape, rewinds that external value source, and restores the ordinary next-entry scan invariant. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryReplace/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryReplace/Internal.lean index ba2a7716..07719fa6 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryReplace/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryReplace/Internal.lean @@ -3,18 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryReplace.Defs -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryCleanup -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryEncode -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryCleanup +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryEncode /-! # Sparse-entry replacement — proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan.lean index 60a66888..8d17f7f6 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan.lean @@ -3,13 +3,14 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScan.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScan.Internal.Sem -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScan.Internal.Bounds -import Complexitylib.Models.TuringMachine.Hoare.Space /-! # Bounded sparse-entry scan @@ -19,6 +20,9 @@ store scanner. The runtime entry count is read from a canonical binary tape; it is not hardwired into the finite controller. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan/Defs.lean index e1becb0d..b0c16950 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan/Defs.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScanStep.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred.Defs /-! # Bounded sparse-entry scan — definitions @@ -17,6 +19,9 @@ miss restores scratch, decrements the count, and loops. Count zero halts with the blank miss result. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan/Internal/Bounds.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan/Internal/Bounds.lean index 3fc37c03..19e14b19 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan/Internal/Bounds.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan/Internal/Bounds.lean @@ -3,13 +3,15 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMatch.Internal -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScan.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany /-! # Encoded-length bounds for sparse-entry scans -- proof internals @@ -19,6 +21,9 @@ matching, and cleanup linear in the two words actually traversed. The final scan theorem retains only the separate binary remaining-count charge. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan/Internal/Ctrl.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan/Internal/Ctrl.lean index 8c9a21bf..88ce2e1f 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan/Internal/Ctrl.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan/Internal/Ctrl.lean @@ -3,14 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScan.Defs -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic /-! # Bounded sparse-entry scan — controller internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan/Internal/Inv.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan/Internal/Inv.lean index f2815956..5dbaf47f 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan/Internal/Inv.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan/Internal/Inv.lean @@ -3,17 +3,24 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScan.Defs -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScanStep -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany -import Mathlib.Tactic.FinCases +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany +public import Mathlib.Tactic.FinCases +public import Mathlib.Data.Rat.Cast.Order +public import Mathlib.Tactic.NormNum.Abs +public import Mathlib.Tactic.NormNum.DivMod +public import Mathlib.Tactic.NormNum.OfScientific /-! # Bounded sparse-entry scan — invariant internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan/Internal/Sem.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan/Internal/Sem.lean index 0c01baa3..1c2ccee3 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan/Internal/Sem.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScan/Internal/Sem.lean @@ -3,17 +3,24 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScan.Internal.Ctrl -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScan.Internal.Inv -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred +public import Complexitylib.Models.TuringMachine.Combinators.WorkBranch +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScanStep /-! # Bounded sparse-entry scan — semantic internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScanStep.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScanStep.lean index 63993d1c..9963eb67 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScanStep.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScanStep.lean @@ -3,11 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScanStep.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScanStep.Internal -import Complexitylib.Models.TuringMachine.Hoare.Space /-! # One bounded sparse-entry scan iteration @@ -16,6 +17,9 @@ This module exposes the compositional hit-or-next-iteration contract for one encoded sparse register-store entry. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScanStep/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScanStep/Defs.lean index cd856a3f..455dcf28 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScanStep/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScanStep/Defs.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryCleanup.Defs -import Complexitylib.Models.TuringMachine.Combinators.WorkSymbolBranch.Defs +public import Complexitylib.Models.TuringMachine.Combinators.WorkSymbolBranch.Defs /-! # One bounded sparse-entry scan iteration — definitions @@ -15,6 +17,9 @@ readable equality flag, preserves the decoded value on a hit, and restores the next-iteration scratch invariant on a miss. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScanStep/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScanStep/Internal.lean index 7d16e700..ace9736b 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScanStep/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryScanStep/Internal.lean @@ -3,16 +3,21 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryCleanup -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryCleanup +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScanStep.Defs -import Complexitylib.Models.TuringMachine.Combinators.WorkSymbolBranch +public import Complexitylib.Models.TuringMachine.Combinators.WorkSymbolBranch +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMatch /-! # One bounded sparse-entry scan iteration — proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate.lean index 63e1fc65..29c19216 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate.lean @@ -3,18 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Internal.Out -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Internal.Sem -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.BoundsInternal -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Source -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Hoare.RetargetOutput /-! # Bounded encoded sparse-store update @@ -25,6 +25,9 @@ copies misses, replaces or deletes the unique hit, and appends a fresh nonzero entry exactly when the address was absent. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/BoundsInternal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/BoundsInternal.lean index 3a578da1..4314f798 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/BoundsInternal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/BoundsInternal.lean @@ -3,13 +3,15 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMatch.Internal -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany /-! # Encoded-length sparse-update bounds -- proof internals @@ -19,6 +21,9 @@ at each iteration. With unary-marker decoding, each such reservation is still linear in the current entry and the instruction's query/replacement widths. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Defs.lean index 2392901c..90e0e7ba 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Defs.lean @@ -3,12 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryAppend.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMissCopy.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred.Defs /-! # Bounded encoded sparse-store update — controller definitions @@ -19,6 +20,9 @@ appending a fresh nonzero entry only when the old count is exhausted without a match. A second count tape tracks the output-store cardinality. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Ctrl.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Ctrl.lean index 25e729c7..477ee886 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Ctrl.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Ctrl.lean @@ -3,14 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Defs -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic /-! # Bounded encoded sparse-store update — controller internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/End.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/End.lean index b8442e7c..d6d37791 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/End.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/End.lean @@ -3,13 +3,15 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Internal.Loop -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Internal.Out -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Internal.Time -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch +public import Complexitylib.Models.TuringMachine.Combinators.WorkBranch /-! # Bounded encoded sparse-store update -- terminal loop case @@ -19,6 +21,9 @@ previous hit and an absent zero write halt immediately; an absent nonzero write runs the checked append and result-count successor subroutines. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Hit.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Hit.lean index ba7119d6..8ac5f0af 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Hit.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Hit.lean @@ -3,23 +3,15 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryCleanup -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMatch -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryReplace -import -Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Internal.Ctrl -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Internal.Inv -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Internal.Loop -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Internal.Out -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Internal.Time -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred +public import Complexitylib.Models.TuringMachine.Combinators.WorkBranch /-! # Bounded encoded sparse-store update -- matching iterations @@ -29,6 +21,9 @@ subroutines for the two branches in which the current old entry has the requested address. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Inv.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Inv.lean index 4bd0febe..7352bb71 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Inv.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Inv.lean @@ -3,12 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Internal.Ctrl -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScan.Internal.Inv -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc /-! # Bounded encoded sparse-store update — invariant internals @@ -18,6 +19,9 @@ particular, this file isolates the only controller-local mutation: changing the canonical zero-valued `found` tape to canonical one after a hit. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Loop.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Loop.lean index d8ba5696..847bd94b 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Loop.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Loop.lean @@ -3,15 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Progress -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Internal.Inv /-! # Bounded encoded sparse-store update — loop invariant internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Miss.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Miss.lean index 5a708836..dc3dfa61 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Miss.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Miss.lean @@ -3,25 +3,24 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMatch -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMissCopy -import -Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Internal.Ctrl -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Internal.Loop -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Internal.Out -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Internal.Time -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred -import Mathlib.Data.Nat.Bitwise +public import Mathlib.Data.Nat.Bitwise +public import Complexitylib.Models.TuringMachine.Combinators.WorkBranch /-! # Bounded encoded sparse-store update -- unmatched entry iteration -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Out.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Out.lean index ba7faefa..f0898fbc 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Out.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Out.lean @@ -3,16 +3,16 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Defs -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryAppend -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryAppend +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMissCopy -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryReplace -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryReplace +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMatch /-! # Bounded encoded sparse-store update — output safety internals @@ -22,6 +22,9 @@ one-way-output machine. Its own dispatch transitions either read back or leave the output head idle, so the complete controller remains a transducer. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Sem.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Sem.lean index 4e26fe21..baeb457b 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Sem.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Sem.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Internal.Step -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Internal.End /-! @@ -17,6 +19,9 @@ store, while the loop invariant carries the processed prefix and emitted output needed to connect the concrete controller to `RegisterStore.write`. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Step.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Step.lean index 0483ac74..fc5271a3 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Step.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Step.lean @@ -3,15 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Internal.Hit -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Internal.Miss /-! # Bounded encoded sparse-store update -- one positive iteration -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Time.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Time.lean index b60d07f2..7b81aea7 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Time.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Internal/Time.lean @@ -3,16 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryMissCopy -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryReplace -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScan.Internal.Inv -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany +public import Mathlib.Data.Rat.Cast.Order +public import Mathlib.Tactic.FinCases +public import Mathlib.Tactic.NormNum.Abs +public import Mathlib.Tactic.NormNum.DivMod +public import Mathlib.Tactic.NormNum.OfScientific /-! # Bounded encoded sparse-store update — static runtime bounds @@ -23,6 +25,9 @@ boundary: a ready loop invariant fixes every owned starting head, while a readable match bounds the one cursor whose endpoint is intentionally in-place. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Progress.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Progress.lean index e846efc0..e00fb8b7 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Progress.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Progress.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Defs /-! # Bounded encoded sparse-store update — progress invariant internals @@ -15,6 +16,9 @@ entries already emitted by the machine, independently of the tape-level simulation proof. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Source.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Source.lean index 69a3cb5b..fee96017 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Source.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Source.lean @@ -3,12 +3,14 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScan.Defs -import Complexitylib.Models.TuringMachine.Combinators.WorkSymbolBranch.Defs -import Complexitylib.Models.TuringMachine.WorkReadOnly +public import Complexitylib.Models.TuringMachine.WorkReadOnly +public import Std.Tactic.BVDecide.Normalize.BitVec /-! # Sparse-store update source preservation @@ -18,6 +20,9 @@ source cells. This file packages that local transition fact as a reusable read-only certificate. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Tagged.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Tagged.lean index 08ac9657..75b5bd60 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Tagged.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/Tagged.lean @@ -3,13 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.TaggedProof /-! # Positive-tag sparse updates -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/TaggedDefs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/TaggedDefs.lean index 2bd19c76..a7ed69a8 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/TaggedDefs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/TaggedDefs.lean @@ -3,11 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Defs -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.DenseOverlay.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs /-! # Positive-tag sparse updates @@ -17,6 +16,9 @@ value `v + 1`. This module packages successor followed by the existing sparse update controller as one reusable write-side kernel. -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/TaggedProof.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/TaggedProof.lean index 734248bf..9be8d7ef 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/TaggedProof.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/EntryUpdate/TaggedProof.lean @@ -3,16 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.TaggedDefs -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.DenseOverlay.Defs /-! # Positive-tag sparse updates -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction.lean index 4816e4be..4cdbbdf1 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction.lean @@ -3,21 +3,22 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Internal -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Direct -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Load -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Immediate -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Store -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Control -import Complexitylib.Models.TuringMachine.Hoare.RetargetOutput /-! # Concrete sparse-store arithmetic instruction kernel @@ -28,6 +29,9 @@ binary machine and the result is committed by the fixed encoded-store update controller. A redirected form writes the new store to a fresh work buffer. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Control.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Control.lean index 5edda91f..5e66c041 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Control.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Control.lean @@ -3,14 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryLookupRestore -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary /-! # Sparse-store control instructions @@ -20,6 +18,9 @@ over the reusable sparse-lookup ABI and a disjoint canonical binary program- counter tape. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Defs.lean index 9535a8a6..5acd6dba 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Defs.lean @@ -3,17 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Defs -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Defs -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary.Defs -import Mathlib.Tactic.FinCases +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul.Defs /-! # Concrete sparse-store arithmetic instruction kernel @@ -25,6 +21,9 @@ controller's replacement tape, so no value-sized bridge is hidden between the two phases. -/ + +@[expose] public section + namespace Complexity namespace RAM @@ -145,7 +144,8 @@ private theorem lhsLookupSlot_injective : Function.Injective lhsLookupSlot := by def lhsLookup {n : ℕ} (tapes : BinaryInstructionTapes n) : EntryLookupRestoreTapes n where idx := fun i => tapes.idx (lhsLookupSlot i) - injective := fun _ _ h => lhsLookupSlot_injective (tapes.injective h) + injective := fun _ _ h => by + exact lhsLookupSlot_injective (tapes.injective h) /-- Parent slots for a reusable lookup whose destination is `rhs`. -/ def rhsLookupSlot (i : Fin 14) : Fin 18 := @@ -173,7 +173,8 @@ private theorem rhsLookupSlot_injective : Function.Injective rhsLookupSlot := by def rhsLookup {n : ℕ} (tapes : BinaryInstructionTapes n) : EntryLookupRestoreTapes n where idx := fun i => tapes.idx (rhsLookupSlot i) - injective := fun _ _ h => rhsLookupSlot_injective (tapes.injective h) + injective := fun _ _ h => by + exact rhsLookupSlot_injective (tapes.injective h) @[simp] theorem lhsLookup_count {n : ℕ} (tapes : BinaryInstructionTapes n) : tapes.lhsLookup.idx 9 = tapes.update.remaining := rfl @@ -283,7 +284,8 @@ private theorem indirectLoadLookupSlot_injective : def indirectLoadLookup {n : ℕ} (tapes : BinaryInstructionTapes n) : EntryLookupRestoreTapes n where idx := fun i => tapes.idx (indirectLoadLookupSlot i) - injective := fun _ _ h => indirectLoadLookupSlot_injective (tapes.injective h) + injective := fun _ _ h => by + exact indirectLoadLookupSlot_injective (tapes.injective h) @[simp] theorem indirectLoadLookup_count {n : ℕ} (tapes : BinaryInstructionTapes n) : @@ -324,7 +326,7 @@ private theorem mulSlot_injective : Function.Injective mulSlot := by def mul {n : ℕ} (tapes : BinaryInstructionTapes n) : TM.BinaryShiftMulABI n where tape := ⟨fun i => tapes.idx (mulSlot i), fun _ _ h => - mulSlot_injective (tapes.injective h)⟩ + by exact mulSlot_injective (tapes.injective h)⟩ @[simp] theorem mul_lhs {n : ℕ} (tapes : BinaryInstructionTapes n) : tapes.mul.lhs = tapes.lhs := rfl diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Dense.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Dense.lean index 6c2c0b66..2da1c473 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Dense.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Dense.lean @@ -3,16 +3,14 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseControl -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseDirect -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseImm -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseLoad -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseStore + +module +public import Mathlib.Data.Finset.Attr +public import Mathlib.Data.Rat.Cast.Order +public import Mathlib.Tactic.NormNum.Abs +public import Mathlib.Tactic.NormNum.DivMod +public import Mathlib.Tactic.NormNum.OfScientific +public import Mathlib.Tactic.NormNum.Pow /-! # Dense-overlay RAM instruction kernels diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseControl.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseControl.lean index 688607fa..c471c77e 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseControl.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseControl.lean @@ -3,15 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseDefs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Control /-! # Dense-overlay control instructions -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseCtrlSim.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseCtrlSim.lean index 1005277e..a521e5a9 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseCtrlSim.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseCtrlSim.lean @@ -3,17 +3,22 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseControl -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseSimDefs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Sim.Control /-! # Dense-overlay control-instruction simulation -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseDefs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseDefs.lean index 19627964..b778a5be 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseDefs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseDefs.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.TaggedDefs /-! @@ -16,6 +18,9 @@ the immutable public input in place. Reads use the dense-overlay lookup and writes successor-tag their actual value before sparse update. -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseDirect.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseDirect.lean index 37caacd4..2bf01f0d 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseDirect.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseDirect.lean @@ -3,17 +3,24 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseDefs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Direct -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Tagged +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.DenseInternal /-! # Dense-overlay direct arithmetic instructions -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseDispatch.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseDispatch.lean index 2362af4f..e471c7fd 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseDispatch.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseDispatch.lean @@ -3,20 +3,21 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import -Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseSim -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.DenseOverlay -import + +module +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseSim +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.DenseOverlay +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Sim.Internal -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary /-! # Fixed-program dense-overlay dispatch -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseImm.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseImm.lean index 81249a26..f1500b7a 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseImm.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseImm.lean @@ -3,17 +3,22 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseDefs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Immediate -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Tagged /-! # Dense-overlay immediate instruction -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseLoad.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseLoad.lean index 4031382f..25e8354c 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseLoad.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseLoad.lean @@ -3,17 +3,24 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseDefs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Load -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate.Tagged +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.DenseInternal /-! # Dense-overlay indirect load -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseSim.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseSim.lean index b72c4689..021c3532 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseSim.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseSim.lean @@ -3,15 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import -Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseCtrlSim -import + +module +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseCtrlSim +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseSimData /-! # Dense-overlay instruction simulation -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseSimData.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseSimData.lean index 864bfde6..406a3726 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseSimData.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseSimData.lean @@ -3,17 +3,26 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Dense -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseSimDefs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Sim.Data +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseImm +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseLoad +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseStore /-! # Dense-overlay data-instruction simulation -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore @@ -229,7 +238,7 @@ theorem denseExecuteInstructionTM_imm_hoareTime_frame /-- Instruction constructor corresponding to a dense direct arithmetic kernel. -/ -private def denseDirectInstruction (op : BinaryInstrOp) +def denseDirectInstruction (op : BinaryInstrOp) (destination source₀ source₁ : ℕ) : Instr := match op with | .add => .add destination source₀ source₁ diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseSimDefs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseSimDefs.lean index 43ecf8bd..342c7af3 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseSimDefs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseSimDefs.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseDefs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Sim.Defs /-! @@ -15,6 +17,9 @@ These definitions connect the dense instruction kernels to the existing fixed-program selector and representation-independent buffered cleanup pass. -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseStore.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseStore.lean index 393d56a7..167bc9c4 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseStore.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/DenseStore.lean @@ -3,14 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseDirect -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy /-! # Dense-overlay indirect store -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Direct.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Direct.lean index 229a4d2f..0ffe70b8 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Direct.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Direct.lean @@ -3,16 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Internal -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryLookupRestore -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Internal.Static /-! # Direct sparse-store arithmetic instructions -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Dispatch.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Dispatch.lean index c2fec7c2..8f2da708 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Dispatch.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Dispatch.lean @@ -3,20 +3,16 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Sim.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Sim.Control -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Sim.Data -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Sim.Internal -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred /-! # Fixed-program sparse RAM dispatch @@ -28,6 +24,9 @@ all-prefix space certificates; semantic selection is proved in the internal execution layer. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Immediate.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Immediate.lean index c98f1465..2b64d001 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Immediate.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Immediate.lean @@ -3,14 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Internal -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Defs /-! # Immediate sparse-store instructions -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Internal.lean index 200ad5c0..f395a41d 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Internal.lean @@ -3,18 +3,21 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Defs -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub -import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul /-! # Concrete sparse-store arithmetic instruction kernel -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Load.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Load.lean index 89b06ba0..7d3ac854 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Load.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Load.lean @@ -3,16 +3,21 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Internal -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryLookupRestore -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Defs +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Internal.Static /-! # Indirect sparse-store load instructions -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Sim/Control.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Sim/Control.lean index d307c630..b6451615 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Sim/Control.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Sim/Control.lean @@ -3,16 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Sim.Defs -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction -import Complexitylib.Models.TuringMachine.Subroutines.CopyWorkOutput +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction +public import Complexitylib.Models.TuringMachine.Subroutines.CopyWorkOutput /-! # Uniform next-store buffering for control instructions -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Sim/Data.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Sim/Data.lean index 4d1e3bb1..f5c8c70e 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Sim/Data.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Sim/Data.lean @@ -3,16 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Sim.Defs -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction -import Complexitylib.Models.TuringMachine.Hoare.RetargetOutput +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction /-! # Uniform next-store buffering for data instructions -/ + +@[expose] public section + namespace Complexity namespace RAM @@ -543,7 +546,7 @@ private theorem retargetDataKernel_hoareTime_frame_internal dataTM dataTime Result hready hbase hresult /-- Instruction constructor corresponding to a direct arithmetic kernel. -/ -private def directInstruction (op : BinaryInstrOp) (destination source₀ +def directInstruction (op : BinaryInstrOp) (destination source₀ source₁ : ℕ) : Instr := match op with | .add => .add destination source₀ source₁ diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Sim/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Sim/Defs.lean index 80701640..08e2a6b5 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Sim/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Sim/Defs.lean @@ -3,14 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Defs -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch.Defs -import Complexitylib.Models.TuringMachine.Lift -import Complexitylib.Models.TuringMachine.Subroutines -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany.Defs +public import Complexitylib.Models.TuringMachine.Lift /-! # Fixed-program sparse RAM instruction dispatch -- definitions @@ -21,6 +18,9 @@ store there. A binary copy of the program counter is then decremented through a fixed finite branch tree, so the resulting TM depends only on the RAM program. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Sim/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Sim/Internal.lean index 16b88a10..cdac41b2 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Sim/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Sim/Internal.lean @@ -3,21 +3,23 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Sim.Defs -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore +public import Complexitylib.Models.TuringMachine.Combinators.WorkBranch +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany /-! # Fixed-program dispatch -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Store.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Store.lean index 58ff3418..7a883d9d 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Store.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Instruction/Store.lean @@ -3,14 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Direct -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy /-! # Indirect sparse-store instructions -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Defs.lean index 9071701c..da34a075 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Defs.lean @@ -3,17 +3,15 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryLookup.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.DenseInputLookup.Defs -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.DenseOverlay.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany.Defs -import Mathlib.Tactic.FinCases +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.DenseOverlay.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst.Defs +public import Mathlib.Tactic.FinCases /-! # Reusable sparse-register operand lookup -- definitions @@ -24,6 +22,9 @@ canonical source, scans the encoded store, copies out the decoded value, resets all scanner scratch, rewinds the source, and restores the runtime entry count. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/DenseInternal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/DenseInternal.lean index e0475dad..39859537 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/DenseInternal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/DenseInternal.lean @@ -3,16 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Internal.Static -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.DenseInputLookup.Internal -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred /-! # Dense overlay lookup -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Assemble.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Assemble.lean index 9cd0c534..37062b5d 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Assemble.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Assemble.lean @@ -3,15 +3,24 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Internal.Prepare -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Internal.Restore +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Internal.Scan +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Internal.Value /-! # Reusable sparse-register lookup -- phase assembly -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Bounds.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Bounds.lean index a5aebcaf..5fd7cf96 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Bounds.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Bounds.lean @@ -3,13 +3,17 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Defs /-! # Reusable sparse-register lookup -- reset bounds -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Prepare.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Prepare.lean index 89a58a33..34c915f7 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Prepare.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Prepare.lean @@ -3,14 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy /-! # Reusable sparse-register lookup -- query preparation -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Reset.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Reset.lean index ab0356b6..e3acf221 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Reset.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Reset.lean @@ -3,16 +3,22 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryLookup -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Internal.Bounds -import Mathlib.Tactic.FinCases +public import Mathlib.Data.Rat.Cast.Order +public import Mathlib.Tactic.NormNum.Abs +public import Mathlib.Tactic.NormNum.DivMod +public import Mathlib.Tactic.NormNum.OfScientific /-! # Reusable sparse-register lookup -- reset certificates -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Restore.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Restore.lean index ca46d557..e0301bdc 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Restore.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Restore.lean @@ -3,14 +3,23 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Internal.Value -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany + +module +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy +public import Mathlib.Data.Rat.Cast.Order +public import Mathlib.Tactic.NormNum.Abs +public import Mathlib.Tactic.NormNum.DivMod +public import Mathlib.Tactic.NormNum.OfScientific /-! # Reusable sparse-register lookup -- scanner restoration -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Scan.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Scan.lean index 80dca499..abb5bb36 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Scan.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Scan.lean @@ -3,15 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryLookup -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryLookup +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Internal.Reset /-! # Reusable sparse-register lookup -- bounded scan phase -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Static.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Static.lean index 3a121611..ecb8900d 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Static.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Static.lean @@ -3,15 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Internal.Assemble -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst /-! # Fixed-address sparse-register lookup -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Value.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Value.lean index da2deb2e..bb6eed6c 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Value.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Lookup/Internal/Value.lean @@ -3,14 +3,22 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Internal.Scan -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Lookup.Defs +public import Mathlib.Data.Rat.Cast.Order +public import Mathlib.Tactic.NormNum.Abs +public import Mathlib.Tactic.NormNum.DivMod +public import Mathlib.Tactic.NormNum.OfScientific /-! # Reusable sparse-register lookup -- value rewind and copy -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program.lean index f09fe595..a098d0d5 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Defs -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Defs +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Internal /-! @@ -16,6 +17,9 @@ finite decrementing selector, restores its scratch, and writes `1` exactly when the selected instruction is `halt`. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Bounds.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Bounds.lean index f8e4fbe2..15c565a5 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Bounds.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Bounds.lean @@ -3,15 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Bounds.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Bounds.Internal /-! # Sparse RAM decision-machine resource bounds -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Bounds/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Bounds/Defs.lean index d5791708..cca9f8f8 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Bounds/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Bounds/Defs.lean @@ -3,8 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Decision.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Defs +public import Mathlib.Tactic.NormNum.Inv +public import Mathlib.Tactic.NormNum.Pow /-! # Sparse RAM decision-machine resource-bound definitions @@ -18,6 +21,9 @@ class-transfer theorem independent of low-level controller constants while still recording a genuine polynomial simulation. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Bounds/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Bounds/Internal.lean index 38895eab..a45f8fd6 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Bounds/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Bounds/Internal.lean @@ -3,17 +3,24 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Bounds.Defs -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Decision -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany -import Mathlib.Tactic.Linarith +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Decision.Defs +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Init.Internal +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Internal /-! # Sparse RAM decision-machine resource-bound proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Decision.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Decision.lean index c265bd81..32a9016a 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Decision.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Decision.lean @@ -3,15 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Decision.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DecisionInternal /-! # Complete sparse RAM decision machine -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Decision/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Decision/Defs.lean index 540e4175..236e695b 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Decision/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Decision/Defs.lean @@ -3,13 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Init.Defs /-! # Complete sparse RAM decision machine -- definitions -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DecisionInternal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DecisionInternal.lean index 7f2b069f..59ae4405 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DecisionInternal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DecisionInternal.lean @@ -3,15 +3,22 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Decision.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Init.Internal +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Internal /-! # Complete sparse RAM decision-machine proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Defs.lean index b33026fb..7e60fec1 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Defs.lean @@ -3,12 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Sim.Defs -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary.Defs /-! # Sparse RAM program controller -- definitions @@ -19,6 +17,9 @@ walks the same decrementing finite branch tree as instruction dispatch, and writes `1` exactly for a selected `halt`; every continuing branch writes blank. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Dense.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Dense.lean index df70378a..d95b70f1 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Dense.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Dense.lean @@ -3,15 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseDefs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseInternal /-! # Dense-overlay RAM program controller -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseBounds.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseBounds.lean index cc21c3e6..6161421f 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseBounds.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseBounds.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseBoundsDefs -import -Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseBoundsProof +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseBoundsProof /-! # Dense-overlay RAM decision-machine resource bounds @@ -16,6 +18,9 @@ quadratic loop bound, and the complete quadratic decision bound for the optimized dense-input RAM simulator. -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseBoundsDefs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseBoundsDefs.lean index b683112f..fbefebb4 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseBoundsDefs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseBoundsDefs.lean @@ -3,10 +3,15 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Bounds.Defs -import -Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseDecisionDefs +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.DenseOverlay.Defs +public import Mathlib.Data.Rat.Cast.Order +public import Mathlib.Tactic.NormNum.Abs +public import Mathlib.Tactic.NormNum.DivMod +public import Mathlib.Tactic.NormNum.OfScientific /-! # Dense-overlay RAM decision-machine resource-bound definitions @@ -16,6 +21,9 @@ width charged by the instruction actually selected at the current program counter. This is the local product that sums quadratically over a run. -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseBoundsProof.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseBoundsProof.lean index ff60c0a5..7fc1603d 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseBoundsProof.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseBoundsProof.lean @@ -3,23 +3,26 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseBoundsDefs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Bounds -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryScan -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryUpdate -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.DenseInputLookup -import Mathlib.Algebra.Order.BigOperators.Group.Finset -import Mathlib.Tactic.Linarith +public import Mathlib.Algebra.Order.BigOperators.Group.Finset +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.DenseOverlay +public import +Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseDecisionDefs /-! # Dense-overlay RAM decision-machine resource-bound proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseDecision.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseDecision.lean index 5eee257f..39784213 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseDecision.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseDecision.lean @@ -3,15 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseDecisionDefs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseDecisionProof /-! # Complete dense-overlay RAM decision machine -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseDecisionDefs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseDecisionDefs.lean index db11c39c..095bc3f9 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseDecisionDefs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseDecisionDefs.lean @@ -3,15 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseDefs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseInitDefs /-! # Complete dense-overlay RAM decision machine -- definitions -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseDecisionProof.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseDecisionProof.lean index 3d2fedfb..f39b98d7 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseDecisionProof.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseDecisionProof.lean @@ -3,17 +3,22 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseDecisionDefs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseInitProof -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseInternal /-! # Complete dense-overlay RAM decision-machine proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseDefs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseDefs.lean index af6a3419..3276fabe 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseDefs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseDefs.lean @@ -3,15 +3,23 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import -Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseDispatch -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Defs +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseSimDefs +public import Mathlib.Data.Rat.Cast.Order +public import Mathlib.Tactic.NormNum.Abs +public import Mathlib.Tactic.NormNum.DivMod +public import Mathlib.Tactic.NormNum.OfScientific /-! # Dense-overlay RAM program controller -- definitions -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseInit.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseInit.lean index 72ab6cfa..e622523e 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseInit.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseInit.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseInitDefs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseInitProof /-! @@ -16,6 +18,9 @@ materializes only the positive-tagged length register, installs the reusable program ABI, and rewinds the input for dense fallback reads. -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseInitDefs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseInitDefs.lean index f31f3fa3..9c015af6 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseInitDefs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseInitDefs.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Init.Defs -import Complexitylib.Models.TuringMachine.Subroutines /-! # Dense-overlay public-input initialization -- definitions @@ -15,6 +16,9 @@ the tagged `R₀` overlay entry. It then installs the ordinary sparse scanner AB and rewinds the real input for dense fallback reads. -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseInitProof.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseInitProof.lean index 277f89c1..82da8850 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseInitProof.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseInitProof.lean @@ -3,16 +3,23 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseInitDefs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Init.Internal -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.DenseOverlay +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.DenseOverlay +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Internal /-! # Dense-overlay public-input initialization -- proofs -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseInternal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseInternal.lean index 1f8d28b7..4bdb5787 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseInternal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/DenseInternal.lean @@ -3,15 +3,21 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.DenseDefs -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program +public import +Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.DenseDispatch /-! # Dense-overlay RAM program controller -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM namespace RegisterStore diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Init/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Init/Defs.lean index 6ae55b52..41d327ba 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Init/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Init/Defs.lean @@ -3,16 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Defs -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryEncode.Defs -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Defs /-! # Sparse RAM public-input initialization definitions @@ -24,6 +17,9 @@ appends the nonzero length register `R₀`. The resulting order need not equal RAM register file. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Init/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Init/Internal.lean index 12327e53..522243f4 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Init/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Init/Internal.lean @@ -3,27 +3,28 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Init.Defs -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryEncode -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Internal -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Hoare.RetargetOutput -import Complexitylib.Models.TuringMachine.Internal -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany -import Complexitylib.Models.TuringMachine.Subroutines.Internal +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.EntryEncode +public import Complexitylib.Models.TuringMachine.Combinators.WorkBranch +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore +public import Mathlib.Data.Rat.Cast.Order +public import Mathlib.Tactic.NormNum.Abs +public import Mathlib.Tactic.NormNum.DivMod +public import Mathlib.Tactic.NormNum.OfScientific /-! # Sparse RAM public-input initialization -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Initialization.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Initialization.lean index 25b52fa0..ca647f36 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Initialization.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Initialization.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Init.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Init.Internal /-! @@ -16,6 +18,9 @@ sparse store, installs the optional length register, and produces the exact clean work-tape image consumed by the reusable RAM program controller. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Internal.lean index a3c5c86a..79b11cdb 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/Program/Internal.lean @@ -3,19 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Defs -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Program.Defs +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.Instruction.Dispatch -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Loop /-! # Sparse RAM program controller -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordDecode.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordDecode.lean index 1a0590ed..d88e2a3f 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordDecode.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordDecode.lean @@ -3,12 +3,15 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordDecode.Defs -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordDecode.Internal -import + +module +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordDecode.Defs +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordDecode.Internal +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordDecode.LinearInternal -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Defs -import Complexitylib.Models.TuringMachine.Hoare.Space +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Defs /-! # RAM snapshot word-width decoder @@ -19,6 +22,9 @@ zero separator and leaves the unary-prefix length as a canonical binary natural on a separate work tape. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordDecode/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordDecode/Defs.lean index 0606fe6d..f3b59c0f 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordDecode/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordDecode/Defs.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.ForWorkOnes.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs + +module +public import Complexitylib.Models.TuringMachine.Combinators.ForWorkOnes.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Defs /-! # RAM snapshot word-width decoder — definitions @@ -17,6 +18,9 @@ per `1`. The source head stops on the zero separator, ready for the payload copy phase. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordDecode/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordDecode/Internal.lean index f20e8e2d..fd6346c7 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordDecode/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordDecode/Internal.lean @@ -3,12 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordDecode.Defs -import Complexitylib.Models.TuringMachine.Combinators.ForWorkOnes.Internal -import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc -import Complexitylib.Models.TuringMachine.Subroutines.Internal -import Mathlib.Tactic.Linarith + +module +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordDecode.Defs +public import Complexitylib.Models.TuringMachine.Combinators.ForWorkOnes.Internal +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc +public import Complexitylib.Models.TuringMachine.Subroutines.Internal +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Internal.Comparison +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Internal.Loop +public import Mathlib.Data.Rat.Cast.Order +public import Mathlib.Tactic.Linarith.Frontend +public import Mathlib.Tactic.NormNum.Abs +public import Mathlib.Tactic.NormNum.DivMod +public import Mathlib.Tactic.NormNum.OfScientific /-! # RAM snapshot word-width decoder — proof internals @@ -18,6 +26,9 @@ needed by `TM.ForWorkOnesLoopSpec`. The only changed tapes are the source cursor and the canonical binary width counter. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordDecode/LinearInternal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordDecode/LinearInternal.lean index c69d70f3..0ac20e4d 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordDecode/LinearInternal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordDecode/LinearInternal.lean @@ -3,9 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordDecode.Defs -import Complexitylib.Models.TuringMachine.Internal -import Complexitylib.Models.TuringMachine.Tape.Encoding + +module +public import + Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordDecode.Defs +public import Complexitylib.Models.TuringMachine.Internal +public import Std.Tactic.BVDecide.Normalize.BitVec /-! # Linear RAM snapshot word decoder — proof internals @@ -15,6 +18,9 @@ the unary width to a marker tape, rewind those markers, then consume one marker while copying one payload bit. Each pass is linear in the encoded word width. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordEncode.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordEncode.lean index acb81347..40f39910 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordEncode.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordEncode.lean @@ -3,16 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordEncode.Defs -import +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordEncode.Internal -import Complexitylib.Models.TuringMachine.Hoare.Space /-! # Self-delimiting word emission -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordEncode/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordEncode/Defs.lean index 24057cf5..5907592d 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordEncode/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordEncode/Defs.lean @@ -3,12 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import - Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Defs -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary.Defs -import Complexitylib.Models.TuringMachine.Tape.Encoding + +module +public import Complexitylib.Models.TuringMachine.Subroutines +public import Mathlib.Data.Nat.Bits +public import Mathlib.Tactic.NormNum.Inv +public import Mathlib.Tactic.NormNum.Pow /-! # Self-delimiting word emission — definitions @@ -18,6 +18,9 @@ work-tape pass either emits one unary width mark per source bit or copies the payload bits themselves. `wordEncodeTM` composes those passes around a rewind. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordEncode/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordEncode/Internal.lean index 40a3dd83..4216c572 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordEncode/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/RegisterStore/Machine/WordEncode/Internal.lean @@ -3,16 +3,21 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Machine.WordEncode.Defs -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Hoare -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary +public import Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs /-! # Self-delimiting word emission — proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig.lean index 39aed6c8..d10d09b4 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Defs -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Internal + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Defs +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Internal /-! # Bounded Turing-machine configurations in RAM registers @@ -15,6 +17,9 @@ simulation. The register layout is explicit, blank cells use value zero, and information. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Defs.lean index e5c75410..8c4c989c 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Defs.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Defs -import Mathlib.Data.Fintype.Sum -import Mathlib.Logic.Equiv.Fin.Basic + +module +public import Complexitylib.Models.RandomAccessMachine.Defs +public import Mathlib.Logic.Equiv.Fin.Basic /-! # Bounded Turing-machine configurations in RAM registers @@ -19,6 +20,9 @@ Blank symbols use code zero. Consequently registers outside the representation and blank cells inside it agree with the RAM's finite-support convention. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Internal.lean index dfbed1e5..b4b30511 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Internal.lean @@ -3,12 +3,17 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Defs /-! # Bounded Turing-machine configuration encoding -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse.lean index d209dc71..b5043bf7 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Defs -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Internal + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Defs +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Internal /-! # Sparse unbounded TM configurations in RAM registers @@ -14,6 +16,9 @@ simulation. Unlike the bounded dense layout, its addresses do not depend on an input length or running-time bound. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI.lean index 45cb00ef..ce0eaf2c 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI.lean @@ -3,8 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.ABI.Defs -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.ABI.Internal.Resources + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.ABI.Defs +public import + Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.ABI.Internal.Resources /-! # Public RAM ABI for the fixed sparse TM simulator @@ -17,6 +20,9 @@ the fixed sparse simulator to a halted TM configuration and returns a public Boolean verdict in `R₀`. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Defs.lean index 586888f4..21ce5a87 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Defs /-! # Public RAM input/output ABI for the sparse TM simulator @@ -16,6 +18,9 @@ old prefix, repairs those six statically remembered bits, and initializes the state, heads, and left-end markers. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Internal/Capture.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Internal/Capture.lean index be856645..08b34612 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Internal/Capture.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Internal/Capture.lean @@ -3,13 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.ABI.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.Internal + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.ABI.Defs +public import Mathlib.Tactic.NormNum.Inv +public import Mathlib.Tactic.NormNum.Pow /-! # Capturing raw-input scratch bits in finite control -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Internal/Decision.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Internal/Decision.lean index 968abac4..8bd01d4b 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Internal/Decision.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Internal/Decision.lean @@ -3,14 +3,21 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.ABI.Internal.Marshal -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Iteration -import Complexitylib.Models.RandomAccessMachine.Structured + +module +public import + Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.ABI.Internal.Marshal +public import + Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Iteration +public import Complexitylib.Models.RandomAccessMachine.Structured /-! # End-to-end public-ABI sparse simulation -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Internal/Loop.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Internal/Loop.lean index b4bb43b2..6b675b42 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Internal/Loop.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Internal/Loop.lean @@ -3,13 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.ABI.Internal.Capture -import Complexitylib.Models.RandomAccessMachine.Structured.Internal.Resources + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.Internal.Resources +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.ABI.Defs /-! # Backward public-input copy -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Internal/Marshal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Internal/Marshal.lean index 3028c838..ed635058 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Internal/Marshal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Internal/Marshal.lean @@ -3,8 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.ABI.Internal.Loop -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Internal + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.ABI.Internal.Loop +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Internal +public import + Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.ABI.Internal.Capture +public import Mathlib.Algebra.Order.Sub.Basic /-! # Public-input marshalling correctness -- proof internals @@ -14,6 +19,9 @@ the finitely many captured scratch positions, and establishes the complete sparse representation of the Turing machine's initial configuration. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Internal/Resources.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Internal/Resources.lean index 051f5b35..00003676 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Internal/Resources.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/ABI/Internal/Resources.lean @@ -3,8 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.ABI.Internal.Decision -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Resources + +module +public import + Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.ABI.Internal.Decision +public import + Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Resources /-! # Resource bounds for the public sparse-simulator ABI -- proof internals @@ -16,6 +20,9 @@ support. The first captured-position repair reloads that scratch register from the sparse data region, returning to the core envelope before simulation. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Containment.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Containment.lean index ba425001..4a0d5beb 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Containment.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Containment.lean @@ -3,7 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Containment.Internal + +module +public import + Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Containment.Internal /-! # TM-to-RAM time-class containment @@ -13,6 +16,9 @@ logarithmic-cost RAM deciders through the public input/output ABI. Polynomial Turing time is therefore contained in polynomial RAM time. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Containment/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Containment/Internal.lean index 3024b9c5..ee7b909b 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Containment/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Containment/Internal.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.P.NormalForm -import Complexitylib.Models.RandomAccessMachine.Classes.Defs -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.ABI + +module +public import Complexitylib.Classes.P.NormalForm +public import Complexitylib.Models.RandomAccessMachine.Classes.Defs +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.ABI /-! # TM-to-RAM time-class containment -- proof internals @@ -15,6 +17,9 @@ to deciders and then discharges the polynomial-bound arithmetic needed for the forward machine-model robustness theorem. -/ + +@[expose] public section + namespace Complexity namespace RAM @@ -58,7 +63,7 @@ theorem mem_DTIME_of_decidesInTime_internal compiledDecision_decidesInTime_internal hdecides, BigO.refl _⟩ /-- Pointwise domination by the evaluation of a natural polynomial. -/ -private def PolyBound (f : ℕ → ℕ) : Prop := +def PolyBound (f : ℕ → ℕ) : Prop := ∃ p : Polynomial ℕ, ∀ inputLength, f inputLength ≤ p.eval inputLength namespace PolyBound diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Defs.lean index a6da0c23..d14aa630 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.Defs /-! # Sparse unbounded TM configurations in RAM registers @@ -17,6 +19,9 @@ compute every cell address using multiplication and addition while allocating new tape positions on demand. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Internal.lean index 1dd780e6..e5920c62 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Internal.lean @@ -3,13 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Defs -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Internal + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Defs +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Internal /-! # Sparse unbounded TM configuration encoding -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step.lean index d7db5944..9837b057 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step.lean @@ -3,10 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Defs -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal -import Complexitylib.Models.RandomAccessMachine.Structured -import Complexitylib.Asymptotics + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Defs +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal +public import Complexitylib.Models.RandomAccessMachine.Structured +public import Complexitylib.Asymptotics +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse /-! # A fixed sparse-RAM block for one Turing-machine transition @@ -19,6 +22,9 @@ RAM execution are checked. The separate `Sparse.ABI` surface supplies the public input/output marshalling layer. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Defs.lean index edbf417b..58ea8c73 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.Switch.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.Switch.Defs /-! # A fixed sparse-RAM block for one Turing-machine transition @@ -15,6 +17,9 @@ It computes an interleaved tape-cell address as an unbounded computation. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal.lean index ce32ba38..b277de5f 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal.lean @@ -3,12 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Layout -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Load -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Action -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Dispatch -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Iteration -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Resources + +module +public import + Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Layout +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Load +public import + Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Action +public import + Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Dispatch +public import + Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Iteration +public import + Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Resources /-! # Fixed sparse TM-transition block -- proof internals diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Action.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Action.lean index 932d726f..e089adb0 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Action.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Action.lean @@ -3,13 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Load -import Complexitylib.Models.RandomAccessMachine.Structured.Internal.Resources + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.Internal.Resources +public import + Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Layout /-! # Selected sparse TM transition actions -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM @@ -261,7 +267,7 @@ private theorem writeMoveOps_control {tm : TM n} exact writeOps_control slot write store hrepresents htapeCount reg hhigh hvalue haddress -theorem writeMoveOps_tape_internal {tm : TM n} +private theorem writeMoveOps_tape_internal {tm : TM n} {cfg : Complexity.Cfg n tm.Q} (slot : Fin (n + 2)) (write : Γw) (direction : Dir3) (store : Structured.Store) (hrepresents : Represents tm cfg store) @@ -282,7 +288,7 @@ theorem writeMoveOps_tape_internal {tm : TM n} exact moveOps_tape n slot direction ((tapeAt cfg slot).write write.toΓ) written hwritten honeWritten -theorem writeMoveOps_otherTape_internal {tm : TM n} +private theorem writeMoveOps_otherTape_internal {tm : TM n} {cfg : Complexity.Cfg n tm.Q} {slot other : Fin (n + 2)} (hne : slot ≠ other) (write : Γw) (direction : Dir3) (store : Structured.Store) (hrepresents : Represents tm cfg store) @@ -1000,7 +1006,8 @@ private theorem writeMoveOps_envelopeChain {tm : TM n} {bound : ℕ} (hone : store (oneReg n) = 1) (hstart : (tapeAt cfg tape).cells 0 = Γ.start) (hhead : (tapeAt cfg tape).head ≤ bound) - (henvelope : ResourceEnvelope tm bound store) : + (henvelope : Structured.Internal.StoreEnvelope + (registerBound n (bound + 1)) (wordBound tm bound) store) : ResourceEnvelopeChain tm bound (writeMoveOps n tape write direction) store := by let written := Structured.Basic.execList (writeOps n tape write) store @@ -1075,7 +1082,7 @@ private theorem workPrefix_list_envelope {tm : TM n} {bound : ℕ} List.append_assoc] using hfinalPrefix · simpa [List.flatMap_cons] using hblock.append hrestChain -theorem actionOps_envelopeChain_internal {tm : TM n} {bound : ℕ} +private theorem actionOps_envelopeChain_internal {tm : TM n} {bound : ℕ} {cfg : Complexity.Cfg n tm.Q} {store : Structured.Store} (hrepresents : Represents tm cfg store) (hheads : HeadsBounded cfg bound) @@ -1193,7 +1200,8 @@ theorem actionOps_measured_internal {tm : TM n} {bound : ℕ} (houtputStart : cfg.output.cells 0 = Γ.start) (hone : store (oneReg n) = 1) (htapeCount : store (tapeCountReg n) = n + 2) - (henvelope : ResourceEnvelope tm bound store) : + (henvelope : Structured.Internal.StoreEnvelope + (registerBound n (bound + 1)) (wordBound tm bound) store) : let final := Structured.Basic.execList (actionOps tm cfg.state (readSymbols cfg)) store Structured.Internal.MeasuredRuns @@ -1201,7 +1209,9 @@ theorem actionOps_measured_internal {tm : TM n} {bound : ℕ} (actionOps tm cfg.state (readSymbols cfg)).length (4 * (actionOps tm cfg.state (readSymbols cfg)).length * wordWidth tm bound) (spaceBound tm bound) ∧ - Represents tm next final ∧ ResourceEnvelope tm bound final := by + Represents tm next final ∧ + Structured.Internal.StoreEnvelope + (registerBound n (bound + 1)) (wordBound tm bound) final := by have hchain := actionOps_envelopeChain_internal hrepresents hheads hworkStart houtputStart hone htapeCount henvelope have hmeasured := Structured.Internal.MeasuredRuns.basicsEnvelopeChain diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Dispatch.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Dispatch.lean index 492f7fb7..2ce84d0a 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Dispatch.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Dispatch.lean @@ -3,13 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Action -import Complexitylib.Models.RandomAccessMachine.Structured.Switch + +module +public import + Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Action +public import Complexitylib.Models.RandomAccessMachine.Structured.Switch +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Load /-! # Nested finite dispatch for the fixed sparse TM transition -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM @@ -245,7 +252,8 @@ theorem program_exec_internal {tm : TM n} hfinalRepresents⟩ simpa [program, stepCount, loaded] using Structured.Exec.seq hloadExec hdispatch -private abbrev ResourceEnvelope (tm : TM n) (bound : ℕ) := +/-- Register and word bounds preserved by sparse step dispatch. -/ +abbrev ResourceEnvelope (tm : TM n) (bound : ℕ) := Structured.Internal.StoreEnvelope (registerBound n (bound + 1)) (wordBound tm bound) diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Iteration.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Iteration.lean index d50fd464..ae2a83d8 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Iteration.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Iteration.lean @@ -3,12 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Dispatch + +module +public import + Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Dispatch /-! # Iterating the fixed sparse TM transition -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Layout.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Layout.lean index a4ea0962..000c9362 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Layout.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Layout.lean @@ -3,13 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Defs +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Internal /-! # Sparse TM-step address and loading layout -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Load.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Load.lean index a0ce1484..11a9702a 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Load.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Load.lean @@ -3,12 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Layout + +module +public import + Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Layout /-! # Loading sparse TM states and head symbols -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Resources.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Resources.lean index 1f29520d..71747efa 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Resources.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Sparse/Step/Internal/Resources.lean @@ -3,8 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Iteration -import Complexitylib.Models.RandomAccessMachine.Structured.Internal.Resources + +module +public import + Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Sparse.Step.Internal.Iteration +public import Complexitylib.Models.RandomAccessMachine.Structured.Internal.Resources /-! # Resource envelopes for the fixed sparse TM simulator -- proof internals @@ -14,6 +17,9 @@ This layer supplies the uniform finite-store envelope needed to turn those measurements into explicit bounds depending only on input length and TM steps. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step.lean index f708dfe8..a58f27af 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Defs -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal -import Complexitylib.Models.RandomAccessMachine.Structured + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Defs +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal +public import Complexitylib.Models.RandomAccessMachine.Structured /-! # Fixed RAM transition blocks for bounded Turing-machine configurations @@ -16,6 +18,9 @@ structured program has exact one-step source semantics; its common resource envelope and compiled-RAM transfer are the next M6 layer. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Defs.lean index a6696870..0d9ce954 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.Switch.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.Switch.Defs /-! # A fixed structured-RAM block for one Turing-machine transition @@ -18,6 +20,9 @@ The construction is fixed once `tm` and the cell-window bound are fixed. It does not install or consult an untrusted transition-table oracle. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal.lean index cda80fd1..22aaddfe 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal.lean @@ -3,11 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal.Layout -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal.Load -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal.Action -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal.Dispatch -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal.Resources + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal.Layout +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal.Load +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal.Action +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal.Dispatch +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal.Resources /-! # One-step TM-to-RAM simulation -- proof internals diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal/Action.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal/Action.lean index 9b0a421f..3ebc7baa 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal/Action.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal/Action.lean @@ -3,12 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal.Load + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal.Layout +public import Complexitylib.Models.RandomAccessMachine.Structured.Internal.Resources /-! # Selected TM transition actions -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM @@ -277,7 +283,7 @@ private theorem writeOps_one (n bound : ℕ) (slot : Fin (n + 2)) rw [writeOps_apply n bound slot write store honeAddress honeValue, Function.update_of_ne honeBase, Function.update_of_ne honeTarget] -theorem writeMoveOps_tape_internal (n bound : ℕ) (slot : Fin (n + 2)) +private theorem writeMoveOps_tape_internal (n bound : ℕ) (slot : Fin (n + 2)) (write : Γw) (direction : Dir3) (tape : Tape) (store : Structured.Store) (hrepresents : RepresentsTape bound slot tape store) (hhead : tape.head ≤ bound) (hstart : tape.cells 0 = Γ.start) @@ -319,7 +325,7 @@ theorem writeMoveOps_one_internal (n bound : ℕ) (slot : Fin (n + 2)) rw [writeMoveOps, execList_append, moveOps_apply_of_ne n bound slot direction written honeHead, honeWritten] -theorem writeMoveOps_otherTape_internal (n bound : ℕ) +private theorem writeMoveOps_otherTape_internal (n bound : ℕ) {slot other : Fin (n + 2)} (hne : slot ≠ other) (write : Γw) (direction : Dir3) (otherTape : Tape) (store : Structured.Store) @@ -1047,13 +1053,14 @@ private theorem workPrefix_list_envelope {tm : TM n} {bound : ℕ} List.append_assoc] using hfinalPrefix · simpa [List.flatMap_cons] using hblock.append hrestChain -theorem actionOps_envelopeChain_internal {tm : TM n} {bound : ℕ} +private theorem actionOps_envelopeChain_internal {tm : TM n} {bound : ℕ} {cfg : Complexity.Cfg n tm.Q} {store : Structured.Store} (hrepresents : Represents tm bound cfg store) (hheads : HeadsBounded cfg bound) (hworkStart : ∀ i, (cfg.work i).cells 0 = Γ.start) (hone : store (oneReg n bound) = 1) - (henvelope : StepEnvelope tm bound store) : + (henvelope : Structured.Internal.StoreEnvelope + (registerLimit n bound) (wordBound tm bound) store) : StepEnvelopeChain tm bound (actionOps tm bound cfg.state (readSymbols cfg)) store := by rcases hdelta : tm.δ cfg.state cfg.input.read @@ -1144,7 +1151,8 @@ theorem actionOps_measured_internal {tm : TM n} {bound : ℕ} (hworkStart : ∀ i, (cfg.work i).cells 0 = Γ.start) (houtputStart : cfg.output.cells 0 = Γ.start) (hone : store (oneReg n bound) = 1) - (henvelope : StepEnvelope tm bound store) : + (henvelope : Structured.Internal.StoreEnvelope + (registerLimit n bound) (wordBound tm bound) store) : let final := Structured.Basic.execList (actionOps tm bound cfg.state (readSymbols cfg)) store Structured.Internal.MeasuredRuns @@ -1152,7 +1160,9 @@ theorem actionOps_measured_internal {tm : TM n} {bound : ℕ} (actionOps tm bound cfg.state (readSymbols cfg)).length (4 * (actionOps tm bound cfg.state (readSymbols cfg)).length * wordWidth tm bound) (spaceBound tm bound) ∧ - Represents tm bound next final ∧ StepEnvelope tm bound final := by + Represents tm bound next final ∧ + Structured.Internal.StoreEnvelope + (registerLimit n bound) (wordBound tm bound) final := by have hchain := actionOps_envelopeChain_internal hrepresents hheads hworkStart hone henvelope have hmeasured := Structured.Internal.MeasuredRuns.basicsEnvelopeChain diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal/Dispatch.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal/Dispatch.lean index aea18b3d..00227ede 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal/Dispatch.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal/Dispatch.lean @@ -3,13 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal.Action -import Complexitylib.Models.RandomAccessMachine.Structured.Switch + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal.Action +public import Complexitylib.Models.RandomAccessMachine.Structured.Switch +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal.Load /-! # Nested finite dispatch for one TM transition -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal/Layout.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal/Layout.lean index e4900137..8d1fb5da 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal/Layout.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal/Layout.lean @@ -3,13 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Defs /-! # TM-to-RAM step layout -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal/Load.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal/Load.lean index cedf2c53..df89c05f 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal/Load.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal/Load.lean @@ -3,13 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal.Layout -import Complexitylib.Models.RandomAccessMachine.Structured.Internal.Resources + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal.Layout +public import Complexitylib.Models.RandomAccessMachine.Structured.Internal.Resources /-! # Loading represented TM states and head symbols -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal/Resources.lean b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal/Resources.lean index 307942c5..08d33cf8 100644 --- a/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal/Resources.lean +++ b/Complexitylib/Models/RandomAccessMachine/Simulation/TMConfig/Step/Internal/Resources.lean @@ -3,12 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal.Dispatch + +module +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal.Action +public import Complexitylib.Models.RandomAccessMachine.Simulation.TMConfig.Step.Internal.Load +public import Complexitylib.Models.RandomAccessMachine.Structured.Switch /-! # Resource bounds for one TM-to-RAM transition -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM @@ -18,7 +25,8 @@ namespace TMConfig namespace Step -private abbrev StepEnvelope (tm : TM n) (bound : ℕ) := +/-- Register and word bounds preserved by a simulated Turing-machine step. -/ +abbrev StepEnvelope (tm : TM n) (bound : ℕ) := Structured.Internal.StoreEnvelope (registerLimit n bound) (wordBound tm bound) private theorem cleared_envelope {tm : TM n} {bound test : ℕ} diff --git a/Complexitylib/Models/RandomAccessMachine/Soundness.lean b/Complexitylib/Models/RandomAccessMachine/Soundness.lean index 218e5c95..e15957a6 100644 --- a/Complexitylib/Models/RandomAccessMachine/Soundness.lean +++ b/Complexitylib/Models/RandomAccessMachine/Soundness.lean @@ -3,7 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Internal + +module +public import Complexitylib.Models.RandomAccessMachine.Internal +public import Mathlib.Data.Nat.Size /-! # Why the RAM must use logarithmic cost: a formal soundness theorem @@ -26,6 +29,9 @@ convention but the boundary between a sound Turing-equivalent model and a "reward-hacked" one that decides more than it should in polynomial time. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured.lean b/Complexitylib/Models/RandomAccessMachine/Structured.lean index afe7355a..7977f91b 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.Internal -import Complexitylib.Models.RandomAccessMachine.Structured.Switch + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.Internal +public import Complexitylib.Models.RandomAccessMachine.Structured.Switch /-! # Structured logarithmic-cost RAM programs @@ -24,6 +26,9 @@ Turing-machine transition compiler. Its branch selection has exact step accounting and preserves explicit logarithmic-cost and space envelopes. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Structured/Defs.lean index e564170b..b99c9697 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Defs /-! # Structured logarithmic-cost RAM programs — definitions @@ -20,6 +22,9 @@ The compiler appends no hidden data operations: source and target executions therefore have equal register effects, logarithmic cost, and peak register space. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/GateEval.lean b/Complexitylib/Models/RandomAccessMachine/Structured/GateEval.lean index a8c9e390..cb4e4cf1 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/GateEval.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/GateEval.lean @@ -3,9 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.GateEval.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.GateEval.Internal -import Complexitylib.Asymptotics + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.GateEval.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.GateEval.Internal +public import Complexitylib.Asymptotics +public import Complexitylib.Models.RandomAccessMachine.Structured /-! # Verified structured RAM decoded-gate evaluator @@ -16,6 +19,9 @@ indirect memo reads, evaluates the gate with branch-free Boolean arithmetic, and indirectly appends the result in exactly twenty RAM transitions. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/GateEval/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Structured/GateEval/Defs.lean index 7cefb830..fc4eaad0 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/GateEval/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/GateEval/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.Defs -import Complexitylib.Circuits.Encoding.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.Defs +public import Complexitylib.Circuits.Encoding.Defs /-! # Structured RAM decoded-gate evaluator — definitions @@ -15,6 +17,9 @@ append the result. Boolean negation, AND, and OR are implemented arithmetically, so the instruction count is independent of the gate and wire values. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/GateEval/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Structured/GateEval/Internal.lean index b4cc6390..71ce4311 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/GateEval/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/GateEval/Internal.lean @@ -3,14 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured -import Complexitylib.Models.RandomAccessMachine.Structured.GateEval.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.Internal.Resources + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.GateEval.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.Internal.Resources +public import Mathlib.Algebra.Order.Sub.Basic +public import Std.Tactic.BVDecide.Normalize.Bool /-! # Structured RAM decoded-gate evaluator — proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM @@ -1608,7 +1614,7 @@ theorem routine_exec_internal {base : ℕ} {gate : CircuitCode.RawGate} · intro index hindex exact routineFinal_wire hready index hindex -theorem finalStore_output_internal (gate : CircuitCode.RawGate) (wires : List Bool) +private theorem finalStore_output_internal (gate : CircuitCode.RawGate) (wires : List Bool) (value0 value1 : Bool) (hvalue0 : wires[gate.input₀]? = some value0) (hvalue1 : wires[gate.input₁]? = some value1) : finalStore gate wires outputReg = Input.bitValue (gate.eval value0 value1) := diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/GateStep.lean b/Complexitylib/Models/RandomAccessMachine/Structured/GateStep.lean index 1583ec6b..7335bab1 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/GateStep.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/GateStep.lean @@ -3,8 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.GateStep.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.GateStep.Internal + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.GateStep.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.GateStep.Internal +public import Complexitylib.Models.RandomAccessMachine.Structured /-! # Verified structured RAM serialized-gate step @@ -15,6 +18,9 @@ invokes the same cursor loop for both unary references, discovers the following memo base at runtime, evaluates the decoded gate, and appends its result. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/GateStep/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Structured/GateStep/Defs.lean index ab90b0a7..0cac825c 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/GateStep/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/GateStep/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.GateEval.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.UnaryDecode.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.GateEval.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.UnaryDecode.Defs /-! # Structured RAM serialized-gate step — definitions @@ -16,6 +18,9 @@ the two references are decoded by two calls to the same loop, and the resulting gate is evaluated and appended without specializing the program to the input. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/GateStep/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Structured/GateStep/Internal.lean index d180c2eb..25e42a35 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/GateStep/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/GateStep/Internal.lean @@ -3,16 +3,21 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Internal.Codec -import Complexitylib.Models.RandomAccessMachine.Structured.GateEval.Internal -import Complexitylib.Models.RandomAccessMachine.Structured.GateStep.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.UnaryDecode.Internal -import Mathlib.Tactic.IntervalCases + +module +public import Complexitylib.Circuits.Encoding.Internal.Codec +public import Complexitylib.Models.RandomAccessMachine.Structured.GateEval.Internal +public import Complexitylib.Models.RandomAccessMachine.Structured.GateStep.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.UnaryDecode.Internal +public import Mathlib.Tactic.IntervalCases /-! # Structured RAM serialized-gate step — proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/GateStreamStep.lean b/Complexitylib/Models/RandomAccessMachine/Structured/GateStreamStep.lean index 75736122..11067aaa 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/GateStreamStep.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/GateStreamStep.lean @@ -3,8 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.GateStreamStep.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.GateStreamStep.Internal + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.GateStreamStep.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.GateStreamStep.Internal +public import Complexitylib.Models.RandomAccessMachine.Structured /-! # Verified structured RAM iterable serialized-gate step @@ -14,6 +17,9 @@ experiment. Code and mutable memo occupy disjoint regions, so the exact same routine can be invoked again at the returned cursor. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/GateStreamStep/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Structured/GateStreamStep/Defs.lean index 9996e092..5cd3c185 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/GateStreamStep/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/GateStreamStep/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.GateEval.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.UnaryDecode.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.GateEval.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.UnaryDecode.Defs /-! # Structured RAM iterable serialized-gate step — definitions @@ -17,6 +19,9 @@ and the memo, so cursor state survives gate evaluation without aliasing either mutable wires or unread code. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/GateStreamStep/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Structured/GateStreamStep/Internal.lean index b627d535..8006097a 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/GateStreamStep/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/GateStreamStep/Internal.lean @@ -3,16 +3,21 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Internal.Codec -import Complexitylib.Models.RandomAccessMachine.Structured.GateEval.Internal -import Complexitylib.Models.RandomAccessMachine.Structured.GateStreamStep.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.UnaryDecode.Internal -import Mathlib.Tactic.IntervalCases + +module +public import Complexitylib.Circuits.Encoding.Internal.Codec +public import Complexitylib.Models.RandomAccessMachine.Structured.GateEval.Internal +public import Complexitylib.Models.RandomAccessMachine.Structured.GateStreamStep.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.UnaryDecode.Internal +public import Mathlib.Tactic.IntervalCases /-! # Structured RAM iterable serialized-gate step — proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM @@ -589,7 +594,7 @@ private theorem header_negated1 {gateStart base : ℕ} rw [header_high store (gateStart + 2) hlarge, hready.code_eq 2] simp [codeBits, CircuitCode.RawGate.encode] -theorem decoders_internal {gateStart base : ℕ} {gate : CircuitCode.RawGate} +private theorem decoders_internal {gateStart base : ℕ} {gate : CircuitCode.RawGate} {tail wires : List Bool} {store : Store} (hready : Ready gateStart base gate tail wires store) (hbound : StoreEnvelope (codeEnd gateStart gate tail) diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/Hamming.lean b/Complexitylib/Models/RandomAccessMachine/Structured/Hamming.lean index b9b19ca9..dbd1c7b3 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/Hamming.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/Hamming.lean @@ -3,9 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.Hamming.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.Hamming.Internal -import Complexitylib.Asymptotics + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.Hamming.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.Hamming.Internal +public import Complexitylib.Asymptotics +public import Complexitylib.Models.RandomAccessMachine.Structured /-! # Verified structured RAM Hamming weight @@ -18,6 +21,9 @@ RAM with an exact transition count, explicit length-indexed budgets, and quasilinear asymptotic corollaries. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/Hamming/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Structured/Hamming/Defs.lean index 359aef92..f0f87deb 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/Hamming/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/Hamming/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.Defs /-! # Structured RAM Hamming-weight program — definitions @@ -13,6 +15,9 @@ hold loop state and input bits start at `R₅`. This avoids the existing raw RAM input convention's overlap between an unbounded input and fixed scratch registers. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/Hamming/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Structured/Hamming/Internal.lean index 75cb802f..1ad5a5c2 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/Hamming/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/Hamming/Internal.lean @@ -3,14 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured -import Complexitylib.Models.RandomAccessMachine.Structured.Hamming.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.Internal.Resources + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.Hamming.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.Internal.Resources /-! # Structured RAM Hamming-weight program — proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Structured/Internal.lean index a2b1880b..295a2373 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/Internal.lean @@ -3,8 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Internal -import Complexitylib.Models.RandomAccessMachine.Structured.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Internal +public import Complexitylib.Models.RandomAccessMachine.Structured.Defs +public import Mathlib.Algebra.Order.Group.Nat +public import Mathlib.Algebra.Order.Sub.Basic /-! # Structured logarithmic-cost RAM programs — proof internals @@ -13,6 +17,9 @@ This file proves that absolute-jump lowering preserves the independent source semantics exactly: final registers, logarithmic cost, and peak register space. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/Internal/Resources.lean b/Complexitylib/Models/RandomAccessMachine/Structured/Internal/Resources.lean index 19805e64..76531504 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/Internal/Resources.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/Internal/Resources.lean @@ -3,7 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.Defs +public import Mathlib.Algebra.Order.BigOperators.Group.Finset +public import Mathlib.Algebra.Order.Ring.Nat +public import Mathlib.Data.Nat.Size +public import Mathlib.Tactic.Ring.RingNF /-! # Resource-proof infrastructure for structured RAM programs @@ -14,6 +20,9 @@ finite register envelopes, their induced `finsum` space bounds, and compositiona source executions carrying exact steps with upper bounds on time and space. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/LastBit.lean b/Complexitylib/Models/RandomAccessMachine/Structured/LastBit.lean index 94226faf..2dbed364 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/LastBit.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/LastBit.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.LastBit.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.Scanner -import Complexitylib.Languages.LastBit + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.LastBit.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.Scanner +public import Complexitylib.Languages.LastBit /-! # Verified structured RAM last-bit scanner @@ -15,6 +17,9 @@ and resource bounds. This module adds only agreement with the existing `Language.lastBitZero` and `Language.lastBitOne` specifications. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/LastBit/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Structured/LastBit/Defs.lean index d6244ac5..668e7b4b 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/LastBit/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/LastBit/Defs.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.Scanner.Defs -import Mathlib.Data.FinEnum.Option + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.Scanner.Defs /-! # Structured RAM last-bit scanner — definitions @@ -13,6 +14,9 @@ This is a second consumer of the typed finite-state scanner API. Its state is `Option Bool`: `none` before any input and `some bit` thereafter. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/PairValidate.lean b/Complexitylib/Models/RandomAccessMachine/Structured/PairValidate.lean index b3abed16..cb52f003 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/PairValidate.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/PairValidate.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.PairValidate.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.PairValidate.Internal -import Complexitylib.Models.RandomAccessMachine.Structured.Scanner -import Complexitylib.Models.TuringMachine.Subroutines.PairValidate + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.PairValidate.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.PairValidate.Internal +public import Complexitylib.Models.RandomAccessMachine.Structured.Scanner +public import Complexitylib.Models.TuringMachine.Subroutines.PairValidate /-! # Verified structured RAM pair validator @@ -17,6 +19,9 @@ logarithmic-cost time and peak-space budgets, and an end-to-end compiled-RAM correctness theorem for the canonical pair-encoding language. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/PairValidate/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Structured/PairValidate/Defs.lean index 0c1461bd..a9a135c3 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/PairValidate/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/PairValidate/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.Scanner.Defs -import Complexitylib.Models.TuringMachine.Subroutines.PairValidate.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.Scanner.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.PairValidate.Defs /-! # Structured RAM pair-encoding validator — definitions @@ -14,6 +16,9 @@ same five-state automaton used by `TM.pairValidateTM`. The generic scanner compiler supplies the table-driven structured RAM program. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/PairValidate/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Structured/PairValidate/Internal.lean index 8d718f54..900fd683 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/PairValidate/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/PairValidate/Internal.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.PairValidate.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.Scanner.Internal + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.PairValidate.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.Scanner.Internal /-! # Structured RAM pair validator — proof internals @@ -13,6 +15,9 @@ The benchmark supplies only its typed scanner specification. State encoding, execution, correctness, and resource proofs are all in the generic scanner layer. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/Scanner.lean b/Complexitylib/Models/RandomAccessMachine/Structured/Scanner.lean index b9a68be6..81b26d5b 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/Scanner.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/Scanner.lean @@ -3,9 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.Scanner.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.Scanner.Internal -import Complexitylib.Asymptotics + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.Scanner.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.Scanner.Internal +public import Complexitylib.Asymptotics +public import Complexitylib.Models.RandomAccessMachine.Structured /-! # Verified finite-state structured RAM scanners @@ -16,6 +19,9 @@ count and explicit logarithmic-time and peak-space bounds, all transferred to the concrete compiled RAM. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/Scanner/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Structured/Scanner/Defs.lean index 59dc439c..fa9dd571 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/Scanner/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/Scanner/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.Defs -import Mathlib.Data.FinEnum + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.Defs +public import Mathlib.Data.FinEnum /-! # Finite-state scanners for the structured RAM frontend @@ -15,6 +17,9 @@ bound and transition-closure fields are the complete trusted interface needed by the generic correctness and resource proof. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/Scanner/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Structured/Scanner/Internal.lean index b80b457e..ad12dc90 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/Scanner/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/Scanner/Internal.lean @@ -3,14 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured -import Complexitylib.Models.RandomAccessMachine.Structured.Internal.Resources -import Complexitylib.Models.RandomAccessMachine.Structured.Scanner.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.Internal.Resources +public import Complexitylib.Models.RandomAccessMachine.Structured.Scanner.Defs +public import Std.Tactic.BVDecide.Normalize.BitVec /-! # Finite-state structured RAM scanners — proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/Switch.lean b/Complexitylib/Models/RandomAccessMachine/Structured/Switch.lean index bd9b872c..bb3100f5 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/Switch.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/Switch.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.Switch.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.Switch.Internal + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.Switch.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.Switch.Internal /-! # Verified finite numeric switches for structured RAM programs @@ -13,6 +15,9 @@ The theorem in this module gives exact source step accounting and explicit logarithmic-cost and peak-space bounds for a finite numeric switch. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/Switch/Compiled.lean b/Complexitylib/Models/RandomAccessMachine/Structured/Switch/Compiled.lean index a849d4b9..edf3b137 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/Switch/Compiled.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/Switch/Compiled.lean @@ -3,12 +3,17 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured + +module +public import Complexitylib.Models.RandomAccessMachine.Structured /-! # Compilation theorem for finite numeric structured-RAM switches -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/Switch/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Structured/Switch/Defs.lean index 60b040ba..87b34e8a 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/Switch/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/Switch/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.Defs /-! # Finite numeric switches for structured RAM programs @@ -13,6 +15,9 @@ tree. A valid numeric code in `test` selects the corresponding branch. The register `one` must contain one and be distinct from `test`. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/Switch/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Structured/Switch/Internal.lean index 1aaabc1c..31972d57 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/Switch/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/Switch/Internal.lean @@ -3,13 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.Internal.Resources -import Complexitylib.Models.RandomAccessMachine.Structured.Switch.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.Internal.Resources +public import Complexitylib.Models.RandomAccessMachine.Structured.Switch.Defs /-! # Finite numeric structured-RAM switches -- proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/ThreeSATSyntax.lean b/Complexitylib/Models/RandomAccessMachine/Structured/ThreeSATSyntax.lean index 49459868..96f646eb 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/ThreeSATSyntax.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/ThreeSATSyntax.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.ThreeSATSyntax.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.Scanner + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.ThreeSATSyntax.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.Scanner /-! # Verified structured RAM exact-3-CNF syntax scanner @@ -13,6 +15,9 @@ The generic typed-scanner compiler supplies the entire implementation proof and resource analysis for the existing 27-state `SAT.ThreeSAT.Syntax` automaton. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/ThreeSATSyntax/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Structured/ThreeSATSyntax/Defs.lean index 9c95a3bb..fe9a143f 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/ThreeSATSyntax/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/ThreeSATSyntax/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.Scanner.Defs -import Complexitylib.SAT.ThreeSAT.Syntax + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.Scanner.Defs +public import Complexitylib.SAT.ThreeSAT.Syntax /-! # Structured RAM exact-3-CNF syntax scanner — definitions @@ -14,6 +16,9 @@ This is the larger typed-scanner benchmark: the existing 27-state bit-level table or benchmark-specific execution invariant. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/UnaryDecode.lean b/Complexitylib/Models/RandomAccessMachine/Structured/UnaryDecode.lean index a3c9ee59..5f712847 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/UnaryDecode.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/UnaryDecode.lean @@ -3,9 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.UnaryDecode.Defs -import Complexitylib.Models.RandomAccessMachine.Structured.UnaryDecode.Internal -import Complexitylib.Asymptotics + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.UnaryDecode.Defs +public import Complexitylib.Models.RandomAccessMachine.Structured.UnaryDecode.Internal +public import Complexitylib.Asymptotics +public import Complexitylib.Models.RandomAccessMachine.Structured /-! # Verified structured RAM terminated-unary decoder @@ -16,6 +19,9 @@ and input exhaustion, and compilation preserves its exact transition count, logarithmic cost, peak space, decoded value, and suffix cursor. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/UnaryDecode/Defs.lean b/Complexitylib/Models/RandomAccessMachine/Structured/UnaryDecode/Defs.lean index 07f405c9..b4576297 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/UnaryDecode/Defs.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/UnaryDecode/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured.Defs -import Complexitylib.Circuits.Encoding.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.Defs +public import Complexitylib.Circuits.Encoding.Defs /-! # Structured RAM terminated-unary cursor decoder — definitions @@ -15,6 +17,9 @@ the loop can exit either successfully at a zero terminator or unsuccessfully at the end of the available array. -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RandomAccessMachine/Structured/UnaryDecode/Internal.lean b/Complexitylib/Models/RandomAccessMachine/Structured/UnaryDecode/Internal.lean index ce542455..a0214a31 100644 --- a/Complexitylib/Models/RandomAccessMachine/Structured/UnaryDecode/Internal.lean +++ b/Complexitylib/Models/RandomAccessMachine/Structured/UnaryDecode/Internal.lean @@ -3,14 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.RandomAccessMachine.Structured -import Complexitylib.Models.RandomAccessMachine.Structured.Internal.Resources -import Complexitylib.Models.RandomAccessMachine.Structured.UnaryDecode.Defs + +module +public import Complexitylib.Models.RandomAccessMachine.Structured.Internal.Resources +public import Complexitylib.Models.RandomAccessMachine.Structured.UnaryDecode.Defs /-! # Structured RAM terminated-unary decoder — proof internals -/ + +@[expose] public section + namespace Complexity namespace RAM diff --git a/Complexitylib/Models/RoseTreeMachine/Data.lean b/Complexitylib/Models/RoseTreeMachine/Data.lean index 3430c6bf..6fb2959b 100644 --- a/Complexitylib/Models/RoseTreeMachine/Data.lean +++ b/Complexitylib/Models/RoseTreeMachine/Data.lean @@ -5,8 +5,12 @@ Authors: Christian Reitwiessner -/ module - -public import Mathlib.Data.Part +public import Aesop.BuiltinRules +public import Mathlib.Data.Nat.Notation +public import Mathlib.Tactic.Finiteness.Attr +public import Mathlib.Tactic.Push +public import Mathlib.Tactic.ToAdditive +public import Mathlib.Tactic.ToDual /-! # Main internal data type for the rose tree machine (RTM) @@ -23,6 +27,7 @@ This file contains the main internal data structure for the RTM, `Data`, a rose -/ + @[expose] public section namespace Complexity diff --git a/Complexitylib/Models/RoseTreeMachine/DataEncode.lean b/Complexitylib/Models/RoseTreeMachine/DataEncode.lean index 3d06b0f9..91bcf703 100644 --- a/Complexitylib/Models/RoseTreeMachine/DataEncode.lean +++ b/Complexitylib/Models/RoseTreeMachine/DataEncode.lean @@ -5,7 +5,6 @@ Authors: Christian Reitwiessner -/ module - public import Complexitylib.Models.RoseTreeMachine.Data public import Mathlib.Data.Nat.Bits public import Mathlib.Data.List.Basic @@ -21,6 +20,7 @@ and `ℕ` (binary encoding via `List Bool`) -/ + @[expose] public section namespace Complexity diff --git a/Complexitylib/Models/RoseTreeMachine/Prog.lean b/Complexitylib/Models/RoseTreeMachine/Prog.lean index f6494672..73adbc2e 100644 --- a/Complexitylib/Models/RoseTreeMachine/Prog.lean +++ b/Complexitylib/Models/RoseTreeMachine/Prog.lean @@ -5,10 +5,9 @@ Authors: Christian Reitwiessner -/ module - -public import Complexitylib.Models.RoseTreeMachine.Data public import Complexitylib.Models.RoseTreeMachine.DataEncode - +public import Mathlib.Order.Lattice +public import Std.Tactic.BVDecide.Normalize.Prop /-! # Programs in a rose tree machine (RTM) @@ -30,6 +29,7 @@ semantics and time and space resource consumption. - `ComputableInOSpace` - generic space-complexity in the RTM model -/ + @[expose] public section namespace Complexity diff --git a/Complexitylib/Models/TuringMachine.lean b/Complexitylib/Models/TuringMachine.lean index e1087d8c..760b6012 100644 --- a/Complexitylib/Models/TuringMachine.lean +++ b/Complexitylib/Models/TuringMachine.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Logic.Relation -import Mathlib.Data.Fintype.Pi -import Mathlib.Data.Rat.Defs + +module +public import Mathlib.Data.Fintype.Pi +public import Mathlib.Data.Rat.Init +public import Std.Tactic.BVDecide.Normalize.Prop /-! # Turing machines @@ -55,6 +57,9 @@ Arora–Barak (*Computational Complexity: A Modern Approach*, Definitions - **NTM execution**: Defined via `trace` (a fixed choice sequence), not a relational step. -/ + +@[expose] public section + namespace Complexity /-- The tape alphabet Γ = {0, 1, □, ▷}. -/ diff --git a/Complexitylib/Models/TuringMachine/Combinators.lean b/Complexitylib/Models/TuringMachine/Combinators.lean index 0ec5b375..f516ee0a 100644 --- a/Complexitylib/Models/TuringMachine/Combinators.lean +++ b/Complexitylib/Models/TuringMachine/Combinators.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine -import Mathlib.Data.Fintype.Sum + +module +public import Complexitylib.Models.TuringMachine +public import Mathlib.Data.Fintype.Sum /-! # TM Combinators @@ -53,6 +55,9 @@ The union machine has three phases: between Phase 1 and Phase 2. -/ + +@[expose] public section + namespace Complexity variable {n₁ n₂ : ℕ} diff --git a/Complexitylib/Models/TuringMachine/Combinators/ForBinaryWork.lean b/Complexitylib/Models/TuringMachine/Combinators/ForBinaryWork.lean index 0a48b940..436117ea 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/ForBinaryWork.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/ForBinaryWork.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.ForBinaryWork.Defs -import Complexitylib.Models.TuringMachine.Combinators.ForBinaryWork.Internal + +module +public import Complexitylib.Models.TuringMachine.Combinators.ForBinaryWork.Defs +public import Complexitylib.Models.TuringMachine.Combinators.ForBinaryWork.Internal /-! # Binary work-tape loop combinator @@ -23,6 +25,9 @@ for bitwise algorithms without iterating over the represented numeric value. - `TM.IsTransducer.forBinaryWorkTM` preserves one-way output safety. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Combinators/ForBinaryWork/Defs.lean b/Complexitylib/Models/TuringMachine/Combinators/ForBinaryWork/Defs.lean index 7412fe06..b97a0df0 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/ForBinaryWork/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/ForBinaryWork/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators + +module +public import Complexitylib.Models.TuringMachine.Combinators /-! # Binary work-tape loop combinator -- definitions @@ -15,6 +17,9 @@ width-driven control needed by bitwise algorithms such as schoolbook multiplication, without a numeric-value counter. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Combinators/ForBinaryWork/Internal.lean b/Complexitylib/Models/TuringMachine/Combinators/ForBinaryWork/Internal.lean index bc8b8ec1..90f2041f 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/ForBinaryWork/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/ForBinaryWork/Internal.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.ForBinaryWork.Defs -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Internal -import Complexitylib.Models.TuringMachine.SpaceTime.Internal.Reachability + +module +public import Complexitylib.Models.TuringMachine.Combinators.ForBinaryWork.Defs +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Models.TuringMachine.Internal +public import Complexitylib.Models.TuringMachine.SpaceTime.Internal.Reachability /-! # Binary work-tape loop combinator -- proof internals @@ -15,6 +17,9 @@ This module proves exact body embedding, bit/blank scanner transitions, the advancing loopback seam, certified finite iteration, and transducer closure. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Combinators/ForInput.lean b/Complexitylib/Models/TuringMachine/Combinators/ForInput.lean index 18527800..61c145b7 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/ForInput.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/ForInput.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.ForInput.Defs -import Complexitylib.Models.TuringMachine.Combinators.ForInput.Internal + +module +public import Complexitylib.Models.TuringMachine.Combinators.ForInput.Defs +public import Complexitylib.Models.TuringMachine.Combinators.ForInput.Internal /-! # Read-only-input loop combinator @@ -22,6 +24,9 @@ counterpart of the unary-work-register loop `TM.forRegTM`. loop run respects the certified auxiliary-space budget. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Combinators/ForInput/Defs.lean b/Complexitylib/Models/TuringMachine/Combinators/ForInput/Defs.lean index 3dbfbee8..cd20212c 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/ForInput/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/ForInput/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators + +module +public import Complexitylib.Models.TuringMachine.Combinators /-! # Read-only-input loop combinator — definitions @@ -14,6 +16,9 @@ invocation per original input bit. The input itself is the loop fuel, so the combinator does not materialize a linear-size unary counter on an auxiliary tape. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Combinators/ForInput/Internal.lean b/Complexitylib/Models/TuringMachine/Combinators/ForInput/Internal.lean index 6deb5cf4..5bd8852f 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/ForInput/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/ForInput/Internal.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.ForInput.Defs -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Internal -import Complexitylib.Models.TuringMachine.SpaceTime.Internal.Reachability + +module +public import Complexitylib.Models.TuringMachine.Combinators.ForInput.Defs +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Models.TuringMachine.Internal +public import Complexitylib.Models.TuringMachine.SpaceTime.Internal.Reachability /-! # Read-only-input loop combinator — proof internals @@ -15,6 +17,9 @@ This module supplies the exact body-simulation embedding and the structural one-way-output proof for `TM.forInputTM`. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Combinators/ForWorkOnes.lean b/Complexitylib/Models/TuringMachine/Combinators/ForWorkOnes.lean index 8b2e1567..684147ba 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/ForWorkOnes.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/ForWorkOnes.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.ForWorkOnes.Defs -import Complexitylib.Models.TuringMachine.Combinators.ForWorkOnes.Internal + +module +public import Complexitylib.Models.TuringMachine.Combinators.ForWorkOnes.Defs +public import Complexitylib.Models.TuringMachine.Combinators.ForWorkOnes.Internal /-! # One-prefix work-tape loop combinator @@ -21,6 +23,9 @@ the RAM snapshot word decoder. - `TM.IsTransducer.forWorkOnesTM` preserves one-way output safety. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Combinators/ForWorkOnes/Defs.lean b/Complexitylib/Models/TuringMachine/Combinators/ForWorkOnes/Defs.lean index 0d17f94c..fe42c4a8 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/ForWorkOnes/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/ForWorkOnes/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators + +module +public import Complexitylib.Models.TuringMachine.Combinators /-! # One-prefix work-tape loop combinator — definitions @@ -19,6 +21,9 @@ driver tape and head. The combinator itself is a concrete `TM`; loop certificates and proofs live in the adjacent internal and surface modules. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Combinators/ForWorkOnes/Internal.lean b/Complexitylib/Models/TuringMachine/Combinators/ForWorkOnes/Internal.lean index 54124f31..68cdee50 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/ForWorkOnes/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/ForWorkOnes/Internal.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.ForWorkOnes.Defs -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Internal + +module +public import Complexitylib.Models.TuringMachine.Combinators.ForWorkOnes.Defs +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic /-! # One-prefix work-tape loop combinator — proof internals @@ -14,6 +15,9 @@ This module proves exact body embedding, driver transitions, certified loop execution, and one-way-output preservation for `TM.forWorkOnesTM`. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Combinators/Internal.lean b/Complexitylib/Models/TuringMachine/Combinators/Internal.lean index 972152e9..3661f7e4 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/Internal.lean @@ -3,14 +3,16 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.Internal.Complement -import Complexitylib.Models.TuringMachine.Combinators.Internal.Seq -import Complexitylib.Models.TuringMachine.Combinators.Internal.If -import Complexitylib.Models.TuringMachine.Combinators.Internal.Loop -import Complexitylib.Models.TuringMachine.Combinators.Internal.Retarget -import Complexitylib.Models.TuringMachine.Combinators.Internal.Scanner -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Combinators.Internal.Union + +module +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Complement +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Seq +public import Complexitylib.Models.TuringMachine.Combinators.Internal.If +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Loop +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Retarget +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Scanner +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Union /-! # Combinator proof internals (aggregation) diff --git a/Complexitylib/Models/TuringMachine/Combinators/Internal/Complement.lean b/Complexitylib/Models/TuringMachine/Combinators/Internal/Complement.lean index 1f9ed40d..f4c3680c 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/Internal/Complement.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/Internal/Complement.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Internal + +module +public import Complexitylib.Models.TuringMachine.Combinators +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Models.TuringMachine.Internal /-! # Complement TM: proof internals @@ -14,6 +16,9 @@ This file provides the simulation lemmas for `TM.complementTM`, showing that the complement machine correctly flips the output of the original TM. -/ + +@[expose] public section + namespace Complexity variable {n : ℕ} diff --git a/Complexitylib/Models/TuringMachine/Combinators/Internal/Generic.lean b/Complexitylib/Models/TuringMachine/Combinators/Internal/Generic.lean index 80f2994d..38fc6894 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/Internal/Generic.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/Internal/Generic.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators + +module +public import Complexitylib.Models.TuringMachine.Combinators /-! # Generic proof tools for TM combinators @@ -37,6 +39,9 @@ and `ComplementInternal`. These lemmas were previously duplicated across multiple Internal files. -/ + +@[expose] public section + namespace Complexity variable {n : ℕ} diff --git a/Complexitylib/Models/TuringMachine/Combinators/Internal/If.lean b/Complexitylib/Models/TuringMachine/Combinators/Internal/If.lean index ff258729..f4ecd648 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/Internal/If.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/Internal/If.lean @@ -3,8 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic + +module +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic /-! # ifTM simulation — proof internals @@ -18,6 +19,9 @@ This file contains the simulation lemmas for `ifTM tmTest tmThen tmElse`. - `ifElseWrap` — embed a `tmElse` config into the `ifTM` config space -/ + +@[expose] public section + namespace Complexity variable {n : ℕ} diff --git a/Complexitylib/Models/TuringMachine/Combinators/Internal/Loop.lean b/Complexitylib/Models/TuringMachine/Combinators/Internal/Loop.lean index 0582db29..e544f80b 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/Internal/Loop.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/Internal/Loop.lean @@ -3,8 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic + +module +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic /-! # loopTM simulation — proof internals @@ -18,6 +19,9 @@ This file contains the simulation lemmas for `loopTM tmBody tmTest`. - Tape transformations use the shared `transitionTape` / `transitionInput` -/ + +@[expose] public section + namespace Complexity variable {n : ℕ} diff --git a/Complexitylib/Models/TuringMachine/Combinators/Internal/Retarget.lean b/Complexitylib/Models/TuringMachine/Combinators/Internal/Retarget.lean index 02bc0167..aedb9175 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/Internal/Retarget.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/Internal/Retarget.lean @@ -3,12 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Internal -import Complexitylib.Models.TuringMachine.Hoare.Defs -import Complexitylib.Models.TuringMachine.Subroutines.Counter -import Complexitylib.Models.TuringMachine.Subroutines.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.Counter +public import Complexitylib.Models.TuringMachine.Subroutines.Internal /-! # retargetInput simulation — proof internals @@ -67,6 +65,9 @@ cell 0 are no-ops) — captured by `Tape.StartInvariant` below and preserved across `TM.step` by `Tape.StartInvariant.step`. -/ + +@[expose] public section + namespace Complexity variable {k : ℕ} diff --git a/Complexitylib/Models/TuringMachine/Combinators/Internal/Scanner.lean b/Complexitylib/Models/TuringMachine/Combinators/Internal/Scanner.lean index b1be1c09..5293748e 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/Internal/Scanner.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/Internal/Scanner.lean @@ -3,8 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic + +module +public import Complexitylib.Models.TuringMachine.Combinators +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Std.Tactic.BVDecide.Normalize.BitVec /-! # Correctness of the generic finite-state scanner @@ -20,6 +23,9 @@ Proofs that `TM.scannerTM` correctly implements a left-to-right fold with characterized by `x ∈ L ↔ finalOutput (x.foldl scanStep s₀) = Γw.one`. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Combinators/Internal/Seq.lean b/Complexitylib/Models/TuringMachine/Combinators/Internal/Seq.lean index 1ccff397..588c31b7 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/Internal/Seq.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/Internal/Seq.lean @@ -3,8 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic + +module +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic /-! # seqTM simulation — proof internals @@ -18,6 +19,9 @@ This file contains the simulation lemmas for `seqTM tm₁ tm₂`. - Tape transformations use the shared `transitionTape` / `transitionInput` -/ + +@[expose] public section + namespace Complexity variable {n : ℕ} diff --git a/Complexitylib/Models/TuringMachine/Combinators/Internal/Union.lean b/Complexitylib/Models/TuringMachine/Combinators/Internal/Union.lean index 61016784..a747c691 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/Internal/Union.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/Internal/Union.lean @@ -3,9 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Internal -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic + +module +public import Complexitylib.Models.TuringMachine.Combinators +public import Complexitylib.Models.TuringMachine.Internal /-! # unionTM simulation — proof internals @@ -33,6 +34,9 @@ The proof proceeds in three phases: - `unionPhase1Cfg` — embedding of a tm₁ config into the union machine's config space -/ + +@[expose] public section + namespace Complexity variable {n₁ n₂ : ℕ} diff --git a/Complexitylib/Models/TuringMachine/Combinators/RetargetCompute.lean b/Complexitylib/Models/TuringMachine/Combinators/RetargetCompute.lean index 7ba48c9f..4711812c 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/RetargetCompute.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/RetargetCompute.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.RetargetCompute.Defs -import Complexitylib.Models.TuringMachine.Combinators.RetargetCompute.Internal + +module +public import Complexitylib.Models.TuringMachine.Combinators.RetargetCompute.Defs +public import Complexitylib.Models.TuringMachine.Combinators.RetargetCompute.Internal /-! # Retargeted-input computation seams @@ -28,6 +30,9 @@ positive advertised time bound. - `TM.placeWorkTM_retargetInputStarted_decidesVirtual` — placed decision seam -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Combinators/RetargetCompute/Defs.lean b/Complexitylib/Models/TuringMachine/Combinators/RetargetCompute/Defs.lean index df8aed8b..e9597f77 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/RetargetCompute/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/RetargetCompute/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators + +module +public import Complexitylib.Models.TuringMachine.Combinators /-! # Retargeted-input computation seams @@ -21,6 +23,9 @@ sentinel transition while reading its input from the last work tape. - `TM.retargetInputStartedCfg` — canonical entry configuration for a virtual input -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Combinators/RetargetCompute/Internal.lean b/Complexitylib/Models/TuringMachine/Combinators/RetargetCompute/Internal.lean index 151031ee..9ccaf0ad 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/RetargetCompute/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/RetargetCompute/Internal.lean @@ -3,10 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.RetargetCompute.Defs -import Complexitylib.Models.TuringMachine.Combinators.Internal.Retarget -import Complexitylib.Models.TuringMachine.Hoare.Defs -import Complexitylib.Models.TuringMachine.Placement.Internal + +module +public import Complexitylib.Models.TuringMachine.Combinators.RetargetCompute.Defs +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Retarget +public import Complexitylib.Models.TuringMachine.Placement.Internal /-! # Retargeted-input computation seam internals @@ -17,6 +18,9 @@ separately: such a machine can compute only the empty output, and the wrapper therefore halts immediately on its parked blank output tape. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Combinators/WorkBranch.lean b/Complexitylib/Models/TuringMachine/Combinators/WorkBranch.lean index 7f1db144..a2457e4e 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/WorkBranch.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/WorkBranch.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch.Defs -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch.Internal + +module +public import Complexitylib.Models.TuringMachine.Combinators.WorkBranch.Defs +public import Complexitylib.Models.TuringMachine.Combinators.WorkBranch.Internal /-! # Direct work-symbol branch combinator @@ -30,6 +32,9 @@ heads reading `▷` must move right. - `TM.IsTransducer.branchWorkBlankTM` preserves one-way output behavior. -/ + +@[expose] public section + namespace Complexity namespace Tape diff --git a/Complexitylib/Models/TuringMachine/Combinators/WorkBranch/Defs.lean b/Complexitylib/Models/TuringMachine/Combinators/WorkBranch/Defs.lean index 73c7837d..e813d3af 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/WorkBranch/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/WorkBranch/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators + +module +public import Complexitylib.Models.TuringMachine.Combinators /-! # Direct work-symbol branch combinator -- definitions @@ -14,6 +16,9 @@ dispatcher uses the ordinary read-back action on every tape and never uses the output tape as control storage. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Combinators/WorkBranch/Internal.lean b/Complexitylib/Models/TuringMachine/Combinators/WorkBranch/Internal.lean index aea156c0..8cd90256 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/WorkBranch/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/WorkBranch/Internal.lean @@ -3,17 +3,21 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Mathlib.NatBits -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch.Defs -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.SpaceTime.Internal.Reachability -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs + +module +public import Complexitylib.Mathlib.NatBits +public import Complexitylib.Models.TuringMachine.Combinators.WorkBranch.Defs +public import Complexitylib.Models.TuringMachine.Hoare.Space +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs +public import Mathlib.Algebra.Order.Group.Nat /-! # Direct work-symbol branch combinator -- proof internals -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Combinators/WorkSymbolBranch.lean b/Complexitylib/Models/TuringMachine/Combinators/WorkSymbolBranch.lean index 722098d1..c82f1b4a 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/WorkSymbolBranch.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/WorkSymbolBranch.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.WorkSymbolBranch.Defs -import Complexitylib.Models.TuringMachine.Combinators.WorkSymbolBranch.Internal -import Complexitylib.Models.TuringMachine.Hoare.Space + +module +public import Complexitylib.Models.TuringMachine.Combinators.WorkSymbolBranch.Defs +public import Complexitylib.Models.TuringMachine.Combinators.WorkSymbolBranch.Internal +public import Complexitylib.Models.TuringMachine.Hoare.Space /-! # Direct work-symbol branch combinator @@ -15,6 +17,9 @@ arbitrary work-tape symbol. It is the direct controller primitive used to branch on the readable sparse-entry equality flag. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Combinators/WorkSymbolBranch/Defs.lean b/Complexitylib/Models/TuringMachine/Combinators/WorkSymbolBranch/Defs.lean index a86f5973..5f07b5aa 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/WorkSymbolBranch/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/WorkSymbolBranch/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch.Defs + +module +public import Complexitylib.Models.TuringMachine.Combinators.WorkBranch.Defs /-! # Direct work-symbol branch combinator — definitions @@ -13,6 +15,9 @@ and runs `onEqual` exactly when the current symbol equals `symbol`. This is the generic controller branch used by the sparse RAM lookup scan. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Combinators/WorkSymbolBranch/Internal.lean b/Complexitylib/Models/TuringMachine/Combinators/WorkSymbolBranch/Internal.lean index d9c5d1fd..ed808acf 100644 --- a/Complexitylib/Models/TuringMachine/Combinators/WorkSymbolBranch/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Combinators/WorkSymbolBranch/Internal.lean @@ -3,13 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Combinators.WorkSymbolBranch.Defs + +module +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Models.TuringMachine.Combinators.WorkSymbolBranch.Defs /-! # Direct work-symbol branch combinator — proof internals -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Composition.lean b/Complexitylib/Models/TuringMachine/Composition.lean index 2a23ffcf..852f4cdd 100644 --- a/Complexitylib/Models/TuringMachine/Composition.lean +++ b/Complexitylib/Models/TuringMachine/Composition.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Composition.Defs -import Complexitylib.Models.TuringMachine.Composition.Internal + +module +public import Complexitylib.Models.TuringMachine.Composition.Defs +public import Complexitylib.Models.TuringMachine.Composition.Internal /-! # Sequential composition after function computation @@ -21,6 +23,9 @@ first delimiter. - `TM.compositionTM_decidesInTime` — function computation followed by a decider -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Composition/Defs.lean b/Complexitylib/Models/TuringMachine/Composition/Defs.lean index 79eb0068..3b6ec604 100644 --- a/Complexitylib/Models/TuringMachine/Composition/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Composition/Defs.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.RetargetCompute.Defs -import Complexitylib.Models.TuringMachine.Lift -import Complexitylib.Models.TuringMachine.Placement.Defs -import Complexitylib.Models.TuringMachine.Subroutines + +module +public import Complexitylib.Models.TuringMachine.Combinators.RetargetCompute.Defs +public import Complexitylib.Models.TuringMachine.Lift +public import Complexitylib.Models.TuringMachine.Placement.Defs +public import Complexitylib.Models.TuringMachine.Subroutines /-! # Sequential composition after function computation @@ -28,6 +30,9 @@ The raw output is rewound and copied to the fresh virtual-input tape before `tmG` resumes after its compulsory first transition off the left-end markers. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Composition/Internal.lean b/Complexitylib/Models/TuringMachine/Composition/Internal.lean index db10e91f..42bb0b9c 100644 --- a/Complexitylib/Models/TuringMachine/Composition/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Composition/Internal.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Composition.Internal.FirstPhase -import Complexitylib.Models.TuringMachine.Composition.Internal.Tail -import Complexitylib.Models.TuringMachine.OutputBounds + +module +public import Complexitylib.Models.TuringMachine.Composition.Internal.FirstPhase +public import Complexitylib.Models.TuringMachine.Composition.Internal.Tail +public import Complexitylib.Models.TuringMachine.OutputBounds /-! # Sequential composition correctness — proof internals @@ -15,6 +17,9 @@ boundary to the normalization tail. It derives coarse monotone time bounds for both function composition and preprocessing followed by a language decider. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Composition/Internal/FirstPhase.lean b/Complexitylib/Models/TuringMachine/Composition/Internal/FirstPhase.lean index 661b7013..3cfaebef 100644 --- a/Complexitylib/Models/TuringMachine/Composition/Internal/FirstPhase.lean +++ b/Complexitylib/Models/TuringMachine/Composition/Internal/FirstPhase.lean @@ -3,9 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Composition.Defs -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Placement.Internal + +module +public import Complexitylib.Models.TuringMachine.Composition.Defs +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Models.TuringMachine.Placement.Internal +public import Complexitylib.Models.TuringMachine.Internal /-! # Function composition: first-phase boundary @@ -15,6 +18,9 @@ raw-output work tape, places that run in the composite layout, and exposes the exact tape facts required by the normalization tail. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Composition/Internal/Tail.lean b/Complexitylib/Models/TuringMachine/Composition/Internal/Tail.lean index 6c425f77..1d0b0ee8 100644 --- a/Complexitylib/Models/TuringMachine/Composition/Internal/Tail.lean +++ b/Complexitylib/Models/TuringMachine/Composition/Internal/Tail.lean @@ -3,11 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Composition.Defs -import Complexitylib.Models.TuringMachine.Subroutines.CopyWorkOutput -import Complexitylib.Models.TuringMachine.Combinators.RetargetCompute -import Complexitylib.Models.TuringMachine.Hoare -import Complexitylib.Models.TuringMachine.Tape.Encoding + +module +public import Complexitylib.Models.TuringMachine.Composition.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.CopyWorkOutput +public import Complexitylib.Models.TuringMachine.Combinators.RetargetCompute /-! # Sequential-composition tail pipeline @@ -24,6 +24,9 @@ The phase-expanded bound is which simplifies to `B + 2 * |y| + 9 + G(|y|)`. -/ + +@[expose] public section + namespace Complexity namespace TM @@ -43,7 +46,7 @@ private theorem transitionTape_eq_of_startInvariant {t : Tape} transitionTape_eq_self (read_ne_start_of_startInvariant hinv hhead) /-- Boundary contract consumed only by the proof-internal composition tail. -/ -private def CompositionTailPre (nf ng : ℕ) (y : List Bool) (B : ℕ) +def CompositionTailPre (nf ng : ℕ) (y : List Bool) (B : ℕ) (inp : Tape) (work : Fin (compositionTapeCount nf ng) → Tape) (out : Tape) : Prop := (work (compositionRawOutputIdx nf ng)).HasOutput y ∧ diff --git a/Complexitylib/Models/TuringMachine/Composition/PairWithInput.lean b/Complexitylib/Models/TuringMachine/Composition/PairWithInput.lean index 4ca7ad31..7ce3a051 100644 --- a/Complexitylib/Models/TuringMachine/Composition/PairWithInput.lean +++ b/Complexitylib/Models/TuringMachine/Composition/PairWithInput.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Composition.PairWithInput.Defs -import Complexitylib.Models.TuringMachine.Composition.PairWithInput.Internal + +module +public import Complexitylib.Models.TuringMachine.Composition.PairWithInput.Defs +public import Complexitylib.Models.TuringMachine.Composition.PairWithInput.Internal /-! # Pair a computed value with the original input @@ -18,6 +20,9 @@ retaining a concrete polynomial-preserving time bound. - `TM.pairWithInputTM_computesInTime` — computation paired with original input -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Composition/PairWithInput/Defs.lean b/Complexitylib/Models/TuringMachine/Composition/PairWithInput/Defs.lean index bbb01e33..d3344a7c 100644 --- a/Complexitylib/Models/TuringMachine/Composition/PairWithInput/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Composition/PairWithInput/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Composition.Defs -import Complexitylib.Models.TuringMachine.Subroutines.PairEmit.Defs + +module +public import Complexitylib.Models.TuringMachine.Composition.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.PairEmit.Defs /-! # Pair a computed value with the original input @@ -16,6 +18,9 @@ directly to the real output. Only the first raw-output delimiter is semantic; later cells may contain arbitrary non-`▷` junk. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Composition/PairWithInput/Internal.lean b/Complexitylib/Models/TuringMachine/Composition/PairWithInput/Internal.lean index b375de17..5b982125 100644 --- a/Complexitylib/Models/TuringMachine/Composition/PairWithInput/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Composition/PairWithInput/Internal.lean @@ -3,12 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Composition.Internal.FirstPhase -import Complexitylib.Models.TuringMachine.Composition.PairWithInput.Defs -import Complexitylib.Models.TuringMachine.Hoare -import Complexitylib.Models.TuringMachine.OutputBounds -import Complexitylib.Models.TuringMachine.Subroutines.Internal -import Complexitylib.Models.TuringMachine.Subroutines.PairEmit + +module +public import Complexitylib.Models.TuringMachine.Composition.Internal.FirstPhase +public import Complexitylib.Models.TuringMachine.Composition.PairWithInput.Defs +public import Complexitylib.Models.TuringMachine.OutputBounds +public import Complexitylib.Models.TuringMachine.Subroutines.Internal +public import Complexitylib.Models.TuringMachine.Subroutines.PairEmit /-! # Pair a computed value with the original input — proof internals @@ -17,6 +18,9 @@ This module verifies the generic fanout pipeline defined in `Composition.PairWithInput.Defs`. -/ + +@[expose] public section + namespace Complexity namespace TM @@ -26,7 +30,7 @@ variable {nf : ℕ} /-- Boundary contract after the source computation has redirected its output. Both source heads remain within `B`, every tape is safely parked away from the left marker, and the real output is fresh for pair emission. -/ -private def PairWithInputTailPre (nf : ℕ) (first second : List Bool) (B : ℕ) +def PairWithInputTailPre (nf : ℕ) (first second : List Bool) (B : ℕ) (inp : Tape) (work : Fin (pairWithInputTapeCount nf) → Tape) (out : Tape) : Prop := let raw := pairWithInputRawOutputIdx nf diff --git a/Complexitylib/Models/TuringMachine/Deterministic.lean b/Complexitylib/Models/TuringMachine/Deterministic.lean index a0bc7000..fab450cc 100644 --- a/Complexitylib/Models/TuringMachine/Deterministic.lean +++ b/Complexitylib/Models/TuringMachine/Deterministic.lean @@ -3,8 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Internal -import Complexitylib.Models.TuringMachine.SingleTape + +module +public import Complexitylib.Models.TuringMachine.SingleTape /-! # Deterministic NTMs → DTMs @@ -30,6 +31,9 @@ deterministic machines: `singleTapeSimTime k T = fun n => 16 * (k + 1) * (T n + n + 1) ^ 2`. -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine.lean b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine.lean index 349faffa..26553ed3 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Defs -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Internal + +module +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Defs +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Internal /-! # Proof-carrying binary stream routines @@ -32,6 +34,9 @@ this initial layer. - `BinaryRoutine.emitRawGateStep_sound` adapts one streaming raw gate. -/ + +@[expose] public section + namespace Complexity namespace BinaryRoutine diff --git a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Arithmetic.lean b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Arithmetic.lean index 878b7826..375e47da 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Arithmetic.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Arithmetic.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic.Defs -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic.Internal + +module +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic.Defs +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic.Internal /-! # Arithmetic leaves for proof-carrying binary routines @@ -22,6 +24,9 @@ word, time bound, and all-prefix space bound to its concrete Turing machine. - `emitNatCode_sound` and `emitRawGate_sound` cover the two encoding leaves. -/ + +@[expose] public section + namespace Complexity namespace BinaryRoutine diff --git a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Arithmetic/Defs.lean b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Arithmetic/Defs.lean index 4f51a952..c81a196a 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Arithmetic/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Arithmetic/Defs.lean @@ -3,14 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.NatCode.Defs -import Complexitylib.Circuits.Encoding.Machine.RawGate.Defs -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAdd.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryMulAdd.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPolynomial.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ClearWork.Defs + +module +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPolynomial.Defs +public import Mathlib.Algebra.Polynomial.Eval.Defs /-! # Arithmetic leaves for proof-carrying binary routines -- definitions @@ -20,6 +17,9 @@ pure value-vector interface. Static index separation and reusable-zero requirements remain explicit in `BinaryRoutine.requires`. -/ + +@[expose] public section + namespace Complexity namespace BinaryRoutine diff --git a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Arithmetic/Internal.lean b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Arithmetic/Internal.lean index e23e2567..dc283e46 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Arithmetic/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Arithmetic/Internal.lean @@ -3,20 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.NatCode -import Complexitylib.Circuits.Encoding.Machine.RawGate -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAdd -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst -import Complexitylib.Models.TuringMachine.Subroutines.BinaryMulAdd -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPolynomial -import Complexitylib.Models.TuringMachine.Subroutines.ClearWork + +module +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPolynomial /-! # Arithmetic leaves for proof-carrying binary routines -- proof internals -/ + +@[expose] public section + namespace Complexity namespace BinaryRoutine diff --git a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Control.lean b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Control.lean index 0a8c048b..60cd3ef3 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Control.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Control.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control.Defs -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control.Internal + +module +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control.Defs +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control.Internal /-! # Proof-carrying binary routine control @@ -26,6 +28,9 @@ Thus many iterations can retain logarithmic auxiliary space. - `TM.BinaryForSegmentSpaceSpec.prefix_withinAuxSpace` covers all prefixes. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Control/Defs.lean b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Control/Defs.lean index 3008ccb8..2a56535e 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Control/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Control/Defs.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch.Defs -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Defs + +module +public import Complexitylib.Models.TuringMachine.Combinators.WorkBranch.Defs +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Defs /-! # Proof-carrying binary routine control -- definitions @@ -20,6 +21,9 @@ bounded iteration witnesses because `BinaryRoutine.Sound` advertises an upper bound rather than an exact runtime. Comparisons and endpoints remain exact. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Control/Internal.lean b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Control/Internal.lean index 7b65655f..c7552b9b 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Control/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Control/Internal.lean @@ -3,18 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.WorkBranch -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control.Defs -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor -import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Internal.Control -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc + +module +public import Complexitylib.Models.TuringMachine.Combinators.WorkBranch +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control.Defs /-! # Proof-carrying binary routine control -- proof internals -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Defs.lean b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Defs.lean index 6d0e9a8e..fbbd0c54 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Defs.lean @@ -3,12 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.GateStream.Defs -import Complexitylib.Models.TuringMachine.Hoare.Space.Defs -import Complexitylib.Models.TuringMachine.Registers.Emit -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs + +module +public import Complexitylib.Circuits.Encoding.Machine.GateStream.Defs +public import Complexitylib.Models.TuringMachine.Hoare.Space.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred.Defs +public import Complexitylib.Circuits.Encoding.Defs /-! # Proof-carrying binary stream routines -- definitions @@ -20,6 +21,9 @@ supports honest partial leaves such as positive predecessor and zero-scratch copying without weakening the canonical state model. -/ + +@[expose] public section + namespace Complexity /-- Pure values represented by all work tapes of a binary routine. -/ diff --git a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/InputLength.lean b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/InputLength.lean index 1da66970..5f14db02 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/InputLength.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/InputLength.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.InputLength.Defs -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.InputLength.Internal + +module +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.InputLength.Defs +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.InputLength.Internal /-! # Fresh-input entry for proof-carrying binary routines @@ -20,6 +22,9 @@ the resulting routine inherits a total all-prefix `ComputesInSpace` contract. transducer. -/ + +@[expose] public section + namespace Complexity namespace BinaryRoutine diff --git a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/InputLength/Defs.lean b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/InputLength/Defs.lean index 909254cd..cd7a106c 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/InputLength/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/InputLength/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryLength.Defs + +module +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryLength.Defs /-! # Fresh-input entry for proof-carrying binary routines -- definitions @@ -14,6 +16,9 @@ binary work-vector discipline. It first counts the unary input length into one designated work tape, then runs a proof-carrying binary routine. -/ + +@[expose] public section + namespace Complexity namespace BinaryRoutine diff --git a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/InputLength/Internal.lean b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/InputLength/Internal.lean index 9e88fe4c..f614463b 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/InputLength/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/InputLength/Internal.lean @@ -3,15 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.InputLength.Defs -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Subroutines.BinaryLength + +module +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.InputLength.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryLength /-! # Fresh-input entry for proof-carrying binary routines -- proof internals -/ + +@[expose] public section + namespace Complexity namespace BinaryRoutine diff --git a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Internal.lean b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Internal.lean index cb05a5ae..69f680b8 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/Internal.lean @@ -3,12 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Circuits.Encoding.Machine.GateStream -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Defs -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc + +module +public import Complexitylib.Circuits.Encoding.Machine.GateStream +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred /-! # Proof-carrying binary stream routines -- proof internals @@ -18,6 +18,9 @@ frames, lifts frame-oriented arithmetic contracts through an arbitrary output accumulator, and composes routines across the parked `seqTM` phase boundary. -/ + +@[expose] public section + namespace Complexity namespace BinaryRoutine diff --git a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/List.lean b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/List.lean index bc0e160a..8775f464 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/List.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/List.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List.Defs -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List.Internal + +module +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List.Defs +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List.Internal /-! # Finite composition of proof-carrying binary routines @@ -14,6 +16,9 @@ unrolled into ordinary lists. This module proves their composition sound once, leaving only genuinely input-dependent ranges to the binary loop adapter. -/ + +@[expose] public section + namespace Complexity namespace BinaryRoutine diff --git a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/List/Defs.lean b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/List/Defs.lean index cae14a9c..025181f5 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/List/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/List/Defs.lean @@ -3,12 +3,17 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Defs + +module +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Defs /-! # Finite composition of proof-carrying binary routines -- definitions -/ + +@[expose] public section + namespace Complexity namespace BinaryRoutine diff --git a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/List/Internal.lean b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/List/Internal.lean index c4f38829..a699f570 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/List/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/List/Internal.lean @@ -3,13 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List.Defs + +module +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List.Defs /-! # Finite composition of proof-carrying binary routines -- proof internals -/ + +@[expose] public section + namespace Complexity namespace BinaryRoutine diff --git a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/SpaceBounds.lean b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/SpaceBounds.lean index 9434f6bf..a0bb175e 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/SpaceBounds.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/SpaceBounds.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.SpaceBounds.Defs -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.SpaceBounds.Internal + +module +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.SpaceBounds.Defs +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.SpaceBounds.Internal /-! # Compositional width bounds for binary routines @@ -17,6 +19,9 @@ resulting auxiliary-space bound. A final polynomial width bound converts the composed certificate to logarithmic space. -/ + +@[expose] public section + namespace Complexity namespace BinaryRoutine diff --git a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/SpaceBounds/Defs.lean b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/SpaceBounds/Defs.lean index 4a2d6c66..aaaa8ad3 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/SpaceBounds/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/SpaceBounds/Defs.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Asymptotics -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control.Defs -import Mathlib.Data.Nat.Pairing + +module +public import Complexitylib.Asymptotics +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Control.Defs /-! # Compositional width bounds for binary routines -- definitions @@ -16,6 +17,9 @@ while `BinaryForSpaceEnvelope` bounds an input-dependent loop by one envelope covering every reachable comparison, body invocation, and successor. -/ + +@[expose] public section + namespace Complexity namespace BinaryRoutine diff --git a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/SpaceBounds/Internal.lean b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/SpaceBounds/Internal.lean index aa79ed28..0f04ed1c 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/SpaceBounds/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/BinaryRoutine/SpaceBounds/Internal.lean @@ -3,15 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.SpaceBounds.Defs -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic -import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc + +module +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.SpaceBounds.Defs +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.Arithmetic.Defs +public import Complexitylib.Models.TuringMachine.Experimental.BinaryRoutine.List.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd /-! # Compositional width bounds for binary routines -- proof internals -/ + +@[expose] public section + namespace Complexity namespace BinaryRoutine diff --git a/Complexitylib/Models/TuringMachine/Experimental/EmitSpec.lean b/Complexitylib/Models/TuringMachine/Experimental/EmitSpec.lean index b146c2dd..7a51ddac 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/EmitSpec.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/EmitSpec.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Registers.Emit + +module +public import Complexitylib.Models.TuringMachine.Registers.Emit /-! # Experimental effect contracts for emitter machines @@ -24,6 +26,9 @@ indexed list fold with one uniform per-stage bound, while `EmitSpec` handles short heterogeneous machine trees and retains each stage's structural bound. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Experimental/Routine.lean b/Complexitylib/Models/TuringMachine/Experimental/Routine.lean index 1f54e9ae..5b645b72 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/Routine.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/Routine.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Experimental.Routine.Defs -import Complexitylib.Models.TuringMachine.Experimental.Routine.Internal + +module +public import Complexitylib.Models.TuringMachine.Experimental.Routine.Defs +public import Complexitylib.Models.TuringMachine.Experimental.Routine.Internal /-! # Experimental first-order Turing-machine routines @@ -27,6 +29,9 @@ experimental until a second independent construction validates the interface. lower to transducers. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Experimental/Routine/Defs.lean b/Complexitylib/Models/TuringMachine/Experimental/Routine/Defs.lean index 442cc0b6..1dd439c3 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/Routine/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/Routine/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.ForInput.Defs + +module +public import Complexitylib.Models.TuringMachine.Combinators.ForInput.Defs /-! # Experimental first-order Turing-machine routines — definitions @@ -19,6 +21,9 @@ obeys the one-way-output discipline. Its name deliberately does not suggest input preservation, termination, or resource safety. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Experimental/Routine/Internal.lean b/Complexitylib/Models/TuringMachine/Experimental/Routine/Internal.lean index cdb921c7..c8163f5b 100644 --- a/Complexitylib/Models/TuringMachine/Experimental/Routine/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Experimental/Routine/Internal.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.ForInput -import Complexitylib.Models.TuringMachine.Experimental.Routine.Defs -import Complexitylib.Models.TuringMachine.Hoare.Space + +module +public import Complexitylib.Models.TuringMachine.Combinators.ForInput +public import Complexitylib.Models.TuringMachine.Experimental.Routine.Defs +public import Complexitylib.Models.TuringMachine.Hoare.Space /-! # Experimental first-order Turing-machine routines — proof internals @@ -14,6 +16,9 @@ This module proves that the structural `Routine.TransducerSafe` certificate is preserved by lowering through sequential composition and read-only-input loops. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Hoare.lean b/Complexitylib/Models/TuringMachine/Hoare.lean index 89819b74..e7ae20c5 100644 --- a/Complexitylib/Models/TuringMachine/Hoare.lean +++ b/Complexitylib/Models/TuringMachine/Hoare.lean @@ -3,11 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Hoare.Defs -import Complexitylib.Models.TuringMachine.Combinators.Internal.Seq -import Complexitylib.Models.TuringMachine.Combinators.Internal.If -import Complexitylib.Models.TuringMachine.Combinators.Internal.Loop -import Complexitylib.Models.TuringMachine.Combinators.Internal.Complement + +module +public import Complexitylib.Models.TuringMachine.Hoare.Defs +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Seq +public import Complexitylib.Models.TuringMachine.Combinators.Internal.If +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Complement /-! # Hoare-style composition rules for TM combinators @@ -31,6 +32,9 @@ parked tapes, or `AllTapesWF` together with positive-head facts, provide common stronger certificates. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Hoare/Defs.lean b/Complexitylib/Models/TuringMachine/Hoare/Defs.lean index 9ebc10e9..f0a704f0 100644 --- a/Complexitylib/Models/TuringMachine/Hoare/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Hoare/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine -import Complexitylib.Models.TuringMachine.Internal + +module +public import Complexitylib.Models.TuringMachine +public import Complexitylib.Models.TuringMachine.Internal /-! # Hoare-style specifications for Turing machines @@ -30,6 +32,9 @@ The precondition must imply that the starting configuration has the machine's `qstart` state. The postcondition holds at halting. -/ + +@[expose] public section + namespace Complexity /-- A predicate on the tape configuration: input tape, work tapes, output tape. -/ diff --git a/Complexitylib/Models/TuringMachine/Hoare/RetargetOutput.lean b/Complexitylib/Models/TuringMachine/Hoare/RetargetOutput.lean index 7b8f089f..89044b19 100644 --- a/Complexitylib/Models/TuringMachine/Hoare/RetargetOutput.lean +++ b/Complexitylib/Models/TuringMachine/Hoare/RetargetOutput.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Hoare.Defs -import Complexitylib.Models.TuringMachine.Lift + +module +public import Complexitylib.Models.TuringMachine.Hoare.Defs +public import Complexitylib.Models.TuringMachine.Lift /-! # Hoare contracts for output redirection @@ -14,6 +16,9 @@ source output as the fresh last work tape while pinning the real output to the standard parked blank tape. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Hoare/Space.lean b/Complexitylib/Models/TuringMachine/Hoare/Space.lean index afdfaab3..1d15c420 100644 --- a/Complexitylib/Models/TuringMachine/Hoare/Space.lean +++ b/Complexitylib/Models/TuringMachine/Hoare/Space.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Hoare.Space.Defs -import Complexitylib.Models.TuringMachine.Hoare.Space.Internal + +module +public import Complexitylib.Models.TuringMachine.Hoare.Space.Defs +public import Complexitylib.Models.TuringMachine.Hoare.Space.Internal /-! # Space-aware Hoare specifications @@ -28,6 +30,9 @@ closure, and a fresh-start computation bridge. - `TM.computesInSpace_of_hoareTimeSpace` — package per-input contracts. -/ + +@[expose] public section + namespace Complexity namespace Cfg diff --git a/Complexitylib/Models/TuringMachine/Hoare/Space/Defs.lean b/Complexitylib/Models/TuringMachine/Hoare/Space/Defs.lean index 6cfc0ec8..14259210 100644 --- a/Complexitylib/Models/TuringMachine/Hoare/Space/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Hoare/Space/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Hoare.Defs + +module +public import Complexitylib.Models.TuringMachine.Hoare.Defs /-! # Space-aware Hoare specifications — definitions @@ -13,6 +15,9 @@ computation requires a bound on every reachable configuration. This module pairs those two obligations in one compositional contract. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Hoare/Space/Internal.lean b/Complexitylib/Models/TuringMachine/Hoare/Space/Internal.lean index 491d8f03..04f23f9a 100644 --- a/Complexitylib/Models/TuringMachine/Hoare/Space/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Hoare/Space/Internal.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Hoare.Space.Defs -import Complexitylib.Models.TuringMachine.Hoare -import Complexitylib.Models.TuringMachine.SpaceTime.Internal.Reachability + +module +public import Complexitylib.Models.TuringMachine.Hoare.Space.Defs +public import Complexitylib.Models.TuringMachine.Hoare +public import Complexitylib.Models.TuringMachine.SpaceTime.Internal.Reachability /-! # Space-aware Hoare specifications — proof internals @@ -14,6 +16,9 @@ This module supplies structural rules, sequential composition, and the bridge from fresh-start contracts to `TM.ComputesInSpace`. -/ + +@[expose] public section + namespace Complexity namespace Cfg diff --git a/Complexitylib/Models/TuringMachine/Internal.lean b/Complexitylib/Models/TuringMachine/Internal.lean index 7e164c7e..064f7ec5 100644 --- a/Complexitylib/Models/TuringMachine/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Internal.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine -import Mathlib.Data.Finset.Lattice.Fold + +module +public import Complexitylib.Models.TuringMachine +public import Mathlib.Data.Finset.Lattice.Fold /-! # TM–NTM embedding: proof internals @@ -13,6 +15,9 @@ Helper lemmas for `TM.toNTM_accepts_iff`, showing that the DTM step function and the NTM trace on `toNTM` compute the same thing. -/ + +@[expose] public section + namespace Complexity variable {n : ℕ} diff --git a/Complexitylib/Models/TuringMachine/Internal/OutputBounds.lean b/Complexitylib/Models/TuringMachine/Internal/OutputBounds.lean index 94089e5f..6dba8aeb 100644 --- a/Complexitylib/Models/TuringMachine/Internal/OutputBounds.lean +++ b/Complexitylib/Models/TuringMachine/Internal/OutputBounds.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Internal + +module +public import Complexitylib.Models.TuringMachine.Internal /-! # Output-length bounds — proof internals @@ -16,6 +18,9 @@ unchanged. Public statements are in `Complexitylib.Models.TuringMachine.OutputBounds`. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Lift.lean b/Complexitylib/Models/TuringMachine/Lift.lean index 4a710bd9..fbc84686 100644 --- a/Complexitylib/Models/TuringMachine/Lift.lean +++ b/Complexitylib/Models/TuringMachine/Lift.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators + +module +public import Complexitylib.Models.TuringMachine.Combinators /-! # Tape-layout combinators: extra work tapes and output retargeting @@ -36,6 +38,9 @@ The time bounds are preserved *exactly* (no `+ 1`): the dummy-tape bounce happens during the simulated machine's own first step. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/OutputBounds.lean b/Complexitylib/Models/TuringMachine/OutputBounds.lean index 0c75787f..6ffd244f 100644 --- a/Complexitylib/Models/TuringMachine/OutputBounds.lean +++ b/Complexitylib/Models/TuringMachine/OutputBounds.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Internal.OutputBounds + +module +public import Complexitylib.Models.TuringMachine.Internal.OutputBounds /-! # Output-length bounds @@ -19,6 +21,9 @@ produce at most `t` output bits. - `TM.ComputesInTime.output_length_le` — a time bound also bounds output length -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Placement.lean b/Complexitylib/Models/TuringMachine/Placement.lean index c7de471f..82957fea 100644 --- a/Complexitylib/Models/TuringMachine/Placement.lean +++ b/Complexitylib/Models/TuringMachine/Placement.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Placement.Defs -import Complexitylib.Models.TuringMachine.Placement.Internal + +module +public import Complexitylib.Models.TuringMachine.Placement.Defs +public import Complexitylib.Models.TuringMachine.Placement.Internal /-! # Work-tape placement @@ -22,6 +24,9 @@ are parked away from the left-end marker. - `TM.placeWorkTM_computesInTime` — same-time preservation of computation -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Placement/Defs.lean b/Complexitylib/Models/TuringMachine/Placement/Defs.lean index b1da0875..2c1ea124 100644 --- a/Complexitylib/Models/TuringMachine/Placement/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Placement/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators + +module +public import Complexitylib.Models.TuringMachine.Combinators /-! # Work-tape placement @@ -23,6 +25,9 @@ source machine. - `TM.placeWorkParkedCfg` — the canonical embedding with parked blank extras -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Placement/Internal.lean b/Complexitylib/Models/TuringMachine/Placement/Internal.lean index 989aad48..d31220f9 100644 --- a/Complexitylib/Models/TuringMachine/Placement/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Placement/Internal.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Placement.Defs -import Complexitylib.Models.TuringMachine.Internal + +module +public import Complexitylib.Models.TuringMachine.Placement.Defs /-! # Work-tape placement correctness internals @@ -15,6 +16,9 @@ extra-tape frame by its prescribed idle action. Stable frames and the canonical parked frame are fixed points of that action. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Registers.lean b/Complexitylib/Models/TuringMachine/Registers.lean index bd92219b..850c5f9a 100644 --- a/Complexitylib/Models/TuringMachine/Registers.lean +++ b/Complexitylib/Models/TuringMachine/Registers.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.Counter + +module +public import Complexitylib.Models.TuringMachine.Subroutines.Counter /-! # Unary registers @@ -29,6 +31,9 @@ actions and stable under the combinator phase transitions. - `TM.reg_zero_init_bumped` — a freshly bumped blank tape is `IsReg 0` -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Registers/Arith.lean b/Complexitylib/Models/TuringMachine/Registers/Arith.lean index 496ec7e1..23e2a258 100644 --- a/Complexitylib/Models/TuringMachine/Registers/Arith.lean +++ b/Complexitylib/Models/TuringMachine/Registers/Arith.lean @@ -3,7 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Registers.ForReg + +module +public import Complexitylib.Models.TuringMachine.Registers.ForReg +public import Complexitylib.Models.TuringMachine.Registers.RegisterOps /-! # Derived register arithmetic @@ -17,6 +20,9 @@ Time bounds are deliberately loose (rounded up via `HoareTime.mono_bound`); only their polynomial shape matters downstream. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Registers/DecReg.lean b/Complexitylib/Models/TuringMachine/Registers/DecReg.lean index 4e0c330a..780e8222 100644 --- a/Complexitylib/Models/TuringMachine/Registers/DecReg.lean +++ b/Complexitylib/Models/TuringMachine/Registers/DecReg.lean @@ -3,7 +3,14 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Registers.MixedRadix + +module +public import Complexitylib.Models.TuringMachine.Registers.Emit +public import Mathlib.Data.Rat.Cast.Order +public import Mathlib.Tactic.NormNum.Abs +public import Mathlib.Tactic.NormNum.DivMod +public import Mathlib.Tactic.NormNum.OfScientific +public import Mathlib.Tactic.NormNum.Pow /-! # decRegTM: decrement a register @@ -17,6 +24,9 @@ pairwise at-most-one families iterate over shrinking suffixes. Mirror of `incRegTM` (`RegisterOps.lean`) with an erase phase. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Registers/Emit.lean b/Complexitylib/Models/TuringMachine/Registers/Emit.lean index b5baa8be..11047d00 100644 --- a/Complexitylib/Models/TuringMachine/Registers/Emit.lean +++ b/Complexitylib/Models/TuringMachine/Registers/Emit.lean @@ -3,9 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines -import Complexitylib.Models.TuringMachine.Registers -import Complexitylib.Models.TuringMachine.Hoare + +module +public import Complexitylib.Models.TuringMachine.Registers +public import Complexitylib.Models.TuringMachine.Hoare /-! # Output-emission subroutines @@ -43,6 +44,9 @@ This layer is the foundation for the Cook–Levin reduction emitter - `TM.emitBitsTM_isTransducer` — fixed-word emission never moves output left -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Registers/EmitSeq.lean b/Complexitylib/Models/TuringMachine/Registers/EmitSeq.lean index 5ed5bd1a..8af16247 100644 --- a/Complexitylib/Models/TuringMachine/Registers/EmitSeq.lean +++ b/Complexitylib/Models/TuringMachine/Registers/EmitSeq.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Registers.InputLen + +module +public import Complexitylib.Models.TuringMachine.Registers.RegisterOps /-! # Sequencing emitter stages @@ -15,6 +17,9 @@ to `(W (k+1), Y (k+1))`. All the finite-tuple folds of the reduction emitter transition family) are instances of this single rule. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Registers/ForReg.lean b/Complexitylib/Models/TuringMachine/Registers/ForReg.lean index b9b698da..02e5e532 100644 --- a/Complexitylib/Models/TuringMachine/Registers/ForReg.lean +++ b/Complexitylib/Models/TuringMachine/Registers/ForReg.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Registers.RegisterOps + +module +public import Complexitylib.Models.TuringMachine.Registers.Emit /-! # forRegTM: the register-fueled loop combinator @@ -23,6 +25,9 @@ The Hoare rule `forRegTM_hoareTime` threads an iteration-indexed family of ghost work-tape functions and output words through the loop. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Registers/Horner.lean b/Complexitylib/Models/TuringMachine/Registers/Horner.lean index 547f852e..ec90be7e 100644 --- a/Complexitylib/Models/TuringMachine/Registers/Horner.lean +++ b/Complexitylib/Models/TuringMachine/Registers/Horner.lean @@ -3,9 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Registers.EmitSeq -import Mathlib.Algebra.Polynomial.Eval.Defs -import Mathlib.Algebra.Polynomial.Eval.Degree + +module +public import Complexitylib.Models.TuringMachine.Registers.EmitSeq +public import Mathlib.Algebra.Polynomial.Eval.Defs +public import Mathlib.Algebra.Polynomial.Eval.Degree +public import Complexitylib.Models.TuringMachine.Registers.Arith /-! # Horner layers: polynomial register evaluation @@ -34,6 +37,9 @@ are deliberately loose. - the `_hoareTime` specification of each machine -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Registers/InputLen.lean b/Complexitylib/Models/TuringMachine/Registers/InputLen.lean index c9168b89..9a21d23b 100644 --- a/Complexitylib/Models/TuringMachine/Registers/InputLen.lean +++ b/Complexitylib/Models/TuringMachine/Registers/InputLen.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Registers.Arith + +module +public import Complexitylib.Models.TuringMachine.Registers.RegisterOps /-! # Input length into a register @@ -16,6 +18,9 @@ besides the start-clause emitter, and the last hand-rolled machine of the campaign (`docs/A5-ReductionEmitter.md`). -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Registers/MixedRadix.lean b/Complexitylib/Models/TuringMachine/Registers/MixedRadix.lean index d2d51a6d..8d82d375 100644 --- a/Complexitylib/Models/TuringMachine/Registers/MixedRadix.lean +++ b/Complexitylib/Models/TuringMachine/Registers/MixedRadix.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Registers.Horner + +module +public import Complexitylib.Models.TuringMachine.Registers.Horner /-! # Mixed-radix variable loading and literal emission @@ -21,6 +23,9 @@ a clause is a `bigSeqTM` of `emitVarLitTM`s followed by the clause separator. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Registers/Probe.lean b/Complexitylib/Models/TuringMachine/Registers/Probe.lean index 13344cd9..e80b5b13 100644 --- a/Complexitylib/Models/TuringMachine/Registers/Probe.lean +++ b/Complexitylib/Models/TuringMachine/Registers/Probe.lean @@ -3,7 +3,15 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Registers.MixedRadix + +module +import Mathlib.Tactic.FinCases +public import Complexitylib.Models.TuringMachine.Registers.Emit +public import Mathlib.Data.Rat.Cast.Order +public import Mathlib.Tactic.NormNum.Abs +public import Mathlib.Tactic.NormNum.DivMod +public import Mathlib.Tactic.NormNum.OfScientific +public import Mathlib.Tactic.NormNum.Pow /-! # symProbeTM: read the input symbol at a register-indexed position @@ -18,6 +26,9 @@ clauses of the tableau pin the input cells, so their symbol digits are read off the input tape position by position. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Registers/RegisterOps.lean b/Complexitylib/Models/TuringMachine/Registers/RegisterOps.lean index 8cf95dca..ad7300d1 100644 --- a/Complexitylib/Models/TuringMachine/Registers/RegisterOps.lean +++ b/Complexitylib/Models/TuringMachine/Registers/RegisterOps.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Registers.Emit + +module +public import Complexitylib.Models.TuringMachine.Registers.Emit /-! # Register operations @@ -19,6 +21,9 @@ Specs are in the ghost-parametrized `EmitPred` style: registers are the canonical tapes `regTape v`, and posts are `Function.update` equations. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Repetition.lean b/Complexitylib/Models/TuringMachine/Repetition.lean index cbc3b45c..833e9bbd 100644 --- a/Complexitylib/Models/TuringMachine/Repetition.lean +++ b/Complexitylib/Models/TuringMachine/Repetition.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Repetition.Internal.ScheduleArithmetic + +module +public import Complexitylib.Models.TuringMachine.Repetition.Internal.ScheduleArithmetic /-! # Fixed-time probabilistic-machine repetition @@ -22,6 +24,9 @@ simulation invariants proved in the internal correctness layer. - `NTM.repeatRandomSeed_apply_repeatChoiceIdx` — compact and machine schedules align -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/Repetition/Correctness.lean b/Complexitylib/Models/TuringMachine/Repetition/Correctness.lean index 568c53db..01ec9a32 100644 --- a/Complexitylib/Models/TuringMachine/Repetition/Correctness.lean +++ b/Complexitylib/Models/TuringMachine/Repetition/Correctness.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.EventProb -import Complexitylib.Models.TuringMachine.Repetition.Internal.Correctness + +module +public import Complexitylib.Classes.EventProb +public import Complexitylib.Models.TuringMachine.Repetition.Internal.Correctness /-! # Correctness and amplification for fixed-time repetition @@ -26,6 +28,9 @@ The source machine need only halt on every `T`-step path for the fixed input. - `NTM.repeatAtTime_acceptProb_le_two_pow` — no-instance amplification -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/Repetition/Defs.lean b/Complexitylib/Models/TuringMachine/Repetition/Defs.lean index 5b2dae86..02903ddb 100644 --- a/Complexitylib/Models/TuringMachine/Repetition/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Repetition/Defs.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.FiniteCounting -import Complexitylib.Models.TuringMachine.Combinators -import Mathlib.Logic.Equiv.Fin.Basic + +module +public import Complexitylib.Classes.FiniteCounting +public import Complexitylib.Models.TuringMachine.Combinators /-! # Fixed-time repetition of probabilistic Turing machines @@ -39,6 +40,9 @@ zero-step run votes according to the initial configuration of `tm`. - `NTM.repeatAtTime` — the repeated majority-vote machine -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/Repetition/Internal.lean b/Complexitylib/Models/TuringMachine/Repetition/Internal.lean index e9649c77..060a9678 100644 --- a/Complexitylib/Models/TuringMachine/Repetition/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Repetition/Internal.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Repetition.Defs -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Trace + +module +public import Complexitylib.Models.TuringMachine.Repetition.Defs +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Models.TuringMachine.Trace /-! # Correctness internals for fixed-time repetition @@ -14,6 +16,9 @@ This file proves the local simulation and fixed-rewind invariants used by the public correctness theorems for `NTM.repeatAtTime`. -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/Repetition/Internal/Boundary.lean b/Complexitylib/Models/TuringMachine/Repetition/Internal/Boundary.lean index 95c1aa98..1757ac77 100644 --- a/Complexitylib/Models/TuringMachine/Repetition/Internal/Boundary.lean +++ b/Complexitylib/Models/TuringMachine/Repetition/Internal/Boundary.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Repetition.Internal.Schedule + +module +public import Complexitylib.Models.TuringMachine.Repetition.Internal.Schedule /-! # Exact trial-boundary trace decomposition @@ -21,6 +23,9 @@ lemmas keep all dependent casts out of the outer correctness induction. - `NTM.repeatStrideChoices_trace_split_three` — complete three-phase split -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/Repetition/Internal/Correctness.lean b/Complexitylib/Models/TuringMachine/Repetition/Internal/Correctness.lean index 5b5e2f9d..6b68bc5e 100644 --- a/Complexitylib/Models/TuringMachine/Repetition/Internal/Correctness.lean +++ b/Complexitylib/Models/TuringMachine/Repetition/Internal/Correctness.lean @@ -3,8 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Repetition.Internal.Boundary -import Complexitylib.Models.TuringMachine.Repetition.Internal.Setup + +module +public import Complexitylib.Models.TuringMachine.Repetition.Internal.Boundary +public import Complexitylib.Models.TuringMachine.Repetition.Internal.Setup +public import Complexitylib.Models.TuringMachine.Repetition.Internal.Trial +public import Complexitylib.Models.TuringMachine.Repetition.Internal.VoteStep /-! # Pathwise correctness of fixed-time repetition @@ -20,6 +24,9 @@ and the final trial writes their strict majority. - `NTM.repeatAtTime_trace_correct_internal` — final full-trace majority theorem -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/Repetition/Internal/Finish.lean b/Complexitylib/Models/TuringMachine/Repetition/Internal/Finish.lean index 096d236f..22e1111b 100644 --- a/Complexitylib/Models/TuringMachine/Repetition/Internal/Finish.lean +++ b/Complexitylib/Models/TuringMachine/Repetition/Internal/Finish.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Repetition.Internal + +module +public import Complexitylib.Models.TuringMachine.Repetition.Internal /-! # Setup and finish phases for fixed-time repetition @@ -12,6 +14,9 @@ Correctness lemmas for the zero-time setup path and the final majority-writing transition of `NTM.repeatAtTime`. -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/Repetition/Internal/Frame.lean b/Complexitylib/Models/TuringMachine/Repetition/Internal/Frame.lean index ad7c12d4..6d38d5a2 100644 --- a/Complexitylib/Models/TuringMachine/Repetition/Internal/Frame.lean +++ b/Complexitylib/Models/TuringMachine/Repetition/Internal/Frame.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Repetition.Internal + +module +public import Complexitylib.Models.TuringMachine.Repetition.Internal /-! # Fresh-bank frame invariants for fixed-time repetition @@ -21,6 +23,9 @@ initial configuration. - `NTM.RepeatFrame.finish_next_project` — exact next-trial initialization -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/Repetition/Internal/Parked.lean b/Complexitylib/Models/TuringMachine/Repetition/Internal/Parked.lean index 4b7b562b..d8123a46 100644 --- a/Complexitylib/Models/TuringMachine/Repetition/Internal/Parked.lean +++ b/Complexitylib/Models/TuringMachine/Repetition/Internal/Parked.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Repetition.Internal.Frame -import Complexitylib.Models.TuringMachine.Repetition.Internal.Rewind + +module +public import Complexitylib.Models.TuringMachine.Repetition.Internal.Frame +public import Complexitylib.Models.TuringMachine.Repetition.Internal.Rewind /-! # Parked tape banks for fixed-time repetition @@ -27,6 +29,9 @@ next active bank. - `NTM.RepeatOtherParked.finish` — a nonfinal finish transfers it to the next bank -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/Repetition/Internal/Rewind.lean b/Complexitylib/Models/TuringMachine/Repetition/Internal/Rewind.lean index 7b207f13..b6bbe5ec 100644 --- a/Complexitylib/Models/TuringMachine/Repetition/Internal/Rewind.lean +++ b/Complexitylib/Models/TuringMachine/Repetition/Internal/Rewind.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Repetition.Internal + +module +public import Complexitylib.Models.TuringMachine.Repetition.Internal /-! # Fixed-time rewind correctness for PTM repetition @@ -27,6 +29,9 @@ this administrative phase. - `NTM.repeatAtTime_trace_rewind_bound` — finish state, parked active tapes, frame -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/Repetition/Internal/Schedule.lean b/Complexitylib/Models/TuringMachine/Repetition/Internal/Schedule.lean index 0eb20ef8..f6f447d3 100644 --- a/Complexitylib/Models/TuringMachine/Repetition/Internal/Schedule.lean +++ b/Complexitylib/Models/TuringMachine/Repetition/Internal/Schedule.lean @@ -3,10 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Repetition.Defs -import Complexitylib.Models.TuringMachine.Repetition.Internal.Parked -import Complexitylib.Models.TuringMachine.Repetition.Internal.ScheduleArithmetic -import Complexitylib.Models.TuringMachine.Repetition.Internal.VoteStep + +module +public import Complexitylib.Models.TuringMachine.Repetition.Internal.Parked +public import Complexitylib.Models.TuringMachine.Repetition.Internal.ScheduleArithmetic +public import Complexitylib.Models.TuringMachine.Repetition.Internal.Votes /-! # Outer schedule and boundary assertions for fixed-time repetition @@ -28,6 +29,9 @@ index algebra, choice slices, vote bookkeeping, and target predicate. - `NTM.RepeatBoundary`, `RepeatOuterClaim` — outer-induction specification -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/Repetition/Internal/ScheduleArithmetic.lean b/Complexitylib/Models/TuringMachine/Repetition/Internal/ScheduleArithmetic.lean index 53c5ccde..c12ab098 100644 --- a/Complexitylib/Models/TuringMachine/Repetition/Internal/ScheduleArithmetic.lean +++ b/Complexitylib/Models/TuringMachine/Repetition/Internal/ScheduleArithmetic.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Repetition.Defs + +module +public import Complexitylib.Models.TuringMachine.Repetition.Defs /-! # Schedule arithmetic internals for fixed-time repetition @@ -14,6 +16,9 @@ proofs below the public surface prevents internal correctness modules from depending on `Complexitylib.Models.TuringMachine.Repetition`. -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/Repetition/Internal/Setup.lean b/Complexitylib/Models/TuringMachine/Repetition/Internal/Setup.lean index c2919352..4f7e1496 100644 --- a/Complexitylib/Models/TuringMachine/Repetition/Internal/Setup.lean +++ b/Complexitylib/Models/TuringMachine/Repetition/Internal/Setup.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Repetition.Internal.Schedule -import Complexitylib.Models.TuringMachine.Repetition.Internal.Trial + +module +public import Complexitylib.Models.TuringMachine.Repetition.Internal.Schedule +public import Complexitylib.Models.TuringMachine.Repetition.Internal.Finish /-! # Setup boundary for fixed-time repetition @@ -20,6 +22,9 @@ machine, whose setup immediately halts with the empty majority verdict. - `NTM.repeatAtTime_trace_zero_repetitions` — the `k = 0` endpoint -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/Repetition/Internal/Trial.lean b/Complexitylib/Models/TuringMachine/Repetition/Internal/Trial.lean index 99e5427a..baaf69e6 100644 --- a/Complexitylib/Models/TuringMachine/Repetition/Internal/Trial.lean +++ b/Complexitylib/Models/TuringMachine/Repetition/Internal/Trial.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Repetition.Internal.Parked + +module +public import Complexitylib.Models.TuringMachine.Repetition.Internal.Parked /-! # Complete trials for fixed-time repetition @@ -21,6 +23,9 @@ zero-time path, and packages the finish-state facts needed by the vote step. - `NTM.repeatAtTime_trace_trial` — the combined trial theorem for every `T` -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/Repetition/Internal/VoteStep.lean b/Complexitylib/Models/TuringMachine/Repetition/Internal/VoteStep.lean index da9cd8a2..b8b60782 100644 --- a/Complexitylib/Models/TuringMachine/Repetition/Internal/VoteStep.lean +++ b/Complexitylib/Models/TuringMachine/Repetition/Internal/VoteStep.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Repetition.Internal.Finish -import Complexitylib.Models.TuringMachine.Repetition.Internal.Frame -import Complexitylib.Models.TuringMachine.Repetition.Internal.Votes + +module +public import Complexitylib.Models.TuringMachine.Repetition.Internal.Finish +public import Complexitylib.Models.TuringMachine.Repetition.Internal.Frame +public import Complexitylib.Models.TuringMachine.Repetition.Internal.Votes /-! # Finish-step vote semantics for fixed-time repetition @@ -23,6 +25,9 @@ source configuration, and specializes the final finish theorem to `repeatVotes`. - `NTM.repeatAtTime_trace_finish_last_votes` — final majority in source-vote form -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/Repetition/Internal/Votes.lean b/Complexitylib/Models/TuringMachine/Repetition/Internal/Votes.lean index a928899a..7bbb85bd 100644 --- a/Complexitylib/Models/TuringMachine/Repetition/Internal/Votes.lean +++ b/Complexitylib/Models/TuringMachine/Repetition/Internal/Votes.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Repetition.Internal + +module +public import Complexitylib.Models.TuringMachine.Repetition.Defs /-! # Vote bookkeeping for fixed-time repetition @@ -13,6 +15,9 @@ block-event majority API and provides the update invariant used by the outer trial induction. -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/Repetition/Validation.lean b/Complexitylib/Models/TuringMachine/Repetition/Validation.lean index 242d84a9..6a376243 100644 --- a/Complexitylib/Models/TuringMachine/Repetition/Validation.lean +++ b/Complexitylib/Models/TuringMachine/Repetition/Validation.lean @@ -3,7 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Repetition + +module +public import Complexitylib.Models.TuringMachine.Repetition +public meta import Complexitylib.Models.TuringMachine.Repetition /-! # Executable validation for fixed-time repetition @@ -14,6 +17,9 @@ repetition wrapper and checks that the selected simulation bit becomes the final majority verdict. -/ + +@[expose] public section + namespace Complexity namespace NTM.RepetitionValidation diff --git a/Complexitylib/Models/TuringMachine/SingleTape.lean b/Complexitylib/Models/TuringMachine/SingleTape.lean index ddad8c68..b88cc0d1 100644 --- a/Complexitylib/Models/TuringMachine/SingleTape.lean +++ b/Complexitylib/Models/TuringMachine/SingleTape.lean @@ -3,13 +3,14 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine -import Complexitylib.Models.TuringMachine.SingleTape.Internal.Pad -import Complexitylib.Models.TuringMachine.SingleTape.Internal -import Complexitylib.Models.TuringMachine.SingleTape.Internal.Sim -import Complexitylib.Models.TuringMachine.SingleTape.Internal.Delta -import Complexitylib.Models.TuringMachine.SingleTape.Internal.Correctness -import Complexitylib.Asymptotics + +module +public import Complexitylib.Models.TuringMachine.SingleTape.Internal.Pad +public import Complexitylib.Models.TuringMachine.SingleTape.Internal +public import Complexitylib.Models.TuringMachine.SingleTape.Internal.Sim +public import Complexitylib.Models.TuringMachine.SingleTape.Internal.Delta +public import Complexitylib.Models.TuringMachine.SingleTape.Internal.Correctness +public import Complexitylib.Asymptotics /-! # Multi-tape → single-tape simulation @@ -40,6 +41,9 @@ This is a reusable robustness lemma: `singleTapeSim_decidesInTime` and `exists_singleTape_decidesInTime` are assembled from these. -/ + +@[expose] public section + namespace Complexity open Complexity diff --git a/Complexitylib/Models/TuringMachine/SingleTape/Internal.lean b/Complexitylib/Models/TuringMachine/SingleTape/Internal.lean index b737b1cd..862ff1cd 100644 --- a/Complexitylib/Models/TuringMachine/SingleTape/Internal.lean +++ b/Complexitylib/Models/TuringMachine/SingleTape/Internal.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine + +module +public import Complexitylib.Models.TuringMachine /-! # Single-tape simulation — encoding internals @@ -17,6 +19,9 @@ layout. Proof internals only — correctness of the full simulation is established downstream. -/ + +@[expose] public section + namespace Complexity namespace NTM.SingleTape diff --git a/Complexitylib/Models/TuringMachine/SingleTape/Internal/Correctness.lean b/Complexitylib/Models/TuringMachine/SingleTape/Internal/Correctness.lean index 668fbc44..94790f86 100644 --- a/Complexitylib/Models/TuringMachine/SingleTape/Internal/Correctness.lean +++ b/Complexitylib/Models/TuringMachine/SingleTape/Internal/Correctness.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.SingleTape.Internal.Delta -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Internal + +module +public import Complexitylib.Models.TuringMachine.SingleTape.Internal.Delta +public import Complexitylib.Models.TuringMachine.Internal +public import Std.Tactic.BVDecide.Normalize.BitVec /-! # Single-tape simulation — correctness internals @@ -19,6 +21,9 @@ iterating `corr_macroStep` over `N`'s computation and translating acceptance. See `docs/A4-SingleTapeSimulation.md`. Proof internals only. -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/SingleTape/Internal/Delta.lean b/Complexitylib/Models/TuringMachine/SingleTape/Internal/Delta.lean index 11491494..2a8528f2 100644 --- a/Complexitylib/Models/TuringMachine/SingleTape/Internal/Delta.lean +++ b/Complexitylib/Models/TuringMachine/SingleTape/Internal/Delta.lean @@ -3,8 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.SingleTape.Internal.Sim -import Complexitylib.Models.TuringMachine.Combinators + +module +public import Complexitylib.Models.TuringMachine.SingleTape.Internal.Sim +public import Complexitylib.Models.TuringMachine.Combinators +public import Complexitylib.Models.TuringMachine.SingleTape.Internal /-! # Single-tape simulation — transition function @@ -27,6 +30,9 @@ backward-chaining characterizations of `gather` and `run` predecessors. See `docs/A4-SingleTapeSimulation.md`. -/ + +@[expose] public section + namespace Complexity namespace NTM.SingleTape diff --git a/Complexitylib/Models/TuringMachine/SingleTape/Internal/Pad.lean b/Complexitylib/Models/TuringMachine/SingleTape/Internal/Pad.lean index 5e1ddbe2..8ef62118 100644 --- a/Complexitylib/Models/TuringMachine/SingleTape/Internal/Pad.lean +++ b/Complexitylib/Models/TuringMachine/SingleTape/Internal/Pad.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine + +module +public import Complexitylib.Models.TuringMachine /-! # Padding a 0-work-tape NTM with a dummy work tape @@ -19,6 +21,9 @@ This closes the `k = 0` case of the single-tape reduction one work tape, while a padded machine *is* already single-work-tape. -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/SingleTape/Internal/Sim.lean b/Complexitylib/Models/TuringMachine/SingleTape/Internal/Sim.lean index a52df7b8..63d9f051 100644 --- a/Complexitylib/Models/TuringMachine/SingleTape/Internal/Sim.lean +++ b/Complexitylib/Models/TuringMachine/SingleTape/Internal/Sim.lean @@ -3,11 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.SingleTape.Internal -import Mathlib.Data.Fintype.Prod -import Mathlib.Data.Fintype.Sum -import Mathlib.Data.Finite.Prod -import Mathlib.Data.Finite.Sum + +module +public import Mathlib.Data.Finite.Prod +public import Mathlib.Data.Finite.Sum +public import Complexitylib.Models.TuringMachine /-! # Single-tape simulation — simulator state type @@ -23,6 +23,9 @@ product/`Pi` synthesis-size limit. `Finite` is a `Prop` and composes with no such limit, so we route through it (`Fintype.ofFinite` / `Classical.decEq`). -/ + +@[expose] public section + namespace Complexity namespace NTM.SingleTape diff --git a/Complexitylib/Models/TuringMachine/SingleTape/Validation.lean b/Complexitylib/Models/TuringMachine/SingleTape/Validation.lean index 2f944d01..c7b66b04 100644 --- a/Complexitylib/Models/TuringMachine/SingleTape/Validation.lean +++ b/Complexitylib/Models/TuringMachine/SingleTape/Validation.lean @@ -3,7 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.SingleTape.Internal.Delta + +module +public import Complexitylib.Models.TuringMachine +public meta import Complexitylib.Models.TuringMachine +public import Complexitylib.Models.TuringMachine.SingleTape.Internal.Delta +public meta import Complexitylib.Models.TuringMachine.SingleTape.Internal.Delta /-! # Single-tape simulation — executable validation (regression suite) @@ -24,6 +29,9 @@ hand-off. They cover off-0 moves, right/left moves with writes, repeated materialization, distant writes read back, and `k = 2` tape interleaving. -/ + +@[expose] public section + namespace Complexity namespace NTM.SingleTape.Validation diff --git a/Complexitylib/Models/TuringMachine/SpaceTime.lean b/Complexitylib/Models/TuringMachine/SpaceTime.lean index 367affd7..1facb362 100644 --- a/Complexitylib/Models/TuringMachine/SpaceTime.lean +++ b/Complexitylib/Models/TuringMachine/SpaceTime.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.SpaceTime.Defs -import Complexitylib.Models.TuringMachine.SpaceTime.Internal.RunBound + +module +public import Complexitylib.Models.TuringMachine.SpaceTime.Defs +public import Complexitylib.Models.TuringMachine.SpaceTime.Internal.RunBound /-! # Time bounds from deterministic transducer space bounds @@ -22,6 +24,9 @@ explicit time bound. - `TM.DecidesInSpace.decidesInTime_configBound` — decision-space bound gives time -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/SpaceTime/Defs.lean b/Complexitylib/Models/TuringMachine/SpaceTime/Defs.lean index 0eeed53b..e8a1e24c 100644 --- a/Complexitylib/Models/TuringMachine/SpaceTime/Defs.lean +++ b/Complexitylib/Models/TuringMachine/SpaceTime/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine -import Mathlib.Data.Fintype.BigOperators + +module +public import Complexitylib.Models.TuringMachine +public import Mathlib.Data.Fintype.BigOperators /-! # Finite observations of space-bounded transducer configurations @@ -25,6 +27,9 @@ the symbol currently under the head can affect future execution. - `TM.transducerConfigBound` — the number of possible transducer snapshots -/ + +@[expose] public section + namespace Complexity namespace Γ diff --git a/Complexitylib/Models/TuringMachine/SpaceTime/Internal/Observation.lean b/Complexitylib/Models/TuringMachine/SpaceTime/Internal/Observation.lean index dc693527..dc8560af 100644 --- a/Complexitylib/Models/TuringMachine/SpaceTime/Internal/Observation.lean +++ b/Complexitylib/Models/TuringMachine/SpaceTime/Internal/Observation.lean @@ -3,7 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.SpaceTime.Defs + +module +public import Complexitylib.Models.TuringMachine.SpaceTime.Defs +public import Std.Tactic.BVDecide.Normalize.BitVec /-! # Bounded-observation extensionality — proof internals @@ -15,6 +18,9 @@ equal after applying the same write and move, provided both successor heads remain inside the observed window. -/ + +@[expose] public section + namespace Complexity namespace Tape diff --git a/Complexitylib/Models/TuringMachine/SpaceTime/Internal/OutputFrontier.lean b/Complexitylib/Models/TuringMachine/SpaceTime/Internal/OutputFrontier.lean index c77276ae..03a48899 100644 --- a/Complexitylib/Models/TuringMachine/SpaceTime/Internal/OutputFrontier.lean +++ b/Complexitylib/Models/TuringMachine/SpaceTime/Internal/OutputFrontier.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine + +module +public import Complexitylib.Models.TuringMachine /-! # Output-frontier invariants — proof internals @@ -13,6 +15,9 @@ initial output tape is blank strictly beyond its head, and a transducer step preserves that property because its output head never moves left. -/ + +@[expose] public section + namespace Complexity namespace Tape diff --git a/Complexitylib/Models/TuringMachine/SpaceTime/Internal/Reachability.lean b/Complexitylib/Models/TuringMachine/SpaceTime/Internal/Reachability.lean index eae79b46..04fff43d 100644 --- a/Complexitylib/Models/TuringMachine/SpaceTime/Internal/Reachability.lean +++ b/Complexitylib/Models/TuringMachine/SpaceTime/Internal/Reachability.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine + +module +public import Complexitylib.Models.TuringMachine /-! # Exact-run decomposition — proof internals @@ -13,6 +15,9 @@ indices. They support the finite reduced-configuration argument without adding execution choices to the machine model. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/SpaceTime/Internal/RunBound.lean b/Complexitylib/Models/TuringMachine/SpaceTime/Internal/RunBound.lean index 911dbd85..9bee0645 100644 --- a/Complexitylib/Models/TuringMachine/SpaceTime/Internal/RunBound.lean +++ b/Complexitylib/Models/TuringMachine/SpaceTime/Internal/RunBound.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.SpaceTime.Internal.Reachability -import Complexitylib.Models.TuringMachine.SpaceTime.Internal.Snapshot + +module +public import Complexitylib.Models.TuringMachine.SpaceTime.Internal.Reachability +public import Complexitylib.Models.TuringMachine.SpaceTime.Internal.Snapshot /-! # Finite-configuration run bounds — proof internals @@ -15,6 +17,9 @@ earlier time. The run's time indices therefore inject into the finite snapshot type. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/SpaceTime/Internal/Snapshot.lean b/Complexitylib/Models/TuringMachine/SpaceTime/Internal/Snapshot.lean index 213ef49c..dc1c1dae 100644 --- a/Complexitylib/Models/TuringMachine/SpaceTime/Internal/Snapshot.lean +++ b/Complexitylib/Models/TuringMachine/SpaceTime/Internal/Snapshot.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.SpaceTime.Internal.Observation -import Complexitylib.Models.TuringMachine.SpaceTime.Internal.OutputFrontier -import Complexitylib.Models.TuringMachine.Internal + +module +public import Complexitylib.Models.TuringMachine.SpaceTime.Internal.Observation +public import Complexitylib.Models.TuringMachine.SpaceTime.Internal.OutputFrontier +public import Complexitylib.Models.TuringMachine.Internal /-! # Reduced transducer snapshot dynamics — proof internals @@ -15,6 +17,9 @@ by the finite snapshot from `SpaceTime.Defs`, once the shared read-only input contents are fixed. -/ + +@[expose] public section + namespace Complexity namespace Tape diff --git a/Complexitylib/Models/TuringMachine/Subroutines.lean b/Complexitylib/Models/TuringMachine/Subroutines.lean index c332383c..4b2f2786 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators + +module +public import Complexitylib.Models.TuringMachine.Combinators /-! # TM Subroutines @@ -29,6 +31,9 @@ statements are re-exported by focused surface modules when needed. - `TM.compareWorkTapesTM` — compare two work tapes cell by cell -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryAdd.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryAdd.lean index 330557e6..72991b4e 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryAdd.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryAdd.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAdd.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAdd.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryAdd.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryAdd.Internal /-! # Canonical binary addition @@ -26,6 +28,9 @@ width-based rather than derived from total loop runtime. - `binaryAddIntoTM_isTransducer` proves append-only-output safety. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryAdd/Defs.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryAdd/Defs.lean index c7a71fb0..a7e4de4b 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryAdd/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryAdd/Defs.lean @@ -3,8 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ClearWork.Defs + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.ClearWork.Defs +public import Complexitylib.Models.TuringMachine.Subroutines /-! # Canonical binary addition — definitions @@ -15,6 +18,9 @@ once per source value, and a distinct scratch counter records loop progress. After the loop, the scratch tape is cleared back to canonical zero. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryAdd/Internal.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryAdd/Internal.lean index 84bc50e3..152493a8 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryAdd/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryAdd/Internal.lean @@ -3,13 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.Internal.Seq -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAdd.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Internal.Control -import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc -import Complexitylib.Models.TuringMachine.Subroutines.ClearWork + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryAdd.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc +public import Complexitylib.Models.TuringMachine.Subroutines.ClearWork +public import Mathlib.Algebra.Order.Ring.Nat /-! # Canonical binary addition — proof internals @@ -21,6 +21,9 @@ about one comparison or one iteration at a time, avoiding any dependence on the total number of loop iterations. -/ + +@[expose] public section + namespace Complexity namespace TM @@ -28,7 +31,7 @@ namespace TM variable {n : ℕ} /-- The standard parked tape for one canonical binary natural. -/ -private def binaryAddNatTape (value : ℕ) : Tape := +def binaryAddNatTape (value : ℕ) : Tape := (Tape.init (value.bits.map Γ.ofBool)).move Dir3.right private theorem binaryAddNatTape_hasBinaryNat (value : ℕ) : @@ -45,7 +48,7 @@ private theorem binaryAddNatTape_parked (value : ℕ) : binaryAddHasBinaryNat_parked (binaryAddNatTape_hasBinaryNat value) /-- Work tapes after `current` completed addition iterations. -/ -private def binaryAddWorkAt (work : Fin n → Tape) +def binaryAddWorkAt (work : Fin n → Tape) (dstIdx counterIdx : Fin n) (dstValue current : ℕ) : Fin n → Tape := Function.update (Function.update work dstIdx (binaryAddNatTape (dstValue + current))) @@ -209,7 +212,8 @@ private theorem binaryAddWorkAt_clear_eq simp [binaryAddWorkAt, hne] · simp [binaryAddWorkAt, hic, hid] -private abbrev binaryAddFramePred +/-- Predicate fixing the tapes framing a binary-addition execution. -/ +abbrev binaryAddFramePred (inp₀ : Tape) (work₀ : Fin n → Tape) (out₀ : Tape) : TapePred n := fun inp work out => inp = inp₀ ∧ work = work₀ ∧ out = out₀ diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryAddConst.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryAddConst.lean index 6ba0c588..4f3c451c 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryAddConst.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryAddConst.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst.Internal /-! # Addition of a fixed natural to a canonical binary tape @@ -20,6 +22,9 @@ sequence of binary successors compiled from a hardwired natural constant. - `binaryAddConstTM_isTransducer` proves append-only-output safety. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryAddConst/Defs.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryAddConst/Defs.lean index 9fa3373c..007c14c5 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryAddConst/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryAddConst/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Registers.RegisterOps -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs + +module +public import Complexitylib.Models.TuringMachine.Registers.RegisterOps +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs /-! # Addition of a fixed natural to a canonical binary tape — definitions @@ -14,6 +16,9 @@ canonical binary successor. No work tape is needed for the hardwired value, so the construction preserves every tape except its destination. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryAddConst/Internal.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryAddConst/Internal.lean index 6e88c31a..f7dae267 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryAddConst/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryAddConst/Internal.lean @@ -3,10 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.Internal.Seq -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc /-! # Addition of a fixed natural to a canonical binary tape — proof internals @@ -16,13 +16,17 @@ compose through `seqTM`; the all-prefix space induction uses the largest destination width rather than the total successor-chain runtime. -/ + +@[expose] public section + namespace Complexity namespace TM variable {n : ℕ} -private def binaryAddConstNatTape (value : ℕ) : Tape := +/-- Canonical parked tape encoding of a natural for constant addition. -/ +def binaryAddConstNatTape (value : ℕ) : Tape := (Tape.init (value.bits.map Γ.ofBool)).move Dir3.right private theorem binaryAddConstNatTape_hasBinaryNat (value : ℕ) : @@ -107,7 +111,8 @@ private theorem binaryAddConstInitialWork_parked exact binaryAddConstHasBinaryNat_parked hdst · exact hother i hi -private abbrev binaryAddConstFramePred +/-- Predicate fixing the tapes framing a constant-addition execution. -/ +abbrev binaryAddConstFramePred (inp₀ : Tape) (work₀ : Fin n → Tape) (out₀ : Tape) : TapePred n := fun inp work out => inp = inp₀ ∧ work = work₀ ∧ out = out₀ diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryCopy.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryCopy.lean index 0c6a51eb..97776971 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryCopy.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryCopy.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy.Internal /-! # Copying canonical binary naturals @@ -21,6 +23,9 @@ destination becomes an exact copy, and the zero scratch is restored literally. - `TM.binaryCopyIntoTM_isTransducer` proves append-only-output safety. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryCopy/Defs.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryCopy/Defs.lean index 738f1326..0acef641 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryCopy/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryCopy/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ClearWork.Defs + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.ClearWork.Defs /-! # Copying canonical binary naturals @@ -14,6 +16,9 @@ binary addition. The source and zero scratch tapes are preserved, while the destination is replaced by an exact copy of the source. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryCopy/Internal.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryCopy/Internal.lean index 5c6b1503..eb4607ba 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryCopy/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryCopy/Internal.lean @@ -3,10 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ClearWork + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.ClearWork /-! # Copying canonical binary naturals -- proof internals @@ -17,13 +18,17 @@ proofs compose the public literal-frame and all-prefix contracts of both phases, then recover the original literal copy frame from canonicality. -/ + +@[expose] public section + namespace Complexity namespace TM variable {n : ℕ} -private def binaryCopyNatTape (value : ℕ) : Tape := +/-- Canonical parked tape encoding of a natural for binary copying. -/ +def binaryCopyNatTape (value : ℕ) : Tape := (Tape.init (value.bits.map Γ.ofBool)).move Dir3.right private theorem binaryCopyNatTape_hasBinaryNat (value : ℕ) : diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryEq.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryEq.lean index 8b86414c..78d33dce 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryEq.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryEq.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryEq.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryEq.Internal -import Complexitylib.Models.TuringMachine.Hoare.Space + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryEq.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryEq.Internal /-! # Binary work-tape equality @@ -14,6 +15,9 @@ This module exposes a framed linear-time correctness theorem for the concrete binary equality routine used by RAM register-store scans. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryEq/Defs.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryEq/Defs.lean index a9eefb2c..2a19b07e 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryEq/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryEq/Defs.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines -import Complexitylib.Models.TuringMachine.Tape.Encoding + +module +public import Complexitylib.Models.TuringMachine.Combinators /-! # Binary work-tape equality — definitions @@ -14,6 +15,9 @@ result on a third work tape. Unlike the legacy output-oriented comparator, it preserves the public output tape and every unrelated work tape. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryEq/Internal.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryEq/Internal.lean index 2d2bc858..fac4df2d 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryEq/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryEq/Internal.lean @@ -3,13 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryEq.Defs -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryEq.Defs +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Models.TuringMachine.Tape.Encoding +public import Std.Tactic.BVDecide.Normalize.BitVec /-! # Binary work-tape equality — proof internals -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor.lean index f6a91bcf..00eb6d95 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Internal /-! # Canonical binary count-up loops @@ -30,6 +32,9 @@ limit, or tape frames. Clients record those endpoint facts in - `IsTransducer.binaryForTM` preserves one-way output safety. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor/Defs.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor/Defs.lean index cb3657a4..9bbb90fe 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs /-! # Canonical binary count-up loops — definitions @@ -25,6 +27,9 @@ The wrapper-free certificate structures at the end of the file separate the executable controller from later correctness and all-prefix space proofs. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor/Internal.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor/Internal.lean index b9e342bd..cecc15be 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor/Internal.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Internal.Comparison -import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Internal.Loop + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Internal.Comparison +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Internal.Loop /-! # Canonical binary count-up loops — internal proofs diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor/Internal/Comparison.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor/Internal/Comparison.lean index 409c7f49..590bf519 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor/Internal/Comparison.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor/Internal/Comparison.lean @@ -3,8 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Internal.Control -import Complexitylib.Mathlib.NatBits + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Internal.Control +public import Complexitylib.Mathlib.NatBits +public import Mathlib.Algebra.Order.Group.Nat +public import Std.Tactic.BVDecide.Normalize.BitVec /-! # Canonical binary count-up loops — comparison internals @@ -17,6 +21,9 @@ the loop invariant `value ≤ limitValue`, the run takes exactly iteration precisely below the limit, or to `done` precisely at equality. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor/Internal/Control.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor/Internal/Control.lean index 9378368f..af8162c1 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor/Internal/Control.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor/Internal/Control.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Defs + +module +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Defs /-! # Canonical binary count-up loops — control proofs @@ -18,6 +20,9 @@ The canonical multi-step comparison run and loop induction are intentionally left to later proof layers. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor/Internal/Loop.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor/Internal/Loop.lean index 7a462281..ff6c99ee 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor/Internal/Loop.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryFor/Internal/Loop.lean @@ -3,10 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Internal -import Complexitylib.Models.TuringMachine.SpaceTime.Internal.Reachability -import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Internal /-! # Canonical binary count-up loops — proof internals @@ -17,6 +17,9 @@ that the binary loop driver preserves the one-way-output discipline of its body. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryLength.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryLength.lean index c8895f58..a369be91 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryLength.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryLength.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Experimental.Routine -import Complexitylib.Models.TuringMachine.Subroutines.BinaryLength.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryLength.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryLength.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryLength.Internal /-! # Binary input-length counter @@ -29,6 +30,9 @@ reuses the local successor bound at each iteration and is formally `O(log n)`. - `TM.binaryLengthTM_isTransducer` — the output head never moves left. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryLength/Defs.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryLength/Defs.lean index afad94af..a2b8a12a 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryLength/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryLength/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Experimental.Routine.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs + +module +public import Complexitylib.Models.TuringMachine.Experimental.Routine.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs /-! # Binary input-length counter — definitions @@ -14,6 +16,9 @@ The input region supplies unary loop fuel without being copied into auxiliary space; the designated work tape holds the growing canonical `Nat.bits` counter. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryLength/Internal.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryLength/Internal.lean index 4775c123..21301bc6 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryLength/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryLength/Internal.lean @@ -3,13 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Asymptotics -import Complexitylib.Mathlib.NatBits -import Complexitylib.Models.TuringMachine.Combinators.ForInput.Internal -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Experimental.Routine.Internal -import Complexitylib.Models.TuringMachine.Subroutines.BinaryLength.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc + +module +public import Complexitylib.Asymptotics +public import Complexitylib.Mathlib.NatBits +public import Complexitylib.Models.TuringMachine.Experimental.Routine.Internal +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryLength.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc /-! # Binary input-length counter — proof internals @@ -19,23 +19,30 @@ The exact run proof scans the read-only input and lifts one proved reachable driver/body phase so input length is never charged as work space. -/ + +@[expose] public section + namespace Complexity namespace TM variable {n : ℕ} {counterIdx : Fin n} -private def binaryLengthStartedBlank : Tape := +/-- A blank tape parked immediately to the right of its start marker. -/ +def binaryLengthStartedBlank : Tape := (Tape.init []).move Dir3.right -private def binaryLengthInput (x : List Bool) (head : ℕ) : Tape := +/-- The immutable input tape for `x`, with its head at `head`. -/ +def binaryLengthInput (x : List Bool) (head : ℕ) : Tape := { head := head cells := (Tape.init (x.map Γ.ofBool)).cells } -private def binaryLengthCounterTape (value : ℕ) : Tape := +/-- The canonical binary counter tape representing `value`. -/ +def binaryLengthCounterTape (value : ℕ) : Tape := (Tape.init (value.bits.map Γ.ofBool)).move Dir3.right -private def binaryLengthWork (counterIdx : Fin n) (value : ℕ) : Fin n → Tape := +/-- Work tapes with `value` on the selected counter tape and blank tapes elsewhere. -/ +def binaryLengthWork (counterIdx : Fin n) (value : ℕ) : Fin n → Tape := Function.update (fun _ => binaryLengthStartedBlank) counterIdx (binaryLengthCounterTape value) @@ -60,7 +67,8 @@ private def binaryLengthBodyDoneCfg (x : List Bool) (counterIdx : Fin n) work := binaryLengthWork counterIdx (value + 1) output := binaryLengthStartedBlank } -private def binaryLengthDoneCfg (x : List Bool) (counterIdx : Fin n) : +/-- Canonical halted configuration produced after measuring `x`. -/ +def binaryLengthDoneCfg (x : List Bool) (counterIdx : Fin n) : Cfg n (binaryLengthTM counterIdx).Q := { state := .inl .done input := binaryLengthInput x (x.length + 1) diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryMulAdd.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryMulAdd.lean index 47ad88b7..173f13a4 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryMulAdd.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryMulAdd.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryMulAdd.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryMulAdd.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryMulAdd.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryMulAdd.Internal /-! # Canonical binary multiply-add @@ -21,6 +23,9 @@ zero. The resource contract gives a width-based all-prefix space bound. - `binaryMulAddIntoTM_isTransducer` proves append-only-output safety. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryMulAdd/Defs.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryMulAdd/Defs.lean index 6b8a3caa..e58af9cc 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryMulAdd/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryMulAdd/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAdd.Defs + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryAdd.Defs /-! # Canonical binary multiply-add — definitions @@ -15,6 +17,9 @@ accumulator, an outer multiplication counter, and the addition routine's private counter. Both counters are restored to canonical zero. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryMulAdd/Internal.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryMulAdd/Internal.lean index 51ca9a9c..3f3b7ee4 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryMulAdd/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryMulAdd/Internal.lean @@ -3,15 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.Internal.Seq -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.SpaceTime.Internal.Reachability -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAdd -import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor.Internal.Control -import Complexitylib.Models.TuringMachine.Subroutines.BinaryFor -import Complexitylib.Models.TuringMachine.Subroutines.BinaryMulAdd.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc -import Complexitylib.Models.TuringMachine.Subroutines.ClearWork + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryAdd +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryMulAdd.Defs /-! # Canonical binary multiply-add — proof internals @@ -24,13 +19,17 @@ formula. Space is proved compositionally for each repeated-addition iteration, so it depends on binary widths rather than on the number of loop steps. -/ + +@[expose] public section + namespace Complexity namespace TM variable {n : ℕ} -private def binaryMulAddNatTape (value : ℕ) : Tape := +/-- Canonical parked tape encoding of a natural for multiply-add. -/ +def binaryMulAddNatTape (value : ℕ) : Tape := (Tape.init (value.bits.map Γ.ofBool)).move Dir3.right private theorem binaryMulAddNatTape_hasBinaryNat (value : ℕ) : @@ -245,7 +244,8 @@ private theorem binaryMulAddWorkAt_clear_eq simp [binaryMulAddWorkAt, hne] · simp [binaryMulAddWorkAt, him, hia] -private abbrev binaryMulAddFramePred +/-- Predicate fixing the tapes framing a binary multiply-add execution. -/ +abbrev binaryMulAddFramePred (inp₀ : Tape) (work₀ : Fin n → Tape) (out₀ : Tape) : TapePred n := fun inp work out => inp = inp₀ ∧ work = work₀ ∧ out = out₀ diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryPolynomial.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryPolynomial.lean index b617d028..d5b27e8b 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryPolynomial.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryPolynomial.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPolynomial.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPolynomial.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPolynomial.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPolynomial.Internal /-! # Canonical binary evaluation of a fixed natural polynomial @@ -24,6 +26,9 @@ not runtime, and is logarithmic in the input value for every fixed polynomial. - `binaryPolynomialEvalTM_isTransducer` proves append-only-output safety. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryPolynomial/Defs.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryPolynomial/Defs.lean index 5bd1e0ab..4acb92b2 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryPolynomial/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryPolynomial/Defs.lean @@ -3,10 +3,16 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Algebra.Polynomial.Eval.Degree -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryMulAdd.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ClearWork.Defs + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryMulAdd.Defs +public import Mathlib.Algebra.Polynomial.Degree.Defs +public import Mathlib.Data.Rat.Cast.Order +public import Mathlib.Tactic.NormNum.Abs +public import Mathlib.Tactic.NormNum.DivMod +public import Mathlib.Tactic.NormNum.OfScientific +public import Mathlib.Tactic.NormNum.Pow /-! # Canonical binary evaluation of a fixed natural polynomial — definitions @@ -18,6 +24,9 @@ The initial orientation is chosen from coefficient-list parity so the designated result tape holds the final value and the other accumulator is zero. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryPolynomial/Internal.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryPolynomial/Internal.lean index b903ee6f..7a926c78 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryPolynomial/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryPolynomial/Internal.lean @@ -3,12 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Asymptotics -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst -import Complexitylib.Models.TuringMachine.Subroutines.BinaryMulAdd -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPolynomial.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ClearWork + +module +public import Complexitylib.Asymptotics +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryMulAdd +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPolynomial.Defs /-! # Canonical binary evaluation of a fixed natural polynomial — proof internals @@ -20,13 +20,17 @@ one width-based space budget independent of their (potentially much larger) running time. -/ + +@[expose] public section + namespace Complexity namespace TM variable {n : ℕ} -private def binaryPolynomialNatTape (value : ℕ) : Tape := +/-- Canonical parked tape encoding of a natural for polynomial evaluation. -/ +def binaryPolynomialNatTape (value : ℕ) : Tape := (Tape.init (value.bits.map Γ.ofBool)).move Dir3.right private theorem binaryPolynomialNatTape_hasBinaryNat (value : ℕ) : @@ -43,7 +47,8 @@ private theorem binaryPolynomialNatTape_parked (value : ℕ) : binaryPolynomialHasBinaryNat_parked (binaryPolynomialNatTape_hasBinaryNat value) -private abbrev binaryPolynomialFramePred +/-- Predicate fixing the tapes framing a binary polynomial evaluation. -/ +abbrev binaryPolynomialFramePred (inp₀ : Tape) (work₀ : Fin n → Tape) (out₀ : Tape) : TapePred n := fun inp work out => inp = inp₀ ∧ work = work₀ ∧ out = out₀ diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryPred.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryPred.lean index 21cf4cb8..a22ef1c0 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryPred.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryPred.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred.Internal /-! # Little-endian binary predecessor @@ -27,6 +29,9 @@ represent `value + 1`; they make no underflow claim. - `TM.binaryPredTM_isTransducer` — the output head never moves left. -/ + +@[expose] public section + namespace Complexity namespace BinaryPred diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryPred/Defs.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryPred/Defs.lean index 9bfea08d..c7dc5222 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryPred/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryPred/Defs.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs -import Mathlib.Data.Nat.Size + +module +public import Complexitylib.Models.TuringMachine.Combinators +public import Mathlib.Data.Nat.Bits /-! # Little-endian binary predecessor — definitions @@ -21,6 +22,9 @@ representation. Public correctness theorems intentionally start from `value + 1`, so no underflow behavior is claimed. -/ + +@[expose] public section + namespace Complexity namespace BinaryPred diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryPred/Internal.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryPred/Internal.lean index 4a887d72..e5deafaa 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryPred/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryPred/Internal.lean @@ -3,10 +3,14 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Mathlib.NatBits -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred.Defs + +module +public import Complexitylib.Mathlib.NatBits +public import Complexitylib.Models.TuringMachine.Hoare.Space +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryPred.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs +public import Mathlib.Algebra.Order.Ring.Nat +public import Mathlib.Algebra.Order.Sub.Basic /-! # Little-endian binary predecessor — proof internals @@ -17,6 +21,9 @@ low-order prefix independently of the target head, including the canonical high-bit erasure needed when decrementing a power of two. -/ + +@[expose] public section + namespace Complexity namespace BinaryPred diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd.lean index a1fce936..e60e125c 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal /-! # Linear-time canonical binary addition @@ -19,6 +21,9 @@ routine; complexity-sensitive RAM simulation should use this width-linear machine instead. -/ + +@[expose] public section + namespace Complexity namespace BinaryRippleAdd diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Defs.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Defs.lean index 597a945e..e819ebcf 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines -import Mathlib.Data.Nat.Size + +module +public import Complexitylib.Models.TuringMachine.Subroutines +public import Mathlib.Data.Nat.Bits /-! # Linear-time canonical binary addition -- definitions @@ -14,6 +16,9 @@ little-endian binary work tapes. Each scan step appends one sum bit to a fresh result tape. A composed wrapper then rewinds all three owned tapes. -/ + +@[expose] public section + namespace Complexity namespace BinaryRippleAdd diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal.lean index ce53af5d..7260e072 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal.lean @@ -3,12 +3,14 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal.Bounds -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal.Out -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal.Pure -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal.Rewind -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal.Scan -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal.Sem + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal.Bounds +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal.Out +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal.Pure +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal.Rewind +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal.Scan +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal.Sem /-! # Linear-time canonical binary addition -- proof internals diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Bounds.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Bounds.lean index 83ab219a..ba0bd0a1 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Bounds.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Bounds.lean @@ -3,7 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Defs + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Defs +public import Mathlib.Data.Nat.Size /-! # Linear binary addition -- resource-bound internals @@ -12,6 +15,9 @@ This file relates the concrete scan and composed-machine bounds to the standard binary widths of the two operands. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Out.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Out.lean index 0531e1ac..992ccbe4 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Out.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Out.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ClearWork.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.ClearWork.Internal /-! # Linear-time canonical binary addition -- output discipline @@ -14,6 +16,9 @@ machines satisfy the transducer discipline required by space-bounded function computation. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Pure.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Pure.lean index 94525438..c9951057 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Pure.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Pure.lean @@ -3,7 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Defs + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Defs +public import Mathlib.Data.Nat.Size +public import Std.Tactic.BVDecide.Normalize.Bool /-! # Linear-time canonical binary addition -- pure proofs @@ -13,6 +17,9 @@ canonical little-endian `Nat.bits`. The generalized theorem includes an incoming carry so that its induction follows the recurrence exactly. -/ + +@[expose] public section + namespace Complexity namespace BinaryRippleAdd diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Rewind.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Rewind.lean index 1b0d0a59..775d7e23 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Rewind.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Rewind.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary.Internal /-! # Linear-time canonical binary addition -- rewind proof internals @@ -13,11 +15,15 @@ This module packages the three-rewind tail of `binaryRippleAddTM` into one framed Hoare-time contract. -/ + +@[expose] public section + namespace Complexity namespace TM -private def binaryRippleAddCanonicalTape (bits : List Bool) : Tape := +/-- Canonical parked tape containing the supplied little-endian binary digits. -/ +def binaryRippleAddCanonicalTape (bits : List Bool) : Tape := (Tape.init (bits.map Γ.ofBool)).move Dir3.right private theorem binaryRippleAddCanonicalTape_parked (bits : List Bool) : diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Scan.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Scan.lean index 9c7d7999..2c76d21f 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Scan.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Scan.lean @@ -3,10 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal.Pure -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Tape.Encoding + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Defs +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Models.TuringMachine.Tape.Encoding /-! # Linear-time canonical binary addition -- scan proof @@ -16,6 +17,9 @@ scan. Rewinding and the complete canonical-natural interface are composed in later internal layers. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Sem.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Sem.lean index e73e0748..aeca3d12 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Sem.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleAdd/Internal/Sem.lean @@ -3,12 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal.Bounds -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal.Pure -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal.Rewind -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal.Scan -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal.Pure +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal.Rewind +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd.Internal.Scan +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc /-! # Linear-time canonical binary addition -- composed semantics @@ -19,6 +19,9 @@ sum, preserves the complete external tape frame, and carries explicit time and all-prefix auxiliary-space bounds. -/ + +@[expose] public section + namespace Complexity namespace TM @@ -41,7 +44,8 @@ private def binaryRippleAddScanPost {n : ℕ} work i = work₀ i) ∧ out = out₀ -private def binaryRippleAddPost {n : ℕ} +/-- Postcondition for completed binary ripple addition. -/ +def binaryRippleAddPost {n : ℕ} (lhsIdx rhsIdx resultIdx : Fin n) (lhs rhs : ℕ) (inp₀ : Tape) (work₀ : Fin n → Tape) (out₀ : Tape) : TapePred n := fun inp work out => diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub.lean index b318197c..fba6b78a 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Internal.Sem -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Internal.Out + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Internal.Sem +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Internal.Out /-! # Linear-time canonical binary subtraction @@ -17,6 +19,9 @@ and preserves the complete external tape frame. Its running time is linear in the operand bit widths. -/ + +@[expose] public section + namespace Complexity namespace BinaryRippleSub diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Defs.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Defs.lean index 9ecec291..95a8f32a 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Defs.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines -import Complexitylib.Models.TuringMachine.Tape.Encoding -import Mathlib.Data.Nat.Size + +module +public import Complexitylib.Models.TuringMachine.Subroutines +public import Mathlib.Data.Nat.Bits /-! # Linear-time canonical binary subtraction -- definitions @@ -16,6 +17,9 @@ A single backward pass then erases the complete result on underflow or removes only its redundant high zeros, while returning the result head to cell one. -/ + +@[expose] public section + namespace Complexity namespace BinaryRippleSub diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Backward.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Backward.lean index e4b7d1ea..d3b06706 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Backward.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Backward.lean @@ -3,8 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Internal.Pure + +module +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Internal.Pure +public import Complexitylib.Models.TuringMachine.Tape.Encoding +public import Mathlib.Algebra.Order.Sub.Basic /-! # Linear-time canonical binary subtraction -- backward cleanup @@ -16,6 +20,9 @@ high one, and returns the result head to cell one. All other tapes are framed literally throughout the run. -/ + +@[expose] public section + namespace Complexity namespace Tape diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Out.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Out.lean index 20c427fd..3a4cf52e 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Out.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Out.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ClearWork.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.ClearWork.Internal /-! # Linear-time canonical binary subtraction -- output discipline @@ -13,6 +15,9 @@ The borrow scan, backward cleanup, and operand rewinds leave the public output tape one-way, so the core and complete machines are safe transducers. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Pure.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Pure.lean index c85ef130..e740753e 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Pure.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Pure.lean @@ -3,8 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Mathlib.NatBits -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Defs + +module +public import Complexitylib.Mathlib.NatBits +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Defs +public import Mathlib.Algebra.Order.Ring.Nat +public import Std.Tactic.BVDecide.Normalize.Bool /-! # Linear-time canonical binary subtraction -- pure proofs @@ -14,11 +18,15 @@ final borrow decides underflow, while trimming is proved to recover the canonical `Nat.bits` representation of the raw fixed-width value. -/ + +@[expose] public section + namespace Complexity namespace BinaryRippleSub -private def boolValue (bit : Bool) : ℕ := +/-- Interpret a Boolean bit as a natural number. -/ +def boolValue (bit : Bool) : ℕ := if bit then 1 else 0 private theorem fullSub_value (borrow lhs rhs : Bool) : diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Rewind.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Rewind.lean index 90f6460a..21d946a0 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Rewind.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Rewind.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary.Internal /-! # Linear-time canonical binary subtraction -- operand rewind internals @@ -13,11 +15,15 @@ The subtraction core already returns its result to cell one. This module packages the two remaining operand rewinds into one exact framed contract. -/ + +@[expose] public section + namespace Complexity namespace TM -private def binaryRippleSubCanonicalTape (bits : List Bool) : Tape := +/-- Canonical parked tape containing the supplied little-endian binary digits. -/ +def binaryRippleSubCanonicalTape (bits : List Bool) : Tape := (Tape.init (bits.map Γ.ofBool)).move Dir3.right private theorem binaryRippleSubCanonicalTape_parked (bits : List Bool) : diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Scan.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Scan.lean index 5765f215..ac063b96 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Scan.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Scan.lean @@ -3,9 +3,14 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Internal.Pure -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Defs +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Models.TuringMachine.Tape.Encoding +public import Mathlib.Algebra.Order.Ring.Nat +public import Mathlib.Tactic.NormNum.Inv +public import Mathlib.Tactic.NormNum.Pow /-! # Linear-time canonical binary subtraction -- forward scan proof @@ -15,6 +20,9 @@ including its final turn into backward cleanup. Cleanup itself is proved in a separate internal layer. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Sem.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Sem.lean index b8df34fb..b96fd815 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Sem.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryRippleSub/Internal/Sem.lean @@ -3,11 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Internal.Backward -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Internal.Rewind -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Internal.Scan -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Internal.Backward +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Internal.Rewind +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleSub.Internal.Scan +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc /-! # Linear-time canonical binary subtraction -- composed semantics @@ -19,11 +20,15 @@ preserves the external tape frame literally, and carries explicit time and all-prefix auxiliary-space bounds. -/ + +@[expose] public section + namespace Complexity namespace TM -private def binaryRippleSubCorePost {n : ℕ} +/-- Postcondition at the end of the core binary ripple-subtraction phase. -/ +def binaryRippleSubCorePost {n : ℕ} (lhsIdx rhsIdx resultIdx : Fin n) (lhs rhs : ℕ) (inp₀ : Tape) (work₀ : Fin n → Tape) (out₀ : Tape) : TapePred n := fun inp work out => @@ -39,7 +44,8 @@ private def binaryRippleSubCorePost {n : ℕ} work i = work₀ i) ∧ out = out₀ -private def binaryRippleSubPost {n : ℕ} +/-- Postcondition for completed binary ripple subtraction. -/ +def binaryRippleSubPost {n : ℕ} (lhsIdx rhsIdx resultIdx : Fin n) (lhs rhs : ℕ) (inp₀ : Tape) (work₀ : Fin n → Tape) (out₀ : Tape) : TapePred n := fun inp work out => diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryShiftMul.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryShiftMul.lean index 03218db4..9b01c2d9 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryShiftMul.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryShiftMul.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul.Internal.Out -import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul.Internal.Pure -import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul.Internal.Sem + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul.Internal.Out +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul.Internal.Pure +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul.Internal.Sem /-! # Width-driven binary shift-and-add multiplication @@ -18,6 +20,9 @@ and preserves the complete external tape frame. Its running time is quadratic in the combined operand width. -/ + +@[expose] public section + namespace Complexity namespace BinaryShiftMul diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryShiftMul/Defs.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryShiftMul/Defs.lean index 8f9e2013..3c41ee1a 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryShiftMul/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryShiftMul/Defs.lean @@ -3,11 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.ForBinaryWork.Defs -import Complexitylib.Models.TuringMachine.Combinators.WorkSymbolBranch.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany.Defs -import Complexitylib.Mathlib.NatBits + +module +public import Complexitylib.Models.TuringMachine.Combinators.ForBinaryWork.Defs +public import Complexitylib.Models.TuringMachine.Combinators.WorkSymbolBranch.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany.Defs +public import Complexitylib.Mathlib.NatBits /-! # Width-driven binary shift-and-add multiplication -- definitions @@ -18,6 +20,9 @@ preserved, the accumulator receives their product, and three scratch tapes are returned to canonical zero. -/ + +@[expose] public section + namespace Complexity namespace BinaryShiftMul diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryShiftMul/Internal/Out.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryShiftMul/Internal/Out.lean index 1a86d91e..0b110116 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryShiftMul/Internal/Out.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryShiftMul/Internal/Out.lean @@ -3,12 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.ForBinaryWork -import Complexitylib.Models.TuringMachine.Combinators.WorkSymbolBranch -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd -import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany + +module +public import Complexitylib.Models.TuringMachine.Combinators.ForBinaryWork +public import Complexitylib.Models.TuringMachine.Combinators.WorkSymbolBranch +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany /-! # Width-driven binary shift-and-add multiplication -- output safety @@ -16,6 +17,9 @@ import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany This file composes the transducer certificates of every multiplication phase. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryShiftMul/Internal/Pure.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryShiftMul/Internal/Pure.lean index d85fbe61..fffc5d54 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryShiftMul/Internal/Pure.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryShiftMul/Internal/Pure.lean @@ -3,7 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul.Defs + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul.Defs +public import Mathlib.Algebra.Order.Ring.Nat +public import Mathlib.Tactic.Ring.RingNF /-! # Width-driven binary shift-and-add multiplication -- pure proofs @@ -13,6 +17,9 @@ shift-and-add fold, its multiplication specialization, and width bounds for every partial accumulator and shifted multiplicand. -/ + +@[expose] public section + namespace Complexity namespace BinaryShiftMul diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinaryShiftMul/Internal/Sem.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinaryShiftMul/Internal/Sem.lean index 26044b05..28fb44ef 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinaryShiftMul/Internal/Sem.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinaryShiftMul/Internal/Sem.lean @@ -3,12 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.ForBinaryWork -import Complexitylib.Models.TuringMachine.Combinators.WorkSymbolBranch -import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy -import Complexitylib.Models.TuringMachine.Subroutines.BinaryRippleAdd -import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul.Internal.Pure -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany + +module +public import Complexitylib.Models.TuringMachine.Combinators.ForBinaryWork +public import Complexitylib.Models.TuringMachine.Combinators.WorkSymbolBranch +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryCopy +public import Complexitylib.Models.TuringMachine.Subroutines.BinaryShiftMul.Internal.Pure +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany /-! # Width-driven binary shift-and-add multiplication -- composed semantics @@ -18,6 +19,9 @@ bit-driven work-tape loop. The multiplier cursor is preserved by every body phase and advanced only by the loopback seam. -/ + +@[expose] public section + namespace Complexity namespace TM @@ -1249,7 +1253,8 @@ private def binaryShiftMulCleanupMid {n : ℕ} (abi : BinaryShiftMulABI n) i ≠ abi.shift → i ≠ abi.tmp → i ≠ abi.dbl → work i = work₀ i) ∧ out = out₀ -private def binaryShiftMulPost {n : ℕ} (abi : BinaryShiftMulABI n) +/-- Postcondition for completed shift-and-add binary multiplication. -/ +def binaryShiftMulPost {n : ℕ} (abi : BinaryShiftMulABI n) (lhs rhs : ℕ) (inp₀ : Tape) (work₀ : Fin n → Tape) (out₀ : Tape) : TapePred n := fun inp work out => diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinarySucc.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinarySucc.lean index 6d9fad10..157df0b3 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinarySucc.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinarySucc.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Internal /-! # Little-endian binary successor @@ -24,6 +26,9 @@ tape to cell one. - `TM.binarySuccTM_isTransducer` — the output head never moves left. -/ + +@[expose] public section + namespace Complexity namespace BinarySucc diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinarySucc/Defs.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinarySucc/Defs.lean index a022b76d..16b55c3d 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinarySucc/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinarySucc/Defs.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Tape.Encoding -import Mathlib.Data.Nat.Size + +module +public import Complexitylib.Models.TuringMachine.Combinators +public import Complexitylib.Models.TuringMachine.Tape.Encoding +public import Mathlib.Data.Nat.Bits /-! # Little-endian binary successor — definitions @@ -16,6 +18,9 @@ significant bit comes first and whose representation of zero is empty. Overflow therefore appends one new high bit at the first blank cell. -/ + +@[expose] public section + namespace Complexity namespace BinarySucc diff --git a/Complexitylib/Models/TuringMachine/Subroutines/BinarySucc/Internal.lean b/Complexitylib/Models/TuringMachine/Subroutines/BinarySucc/Internal.lean index 33bcf5f8..e26ea8a5 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/BinarySucc/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/BinarySucc/Internal.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs + +module +public import Complexitylib.Models.TuringMachine.Hoare.Space +public import Complexitylib.Models.TuringMachine.Subroutines.BinarySucc.Defs +public import Mathlib.Data.Nat.Size /-! # Little-endian binary successor — proof internals @@ -15,6 +17,9 @@ of `TM.binarySuccTM`. The carry proof uses a private head-independent binary content predicate, generalized over the already-zeroed low-order prefix. -/ + +@[expose] public section + namespace Complexity namespace BinarySucc diff --git a/Complexitylib/Models/TuringMachine/Subroutines/ClearWork.lean b/Complexitylib/Models/TuringMachine/Subroutines/ClearWork.lean index e7b94804..a2ec06fb 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/ClearWork.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/ClearWork.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.ClearWork.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ClearWork.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.ClearWork.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.ClearWork.Internal /-! # Clearing a binary work tape @@ -20,6 +22,9 @@ discipline of the clearing, rewinding, and composite machines. - `clearWorkTM_isTransducer` — clearing never moves the output head left. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/ClearWork/Defs.lean b/Complexitylib/Models/TuringMachine/Subroutines/ClearWork/Defs.lean index 7b9f7baf..02e66bec 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/ClearWork/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/ClearWork/Defs.lean @@ -3,7 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines + +module +public import Mathlib.Data.Finset.Attr +public import Mathlib.Data.Nat.Notation +public import Mathlib.Tactic.Finiteness.Attr +public import Mathlib.Tactic.SetLike +public import Mathlib.Tactic.ToAdditive /-! # Clearing a binary work tape — definitions @@ -12,6 +18,9 @@ This module names the concrete time bound used by the public framed contract for `TM.clearWorkTM`. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/ClearWork/Internal.lean b/Complexitylib/Models/TuringMachine/Subroutines/ClearWork/Internal.lean index ca52d86d..a45e9bf0 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/ClearWork/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/ClearWork/Internal.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Registers -import Complexitylib.Models.TuringMachine.Subroutines.ClearWork.Defs -import Complexitylib.Models.TuringMachine.Subroutines.Internal + +module +public import Complexitylib.Models.TuringMachine.Hoare.Space +public import Complexitylib.Models.TuringMachine.Registers +public import Complexitylib.Models.TuringMachine.Subroutines.ClearWork.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.Internal /-! # Clearing a binary work tape — proof internals @@ -16,6 +18,9 @@ contract and proves that its component machines never move the output head left. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/CopyOutput.lean b/Complexitylib/Models/TuringMachine/Subroutines/CopyOutput.lean index de14c24b..5ba68eae 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/CopyOutput.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/CopyOutput.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines -import Complexitylib.Models.TuringMachine.Subroutines.Internal.CopyOutput + +module +public import Complexitylib.Models.TuringMachine.Subroutines +public import Complexitylib.Models.TuringMachine.Subroutines.Internal.CopyOutput /-! # Input-to-output copy subroutine @@ -19,6 +21,9 @@ its Boolean input verbatim to its output tape in the exact linear bound within time `m + 2` -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/CopyWorkOutput.lean b/Complexitylib/Models/TuringMachine/Subroutines/CopyWorkOutput.lean index 36bcd8b4..4f40f4d3 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/CopyWorkOutput.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/CopyWorkOutput.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.Internal.CopyWorkOutput + +module +public import Complexitylib.Models.TuringMachine.Subroutines.Internal.CopyWorkOutput /-! # Copy a raw work-tape output @@ -19,6 +21,9 @@ junk. The fresh destination receives a canonical `Tape.HasBinaryPrefix`. - `TM.copyWorkToWorkTM_hoareTime_frame_of_hasOutput` — copy with frame preservation -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/Counter.lean b/Complexitylib/Models/TuringMachine/Subroutines/Counter.lean index 7b07f268..f60cb3b7 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/Counter.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/Counter.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Hoare.Defs + +module +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Models.TuringMachine.Hoare.Defs /-! # Counter-building TM subroutines @@ -16,6 +18,9 @@ The SAT-specific NP construction only needs a linear witness bound: that writes exactly `|input| + 1` unary marks to a designated counter tape. -/ + +@[expose] public section + namespace Complexity namespace Tape @@ -264,10 +269,12 @@ instance : Fintype LinearCounterPhase where elems := {.scan, .rewind, .done} complete := fun x => by cases x <;> simp -private def counterPreserveWork (wHeads : Fin n → Γ) : Fin n → Γw := +/-- Preserve every writable work-tape symbol. -/ +def counterPreserveWork (wHeads : Fin n → Γ) : Fin n → Γw := fun i => readBackWrite (wHeads i) -private def counterIdleDirs (wHeads : Fin n → Γ) : Fin n → Dir3 := +/-- Keep every work head stationary, except when bouncing off the start marker. -/ +def counterIdleDirs (wHeads : Fin n → Γ) : Fin n → Dir3 := fun i => idleDir (wHeads i) private theorem counterIdleDirs_right_of_start (wHeads : Fin n → Γ) : @@ -275,11 +282,13 @@ private theorem counterIdleDirs_right_of_start (wHeads : Fin n → Γ) : intro i hi exact idleDir_right_of_start hi -private def counterWriteOneWork (counterIdx : Fin n) (wHeads : Fin n → Γ) : +/-- Write one unary mark on the counter tape and preserve every other tape. -/ +def counterWriteOneWork (counterIdx : Fin n) (wHeads : Fin n → Γ) : Fin n → Γw := fun i => if i = counterIdx then Γw.one else readBackWrite (wHeads i) -private def counterAdvanceDirs (counterIdx : Fin n) (wHeads : Fin n → Γ) : +/-- Advance the counter head and idle every other work head. -/ +def counterAdvanceDirs (counterIdx : Fin n) (wHeads : Fin n → Γ) : Fin n → Dir3 := fun i => if i = counterIdx then Dir3.right else idleDir (wHeads i) @@ -291,7 +300,8 @@ private theorem counterAdvanceDirs_right_of_start (counterIdx : Fin n) · simp [counterAdvanceDirs, hidx] · simp [counterAdvanceDirs, hidx, idleDir_right_of_start hi] -private def counterRewindDirs (counterIdx : Fin n) (wHeads : Fin n → Γ) : +/-- Rewind the counter head and idle every other work head. -/ +def counterRewindDirs (counterIdx : Fin n) (wHeads : Fin n → Γ) : Fin n → Dir3 := fun i => if i = counterIdx then moveLeftDir (wHeads i) else idleDir (wHeads i) diff --git a/Complexitylib/Models/TuringMachine/Subroutines/GuessBounded.lean b/Complexitylib/Models/TuringMachine/Subroutines/GuessBounded.lean index 1b790ae2..2af64c58 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/GuessBounded.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/GuessBounded.lean @@ -3,9 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.Counter -import Complexitylib.Models.TuringMachine.Tape.Encoding -import Complexitylib.Models.TuringMachine.Trace + +module +public import Complexitylib.Models.TuringMachine.Subroutines.Counter +public import Complexitylib.Models.TuringMachine.Tape.Encoding +public import Complexitylib.Models.TuringMachine.Trace +public import Std.Tactic.BVDecide.Normalize.BitVec /-! # Nondeterministic TM subroutines @@ -19,6 +22,9 @@ guess phase a structural all-paths halting bound, which is essential for `NTIME`. -/ + +@[expose] public section + namespace Complexity namespace NTM @@ -49,11 +55,11 @@ instance : Fintype GuessBoundedPhase where /-- Preserve a work tape by writing back the symbol currently under its head and using an idle direction. -/ -private def preserveWork (wHeads : Fin n → Γ) : Fin n → Γw := +def preserveWork (wHeads : Fin n → Γ) : Fin n → Γw := fun i => TM.readBackWrite (wHeads i) /-- Idle directions for all work tapes. -/ -private def idleWorkDirs (wHeads : Fin n → Γ) : Fin n → Dir3 := +def idleWorkDirs (wHeads : Fin n → Γ) : Fin n → Dir3 := fun i => TM.idleDir (wHeads i) private theorem idleWorkDirs_right_of_start (wHeads : Fin n → Γ) : @@ -65,7 +71,7 @@ private theorem idleWorkDirs_right_of_start (wHeads : Fin n → Γ) : nondeterministic bit, while the counter tape has its current mark erased. The definition is meaningful when `witnessIdx ≠ counterIdx`; later correctness lemmas assume that disjointness. -/ -private def guessWriteWork (witnessIdx counterIdx : Fin n) +def guessWriteWork (witnessIdx counterIdx : Fin n) (choice : Bool) (wHeads : Fin n → Γ) : Fin n → Γw := fun i => if i = witnessIdx then Γw.ofBool choice @@ -74,7 +80,7 @@ private def guessWriteWork (witnessIdx counterIdx : Fin n) /-- Work directions for the bit-writing step: witness and counter advance right, all other tapes idle. -/ -private def guessWriteDirs (witnessIdx counterIdx : Fin n) +def guessWriteDirs (witnessIdx counterIdx : Fin n) (wHeads : Fin n → Γ) : Fin n → Dir3 := fun i => if i = witnessIdx then Dir3.right @@ -93,7 +99,7 @@ private theorem guessWriteDirs_right_of_start (witnessIdx counterIdx : Fin n) · simp [guessWriteDirs, hwi, hci, TM.idleDir_right_of_start hi] /-- Work directions for rewinding the witness tape to cell 1. -/ -private def rewindWitnessDirs (witnessIdx : Fin n) +def rewindWitnessDirs (witnessIdx : Fin n) (wHeads : Fin n → Γ) : Fin n → Dir3 := fun i => if i = witnessIdx then TM.moveLeftDir (wHeads i) diff --git a/Complexitylib/Models/TuringMachine/Subroutines/Internal.lean b/Complexitylib/Models/TuringMachine/Subroutines/Internal.lean index fc2d6d6e..15a19ffb 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/Internal.lean @@ -3,11 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines -import Complexitylib.Models.TuringMachine.Tape.Encoding -import Complexitylib.Models.TuringMachine.Hoare -import Complexitylib.Models.TuringMachine.Hoare.Defs -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic + +module +public import Complexitylib.Models.TuringMachine.Subroutines +public import Complexitylib.Models.TuringMachine.Tape.Encoding +public import Complexitylib.Models.TuringMachine.Hoare +public import Complexitylib.Models.TuringMachine.Hoare.Defs /-! # TM Subroutines: proof internals @@ -37,6 +38,9 @@ an arbitrary predicate `P` on the untouched tapes through the run. work-to-work copy -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/Internal/CopyOutput.lean b/Complexitylib/Models/TuringMachine/Subroutines/Internal/CopyOutput.lean index 3b50e3dd..93b89028 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/Internal/CopyOutput.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/Internal/CopyOutput.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines -import Complexitylib.Models.TuringMachine.Tape.Encoding -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic + +module +public import Complexitylib.Models.TuringMachine.Subroutines +public import Complexitylib.Models.TuringMachine.Tape.Encoding +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic /-! # Input-to-output copy correctness @@ -19,6 +21,9 @@ The public theorem is stated in `Complexitylib.Models.TuringMachine.Subroutines.CopyOutput`. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/Internal/CopyWorkOutput.lean b/Complexitylib/Models/TuringMachine/Subroutines/Internal/CopyWorkOutput.lean index 7f2f511b..89335ce6 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/Internal/CopyWorkOutput.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/Internal/CopyWorkOutput.lean @@ -3,7 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.Internal + +module +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Models.TuringMachine.Hoare.Defs +public import Complexitylib.Models.TuringMachine.Subroutines +public import Complexitylib.Models.TuringMachine.Tape.Encoding /-! # Copy a raw work-tape output — proof internals @@ -17,6 +22,9 @@ Public statements are in `Complexitylib.Models.TuringMachine.Subroutines.CopyWorkOutput`. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/Internal/ScanRight.lean b/Complexitylib/Models/TuringMachine/Subroutines/Internal/ScanRight.lean index 532b881c..21aa23ac 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/Internal/ScanRight.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/Internal/ScanRight.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Hoare.Defs -import Complexitylib.Models.TuringMachine.Subroutines -import Complexitylib.Models.TuringMachine.Tape.Encoding + +module +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Models.TuringMachine.Hoare.Defs +public import Complexitylib.Models.TuringMachine.Subroutines +public import Complexitylib.Models.TuringMachine.Tape.Encoding /-! # Right-scanner correctness @@ -20,6 +22,9 @@ The public compositional theorem is stated in `Complexitylib.Models.TuringMachine.Subroutines.ScanRight`. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/PairEmit.lean b/Complexitylib/Models/TuringMachine/Subroutines/PairEmit.lean index ea6a7f13..f0a8c8ab 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/PairEmit.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/PairEmit.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.PairEmit.Defs -import Complexitylib.Models.TuringMachine.Subroutines.PairEmit.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.PairEmit.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.PairEmit.Internal /-! # Pair emission from the input and a work tape @@ -19,6 +21,9 @@ second component. - `TM.pairInputWorkTM_hoareTime` — compositional time-bounded contract -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/PairEmit/Defs.lean b/Complexitylib/Models/TuringMachine/Subroutines/PairEmit/Defs.lean index 1a64e6ea..8a69018b 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/PairEmit/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/PairEmit/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators + +module +public import Complexitylib.Models.TuringMachine.Combinators /-! # Pair emission from the input and a work tape @@ -20,6 +22,9 @@ Both sources are consumed only through their first blank delimiter. - `TM.pairInputWorkTime` — the exact running time on canonical sources -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/PairEmit/Internal.lean b/Complexitylib/Models/TuringMachine/Subroutines/PairEmit/Internal.lean index a24dc7e3..287298a8 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/PairEmit/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/PairEmit/Internal.lean @@ -3,11 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Encoding.Pairing -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Hoare.Defs -import Complexitylib.Models.TuringMachine.Subroutines.PairEmit.Defs -import Complexitylib.Models.TuringMachine.Tape.Encoding + +module +public import Complexitylib.Encoding.Pairing +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Models.TuringMachine.Hoare.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.PairEmit.Defs +public import Complexitylib.Models.TuringMachine.Tape.Encoding /-! # Pair emission from the input and a work tape — proof internals @@ -15,6 +17,9 @@ import Complexitylib.Models.TuringMachine.Tape.Encoding This module verifies the exact two-pass controller in `PairEmit.Defs`. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/PairSplit.lean b/Complexitylib/Models/TuringMachine/Subroutines/PairSplit.lean index 6f711f53..cb9f8d7d 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/PairSplit.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/PairSplit.lean @@ -3,10 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Hoare.Defs -import Complexitylib.Models.TuringMachine.Subroutines.PairSplit.Defs -import Complexitylib.Models.TuringMachine.Subroutines.PairSplit.Internal -import Complexitylib.Models.TuringMachine.Tape.Encoding + +module +public import Complexitylib.Models.TuringMachine.Hoare.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.PairSplit.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.PairSplit.Internal +public import Complexitylib.Models.TuringMachine.Tape.Encoding /-! # Split a paired input onto work tapes @@ -34,6 +36,9 @@ with a distinct failure result. `HasOutput` specifications. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/PairSplit/Defs.lean b/Complexitylib/Models/TuringMachine/Subroutines/PairSplit/Defs.lean index 6a144749..13612b12 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/PairSplit/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/PairSplit/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators + +module +public import Complexitylib.Models.TuringMachine.Combinators /-! # Pair-splitting machine — definitions @@ -14,6 +16,9 @@ and the public compositional specification live in the adjacent internal and surface modules. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/PairSplit/Internal.lean b/Complexitylib/Models/TuringMachine/Subroutines/PairSplit/Internal.lean index 5744a2f9..a831a9a7 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/PairSplit/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/PairSplit/Internal.lean @@ -3,11 +3,14 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Encoding.Pairing -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Trace -import Complexitylib.Models.TuringMachine.Subroutines.PairSplit.Defs -import Mathlib.Tactic.Ring + +module +public import Complexitylib.Encoding.Pairing +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Models.TuringMachine.Trace +public import Complexitylib.Models.TuringMachine.Subroutines.PairSplit.Defs +public import Mathlib.Algebra.Order.Ring.Nat +public import Mathlib.Tactic.Ring.RingNF /-! # Pair-splitting machine — proof internals @@ -17,6 +20,9 @@ This file proves the stepwise decoding and exact-time correctness facts for `Complexitylib.Models.TuringMachine.Subroutines.PairSplit`. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/PairValidate.lean b/Complexitylib/Models/TuringMachine/Subroutines/PairValidate.lean index 2e84f748..ad8a36ea 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/PairValidate.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/PairValidate.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Lift -import Complexitylib.Models.TuringMachine.Hoare -import Complexitylib.Models.TuringMachine.Subroutines.PairValidate.Defs -import Complexitylib.Models.TuringMachine.Subroutines.PairValidate.Internal + +module +public import Complexitylib.Models.TuringMachine.Lift +public import Complexitylib.Models.TuringMachine.Hoare +public import Complexitylib.Models.TuringMachine.Subroutines.PairValidate.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.PairValidate.Internal /-! # Validate paired machine inputs @@ -20,6 +22,9 @@ need rejecting semantics, then rewind and use the canonical splitter to stage the two decoded components. -/ + +@[expose] public section + namespace Complexity /-- Decoder-facing characterization of membership in `validPairEncoding`. -/ diff --git a/Complexitylib/Models/TuringMachine/Subroutines/PairValidate/Defs.lean b/Complexitylib/Models/TuringMachine/Subroutines/PairValidate/Defs.lean index 3889a078..a5d6a775 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/PairValidate/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/PairValidate/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Encoding.Pairing -import Complexitylib.Models.TuringMachine.Combinators + +module +public import Complexitylib.Encoding.Pairing +public import Complexitylib.Models.TuringMachine.Combinators /-! # Pair-encoding validator — definitions @@ -15,6 +17,9 @@ has total semantics: it writes `1` exactly when `unpair?` succeeds and writes `0` on every malformed encoding. -/ + +@[expose] public section + namespace Complexity /-- The language of strings on which the canonical pair decoder succeeds. -/ diff --git a/Complexitylib/Models/TuringMachine/Subroutines/PairValidate/Internal.lean b/Complexitylib/Models/TuringMachine/Subroutines/PairValidate/Internal.lean index 549a2f02..3f222920 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/PairValidate/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/PairValidate/Internal.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.Internal.Scanner -import Complexitylib.Models.TuringMachine.Hoare -import Complexitylib.Models.TuringMachine.Lift -import Complexitylib.Models.TuringMachine.Subroutines.PairValidate.Defs + +module +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Scanner +public import Complexitylib.Models.TuringMachine.Hoare +public import Complexitylib.Models.TuringMachine.Lift +public import Complexitylib.Models.TuringMachine.Subroutines.PairValidate.Defs /-! # Pair-encoding validator — proof internals @@ -15,6 +17,9 @@ The finite-state fold is related to `unpair?`, then the generic scanner correctness theorem supplies the executable machine proof and exact time bound. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/ResetBinary.lean b/Complexitylib/Models/TuringMachine/Subroutines/ResetBinary.lean index 70d86791..8e35f8dd 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/ResetBinary.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/ResetBinary.lean @@ -3,10 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Subroutines.ClearWork -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.ClearWork +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary.Internal /-! # Resetting a binary work tape @@ -15,6 +16,9 @@ This module exposes the framed time and space contracts for rewinding an arbitrary canonical binary cursor and clearing it to the standard blank tape. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/ResetBinary/Defs.lean b/Complexitylib/Models/TuringMachine/Subroutines/ResetBinary/Defs.lean index de9571bc..5ac61602 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/ResetBinary/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/ResetBinary/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.ClearWork.Defs -import Complexitylib.Models.TuringMachine.Tape.Encoding + +module +public import Complexitylib.Models.TuringMachine.Subroutines.ClearWork.Defs +public import Complexitylib.Models.TuringMachine.Subroutines /-! # Resetting a binary work tape — definitions @@ -14,6 +16,9 @@ contents and then clears the resulting completed string to the standard blank work tape. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/ResetBinary/Internal.lean b/Complexitylib/Models/TuringMachine/Subroutines/ResetBinary/Internal.lean index acfa84a3..cde4e27c 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/ResetBinary/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/ResetBinary/Internal.lean @@ -3,15 +3,19 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Hoare -import Complexitylib.Models.TuringMachine.Registers -import Complexitylib.Models.TuringMachine.Subroutines.Internal -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary.Defs + +module +public import Complexitylib.Models.TuringMachine.Registers +public import Complexitylib.Models.TuringMachine.Subroutines.Internal +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary.Defs /-! # Resetting a binary work tape — proof internals -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/ResetBinaryMany.lean b/Complexitylib/Models/TuringMachine/Subroutines/ResetBinaryMany.lean index 722ae7ab..baec41a7 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/ResetBinaryMany.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/ResetBinaryMany.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Hoare.Space -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany.Defs -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany.Internal /-! # Resetting several binary work tapes @@ -14,6 +15,9 @@ This module exposes a framed compositional contract for resetting a fixed list of distinct canonical binary work tapes. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/ResetBinaryMany/Defs.lean b/Complexitylib/Models/TuringMachine/Subroutines/ResetBinaryMany/Defs.lean index b2dae0c7..98543d66 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/ResetBinaryMany/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/ResetBinaryMany/Defs.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Registers.RegisterOps -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary.Defs + +module +public import Complexitylib.Models.TuringMachine.Registers.RegisterOps +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary.Defs /-! # Resetting several binary work tapes — definitions @@ -14,6 +16,9 @@ tape named by `targets`. The executable machine depends only on the tape-index list; represented contents and resource bounds occur only in its contracts. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/ResetBinaryMany/Internal.lean b/Complexitylib/Models/TuringMachine/Subroutines/ResetBinaryMany/Internal.lean index 536f581b..f0a1b384 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/ResetBinaryMany/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/ResetBinaryMany/Internal.lean @@ -3,13 +3,18 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary -import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany.Defs + +module +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinary +public import Complexitylib.Models.TuringMachine.Subroutines.ResetBinaryMany.Defs /-! # Resetting several binary work tapes — proof internals -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/ScanRight.lean b/Complexitylib/Models/TuringMachine/Subroutines/ScanRight.lean index 8d2f2219..fc1c62bb 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/ScanRight.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/ScanRight.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Hoare.Defs -import Complexitylib.Models.TuringMachine.Subroutines -import Complexitylib.Models.TuringMachine.Subroutines.Internal.ScanRight -import Complexitylib.Models.TuringMachine.Tape.Encoding + +module +public import Complexitylib.Models.TuringMachine.Hoare.Defs +public import Complexitylib.Models.TuringMachine.Subroutines +public import Complexitylib.Models.TuringMachine.Subroutines.Internal.ScanRight +public import Complexitylib.Models.TuringMachine.Tape.Encoding /-! # Frame-preserving right scan @@ -21,6 +23,9 @@ first blank. Every stable tape outside that target is preserved exactly. - `TM.scanRightTM_hoareTime_frame` — bounded compositional form of that endpoint. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/UnaryLength.lean b/Complexitylib/Models/TuringMachine/Subroutines/UnaryLength.lean index 450d0fa8..7eea7bff 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/UnaryLength.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/UnaryLength.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.UnaryLength.Defs -import Complexitylib.Models.TuringMachine.Subroutines.UnaryLength.Internal + +module +public import Complexitylib.Models.TuringMachine.Subroutines.UnaryLength.Defs +public import Complexitylib.Models.TuringMachine.Subroutines.UnaryLength.Internal /-! # Unary input-length transducer @@ -18,6 +20,9 @@ emits `List.replicate x.length true` within the linear bound `|x| + 2`. linear time -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/UnaryLength/Defs.lean b/Complexitylib/Models/TuringMachine/Subroutines/UnaryLength/Defs.lean index a28820d7..5c81b173 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/UnaryLength/Defs.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/UnaryLength/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators + +module +public import Complexitylib.Models.TuringMachine.Combinators /-! # Unary input-length transducer — definitions @@ -13,6 +15,9 @@ once and writes one `true` bit per input bit. Its output is therefore the unary representation `List.replicate x.length true` of the input length. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Subroutines/UnaryLength/Internal.lean b/Complexitylib/Models/TuringMachine/Subroutines/UnaryLength/Internal.lean index 403edf8d..f625404d 100644 --- a/Complexitylib/Models/TuringMachine/Subroutines/UnaryLength/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Subroutines/UnaryLength/Internal.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Subroutines.UnaryLength.Defs -import Complexitylib.Models.TuringMachine.Tape.Encoding + +module +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Models.TuringMachine.Subroutines.UnaryLength.Defs +public import Complexitylib.Models.TuringMachine.Tape.Encoding /-! # Unary input-length transducer — proof internals @@ -16,6 +18,9 @@ writes one `true` bit per input bit, and halts on the first input blank after exactly `|x| + 2` transitions. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/Tape/Encoding.lean b/Complexitylib/Models/TuringMachine/Tape/Encoding.lean index 18bfeb33..86668ae1 100644 --- a/Complexitylib/Models/TuringMachine/Tape/Encoding.lean +++ b/Complexitylib/Models/TuringMachine/Tape/Encoding.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine + +module +public import Complexitylib.Models.TuringMachine /-! # Binary string encodings on Turing-machine tapes @@ -17,6 +19,9 @@ beginning of a remaining suffix. These shapes are shared by deterministic and nondeterministic machine constructions. -/ + +@[expose] public section + namespace Complexity namespace Tape diff --git a/Complexitylib/Models/TuringMachine/Trace.lean b/Complexitylib/Models/TuringMachine/Trace.lean index 0cce91b0..734f06a0 100644 --- a/Complexitylib/Models/TuringMachine/Trace.lean +++ b/Complexitylib/Models/TuringMachine/Trace.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine -import Complexitylib.Models.TuringMachine.Trace.Internal + +module +public import Complexitylib.Models.TuringMachine +public import Complexitylib.Models.TuringMachine.Trace.Internal /-! # Nondeterministic trace decomposition @@ -18,6 +20,9 @@ dependent `Fin` casts into fixed-schedule simulation proofs. - `NTM.trace_invariant` -- prove an indexed invariant one trace step at a time. -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/Trace/Internal.lean b/Complexitylib/Models/TuringMachine/Trace/Internal.lean index ba9059cb..f28b1037 100644 --- a/Complexitylib/Models/TuringMachine/Trace/Internal.lean +++ b/Complexitylib/Models/TuringMachine/Trace/Internal.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Internal + +module +public import Complexitylib.Models.TuringMachine.Internal /-! # Nondeterministic trace API -- proof internals @@ -11,6 +13,9 @@ import Complexitylib.Models.TuringMachine.Internal Proofs for the public finite-trace decomposition rules. -/ + +@[expose] public section + namespace Complexity namespace NTM diff --git a/Complexitylib/Models/TuringMachine/UTM/Clock.lean b/Complexitylib/Models/TuringMachine/UTM/Clock.lean index 66291d7b..0ae618cd 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Clock.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Clock.lean @@ -3,10 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Lift -import Complexitylib.Models.TuringMachine.Hoare.Defs -import Complexitylib.Models.TuringMachine.Registers -import Complexitylib.Models.TuringMachine.UTM.Internal.VTape + +module +public import Complexitylib.Models.TuringMachine.Lift +public import Complexitylib.Models.TuringMachine.Hoare.Defs +public import Complexitylib.Models.TuringMachine.Registers +public import Complexitylib.Models.TuringMachine.UTM.Internal.VTape /-! # Clock infrastructure for the time-bounded universal machine @@ -48,6 +50,9 @@ not `bodyTM` phase states, so they sit beside `liftTM` rather than in `zeroTestTM_hoareTime` (4 steps). -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/UTM/ClockConstructible.lean b/Complexitylib/Models/TuringMachine/UTM/ClockConstructible.lean index fc1d3993..dc8b8f0d 100644 --- a/Complexitylib/Models/TuringMachine/UTM/ClockConstructible.lean +++ b/Complexitylib/Models/TuringMachine/UTM/ClockConstructible.lean @@ -3,8 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Tactic.Ring -import Complexitylib.Models.TuringMachine.Registers.Arith + +module +public import Complexitylib.Models.TuringMachine.Registers.RegisterOps +public import Mathlib.Algebra.Order.Ring.Nat +public import Mathlib.Tactic.Ring.RingNF /-! # Clock constructibility for the time hierarchy theorem @@ -33,6 +36,9 @@ state, ghost-framed step/run lemmas as in `UTM/Clock.lean` and `InputLen.lean`). -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/UTM/ClockedUtm.lean b/Complexitylib/Models/TuringMachine/UTM/ClockedUtm.lean index d5e76c70..54dd38a2 100644 --- a/Complexitylib/Models/TuringMachine/UTM/ClockedUtm.lean +++ b/Complexitylib/Models/TuringMachine/UTM/ClockedUtm.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Internal.SimClocked -import Complexitylib.Models.TuringMachine.UTM.Internal.SeekFrontier -import Complexitylib.Models.TuringMachine.Subroutines.Internal + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.SimClocked +public import Complexitylib.Models.TuringMachine.UTM.Internal.SeekFrontier +public import Complexitylib.Models.TuringMachine.Subroutines.Internal /-! # The clocked universal machine @@ -39,6 +41,9 @@ both within `clockedUtmTime α x V` steps from the started tapes `retargetInput` mid-sequence). -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/UTM/Diagonal.lean b/Complexitylib/Models/TuringMachine/UTM/Diagonal.lean index 3024ec34..46cb7f4c 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Diagonal.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Diagonal.lean @@ -3,13 +3,15 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Internal.PairSelf -import Complexitylib.Models.TuringMachine.UTM.Internal.TermCheck -import Complexitylib.Models.TuringMachine.UTM.ClockedUtm -import Complexitylib.Models.TuringMachine.UTM.Internal.NegOut -import Complexitylib.Models.TuringMachine.UTM.HierarchySupport -import Complexitylib.Models.TuringMachine.UTM.ClockConstructible -import Complexitylib.Models.TuringMachine.Combinators.Internal.Retarget + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.PairSelf +public import Complexitylib.Models.TuringMachine.UTM.Internal.TermCheck +public import Complexitylib.Models.TuringMachine.UTM.ClockedUtm +public import Complexitylib.Models.TuringMachine.UTM.Internal.NegOut +public import Complexitylib.Models.TuringMachine.UTM.HierarchySupport +public import Complexitylib.Models.TuringMachine.UTM.ClockConstructible +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Retarget /-! # The time-hierarchy diagonalizer `diagTM` @@ -60,6 +62,9 @@ Two landed specs do not quite fit and are bridged locally: clean output tape. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/UTM/Encoding.lean b/Complexitylib/Models/TuringMachine/UTM/Encoding.lean index 6cac5dcd..e6ba881b 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Encoding.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Encoding.lean @@ -3,8 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine -import Complexitylib.Mathlib.NatBits + +module +public import Complexitylib.Models.TuringMachine +public import Mathlib.Tactic.NormNum.Inv +public import Mathlib.Tactic.NormNum.Pow /-! # TM State Normalization and Binary Encoding @@ -40,6 +43,9 @@ Turing machines: - `allΓFuncs` — enumerate all `Fin n → Γ` functions -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/UTM/HierarchySupport.lean b/Complexitylib/Models/TuringMachine/UTM/HierarchySupport.lean index 8ec49ee0..3ad12c86 100644 --- a/Complexitylib/Models/TuringMachine/UTM/HierarchySupport.lean +++ b/Complexitylib/Models/TuringMachine/UTM/HierarchySupport.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Internal.SimLoop -import Complexitylib.Asymptotics + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.SimLoop +public import Complexitylib.Asymptotics /-! # Support lemmas for the time-hierarchy theorem @@ -21,6 +23,9 @@ Four self-contained ingredients used by the diagonalization argument: a step budget `V` or is still running after exactly `V` steps. -/ + +@[expose] public section + namespace Complexity open Asymptotics Filter diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/Body.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/Body.lean index b0bb8e80..f00c004d 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/Body.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/Body.lean @@ -3,16 +3,15 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.UTM.Internal.Desc -import Complexitylib.Models.TuringMachine.UTM.Internal.VTape -import Mathlib.Tactic.DeriveFintype -import Mathlib.Tactic.FinCases -import Mathlib.Data.Fintype.Sigma -import Mathlib.Data.Fintype.Prod -import Mathlib.Data.Fintype.Option -import Mathlib.Data.Fintype.Sum + +module +public import Complexitylib.Models.TuringMachine.Combinators +public import Mathlib.Tactic.DeriveFintype +public import Mathlib.Tactic.FinCases +public import Mathlib.Data.Fintype.Sigma +public import Mathlib.Data.Fintype.Prod +public import Mathlib.Data.Fintype.Option +public import Complexitylib.Models.TuringMachine.UTM.Encoding /-! # The universal machine's loop body @@ -33,6 +32,9 @@ This file defines the machine only; its `HoareTime` spec and the correspondence with `TMDesc.toTM.step` live in `BodyInternal.lean` (M3). -/ + +@[expose] public section + namespace Complexity namespace TM.UTMBody diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/BodyApply.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/BodyApply.lean index cfd7748b..1e26840a 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/BodyApply.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/BodyApply.lean @@ -3,8 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Internal.BodyInternal -import Complexitylib.Models.TuringMachine.UTM.Internal.VTape + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.BodyInternal +public import Complexitylib.Models.TuringMachine.UTM.Internal.VTape +public import Complexitylib.Models.TuringMachine.UTM.Internal.Desc /-! # Body machine: peek, default-move, and apply phases @@ -27,6 +30,9 @@ tapes (the `+1`-shift shadows of the simulated input/work/output tapes, decoders to the description decoders in `Desc.lean`. -/ + +@[expose] public section + namespace Complexity namespace TM.UTMBody diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/BodyAssembly.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/BodyAssembly.lean index 3ea6199b..8594df23 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/BodyAssembly.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/BodyAssembly.lean @@ -3,10 +3,13 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Internal.BodyMatch -import Complexitylib.Models.TuringMachine.UTM.Internal.BodyApply -import Complexitylib.Models.TuringMachine.UTM.Internal.DescLayout -import Complexitylib.Models.TuringMachine.UTM.Internal.Verdict + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.BodyMatch +public import Complexitylib.Models.TuringMachine.UTM.Internal.BodyApply +public import Complexitylib.Models.TuringMachine.UTM.Internal.DescLayout +public import Complexitylib.Models.TuringMachine.UTM.Internal.Verdict +public import Complexitylib.Models.TuringMachine.UTM.Internal.Interp /-! # Body correctness: phase assembly @@ -19,6 +22,9 @@ halted interpreted machine makes the body a bounded-time no-op, and a running one brings it to the peek phase with all tapes restored. -/ + +@[expose] public section + namespace Complexity namespace TM.UTMBody diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/BodyInternal.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/BodyInternal.lean index ea225432..f101726b 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/BodyInternal.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/BodyInternal.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Internal.Body -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.Body +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic /-! # Body machine: step reduction @@ -16,6 +18,9 @@ work tapes act per `acts`, whose real input idles, and whose real output write-backs — in closed form. -/ + +@[expose] public section + namespace Complexity namespace TM.UTMBody diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/BodyIteration.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/BodyIteration.lean index aa39da42..2dad9d1c 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/BodyIteration.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/BodyIteration.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Internal.BodyLoop -import Complexitylib.Models.TuringMachine.UTM.Internal.StepGlue + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.BodyLoop +public import Complexitylib.Models.TuringMachine.UTM.Internal.StepGlue /-! # Body correctness: the per-iteration theorem @@ -28,6 +30,9 @@ divergence: an entry region starting with an empty segment followed by junk (see `matchLoop`). -/ + +@[expose] public section + namespace Complexity namespace TM.UTMBody diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/BodyLookup.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/BodyLookup.lean index 51e6a575..eeb2909a 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/BodyLookup.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/BodyLookup.lean @@ -3,8 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Internal.Verdict -import Complexitylib.Models.TuringMachine.UTM.Internal.BodyApply + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.Verdict +public import Complexitylib.Models.TuringMachine.UTM.Internal.BodyApply +public import Std.Tactic.BVDecide.Normalize.BitVec /-! # Match-loop ↔ lookup correspondence (pure list level) @@ -30,6 +33,9 @@ no machine steps (design appendix 2): entry's action fields. -/ + +@[expose] public section + namespace Complexity namespace TM.UTMBody diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/BodyLoop.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/BodyLoop.lean index 5701550a..ff607c99 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/BodyLoop.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/BodyLoop.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Internal.BodyAssembly -import Complexitylib.Models.TuringMachine.UTM.Internal.BodyLookup + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.BodyAssembly +public import Complexitylib.Models.TuringMachine.UTM.Internal.BodyLookup /-! # Body machine: the match-loop induction @@ -40,6 +42,9 @@ regions of the form `entry □ ⋯ □ □` (head symbol is an entry bit) or ` which has just read the next region's head symbol and found it non-`□`. -/ + +@[expose] public section + namespace Complexity namespace TM.UTMBody diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/BodyMatch.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/BodyMatch.lean index 23bb1215..265b898d 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/BodyMatch.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/BodyMatch.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Internal.BodyInternal + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.BodyInternal /-! # Body machine: match-phase loop lemmas @@ -20,6 +22,9 @@ exactly preserved (`idle_tape_id` frames), and scratch extension is stated as an update-on-an-interval of the ghost cells (as in `dfCopy_loop`). -/ + +@[expose] public section + namespace Complexity namespace TM.UTMBody diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/ClockFrontier.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/ClockFrontier.lean index 42f2ea3f..951997eb 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/ClockFrontier.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/ClockFrontier.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Clock + +module +public import Complexitylib.Models.TuringMachine.UTM.Clock /-! # Frontier-parked clock machines for the time-bounded universal machine @@ -33,6 +35,9 @@ Two `TM 7` machines, both with ghost-initial-tapes `HoareTime` specs: `δ_right_of_start`, making `out.head = 1` unachievable. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/Desc.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/Desc.lean index c52cda1b..1c642bb2 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/Desc.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/Desc.lean @@ -3,8 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine -import Complexitylib.Models.TuringMachine.UTM.Encoding + +module +public import Complexitylib.Models.TuringMachine.UTM.Encoding +public import Complexitylib.Mathlib.NatBits +public import Mathlib.Algebra.Order.Ring.Nat /-! # Machine descriptions for the universal Turing machine @@ -49,6 +52,9 @@ string denotes some machine. - `decodeDesc_encodeDesc_append` — roundtrip ignores trailing junk -/ + +@[expose] public section + namespace Complexity -- ════════════════════════════════════════════════════════════════════════ diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/DescLayout.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/DescLayout.lean index 2e5d537c..5752fdd4 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/DescLayout.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/DescLayout.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Internal.VTape -import Complexitylib.Models.TuringMachine.UTM.Internal.Desc -import Complexitylib.Models.TuringMachine.UTM.Internal.HaltTest + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.VTape +public import Complexitylib.Models.TuringMachine.UTM.Internal.Desc +public import Complexitylib.Models.TuringMachine.UTM.Internal.HaltTest /-! # Description-tape layout @@ -22,6 +24,9 @@ These feed the seek phase (two `scanRight_loop` instances land the desc head at the entry region) and the match loop (entry-region cells). -/ + +@[expose] public section + namespace Complexity namespace TM.UTMBody diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/Extract.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/Extract.lean index 82518208..eeac413a 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/Extract.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/Extract.lean @@ -3,9 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Hoare.Defs -import Complexitylib.Models.TuringMachine.UTM.Internal.VTape -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic + +module +public import Complexitylib.Models.TuringMachine.Hoare.Defs +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic /-! # UTM extraction phase: `extractTM` @@ -42,6 +43,9 @@ unchanged (only its head moves). within `B + m + 8` steps, where `B` bounds the initial work-2 head. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/HaltTest.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/HaltTest.lean index 3639e8e4..5ffaa18a 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/HaltTest.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/HaltTest.lean @@ -3,10 +3,13 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Hoare.Defs -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.UTM.Internal.VTape -import Complexitylib.Models.TuringMachine.UTM.Internal.Desc + +module +public import Complexitylib.Models.TuringMachine.Hoare.Defs +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Models.TuringMachine.UTM.Internal.VTape +public import Complexitylib.Models.TuringMachine.UTM.Internal.Desc +public import Mathlib.Algebra.Order.Sub.Basic /-! # The UTM halt test machine @@ -46,6 +49,9 @@ extends beyond it (and `takeField` fields are always blank-free). The UTM state tape holds bit symbols only, so this is no restriction in use. -/ + +@[expose] public section + namespace Complexity -- ════════════════════════════════════════════════════════════════════════ diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/Init.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/Init.lean index fc48baad..a5c8e76f 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/Init.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/Init.lean @@ -3,11 +3,14 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Internal.Desc -import Complexitylib.Models.TuringMachine.UTM.Internal.VTape -import Complexitylib.Models.TuringMachine.Hoare.Defs -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Encoding.Pairing + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.Desc +public import Complexitylib.Models.TuringMachine.UTM.Internal.VTape +public import Complexitylib.Models.TuringMachine.Hoare.Defs +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.Encoding.Pairing +public import Mathlib.Algebra.Order.Sub.Basic /-! # UTM initialization machine @@ -31,6 +34,9 @@ or a blank in the middle of a 2-cell group in the α-region) make the machine halt immediately; the specification only covers well-formed inputs. -/ + +@[expose] public section + namespace Complexity namespace TM @@ -87,7 +93,7 @@ instance : Fintype InitQ where /-- One step of a work-tape rewind: move the head of work tape `idx` left until it reads `▷`, then bounce right to cell 1 and enter `qnext`. All other tapes idle. -/ -private def rewindStep (idx : Fin 6) (qloop qnext : InitQ) +def rewindStep (idx : Fin 6) (qloop qnext : InitQ) (iHead : Γ) (wHeads : Fin 6 → Γ) (oHead : Γ) : InitQ × (Fin 6 → Γw) × Γw × Dir3 × (Fin 6 → Dir3) × Dir3 := if wHeads idx = Γ.start then diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/Interp.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/Interp.lean index f31d30b9..726ea589 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/Interp.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/Interp.lean @@ -3,8 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Internal.Desc -import Complexitylib.Models.TuringMachine.UTM.Encoding + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.Desc /-! # Interpreting machine descriptions @@ -29,6 +30,9 @@ table lists every `(state, symbols)` combination densely. - `descOfTM_decidesInTime` — language and running time carry over exactly -/ + +@[expose] public section + namespace Complexity namespace TMDesc diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/NegOut.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/NegOut.lean index 3d41f4e7..313afe8b 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/NegOut.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/NegOut.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Hoare.Defs -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic + +module +public import Complexitylib.Models.TuringMachine.Hoare.Defs +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic /-! # Output negation phase: `negOutTM` @@ -42,6 +44,9 @@ writes and `idleDir` moves); the output cells are unchanged except cell 1. the output head parked at cell 1, and `inp = inp₀`, `work = work₀`. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/PairSelf.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/PairSelf.lean index 0366eff0..e16612a5 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/PairSelf.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/PairSelf.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.NP.Internal.PairBuildTM -import Complexitylib.Models.TuringMachine.Subroutines.Internal + +module +public import Complexitylib.Classes.NP.Internal.PairBuildTM +public import Complexitylib.Models.TuringMachine.Subroutines.Internal /-! # `pairSelfTM`: build `pair x x` from input `x` @@ -42,6 +44,9 @@ clearWorkTM 0 erase work tape 0 back to the started blank tape - `pairSelfTime_le` — the clean quadratic bound `pairSelfTime n ≤ 58·(n+1)²` -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/SeekFrontier.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/SeekFrontier.lean index 979c4147..53ca5e77 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/SeekFrontier.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/SeekFrontier.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Clock + +module +public import Complexitylib.Models.TuringMachine.UTM.Clock /-! # Frontier-seeking clock machine for the time-bounded universal machine @@ -27,6 +29,9 @@ steps, every other tape exactly preserved. Behavior from head 1 on frontier `V = max V 1`, halting. Total `V + 1` steps. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/Sim.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/Sim.lean index e3a0afd5..e905be2a 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/Sim.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/Sim.lean @@ -3,9 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Machine -import Complexitylib.Models.TuringMachine.UTM.Internal.BodyAssembly -import Complexitylib.Models.TuringMachine.UTM.Internal.Init + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.BodyAssembly +public import Complexitylib.Encoding.Pairing /-! # Universal machine: simulation bridges @@ -24,6 +25,9 @@ The completed loop simulation and headline universal-machine theorems are in `UTM/SimLoop.lean` and `UTM/Universal.lean`. -/ + +@[expose] public section + namespace Complexity namespace TM.UTMBody diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/SimClocked.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/SimClocked.lean index 8e6fb2ee..9214f2b4 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/SimClocked.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/SimClocked.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Internal.SimLoop -import Complexitylib.Models.TuringMachine.UTM.Internal.ClockFrontier + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.SimLoop +public import Complexitylib.Models.TuringMachine.UTM.Internal.ClockFrontier /-! # Universal machine: the clocked (time-bounded) simulate/halt-test loop @@ -51,6 +53,9 @@ the state tape (`SimInv` at the final interpreted configuration makes a subsequent halt test conclusive via `simInv_verdict`). -/ + +@[expose] public section + namespace Complexity namespace TM.UTMBody diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/SimLoop.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/SimLoop.lean index 829852c2..d2ad2662 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/SimLoop.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/SimLoop.lean @@ -3,10 +3,14 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Internal.BodyIteration -import Complexitylib.Models.TuringMachine.UTM.Internal.Sim -import Complexitylib.Models.TuringMachine.Combinators.Internal.Loop -import Complexitylib.Models.TuringMachine.Hoare + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.BodyIteration +public import Complexitylib.Models.TuringMachine.UTM.Internal.Sim +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Loop +public import Complexitylib.Models.TuringMachine.Hoare +public import Complexitylib.Models.TuringMachine.UTM.Machine +public import Mathlib.Tactic.Ring.RingNF /-! # Universal machine: the simulate/halt-test loop @@ -46,6 +50,9 @@ halted-configurations-don't-step principle (`TM.reachesIn_le_halt`) identify the loop's exit configuration with `mcF`. -/ + +@[expose] public section + namespace Complexity namespace TM.UTMBody diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/StepGlue.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/StepGlue.lean index 8229e763..b897ac3d 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/StepGlue.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/StepGlue.lean @@ -3,8 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Internal.BodyAssembly -import Complexitylib.Models.TuringMachine.UTM.Internal.BodyLookup + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.BodyLookup /-! # Glue facts: phase outputs vs the interpreted step @@ -19,6 +20,9 @@ Small bridges used when matching the body's phase outputs against the identity on them. -/ + +@[expose] public section + namespace Complexity namespace TM.UTMBody diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/TermCheck.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/TermCheck.lean index 7afdae1b..42144d55 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/TermCheck.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/TermCheck.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Internal.BodyIteration -import Complexitylib.Models.TuringMachine.Registers + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.BodyIteration +public import Complexitylib.Models.TuringMachine.Subroutines.Counter /-! # `termCheckTM`: deciding `TerminatedRegion` by a single input scan @@ -31,6 +33,9 @@ Contents: `Γ.one`/`Γ.zero` at output cell 1 (output head parked back at 1). -/ + +@[expose] public section + namespace Complexity namespace TM.UTMBody diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/Terminated.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/Terminated.lean index fcc7ee5f..3d46ed02 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/Terminated.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/Terminated.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Internal.BodyIteration + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.BodyIteration /-! # `TerminatedRegion` for encoded descriptions @@ -22,6 +24,9 @@ separator `□`. Extracted tables are nonempty (`descOfTM_entries_ne_nil`), since every machine has at least its start state. -/ + +@[expose] public section + namespace Complexity namespace TM.UTMBody diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/VTape.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/VTape.lean index 46b109f3..078453ed 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/VTape.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/VTape.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine + +module +public import Complexitylib.Models.TuringMachine /-! # Virtual tapes: the +1 shift representation @@ -41,6 +43,9 @@ Under this shift the one-sided tape dynamics correspond exactly: - `VShift.init` — the initial correspondence -/ + +@[expose] public section + namespace Complexity -- ════════════════════════════════════════════════════════════════════════ diff --git a/Complexitylib/Models/TuringMachine/UTM/Internal/Verdict.lean b/Complexitylib/Models/TuringMachine/UTM/Internal/Verdict.lean index fd62b499..9ef4afd8 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Internal/Verdict.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Internal/Verdict.lean @@ -3,9 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Internal.Interp -import Complexitylib.Mathlib.NatBits -import Complexitylib.Models.TuringMachine.UTM.Internal.HaltTest + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.HaltTest /-! # Halt-test verdict correspondence @@ -23,6 +23,9 @@ halt check of the interpreted machine `(decodeDesc α).toTM`: the interpreted machine sits exactly at its (clamped) halt state. -/ + +@[expose] public section + namespace Complexity namespace TM.UTMBody diff --git a/Complexitylib/Models/TuringMachine/UTM/Machine.lean b/Complexitylib/Models/TuringMachine/UTM/Machine.lean index 8d7c752e..3705da81 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Machine.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Machine.lean @@ -3,11 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.UTM.Internal.Init -import Complexitylib.Models.TuringMachine.UTM.Internal.Body -import Complexitylib.Models.TuringMachine.UTM.Internal.HaltTest -import Complexitylib.Models.TuringMachine.UTM.Internal.Extract + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.Init +public import Complexitylib.Models.TuringMachine.UTM.Internal.Body +public import Complexitylib.Models.TuringMachine.UTM.Internal.HaltTest +public import Complexitylib.Models.TuringMachine.UTM.Internal.Extract /-! # The universal Turing machine @@ -28,6 +29,9 @@ the simulation and time-bound theorems are assembled in `UTM/Sim.lean` from the phase Hoare triples. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/Models/TuringMachine/UTM/Universal.lean b/Complexitylib/Models/TuringMachine/UTM/Universal.lean index 304a4cb2..b58eea17 100644 --- a/Complexitylib/Models/TuringMachine/UTM/Universal.lean +++ b/Complexitylib/Models/TuringMachine/UTM/Universal.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.UTM.Internal.SimLoop -import Complexitylib.Models.TuringMachine.UTM.Internal.Terminated -import Complexitylib.Models.TuringMachine.Deterministic + +module +public import Complexitylib.Models.TuringMachine.UTM.Internal.SimLoop +public import Complexitylib.Models.TuringMachine.UTM.Internal.Terminated +public import Complexitylib.Models.TuringMachine.Deterministic /-! # The universal machine: headline theorems @@ -25,6 +27,9 @@ import Complexitylib.Models.TuringMachine.Deterministic quadratic factor coming solely from the single-tape reduction. -/ + +@[expose] public section + namespace Complexity namespace TM.UTMBody diff --git a/Complexitylib/Models/TuringMachine/WorkReadOnly.lean b/Complexitylib/Models/TuringMachine/WorkReadOnly.lean index 47c634ca..4c7c420a 100644 --- a/Complexitylib/Models/TuringMachine/WorkReadOnly.lean +++ b/Complexitylib/Models/TuringMachine/WorkReadOnly.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Internal + +module +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic /-! # Read-only work-tape certificates @@ -14,6 +15,9 @@ of `tm` writes the symbol already read on work tape `idx`. The head may move, but valid tape contents are preserved through every finite run. -/ + +@[expose] public section + namespace Complexity namespace TM diff --git a/Complexitylib/SAT.lean b/Complexitylib/SAT.lean index 2ce8a543..da63be75 100644 --- a/Complexitylib/SAT.lean +++ b/Complexitylib/SAT.lean @@ -3,23 +3,25 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Semantics -import Complexitylib.SAT.Rename -import Complexitylib.SAT.ThreeCNF -import Complexitylib.SAT.ThreeSAT -import Complexitylib.SAT.ThreeSAT.Completeness -import Complexitylib.SAT.ThreeSAT.Syntax -import Complexitylib.SAT.Tseitin -import Complexitylib.SAT.Tseitin.Machine -import Complexitylib.SAT.QBF -import Complexitylib.SAT.Resolution -import Complexitylib.SAT.Encoding -import Complexitylib.SAT.Language -import Complexitylib.SAT.Verifier -import Complexitylib.SAT.Headline -import Complexitylib.SAT.ThreeSAT.Headline -import Complexitylib.SAT.CookLevin -import Complexitylib.SAT.CookLevin.Assembly + +module +public import Complexitylib.SAT.Semantics +public import Complexitylib.SAT.Rename +public import Complexitylib.SAT.ThreeCNF +public import Complexitylib.SAT.ThreeSAT +public import Complexitylib.SAT.ThreeSAT.Completeness +public import Complexitylib.SAT.ThreeSAT.Syntax +public import Complexitylib.SAT.Tseitin +public import Complexitylib.SAT.Tseitin.Machine +public import Complexitylib.SAT.QBF +public import Complexitylib.SAT.Resolution +public import Complexitylib.SAT.Encoding +public import Complexitylib.SAT.Language +public import Complexitylib.SAT.Verifier +public import Complexitylib.SAT.Headline +public import Complexitylib.SAT.ThreeSAT.Headline +public import Complexitylib.SAT.CookLevin +public import Complexitylib.SAT.CookLevin.Assembly /-! # SAT: Boolean satisfiability diff --git a/Complexitylib/SAT/CookLevin.lean b/Complexitylib/SAT/CookLevin.lean index da2d729c..a54b4712 100644 --- a/Complexitylib/SAT/CookLevin.lean +++ b/Complexitylib/SAT/CookLevin.lean @@ -3,10 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Headline -import Complexitylib.SAT.Rename -import Complexitylib.Classes.NP.Reduction -import Complexitylib.Models.TuringMachine.SingleTape + +module +public import Complexitylib.SAT.Rename +public import Complexitylib.Models.TuringMachine.Internal +public import Complexitylib.SAT.Verifier /-! # Cook–Levin tableau core @@ -38,6 +39,9 @@ the emitter implementation is split across the modules under `SAT/CookLevin/`. -/ + +@[expose] public section + namespace Complexity open Complexity diff --git a/Complexitylib/SAT/CookLevin/Assembly.lean b/Complexitylib/SAT/CookLevin/Assembly.lean index 859ec996..633e04ac 100644 --- a/Complexitylib/SAT/CookLevin/Assembly.lean +++ b/Complexitylib/SAT/CookLevin/Assembly.lean @@ -3,7 +3,14 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.CookLevin.Internal.EmitterActive + +module +public import Complexitylib.SAT.CookLevin.Internal.EmitterActive +public import Complexitylib.Classes.NP.Reduction +public import Complexitylib.Models.TuringMachine.Registers.InputLen +public import Complexitylib.Models.TuringMachine.SingleTape +public import Complexitylib.SAT.CookLevin.Internal.EmitterStart +public import Complexitylib.SAT.Headline /-! # The reduction emitter, assembled @@ -20,6 +27,9 @@ Cook–Levin reductions `cookLevin_reduction_singleTape` / `NPComplete_language` for the SAT language `language`. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/CookLevin/Internal/Emitter.lean b/Complexitylib/SAT/CookLevin/Internal/Emitter.lean index 75e19e17..88428c99 100644 --- a/Complexitylib/SAT/CookLevin/Internal/Emitter.lean +++ b/Complexitylib/SAT/CookLevin/Internal/Emitter.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.CookLevin -import Complexitylib.Models.TuringMachine.Registers.MixedRadix -import Complexitylib.Models.TuringMachine.Registers.DecReg + +module +public import Complexitylib.Models.TuringMachine.Registers.MixedRadix +public import Complexitylib.SAT.Encoding +public import Mathlib.Analysis.SpecialFunctions.Pow.NNReal /-! # The reduction emitter: clause and CNF machines @@ -22,6 +24,9 @@ these with the concrete descriptor lists mirroring each family's definition. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/CookLevin/Internal/EmitterActive.lean b/Complexitylib/SAT/CookLevin/Internal/EmitterActive.lean index 356947df..4897a851 100644 --- a/Complexitylib/SAT/CookLevin/Internal/EmitterActive.lean +++ b/Complexitylib/SAT/CookLevin/Internal/EmitterActive.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.CookLevin.Internal.EmitterStart + +module +public import Complexitylib.SAT.CookLevin.Internal.EmitterFamilies /-! # The active-transition family emitter @@ -16,6 +18,9 @@ unrolled at definition level (`bigSeqTM` over their lists); rows and positions are runtime loops. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/CookLevin/Internal/EmitterFamilies.lean b/Complexitylib/SAT/CookLevin/Internal/EmitterFamilies.lean index 819ff386..22551a66 100644 --- a/Complexitylib/SAT/CookLevin/Internal/EmitterFamilies.lean +++ b/Complexitylib/SAT/CookLevin/Internal/EmitterFamilies.lean @@ -3,7 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.CookLevin.Internal.EmitterLoop + +module +public import Complexitylib.SAT.CookLevin.Internal.EmitterLoop +public import Complexitylib.Models.TuringMachine.Registers.DecReg +public import Complexitylib.SAT.CookLevin /-! # The clause-family emitters @@ -17,6 +21,9 @@ The emitter's tape layout is fixed once (`Emit.nT = 20` work tapes, named indices below), so register-distinctness side conditions are all `decide`. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/CookLevin/Internal/EmitterLoop.lean b/Complexitylib/SAT/CookLevin/Internal/EmitterLoop.lean index 4778d05f..e0f71fc7 100644 --- a/Complexitylib/SAT/CookLevin/Internal/EmitterLoop.lean +++ b/Complexitylib/SAT/CookLevin/Internal/EmitterLoop.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.CookLevin.Internal.Emitter + +module +public import Complexitylib.SAT.CookLevin.Internal.Emitter /-! # The emitter loop driver @@ -21,6 +23,9 @@ discharges every `LitDesc.Spec` obligation) and the `encode`/`flatMap` distribution lemma. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/CookLevin/Internal/EmitterStart.lean b/Complexitylib/SAT/CookLevin/Internal/EmitterStart.lean index 2c7d2e8b..ad29ca80 100644 --- a/Complexitylib/SAT/CookLevin/Internal/EmitterStart.lean +++ b/Complexitylib/SAT/CookLevin/Internal/EmitterStart.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.CookLevin.Internal.EmitterFamilies -import Complexitylib.Models.TuringMachine.Registers.Probe + +module +public import Complexitylib.SAT.CookLevin.Internal.EmitterFamilies +public import Complexitylib.Models.TuringMachine.Registers.Probe /-! # The start-clause family emitter @@ -17,6 +19,9 @@ the scratch, emit. Tapes 1 and 2 are blank beyond `▷`, so their loops are ordinary constant-digit clause loops. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Encoding.lean b/Complexitylib/SAT/Encoding.lean index 9ebd8f9d..899bc18a 100644 --- a/Complexitylib/SAT/Encoding.lean +++ b/Complexitylib/SAT/Encoding.lean @@ -3,9 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Semantics -import Mathlib.Tactic.Ring -import Mathlib.Tactic.Linarith + +module +public import Complexitylib.SAT.Semantics +public import Mathlib.Tactic.Ring.RingNF +public import Std.Tactic.BVDecide.Normalize.Prop /-! # SAT: Encoding Layer @@ -51,6 +53,9 @@ The matching executable decoder `CNF.decode?`, its round-trip theorem, and its soundness theorem live with the token parser in `Complexitylib.SAT.Verifier`. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Headline.lean b/Complexitylib/SAT/Headline.lean index f52e7964..ea87f194 100644 --- a/Complexitylib/SAT/Headline.lean +++ b/Complexitylib/SAT/Headline.lean @@ -3,8 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.VerifierTM -import Complexitylib.SAT.Internal.GuessVerify + +module +public import Complexitylib.SAT.VerifierTM +public import Complexitylib.SAT.Internal.GuessVerify /-! # SAT ∈ NP — the headline theorem @@ -20,6 +22,9 @@ This file ties together the two halves of the `SAT ∈ NP` proof: Combining them yields the unconditional theorem `SAT.language_mem_NP : language ∈ NP`. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Internal/GuessVerify.lean b/Complexitylib/SAT/Internal/GuessVerify.lean index 1add91b1..4d74a5bd 100644 --- a/Complexitylib/SAT/Internal/GuessVerify.lean +++ b/Complexitylib/SAT/Internal/GuessVerify.lean @@ -3,13 +3,12 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Language -import Complexitylib.Asymptotics -import Complexitylib.Classes.NP.Internal.PairBuildTM -import Complexitylib.Models.TuringMachine.Subroutines.GuessBounded -import Complexitylib.Models.TuringMachine.Subroutines.Internal -import Complexitylib.Models.TuringMachine.Combinators.Internal.Retarget -import Complexitylib.Models.TuringMachine.Trace + +module +public import Complexitylib.SAT.Language +public import Complexitylib.Classes.NP.Internal.PairBuildTM +public import Complexitylib.Models.TuringMachine.Subroutines.GuessBounded +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Retarget /-! # SAT-specialized guess-and-verify NTM @@ -33,6 +32,9 @@ counter setup, input rewind, bounded guessing, pair building, and verifier simulation. -/ + +@[expose] public section + namespace Complexity namespace SAT @@ -159,7 +161,8 @@ instance {Q : Type} [DecidableEq Q] [Fintype Q] : Fintype (GuessVerifyPhase Q) w def verifierStartedState (M : TM k) : M.Q := (M.δ M.qstart Γ.start (fun _ : Fin k => Γ.start) Γ.start).1 -private def phaseBoundary {Q : Type} (q : GuessVerifyPhase Q) +/-- Boundary transition that preserves symbols and advances heads parked on `▷`. -/ +def phaseBoundary {Q : Type} (q : GuessVerifyPhase Q) (iHead : Γ) (wHeads : Fin (k + 3) → Γ) (oHead : Γ) : GuessVerifyPhase Q × (Fin (k + 3) → Γw) × Γw × Dir3 × (Fin (k + 3) → Dir3) × Dir3 := @@ -174,7 +177,8 @@ private theorem phaseBoundary_right_of_start {Q : Type} (q : GuessVerifyPhase Q) (oHead = Γ.start → (phaseBoundary (k := k) q iHead wHeads oHead).2.2.2.2.2 = Dir3.right) := rightOfStart_allIdle iHead wHeads oHead -private def satVerifyTransition (M : TM k) (q : M.Q) +/-- Lift of the deterministic verifier transition to the guess-and-verify tape layout. -/ +def satVerifyTransition (M : TM k) (q : M.Q) (iHead : Γ) (wHeads : Fin (k + 3) → Γ) (oHead : Γ) : GuessVerifyPhase M.Q × (Fin (k + 3) → Γw) × Γw × Dir3 × (Fin (k + 3) → Dir3) × Dir3 := @@ -221,7 +225,8 @@ private theorem satVerifyTransition_right_of_start (M : TM k) (q : M.Q) exact hwi) · simp [hip, idleDir_right_of_start hwi] -private def satGuessVerifyDelta (M : TM k) : +/-- Nondeterministic transition function for the combined SAT guess-and-verify machine. -/ +def satGuessVerifyDelta (M : TM k) : Bool → GuessVerifyPhase M.Q → Γ → (Fin (k + 3) → Γ) → Γ → GuessVerifyPhase M.Q × (Fin (k + 3) → Γw) × Γw × Dir3 × (Fin (k + 3) → Dir3) × Dir3 := diff --git a/Complexitylib/SAT/Internal/LinearGuessVerify.lean b/Complexitylib/SAT/Internal/LinearGuessVerify.lean index 570bdd6b..3ea53b19 100644 --- a/Complexitylib/SAT/Internal/LinearGuessVerify.lean +++ b/Complexitylib/SAT/Internal/LinearGuessVerify.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Internal.GuessVerify + +module +public import Complexitylib.SAT.Internal.GuessVerify /-! # Generic linear-witness interface for the SAT guess-and-verify machine @@ -20,6 +22,9 @@ theorems for any relation with that same linear bound. language -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Language.lean b/Complexitylib/SAT/Language.lean index 7537ff68..8ff90d29 100644 --- a/Complexitylib/SAT/Language.lean +++ b/Complexitylib/SAT/Language.lean @@ -3,11 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Semantics -import Complexitylib.SAT.Encoding -import Complexitylib.Classes.Pairing -import Complexitylib.Classes.FNP -import Complexitylib.Classes.NP.Witness + +module +public import Complexitylib.SAT.Encoding +public import Complexitylib.Classes.NP.Witness /-! # SAT: Language and Witness Relation @@ -28,6 +27,9 @@ SAT-specialized guess-and-verify construction is assembled into the unconditional headline theorem in `SAT/Headline.lean`. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/QBF.lean b/Complexitylib/SAT/QBF.lean index bdf0a635..fa451dd1 100644 --- a/Complexitylib/SAT/QBF.lean +++ b/Complexitylib/SAT/QBF.lean @@ -3,10 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Data.Nat.Basic -import Mathlib.Data.Bool.Basic -import Mathlib.Logic.Function.Basic -import Mathlib.Data.Finset.Basic + +module +public import Mathlib.Data.Finset.SDiff +public import Std.Tactic.BVDecide.Normalize.Bool /-! # Quantified Boolean formulas @@ -28,6 +28,9 @@ ranges over the two Boolean values substituted for `x_i` via `Function.update`. the quantifiers, phrased as existence/universality over the substituted value -/ + +@[expose] public section + namespace Complexity /-- Quantified Boolean formulas over variables indexed by `ℕ`. -/ diff --git a/Complexitylib/SAT/Rename.lean b/Complexitylib/SAT/Rename.lean index 29bb9bf6..97bc896a 100644 --- a/Complexitylib/SAT/Rename.lean +++ b/Complexitylib/SAT/Rename.lean @@ -3,7 +3,9 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Semantics + +module +public import Complexitylib.SAT.Semantics /-! # Variable renaming and satisfiability transport @@ -27,6 +29,9 @@ machine actually emits (`docs/A5-ReductionEmitter.md`). preserves satisfiability -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Resolution.lean b/Complexitylib/SAT/Resolution.lean index 4e471d6a..bef82c5b 100644 --- a/Complexitylib/SAT/Resolution.lean +++ b/Complexitylib/SAT/Resolution.lean @@ -3,7 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Semantics + +module +public import Complexitylib.SAT.Semantics +public import Std.Tactic.BVDecide.Normalize.BitVec /-! # Resolution @@ -23,6 +26,9 @@ resolvent — is the semantic core underlying resolution proof systems. clause proves the formula unsatisfiable -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Semantics.lean b/Complexitylib/SAT/Semantics.lean index e8db8019..92417cc2 100644 --- a/Complexitylib/SAT/Semantics.lean +++ b/Complexitylib/SAT/Semantics.lean @@ -3,9 +3,14 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Mathlib.Data.List.Basic -import Mathlib.Data.Fintype.Pi -import Mathlib.Tactic.Linarith + +module +public import Mathlib.Data.Fintype.Pi +public import Mathlib.Data.Rat.Cast.Order +public import Mathlib.Tactic.NormNum.Abs +public import Mathlib.Tactic.NormNum.DivMod +public import Mathlib.Tactic.NormNum.OfScientific +public import Mathlib.Tactic.NormNum.Pow /-! # SAT: Semantic Layer @@ -39,6 +44,9 @@ exists, equal to a prefix of any longer one. This is essential for polynomial balance in the NP reduction. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/ThreeCNF.lean b/Complexitylib/SAT/ThreeCNF.lean index 015d2366..0c9ef545 100644 --- a/Complexitylib/SAT/ThreeCNF.lean +++ b/Complexitylib/SAT/ThreeCNF.lean @@ -3,7 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Rename + +module +public import Complexitylib.SAT.Rename +public import Std.Tactic.BVDecide.Normalize.Prop /-! # 3-CNF formulas @@ -25,6 +28,9 @@ turning an arbitrary CNF into an equisatisfiable 3-CNF — builds on this predic and is tracked separately. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/ThreeSAT.lean b/Complexitylib/SAT/ThreeSAT.lean index fd32c79b..78a5dd42 100644 --- a/Complexitylib/SAT/ThreeSAT.lean +++ b/Complexitylib/SAT/ThreeSAT.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.ThreeCNF -import Complexitylib.SAT.Verifier + +module +public import Complexitylib.SAT.ThreeCNF +public import Complexitylib.SAT.Verifier /-! # Encoded CNF-SAT and 3SAT languages @@ -23,6 +25,9 @@ reduction claim is made here. - `ThreeSAT.fallbackEncoding` — valid no-instance output for malformed inputs -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/ThreeSAT/Completeness.lean b/Complexitylib/SAT/ThreeSAT/Completeness.lean index 1ea6e059..6f10a94d 100644 --- a/Complexitylib/SAT/ThreeSAT/Completeness.lean +++ b/Complexitylib/SAT/ThreeSAT/Completeness.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.NP.Reduction -import Complexitylib.SAT.CookLevin.Assembly -import Complexitylib.SAT.ThreeSAT.Headline -import Complexitylib.SAT.Tseitin.Machine + +module +public import Complexitylib.Classes.NP.Reduction +public import Complexitylib.SAT.CookLevin.Assembly +public import Complexitylib.SAT.ThreeSAT.Headline +public import Complexitylib.SAT.Tseitin.Machine /-! # NP-completeness of 3SAT @@ -23,6 +25,9 @@ headline NP-completeness theorem. - `ThreeSAT.NPComplete_language` -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/ThreeSAT/Headline.lean b/Complexitylib/SAT/ThreeSAT/Headline.lean index 73359930..2d02294a 100644 --- a/Complexitylib/SAT/ThreeSAT/Headline.lean +++ b/Complexitylib/SAT/ThreeSAT/Headline.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Headline -import Complexitylib.SAT.Internal.LinearGuessVerify -import Complexitylib.SAT.ThreeSAT.Verifier -import Complexitylib.Classes.Containments + +module +public import Complexitylib.SAT.Headline +public import Complexitylib.SAT.Internal.LinearGuessVerify +public import Complexitylib.SAT.ThreeSAT.Verifier +public import Complexitylib.Classes.Containments /-! # 3SAT is in NP @@ -18,6 +20,9 @@ is in P. The generic linear-witness guess-and-verify construction then gives the headline theorem `ThreeSAT.language_mem_NP`. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/ThreeSAT/Syntax.lean b/Complexitylib/SAT/ThreeSAT/Syntax.lean index 6e7e242b..0bb36d17 100644 --- a/Complexitylib/SAT/ThreeSAT/Syntax.lean +++ b/Complexitylib/SAT/ThreeSAT/Syntax.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.ThreeSAT -import Complexitylib.Classes.P -import Complexitylib.Models.TuringMachine.Combinators.Internal.Scanner + +module +public import Complexitylib.SAT.ThreeSAT +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Scanner /-! # Regular syntax checker for exact 3-CNF encodings @@ -24,6 +25,9 @@ and makes the intended 3SAT decomposition explicit. - `ThreeSAT.language_eq_cnfsat_inter_syntax` -- semantic decomposition of 3SAT -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/ThreeSAT/Verifier.lean b/Complexitylib/SAT/ThreeSAT/Verifier.lean index 6f85ed7a..02388b4a 100644 --- a/Complexitylib/SAT/ThreeSAT/Verifier.lean +++ b/Complexitylib/SAT/ThreeSAT/Verifier.lean @@ -3,9 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.ThreeSAT.Syntax -import Complexitylib.Classes.Pairing -import Complexitylib.Models.TuringMachine.Combinators.Internal.Scanner + +module +public import Complexitylib.SAT.ThreeSAT.Syntax /-! # Exact-3 syntax on paired verifier inputs @@ -22,6 +22,9 @@ exact-3 syntax checker. - `ThreeSAT.PairSyntax.language_mem_P` -- the paired syntax language is in P -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin.lean b/Complexitylib/SAT/Tseitin.lean index ed634385..1f0fc196 100644 --- a/Complexitylib/SAT/Tseitin.lean +++ b/Complexitylib/SAT/Tseitin.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.ThreeSAT -import Complexitylib.SAT.Tseitin.Defs -import Complexitylib.SAT.Tseitin.Internal.Correctness -import Complexitylib.SAT.Tseitin.Internal.Size + +module +public import Complexitylib.SAT.ThreeSAT +public import Complexitylib.SAT.Tseitin.Defs +public import Complexitylib.SAT.Tseitin.Internal.Correctness +public import Complexitylib.SAT.Tseitin.Internal.Size /-! # Size-controlled reduction from CNF-SAT to 3SAT @@ -29,6 +31,9 @@ separate from this semantic layer. - `ThreeSAT.reduction_correct` — total encoded membership equivalence -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Defs.lean b/Complexitylib/SAT/Tseitin/Defs.lean index c60fb205..5db89b59 100644 --- a/Complexitylib/SAT/Tseitin/Defs.lean +++ b/Complexitylib/SAT/Tseitin/Defs.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.ThreeCNF + +module +public import Complexitylib.SAT.Semantics /-! # Tseitin splitting from CNF to exact 3-CNF @@ -21,6 +23,9 @@ Fresh counters are threaded across clauses, beginning above the largest source variable. Correctness and size theorems live in the internal and public layers. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Internal/Correctness.lean b/Complexitylib/SAT/Tseitin/Internal/Correctness.lean index b856abed..eb25c4c6 100644 --- a/Complexitylib/SAT/Tseitin/Internal/Correctness.lean +++ b/Complexitylib/SAT/Tseitin/Internal/Correctness.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Internal.FunctionSemantics -import Complexitylib.SAT.Tseitin.Internal.Shape + +module +public import Complexitylib.SAT.Tseitin.Internal.FunctionSemantics +public import Complexitylib.SAT.Tseitin.Internal.Shape /-! # Correctness of Tseitin clause splitting @@ -15,6 +17,9 @@ are chosen recursively while preserving all earlier variable values. The CNF proof threads those extensions across disjoint fresh ranges. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Internal/EncodingBounds.lean b/Complexitylib/SAT/Tseitin/Internal/EncodingBounds.lean index 8d150aa6..9d6553b7 100644 --- a/Complexitylib/SAT/Tseitin/Internal/EncodingBounds.lean +++ b/Complexitylib/SAT/Tseitin/Internal/EncodingBounds.lean @@ -3,8 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Encoding -import Complexitylib.SAT.Tseitin.Defs + +module +public import Complexitylib.SAT.Encoding +public import Complexitylib.SAT.Tseitin.Defs +public import Complexitylib.SAT.ThreeCNF /-! # Encoding-size support for Tseitin splitting @@ -14,6 +17,9 @@ unary-variable SAT bit encoding and bound exact-3 formulas whose variable indices share a common upper bound. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Internal/FunctionSemantics.lean b/Complexitylib/SAT/Tseitin/Internal/FunctionSemantics.lean index 9a1072f5..4e436e4b 100644 --- a/Complexitylib/SAT/Tseitin/Internal/FunctionSemantics.lean +++ b/Complexitylib/SAT/Tseitin/Internal/FunctionSemantics.lean @@ -3,7 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Defs + +module +public import Complexitylib.SAT.Tseitin.Defs +public import Complexitylib.SAT.Rename +public import Std.Tactic.BVDecide.Normalize.Bool /-! # Total-function semantics for Tseitin splitting @@ -19,6 +23,9 @@ satisfiability notions equivalent, and records the congruence and update lemmas by the recursive Tseitin correctness proof. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Internal/Shape.lean b/Complexitylib/SAT/Tseitin/Internal/Shape.lean index 42677bde..67c4ad58 100644 --- a/Complexitylib/SAT/Tseitin/Internal/Shape.lean +++ b/Complexitylib/SAT/Tseitin/Internal/Shape.lean @@ -3,7 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Defs + +module +public import Complexitylib.SAT.Tseitin.Defs +public import Complexitylib.SAT.ThreeCNF /-! # Structural properties of Tseitin clause splitting @@ -14,6 +17,9 @@ generated variable below the first unused counter, and has linear structural size in the source literal and clause counts. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Internal/Size.lean b/Complexitylib/SAT/Tseitin/Internal/Size.lean index 4ea617aa..a5c96f16 100644 --- a/Complexitylib/SAT/Tseitin/Internal/Size.lean +++ b/Complexitylib/SAT/Tseitin/Internal/Size.lean @@ -3,8 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Internal.EncodingBounds -import Complexitylib.SAT.Tseitin.Internal.Shape + +module +public import Complexitylib.SAT.Tseitin.Internal.EncodingBounds +public import Complexitylib.SAT.Tseitin.Internal.Shape +public import Mathlib.Tactic.Linarith.Frontend /-! # Size bounds for Tseitin splitting @@ -14,6 +17,9 @@ Because the concrete SAT codec writes variable indices in unary, newly allocated indices make the honest bit-level bound quadratic in the source encoding length. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Internal/StateBounds.lean b/Complexitylib/SAT/Tseitin/Internal/StateBounds.lean index 21997b16..c8eff119 100644 --- a/Complexitylib/SAT/Tseitin/Internal/StateBounds.lean +++ b/Complexitylib/SAT/Tseitin/Internal/StateBounds.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Internal.Streaming + +module +public import Complexitylib.SAT.Tseitin.Internal.Streaming /-! # Register bounds for the streaming Tseitin transformation @@ -15,6 +17,9 @@ consumed. The concrete reduction machine uses this invariant to select one uniform register-operation budget for its entire input scan. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Internal/Streaming.lean b/Complexitylib/SAT/Tseitin/Internal/Streaming.lean index 410ad59d..8c322800 100644 --- a/Complexitylib/SAT/Tseitin/Internal/Streaming.lean +++ b/Complexitylib/SAT/Tseitin/Internal/Streaming.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Defs -import Complexitylib.SAT.Verifier + +module +public import Complexitylib.SAT.Tseitin.Defs +public import Complexitylib.SAT.Verifier /-! # Streaming specification for the CNF-to-3CNF transformation @@ -23,6 +25,9 @@ variables are fresh. On a valid `CNF.tokens` stream, the emitted tokens and bits are exactly the encoding produced by `CNF.to3Aux` at that start value. -/ + +@[expose] public section + namespace Complexity namespace SAT @@ -72,7 +77,7 @@ def initial (next : ℕ) : State := { next, pending := .zero, scan := .boundary, emitted := [] } /-- The token encoding of one completed output clause. -/ -private def clauseTokens (c : Clause) : List EncToken := +def clauseTokens (c : Clause) : List EncToken := CNF.tokens [c] /-- Incorporate a decoded source literal. The first three literals are kept; diff --git a/Complexitylib/SAT/Tseitin/Internal/StreamingEndpoint.lean b/Complexitylib/SAT/Tseitin/Internal/StreamingEndpoint.lean index 4c957487..59d9299f 100644 --- a/Complexitylib/SAT/Tseitin/Internal/StreamingEndpoint.lean +++ b/Complexitylib/SAT/Tseitin/Internal/StreamingEndpoint.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Internal.Streaming + +module +public import Complexitylib.SAT.Tseitin.Internal.Streaming /-! # Successful streaming endpoints @@ -14,6 +16,9 @@ typed CNF token stream. The endpoint is recovered from the public `Internal.Streaming` remains the single source of truth. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine.lean b/Complexitylib/SAT/Tseitin/Machine.lean index 0f8c7c6f..8cbc14a8 100644 --- a/Complexitylib/SAT/Tseitin/Machine.lean +++ b/Complexitylib/SAT/Tseitin/Machine.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Classes.P.NormalForm -import Complexitylib.SAT.Tseitin.Machine.Controller -import Complexitylib.SAT.Tseitin.Machine.Internal.PolynomialTime + +module +public import Complexitylib.Classes.P.NormalForm +public import Complexitylib.SAT.Tseitin.Machine.Controller +public import Complexitylib.SAT.Tseitin.Machine.Internal.PolynomialTime /-! # Polynomial-time Tseitin reduction machine @@ -21,6 +23,9 @@ the fixed malformed-input fallback. - `ThreeSAT.reduction_mem_FP` -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Controller.lean b/Complexitylib/SAT/Tseitin/Machine/Controller.lean index 21522d31..fed66694 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Controller.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Controller.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Machine.Defs -import Mathlib.Data.Fintype.Sigma + +module +public import Complexitylib.SAT.Tseitin.Machine.Defs /-! # Streaming controller for the CNF-to-3CNF reduction machine @@ -30,6 +31,9 @@ accounting live in proof-only internal modules and are exposed publicly by `Complexitylib.SAT.Tseitin.Machine`. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Defs.lean b/Complexitylib/SAT/Tseitin/Machine/Defs.lean index 3eddfb4d..d8385dfe 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Defs.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Defs.lean @@ -3,9 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Lift -import Complexitylib.Models.TuringMachine.Registers.InputLen -import Complexitylib.SAT.ThreeSAT + +module +public import Complexitylib.Models.TuringMachine.Registers.InputLen +public import Complexitylib.SAT.ThreeSAT +public import Complexitylib.Models.TuringMachine.Registers.Arith +public import Complexitylib.Models.TuringMachine.Subroutines /-! # Machine building blocks for the CNF-to-3CNF reduction @@ -36,6 +39,9 @@ these machines. - `reductionTMWith` — validate first, then branch to an emitter or fallback -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Internal/BranchFrame.lean b/Complexitylib/SAT/Tseitin/Machine/Internal/BranchFrame.lean index c2573b01..ff1ab2c3 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Internal/BranchFrame.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Internal/BranchFrame.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Machine.Internal.FrontEndSpec + +module +public import Complexitylib.SAT.Tseitin.Machine.Internal.FrontEndSpec /-! # Shared branch frame for the Tseitin reduction machine @@ -22,6 +24,9 @@ work registers, validator verdict, tape well-formedness, and the standard - `validationFramedPost_to_branchPre_internal` -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Internal/BufferSpecs.lean b/Complexitylib/SAT/Tseitin/Machine/Internal/BufferSpecs.lean index 79b613d2..2f57acf3 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Internal/BufferSpecs.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Internal/BufferSpecs.lean @@ -3,9 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Experimental.EmitSpec -import Complexitylib.SAT.Tseitin.Machine.Defs -import Mathlib.Tactic.FinCases + +module +public import Complexitylib.Models.TuringMachine.Experimental.EmitSpec +public import Complexitylib.SAT.Tseitin.Machine.Defs /-! # Hoare specifications for Tseitin literal buffers and emitters @@ -31,6 +32,9 @@ stable under later polynomial rounding. - `closeClauseTM_hoareTime_internal` -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerCalls.lean b/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerCalls.lean index 01b1eb6d..979428be 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerCalls.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerCalls.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Machine.Internal.BufferSpecs -import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerLift + +module +public import Complexitylib.SAT.Tseitin.Machine.Internal.BufferSpecs +public import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerLift /-! # Completed child calls of the Tseitin streaming controller @@ -16,6 +18,9 @@ step, and exposes the resulting first-bit read state together with the exact buffer/output postcondition. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerInput.lean b/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerInput.lean index aa3ae067..69197426 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerInput.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerInput.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerRead -import Complexitylib.SAT.Tseitin.Machine.Internal.RuntimeBounds + +module +public import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerRead +public import Complexitylib.SAT.Tseitin.Machine.Internal.RuntimeBounds /-! # Input framing for the Tseitin streaming controller @@ -16,6 +18,9 @@ the next two cells with the next token and normalize the frame after those two cells have been consumed. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerInvariant.lean b/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerInvariant.lean index 694635f2..445215e0 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerInvariant.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerInvariant.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Internal.Streaming -import Complexitylib.SAT.Tseitin.Machine.Controller -import Complexitylib.SAT.Tseitin.Machine.Internal.BufferSpecs + +module +public import Complexitylib.SAT.Tseitin.Internal.Streaming +public import Complexitylib.SAT.Tseitin.Machine.Controller +public import Complexitylib.SAT.Tseitin.Machine.Internal.BufferSpecs /-! # Register invariant for the Tseitin streaming controller @@ -35,6 +37,9 @@ register-level Hoare specifications in `Machine.Internal.BufferSpecs`. - `StreamingStatePred` -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerLift.lean b/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerLift.lean index b40a2f55..3189b021 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerLift.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerLift.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.SAT.Tseitin.Machine.Controller + +module +public import Complexitylib.SAT.Tseitin.Machine.Controller /-! # Child-execution lifting for the Tseitin streaming controller @@ -32,6 +33,9 @@ No token semantics are proved here. - `validEmitterTM_close_return_step_internal` -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerRead.lean b/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerRead.lean index 251bb039..16d648ca 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerRead.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerRead.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerLift + +module +public import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerLift /-! # Concrete read paths for the Tseitin streaming controller @@ -25,6 +27,9 @@ semantics remain separate layers. - `validEmitterTM_read_blank_reachesIn_internal` -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerRun.lean b/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerRun.lean index fb0a87c4..8fc2ef5e 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerRun.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerRun.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerInput -import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerToken + +module +public import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerInput +public import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerToken /-! # Run simulation for the Tseitin streaming controller @@ -26,6 +28,9 @@ to the next layer. - `validEmitterTM_streaming_run_internal` -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerSemantics.lean b/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerSemantics.lean index 4d8eb543..e23dd3b5 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerSemantics.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerSemantics.lean @@ -3,8 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerInvariant -import Complexitylib.SAT.Tseitin.Machine.Internal.RuntimeBounds + +module +public import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerInvariant /-! # Semantic glue for the streaming Tseitin controller @@ -26,6 +27,9 @@ The results are definitional seams used by the later controller induction. - `pendingBits_eq_closeClause_emitted_internal` -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerToken.lean b/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerToken.lean index 4a5cb8b0..6e27e5a2 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerToken.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Internal/ControllerToken.lean @@ -3,10 +3,12 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerCalls -import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerRead -import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerSemantics -import Complexitylib.SAT.Tseitin.Machine.Internal.RuntimeBounds + +module +public import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerCalls +public import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerRead +public import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerSemantics +public import Complexitylib.SAT.Tseitin.Machine.Internal.RuntimeBounds /-! # One-token simulation for the Tseitin streaming controller @@ -26,6 +28,9 @@ later induction over `Streaming.run` can instantiate it directly. - `validEmitterTM_streaming_step_internal` -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Internal/EmitterSpec.lean b/Complexitylib/SAT/Tseitin/Machine/Internal/EmitterSpec.lean index 1904b50c..bb373859 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Internal/EmitterSpec.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Internal/EmitterSpec.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Internal.StreamingEndpoint -import Complexitylib.SAT.Tseitin.Machine.Internal.BranchFrame -import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerRun + +module +public import Complexitylib.SAT.Tseitin.Internal.StreamingEndpoint +public import Complexitylib.SAT.Tseitin.Machine.Internal.BranchFrame +public import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerRun /-! # Typed-input specification for the Tseitin valid emitter @@ -27,6 +29,9 @@ rounds it to the library's explicit quartic envelope. - `validEmitterTM_hoareTime_quartic_internal` -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Internal/Execution.lean b/Complexitylib/SAT/Tseitin/Machine/Internal/Execution.lean index c407bd0f..2558709e 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Internal/Execution.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Internal/Execution.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.SAT.Tseitin.Machine.Internal.ValidationFramed + +module +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic +public import Complexitylib.SAT.Tseitin.Machine.Internal.ValidationFramed /-! # Execution of the Tseitin syntax-validation machine @@ -24,6 +26,9 @@ started execution theorem. - `validationTM_hoareTime_internal` — compositional `HoareTime` interface -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Internal/FrontEndSpec.lean b/Complexitylib/SAT/Tseitin/Machine/Internal/FrontEndSpec.lean index 39f39125..7902876c 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Internal/FrontEndSpec.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Internal/FrontEndSpec.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Machine.Internal.Setup -import Complexitylib.SAT.Tseitin.Machine.Internal.ValidationFramed + +module +public import Complexitylib.SAT.Tseitin.Machine.Internal.Setup +public import Complexitylib.SAT.Tseitin.Machine.Internal.ValidationFramed /-! # Hoare specification for the Tseitin reduction front end @@ -29,6 +31,9 @@ The resulting postcondition records all state needed by the branch assembly: `13(|z| + 1)` -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Internal/InvalidBranchSpec.lean b/Complexitylib/SAT/Tseitin/Machine/Internal/InvalidBranchSpec.lean index 4dfac22f..7923f48d 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Internal/InvalidBranchSpec.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Internal/InvalidBranchSpec.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Machine.Internal.BranchFrame + +module +public import Complexitylib.SAT.Tseitin.Machine.Internal.BranchFrame /-! # Invalid-input branch of the Tseitin reduction machine @@ -23,6 +25,9 @@ time bound are completely independent of the supplied `validEmitter`. - `reductionTMWith_invalid_reachesIn_internal` -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Internal/PolynomialTime.lean b/Complexitylib/SAT/Tseitin/Machine/Internal/PolynomialTime.lean index 6898a541..39c1b950 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Internal/PolynomialTime.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Internal/PolynomialTime.lean @@ -3,12 +3,13 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Asymptotics -import Complexitylib.SAT.Tseitin -import Complexitylib.SAT.Tseitin.Machine.Internal.EmitterSpec -import Complexitylib.SAT.Tseitin.Machine.Internal.InvalidBranchSpec -import Complexitylib.SAT.Tseitin.Machine.Internal.ValidBranchAssembly -import Complexitylib.SAT.Tseitin.Machine.Internal.Validation + +module +public import Complexitylib.SAT.Tseitin +public import Complexitylib.SAT.Tseitin.Machine.Internal.EmitterSpec +public import Complexitylib.SAT.Tseitin.Machine.Internal.InvalidBranchSpec +public import Complexitylib.SAT.Tseitin.Machine.Internal.ValidBranchAssembly +public import Complexitylib.SAT.Tseitin.Machine.Internal.Validation /-! # Polynomial-time correctness of the Tseitin reduction machine @@ -26,6 +27,9 @@ bit length. - `reductionTM_computesInTime_internal` -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Internal/RuntimeBounds.lean b/Complexitylib/SAT/Tseitin/Machine/Internal/RuntimeBounds.lean index d78f58f9..46a08e59 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Internal/RuntimeBounds.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Internal/RuntimeBounds.lean @@ -3,9 +3,11 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Registers.Horner -import Complexitylib.SAT.Tseitin.Internal.StateBounds -import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerInvariant + +module +public import Complexitylib.Models.TuringMachine.Registers.Horner +public import Complexitylib.SAT.Tseitin.Internal.StateBounds +public import Complexitylib.SAT.Tseitin.Machine.Internal.ControllerInvariant /-! # Coarse runtime bounds for the streaming Tseitin controller @@ -28,6 +30,9 @@ overhead. The complete token pass is bounded by an explicit quartic. - `typed_controllerRun_le_quartic_internal` -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Internal/Setup.lean b/Complexitylib/SAT/Tseitin/Machine/Internal/Setup.lean index 01f886dc..fcd7cf00 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Internal/Setup.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Internal/Setup.lean @@ -3,8 +3,10 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine.Subroutines.Internal -import Complexitylib.SAT.Tseitin.Machine.Defs + +module +public import Complexitylib.Models.TuringMachine.Subroutines.Internal +public import Complexitylib.SAT.Tseitin.Machine.Defs /-! # Setup specifications for the Tseitin reduction machine @@ -25,6 +27,9 @@ are preserved. - `fallbackEmitter_hoareTime_internal` — emit the fixed fallback from a clear output -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Internal/ValidBranchAssembly.lean b/Complexitylib/SAT/Tseitin/Machine/Internal/ValidBranchAssembly.lean index 42fa43c9..e690dde6 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Internal/ValidBranchAssembly.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Internal/ValidBranchAssembly.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Machine.Internal.BranchFrame + +module +public import Complexitylib.SAT.Tseitin.Machine.Internal.BranchFrame /-! # Valid-input assembly for the Tseitin reduction machine @@ -24,6 +26,9 @@ which is exactly the final transition performed by `ifTM`. - `reductionTMWith_valid_emit_reachesIn_internal` -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Internal/Validation.lean b/Complexitylib/SAT/Tseitin/Machine/Internal/Validation.lean index 1351d266..5382e191 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Internal/Validation.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Internal/Validation.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Machine.Defs + +module +public import Complexitylib.SAT.Tseitin.Machine.Defs /-! # Correctness of the pure Tseitin input validator @@ -15,6 +17,9 @@ streams, then transports that characterization across the concrete two-bit tokenization. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Internal/ValidationFramed.lean b/Complexitylib/SAT/Tseitin/Machine/Internal/ValidationFramed.lean index f417fc08..15bb5aca 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Internal/ValidationFramed.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Internal/ValidationFramed.lean @@ -3,7 +3,9 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin.Machine.Defs + +module +public import Complexitylib.SAT.Tseitin.Machine.Defs /-! # Framed execution of the Tseitin syntax validator @@ -21,6 +23,9 @@ its Boolean verdict, for a total of `|z| + 1` steps. - `validationTM_started_framed_hoareTime_internal` -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Tseitin/Machine/Validation.lean b/Complexitylib/SAT/Tseitin/Machine/Validation.lean index 8bace7c6..02fc79b0 100644 --- a/Complexitylib/SAT/Tseitin/Machine/Validation.lean +++ b/Complexitylib/SAT/Tseitin/Machine/Validation.lean @@ -3,12 +3,20 @@ Copyright (c) 2026 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Tseitin -import Complexitylib.SAT.Tseitin.Internal.Streaming -import Complexitylib.SAT.Tseitin.Machine.Controller -import Complexitylib.SAT.Tseitin.Machine.Internal.Execution -import Complexitylib.SAT.Tseitin.Machine.Internal.PolynomialTime -import Complexitylib.SAT.Tseitin.Machine.Internal.Validation + +module +public import Complexitylib.SAT.Tseitin +public meta import Complexitylib.SAT.Tseitin +public import Complexitylib.SAT.Tseitin.Internal.Streaming +public meta import Complexitylib.SAT.Tseitin.Internal.Streaming +public import Complexitylib.SAT.Tseitin.Machine.Controller +public meta import Complexitylib.SAT.Tseitin.Machine.Controller +public import Complexitylib.SAT.Tseitin.Machine.Internal.Execution +public meta import Complexitylib.SAT.Tseitin.Machine.Internal.Execution +public import Complexitylib.SAT.Tseitin.Machine.Internal.PolynomialTime +public meta import Complexitylib.SAT.Tseitin.Machine.Internal.PolynomialTime +public import Complexitylib.SAT.Tseitin.Machine.Internal.Validation +public meta import Complexitylib.SAT.Tseitin.Machine.Internal.Validation /-! # Executable validation for the Tseitin reduction front end @@ -28,6 +36,9 @@ to the executable guards, its imported proof layer establishes: within one explicit quartic bound. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/Verifier.lean b/Complexitylib/SAT/Verifier.lean index 7af8461b..fec4d109 100644 --- a/Complexitylib/SAT/Verifier.lean +++ b/Complexitylib/SAT/Verifier.lean @@ -3,7 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Language + +module +public import Complexitylib.SAT.Language +public import Std.Tactic.BVDecide.Normalize.BitVec /-! # SAT verifier specification @@ -20,6 +23,9 @@ computes this specification and proves `pairLang Witness ∈ P`; this file is the small executable/semantic audit surface for that machine proof. -/ + +@[expose] public section + namespace Complexity namespace SAT diff --git a/Complexitylib/SAT/VerifierTM.lean b/Complexitylib/SAT/VerifierTM.lean index 4466ddc5..2563a5b5 100644 --- a/Complexitylib/SAT/VerifierTM.lean +++ b/Complexitylib/SAT/VerifierTM.lean @@ -3,15 +3,11 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.SAT.Verifier -import Complexitylib.Models.TuringMachine.Subroutines.PairSplit -import Complexitylib.Models.TuringMachine.Subroutines.Counter -import Complexitylib.Models.TuringMachine.Combinators -import Complexitylib.Models.TuringMachine.Combinators.Internal.Retarget -import Complexitylib.Models.TuringMachine.Combinators.Internal.Generic -import Complexitylib.Models.TuringMachine.Hoare -import Complexitylib.Models.TuringMachine.Hoare.Defs -import Complexitylib.Models.TuringMachine.Tape.Encoding + +module +public import Complexitylib.SAT.Verifier +public import Complexitylib.Models.TuringMachine.Subroutines.Counter +public import Complexitylib.Models.TuringMachine.Combinators.Internal.Retarget /-! # SAT verifier TMs @@ -36,6 +32,9 @@ paired witness language underlying `SAT.language ∈ NP` — is characterized both semantically and at the machine level. -/ + +@[expose] public section + namespace Complexity namespace SAT @@ -1290,18 +1289,22 @@ instance : Fintype SatEvalPhase where | rewindAlpha mode => simp -private def boolWrite (b : Bool) : Γw := +/-- Writable tape symbol encoding of a Boolean. -/ +def boolWrite (b : Bool) : Γw := if b then Γw.one else Γw.zero -private def readBit? : Γ → Option Bool +/-- Decodes a tape symbol as a bit when it is `0` or `1`. -/ +def readBit? : Γ → Option Bool | Γ.zero => some false | Γ.one => some true | _ => none -private def assignmentBitAtHead (g : Γ) : Bool := +/-- Assignment value represented by the symbol under the assignment-tape head. -/ +def assignmentBitAtHead (g : Γ) : Bool := g = Γ.one -private def literalValueAtHead (sign : Bool) (g : Γ) : Bool := +/-- Truth value of a signed literal at the assignment-tape head. -/ +def literalValueAtHead (sign : Bool) (g : Γ) : Bool := assignmentBitAtHead g == sign private theorem assignmentBitAtHead_initTape_eq_get (α : Assignment) (var : ℕ) : @@ -1321,17 +1324,20 @@ private theorem literalValueAtHead_initTape_eq_litEval (Assignment.get α var == sign) := by simp [literalValueAtHead, assignmentBitAtHead_initTape_eq_get] -private def finishEvalMode : SatEvalMode → Γw +/-- Output written when the evaluator reaches the end of the encoded formula. -/ +def finishEvalMode : SatEvalMode → Γw | .boundary cnf _clause empty => boolWrite (cnf && empty) | .inLit .. => Γw.zero -private def satEvalReject {n : ℕ} (state : SatEvalPhase) +/-- Rejecting transition that preserves the current tape contents. -/ +def satEvalReject {n : ℕ} (state : SatEvalPhase) (iHead : Γ) (wHeads : Fin n → Γ) (oHead : Γ) : SatEvalPhase × (Fin n → Γw) × Γw × Dir3 × (Fin n → Dir3) × Dir3 := (state, fun i => TM.readBackWrite (wHeads i), Γw.zero, TM.idleDir iHead, fun i => TM.idleDir (wHeads i), TM.idleDir oHead) -private def satEvalTokenStep (mode : SatEvalMode) (tok : EncToken) (αHead : Γ) : +/-- Pure evaluator-state transition for one decoded encoding token. -/ +def satEvalTokenStep (mode : SatEvalMode) (tok : EncToken) (αHead : Γ) : SatEvalPhase × Dir3 × Γw := match mode with | .boundary cnf clause empty => @@ -1352,14 +1358,16 @@ private def satEvalTokenStep (mode : SatEvalMode) (tok : EncToken) (αHead : Γ) | .clauseSep => (.done, Dir3.stay, Γw.zero) -private def tokenOfBits (first second : Bool) : EncToken := +/-- Decodes the fixed two-bit representation of an encoding token. -/ +def tokenOfBits (first second : Bool) : EncToken := match first, second with | false, false => .bit false | true, true => .bit true | false, true => .litSep | true, false => .clauseSep -private def satEvalDelta : +/-- Transition function of the one-work-tape SAT evaluator. -/ +def satEvalDelta : SatEvalPhase → Γ → (Fin 1 → Γ) → Γ → SatEvalPhase × (Fin 1 → Γw) × Γw × Dir3 × (Fin 1 → Dir3) × Dir3 := fun state iHead wHeads oHead => @@ -2680,41 +2688,48 @@ instance : Fintype VerifyPairPhase where intro q cases q <;> simp -private def verifyPairReject (iHead : Γ) (wHeads : Fin 3 → Γ) (oHead : Γ) : +/-- Rejecting transition for the paired-formula verifier. -/ +def verifyPairReject (iHead : Γ) (wHeads : Fin 3 → Γ) (oHead : Γ) : VerifyPairPhase × (Fin 3 → Γw) × Γw × Dir3 × (Fin 3 → Dir3) × Dir3 := (.done, fun i => TM.readBackWrite (wHeads i), Γw.zero, TM.idleDir iHead, fun i => TM.idleDir (wHeads i), TM.idleDir oHead) -private def verifyPairPreserveWork (wHeads : Fin 3 → Γ) : Fin 3 → Γw := +/-- Rewrites every paired-verifier work symbol without changing its value. -/ +def verifyPairPreserveWork (wHeads : Fin 3 → Γ) : Fin 3 → Γw := fun i => TM.readBackWrite (wHeads i) -private def verifyPairSplitWrite (zBit : Bool) (wHeads : Fin 3 → Γ) : Fin 3 → Γw := +/-- Work-tape writes while splitting the formula and assignment encodings. -/ +def verifyPairSplitWrite (zBit : Bool) (wHeads : Fin 3 → Γ) : Fin 3 → Γw := fun i => if i = ⟨0, by omega⟩ then boolWrite zBit else if i = ⟨2, by omega⟩ then Γw.one else TM.readBackWrite (wHeads i) -private def verifyPairSplitDirs (wHeads : Fin 3 → Γ) : Fin 3 → Dir3 := +/-- Work-tape head directions while splitting the paired encoding. -/ +def verifyPairSplitDirs (wHeads : Fin 3 → Γ) : Fin 3 → Dir3 := fun i => if i = ⟨0, by omega⟩ then Dir3.right else if i = ⟨2, by omega⟩ then Dir3.right else TM.idleDir (wHeads i) -private def verifyPairCopyAlphaWrite (aBit : Bool) (wHeads : Fin 3 → Γ) : +/-- Work-tape writes while copying the assignment component. -/ +def verifyPairCopyAlphaWrite (aBit : Bool) (wHeads : Fin 3 → Γ) : Fin 3 → Γw := fun i => if i = ⟨1, by omega⟩ then boolWrite aBit else if i = ⟨2, by omega⟩ then Γw.blank else TM.readBackWrite (wHeads i) -private def verifyPairCopyAlphaDirs (wHeads : Fin 3 → Γ) : Fin 3 → Dir3 := +/-- Work-tape head directions while copying the assignment component. -/ +def verifyPairCopyAlphaDirs (wHeads : Fin 3 → Γ) : Fin 3 → Dir3 := fun i => if i = ⟨1, by omega⟩ then Dir3.right else if i = ⟨2, by omega⟩ then Dir3.right else TM.idleDir (wHeads i) -private def verifyPairEvalDirs (αHead : Γ) (αDir : Dir3) (wHeads : Fin 3 → Γ) : +/-- Work-tape directions induced by one evaluator step. -/ +def verifyPairEvalDirs (αHead : Γ) (αDir : Dir3) (wHeads : Fin 3 → Γ) : Fin 3 → Dir3 := fun i => if i = ⟨0, by omega⟩ then Dir3.right @@ -2723,7 +2738,8 @@ private def verifyPairEvalDirs (αHead : Γ) (αDir : Dir3) (wHeads : Fin 3 → else TM.idleDir (wHeads i) -private def verifyPairDelta : +/-- Transition function for verifying a paired formula-and-assignment encoding. -/ +def verifyPairDelta : VerifyPairPhase → Γ → (Fin 3 → Γ) → Γ → VerifyPairPhase × (Fin 3 → Γw) × Γw × Dir3 × (Fin 3 → Dir3) × Dir3 := fun state iHead wHeads oHead => diff --git a/Complexitylib/TimeConstructible.lean b/Complexitylib/TimeConstructible.lean index 444e55fa..2ff7051b 100644 --- a/Complexitylib/TimeConstructible.lean +++ b/Complexitylib/TimeConstructible.lean @@ -3,9 +3,10 @@ Copyright (c) 2025 Samuel Schlesinger. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Samuel Schlesinger -/ -import Complexitylib.Models.TuringMachine -import Complexitylib.Asymptotics -import Mathlib.Data.Nat.Bits + +module +public import Complexitylib.Models.TuringMachine +public import Complexitylib.Asymptotics /-! # Time-constructible functions @@ -31,6 +32,9 @@ time-constructible. - `TimeConstructible.computable` — extract the witnessing TM and time bound -/ + +@[expose] public section + namespace Complexity diff --git a/scripts/migrate_modules.py b/scripts/migrate_modules.py new file mode 100644 index 00000000..d6ef9518 --- /dev/null +++ b/scripts/migrate_modules.py @@ -0,0 +1,434 @@ +#!/usr/bin/env python3 +"""Drive and validate Complexitylib's Lean module-system migration. + +This script is intentionally narrow: it updates the library sources, not the +standalone axiom-audit script. The compatibility phase preserves declarations +that refer to private helpers in the same file. After that compatibility build, +`lake shake` minimizes the migrated import graph before the temporary bridge is +removed: + +Usage: + python3 scripts/migrate_modules.py + python3 scripts/migrate_modules.py --compat + python3 scripts/migrate_modules.py --strict + python3 scripts/migrate_modules.py --run + python3 scripts/migrate_modules.py --check + python3 scripts/migrate_modules.py --validate + +On an unmigrated tree, `--run` checks the legacy build, applies the compatibility +migration, builds the module graph, minimizes imports, removes the compatibility +options, and runs every required project gate. On an already migrated tree it +is an idempotent strict validation run. +""" + +import argparse +import re +import subprocess +import sys +from pathlib import Path + + +ROOT = Path(__file__).resolve().parent.parent +LIBRARY = ROOT / "Complexitylib" +ROOT_MODULE = ROOT / "Complexitylib.lean" + +COPYRIGHT_RE = re.compile( + r"\A/-\n" + r"Copyright \(c\) \d{4} .*\. All rights reserved\.\n" + r"Released under Apache 2\.0 license as described in the file LICENSE\.\n" + r"Authors: .*\n" + r"-/\n" +) +MODULE_RE = re.compile(r"^module(?:\s+--.*)?$", re.MULTILINE) +LEGACY_IMPORT_RE = re.compile( + r"^(?Pmeta\s+)?import(?!\s+all)(?=\s)", + re.MULTILINE, +) +EXPOSE_SECTION = "@[expose] public section" +PRIVATE_IN_PUBLIC = "set_option backward.privateInPublic true" +PRIVATE_IN_PUBLIC_WARN = "set_option backward.privateInPublic.warn false" +VALIDATION_MODULES = [ + "Complexitylib.Models.TuringMachine.SingleTape.Validation", + "Complexitylib.Models.TuringMachine.Repetition.Validation", + "Complexitylib.Circuits.Encoding.Validation", + "Complexitylib.SAT.Tseitin.Machine.Validation", +] + + +def library_files() -> list[Path]: + """Return every source file belonging to the public Lean library.""" + return [ROOT_MODULE, *sorted(LIBRARY.rglob("*.lean"))] + + +def block_comment_end(text: str, start: int) -> int: + """Return the byte after a possibly nested Lean block comment.""" + depth = 0 + cursor = start + while cursor < len(text): + if text.startswith("/-", cursor): + depth += 1 + cursor += 2 + elif text.startswith("-/", cursor): + depth -= 1 + cursor += 2 + if depth == 0: + return cursor + else: + cursor += 1 + raise ValueError("unterminated block comment") + + +def canonical_imports(header: str) -> str: + """Canonicalize imports without discarding pre-docstring commands.""" + lines = header.splitlines() + module_line = next( + index + for index, line in enumerate(lines) + if MODULE_RE.fullmatch(line) + ) + imports: list[tuple[bool, bool, bool, str]] = [] + seen = set() + final_import_line = module_line + cursor = module_line + 1 + while cursor < len(lines): + stripped = lines[cursor].strip() + public = False + meta = False + import_all = False + imported = None + if stripped.startswith(("public import", "public meta import", "import", "meta import")): + tokens = stripped.split() + if "import" in tokens: + import_index = tokens.index("import") + public = "public" in tokens[:import_index] + meta = "meta" in tokens[:import_index] + remainder = tokens[import_index + 1 :] + if remainder and remainder[0] == "all": + import_all = True + remainder = remainder[1:] + if remainder: + imported = remainder[0] + elif cursor + 1 < len(lines): + continuation = lines[cursor + 1].strip() + if continuation and continuation[0].isupper(): + imported = continuation + cursor += 1 + + if imported is not None: + imported = imported.split("--", 1)[0].strip() + key = (public, meta, import_all, imported) + if key not in seen: + imports.append(key) + seen.add(key) + final_import_line = cursor + cursor += 1 + + rebuilt = lines[: module_line + 1] + for public, meta, import_all, imported in imports: + public_prefix = "public " if public else "" + meta_prefix = "meta " if meta else "" + all_suffix = " all" if import_all else "" + import_command = f"{public_prefix}{meta_prefix}import{all_suffix}" + import_line = f"{import_command} {imported}" + if len(import_line) <= 100: + rebuilt.append(import_line) + else: + indent = " " if len(imported) + 2 <= 100 else "" + rebuilt.extend([import_command, f"{indent}{imported}"]) + + suffix = lines[final_import_line + 1 :] + while suffix and not suffix[0].strip(): + suffix.pop(0) + while suffix and not suffix[-1].strip(): + suffix.pop() + if suffix: + rebuilt.extend(["", *suffix]) + return "\n".join(rebuilt) + "\n\n" + + +def add_compatibility(text: str) -> str: + """Allow public declarations to use private helpers from their own file.""" + module_doc = text.find("/-!") + text = canonical_imports(text[:module_doc]) + text[module_doc:] + if PRIVATE_IN_PUBLIC not in text: + module_doc = text.find("/-!") + module_doc_end = block_comment_end(text, module_doc) + options = f"\n\n{PRIVATE_IN_PUBLIC}\n{PRIVATE_IN_PUBLIC_WARN}" + text = text[:module_doc_end] + options + text[module_doc_end:] + return text + + +def remove_compatibility(text: str) -> str: + """Remove the temporary private-in-public migration bridge.""" + lines = text.splitlines() + lines = [ + line + for line in lines + if line not in {PRIVATE_IN_PUBLIC, PRIVATE_IN_PUBLIC_WARN} + ] + return "\n".join(lines) + "\n" + + +def place_expose_section(text: str) -> str: + """Place the public section outside any namespace opened before the doc.""" + module_doc = text.find("/-!") + if module_doc < 0: + raise ValueError("missing module docstring") + scope = re.search(r"^(?:namespace|section)(?:\s|$)", text[:module_doc], re.MULTILINE) + marker = text.find(EXPOSE_SECTION) + + if marker >= 0 and scope is not None and marker > scope.start(): + line_start = text.rfind("\n", 0, marker) + 1 + line_end = text.find("\n", marker) + if line_end < 0: + line_end = len(text) + else: + line_end += 1 + text = text[:line_start] + text[line_end:] + module_doc = text.find("/-!") + scope = re.search( + r"^(?:namespace|section)(?:\s|$)", + text[:module_doc], + re.MULTILINE, + ) + marker = -1 + + if marker < 0: + if scope is not None: + text = ( + text[: scope.start()] + + f"{EXPOSE_SECTION}\n\n" + + text[scope.start() :] + ) + else: + doc_end = block_comment_end(text, module_doc) + if text[doc_end:].strip(): + text = text[:doc_end] + f"\n\n{EXPOSE_SECTION}" + text[doc_end:] + return text + + +def migrate( + path: Path, + compatibility: bool = False, + strict: bool = False, +) -> str: + """Return the compatibility-first module-system form of `path`.""" + text = path.read_text(encoding="utf-8") + header = COPYRIGHT_RE.match(text) + if header is None: + raise ValueError("missing canonical copyright header") + + was_module = MODULE_RE.search(text) is not None + if not was_module: + text = text[: header.end()] + "\nmodule\n" + text[header.end() :] + + module_doc = text.find("/-!") + if not was_module: + text = ( + LEGACY_IMPORT_RE.sub( + lambda match: f"public {match.group('meta') or ''}import", + text[:module_doc], + ) + + text[module_doc:] + ) + + text = place_expose_section(text) + + if compatibility: + module_doc = text.find("/-!") + doc_end = block_comment_end(text, module_doc) + if text[doc_end:].strip(): + text = add_compatibility(text) + else: + text = canonical_imports(text[:module_doc]) + text[module_doc:] + + if strict: + text = remove_compatibility(text) + + return text + + +def violations( + path: Path, + text: str, + compatibility: bool = False, + strict: bool = False, +) -> list[str]: + """Return module-system migration invariants violated by `text`.""" + found = [] + if MODULE_RE.search(text) is None: + found.append("missing module header") + module_doc = text.find("/-!") + if module_doc < 0: + found.append("missing module docstring") + else: + doc_end = block_comment_end(text, module_doc) + has_declarations = bool(text[doc_end:].strip()) + if has_declarations and EXPOSE_SECTION not in text: + found.append("declarations are not in an exposed public section") + if compatibility and has_declarations: + if PRIVATE_IN_PUBLIC not in text or PRIVATE_IN_PUBLIC_WARN not in text: + found.append("missing private-in-public compatibility options") + if compatibility and module_doc >= 0 and has_declarations: + if re.search( + r"^public\s+(?:meta\s+)?import\s+all(?:\s|$)", + text[:module_doc], + re.MULTILINE, + ): + found.append("invalid combined `public import all`") + if strict and ( + PRIVATE_IN_PUBLIC in text or PRIVATE_IN_PUBLIC_WARN in text + ): + found.append("temporary private-in-public compatibility option remains") + return found + + +def update_sources( + compatibility: bool, + strict: bool = False, +) -> tuple[int, list[str]]: + """Update all library files and return `(changed, errors)`.""" + changed = 0 + errors = [] + for path in library_files(): + try: + old = path.read_text(encoding="utf-8") + new = migrate(path, compatibility, strict) + if new != old: + path.write_text(new, encoding="utf-8") + changed += 1 + for violation in violations(path, new, compatibility, strict): + errors.append(f"{path.relative_to(ROOT)}: {violation}") + except ValueError as error: + errors.append(f"{path.relative_to(ROOT)}: {error}") + return changed, errors + + +def run(command: list[str]) -> None: + """Run one migration phase from the repository root.""" + print(f"+ {' '.join(command)}", flush=True) + subprocess.run(command, cwd=ROOT, check=True) + + +def run_validation(include_full_build: bool = True) -> None: + """Run every build, lint, and axiom gate required by AGENTS.md.""" + if include_full_build: + run(["lake", "build", "--wfail"]) + for module in VALIDATION_MODULES: + run(["lake", "build", "--wfail", module]) + run([sys.executable, "scripts/lint_style.py"]) + run(["lake", "exe", "runLinter", "Complexitylib", *VALIDATION_MODULES]) + run(["lake", "env", "lean", "scripts/AxiomGuard.lean"]) + + +def main() -> int: + parser = argparse.ArgumentParser() + mode = parser.add_mutually_exclusive_group() + mode.add_argument( + "--check", + action="store_true", + help="verify the migration invariants without editing files", + ) + mode.add_argument( + "--compat", + action="store_true", + help="also restore legacy visibility for the first complete build", + ) + mode.add_argument( + "--strict", + action="store_true", + help="remove temporary private-in-public compatibility options", + ) + mode.add_argument( + "--run", + action="store_true", + help="migrate when needed, then run every required project gate", + ) + mode.add_argument( + "--validate", + action="store_true", + help="run every required project gate without editing sources", + ) + args = parser.parse_args() + + needs_migration = any( + MODULE_RE.search(path.read_text(encoding="utf-8")) is None + for path in library_files() + ) + compatibility = args.compat or (args.run and needs_migration) + if args.run and needs_migration: + try: + run(["lake", "build", "--wfail"]) + except subprocess.CalledProcessError as error: + print( + "module migration: the pre-migration build must pass before " + "dependencies can be recovered", + file=sys.stderr, + ) + return error.returncode + + if args.validate: + try: + run_validation() + except subprocess.CalledProcessError as error: + print( + f"module migration: command failed with exit code {error.returncode}", + file=sys.stderr, + ) + return error.returncode + return 0 + + if args.check: + changed = 0 + errors = [] + for path in library_files(): + current = path.read_text(encoding="utf-8") + try: + for violation in violations(path, current, strict=True): + errors.append(f"{path.relative_to(ROOT)}: {violation}") + except ValueError as error: + errors.append(f"{path.relative_to(ROOT)}: {error}") + else: + changed, errors = update_sources(compatibility, args.strict) + + for error in errors: + print(f"module migration: {error}") + if errors: + print(f"module migration: FAILED ({len(errors)} violation(s))") + return 1 + + if args.check: + print(f"module migration: OK ({len(library_files())} modules)") + else: + print(f"module migration: updated {changed}/{len(library_files())} files") + + if args.run: + try: + if needs_migration: + run(["lake", "build", "--wfail"]) + run(["lake", "shake", "--fix", "--add-public"]) + changed, errors = update_sources( + compatibility=False, + strict=True, + ) + print( + f"module migration: strictified " + f"{changed}/{len(library_files())} files" + ) + if errors: + for error in errors: + print(f"module migration: {error}") + return 1 + run(["lake", "build", "--wfail"]) + run_validation(include_full_build=False) + except subprocess.CalledProcessError as error: + print( + f"module migration: command failed with exit code {error.returncode}", + file=sys.stderr, + ) + return error.returncode + return 0 + + +if __name__ == "__main__": + sys.exit(main())