Download data/lean/OAI/Algorithms/SubexponentialSAT/SqrtLogSpace/FactorEvaluationSpace.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 28.7 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Algorithms/SubexponentialSAT/SqrtLogSpace/FactorEvaluationSpace.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Algorithms/SubexponentialSAT/SqrtLogSpace/FactorEvaluationSpace.lean
-
curl -L -o FactorEvaluationSpace.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Algorithms/SubexponentialSAT/SqrtLogSpace/FactorEvaluationSpace.lean
28.7 kB
| import OAI.Algorithms.SubexponentialSAT.SqrtLogSpace.FactorArithmeticProgram | |
| import OAI.Algorithms.SubexponentialSAT.SqrtLog.LeafProgramFactorBoundsPolynomial | |
| import OAI.Algorithms.SubexponentialSAT.SqrtLog.LeafProgramFactorValue | |
| import OAI.Algorithms.SubexponentialSAT.SqrtLogSpace.FactorEnvironment | |
| import OAI.Algorithms.SubexponentialSAT.SqrtLogSpace.FactorProductSpace | |
| import OAI.Algorithms.SubexponentialSAT.BitProgramSpace | |
| /-! Immediate correction specialization keeps every factor dictionary over the | |
| empty formal-variable support. The retained key capacity is polynomial u*J. | |
| The bounds below apply to the actual native indicator, clause and product | |
| programs, including their input parsers and paid tape cleanup. -/ | |
| namespace OAI.Algorithms.SubexponentialSAT.SqrtLogSpace.FactorEvaluationSpace | |
| open OAI BitProgram StructuredCalls SubexpLiftRing SubexpQuarticRing | |
| open SqrtLog SqrtLog.LeafProgram | |
| open HashCircuitProgram HashCircuitProgram.Native MomentsProgram | |
| open IdempotentApplyProgram.Steps NativeSemantics FactorBounds | |
| variable {p t n d : β} [Fact p.Prime] | |
| @[simp] theorem empty_capacity (u J : β) (hJ : 0 < J) : | |
| IdempotentApplyProgram.Bounds.capacity (β : Finset (Fin n)) u J = u * J := by | |
| simp [IdempotentApplyProgram.Bounds.capacity, Squarefree.Sparse.supportUniverse, | |
| Finset.filter_singleton, hJ] | |
| theorem rawHash_good (ctx : Context p t n d) | |
| (minus : RingProgram.Code (Word (baseWidth p t)) d) | |
| (one : Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (incidence : Fin n β Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (hone : Good (β : Finset (Fin n)) ctx.u ctx.J one) | |
| (hi : β v, Good (β : Finset (Fin n)) ctx.u ctx.J (incidence v)) | |
| (ws : List (Row.WeightedClause n (baseWidth p t) d)) : | |
| Good (β : Finset (Fin n)) ctx.u ctx.J (Indicator.rawHash ctx minus one incidence ws) := | |
| row_fold_good p t ctx.modulus ctx.cache ctx.table (β : Finset (Fin n)) ctx.u ctx.J | |
| minus one incidence hone hi ws [] Good.nil | |
| theorem result_good (ctx : Context p t n d) (hu : 0 < ctx.u) (hJ : 0 < ctx.J) | |
| (minus : RingProgram.Code (Word (baseWidth p t)) d) | |
| (one : Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (incidence : Fin n β Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (hone : Good (β : Finset (Fin n)) ctx.u ctx.J one) | |
| (hi : β v, Good (β : Finset (Fin n)) ctx.u ctx.J (incidence v)) | |
| (ws : List (Row.WeightedClause n (baseWidth p t) d)) | |
| (digits : List (IdempotentApplyProgram.Triple (RingProgram.ScalarCode p t))) : | |
| Good (β : Finset (Fin n)) ctx.u ctx.J (Indicator.result ctx minus one incidence ws digits) := by | |
| have hh := rawHash_good ctx minus one incidence hone hi ws | |
| have hp := IdempotentApplyProgram.Bounds.prepared_bounded ctx (β : Finset (Fin n)) minus | |
| (Indicator.rawHash ctx minus one incidence ws) one hh.valid (indicator_good_iff.mpr hone) | |
| exact indicator_good_iff.mp (IdempotentApplyProgram.Bounds.loopResult_good ctx (β : Finset (Fin n)) | |
| hu hJ _ _ hh.valid hp.1 digits.reverse [] | |
| (IdempotentApplyProgram.Bounds.good_nil (β : Finset (Fin n)) ctx.u ctx.J)) | |
| omit [Fact p.Prime] in | |
| theorem table_length (ctx : Context p t n d) | |
| (incidence : Fin n β Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (hi : β v, Good (β : Finset (Fin n)) ctx.u ctx.J (incidence v)) : | |
| (Squarefree.Program.lookupRecords (Cost.entries incidence)).length β€ | |
| tableBound (baseWidth p t) d n ctx.u ctx.J | |
| (IdempotentApplyProgram.Bounds.capacity ((β : Finset (Fin n)) : Finset (Fin n)) ctx.u ctx.J) := by | |
| have hp := fun v => Cost.good_bytes (hi v) (le_refl | |
| (IdempotentApplyProgram.Bounds.capacity ((β : Finset (Fin n)) : Finset (Fin n)) ctx.u ctx.J)) | |
| simpa only [Cost.entries,LookupBounds.incidence_entries_length,tableBound] using | |
| LookupBounds.records_length (Cost.entries incidence) n _ | |
| (LookupBounds.incidence_key_length _ ()) | |
| (LookupBounds.incidence_payload_length _ () _ hp) | |
| theorem productBudget_le (ctx : Context p t n d) | |
| (seed factor : Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (hs : Good (β : Finset (Fin n)) ctx.u ctx.J seed) | |
| (hf : Good (β : Finset (Fin n)) ctx.u ctx.J factor) : | |
| Factor.productBudget p t ctx.modulus ctx.cache ctx.table ctx.u ctx.J seed factor β€ | |
| 56*Cost.bytesBound (baseWidth p t) d n ctx.u ctx.J | |
| (IdempotentApplyProgram.Bounds.capacity ((β : Finset (Fin n)) : Finset (Fin n)) ctx.u ctx.J)+ | |
| Cost.productBound (baseWidth p t) d n ctx.u ctx.J | |
| (IdempotentApplyProgram.Bounds.capacity ((β : Finset (Fin n)) : Finset (Fin n)) ctx.u ctx.J)+54 := by | |
| have hcap := le_refl (IdempotentApplyProgram.Bounds.capacity ((β : Finset (Fin n)) : Finset (Fin n)) ctx.u ctx.J) | |
| have bs := Cost.good_bytes hs hcap | |
| have bf := Cost.good_bytes hf hcap | |
| have br := Cost.good_bytes (product_good p t ctx.modulus ctx.cache ctx.table | |
| (β : Finset (Fin n)) ctx.u ctx.J seed factor hs hf) hcap | |
| have hw := Cost.product_le p t ctx.modulus ctx.cache ctx.table hcap seed factor hs hf | |
| dsimp only [Factor.productBudget] | |
| omega | |
| theorem indicatorBudget_le (ctx : Context p t n d) (hu : 0 < ctx.u) (hJ : 0 < ctx.J) | |
| (minus : RingProgram.Code (Word (baseWidth p t)) d) | |
| (one : Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (incidence : Fin n β Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (hone : Good (β : Finset (Fin n)) ctx.u ctx.J one) | |
| (hi : β v, Good (β : Finset (Fin n)) ctx.u ctx.J (incidence v)) | |
| (ws : List (Row.WeightedClause n (baseWidth p t) d)) | |
| (digits : List (IdempotentApplyProgram.Triple (RingProgram.ScalarCode p t))) | |
| (k : β) (hk : β w β ws, w.literals.length β€ k) : | |
| FactorServices.indicatorBudget ctx minus one incidence (Cost.entries incidence) ws digits β€ | |
| Cost.programBound (baseWidth p t) d n ctx.u ctx.J | |
| (IdempotentApplyProgram.Bounds.capacity ((β : Finset (Fin n)) : Finset (Fin n)) ctx.u ctx.J) k ws.length+ | |
| IdempotentApplyProgram.Bounds.totalEnvelope (baseWidth p t) d n ctx.u ctx.J | |
| (IdempotentApplyProgram.Bounds.capacity ((β : Finset (Fin n)) : Finset (Fin n)) ctx.u ctx.J) digits.length+4 := by | |
| have hh := rawHash_good ctx minus one incidence hone hi ws | |
| have hc := Cost.program_le p t ctx.modulus ctx.cache ctx.table | |
| (le_refl (IdempotentApplyProgram.Bounds.capacity ((β : Finset (Fin n)) : Finset (Fin n)) ctx.u ctx.J)) | |
| minus one incidence hone hi (List.replicate d true) (by simp) ws k hk | |
| have ha := IdempotentApplyProgram.Bounds.totalCost_le ctx (β : Finset (Fin n)) hu hJ minus | |
| (Indicator.rawHash ctx minus one incidence ws) one | |
| (IdempotentApplyProgram.Bounds.good_bounded ctx (β : Finset (Fin n)) _ (indicator_good_iff.mpr hh)) | |
| (indicator_good_iff.mpr hone) digits | |
| change IdempotentApplyProgram.applicationBudget _ _ _ _ _ β€ _ at ha | |
| unfold FactorServices.indicatorBudget | |
| omega | |
| theorem hashService_le (ctx : Context p t n d) (hu : 0 < ctx.u) (hJ : 0 < ctx.J) | |
| (minus : RingProgram.Code (Word (baseWidth p t)) d) | |
| (one seed : Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (incidence : Fin n β Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (hone : Good (β : Finset (Fin n)) ctx.u ctx.J one) (hs : Good (β : Finset (Fin n)) ctx.u ctx.J seed) | |
| (hi : β v, Good (β : Finset (Fin n)) ctx.u ctx.J (incidence v)) | |
| (ws : List (Row.WeightedClause n (baseWidth p t) d)) | |
| (digits : List (IdempotentApplyProgram.Triple (RingProgram.ScalarCode p t))) | |
| (k : β) (hk : β w β ws, w.literals.length β€ k) : | |
| FactorServices.indicatorBudget ctx minus one incidence (Cost.entries incidence) ws digits+ | |
| (2*(Product.bytes (Indicator.rawHash ctx minus one incidence ws)).length+ | |
| 2*(Squarefree.Program.lookupRecords (Cost.entries incidence)).length+6+ | |
| Factor.productBudget p t ctx.modulus ctx.cache ctx.table ctx.u ctx.J seed | |
| (Indicator.result ctx minus one incidence ws digits)) β€ | |
| hashServiceBound (baseWidth p t) d n ctx.u ctx.J | |
| (IdempotentApplyProgram.Bounds.capacity ((β : Finset (Fin n)) : Finset (Fin n)) ctx.u ctx.J) k ws.length digits.length := by | |
| have h1 := indicatorBudget_le ctx hu hJ minus one incidence hone hi ws digits k hk | |
| have h2 := table_length ctx incidence hi | |
| have h3 := Cost.good_bytes (rawHash_good ctx minus one incidence hone hi ws) | |
| (le_refl (IdempotentApplyProgram.Bounds.capacity ((β : Finset (Fin n)) : Finset (Fin n)) ctx.u ctx.J)) | |
| have h4 := productBudget_le ctx seed _ hs (result_good ctx hu hJ minus one incidence hone hi ws digits) | |
| unfold hashServiceBound | |
| omega | |
| theorem clauseResult_good (ctx : Context p t n d) | |
| (minus : RingProgram.Code (Word (baseWidth p t)) d) | |
| (one : Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (incidence : Fin n β Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (hone : Good (β : Finset (Fin n)) ctx.u ctx.J one) | |
| (hi : β v, Good (β : Finset (Fin n)) ctx.u ctx.J (incidence v)) | |
| (ls : List (SAT.Literal (Fin n))) : | |
| Good (β : Finset (Fin n)) ctx.u ctx.J (FactorServices.clauseResult ctx minus one incidence ls) := | |
| clause_fold_good p t ctx.modulus ctx.cache ctx.table (β : Finset (Fin n)) ctx.u ctx.J | |
| minus one incidence hone hi ls one hone | |
| theorem markedService_le (ctx : Context p t n d) | |
| (minus : RingProgram.Code (Word (baseWidth p t)) d) | |
| (one seed : Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (incidence : Fin n β Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (hone : Good (β : Finset (Fin n)) ctx.u ctx.J one) (hs : Good (β : Finset (Fin n)) ctx.u ctx.J seed) | |
| (hi : β v, Good (β : Finset (Fin n)) ctx.u ctx.J (incidence v)) | |
| (ls : List (SAT.Literal (Fin n))) : | |
| FactorServices.clauseBudget ctx minus one incidence (Cost.entries incidence) ls+ | |
| (2*(Squarefree.Program.lookupRecords (Cost.entries incidence)).length+3+ | |
| Factor.productBudget p t ctx.modulus ctx.cache ctx.table ctx.u ctx.J seed | |
| (FactorServices.clauseResult ctx minus one incidence ls)) β€ | |
| markedServiceBound (baseWidth p t) d n ctx.u ctx.J | |
| (IdempotentApplyProgram.Bounds.capacity ((β : Finset (Fin n)) : Finset (Fin n)) ctx.u ctx.J) ls.length := by | |
| have h1 := Cost.clause_le p t ctx.modulus ctx.cache ctx.table | |
| (le_refl (IdempotentApplyProgram.Bounds.capacity ((β : Finset (Fin n)) : Finset (Fin n)) ctx.u ctx.J)) | |
| minus one incidence hone hi (List.replicate d true) (by simp) ls one hone | |
| have h2 := table_length ctx incidence hi | |
| have h3 := Cost.good_bytes hone | |
| (le_refl (IdempotentApplyProgram.Bounds.capacity ((β : Finset (Fin n)) : Finset (Fin n)) ctx.u ctx.J)) | |
| have h4 := productBudget_le ctx seed _ hs (clauseResult_good ctx minus one incidence hone hi ls) | |
| unfold FactorServices.clauseBudget markedServiceBound | |
| omega | |
| /-- All numerical arguments are encoded dimensions or polynomial retained | |
| capacity. The exponent is fixed independently of every input. -/ | |
| def inputScale (B d n u J k m L : β) : β := | |
| B + d + n + u + J + u * J + k + m + L + 1 | |
| def serviceBudget (B d n u J k m L : β) : β := | |
| 14000000 * (inputScale B d n u J k m L) ^ 9 | |
| theorem empty_capacity_le (u J : β) : | |
| IdempotentApplyProgram.Bounds.capacity (β : Finset (Fin n)) u J β€ u * J := by | |
| have h : (Squarefree.Sparse.supportUniverse (β : Finset (Fin n)) J).card β€ 1 := by | |
| calc | |
| _ β€ ((β : Finset (Fin n)).powerset).card := Finset.card_filter_le _ _ | |
| _ = 1 := by simp | |
| simpa only [IdempotentApplyProgram.Bounds.capacity, Nat.mul_one] using | |
| Nat.mul_le_mul_left (u * J) h | |
| theorem indicatorBudget_polynomial (ctx : Context p t n d) | |
| (hu : 0 < ctx.u) (hJ : 0 < ctx.J) | |
| (minus : RingProgram.Code (Word (baseWidth p t)) d) | |
| (one : Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (incidence : Fin n β Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (hone : Good β ctx.u ctx.J one) | |
| (hi : β v, Good β ctx.u ctx.J (incidence v)) | |
| (ws : List (Row.WeightedClause n (baseWidth p t) d)) | |
| (digits : List (IdempotentApplyProgram.Triple (RingProgram.ScalarCode p t))) | |
| (k : β) (hk : β w β ws, w.literals.length β€ k) : | |
| FactorServices.indicatorBudget ctx minus one incidence (Cost.entries incidence) ws digits β€ | |
| serviceBudget (baseWidth p t) d n ctx.u ctx.J k ws.length digits.length := by | |
| have hs := hashService_le ctx hu hJ minus one one incidence hone hone hi ws digits k hk | |
| have hc := empty_capacity_le (n:=n) ctx.u ctx.J | |
| let Z := inputScale (baseWidth p t) d n ctx.u ctx.J k ws.length digits.length | |
| have hp := FactorBounds.hashServiceBound_le (baseWidth p t) d n ctx.u ctx.J | |
| (IdempotentApplyProgram.Bounds.capacity (β : Finset (Fin n)) ctx.u ctx.J) | |
| k ws.length digits.length Z | |
| (by dsimp [Z, inputScale]; omega) (by dsimp [Z, inputScale]; omega) | |
| (by dsimp [Z, inputScale]; omega) (by dsimp [Z, inputScale]; omega) | |
| (by dsimp [Z, inputScale]; omega) (by dsimp [Z, inputScale]; omega) | |
| (by dsimp [Z, inputScale]; omega) (by dsimp [Z, inputScale]; omega) | |
| (by dsimp [Z, inputScale]; omega) (by dsimp [Z, inputScale]; omega) | |
| change _ β€ 14000000 * Z ^ 9 | |
| omega | |
| theorem clauseBudget_polynomial (ctx : Context p t n d) | |
| (minus : RingProgram.Code (Word (baseWidth p t)) d) | |
| (one : Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (incidence : Fin n β Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (hone : Good β ctx.u ctx.J one) | |
| (hi : β v, Good β ctx.u ctx.J (incidence v)) | |
| (ls : List (SAT.Literal (Fin n))) : | |
| FactorServices.clauseBudget ctx minus one incidence (Cost.entries incidence) ls β€ | |
| serviceBudget (baseWidth p t) d n ctx.u ctx.J ls.length 0 0 := by | |
| have hs := markedService_le ctx minus one one incidence hone hone hi ls | |
| have hc := empty_capacity_le (n:=n) ctx.u ctx.J | |
| let Z := inputScale (baseWidth p t) d n ctx.u ctx.J ls.length 0 0 | |
| have hZ : 1 β€ Z := by dsimp [Z, inputScale]; omega | |
| have hp := FactorBounds.markedServiceBound_le (baseWidth p t) d n ctx.u ctx.J | |
| (IdempotentApplyProgram.Bounds.capacity (β : Finset (Fin n)) ctx.u ctx.J) | |
| ls.length Z hZ | |
| (by dsimp [Z, inputScale]; omega) (by dsimp [Z, inputScale]; omega) | |
| (by dsimp [Z, inputScale]; omega) (by dsimp [Z, inputScale]; omega) | |
| (by dsimp [Z, inputScale]; omega) (by dsimp [Z, inputScale]; omega) | |
| (by dsimp [Z, inputScale]; omega) | |
| have hpow : Z ^ 8 β€ Z ^ 9 := Nat.pow_le_pow_right hZ (by decide) | |
| change _ β€ 14000000 * Z ^ 9 | |
| omega | |
| /-- Concrete wide indicator execution, its actual result, and total space at | |
| all prefixes of the same compiled run. Only its polynomial local runtime is | |
| used to control allocation; this estimate is never applied to the exponential | |
| outer traversal. -/ | |
| theorem indicator_run_space (ctx : Context p t n d) (hd : 0 < d) | |
| (hB : 0 < baseWidth p t) (hu : 0 < ctx.u) (hJ : 0 < ctx.J) | |
| (minus : RingProgram.Code (Word (baseWidth p t)) d) | |
| (one : Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (incidence : Fin n β Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (hone : Good β ctx.u ctx.J one) | |
| (hi : β v, Good β ctx.u ctx.J (incidence v)) | |
| (ws : List (Row.WeightedClause n (baseWidth p t) d)) | |
| (digits : List (IdempotentApplyProgram.Triple (RingProgram.ScalarCode p t))) | |
| (width : β) (hwidth : β w β ws, w.literals.length β€ width) | |
| (a : Factor.Data) | |
| (hlow : β i, a.stacks (Factor.indicatorStacks (Memory.lowPort i)) = low ctx i) | |
| (hsource : a.stacks 64 = Encoding.encodeList id (ws.map Row.payload)) | |
| (htable : a.stacks 62 = Squarefree.Program.lookupRecords (Cost.entries incidence)) | |
| (honeTape : a.stacks 69 = Product.bytes one) | |
| (hminus : a.stacks 76 = RingProgram.flat minus) | |
| (htape : a.stacks 143 = IdempotentApplyProgram.triplesTape digits) | |
| (hshape : (a.stacks 88).length = n) | |
| (hwork : β i β FactorServices.indicatorScratch, a.stacks (Factor.indicatorStacks i) = []) : | |
| let budget := serviceBudget (baseWidth p t) d n ctx.u ctx.J width ws.length digits.length | |
| let output := Indicator.result ctx minus one incidence ws digits | |
| let program := compiled Factor.indicator 64 67 | |
| β steps rr, steps β€ budget β§ Good β ctx.u ctx.J output β§ | |
| Eval Factor.indicator steps a (FactorServices.indicatorFinished a rr | |
| (Product.bytes (Indicator.rawHash ctx minus one incidence ws)) (Product.bytes output)) β§ | |
| Trace program (steps + 1) (a.withPC (some program.entry)) | |
| ((FactorServices.indicatorFinished a rr | |
| (Product.bytes (Indicator.rawHash ctx minus one incidence ws)) | |
| (Product.bytes output)).withPC none) β§ | |
| β prefixSteps intermediate, prefixSteps β€ steps + 1 β | |
| Trace program prefixSteps (a.withPC (some program.entry)) intermediate β | |
| dataBits intermediate β€ stackBits a.stacks + budget + 1 := by | |
| dsimp only | |
| obtain β¨steps, rr, hs, heβ© := FactorServices.indicator_eval ctx hd hB minus one incidence | |
| (Cost.entries incidence) | |
| (incidenceEntries_lookup (fun (_ : Unit) v => Product.bytes (incidence v)) ()) | |
| ws digits a hlow hsource htable honeTape hminus htape hshape hwork | |
| have hb := hs.trans (indicatorBudget_polynomial ctx hu hJ minus one incidence hone hi | |
| ws digits width hwidth) | |
| refine β¨steps, rr, hb, result_good ctx hu hJ minus one incidence hone hi ws digits, | |
| he, compiled_halt_trace he 64 67, ?_β© | |
| intro prefixSteps intermediate hp htrace | |
| have hgrowth := trace_dataBits (compiled Factor.indicator 64 67) htrace | |
| change dataBits intermediate β€ stackBits a.stacks + prefixSteps at hgrowth | |
| omega | |
| theorem clause_run_space (ctx : Context p t n d) | |
| (minus : RingProgram.Code (Word (baseWidth p t)) d) | |
| (one : Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (incidence : Fin n β Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (hone : Good β ctx.u ctx.J one) | |
| (hi : β v, Good β ctx.u ctx.J (incidence v)) | |
| (ls : List (SAT.Literal (Fin n))) (a : Factor.Data) | |
| (hlow : β i, a.stacks (Clause.callerStacks (Memory.lowPort i)) = low ctx i) | |
| (hsource : a.stacks 63 = Encoding.encodeList id (ls.map Clause.literalBits)) | |
| (htable : a.stacks 62 = Squarefree.Program.lookupRecords (Cost.entries incidence)) | |
| (honeTape : a.stacks 69 = Product.bytes one) | |
| (hminus : a.stacks 76 = RingProgram.flat minus) | |
| (hwork : β i β FactorServices.clauseScratch, a.stacks (Clause.callerStacks i) = []) : | |
| let budget := serviceBudget (baseWidth p t) d n ctx.u ctx.J ls.length 0 0 | |
| let output := FactorServices.clauseResult ctx minus one incidence ls | |
| let program := compiled Clause.caller 63 67 | |
| β steps rr, steps β€ budget β§ Good β ctx.u ctx.J output β§ | |
| Eval Clause.caller steps a (FactorServices.clauseFinished a rr (Product.bytes output)) β§ | |
| Trace program (steps + 1) (a.withPC (some program.entry)) | |
| ((FactorServices.clauseFinished a rr (Product.bytes output)).withPC none) β§ | |
| β prefixSteps intermediate, prefixSteps β€ steps + 1 β | |
| Trace program prefixSteps (a.withPC (some program.entry)) intermediate β | |
| dataBits intermediate β€ stackBits a.stacks + budget + 1 := by | |
| dsimp only | |
| obtain β¨steps, rr, hs, heβ© := FactorServices.clause_eval ctx minus one incidence | |
| (Cost.entries incidence) | |
| (incidenceEntries_lookup (fun (_ : Unit) v => Product.bytes (incidence v)) ()) | |
| ls a hlow hsource htable honeTape hminus hwork | |
| have hb := hs.trans (clauseBudget_polynomial ctx minus one incidence hone hi ls) | |
| refine β¨steps, rr, hb, clauseResult_good ctx minus one incidence hone hi ls, | |
| he, compiled_halt_trace he 63 67, ?_β© | |
| intro prefixSteps intermediate hp htrace | |
| have hgrowth := trace_dataBits (compiled Clause.caller 63 67) htrace | |
| change dataBits intermediate β€ stackBits a.stacks + prefixSteps at hgrowth | |
| omega | |
| theorem hashWork_polynomial (ctx : Context p t n d) | |
| (hu : 0 < ctx.u) (hJ : 0 < ctx.J) | |
| (minus : RingProgram.Code (Word (baseWidth p t)) d) | |
| (one seed : Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (incidence : Fin n β Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (hone : Good β ctx.u ctx.J one) (hseed : Good β ctx.u ctx.J seed) | |
| (hi : β v, Good β ctx.u ctx.J (incidence v)) | |
| (ws : List (Row.WeightedClause n (baseWidth p t) d)) | |
| (digits : List (IdempotentApplyProgram.Triple (RingProgram.ScalarCode p t))) | |
| (k : β) (hk : β w β ws, w.literals.length β€ k) : | |
| FactorServices.indicatorBudget ctx minus one incidence (Cost.entries incidence) ws digits + | |
| (2 * (Product.bytes (Indicator.rawHash ctx minus one incidence ws)).length + | |
| 2 * (Squarefree.Program.lookupRecords (Cost.entries incidence)).length + 6 + | |
| Factor.productBudget p t ctx.modulus ctx.cache ctx.table ctx.u ctx.J seed | |
| (Indicator.result ctx minus one incidence ws digits)) β€ | |
| serviceBudget (baseWidth p t) d n ctx.u ctx.J k ws.length digits.length := by | |
| have hs := hashService_le ctx hu hJ minus one seed incidence hone hseed hi ws digits k hk | |
| have hc := empty_capacity_le (n:=n) ctx.u ctx.J | |
| let Z := inputScale (baseWidth p t) d n ctx.u ctx.J k ws.length digits.length | |
| exact hs.trans (FactorBounds.hashServiceBound_le (baseWidth p t) d n ctx.u ctx.J | |
| (IdempotentApplyProgram.Bounds.capacity (β : Finset (Fin n)) ctx.u ctx.J) | |
| k ws.length digits.length Z | |
| (by dsimp [Z, inputScale]; omega) (by dsimp [Z, inputScale]; omega) | |
| (by dsimp [Z, inputScale]; omega) (by dsimp [Z, inputScale]; omega) | |
| (by dsimp [Z, inputScale]; omega) (by dsimp [Z, inputScale]; omega) | |
| (by dsimp [Z, inputScale]; omega) (by dsimp [Z, inputScale]; omega) | |
| (by dsimp [Z, inputScale]; omega) (by dsimp [Z, inputScale]; omega)) | |
| theorem markedWork_polynomial (ctx : Context p t n d) | |
| (minus : RingProgram.Code (Word (baseWidth p t)) d) | |
| (one seed : Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (incidence : Fin n β Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (hone : Good β ctx.u ctx.J one) (hseed : Good β ctx.u ctx.J seed) | |
| (hi : β v, Good β ctx.u ctx.J (incidence v)) | |
| (ls : List (SAT.Literal (Fin n))) : | |
| FactorServices.clauseBudget ctx minus one incidence (Cost.entries incidence) ls + | |
| (2 * (Squarefree.Program.lookupRecords (Cost.entries incidence)).length + 3 + | |
| Factor.productBudget p t ctx.modulus ctx.cache ctx.table ctx.u ctx.J seed | |
| (FactorServices.clauseResult ctx minus one incidence ls)) β€ | |
| serviceBudget (baseWidth p t) d n ctx.u ctx.J ls.length 0 0 := by | |
| have hs := markedService_le ctx minus one seed incidence hone hseed hi ls | |
| have hc := empty_capacity_le (n:=n) ctx.u ctx.J | |
| let Z := inputScale (baseWidth p t) d n ctx.u ctx.J ls.length 0 0 | |
| have hZ : 1 β€ Z := by dsimp [Z, inputScale]; omega | |
| have hp := FactorBounds.markedServiceBound_le (baseWidth p t) d n ctx.u ctx.J | |
| (IdempotentApplyProgram.Bounds.capacity (β : Finset (Fin n)) ctx.u ctx.J) | |
| ls.length Z hZ | |
| (by dsimp [Z, inputScale]; omega) (by dsimp [Z, inputScale]; omega) | |
| (by dsimp [Z, inputScale]; omega) (by dsimp [Z, inputScale]; omega) | |
| (by dsimp [Z, inputScale]; omega) (by dsimp [Z, inputScale]; omega) | |
| (by dsimp [Z, inputScale]; omega) | |
| have hpow : Z ^ 8 β€ Z ^ 9 := Nat.pow_le_pow_right hZ (by decide) | |
| change _ β€ 14000000 * Z ^ 9 | |
| omega | |
| theorem hashArithmetic_run_space (ctx : Context p t n d) (hd : 0 < d) | |
| (hB : 0 < baseWidth p t) (hu : 0 < ctx.u) (hJ : 0 < ctx.J) | |
| (minus : RingProgram.Code (Word (baseWidth p t)) d) | |
| (one seed : Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (incidence : Fin n β Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (hone : Good β ctx.u ctx.J one) (hseed : Good β ctx.u ctx.J seed) | |
| (hi : β v, Good β ctx.u ctx.J (incidence v)) | |
| (ws : List (Row.WeightedClause n (baseWidth p t) d)) | |
| (digits : List (IdempotentApplyProgram.Triple (RingProgram.ScalarCode p t))) | |
| (width : β) (hwidth : β w β ws, w.literals.length β€ width) | |
| (a : Factor.Data) | |
| (hlow : β i, a.stacks (Factor.indicatorStacks (Memory.lowPort i)) = low ctx i) | |
| (hsource : a.stacks 64 = Encoding.encodeList id (ws.map Row.payload)) | |
| (htable : a.stacks 62 = Squarefree.Program.lookupRecords (Cost.entries incidence)) | |
| (honeTape : a.stacks 69 = Product.bytes one) | |
| (hminus : a.stacks 76 = RingProgram.flat minus) | |
| (htape : a.stacks 143 = IdempotentApplyProgram.triplesTape digits) | |
| (hshape : (a.stacks 88).length = n) | |
| (hwork : β i β FactorServices.indicatorScratch, a.stacks (Factor.indicatorStacks i) = []) | |
| (hseedTape : a.stacks 151 = Product.bytes seed) (htmp : a.stacks 159 = []) : | |
| let budget := serviceBudget (baseWidth p t) d n ctx.u ctx.J width ws.length digits.length | |
| let result := Product.run p t ctx.modulus ctx.cache ctx.table ctx.u ctx.J seed | |
| (Indicator.result ctx minus one incidence ws digits) [] | |
| let program := compiled hashArithmetic 64 151 | |
| β steps b, steps β€ budget β§ Good β ctx.u ctx.J result β§ | |
| Eval hashArithmetic steps a b β§ | |
| b.stacks = Function.update (Function.update (Function.update (Function.update | |
| (Function.update a.stacks 64 []) 67 []) 68 []) 62 []) 151 (Product.bytes result) β§ | |
| Trace program (steps + 1) (a.withPC (some program.entry)) (b.withPC none) β§ | |
| β prefixSteps intermediate, prefixSteps β€ steps + 1 β | |
| Trace program prefixSteps (a.withPC (some program.entry)) intermediate β | |
| dataBits intermediate β€ stackBits a.stacks + budget + 1 := by | |
| dsimp only | |
| obtain β¨steps, b, hs, he, hbβ© := Factor.hash_value_eval ctx hd hB minus one seed incidence | |
| (Cost.entries incidence) | |
| (incidenceEntries_lookup (fun (_ : Unit) v => Product.bytes (incidence v)) ()) | |
| ws digits a hlow hsource htable honeTape hminus htape hshape hwork hseedTape htmp | |
| rw [htable] at hs | |
| have hbound := hs.trans (hashWork_polynomial ctx hu hJ minus one seed incidence hone hseed hi | |
| ws digits width hwidth) | |
| have hgood := product_good p t ctx.modulus ctx.cache ctx.table β ctx.u ctx.J seed _ hseed | |
| (result_good ctx hu hJ minus one incidence hone hi ws digits) | |
| refine β¨steps, b, hbound, hgood, he, hb, compiled_halt_trace he 64 151, ?_β© | |
| intro prefixSteps intermediate hp htrace | |
| have hgrowth := trace_dataBits (compiled hashArithmetic 64 151) htrace | |
| change dataBits intermediate β€ stackBits a.stacks + prefixSteps at hgrowth | |
| omega | |
| theorem markedArithmetic_run_space (ctx : Context p t n d) | |
| (minus : RingProgram.Code (Word (baseWidth p t)) d) | |
| (one seed : Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (incidence : Fin n β Raw (p:=p) (t:=t) (n:=n) (d:=d)) | |
| (hone : Good β ctx.u ctx.J one) (hseed : Good β ctx.u ctx.J seed) | |
| (hi : β v, Good β ctx.u ctx.J (incidence v)) | |
| (ls : List (SAT.Literal (Fin n))) (a : Factor.Data) | |
| (hlow : β i, a.stacks (Clause.callerStacks (Memory.lowPort i)) = low ctx i) | |
| (hsource : a.stacks 63 = Encoding.encodeList id (ls.map Clause.literalBits)) | |
| (htable : a.stacks 62 = Squarefree.Program.lookupRecords (Cost.entries incidence)) | |
| (honeTape : a.stacks 69 = Product.bytes one) | |
| (hminus : a.stacks 76 = RingProgram.flat minus) | |
| (hwork : β i β FactorServices.clauseScratch, a.stacks (Clause.callerStacks i) = []) | |
| (hseedTape : a.stacks 151 = Product.bytes seed) (htmp : a.stacks 159 = []) : | |
| let budget := serviceBudget (baseWidth p t) d n ctx.u ctx.J ls.length 0 0 | |
| let result := Product.run p t ctx.modulus ctx.cache ctx.table ctx.u ctx.J seed | |
| (FactorServices.clauseResult ctx minus one incidence ls) [] | |
| let program := compiled markedArithmetic 63 151 | |
| β steps b, steps β€ budget β§ Good β ctx.u ctx.J result β§ | |
| Eval markedArithmetic steps a b β§ | |
| b.stacks = Function.update (Function.update (Function.update | |
| (Function.update a.stacks 63 []) 67 []) 62 []) 151 (Product.bytes result) β§ | |
| Trace program (steps + 1) (a.withPC (some program.entry)) (b.withPC none) β§ | |
| β prefixSteps intermediate, prefixSteps β€ steps + 1 β | |
| Trace program prefixSteps (a.withPC (some program.entry)) intermediate β | |
| dataBits intermediate β€ stackBits a.stacks + budget + 1 := by | |
| dsimp only | |
| obtain β¨steps, b, hs, he, hbβ© := Factor.marked_value_eval ctx minus one seed incidence | |
| (Cost.entries incidence) | |
| (incidenceEntries_lookup (fun (_ : Unit) v => Product.bytes (incidence v)) ()) | |
| ls a hlow hsource htable honeTape hminus hwork hseedTape htmp | |
| rw [htable] at hs | |
| have hbound := hs.trans (markedWork_polynomial ctx minus one seed incidence hone hseed hi ls) | |
| have hgood := product_good p t ctx.modulus ctx.cache ctx.table β ctx.u ctx.J seed _ hseed | |
| (clauseResult_good ctx minus one incidence hone hi ls) | |
| refine β¨steps, b, hbound, hgood, he, hb, compiled_halt_trace he 63 151, ?_β© | |
| intro prefixSteps intermediate hp htrace | |
| have hgrowth := trace_dataBits (compiled markedArithmetic 63 151) htrace | |
| change dataBits intermediate β€ stackBits a.stacks + prefixSteps at hgrowth | |
| omega | |
| end OAI.Algorithms.SubexponentialSAT.SqrtLogSpace.FactorEvaluationSpace | |