Download data/lean/OAI/RepresentationTheory/UniversalSquare/Support/RowChecker.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 4.54 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/RepresentationTheory/UniversalSquare/Support/RowChecker.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/RepresentationTheory/UniversalSquare/Support/RowChecker.lean
-
curl -L -o RowChecker.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/RepresentationTheory/UniversalSquare/Support/RowChecker.lean
4.54 kB
| import Mathlib | |
| import OAI.RepresentationTheory.Saxl.Main | |
| import OAI.RepresentationTheory.UniversalSquare.Support.ResidualTrees | |
| namespace OAI | |
| /-! Row Checker. -/ | |
| section | |
| namespace UniversalTensorSquare | |
| def quickRejected (fuel n upper : β) (A B : List (β Γ β)) : Bool := | |
| decide (n < fuel) || decide (fuel*upper < n) || | |
| A.any (fun p => decide (0 < p.1) && decide (p.2 < fuel)) || | |
| B.any (fun p => decide (fuel β€ p.1) && decide (p.2 < n)) || | |
| A.any (fun p => decide (p.2*upper < n*min p.1 upper)) || | |
| B.any (fun p => decide (p.2*fuel < n*min p.1 fuel)) | |
| lemma quickRejected_iff (fuel n upper : β) (A B : List (β Γ β)) : | |
| quickRejected fuel n upper A B = true β rejectedRows fuel n upper A B := by | |
| simp only [quickRejected,rejectedRows,Bool.or_eq_true,Bool.and_eq_true, | |
| List.any_eq_true,decide_eq_true_eq] | |
| simp only [or_assoc] | |
| def quickAllowed (a : β) (A B : List (β Γ β)) : Bool := | |
| A.all (fun p => decide (min p.1 a β€ p.2)) && | |
| B.all (fun p => decide (p.1 = 0) || decide (a β€ p.2)) | |
| lemma quickAllowed_iff (a : β) (A B : List (β Γ β)) : | |
| quickAllowed a A B = true β allowedRow a A B := by | |
| simp only [quickAllowed,allowedRow,Bool.and_eq_true,List.all_eq_true, | |
| Bool.or_eq_true,decide_eq_true_eq] | |
| constructor | |
| Β· rintro β¨hA,hBβ© | |
| refine β¨hA,fun p hp hk => ?_β© | |
| obtain h | h := hB p hp | |
| Β· omega | |
| Β· exact h | |
| Β· rintro β¨hA,hBβ© | |
| refine β¨hA,fun p hp => ?_β© | |
| by_cases hz : p.1 = 0 | |
| Β· exact Or.inl hz | |
| Β· exact Or.inr (hB p hp (by omega)) | |
| def checkRowPrefixes (P : List β β Bool) : β β β β β β | |
| List (β Γ β) β List (β Γ β) β List β β Bool | |
| | fuel,n,upper,A,B,pref => | |
| if quickRejected fuel n upper A B then true else | |
| match fuel with | |
| | 0 => if n = 0 then P pref.reverse else true | |
| | k+1 => | |
| let lo := max 1 (n/(k+1)) | |
| (List.range' lo (min n upper+1-lo)).all fun a => | |
| if quickAllowed a A B && decide (n β€ (k+1)*a) then | |
| checkRowPrefixes P k (n-a) a (clipBudget A a) (rowBudget B a) (a::pref) | |
| else true | |
| lemma checkRowPrefixes_sound (P : List β β Bool) (fuel n upper : β) | |
| (A B : List (β Γ β)) (pref : List β) | |
| (hc : checkRowPrefixes P fuel n upper A B pref = true) : | |
| β rs β constrainedRows fuel n upper A B, P (pref.reverse ++ rs) = true := by | |
| induction fuel generalizing n upper A B pref with | |
| | zero => | |
| intro rs hrs | |
| rw [constrainedRows] at hrs | |
| split_ifs at hrs with hrej hn | |
| Β· simp at hrs | |
| Β· simp only [List.mem_singleton] at hrs | |
| subst rs | |
| simpa only [checkRowPrefixes, quickRejected_iff, ite_eq_right hrej, ite_eq_left hn, List.append_nil] using hc | |
| Β· simp at hrs | |
| | succ k ih => | |
| intro rs hrs | |
| rw [constrainedRows] at hrs | |
| split_ifs at hrs with hrej | |
| Β· simp at hrs | |
| Β· obtain β¨a,ha,hrβ© := List.mem_flatMap.mp hrs | |
| split_ifs at hr with hallowed | |
| Β· obtain β¨ys,hy,rflβ© := List.mem_map.mp hr | |
| have hlo : max 1 (n/(k+1)) β€ a := by | |
| have hh := Nat.div_le_of_le_mul hallowed.2 | |
| have ha' := (List.mem_range'_1.mp ha).1 | |
| exact max_le ha' hh | |
| have hai : a β List.range' (max 1 (n/(k+1))) | |
| (min n upper+1-max 1 (n/(k+1))) := by | |
| have ha' := List.mem_range'_1.mp ha | |
| apply List.mem_range'_1.mpr | |
| refine β¨hlo, ?_β© | |
| have he : max 1 (n/(k+1)) + (min n upper+1-max 1 (n/(k+1))) = min n upper+1 := by | |
| apply Nat.add_sub_of_le | |
| omega | |
| rw [he] | |
| omega | |
| rw [checkRowPrefixes] at hc | |
| simp only [quickRejected_iff, ite_eq_right hrej] at hc | |
| have hh := List.all_eq_true.mp hc a hai | |
| simp only [Bool.and_eq_true,quickAllowed_iff,decide_eq_true_eq,ite_eq_left hallowed] at hh | |
| have hi := ih (n-a) a (clipBudget A a) (rowBudget B a) (a::pref) hh ys hy | |
| simpa only [List.reverse_cons, List.append_assoc, List.singleton_append] using hi | |
| Β· simp at hr | |
| lemma checked_constrainedRows (P : List β β Prop) [DecidablePred P] | |
| (fuel n upper : β) (A B : List (β Γ β)) | |
| (h : checkRowPrefixes (fun rs => decide (P rs)) fuel n upper A B [] = true) : | |
| β rs β constrainedRows fuel n upper A B, P rs := by | |
| intro rs hrs | |
| have hh := checkRowPrefixes_sound (fun rs => decide (P rs)) fuel n upper A B [] h rs hrs | |
| simp only [List.reverse_nil,List.nil_append] at hh | |
| exact of_decide_eq_true hh | |
| end UniversalTensorSquare | |
| end | |
| end OAI | |