Download data/lean/OAI/MathematicalPhysics/RapidForcing/RatOperations.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 3.76 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/MathematicalPhysics/RapidForcing/RatOperations.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/MathematicalPhysics/RapidForcing/RatOperations.lean
-
curl -L -o RatOperations.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/MathematicalPhysics/RapidForcing/RatOperations.lean
3.76 kB
| import OAI.MathematicalPhysics.RapidForcing.RatComputable | |
| import OAI.MathematicalPhysics.RapidForcing.ComputableAutomation | |
| namespace OAI | |
| section | |
| open Encodable Denumerable | |
| namespace RapidForcing.EffectiveArithmetic | |
| lemma rat_divInt_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_divInt : 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_divInt_graph _ _ _ hd | |
| @[fun_prop] lemma computable_rat_inv : Computable (fun q : β => qβ»ΒΉ) := by | |
| have := computable_rat_divInt.comp (show Computable (fun q : β => ((q.den : β€), q.num)) by fun_prop) | |
| exact this.of_eq (fun q => by simpa [Int.cast_natCast, inv_div] using congrArg Inv.inv (Rat.num_div_den q)) | |
| @[fun_prop] lemma computable_rat_div : Computable (fun p : β Γ β => p.1 / p.2) := by | |
| simpa [div_eq_mul_inv] using (show Computable (fun p : β Γ β => p.1 * p.2β»ΒΉ) by fun_prop) | |
| @[fun_prop] lemma computable_rat_abs : Computable (fun q : β => |q|) := by | |
| apply Computable.of_eq (show Computable (fun q : β => if 0 β€ q then q else -q) by fun_prop) | |
| intro q | |
| split_ifs with h | |
| Β· exact (abs_of_nonneg h).symm | |
| Β· exact (abs_of_neg (lt_of_not_ge h)).symm | |
| @[fun_prop] lemma computable_rat_max : Computable (fun p : β Γ β => max p.1 p.2) := by | |
| simpa only [max_def] using (show Computable (fun p : β Γ β => if p.1 β€ p.2 then p.2 else p.1) by fun_prop) | |
| @[fun_prop] lemma computable_rat_pow : Computable (fun p : β Γ β => p.1 ^ p.2) := by | |
| have h := Computable.nat_rec (f := fun p : β Γ β => p.2) | |
| (g := fun _ => (1 : β)) (h := fun p r => r.2 * p.1) | |
| (by fun_prop) (by fun_prop) (by unfold Computableβ; fun_prop) | |
| apply h.of_eq | |
| intro p | |
| induction p.2 <;> simp [pow_succ, *] | |
| @[fun_prop] lemma computable_rat_natCeil : Computable (fun q : β => βqββ) := by | |
| apply computable_of_compGraph _ (fun q n : _ => | |
| if n = (0 : β) then q β€ 0 else (n - 1 : β) < q β§ q β€ (n : β)) | |
| Β· have hi : CompPred (fun p : β Γ β => | |
| (p.2 = 0 β§ p.1 β€ 0) β¨ (p.2 β 0 β§ (p.2 - 1 : β) < p.1 β§ p.1 β€ (p.2 : β))) := by fun_prop | |
| exact hi.of_eq (fun p => by split_ifs <;> simp_all) | |
| Β· intro q n | |
| by_cases hn : n = 0 | |
| Β· simp [hn, eq_comm, Nat.ceil_eq_zero] | |
| Β· simp only [ite_eq_right hn] | |
| rw [eq_comm, Nat.ceil_eq_iff hn] | |
| simp only [Nat.cast_sub (Nat.one_le_iff_ne_zero.mpr hn), Nat.cast_one] | |
| @[fun_prop] lemma computable_rat_natFloor : Computable (fun q : β => βqββ) := by | |
| apply computable_of_compGraph _ (fun q n : _ => | |
| if n = (0 : β) then q < 1 else (n : β) β€ q β§ q < (n : β) + 1) | |
| Β· have hi : CompPred (fun p : β Γ β => | |
| (p.2 = 0 β§ p.1 < 1) β¨ (p.2 β 0 β§ (p.2 : β) β€ p.1 β§ p.1 < (p.2 : β) + 1)) := by fun_prop | |
| exact hi.of_eq (fun p => by split_ifs <;> simp_all) | |
| Β· intro q n | |
| by_cases hn : n = 0 | |
| Β· simp [hn, eq_comm, Nat.floor_eq_zero] | |
| Β· simp only [ite_eq_right hn] | |
| rw [eq_comm, Nat.floor_eq_iff' hn] | |
| end RapidForcing.EffectiveArithmetic | |
| end | |
| end OAI | |