Download data/lean/OAI/Combinatorics/EditApproximation/Binary/BinaryCutReads.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.17 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/EditApproximation/Binary/BinaryCutReads.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/EditApproximation/Binary/BinaryCutReads.lean
-
curl -L -o BinaryCutReads.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/EditApproximation/Binary/BinaryCutReads.lean
5.17 kB
| import OAI.Combinatorics.EditApproximation.Binary.BinaryPrefixReads | |
| import OAI.Combinatorics.EditApproximation.Binary.BinaryBandGuardWork | |
| import OAI.Combinatorics.EditApproximation.Definitions | |
| namespace OAI | |
| /-! Literal cut predicates and all-cut loops with costed child readers. -/ | |
| namespace EditApproximation | |
| theorem allWithWork_extra {Ξ± : Type*} (read plain : Ξ± β Bool Γ β) (extra : Ξ± β β) | |
| (xs : List Ξ±) (hv : β x β xs, (read x).1 = (plain x).1) | |
| (hc : β x β xs, (read x).2 β€ (plain x).2 + extra x) : | |
| (allWithWork read xs).1 = (allWithWork plain xs).1 β§ | |
| (allWithWork read xs).2 β€ (allWithWork plain xs).2 + (xs.map extra).sum := by | |
| have costBound (a a' b b' A B : β) (ha : a β€ a' + A) (hb : b β€ b' + B) : | |
| a + b + 3 β€ a' + b' + 3 + (A + B) := by | |
| omega | |
| induction xs with | |
| | nil => exact β¨rfl, Nat.le_refl _β© | |
| | cons x xs ih => | |
| have hh := hv x List.mem_cons_self | |
| have hhCost := hc x List.mem_cons_self | |
| have ht := ih (fun y hy => hv y (List.mem_cons_of_mem _ hy)) | |
| (fun y hy => hc y (List.mem_cons_of_mem _ hy)) | |
| constructor | |
| Β· change ((read x).1 && (allWithWork read xs).1) = | |
| ((plain x).1 && (allWithWork plain xs).1) | |
| rw [hh, ht.1] | |
| Β· change (read x).2 + (allWithWork read xs).2 + 3 β€ | |
| (plain x).2 + (allWithWork plain xs).2 + 3 + (extra x + (xs.map extra).sum) | |
| exact costBound _ _ _ _ _ _ hhCost ht.2 | |
| namespace BinaryFraction | |
| theorem cutGuardReadWithWork_eq {nx ny M : β} (parent : TargetInterval nx) (r : TargetInterval ny) | |
| (actions : List (Fin M β TargetInterval ny)) (hne : actions β []) | |
| (read : Fin M β TargetInterval ny β BinaryFraction Γ β) (states : Fin M β TargetInterval ny) | |
| (velocity tolerance : BinaryFraction) (j : Fin M) : | |
| (cutGuardReadWithWork parent r actions hne read states velocity tolerance j).1 = | |
| (cutGuardWithWork parent r actions hne (fun i q => (read i q).1) states velocity tolerance j).1 := by | |
| simp only [cutGuardReadWithWork, cutGuardWithWork] | |
| split_ifs | |
| Β· rfl | |
| Β· simp only [prefixMinimumReadWithWork_eq] | |
| theorem cutGuardReadWithWork_cost {nx ny M : β} (parent : TargetInterval nx) (r : TargetInterval ny) | |
| (actions : List (Fin M β TargetInterval ny)) (hne : actions β []) | |
| (read : Fin M β TargetInterval ny β BinaryFraction Γ β) (states : Fin M β TargetInterval ny) | |
| (velocity tolerance : BinaryFraction) (j : Fin M) (R : β) | |
| (hr : β action β actions, β i, (read i (action i)).2 β€ R) : | |
| (cutGuardReadWithWork parent r actions hne read states velocity tolerance j).2 β€ | |
| (cutGuardWithWork parent r actions hne (fun i q => (read i q).1) states velocity tolerance j).2 + | |
| (actions.length + 1) * (M * (R + 4)) := by | |
| have costBound (s o p p' v u w x y A : β) (hp : p β€ p' + A) : | |
| s + o + p + v + u + w + x + y + 5 β€ s + o + p' + v + u + w + x + y + 5 + A := by | |
| omega | |
| unfold cutGuardReadWithWork cutGuardWithWork | |
| split_ifs | |
| Β· exact Nat.le_add_right _ _ | |
| Β· have h := prefixMinimumReadWithWork_cost parent r actions hne read j.val | |
| (subWithWork (nat (states j).lo) (nat (sourceChild parent j).lo)).1 R hr | |
| dsimp only | |
| rw [prefixMinimumReadWithWork_eq] | |
| exact costBound _ _ _ _ _ _ _ _ _ _ h | |
| theorem bandPredicateReadWithWork_eq_cost {nx ny M : β} | |
| (parent : TargetInterval nx) (r : TargetInterval ny) (b : β) (tau theta velocity : BinaryFraction) | |
| (actions : List (Fin M β TargetInterval ny)) (hne : actions β []) | |
| (read : Fin M β TargetInterval ny β BinaryFraction Γ β) (states : Fin M β TargetInterval ny) | |
| (R : β) (hr : β action β actions, β i, (read i (action i)).2 β€ R) : | |
| (bandPredicateReadWithWork parent r b tau theta velocity actions hne read states).1 = | |
| (bandPredicateWithWork parent r b tau theta velocity actions hne | |
| (fun i q => (read i q).1) states).1 β§ | |
| (bandPredicateReadWithWork parent r b tau theta velocity actions hne read states).2 β€ | |
| (bandPredicateWithWork parent r b tau theta velocity actions hne | |
| (fun i q => (read i q).1) states).2 + M * ((actions.length + 1) * (M * (R + 4))) := by | |
| have costBound (c a t k k' A : β) (hk : k β€ k' + A) : | |
| c + a + t + k + 4 β€ c + a + t + k' + 4 + A := by | |
| omega | |
| have h := allWithWork_extra | |
| (cutGuardReadWithWork parent r actions hne read states velocity (bandToleranceWithWork tau theta b M).1) | |
| (cutGuardWithWork parent r actions hne (fun i q => (read i q).1) states velocity | |
| (bandToleranceWithWork tau theta b M).1) | |
| (fun _ => (actions.length + 1) * (M * (R + 4))) (List.finRange M) | |
| (fun i _ => cutGuardReadWithWork_eq parent r actions hne read states velocity _ i) | |
| (fun i _ => cutGuardReadWithWork_cost parent r actions hne read states velocity _ i R hr) | |
| simp only [List.map_const', List.length_finRange, List.sum_replicate, smul_eq_mul] at h | |
| constructor | |
| Β· simp only [bandPredicateReadWithWork, bandPredicateWithWork, h.1] | |
| Β· unfold bandPredicateReadWithWork bandPredicateWithWork | |
| dsimp only | |
| exact costBound _ _ _ _ _ _ h.2 | |
| end BinaryFraction | |
| end EditApproximation | |
| end OAI | |