Download data/lean/OAI/Computability/Scheduling/PolynomialLists.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 8.93 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/Scheduling/PolynomialLists.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/Scheduling/PolynomialLists.lean
-
curl -L -o PolynomialLists.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/Scheduling/PolynomialLists.lean
8.93 kB
| import OAI.Computability.Scheduling.PolynomialLoops | |
| namespace OAI | |
| universe u1 u2 u3 u4 u5 u6 u7 u8 u9 u10 u11 u12 u13 u14 u15 u16 | |
| section | |
| namespace ThreeMachine.StackCompiler | |
| @[simp] theorem volume_block {n : β} (b : Algorithm.Block (Fin n)) : | |
| volume b = volume b.length+volume b.time+1 := by | |
| change volume (b.length,b.time) = _ | |
| rw [volume_pair] | |
| theorem block_length_le_volume {n : β} (b : Algorithm.Block (Fin n)) : b.length β€ volume b := by | |
| rw [volume_block,volume_nat]; omega | |
| theorem block_time_volume_le {n : β} (b : Algorithm.Block (Fin n)) : volume b.time β€ volume b := by | |
| rw [volume_block]; omega | |
| namespace Poly | |
| variable {J : Type u1} {s n : J β β} {d e : β} | |
| theorem blockLength (b : β j, Algorithm.Block (Fin (n j))) | |
| (h : Poly s (fun j => volume (b j)) d) : Poly s (fun j => (b j).length) d := | |
| of_le (fun j => block_length_le_volume (b j)) h | |
| theorem blockTime (b : β j, Algorithm.Block (Fin (n j))) | |
| (h : Poly s (fun j => volume (b j)) d) : Poly s (fun j => volume (b j).time) d := | |
| of_le (fun j => block_time_volume_le (b j)) h | |
| theorem volumeBlock (b : β j, Algorithm.Block (Fin (n j))) | |
| (hl : Poly s (fun j => (b j).length) d) | |
| (ht : Poly s (fun j => volume (b j).time) e) : Poly s (fun j => volume (b j)) (Max.max d e) := by | |
| simp only [volume_block,volume_nat] | |
| poly_bound | |
| variable {Ξ± : J β Type u2} {Ξ² : J β Type u3} [β j, Coding (Ξ± j)] [β j, Coding (Ξ² j)] | |
| theorem volumeFst (p : β j, Ξ± j Γ Ξ² j) (h : Poly s (fun j => volume (p j)) d) : | |
| Poly s (fun j => volume (p j).1) d := of_le (fun j => by rw [volume_prod]; omega) h | |
| theorem volumeSnd (p : β j, Ξ± j Γ Ξ² j) (h : Poly s (fun j => volume (p j)) d) : | |
| Poly s (fun j => volume (p j).2) d := of_le (fun j => by rw [volume_prod]; omega) h | |
| omit [β j, Coding (Ξ² j)] in | |
| theorem volumeOption (o : β j, Option (Ξ± j)) {v : J β β} | |
| (h : Poly s v d) (hv : β j, β a β o j, volume a β€ v j) : Poly s (fun j => volume (o j)) d := by | |
| apply of_le (fun j => volume_option_le (o j) (v j) (hv j)) | |
| poly_bound | |
| omit [β j, Coding (Ξ² j)] in | |
| theorem volumeOptionSome (a : β j, Ξ± j) (h : Poly s (fun j => volume (a j)) d) : | |
| Poly s (fun j => volume (some (a j))) d := by simp only [volume_some]; poly_bound | |
| omit [β j, Coding (Ξ² j)] in | |
| theorem volumeOptionNone (s : J β β) : Poly s (fun j => volume (none : Option (Ξ± j))) 0 := by | |
| simp only [volume_none]; exact const s 1 | |
| end Poly | |
| end ThreeMachine.StackCompiler | |
| end | |
| section | |
| namespace ThreeMachine.StackCompiler.Poly | |
| variable {I : Type u4} {J : Type u5} {s : J β β} | |
| variable {Ξ± : I β Type u6} {Ξ² : I β Type u7} {Ξ³ : I β Type u8} [β i, Coding (Ξ± i)] [β i, Coding (Ξ² i)] [β i, Coding (Ξ³ i)] | |
| variable (idx : J β I) (xs : β j, List (Ξ± (idx j))) (e : β j, Ξ³ (idx j)) | |
| theorem flatMapTime {f : β i, Ξ± i Γ Ξ³ i β List (Ξ² i)} (R : Uniform f) {l t vx ve v : β} | |
| (hl : Poly s (fun j => (xs j).length) l) | |
| (ht : Poly (fun p : Pool idx xs => s p.1) | |
| (fun p => R.time (idx p.1) (p.2.1,e p.1)) t) | |
| (hx : Poly s (fun j => volume (xs j)) vx) | |
| (he : Poly s (fun j => volume (e j)) ve) | |
| (hv : Poly (fun p : Pool idx xs => s p.1) | |
| (fun p => volume (f (idx p.1) (p.2.1,e p.1))) v) : | |
| Poly s (fun j => R.flatMap.time (idx j) (xs j,e j)) | |
| (l+v+Max.max t (Max.max vx (Max.max ve (l+v)))) := by | |
| have hm := volumeMap idx xs e (Ξ² := fun i => List (Ξ² i)) hl hv | |
| have hfV : Poly s (fun j => volume ((xs j).flatMap (fun a => f (idx j) (a,e j)))) (l+v) := by | |
| have hv (j : J) : volume ((xs j).flatMap (fun a => f (idx j) (a,e j))) β€ | |
| volume ((xs j).map (fun a => f (idx j) (a,e j))) := by | |
| rw [volume_flatten,β List.flatMap_def] | |
| omega | |
| exact of_le hv hm | |
| have hf := lengthVolume _ hfV | |
| obtain β¨C,hCβ© := ht | |
| have hT := powerBase s C t | |
| apply of_le (fun j => Uniform.time_flatMap R (idx j) (xs j) (e j) | |
| (C*(s j+2)^t) (fun a ha => hC β¨j,β¨a,haβ©β©)) | |
| poly_bound | |
| variable (o : β j, Option (Ξ± (idx j))) | |
| theorem optionMapTime {f : β i, Ξ± i Γ Ξ³ i β Ξ² i} (R : Uniform f) {t vo ve v : β} | |
| (ht : Poly (fun p : Pool idx (fun j => (o j).toList) => s p.1) | |
| (fun p => R.time (idx p.1) (p.2.1,e p.1)) t) | |
| (ho : Poly s (fun j => volume (o j)) vo) | |
| (he : Poly s (fun j => volume (e j)) ve) | |
| (hv : Poly (fun p : Pool idx (fun j => (o j).toList) => s p.1) | |
| (fun p => volume (f (idx p.1) (p.2.1,e p.1))) v) : | |
| Poly s (fun j => R.optionMap.time (idx j) (o j,e j)) (Max.max t (Max.max vo (Max.max ve v))) := by | |
| obtain β¨C,hCβ© := ht | |
| obtain β¨D,hDβ© := hv | |
| have hT := powerBase s C t | |
| have hV := powerBase s D v | |
| apply of_le (fun j => Uniform.time_optionMap R (idx j) (o j) (e j) | |
| (C*(s j+2)^t) (D*(s j+2)^v) (fun a ha => hC β¨j,β¨a,by simpa using haβ©β©) | |
| (fun a ha => hD β¨j,β¨a,by simpa using haβ©β©)) | |
| poly_bound | |
| end ThreeMachine.StackCompiler.Poly | |
| namespace ThreeMachine.StackCompiler.Poly | |
| variable {J : Type u9} {s : J β β} {d e : β} {Ξ± : J β Type u10} {Ξ² : J β Type u11} | |
| variable [β j, Coding (Ξ± j)] [β j, Coding (Ξ² j)] | |
| omit [β j, Coding (Ξ± j)] [β j, Coding (Ξ² j)] in | |
| theorem lengthOption (o : β j, Option (Ξ± j)) : Poly s (fun j => (o j).toList.length) 0 := | |
| of_le (fun j => by cases o j <;> simp) (const s 1) | |
| omit [β j, Coding (Ξ² j)] in | |
| theorem volumeIte (p : J β Prop) [β j, Decidable (p j)] (a b : β j, Ξ± j) | |
| (ha : Poly s (fun j => volume (a j)) d) (hb : Poly s (fun j => volume (b j)) e) : | |
| Poly s (fun j => volume (if p j then a j else b j)) (Max.max d e) := by | |
| convert iteNat p ha hb using 1 | |
| funext j; split <;> rfl | |
| omit [β j, Coding (Ξ± j)] in | |
| theorem volumeOptionMap (f : β j, Ξ± j β Ξ² j) (o : β j, Option (Ξ± j)) | |
| (h : Poly (fun p : ListPool (fun j => (o j).toList) => s p.1) | |
| (fun p => volume (f p.1 p.2.1)) d) : Poly s (fun j => volume ((o j).map (f j))) d := by | |
| obtain β¨C,hCβ© := h | |
| apply volumeOption _ (powerBase s C d) | |
| intro j b hb | |
| cases ho : o j with | |
| | none => simp [ho] at hb | |
| | some a => | |
| have he : f j a = b := by simpa [ho] using hb | |
| subst b | |
| exact hC β¨j,β¨a,by simp [ho]β©β© | |
| end ThreeMachine.StackCompiler.Poly | |
| namespace ThreeMachine.StackCompiler.Poly | |
| variable {J : Type u12} {s : J β β} {d : β} {K V : J β Type} | |
| variable [β j, Coding (K j)] [β j, Coding (V j)] [β j, DecidableEq (K j)] | |
| theorem volumeLookup (xs : β j, List (K j Γ V j)) (k : β j, K j) | |
| (h : Poly s (fun j => volume (xs j)) d) : | |
| Poly s (fun j => volume (Algorithm.lookup (xs j) (k j))) d := by | |
| apply volumeOption _ h | |
| intro j v hv | |
| have h := volume_mem_le (Algorithm.lookup_mem hv) | |
| rw [volume_prod] at h | |
| dsimp only at h | |
| omega | |
| end ThreeMachine.StackCompiler.Poly | |
| namespace ThreeMachine.StackCompiler.Poly | |
| variable {J : Type u13} {s : J β β} {d : β} {Ξ± : J β Type u14} [β j, Coding (Ξ± j)] | |
| theorem volumeOptionToList (o : β j, Option (Ξ± j)) | |
| (h : Poly s (fun j => volume (o j)) d) : | |
| Poly s (fun j => volume (o j).toList) d := by | |
| simpa only [volume_optionToList] using h | |
| end ThreeMachine.StackCompiler.Poly | |
| end | |
| section | |
| namespace ThreeMachine.StackCompiler.Poly | |
| variable {J : Type u15} {s : J β β} {d e : β} {Ξ± : J β Type u16} | |
| theorem lengthCons (a : β j, Ξ± j) (xs : β j, List (Ξ± j)) | |
| (h : Poly s (fun j => (xs j).length) d) : | |
| Poly s (fun j => (a j :: xs j).length) d := by | |
| simp only [List.length_cons]; poly_bound | |
| theorem lengthTail (xs : β j, List (Ξ± j)) | |
| (h : Poly s (fun j => (xs j).length) d) : | |
| Poly s (fun j => (xs j).tail.length) d := | |
| of_le (fun j => by simp only [List.length_tail]; omega) h | |
| theorem lengthTake (k : J β β) (xs : β j, List (Ξ± j)) | |
| (h : Poly s (fun j => (xs j).length) d) : | |
| Poly s (fun j => ((xs j).take (k j)).length) d := | |
| of_le (fun j => (List.take_sublist (k j) (xs j)).length_le) h | |
| theorem lengthDrop (k : J β β) (xs : β j, List (Ξ± j)) | |
| (h : Poly s (fun j => (xs j).length) d) : | |
| Poly s (fun j => ((xs j).drop (k j)).length) d := | |
| of_le (fun j => (List.drop_sublist (k j) (xs j)).length_le) h | |
| theorem lengthReverse (xs : β j, List (Ξ± j)) | |
| (h : Poly s (fun j => (xs j).length) d) : | |
| Poly s (fun j => (xs j).reverse.length) d := by simpa only [List.length_reverse] using h | |
| theorem lengthAppend (xs ys : β j, List (Ξ± j)) | |
| (hx : Poly s (fun j => (xs j).length) d) (hy : Poly s (fun j => (ys j).length) e) : | |
| Poly s (fun j => (xs j ++ ys j).length) (Max.max d e) := by | |
| simpa only [List.length_append] using hx.add hy | |
| theorem lengthRange (k : J β β) (h : Poly s k d) : | |
| Poly s (fun j => (List.range (k j)).length) d := by simpa only [List.length_range] using h | |
| theorem lengthReplicate (k : J β β) (a : β j, Ξ± j) (h : Poly s k d) : | |
| Poly s (fun j => (List.replicate (k j) (a j)).length) d := by simpa only [List.length_replicate] using h | |
| end ThreeMachine.StackCompiler.Poly | |
| end | |
| end OAI | |