mirror of
https://github.com/GTBarkley/comm_alg.git
synced 2024-12-26 07:38:36 -06:00
Merge branch 'GTBarkley:main' into main
This commit is contained in:
commit
0bda9dea5b
1 changed files with 21 additions and 101 deletions
|
@ -22,34 +22,20 @@ macro "obviously" : tactic =>
|
||||||
-- | nlinarith; done
|
-- | nlinarith; done
|
||||||
| fail "No, this is not obvious."))
|
| fail "No, this is not obvious."))
|
||||||
|
|
||||||
|
|
||||||
-- Testing of Polynomial
|
-- Testing of Polynomial
|
||||||
section Polynomial
|
section Polynomial
|
||||||
noncomputable section
|
noncomputable section
|
||||||
#check Polynomial
|
|
||||||
#check Polynomial (ℚ)
|
|
||||||
#check Polynomial.eval
|
|
||||||
|
|
||||||
|
|
||||||
example (f : Polynomial ℚ) (hf : f = Polynomial.C (1 : ℚ)) : Polynomial.eval 2 f = 1 := by
|
example (f : Polynomial ℚ) (hf : f = Polynomial.C (1 : ℚ)) : Polynomial.eval 2 f = 1 := by
|
||||||
have : ∀ (q : ℚ), Polynomial.eval q f = 1 := by
|
have : ∀ (q : ℚ), Polynomial.eval q f = 1 := by
|
||||||
sorry
|
sorry
|
||||||
obviously
|
|
||||||
|
|
||||||
-- example (f : ℤ → ℤ) (hf : ∀ x, f x = x ^ 2) : Polynomial.eval 2 f = 4 := by
|
|
||||||
-- sorry
|
|
||||||
|
|
||||||
-- degree of a constant function is ⊥ (is this same as -1 ???)
|
-- degree of a constant function is ⊥ (is this same as -1 ???)
|
||||||
#print Polynomial.degree_zero
|
#print Polynomial.degree_zero
|
||||||
|
|
||||||
def F : Polynomial ℚ := Polynomial.C (2 : ℚ)
|
def F : Polynomial ℚ := Polynomial.C (2 : ℚ)
|
||||||
#print F
|
|
||||||
#check F
|
|
||||||
#check Polynomial.degree F
|
|
||||||
#check Polynomial.degree 0
|
|
||||||
#check WithBot ℕ
|
|
||||||
-- #eval Polynomial.degree F
|
-- #eval Polynomial.degree F
|
||||||
#check Polynomial.eval 1 F
|
|
||||||
example : Polynomial.eval (100 : ℚ) F = (2 : ℚ) := by
|
example : Polynomial.eval (100 : ℚ) F = (2 : ℚ) := by
|
||||||
refine Iff.mpr (Rat.ext_iff (Polynomial.eval 100 F) 2) ?_
|
refine Iff.mpr (Rat.ext_iff (Polynomial.eval 100 F) 2) ?_
|
||||||
simp only [Rat.ofNat_num, Rat.ofNat_den]
|
simp only [Rat.ofNat_num, Rat.ofNat_den]
|
||||||
|
@ -57,42 +43,22 @@ example : Polynomial.eval (100 : ℚ) F = (2 : ℚ) := by
|
||||||
simp
|
simp
|
||||||
|
|
||||||
-- Treat polynomial f ∈ ℚ[X] as a function f : ℚ → ℚ
|
-- Treat polynomial f ∈ ℚ[X] as a function f : ℚ → ℚ
|
||||||
#check CoeFun
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end section
|
end section
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- @[BH, 4.1.2]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- All the polynomials are in ℚ[X], all the functions are considered as ℤ → ℤ
|
-- All the polynomials are in ℚ[X], all the functions are considered as ℤ → ℤ
|
||||||
noncomputable section
|
noncomputable section
|
||||||
-- Polynomial type of degree d
|
-- Polynomial type of degree d
|
||||||
@[simp]
|
@[simp]
|
||||||
def PolyType (f : ℤ → ℤ) (d : ℕ) := ∃ Poly : Polynomial ℚ, ∃ (N : ℤ), (∀ (n : ℤ), N ≤ n → f n = Polynomial.eval (n : ℚ) Poly) ∧ d = Polynomial.degree Poly
|
def PolyType (f : ℤ → ℤ) (d : ℕ) := ∃ Poly : Polynomial ℚ, ∃ (N : ℤ), (∀ (n : ℤ), N ≤ n → f n = Polynomial.eval (n : ℚ) Poly) ∧ d = Polynomial.degree Poly
|
||||||
section
|
section
|
||||||
-- structure PolyType (f : ℤ → ℤ) where
|
|
||||||
-- Poly : Polynomial ℤ
|
|
||||||
-- d :
|
|
||||||
-- N : ℤ
|
|
||||||
-- Poly_equal : ∀ n ∈ ℤ → f n = Polynomial.eval n : ℤ Poly
|
|
||||||
|
|
||||||
#check PolyType
|
#check PolyType
|
||||||
|
|
||||||
example (f : ℤ → ℤ) (hf : ∀ x, f x = x ^ 2) : PolyType f 2 := by
|
example (f : ℤ → ℤ) (hf : ∀ x, f x = x ^ 2) : PolyType f 2 := by
|
||||||
unfold PolyType
|
unfold PolyType
|
||||||
sorry
|
sorry
|
||||||
-- use Polynomial.monomial (2 : ℤ) (1 : ℤ)
|
|
||||||
-- have' := hf 0; ring_nf at this
|
|
||||||
-- exact this
|
|
||||||
|
|
||||||
end section
|
end section
|
||||||
|
|
||||||
-- Δ operator (of d times)
|
-- Δ operator (of d times)
|
||||||
|
@ -101,22 +67,13 @@ def Δ : (ℤ → ℤ) → ℕ → (ℤ → ℤ)
|
||||||
| f, 0 => f
|
| f, 0 => f
|
||||||
| f, d + 1 => fun (n : ℤ) ↦ (Δ f d) (n + 1) - (Δ f d) (n)
|
| f, d + 1 => fun (n : ℤ) ↦ (Δ f d) (n + 1) - (Δ f d) (n)
|
||||||
section
|
section
|
||||||
-- def Δ (f : ℤ → ℤ) (d : ℕ) := fun (n : ℤ) ↦ f (n + 1) - f n
|
|
||||||
-- def add' : ℕ → ℕ → ℕ
|
|
||||||
-- | 0, m => m
|
|
||||||
-- | n+1, m => (add' n m) + 1
|
|
||||||
-- #eval add' 5 10
|
|
||||||
#check Δ
|
#check Δ
|
||||||
def f (n : ℤ) := n
|
def f (n : ℤ) := n
|
||||||
#eval (Δ f 1) 100
|
#eval (Δ f 1) 100
|
||||||
-- #check (by (show_term unfold Δ) : Δ f 0=0)
|
-- #check (by (show_term unfold Δ) : Δ f 0=0)
|
||||||
end section
|
end section
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- (NO need to prove another direction) Constant polynomial function = constant function
|
-- (NO need to prove another direction) Constant polynomial function = constant function
|
||||||
lemma Poly_constant (F : Polynomial ℚ) (c : ℚ) :
|
lemma Poly_constant (F : Polynomial ℚ) (c : ℚ) :
|
||||||
(F = Polynomial.C (c : ℚ)) ↔ (∀ r : ℚ, (Polynomial.eval r F) = (c : ℚ)) := by
|
(F = Polynomial.C (c : ℚ)) ↔ (∀ r : ℚ, (Polynomial.eval r F) = (c : ℚ)) := by
|
||||||
|
@ -129,9 +86,6 @@ lemma Poly_constant (F : Polynomial ℚ) (c : ℚ) :
|
||||||
simp
|
simp
|
||||||
· sorry
|
· sorry
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Shifting doesn't change the polynomial type
|
-- Shifting doesn't change the polynomial type
|
||||||
lemma Poly_shifting (f : ℤ → ℤ) (g : ℤ → ℤ) (hf : PolyType f d) (s : ℤ) (hfg : ∀ (n : ℤ), f (n + s) = g (n)) : PolyType g d := by
|
lemma Poly_shifting (f : ℤ → ℤ) (g : ℤ → ℤ) (hf : PolyType f d) (s : ℤ) (hfg : ∀ (n : ℤ), f (n + s) = g (n)) : PolyType g d := by
|
||||||
simp only [PolyType]
|
simp only [PolyType]
|
||||||
|
@ -149,29 +103,29 @@ lemma PolyType_0 (f : ℤ → ℤ) : (PolyType f 0) ↔ (∃ (c : ℤ), ∃ (N :
|
||||||
have HH : ∃ (c : ℚ), Poly = Polynomial.C (c : ℚ) :=
|
have HH : ∃ (c : ℚ), Poly = Polynomial.C (c : ℚ) :=
|
||||||
⟨Poly.coeff 0, Polynomial.eq_C_of_degree_eq_zero (by rw[← H2]; rfl)⟩
|
⟨Poly.coeff 0, Polynomial.eq_C_of_degree_eq_zero (by rw[← H2]; rfl)⟩
|
||||||
cases' HH with c HHH
|
cases' HH with c HHH
|
||||||
have HHHH : ∃ (d : ℤ), d = c :=
|
have HHHH : ∃ (d : ℤ), d = c :=
|
||||||
⟨f N, by simp [(Poly_constant Poly c).mp HHH N, H1 N (le_refl N)]⟩
|
⟨f N, by simp [(Poly_constant Poly c).mp HHH N, H1 N (le_refl N)]⟩
|
||||||
cases' HHHH with d H5; exact ⟨d, by rw[← H5] at HHH; exact HHH⟩
|
cases' HHHH with d H5; exact ⟨d, by rw[← H5] at HHH; exact HHH⟩
|
||||||
rcases this2 with ⟨c, hthis2⟩
|
rcases this2 with ⟨c, hthis2⟩
|
||||||
use c; use N; intro n
|
use c; use N; constructor
|
||||||
constructor
|
· intro n
|
||||||
· have this4 : Polynomial.eval (n : ℚ) Poly = c := by
|
have this4 : Polynomial.eval (n : ℚ) Poly = c := by
|
||||||
rw [hthis2]; simp only [map_intCast, Polynomial.eval_int_cast]
|
rw [hthis2]; simp only [map_intCast, Polynomial.eval_int_cast]
|
||||||
exact fun HH1 => Iff.mp (Rat.coe_int_inj (f n) c) (by rw [←this4, H1 n HH1])
|
exact fun HH1 => Iff.mp (Rat.coe_int_inj (f n) c) (by rw [←this4, H1 n HH1])
|
||||||
· intro c0
|
· intro c0
|
||||||
simp only [hthis2, c0, Int.cast_zero, map_zero, Polynomial.degree_zero]
|
simp only [hthis2, c0, Int.cast_zero, map_zero, Polynomial.degree_zero]
|
||||||
at this1
|
at this1
|
||||||
· rintro ⟨c, N, hh⟩
|
· rintro ⟨c, N, hh⟩
|
||||||
have H2 : (c : ℚ) ≠ 0 := by simp only [ne_eq, Int.cast_eq_zero]; exact (hh 0).2
|
have H2 : (c : ℚ) ≠ 0 := by simp only [ne_eq, Int.cast_eq_zero, hh]
|
||||||
exact ⟨Polynomial.C (c : ℚ), N, fun n Nn
|
exact ⟨Polynomial.C (c : ℚ), N, fun n Nn
|
||||||
=> by rw [(hh n).1 Nn]; exact (((Poly_constant (Polynomial.C (c : ℚ))
|
=> by rw [hh.1 n Nn]; exact (((Poly_constant (Polynomial.C (c : ℚ))
|
||||||
(c : ℚ)).mp rfl) n).symm, by rw [Polynomial.degree_C H2]; rfl⟩
|
(c : ℚ)).mp rfl) n).symm, by rw [Polynomial.degree_C H2]; rfl⟩
|
||||||
|
|
||||||
-- Δ of 0 times preserves the function
|
-- Δ of 0 times preserves the function
|
||||||
lemma Δ_0 (f : ℤ → ℤ) : (Δ f 0) = f := by tauto
|
lemma Δ_0 (f : ℤ → ℤ) : (Δ f 0) = f := by rfl
|
||||||
|
--simp only [Δ]
|
||||||
-- Δ of 1 times decreaes the polynomial type by one
|
-- Δ of 1 times decreaes the polynomial type by one
|
||||||
lemma Δ_1 (f : ℤ → ℤ) (d : ℕ): d > 0 → PolyType f d → PolyType (Δ f 1) (d - 1) := by
|
lemma Δ_1 (f : ℤ → ℤ) (d : ℕ): PolyType f (d + 1) → PolyType (Δ f 1) d := by
|
||||||
sorry
|
sorry
|
||||||
|
|
||||||
-- Δ of d times maps polynomial of degree d to polynomial of degree 0
|
-- Δ of d times maps polynomial of degree d to polynomial of degree 0
|
||||||
|
@ -181,22 +135,13 @@ lemma foofoo (d : ℕ) : (f : ℤ → ℤ) → (PolyType f d) → (PolyType (Δ
|
||||||
induction' d with d hd
|
induction' d with d hd
|
||||||
· intro f h
|
· intro f h
|
||||||
rw [Δ_0]
|
rw [Δ_0]
|
||||||
tauto
|
exact h
|
||||||
· intro f hf
|
· intro f hf
|
||||||
have this1 : PolyType f (d + 1) := by tauto
|
have this4 := hd (Δ f 1) $ (Δ_1 f d) hf
|
||||||
have this2 : PolyType (Δ f (d + 1)) 0 := by
|
rwa [Δ_1_s_equiv_Δ_s_1] at this4
|
||||||
have this3 : PolyType (Δ f 1) d := by
|
|
||||||
have this4 : d + 1 > 0 := by positivity
|
|
||||||
have this5 : (d + 1) > 0 → PolyType f (d + 1) → PolyType (Δ f 1) d := Δ_1 f (d + 1)
|
|
||||||
exact this5 this4 this1
|
|
||||||
clear hf
|
|
||||||
specialize hd (Δ f 1)
|
|
||||||
have this4 : PolyType (Δ (Δ f 1) d) 0 := by tauto
|
|
||||||
rw [Δ_1_s_equiv_Δ_s_1] at this4
|
|
||||||
tauto
|
|
||||||
tauto
|
|
||||||
|
|
||||||
lemma Δ_d_PolyType_d_to_PolyType_0 (f : ℤ → ℤ) (d : ℕ): PolyType f d → PolyType (Δ f d) 0 := fun h => (foofoo d f) h
|
lemma Δ_d_PolyType_d_to_PolyType_0 (f : ℤ → ℤ) (d : ℕ): PolyType f d → PolyType (Δ f d) 0 :=
|
||||||
|
fun h => (foofoo d f) h
|
||||||
|
|
||||||
lemma foofoofoo (d : ℕ) : (f : ℤ → ℤ) → (∃ (c : ℤ), ∃ (N : ℤ), (∀ (n : ℤ), N ≤ n → (Δ f d) (n) = c) ∧ c ≠ 0) → (PolyType f d) := by
|
lemma foofoofoo (d : ℕ) : (f : ℤ → ℤ) → (∃ (c : ℤ), ∃ (N : ℤ), (∀ (n : ℤ), N ≤ n → (Δ f d) (n) = c) ∧ c ≠ 0) → (PolyType f d) := by
|
||||||
induction' d with d hd
|
induction' d with d hd
|
||||||
|
@ -218,43 +163,18 @@ lemma foofoofoo (d : ℕ) : (f : ℤ → ℤ) → (∃ (c : ℤ), ∃ (N : ℤ),
|
||||||
sorry
|
sorry
|
||||||
tauto
|
tauto
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- [BH, 4.1.2] (a) => (b)
|
-- [BH, 4.1.2] (a) => (b)
|
||||||
-- Δ^d f (n) = c for some nonzero integer c for n >> 0 → f is of polynomial type d
|
-- Δ^d f (n) = c for some nonzero integer c for n >> 0 → f is of polynomial type d
|
||||||
lemma a_to_b (f : ℤ → ℤ) (d : ℕ) : (∃ (c : ℤ), ∃ (N : ℤ), (∀ (n : ℤ), N ≤ n → (Δ f d) (n) = c) ∧ c ≠ 0) → PolyType f d := by
|
lemma a_to_b (f : ℤ → ℤ) (d : ℕ) : (∃ (c : ℤ), ∃ (N : ℤ), (∀ (n : ℤ), N ≤ n → (Δ f d) (n) = c) ∧ c ≠ 0) → PolyType f d := by
|
||||||
sorry
|
sorry
|
||||||
-- intro h
|
|
||||||
-- rcases h with ⟨c, N, hh⟩
|
|
||||||
-- have H1 := λ n => (hh n).left
|
|
||||||
-- have H2 := λ n => (hh n).right
|
|
||||||
-- clear hh
|
|
||||||
-- have H2 : c ≠ 0 := by
|
|
||||||
-- tauto
|
|
||||||
-- induction' d with d hd
|
|
||||||
|
|
||||||
-- -- Base case
|
|
||||||
-- · rw [PolyType_0]
|
|
||||||
-- use c
|
|
||||||
-- use N
|
|
||||||
-- tauto
|
|
||||||
|
|
||||||
-- -- Induction step
|
|
||||||
-- · sorry
|
|
||||||
|
|
||||||
-- [BH, 4.1.2] (a) <= (b)
|
-- [BH, 4.1.2] (a) <= (b)
|
||||||
-- f is of polynomial type d → Δ^d f (n) = c for some nonzero integer c for n >> 0
|
-- f is of polynomial type d → Δ^d f (n) = c for some nonzero integer c for n >> 0
|
||||||
lemma b_to_a (f : ℤ → ℤ) (d : ℕ) : PolyType f d → (∃ (c : ℤ), ∃ (N : ℤ), (∀ (n : ℤ), N ≤ n → (Δ f d) (n) = c) ∧ c ≠ 0) := by
|
lemma b_to_a (f : ℤ → ℤ) (d : ℕ) (poly : PolyType f d) :
|
||||||
intro h
|
(∃ (c : ℤ), ∃ (N : ℤ), (∀ (n : ℤ), N ≤ n → (Δ f d) (n) = c) ∧ c ≠ 0) := by
|
||||||
have : PolyType (Δ f d) 0 := by
|
rw [←PolyType_0]; exact Δ_d_PolyType_d_to_PolyType_0 f d poly
|
||||||
apply Δ_d_PolyType_d_to_PolyType_0
|
|
||||||
exact h
|
|
||||||
have this1 : (∃ (c : ℤ), ∃ (N : ℤ), (∀ (n : ℤ), (N ≤ n → (Δ f d) n = c)) ∧ c ≠ 0) := by
|
|
||||||
rw [←PolyType_0]
|
|
||||||
exact this
|
|
||||||
exact this1
|
|
||||||
end
|
|
||||||
|
|
||||||
|
end
|
||||||
-- @Additive lemma of length for a SES
|
-- @Additive lemma of length for a SES
|
||||||
-- Given a SES 0 → A → B → C → 0, then length (A) - length (B) + length (C) = 0
|
-- Given a SES 0 → A → B → C → 0, then length (A) - length (B) + length (C) = 0
|
||||||
section
|
section
|
||||||
|
|
Loading…
Reference in a new issue