Formally verifying FactorForge's discrete dynamic programming model in Lean 4
Complete mathematical blueprint, locked Lean 4.36.0 specifications, inductive proof sketches, 12-state BsaI constructive trace, and sampled Python correspondence for FactorForge's discrete integer DP core.
Constraint-aware coding-sequence (CDS) optimization selects synonymous codons preserving a target protein while avoiding forbidden motifs across flanks and inter-codon junctions, satisfying global nucleotide GC bounds, and maximizing an additive codon-fitness objective. Finite unit suites test sampled inputs, whereas informal or unconstrained AI-generated proofs risk silent specification weakening unless checked by an independent proof kernel. Here we present the full mathematical blueprint of FactorForgeFormal, a zero-dependency Lean 4.36.0 formalization (14 modules, >2,500 lines, 0 sorry, verified transitively via leanchecker) proving 20 core theorems, 3 helper lemmas, and 14 concrete witnesses across Tropical max-plus algebra, construct-level DFA safety, the 64-triplet Standard Genetic Code (ValidCodonForAA), constructive backtracking DP optimality (dpOptimizeEndToEnd), exact rational pause-ramp interpolation (ExactRat), and conditional integer perturbation margins - alongside a fail-closed Python correspondence and 8/8 reference-copy mutation suite.
Module & Theorem Dependency Graph (FactorForgeFormal, 14 Modules, 0 sorry)
FactorForgeFormal. Arrows point from foundational specifications and lemmas to dependent theorems, culminating in constructive solver verification (dpOptimizeEndToEnd), concrete BsaI automaton instantiation (Witnesses.lean), and fresh-kernel replay (leanchecker).1. Verification Architecture and Role-Separated Trust
Checking a dynamic-programming (DP) coding-sequence compiler solely through finite unit tests verifies input-output agreement on chosen examples, yet cannot prove universal invariants across arbitrary protein lengths , tight integer GC intervals , or cross-junction motif bridges spanning flanks, coding triplets, and stop/terminator tails. Conversely, delegating both specification design and proof authoring to a single unconstrained automated workflow creates two well-known failure modes:
- Specification weakening and vacuity: A formalization can silently omit synonymous translation invariance (), trust unverified metadata fields on candidate records (such as a codon record
AAAclaiminggc = 3, or a stop tripletTAAinside a sense menu), or prove universal implications whose hypotheses are accidentally uninhabited. - Model-to-code conflation: Proving Bellman optimality for a discrete integer model over is not the same claim as proving universal code refinement for an operational Python optimizer that accumulates IEEE-754 binary64
math.logfloats, applies a1e-12intra-state tie tolerance, and reconstructs paths via mutable tuple backpointers.
To guard against silent specification drift and measure runtime boundaries explicitly, FactorForgeFormal enforces a four-layer trust separation:
- Locked Lean 4 specifications (
formal/FactorForgeFormal/Spec/): Six modules (Tropical.lean,Automaton.lean,GeneticCode.lean,ExactDP.lean,KineticAndParity.lean, and aggregatorSpec.lean) declare all data structures, algorithms, and target propositions (Prop_*) with zerosorryplaceholders, bound to locked file digests inspec_lock_manifest.json. - Isolated tactic proofs (
formal/FactorForgeFormal/Proofs/): Five proof modules importSpec/read-only and establish 20 core theorems plus 3 structural helper lemmas using structural induction, fold-invariant lifting, kernel reduction (decide), and linear integer arithmetic (omega), with zero external Mathlib dependencies and zeronative_decide. - Concrete non-vacuity witnesses and kernel axiom audit (
Witnesses.lean,Audit.lean): Fourteen kernel-checked theorems instantiate the specifications on a 12-state BsaI (GGTCTC/GAGACC) automaton across construct"GGTC" + "SL" + "TAA", refuting malformed codons and proving constructive selection ofAGCCTGat quantized score-357.Audit.leanruns#print axiomsacross all 34 declarations, followed by fresh-process kernel replay vialeanchecker. - Sampled Python correspondence & reference-mutation harness (
tests/): Cross-checks the self-containedfactorforge_snapshot/against an Aho-Corasick-independent substring enumerator (BruteForceCDSOracle), an exact integer mirror (LeanExactMirrorDP), a 200-instance shrinking fuzzer across fourPYTHONHASHSEEDsettings, and an 8-defect reference-copy mutation suite. Importantly, internal multi-agent adversarial review performed during development is an automated engineering check, not an independent audit by external human mathematicians or software verification specialists.
2. Tropical Max-Plus Algebra (Spec/Tropical.lean)
Additive log-CAI maximization over reachable finite states is formalized over the extended integer semiring , where unreachable (gc, state) cells carry , path extension adds integer step scores, and state relaxation takes the pointwise maximum.
Definition 2.1 (Tropical Carrier, Operations, and Partial Order). For carrier type , inductive type Trop α has constructors negInf (, additive identity ) and finite a (with multiplicative identity ). Over , relaxation , extension , and partial order are defined by:
inductive Trop (alpha : Type u) where
| negInf : Trop alpha
| finite : alpha -> Trop alpha
deriving DecidableEq, Repr
def oplus {alpha : Type u} [Max alpha] : Trop alpha -> Trop alpha -> Trop alpha
| Trop.negInf, b => b
| a, Trop.negInf => a
| Trop.finite a, Trop.finite b => Trop.finite (max a b)
def otimes {alpha : Type u} [Add alpha] : Trop alpha -> Trop alpha -> Trop alpha
| Trop.negInf, _ => Trop.negInf
| _, Trop.negInf => Trop.negInf
| Trop.finite a, Trop.finite b => Trop.finite (a + b)
Theorem 2.1 (tropIntSemiringLaws) & Theorem 2.2 (tropIntOrderLaws). satisfies all 12 idempotent max-plus semiring identities - associativity, commutativity, idempotence (), and identity of ; associativity, unit , and annihilation of ; left and right distributivity - and is a partial order for which is the least upper bound and is monotone in both arguments.
Proof sketch (Proofs/Tropical.lean). Proved by exhaustive 3-way constructor case analysis (cases a <;> cases b <;> cases c), reducing finite branches to linear integer max and + goals closed by omega (#print axioms: [propext, Quot.sound]).
3. Construct-Level Finite-State Automaton Safety (Spec/Automaton.lean)
Forbidden restriction endonuclease recognition sites (such as BsaI GGTCTC and reverse complement GAGACC) and sequence motifs can span -flank-to-CDS junctions, inter-codon boundaries, and CDS-to-stop/terminator junctions. Spec/Automaton.lean models bounded nucleotide DFAs over .
Definition 3.1 (Bounded DFA and Prefix-Safe Stepping). An Automaton comprises state count , initial state , state-closed transition map (), and forbidden terminal indicator . Multi-symbol stepping and prefix-wise terminal avoidance recurse over base lists, while stepCodonSafe mirrors CompiledAutomaton.step_codon by halting immediately with (s', false) if any intermediate base visits a terminal state.
structure Automaton where
numStates : Nat
initState : Nat
stepSym : Nat -> Base -> Nat
isTerminal : Nat -> Bool
init_lt : initState < numStates
step_lt : ∀ s b, s < numStates -> stepSym s b < numStates
def safeSeq (M : Automaton) (s : Nat) : List Base -> Bool
| [] => true
| b :: bs =>
let s' := M.stepSym s b
if M.isTerminal s' then false else safeSeq M s' bs
def stepCodonSafe (M : Automaton) (s : Nat) (codon : List Base) : Nat × Bool :=
match codon with
| [] => (s, true)
| b :: bs =>
let s' := M.stepSym s b
if M.isTerminal s' then (s', false) else stepCodonSafe M s' bs
Theorems 3.1–3.5 (
stepSeqAppend,safeSeqAppend,stepCodonSafeSound,stepCodonSafeComplete,fullConstructSafe). Multi-base transitions compose homomorphically (), prefix safety factors cleanly across intermediate states (), andstepCodonSafeis both sound and complete for(stepSeq, safeSeq). Consequently, for any flank , codon list , and tail with and :
Proof sketch (Proofs/Automaton.lean). Structural list induction on xs generalizing starting state s, splitting on M.isTerminal (M.stepSym s b). Helper safeCodonList_implies_safeSeq lifts stepCodonSafeSound across cds : List (List Base), after which fullConstructSafe rewrites List.append_assoc and applies safeSeqAppend twice (#print axioms: [propext] only).
4. Standard 64-Triplet Genetic Code and Synonymous Menu Validity (Spec/GeneticCode.lean)
To prevent malformed candidate menus from bypassing amino-acid fidelity or falsifying stored GC counts, Spec/GeneticCode.lean encodes all triplets (translateTriplet) and recursive frame-exact sense decoding (translateDNA), checked 64-for-64 against Python's STANDARD_GENETIC_CODE.
Definition 4.1 (ValidCodonForAA & WellFormedMenu). A candidate codon record is valid for target residue iff it has exact length 3, nucleotide GC count matching its stored gc field, and sense translation equal to :
def ValidCodonForAA (c : CodonSpec) (a : AminoAcid) : Bool :=
c.seq.length == 3 && c.gc == seqGC c.seq && translateCodonSeq c.seq == some (.aa a)
def WellFormedMenu : List AminoAcid -> List (List CodonSpec) -> Prop
| [], [] => True
| a :: as, opts :: rest =>
(∀ c ∈ opts, ValidCodonForAA c a = true) ∧ WellFormedMenu as rest
| _, _ => False
Theorem 4.1 (geneticCodePartition64, zero axioms), Lemmas 4.2–4.3 (validCodonForAA_destruct, translateDNA_cons3), & Theorems 4.4–4.5 (gcConservation, proteinPreservationAndGC). Inside Lean's kernel with zero axioms, the 64 DNA triplets partition into exactly 61 sense codons and 3 stop codons (TAA, TAG, TGA). Under WellFormedMenu P L, every ValidPath M s0 L C flattens to coding DNA satisfying:
guaranteeing zero reading-frame shifts and zero internal or terminal stop codons.
5. Bellman Optimality and Constructive Witness Extraction (Spec/ExactDP.lean)
5.1 Tropical Bellman Table vs. Constructive Candidate Solver
Over the discrete state lattice , Spec/ExactDP.lean defines both the Tropical value recurrence dpEval / dpBestScore and the constructive prefix-tracking solver dpTrackEval / dpOptimize.
To return an explicit optimal codon list some (v, cs) rather than an existential value proof, DPCandidate := Option (Int × List CodonSpec) pairs integer scores with prefix codon lists via deterministic relaxation relaxCand (retaining first-seen on exact score ties) and extendCand.
def Prop_DPOptimizeEndToEnd : Prop :=
∀ (M : Automaton) (leftFlank : List Base) (minGC maxGC : Nat) (tail : List Base)
(protein : List AminoAcid) (layers : List (List CodonSpec)),
WellFormedMenu protein layers ->
let s0 := M.stepSeq M.initState leftFlank
(M.safeSeq M.initState leftFlank = true ->
candToTrop (dpOptimize M leftFlank minGC maxGC tail layers) =
dpBestScore M s0 minGC maxGC tail layers) ∧
(dpOptimize M leftFlank minGC maxGC tail layers = none ↔
M.safeSeq M.initState leftFlank = false ∨
∀ cs, ¬ FeasibleCDS M s0 minGC maxGC tail layers cs) ∧
(∀ (v : Int) (cs : List CodonSpec),
dpOptimize M leftFlank minGC maxGC tail layers = some (v, cs) ->
let dna := cs.flatMap (·.seq)
FeasibleCDS M s0 minGC maxGC tail layers cs ∧
pathScore cs = v ∧
dna.length = 3 * protein.length ∧
translateDNA dna = some protein ∧
minGC ≤ seqGC dna ∧
seqGC dna ≤ maxGC ∧
M.safeSeq M.initState (leftFlank ++ dna ++ tail) = true ∧
∀ cs', FeasibleCDS M s0 minGC maxGC tail layers cs' -> pathScore cs' ≤ v)
5.2 Soundness, Completeness, Pruning, and Crown Theorem dpOptimizeEndToEnd
Theorems 5.1–5.3 (
dpSoundness,dpCompleteness,exactGlobalOptimality) & Lemma (exactOpt_witness_eq). For , every finite entry witnesses an authenticValidPathwith matching , and everyValidPathis upper-bounded by . Terminal projectiondpBestScoreupper-bounds allFeasibleCDSpaths and attains every finite global optimum.
Theorem 5.4 (Crown Theorem: dpOptimizeEndToEnd). Under WellFormedMenu P L with :
- Value refinement: When , .
- Complete infeasibility certificate: if and only if is unsafe or zero
FeasibleCDSpaths exist. - 8-part constructive sequence optimality: Whenever with , is feasible, , , , , the full construct is motif-safe from , and for every feasible competitor .
Theorems 5.5–5.6 (
gcEnvelopeAndPruningAdmissible,synonymousEnvelopeUnsat). Any feasible split satisfies and , proving suffix GC pruning never drops an optimal completion, and any target window disjoint from has zero feasible solutions.
Proof sketch (Proofs/ExactDP.lean, 1,225 lines). Uses snoc-list induction (list_snoc_rec) over DP layers and nested fold-invariant lemmas across List.range M.numStates and opts. Homomorphism lemma candToTrop_dpTrackEval proves candToTrop (dpTrackEval ...) = dpEval ... via candToTrop (relaxCand x y) = oplus (candToTrop x) (candToTrop y), while dpTrackSoundness lifts witness validity to compose proteinPreservationAndGC, fullConstructSafe, and exactGlobalOptimality.
6. Exact Rational Kinetics, Tie Orders, and Perturbation Margins (Spec/KineticAndParity.lean)
Definition 6.1 (ExactRat & rampTau). Exact rationals compare fractions via cross-multiplication () with zero rounding. Upstream deceleration ramp interpolation is represented exactly as:
Theorems 6.1–6.4 (
tasepRampBoundsAndMonotonicity,zeroWeightParity,pathLexTotalOrder,approxScoreExactness).
- Exact ramp interiority & monotonicity: For and , ; is strictly increasing in and invariant at .
- Zero-weight pause parity: When all active pause weights equal , structure-aware
structFitnesscollapses identically to baseline fitness across every entry ofdpEval.- Lexicographic strict total order: Prefix rank comparator
pathLexLtis irreflexive, transitive, asymmetric, and trichotomous onList Nat.- Conditional integer perturbation margin (
List Int): If pointwise integer error satisfies across steps, then , and with guarantees .
Runtime boundary (float vs. List Int / ExactRat). approxScoreExactness is a conditional theorem over List Int (fixed-point integer quantization), not a binary64 math.log floating-point error proof. Likewise, Python's round(..., 3) in TASEPKineticsEngine collapses strict interiority when (for instance, ).
7. Concrete 12-State BsaI Automaton & Constructive Refutation Trace (Witnesses.lean)
To prove non-vacuity inside Lean's kernel, Witnesses.lean encodes the deterministic 12-state Aho-Corasick automaton for BsaI (GGTCTC terminal state 6; reverse complement GAGACC terminal state 11) and optimizes dipeptide "SL" ([.S, .L]) across flank "GGTC", stop tail "TAA", and GC window [2, 4]:
- Flank stepping (
witness_leftFlank_safe):"GGTC"transitions safely (s0 = 4). - Junction violation refutation (
witness_tct_rejected): Highest-scoring Serine codonTCT(quantized score-223) steps , completing"GGTCTC"across the junction and halting with(6, false). - Malformed candidate refutation (
witness_malformed_codon_rejected): KerneldeciderejectsAAAclaiminggc = 3,AAAclaiming Serine.S, and stop tripletTAAclaiming Tyrosine.Y. - Constructive global optimum (
witness_dpOptimize_sl_end_to_end):dpOptimizeselectsAGC(, score-357,gc = 2) followed byCTG(, score0,gc = 2) and safe stop tail"TAA"(), outputtingsome (-357, [AGC, CTG])("AGCCTG",seqGC = 4).
theorem witness_malformed_codon_rejected :
ValidCodonForAA ⟨[.A, .A, .A], 3, 100⟩ .K = false ∧
ValidCodonForAA ⟨[.A, .A, .A], 0, 100⟩ .S = false ∧
ValidCodonForAA ⟨[.T, .A, .A], 0, 0⟩ .Y = false := by
decide
theorem witness_dpOptimize_sl_end_to_end :
∃ cs : List CodonSpec,
dpOptimize bsaiAutomaton leftFlankGGTC 2 4 tailStopTAA slLayers = some (-357, cs) ∧
translateDNA (cs.flatMap (·.seq)) = some [.S, .L] ∧
2 ≤ seqGC (cs.flatMap (·.seq)) ∧
seqGC (cs.flatMap (·.seq)) ≤ 4 ∧
bsaiAutomaton.safeSeq bsaiAutomaton.initState
(leftFlankGGTC ++ cs.flatMap (·.seq) ++ tailStopTAA) = true
8. Complete Theorem, Witness, Mutation, and Coverage Catalogs
8.1 Catalog of 20 Core Theorems + 3 Structural Helper Lemmas
Audit.lean directly prints 20 core theorem declarations and 14 witnesses (34 total). The three helper rows belong to the proof-module catalog; their axiom footprints are separately reproducible with #print axioms.
Axiom legend: none = zero axioms; P = [propext]; P, Q = [propext, Quot.sound]; P, C, Q = [propext, Classical.choice, Quot.sound] (zero sorryAx and zero custom axioms).
| Module | Lean Theorem / Lemma Identifier | #print axioms | Verified Mathematical Statement |
|---|---|---|---|
Tropical | tropIntSemiringLaws | P, Q | 12 idempotent max-plus semiring laws over . |
Tropical | tropIntOrderLaws | P, Q | Partial order, least upper bound, and / monotonicity. |
Automaton | stepSeqAppend | P | for all base lists . |
Automaton | safeSeqAppend | P | . |
Automaton | stepCodonSafeSound | P | stepCodonSafe(q, c) = (q', true) implies and safeSeq(q, c). |
Automaton | stepCodonSafeComplete | P | safeSeq(q, c) = true implies stepCodonSafe(q, c) = (stepSeq(q, c), true). |
Automaton | fullConstructSafe | P | Safe flank, safe codons, and safe tail yield safe full construct. |
GeneticCode | geneticCodePartition64 | none | 64 DNA triplets partition into 61 sense codons and 3 stop codons. |
GeneticCode | validCodonForAA_destruct (helper) | P, C, Q | Decomposes ValidCodonForAA into 3 bases, exact GC, and sense AA. |
GeneticCode | translateDNA_cons3 (helper) | P | Sense triplet prefix preserves recursive translateDNA decoding. |
ExactDP | gcConservation | P, C, Q | Sum of well-formed codon gc fields equals flattened nucleotide seqGC. |
ExactDP | proteinPreservationAndGC | P, C, Q | Valid paths over WellFormedMenu preserve length , seqGC, and some P. |
ExactDP | dpSoundness | P, C, Q | Every finite dpEval entry witnesses an authentic ValidPath at . |
ExactDP | dpCompleteness | P, C, Q | Every ValidPath score is upper-bounded by dpEval at . |
ExactDP | exactGlobalOptimality | P, C, Q | dpBestScore upper-bounds all FeasibleCDS and attains finite optima. |
ExactDP | exactOpt_witness_eq (helper) | P, C, Q | Feasible witness upper-bounding all feasible competitors equals dpBestScore. |
ExactDP | dpOptimizeEndToEnd | P, C, Q | Constructive dpOptimize value parity, none-iff-unsat, and 8-part optimality. |
ExactDP | gcEnvelopeAndPruningAdmissible | P, C, Q | Achievable suffix GC bounds preserve all feasible completions. |
ExactDP | synonymousEnvelopeUnsat | P, C, Q | Target GC bands disjoint from admit zero feasible paths. |
KineticAndParity | tasepRampBoundsAndMonotonicity | P, Q | Exact rational ramp interiority , strict monotonicity, and invariance. |
KineticAndParity | zeroWeightParity | P, Q | Zero-weight pause maps collapse step fitness and full DP tables to baseline. |
KineticAndParity | pathLexTotalOrder | P, Q | Irreflexivity, transitivity, asymmetry, and trichotomy of pathLexLt. |
KineticAndParity | approxScoreExactness | P, Q | Conditional List Int error bound and strict argmax preservation. |
8.2 All 14 Concrete Witness & Refutation Theorems (Witnesses.lean)
| Witness Theorem Identifier | #print axioms | Concrete Kernel-Verified Property |
|---|---|---|
witness_malformed_codon_rejected | P | Rejects AAA claiming gc = 3, AAA for .S, and stop TAA for .Y. |
witness_sl_wellFormedMenu | P | Certifies 6 Serine + 6 Leucine options satisfy WellFormedMenu [.S, .L]. |
witness_leftFlank_safe | P, Q | Left flank "GGTC" is safe on 12-state BsaI DFA and reaches state 4. |
witness_sl_feasible | P, Q | Path AGCCTG satisfies FeasibleCDS across "GGTC" + "SL" + "TAA". |
witness_dpBest_sl_exact | P, C, Q | Proves dpBestScore(...) = finite (-357) via exactOpt_witness_eq. |
witness_dpOptimize_sl_end_to_end | P, C, Q | Constructively extracts some (-357, cs) translating to [.S, .L]. |
witness_tct_rejected | P, Q | Proves Serine codon TCT from state 4 hits forbidden BsaI state 6. |
witness_gc_and_protein_preservation | P, C, Q | Instantiates proteinPreservationAndGC on optPathSL (AGCCTG). |
witness_gc_pruning_admissible | P, C, Q | Verifies prefix AGC + suffix Leucine GC envelope bounds [2, 4]. |
witness_tasep_ramp | P, Q | Certifies in ExactRat. |
witness_zero_weight_parity | P, Q | Confirms zero-weight pause entries preserve score -357 identically. |
witness_path_lex_order | P, Q | Certifies [14, 19] < [15, 19] < [48, 19] => [14, 19] < [48, 19]. |
witness_approx_margin_exactness | P, Q | Certifies 2-codon margin . |
witness_unsat_gc | P, C, Q | Certifies zero feasible paths exist when target GC band is [5, 6] > 4. |
8.3 Reference-Copy Mutation Audit (8/8 Injected Semantic Defects Killed)
Across 200 seeded random instances repeated over PYTHONHASHSEED , operational DPV2Optimizer matched BruteForceCDSOracle on feasibility, amino-acid translation, motif safety, and optimal score, while exposing a concrete tie-breaking difference on homodipeptides (FF: TTTTTC vs TTCTTT, identical score at (g = 1, s = 0)). In test_mutation_detection_audit.py, eight semantic defects were injected into an instrumented reference solver copy:
| Mutant ID | Audit Outcome | Injected Defect & Killing Oracle Assertion |
|---|---|---|
M1_WRONG_SYNONYMOUS_CODON | Killed | Injects Lysine AAA (gc = 0) into Serine menu on "SL" ([0.30, 0.67] GC); caught by translate_dna(seq) != "SL". |
M2_GC_COUNT_DROP_C | Killed | Counts only 'G' instead of 'G' + 'C' on "TT" ([0.66, 0.67] GC); caught by nucleotide GC window & oracle set check. |
M3_DROP_REVERSE_COMPLEMENT | Killed | Omits reverse complement GAGACC on "GA" + "DL"; emits junction GAGACC, caught by raw substring check. |
M4_IGNORE_LEFT_FLANK | Killed | Starts at s0 = 0 instead of step("GGTC") = 4 on "GGTC" + "SL" + "TAA"; emits TCT (GGTCTC), caught by substring check. |
M5_IGNORE_RIGHT_FLANK | Killed | Skips terminal right-flank transition on "" + "G" + "CTC"; emits GGT (GGTCTC), caught by substring check. |
M6_OFF_BY_ONE_MAX_GC | Killed | Replaces g <= max_gc with g < max_gc on "TT" (min_gc = max_gc = 4); falsely raises No in-band candidate. |
M7_MIN_INSTEAD_OF_MAX | Killed | Minimizes rather than maximizes log-CAI during state relaxation; caught by optimal score check against BruteForceCDSOracle. |
M8_CORRUPT_BACKPOINTER | Killed | Stores prev_g = g + 1 in forward pass; fails backtracking with KeyError or mismatched sequence. |
8.4 Mathematical Formulation Coverage Matrix (F1–F28)
Tiers: L1 = Lean 4 kernel proof; O1 = brute-force/fuzzer/mutation suite in this archive; C1 = deterministic unit tests in the main repository; (B) = documented runtime divergence.
| ID | Formulation | Lean 4 / Python Anchor | Verification Tier | Scope Note |
|---|---|---|---|---|
F1 | Codon frequency | load_codon_usage_table | C1 | Table loader |
F2 | Relative adaptiveness | _build_codon_weights | C1 + O1 | Clamped at |
F3 | Geometric CAI & log sum | pathScore, approxScoreExactness | L1 + O1 (B) | Int vs binary64 float |
F4 | Nucleotide GC count & percent | seqGC, gcConservation | L1 + O1 | Exact integer GC |
F5 | 64-triplet Genetic Code | translateTriplet, geneticCodePartition64 | L1 + O1 | 64/64 bijection |
F6 | Sense translation | ValidCodonForAA, proteinPreservationAndGC | L1 + O1 | Menu soundness |
F7 | Forbidden motif + RC closure | Automaton, AutomatonCompiler | L1 + O1 (B) | Supplied DFA table |
F8 | Full-construct junction safety | fullConstructSafe | L1 + O1 | Arbitrary flanks |
F9 | Feasible CDS set | FeasibleCDS, synonymousEnvelopeUnsat | L1 + O1 | Integer GC band |
F10–F14 | Random, Greedy, Balanced, GC-target, SOP / local rewriter | reverse_translator.py, sop_balancer.py, local_rewriter.py | C1 | Non-DP heuristics |
F15 | Tropical max-plus semiring | tropIntSemiringLaws, tropIntOrderLaws | L1 + O1 | algebra |
F16 | Forward Bellman layer step | dpStep, dpSoundness, dpCompleteness | L1 + O1 (B) | ramp outside Lean |
F17 | Terminal filter & global optimum | dpBestScore, exactGlobalOptimality | L1 + O1 (B) | Fallback in O1 |
F18 | Constructive backtracking & ties | dpOptimizeEndToEnd, pathLexTotalOrder | L1 + O1 (B) | 3 distinct tie rules |
F19 | Suffix GC pruning & TASEP ramp | gcEnvelopeAndPruningAdmissible, tasepRampBoundsAndMonotonicity | L1 + O1 (B) | round(..., 3) near |
F20–F26 | Candidate pass gate, window GC, homopolymer, dinucleotide, means | SharedEvaluator, BenchmarkRunner | C1 (+ O1) | Descriptive metrics |
F27 | Manifest file-integrity binding | verify_all.py, REPRODUCIBILITY_MANIFEST.json | O1 | 229-file lock |
F28 | Epistemic classification gate | UNVERIFIED_PUBLIC_CORPUS | Governance | Zero wet-lab claim |
9. Exact Proof Boundaries and Fail-Closed Replay Protocol
This milestone proves the mathematical soundness of FactorForge's explicitly specified discrete integer DP model, not a universal formal verification of the entire Python software stack:
| Scope Area | Current Status | Exact Technical Boundary |
|---|---|---|
Discrete integer DP core & 64-codon translation (FactorForgeFormal) | Verified in Lean 4 | 20 core theorems + 3 helper lemmas, 14 witnesses, 34 #print axioms checks (0 sorry), leanchecker verified. Optimality is relative to supplied WellFormedMenu menus (supplied-menu soundness; universal runtime menu correspondence is not proved here). |
| Sampled Python DP correspondence & reproducible archive | Completed (finite suite) | 28 pytest checks, 4 PYTHONHASHSEED runs, 8/8 reference-copy mutant kills, and 229-file manifest integrity checks (python verify_all.py). |
| Universal Python-to-Lean refinement & backpointer proof | Not proved (future scope) | Lean's dpOptimize tracks prefix lists; operational Python reconstructs mutable (prev_g, prev_s) backpointers and is not extracted from Lean. |
IEEE-754 float & 1e-12 epsilon error bounds | Not proved (future scope) | Operational DP accumulates binary64 math.log floats with a non-transitive 1e-12 intra-state tie window (relaxCand first-seen, LeanExactMirrorDP PathRank, and operational DPV2Optimizer last-codon tie-breaking follow three distinct tie policies). approxScoreExactness is conditional over List Int. |
| General substring motif compiler & non-DP heuristics | Not proved in Lean | Lean assumes a supplied DFA transition table rather than proving general Aho-Corasick fail-link compilation for arbitrary motif sets; AutomatonCompiler permutes internal state IDs with PYTHONHASHSEED; Python round(..., 3) collapses ramp strictness near ; initiation clamping and heuristics lie outside ExactDP.lean. |
| Biological expression & wet-lab performance | Not available | UNVERIFIED_PUBLIC_CORPUS · Biological validation: NOT_AVAILABLE. Mathematical optimization correctness implies zero wet-lab expression, folding, or yield guarantee. |
To replay the entire verification archive locally from clean state (with Python 3.11+, pytest, ruff, and elan leanprover/lean4:v4.36.0 installed), unpack FactorForge_Lean4_Verification_Package.zip to a short directory path and run:
python verify_all.py
Want to inspect all 2,749 lines of Lean 4 specifications & tactic proofs?
Switch to Full Proof mode to browse all 14 modules (including FactorForgeFormal.lean, Spec/, Proofs/, Witnesses.lean, Audit.lean) and the 34 #print axioms kernel outputs inline, or download the Complete Full Monograph PDF.