Download data/lean/OAI/MathematicalPhysics/RapidForcing/RatComputable.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 4.45 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/MathematicalPhysics/RapidForcing/RatComputable.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/MathematicalPhysics/RapidForcing/RatComputable.lean
-
curl -L -o RatComputable.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/MathematicalPhysics/RapidForcing/RatComputable.lean
4.45 kB
| import OAI.MathematicalPhysics.RapidForcing.RatPrimrec | |
| namespace OAI | |
| section | |
| open Encodable Denumerable | |
| namespace RapidForcing.EffectiveArithmetic | |
| lemma computable_of_graph {A B : Type} [Primcodable A] [Primcodable B] | |
| (f : A β B) (R : A β B β Prop) [DecidableRel R] | |
| (hR : PrimrecPred (fun p : A Γ B => R p.1 p.2)) | |
| (h : β a b, R a b β b = f a) : Computable f := by | |
| let test : A β β β Option B := fun a n => | |
| (decode n).bind fun b => if R a b then some b else none | |
| have ht : Primrecβ test := | |
| Primrec.option_bind (Primrec.decode.comp Primrec.snd) | |
| (Primrec.ite (hR.comp ((Primrec.fst.comp Primrec.fst).pair Primrec.snd)) | |
| (Primrec.option_some.comp Primrec.snd) (Primrec.const none)).toβ | |
| apply (Partrec.rfindOpt ht.to_comp).of_eq_tot | |
| intro a | |
| have hd : (Nat.rfindOpt (test a)).Dom := Nat.rfindOpt_dom.mpr | |
| β¨encode (f a), f a, by simp [test, Encodable.encodek, (h a (f a)).mpr rfl]β© | |
| have hm : (Nat.rfindOpt (test a)).get hd β Nat.rfindOpt (test a) := β¨hd, rflβ© | |
| obtain β¨n, hnβ© := Nat.rfindOpt_spec hm | |
| have he : (Nat.rfindOpt (test a)).get hd = f a := by | |
| simp only [test, Option.mem_bind_iff] at hn | |
| obtain β¨b, _, hbβ© := hn | |
| split_ifs at hb with hab | |
| Β· obtain rfl := Option.mem_some_iff.mp hb | |
| exact (h a _).mp hab | |
| Β· contradiction | |
| exact he βΈ hm | |
| @[fun_prop] lemma primrec_rat_le : PrimrecPred (fun p : β Γ β => p.1 β€ p.2) := by | |
| exact (show PrimrecPred (fun p : β Γ β => p.1.num * (p.2.den : β€) β€ | |
| p.2.num * (p.1.den : β€)) by fun_prop).of_eq (fun p => (Rat.le_iff _ _).symm) | |
| @[fun_prop] lemma primrec_rat_lt : PrimrecPred (fun p : β Γ β => p.1 < p.2) := by | |
| exact (PrimrecPred.not (primrec_rat_le.comp (Primrec.snd.pair Primrec.fst))).of_eq | |
| (fun p => not_le) | |
| lemma rat_div_graph (n : β€) (d : β) (q : β) (hd : d β 0) : | |
| q.num * (d : β€) = n * (q.den : β€) β q = (n : β) / d := by | |
| have hq : (q.den : β) β 0 := by exact_mod_cast q.den_nz | |
| have hd' : (d : β) β 0 := by exact_mod_cast hd | |
| conv_rhs => rw [β Rat.num_div_den q, div_eq_div_iff hq hd'] | |
| exact_mod_cast (Iff.rfl : q.num * (d : β€) = n * (q.den : β€) β _) | |
| @[fun_prop] lemma computable_rat_divNat : Computable (fun p : β€ Γ β => (p.1 : β) / p.2) := by | |
| apply computable_of_graph _ (fun p q => | |
| if p.2 = 0 then q = 0 else q.num * (p.2 : β€) = p.1 * (q.den : β€)) | |
| Β· have hi : PrimrecPred (fun p : (β€ Γ β) Γ β => | |
| (p.1.2 = 0 β§ p.2 = 0) β¨ (p.1.2 β 0 β§ p.2.num * (p.1.2 : β€) = p.1.1 * (p.2.den : β€))) := by fun_prop | |
| exact hi.of_eq (fun p => by split_ifs <;> simp_all) | |
| Β· intro p q | |
| split_ifs with hd | |
| Β· simp [hd] | |
| Β· exact rat_div_graph _ _ _ hd | |
| @[fun_prop] lemma computable_rat_castInt : Computable (fun z : β€ => (z : β)) := by | |
| simpa using computable_rat_divNat.comp (Computable.id.pair (Computable.const 1)) | |
| @[fun_prop] lemma computable_rat_castNat : Computable (fun n : β => (n : β)) := by | |
| simpa only [Int.cast_natCast] using computable_rat_castInt.comp primrec_int_cast.to_comp | |
| @[fun_prop] lemma computable_rat_add : Computable (fun p : β Γ β => p.1 + p.2) := by | |
| have hh : Primrec (fun p : β Γ β => | |
| (p.1.num * (p.2.den : β€) + p.2.num * (p.1.den : β€), p.1.den * p.2.den)) := by fun_prop | |
| apply (computable_rat_divNat.comp hh.to_comp).of_eq | |
| intro p | |
| dsimp; push_cast | |
| conv_rhs => rw [β Rat.num_div_den p.1, β Rat.num_div_den p.2] | |
| have h1 : (p.1.den : β) β 0 := by exact_mod_cast p.1.den_nz | |
| have h2 : (p.2.den : β) β 0 := by exact_mod_cast p.2.den_nz | |
| field_simp | |
| @[fun_prop] lemma computable_rat_mul : Computable (fun p : β Γ β => p.1 * p.2) := by | |
| have hh : Primrec (fun p : β Γ β => (p.1.num * p.2.num, p.1.den * p.2.den)) := by fun_prop | |
| apply (computable_rat_divNat.comp hh.to_comp).of_eq | |
| intro p | |
| dsimp; push_cast | |
| rw [mul_div_mul_comm, Rat.num_div_den, Rat.num_div_den] | |
| @[fun_prop] lemma computable_rat_neg : Computable (fun q : β => -q) := by | |
| have hh : Primrec (fun q : β => (-q.num, q.den)) := by fun_prop | |
| apply (computable_rat_divNat.comp hh.to_comp).of_eq | |
| intro q | |
| simp only [Int.cast_neg, neg_div, Rat.num_div_den] | |
| @[fun_prop] lemma computable_rat_sub : Computable (fun p : β Γ β => p.1 - p.2) := by | |
| simpa only [sub_eq_add_neg] using (show Computable (fun p : β Γ β => p.1 + -p.2) by fun_prop) | |
| end RapidForcing.EffectiveArithmetic | |
| end | |
| end OAI | |