Download data/lean/OAI/Computability/RandomMean/Allocation.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.05 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/RandomMean/Allocation.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/RandomMean/Allocation.lean
-
curl -L -o Allocation.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/RandomMean/Allocation.lean
7.05 kB
| import OAI.Computability.RandomMean.Loop | |
| namespace OAI | |
| section | |
| namespace MeanPayoff.TreeDevice.Certified | |
| open BinaryData Code | |
| local infixl:80 " β«β " => Code.comp | |
| local infixr:70 " ββ " => Code.pair | |
| namespace Counter | |
| noncomputable def fixedPower : β β Code Count Count | |
| | 0 => const [()] | |
| | k+1 => (Code.id ββ fixedPower k) β«β mul | |
| @[simp] theorem fixedPower_length (k : β) (c : Count) : (fixedPower k c).length=c.length^k := by | |
| induction k with | |
| | zero => rfl | |
| | succ k ih => simp [fixedPower,ih,pow_succ,Nat.mul_comm] | |
| end Counter | |
| namespace RootCode | |
| open InputCode | |
| noncomputable def g : Code Parsed Count := width β«β NaturalLog.length β«β Counter.inc β«β Counter.inc | |
| noncomputable def argument : Code Parsed Count := (const (List.replicate (2^17) ()) ββ g) β«β Counter.mul | |
| noncomputable def exponent : Code Parsed Count := argument β«β Counter.word β«β NaturalLog.ceil | |
| noncomputable def cap : Code Parsed Count := (argument ββ argument) β«β Counter.add | |
| noncomputable def samples : Code Parsed Count := (exponent ββ cap) β«β Counter.power | |
| noncomputable def trialBase : Code Parsed Count := (samples ββ (n β«β Counter.inc)) β«β Counter.mul β«β Counter.fixedPower 6 | |
| noncomputable def trials : Code Parsed Count := (trialBase ββ trialBase) β«β Counter.add β«β Counter.inc | |
| noncomputable def basic : Code Parsed Count := (n ββ ((const (List.replicate 128 ()) ββ samples) β«β Counter.mul)) β«β Counter.mul | |
| noncomputable def env : Code Parsed RawControl.Env := rows ββ exponent ββ samples ββ trials ββ basic | |
| theorem g_length (G : Game) : (g (game G)).length=globalG (topWidth G).toNat+1 := by | |
| change (NaturalLog.length (width (game G))).length+1+1=_ | |
| rw [NaturalLog.length_exact _ (by rw [width_val]; exact (topWidth_positive G).le),width_val] | |
| unfold globalG | |
| omega | |
| theorem argument_length (G : Game) : (argument (game G)).length=2^17*(globalG (topWidth G).toNat+1) := by | |
| simp only [argument,comp_eval,pair_eval,const_eval,Counter.mul_length,List.length_replicate,g_length] | |
| theorem exponent_length (G : Game) : (exponent (game G)).length=sampleExponent (topWidth G).toNat := by | |
| change (NaturalLog.ceil (Counter.word (argument (game G)))).length=_ | |
| rw [NaturalLog.ceil_exact _ (by rw [Counter.word_val]; exact_mod_cast (show 0<(argument (game G)).length by rw [argument_length]; positivity)),Counter.word_val,Int.toNat_natCast,argument_length] | |
| rfl | |
| theorem samples_length (G : Game) : (samples (game G)).length=globalS (topWidth G).toNat := by | |
| change (Counter.power (exponent (game G),cap (game G))).length=_ | |
| rw [Counter.power_exact] | |
| Β· rw [List.length_replicate,exponent_length] | |
| rfl | |
| Β· change 2^(exponent (game G)).length β€ (Counter.add (argument (game G),argument (game G))).length | |
| rw [Counter.add_length,exponent_length,argument_length] | |
| have h := Counter.pow_clog_le (2^17*(globalG (topWidth G).toNat+1)) (by positivity) | |
| change 2^Nat.clog 2 (2^17*(globalG (topWidth G).toNat+1)) β€ _ | |
| simpa only [two_mul] using h | |
| theorem trials_length (G : Game) : (trials (game G)).length=globalJ G.n (topWidth G).toNat := by | |
| simp only [trials,trialBase,comp_eval,pair_eval,Counter.inc_length,Counter.add_length,Counter.fixedPower_length,Counter.mul_length,n_game,List.length_replicate,samples_length] | |
| unfold globalJ | |
| omega | |
| theorem basic_length (G : Game) : (basic (game G)).length=G.n*(128*globalS (topWidth G).toNat) := by | |
| simp only [basic,comp_eval,pair_eval,Counter.mul_length,const_eval,List.length_replicate,n_game,samples_length] | |
| theorem env_rep (G : Game) : RawControl.EnvRep G (topWidth G).toNat (env (game G)) := by | |
| refine β¨β¨Normalize.word G,rows_game G,Normalize.word_val Gβ©,exponent_length G,samples_length G,trials_length G,?_β© | |
| exact (basic_length G).ge | |
| end RootCode | |
| end MeanPayoff.TreeDevice.Certified | |
| end | |
| section | |
| namespace MeanPayoff.TreeDevice.Certified | |
| open BinaryData Code | |
| local infixl:80 " β«β " => Code.comp | |
| local infixr:70 " ββ " => Code.pair | |
| namespace RootCode | |
| open InputCode | |
| noncomputable def ones : Code Parsed (List W) := n β«β map (Word.constant 1) | |
| noncomputable def budgets : Code Parsed RawBudget.Data := | |
| ((n β«β Counter.word) ββ Word.constant 1) ββ | |
| ((n β«β Counter.word) ββ Word.constant 1) ββ ones ββ ones | |
| noncomputable def box : Code Parsed RawBox.Data := | |
| width ββ (n β«β map (Word.constant 0)) ββ ((width ββ n) β«β envMap (fst : Code (WΓUnit) W)) | |
| noncomputable def state : Code Parsed RawControl.State := | |
| RawControl.call 0 (RawControl.pack budgets box) (const []) | |
| noncomputable def start : Code Digits (WΓRawControl.Acc) := | |
| parse β«β (width ββ (env ββ state)) | |
| theorem budgets_rep (G : Game) : RawBudget.Rep (rootBudgets G) (budgets (game G)) := by | |
| have hn : (Counter.word (n (game G))).val=G.n := by simp | |
| have hx : ones (game G)=List.ofFn (fun _ : Fin G.n => EdgeRead.encodedWord 1) := by | |
| change (List.replicate G.n ()).map (fun _ => EdgeRead.encodedWord 1)=_ | |
| simp [List.ofFn_const] | |
| refine β¨?_,?_,?_,?_,?_,?_,?_β© | |
| Β· change 0<(Counter.word (n (game G))).val | |
| rw [hn]; exact_mod_cast G.positive | |
| Β· change 0<(Word.constant 1 (game G)).val | |
| simp | |
| Β· change 0<(Counter.word (n (game G))).val | |
| rw [hn]; exact_mod_cast G.positive | |
| Β· change 0<(Word.constant 1 (game G)).val | |
| simp | |
| Β· change (G.n : β)=(Counter.word (n (game G))).val/(Word.constant 1 (game G)).val | |
| simp | |
| Β· change (G.n : β)=(Counter.word (n (game G))).val/(Word.constant 1 (game G)).val | |
| simp | |
| Β· refine β¨fun _ => EdgeRead.encodedWord 1,fun _ => EdgeRead.encodedWord 1,hx,hx,?_,?_,?_,?_β© <;> | |
| intro i <;> simp [EdgeRead.encodedWord_val,rootBudgets] | |
| theorem box_rep (G : Game) : RawBox.Rep (rootBox G) (box (game G)) := by | |
| refine β¨?_,?_,?_β© | |
| Β· change (width (game G)).val=((topWidth G).toNat : β€) | |
| rw [width_val,Int.toNat_of_nonneg (topWidth_positive G).le] | |
| Β· refine β¨fun _ => EdgeRead.encodedWord 0,?_,?_β© | |
| Β· change (List.replicate G.n ()).map (fun _ => EdgeRead.encodedWord 0)=_ | |
| simp [List.ofFn_const] | |
| Β· intro i; exact EdgeRead.encodedWord_val 0 | |
| Β· refine β¨fun _ => width (game G),?_,?_β© | |
| Β· change (List.replicate G.n ()).map (fun _ => width (game G))=_ | |
| simp [List.ofFn_const] | |
| Β· intro i; exact width_val G | |
| theorem state_rep (G : Game) : RawControl.StateRep | |
| (SourceControl.State.call (SourceControl.Job.solve (rootBudgets G) (rootBox G)) .done) (state (game G)) := by | |
| exact .call rfl β¨budgets_rep G,box_rep Gβ© .done | |
| end RootCode | |
| end MeanPayoff.TreeDevice.Certified | |
| end | |
| section | |
| namespace MeanPayoff.TreeDevice.Certified | |
| open BinaryData Code | |
| local infixl:80 " β«β " => Code.comp | |
| local infixr:70 " ββ " => Code.pair | |
| namespace Allocation | |
| end Allocation | |
| end MeanPayoff.TreeDevice.Certified | |
| end | |
| section | |
| namespace MeanPayoff | |
| namespace PolyBound | |
| variable {ΞΉ : Type} {r f g : ΞΉββ} | |
| end PolyBound | |
| namespace TreeDevice | |
| open BinaryData | |
| end TreeDevice | |
| end MeanPayoff | |
| end | |
| end OAI | |