Download data/lean/OAI/GroupTheory/SimpleOvergroups/EffectiveTables.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 9.24 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/GroupTheory/SimpleOvergroups/EffectiveTables.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/GroupTheory/SimpleOvergroups/EffectiveTables.lean
-
curl -L -o EffectiveTables.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/GroupTheory/SimpleOvergroups/EffectiveTables.lean
9.24 kB
| import Mathlib | |
| import OAI.Computability.FiniteCompiler.Effectivity | |
| import OAI.Computability.FiniteCompiler.Quotients | |
| import OAI.Computability.FiniteCompiler.SelfReference | |
| import OAI.GroupTheory.BooneHigman.Basic | |
| import OAI.GroupTheory.SimpleOvergroups.ContextualTables | |
| namespace OAI | |
| namespace SimpleFInftyOvergroups.ContextualEncoding | |
| open FiniteAlgebraicEnvelopes FiniteAlgebraicEnvelopes.Bootstrap | |
| namespace CodedSearch | |
| variable {A S Q : Type*} [DecidableEq S] [DecidableEq Q] | |
| variable {r : S β S β Prop} [DecidableRel (List.Shortlex r)] | |
| variable (C : DelimiterCode A S) | |
| def lt (u v : List A) : Bool := decide (List.Shortlex r (C.encode u) (C.encode v)) | |
| def compute (E : FiniteSearch C) (z : S) (f : List A β Part (Option Q)) (n : β) : | |
| Part (List (List S Γ List S)) := | |
| (Effect.traverse (fun w => (f w).map (w,Β·)) (E.words n)).map | |
| (Uniform.table C.encode (lt (r := r) C) z) | |
| variable (wf : WellFounded r) [Std.Trichotomous r] (q : List A β Option Q) | |
| omit [DecidableEq S] [Std.Trichotomous r] in | |
| theorem pick_class {ps : List (List A Γ Option Q)} {w v : List A} | |
| (hps : β p β ps, p.2 = q p.1) (hv : q v = q w) : | |
| q (Uniform.pick (lt (r := r) C) ps v (q w)) = q w := by | |
| induction ps generalizing v with | |
| | nil => exact hv | |
| | cons p ps ih => | |
| simp only [Uniform.pick, List.foldl_cons] | |
| apply ih (fun p hp => hps p (List.mem_cons_of_mem _ hp)) | |
| simp only [Uniform.pickStep] | |
| split | |
| next h => exact (hps p List.mem_cons_self).symm.trans h.1 | |
| next h => exact hv | |
| omit [DecidableEq S] in | |
| theorem pick_least_fixed {ps : List (List A Γ Option Q)} {w : List A} | |
| (hps : β p β ps, p.2 = q p.1) : | |
| Uniform.pick (lt (r := r) C) ps (EncodedCanonical.least C wf q w) (q w) = | |
| EncodedCanonical.least C wf q w := by | |
| induction ps with | |
| | nil => rfl | |
| | cons p ps ih => | |
| have hh : Β¬ (p.2 = q w β§ lt (r := r) C p.1 (EncodedCanonical.least C wf q w) = true) := by | |
| rintro β¨hq, hrβ© | |
| exact EncodedCanonical.least_global_min C wf q | |
| ((hps p List.mem_cons_self).symm.trans hq) (of_decide_eq_true hr) | |
| simp only [Uniform.pick, List.foldl_cons, Uniform.pickStep, ite_eq_right hh] | |
| exact ih (fun p hp => hps p (List.mem_cons_of_mem _ hp)) | |
| omit [DecidableEq S] in | |
| theorem pick_eq_least {ps : List (List A Γ Option Q)} {w : List A} | |
| (hps : β p β ps, p.2 = q p.1) | |
| (hm : (EncodedCanonical.least C wf q w, q w) β ps) : | |
| Uniform.pick (lt (r := r) C) ps w (q w) = EncodedCanonical.least C wf q w := by | |
| obtain β¨before, after, rflβ© := List.mem_iff_append.mp hm | |
| have hb : β p β before, p.2 = q p.1 := fun p hp => hps p (List.mem_append_left _ hp) | |
| have ha : β p β after, p.2 = q p.1 := fun p hp => | |
| hps p (List.mem_append_right _ (List.mem_cons_of_mem _ hp)) | |
| have hclass := pick_class (r := r) C q hb (w := w) rfl | |
| have hsel : Uniform.pickStep (lt (r := r) C) (q w) | |
| (Uniform.pick (lt (r := r) C) before w (q w)) | |
| (EncodedCanonical.least C wf q w, q w) = EncodedCanonical.least C wf q w := by | |
| unfold Uniform.pickStep | |
| simp only [true_and, lt, decide_eq_true_eq] | |
| split | |
| Β· rfl | |
| next h => | |
| apply C.encode_injective | |
| exact Std.Trichotomous.trichotomous _ _ | |
| (EncodedCanonical.least_global_min C wf q hclass) h | |
| simp only [Uniform.pick, List.foldl_append, List.foldl_cons] | |
| change after.foldl (Uniform.pickStep (lt (r := r) C) (q w)) | |
| (Uniform.pickStep (lt (r := r) C) (q w) | |
| (Uniform.pick (lt (r := r) C) before w (q w)) | |
| (EncodedCanonical.least C wf q w, q w)) = _ | |
| rw [hsel] | |
| exact pick_least_fixed C wf q ha | |
| variable (E : FiniteSearch C) (z : S) | |
| omit [DecidableEq S] in | |
| theorem output_full {n : β} {w : List A} (hw : (C.encode w).length β€ n) : | |
| Uniform.output C.encode (lt (r := r) C) z | |
| ((E.words n).map fun v => (v,q v)) (w,q w) = CodeTable.output C wf q z w := by | |
| have hps : β p β (E.words n).map (fun v => (v,q v)), p.2 = q p.1 := by | |
| intro p hp | |
| obtain β¨v, _, rflβ© := List.mem_map.mp hp | |
| rfl | |
| have hm : (EncodedCanonical.least C wf q w, q w) β (E.words n).map (fun v => (v,q v)) := | |
| List.mem_map.mpr β¨EncodedCanonical.least C wf q w, (E.mem_words _ _).mpr | |
| ((EncodedCanonical.least_length C wf q w).trans hw), by simp [EncodedCanonical.least_class]β© | |
| simp only [Uniform.output, CodeTable.output, pick_eq_least C wf q hps hm] | |
| theorem table_full (n : β) : | |
| Uniform.table C.encode (lt (r := r) C) z ((E.words n).map fun v => (v,q v)) = | |
| CodeTable.table C E wf q z n := by | |
| classical | |
| unfold Uniform.table CodeTable.table | |
| rw [List.flatMap_map] | |
| have hh : β w β E.words n, | |
| (if w β [] β§ Uniform.output C.encode (lt (r := r) C) z | |
| ((E.words n).map fun v => (v,q v)) (w,q w) β C.encode w | |
| then [(C.encode w, Uniform.output C.encode (lt (r := r) C) z | |
| ((E.words n).map fun v => (v,q v)) (w,q w))] else []) = | |
| (if w β [] β§ CodeTable.output C wf q z w β C.encode w | |
| then [(C.encode w, CodeTable.output C wf q z w)] else []) := by | |
| intro w hw | |
| rw [output_full C wf q E z ((E.mem_words _ _).mp hw)] | |
| rw [List.flatMap_congr hh] | |
| have he (l : List (List A)) : | |
| l.flatMap (fun w => if w β [] β§ CodeTable.output C wf q z w β C.encode w | |
| then [(C.encode w, CodeTable.output C wf q z w)] else []) = | |
| (l.filter fun w => w β [] β§ CodeTable.output C wf q z w β C.encode w).map | |
| (fun w => (C.encode w, CodeTable.output C wf q z w)) := by | |
| induction l with | |
| | nil => rfl | |
| | cons w l ih => | |
| by_cases h : w β [] β§ CodeTable.output C wf q z w β C.encode w | |
| Β· simp only [List.flatMap_cons, List.filter_cons, decide_eq_true_eq, ite_eq_left h, | |
| List.map_cons, List.singleton_append, ih] | |
| Β· simp only [List.flatMap_cons, List.filter_cons, decide_eq_true_eq, ite_eq_right h, | |
| List.nil_append, ih] | |
| refine (he _).trans ?_ | |
| congr 1 | |
| apply List.filter_congr | |
| intro w hw | |
| apply Bool.eq_iff_iff.mpr | |
| simp only [decide_eq_true_eq] | |
| theorem compute_full {f : List A β Part (Option Q)} {n : β} | |
| (h : β w, (C.encode w).length β€ n β q w β f w) : | |
| CodeTable.table C E wf q z n β compute (r := r) C E z f n := by | |
| apply (Part.mem_map_iff _).mpr | |
| refine β¨(E.words n).map (fun w => (w,q w)), ?_, table_full C wf q E z nβ© | |
| apply Search.traverse_map | |
| intro w hw | |
| exact (Part.mem_map_iff _).mpr β¨_, h w ((E.mem_words _ _).mp hw), rflβ© | |
| omit [Std.Trichotomous r] in | |
| theorem compute_domain {f : List A β Part (Option Q)} {n : β} | |
| (hc : (compute (r := r) C E z f n).Dom) : | |
| β w, (C.encode w).length β€ n β (f w).Dom := by | |
| obtain β¨rs, hrsβ© := Part.dom_iff_mem.mp hc | |
| obtain β¨ps, hps, _β© := (Part.mem_map_iff _).mp hrs | |
| have ht := Effect.traverse_domain hps.1 | |
| intro w hw | |
| obtain β¨p, hpβ© := Part.dom_iff_mem.mp (ht w ((E.mem_words _ _).mpr hw)) | |
| obtain β¨v, hv, _β© := (Part.mem_map_iff _).mp hp | |
| exact hv.1 | |
| theorem compute_eq {f : List A β Part (Option Q)} {n : β} | |
| {rs : List (List S Γ List S)} (hc : rs β compute (r := r) C E z f n) : | |
| rs = CodeTable.table C E wf (Search.value f) z n := | |
| Part.mem_unique hc (compute_full C wf (Search.value f) E z | |
| (fun w hw => Search.value_mem (compute_domain C E z hc.1 w hw))) | |
| end CodedSearch | |
| namespace CodedProgram | |
| variable {P A S Q : Type*} | |
| [Primcodable P] [Primcodable A] [Primcodable S] [Primcodable Q] | |
| [DecidableEq S] [DecidableEq Q] | |
| def compute (words : P β β β List (List A)) (code : P β List A β List S) | |
| (lt : P β List A β List A β Bool) (z : S) | |
| (f : P β List A β Part (Option Q)) (p : P) (n : β) : | |
| Part (List (List S Γ List S)) := | |
| (Effect.traverse (fun w => (f p w).map (w,Β·)) (words p n)).map | |
| (Uniform.table (code p) (lt p) z) | |
| theorem partrec_compute (words : P β β β List (List A)) | |
| (code : P β List A β List S) (lt : P β List A β List A β Bool) (z : S) | |
| (hw : Primrecβ words) (hc : Primrecβ code) | |
| (hl : Primrec (fun x : P Γ List A Γ List A => lt x.1 x.2.1 x.2.2)) | |
| {f : P β List A β Part (Option Q)} (hf : Partrecβ f) : | |
| Partrecβ (compute words code lt z f) := by | |
| have hp : Partrecβ (fun p w => (f p w).map (w,Β·)) := | |
| (hf.map ((Computable.snd.comp Computable.fst).pair Computable.snd).toβ).toβ | |
| exact (((Effect.partrec_traverse_parameter hp).comp Computable.fst hw.to_comp).map | |
| ((Uniform.primrec_table code lt z hc hl).to_comp.comp | |
| ((Computable.fst.comp Computable.fst).pair Computable.snd)).toβ).toβ | |
| theorem partrec_search {r : S β S β Prop} [DecidableRel (List.Shortlex r)] | |
| (C : DelimiterCode A S) (E : FiniteSearch C) (z : S) | |
| (hw : Primrec E.words) (hc : Primrec C.encode) | |
| (hl : PrimrecRel (List.Shortlex r)) | |
| {f : P β List A β Part (Option Q)} (hf : Partrecβ f) : | |
| Partrecβ (fun p => CodedSearch.compute (r := r) C E z (f p)) := by | |
| apply partrec_compute (fun _ => E.words) (fun _ => C.encode) | |
| (fun _ => CodedSearch.lt (r := r) C) z (hw.comp Primrec.snd).toβ | |
| (hc.comp Primrec.snd).toβ _ hf | |
| exact hl.decide.comp | |
| (hc.comp (Primrec.fst.comp Primrec.snd)) | |
| (hc.comp (Primrec.snd.comp Primrec.snd)) | |
| end CodedProgram | |
| end SimpleFInftyOvergroups.ContextualEncoding | |
| end OAI | |