The fine Lemma 12 program, correctness: under OracleSpec the program interchanges the two [2^u] fields of…
ProvedNLogN.KFE.l12F_rat_correctThe fine Lemma 12 program, correctness: under OracleSpec the program interchanges the two [2^u] fields of the bit array.
The following holds (Lean statement, in the scope of module Solutions.KFEInst):
theorem NLogN.KFE.l12F_rat_correct (Qc : QCircuit (ZMod 2) m W) (hm : 2 ≤ m)
(q : ℕ) (hq : q.Prime) (Bb u : ℕ) (Pre G Suf : Shape) (hu : 1 ≤ u)
(hPre : ∀ a ∈ Pre, 1 ≤ a) (hG : ∀ a ∈ G, 1 ≤ a) (hS : ∀ a ∈ Suf, 1 ≤ a)
(e Kp : ℕ) (he : e = Nat.clog q (2 ^ u)) (hKp : Kp = Nat.clog m e)
(hspec : OracleSpec (AModel.prog (Qc.toCircuit (q ^ m ^ Kp)) q) 0 W m q Kp)
(hfr : ∀ j < Kp, FramesOK (fun X => GoodAtQ q ((Qc.den : ℚ)⁻¹ • ratM X) ∧
∀ T, TStep.sh T ∈ edgeTplQ Qc X → TOK T (q ^ m ^ j) Bb)
(Qc.toCircuit (q ^ m ^ Kp)).gates (Qc.toCircuit (q ^ m ^ Kp)).Min
(Qc.toCircuit (q ^ m ^ Kp)).Mout)
(hsb : ∀ j < Kp, SubBnd (q ^ m ^ j) Bb)
(hBb : zsz (((2 * vol (qShape Pre G Suf q e) + m + W * e : ℕ)) : ℤ) ≤ Bb) (hB1 : 1 ≤ Bb)
(I : List Sym) (s : IState HS) (F : Fin HS → List ℤ) (xs : List (ZMod 2))
(LP LG LS LU : List ℤ)
(FP : F kP = (vol Pre : ℤ) :: LP) (FG : F kG = (vol G : ℤ) :: LG)
(FS : F NLogN.KIL.kS = (vol Suf : ℤ) :: LS) (FU : F aU = (u : ℤ) :: LU) (F0 : F 0 = enc2 xs)
(F8 : F 8 = []) (F9 : F 9 = []) (F10 : F 10 = []) (F11 : F 11 = []) (F15 : F 15 = [])
(F20 : F 20 = []) (F21 : F 21 = []) (F23 : F 23 = []) (F24 : F 24 = [])
(hxs : xs.length = vol (binShape Pre G Suf (2 ^ u))) :
IRuns I (progF (Qc.toCircuit 1) (edgeTplQ Qc)) (l12F q m W) (encK s F)
(encK s (Function.update F 0 (enc2 (AModel.pull (binShape Pre G Suf (2 ^ u))
(binShape Pre G Suf (2 ^ u)) (swapPos Pre.length (Pre.length + 1 + G.length)) 0 xs))))
(cL12F u e (min (W * Kp) e) Kp (e - min (W * Kp) e) (vol (qShape Pre G Suf q e))
(vol (rowShape (vol Pre) (padRows W Kp (q ^ min (W * Kp) e))
(G ++ List.replicate (min (W * Kp) e) q) Suf q (e - min (W * Kp) e))) m q
(fun j => ilCostF W (KlevF (Qc.toCircuit 1) (edgeTplQ Qc) + 10 ^ 5) (KbF (Qc.toCircuit 1) (edgeTplQ Qc) + 10 ^ 9 + 100) (Kd m)
(SWn (Qc.toCircuit 1) (edgeTplQ Qc)) q Bb j
(vol (rowShape (vol Pre) (padRows W Kp (q ^ min (W * Kp) e))
(G ++ List.replicate (min (W * Kp) e) q) Suf q (e - min (W * Kp) e)))) Bb)
Context. The lemma belongs to the part KFE: the fine Lemma 12 program with the fine Prop. 11 code as oracle.
Formalization Note. This lemma belongs to the item-language (IL) layer of the integer-multiplication-kappa campaign: tape-level programs (register programs over 64 item stacks of the NLogN multitape framework, definition bundles IntMul_HvdH_M_Defs1–IntMul_HvdH_M_Defs8) that implement the data-movement primitives of the OpenAI preprint Integer multiplication below (field moves, row split/merge, shifts, the uniform Proposition 11 interchange, Lemma 12 with fine -per-element costs, Gaussian record primitives, Proposition 14 pieces) with exact list denotations from the array-model bundles IntMul_Kappa_K_Defs* and explicit cost bounds. All names refer to the definition bundles up to IntMul_Kappa_K_Defs18.
-- OpenAI-preprint / κ-improvement development (integer-multiplication-kappa), generated by skeleton subtraction.
import Definitions.Def_IntMul_Kappa_K_Defs18
set_option autoImplicit false
set_option relaxedAutoImplicit false
set_option maxHeartbeats 1000000
set_option linter.unusedSimpArgs false
set_option linter.unusedVariables false
open NLogN
open NLogN.KFE
open IntMul RS AModel AModelL12 AModelRat AModelFac KIL KFD
variable {m W : ℕ} [NeZero W]
theorem NLogN.KFE.l12F_rat_correct (Qc : QCircuit (ZMod 2) m W) (hm : 2 ≤ m)
(q : ℕ) (hq : q.Prime) (Bb u : ℕ) (Pre G Suf : Shape) (hu : 1 ≤ u)
(hPre : ∀ a ∈ Pre, 1 ≤ a) (hG : ∀ a ∈ G, 1 ≤ a) (hS : ∀ a ∈ Suf, 1 ≤ a)
(e Kp : ℕ) (he : e = Nat.clog q (2 ^ u)) (hKp : Kp = Nat.clog m e)
(hspec : OracleSpec (AModel.prog (Qc.toCircuit (q ^ m ^ Kp)) q) 0 W m q Kp)
(hfr : ∀ j < Kp, FramesOK (fun X => GoodAtQ q ((Qc.den : ℚ)⁻¹ • ratM X) ∧
∀ T, TStep.sh T ∈ edgeTplQ Qc X → TOK T (q ^ m ^ j) Bb)
(Qc.toCircuit (q ^ m ^ Kp)).gates (Qc.toCircuit (q ^ m ^ Kp)).Min
(Qc.toCircuit (q ^ m ^ Kp)).Mout)
(hsb : ∀ j < Kp, SubBnd (q ^ m ^ j) Bb)
(hBb : zsz (((2 * vol (qShape Pre G Suf q e) + m + W * e : ℕ)) : ℤ) ≤ Bb) (hB1 : 1 ≤ Bb)
(I : List Sym) (s : IState HS) (F : Fin HS → List ℤ) (xs : List (ZMod 2))
(LP LG LS LU : List ℤ)
(FP : F kP = (vol Pre : ℤ) :: LP) (FG : F kG = (vol G : ℤ) :: LG)
(FS : F NLogN.KIL.kS = (vol Suf : ℤ) :: LS) (FU : F aU = (u : ℤ) :: LU) (F0 : F 0 = enc2 xs)
(F8 : F 8 = []) (F9 : F 9 = []) (F10 : F 10 = []) (F11 : F 11 = []) (F15 : F 15 = [])
(F20 : F 20 = []) (F21 : F 21 = []) (F23 : F 23 = []) (F24 : F 24 = [])
(hxs : xs.length = vol (binShape Pre G Suf (2 ^ u))) :
IRuns I (progF (Qc.toCircuit 1) (edgeTplQ Qc)) (l12F q m W) (encK s F)
(encK s (Function.update F 0 (enc2 (AModel.pull (binShape Pre G Suf (2 ^ u))
(binShape Pre G Suf (2 ^ u)) (swapPos Pre.length (Pre.length + 1 + G.length)) 0 xs))))
(cL12F u e (min (W * Kp) e) Kp (e - min (W * Kp) e) (vol (qShape Pre G Suf q e))
(vol (rowShape (vol Pre) (padRows W Kp (q ^ min (W * Kp) e))
(G ++ List.replicate (min (W * Kp) e) q) Suf q (e - min (W * Kp) e))) m q
(fun j => ilCostF W (KlevF (Qc.toCircuit 1) (edgeTplQ Qc) + 10 ^ 5) (KbF (Qc.toCircuit 1) (edgeTplQ Qc) + 10 ^ 9 + 100) (Kd m)
(SWn (Qc.toCircuit 1) (edgeTplQ Qc)) q Bb j
(vol (rowShape (vol Pre) (padRows W Kp (q ^ min (W * Kp) e))
(G ++ List.replicate (min (W * Kp) e) q) Suf q (e - min (W * Kp) e)))) Bb) := by sorry