Download data/lean/OAI/Algorithms/SubexponentialSAT/Subexp/BlockSearchConcrete.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.83 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Algorithms/SubexponentialSAT/Subexp/BlockSearchConcrete.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Algorithms/SubexponentialSAT/Subexp/BlockSearchConcrete.lean
-
curl -L -o BlockSearchConcrete.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Algorithms/SubexponentialSAT/Subexp/BlockSearchConcrete.lean
7.83 kB
| import OAI.Algorithms.SubexponentialSAT.LeanCompat | |
| import OAI.Algorithms.SubexponentialSAT.Subexp.BlockSearchExecution | |
| import OAI.Algorithms.SubexponentialSAT.Subexp.BlockSearchBounds | |
| import OAI.Algorithms.SubexponentialSAT.Subexp.BlockCoefficientProgram | |
| namespace OAI.Algorithms | |
| /-! A fixed executable prime-field kernel-basis and complement search. -/ | |
| namespace SubexponentialSAT.Subexp.BlockSearchConcrete | |
| open BitProgram StructuredCalls BlockSearch BlockSearchEncoding BlockSearchPredicate | |
| open SubexpTupleRefinement | |
| /-- This instruction table is independent of the prime and matrix dimensions. -/ | |
| def program := BlockSearchExecution.program BlockCoefficientProgram.matrixPair | |
| def inputState (p : β) [Fact p.Prime] {m N : β} | |
| (M : Fin m β Fin N β ZMod p) (regs : Fin 24 β Bool) : StructuredProgram.State 24 42 := | |
| BlockSearchExecution.inputState (BlockCoefficientProgram.context p M) (scalarCode p) | |
| (QuarticSearch.elements p) N regs | |
| def cost (p : β) [Fact p.Prime] (m N : β) : β := | |
| BlockSearchExecution.cost (scalarCode p) (QuarticSearch.elements p) N | |
| (BlockCoefficientProgram.coefficientCost p m N) | |
| /-- The complete instruction bound is exponential in a polynomial of the | |
| local dimension and logarithmic field width, including tuple generation. -/ | |
| theorem cost_le (p : β) [Fact p.Prime] (m N : β) : | |
| cost p m N β€ | |
| 800 * (N * N + 1) * p ^ (N * N) * | |
| ((N * N + 1) * (2 * MatrixWordEncoding.width p + 1) + 1) + | |
| 800 * (N + 1) * p ^ N * ((N + 1) * (2 * MatrixWordEncoding.width p + 1) + 1) + | |
| 6 * N ^ 2 + 22 * N + 37 + | |
| BlockSearchExecution.searchBound p N (2 * MatrixWordEncoding.width p + 1) | |
| (BlockCoefficientProgram.coefficientCost p m N) := by | |
| have hp := (show Nat.Prime p from Fact.out).two_le | |
| have ha : 1 β€ (QuarticSearch.elements p).length := by | |
| rw [QuarticSearch.length_elements] | |
| omega | |
| have h := BlockSearchBounds.cost_le (scalarCode p) (QuarticSearch.elements p) ha N | |
| (BlockCoefficientProgram.coefficientCost p m N) | |
| simpa only [cost, QuarticSearch.length_elements, scalarCode, | |
| BlockSearchProgram.framedCode, MatrixWordEncoding.code] using h | |
| theorem validCoefficient_eq (p : β) [Fact p.Prime] (N : β) : | |
| BlockSearchCoverage.ValidCoefficient (scalarCode p) N = | |
| BlockCoefficientProgram.validCoefficient p N := by | |
| funext bits | |
| apply propext | |
| constructor | |
| Β· rintro β¨x, hxβ© | |
| refine β¨x, ?_β© | |
| simpa only [encoded_vector_eq_words, BlockCoefficientProgram.vectorWords] using hx | |
| Β· rintro β¨x, hxβ© | |
| refine β¨x, ?_β© | |
| simpa only [encoded_vector_eq_words, BlockCoefficientProgram.vectorWords] using hx | |
| theorem tableBits_eq (p : β) [Fact p.Prime] {N : β} | |
| (C : Fin N β Fin N β ZMod p) : | |
| encodeTuple (scalarCode p) (flattenTable C) = BlockCoefficientProgram.tableBits p C := by | |
| simpa only [BlockCoefficientProgram.tableBits, BlockCoefficientProgram.matrixBits, | |
| BlockCoefficientProgram.matrixRows, BlockCoefficientProgram.vectorWords] using | |
| encoded_table_eq_flatten_words p C | |
| theorem coefficientContract_with_alphabet (p : β) [Fact p.Prime] | |
| (alphabet : List (ZMod p)) (hfull : β x, x β alphabet) {m N : β} | |
| (M : Fin m β Fin N β ZMod p) (C : Fin N β Fin N β ZMod p) (d : Fin (N + 1)) : | |
| BlockSearchLoop.CoefficientContract BlockCoefficientProgram.matrixPair | |
| (BlockCoefficientProgram.context p M) (encodeTuple (scalarCode p) (flattenTable C)) | |
| (splitCode d) | |
| (encodedTest (scalarCode p) alphabet M | |
| (encodeTuple (scalarCode p) (flattenTable C)) (splitCode d)) | |
| (fun _ => BlockCoefficientProgram.coefficientCost p m N) | |
| (BlockSearchCoverage.ValidCoefficient (scalarCode p) N) := by | |
| have hc := BlockCoefficientProgram.coefficientContract p M C d | |
| (encodedTest (scalarCode p) alphabet M | |
| (encodeTuple (scalarCode p) (flattenTable C)) (splitCode d)) (fun x => by | |
| simpa only [test, BlockCoefficientProgram.vectorWords] using | |
| test_on_words p alphabet hfull M d C x) | |
| simpa only [β tableBits_eq p C, β validCoefficient_eq p N, splitCode] using hc | |
| theorem coefficientContract (p : β) [Fact p.Prime] {m N : β} | |
| (M : Fin m β Fin N β ZMod p) (C : Fin N β Fin N β ZMod p) (d : Fin (N + 1)) : | |
| BlockSearchLoop.CoefficientContract BlockCoefficientProgram.matrixPair | |
| (BlockCoefficientProgram.context p M) (encodeTuple (scalarCode p) (flattenTable C)) | |
| (splitCode d) | |
| (encodedTest (scalarCode p) (QuarticSearch.elements p) M | |
| (encodeTuple (scalarCode p) (flattenTable C)) (splitCode d)) | |
| (fun _ => BlockCoefficientProgram.coefficientCost p m N) | |
| (BlockSearchCoverage.ValidCoefficient (scalarCode p) N) := | |
| coefficientContract_with_alphabet p (QuarticSearch.elements p) | |
| (QuarticSearch.mem_elements p) M C d | |
| /-- The executable search accepts any supplied complete scalar alphabet, | |
| including the reversed order emitted by the scalar-alphabet formatter. -/ | |
| theorem program_runsIn_with_alphabet (p : β) [Fact p.Prime] | |
| (alphabet : List (ZMod p)) (hfull : β x, x β alphabet) {m N : β} | |
| (M : Fin m β Fin N β ZMod p) (regs : Fin 24 β Bool) : | |
| β (next : StructuredProgram.State 24 42) (C : Fin N β Fin N β ZMod p) (d : Fin (N + 1)), | |
| GoodPair M (splitPair d C) β§ next.stacks 41 = encodeTuple (scalarCode p) (flattenTable C) β§ | |
| next.stacks 8 = splitCode d β§ | |
| RunsIn program | |
| (BlockSearchExecution.cost (scalarCode p) alphabet N | |
| (BlockCoefficientProgram.coefficientCost p m N)) | |
| ((BlockSearchExecution.inputState (BlockCoefficientProgram.context p M) | |
| (scalarCode p) alphabet N regs).withPC (some program.entry)) (next.withPC none) := | |
| BlockSearchExecution.program_runsIn BlockCoefficientProgram.matrixPair | |
| (BlockCoefficientProgram.context p M) (scalarCode p) alphabet hfull M | |
| (BlockCoefficientProgram.coefficientCost p m N) rfl | |
| (coefficientContract_with_alphabet p alphabet hfull M) regs | |
| /-- All enumeration, arithmetic tests, and selection are executions of the | |
| same fixed instruction table. The output supplies a certified kernel basis | |
| and complement for the input matrix. -/ | |
| theorem program_runsIn (p : β) [Fact p.Prime] {m N : β} | |
| (M : Fin m β Fin N β ZMod p) (regs : Fin 24 β Bool) : | |
| β (next : StructuredProgram.State 24 42) (C : Fin N β Fin N β ZMod p) (d : Fin (N + 1)), | |
| GoodPair M (splitPair d C) β§ next.stacks 41 = encodeTuple (scalarCode p) (flattenTable C) β§ | |
| next.stacks 8 = splitCode d β§ | |
| RunsIn program (cost p m N) | |
| ((inputState p M regs).withPC (some program.entry)) (next.withPC none) := by | |
| exact BlockSearchExecution.program_runsIn BlockCoefficientProgram.matrixPair | |
| (BlockCoefficientProgram.context p M) (scalarCode p) (QuarticSearch.elements p) | |
| (QuarticSearch.mem_elements p) M (BlockCoefficientProgram.coefficientCost p m N) | |
| rfl (coefficientContract p M) regs | |
| theorem program_primitive_runsIn (p : β) [Fact p.Prime] {m N : β} | |
| (M : Fin m β Fin N β ZMod p) (regs : Fin 24 β Bool) : | |
| β (next : StructuredProgram.State 24 42) (C : Fin N β Fin N β ZMod p) (d : Fin (N + 1)), | |
| GoodPair M (splitPair d C) β§ next.stacks 41 = encodeTuple (scalarCode p) (flattenTable C) β§ | |
| next.stacks 8 = splitCode d β§ | |
| Computation.RunsIn (BitProgram.primitive program).step | |
| (BitProgram.primitiveOverhead program * cost p m N) | |
| (BitProgram.primitiveCfg program ((inputState p M regs).withPC (some program.entry))) | |
| (BitProgram.primitiveCfg program (next.withPC none)) := by | |
| obtain β¨next, C, d, hgood, hC, hd, hrunβ© := program_runsIn p M regs | |
| exact β¨next, C, d, hgood, hC, hd, BitProgram.primitive_execution program hrunβ© | |
| end SubexponentialSAT.Subexp.BlockSearchConcrete | |
| end OAI.Algorithms | |