cfahlgren1's picture
download
raw
2.53 kB
import Mathlib
namespace OAI
section
namespace MaximalSeshadri.EulerNumerics
lemma periodic_nat_gcd {α : Type*} (f : ℕ → α) (a b : ℕ)
(ha : Function.Periodic f a) (hb : Function.Periodic f b) :
Function.Periodic f (Nat.gcd a b) := by
induction a using Nat.strong_induction_on generalizing b with
| h a ih =>
by_cases hz : a = 0
· simpa [hz] using hb
have hm : Function.Periodic f (b % a) := by
intro n
have H := ha.nat_mul (b/a) (n+b%a)
rw [Nat.cast_id, Nat.add_assoc,Nat.mod_add_div'] at H
exact H.symm.trans (hb n)
rw [Nat.gcd_rec]
exact ih (b%a) (Nat.mod_lt b (Nat.pos_of_ne_zero hz)) a hm ha
lemma periodic_nat_coprime_constant {α : Type*} (f : ℕ → α) (a b : ℕ)
(hab : Nat.Coprime a b) (ha : Function.Periodic f a)
(hb : Function.Periodic f b) (n : ℕ) : f n = f 0 := by
have H := periodic_nat_gcd f a b ha hb
rw [hab.gcd_eq_one] at H
simpa only [Nat.cast_id,mul_one] using H.nat_mul_eq n
theorem quadratic_of_coprime_differences (f : ℕ → ℤ) (a b : ℕ)
(hab : Nat.Coprime a b) (d e c h : ℤ)
(ha : ∀ n, f (n+a) - f n = (n : ℤ)*d+c)
(hb : ∀ n, f (n+b) - f n = (n : ℤ)*e+h) (n : ℕ) :
2*f n = (n : ℤ)*((n : ℤ)-1)*(f 2-2*f 1+f 0) +
2*(n : ℤ)*(f 1-f 0)+2*f 0 := by
let g (n : ℕ) := f (n+2)-2*f (n+1)+f n
have periodic (a : ℕ) (d c : ℤ)
(ha : ∀ n, f (n+a)-f n = (n : ℤ)*d+c) : Function.Periodic g a := by
intro n
have H₀ := ha n
have H₁ := ha (n+1)
have H₂ := ha (n+2)
dsimp [g]
rw [show n+a+2 = n+2+a by omega,show n+a+1 = n+1+a by omega]
push_cast at H₁ H₂
nlinarith
have hg (n : ℕ) : g n = f 2-2*f 1+f 0 :=
periodic_nat_coprime_constant g a b hab (periodic a d c ha) (periodic b e h hb) n
induction n using Nat.twoStepInduction with
| zero => simp
| one => simp; ring
| more n hn hn₁ =>
have H := hg n
dsimp [g] at H
push_cast at hn₁ ⊢
nlinarith
theorem slope_of_quadratic (f : ℕ → ℤ) (q : ℤ)
(hf : ∀ n, 2*f n = (n : ℤ)*((n : ℤ)-1)*q +
2*(n : ℤ)*(f 1-f 0)+2*f 0)
(a : ℕ) (d c : ℤ) (ha : ∀ n, f (n+a)-f n = (n : ℤ)*d+c) :
d = (a : ℤ)*q := by
have H₀ := ha 0
have H₁ := ha 1
have F₀ := hf a
have F₁ := hf (a+1)
simp only [Nat.cast_zero,zero_mul,zero_add] at H₀
rw [Nat.add_comm 1 a] at H₁
push_cast at H₁ F₁
nlinarith
end MaximalSeshadri.EulerNumerics
end
end OAI

Xet Storage Details

Size:
2.53 kB
·
Xet hash:
b503a31d4a468b3372f12feab26ac0d9350716a0bd3b959c0bc783d19844002b

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.