Changes
159 changed files (+0/-16515)
-
-
@@ -1,1 +0,0 @@#eval "Hello, World!"
-
-
-
MIL/01_Introduction/02_Overview.lean (deleted)
-
@@ -1,62 +0,0 @@import data.nat.basic import data.nat.parity import tactic open nat /- These are pieces of data. -/ #check 2 + 2 def f (x : ℕ) := x + 3 #check f /- These are propositions, of type `Prop`. -/ #check 2 + 2 = 4 def fermat_last_theorem := ∀ x y z n : ℕ, n > 2 ∧ x * y * z ≠ 0 → x^n + y^n ≠ z^n #check fermat_last_theorem /- These are proofs of propositions. -/ theorem easy : 2 + 2 = 4 := rfl #check easy theorem hard : fermat_last_theorem := sorry #check hard /- Here are some proofs. -/ example : ∀ m n : nat, even n → even (m * n) := assume m n ⟨k, (hk : n = k + k)⟩, have hmn : m * n = m * k + m * k, by rw [hk, mul_add], show ∃ l, m * n = l + l, from ⟨_, hmn⟩ example : ∀ m n : nat, even n → even (m * n) := λ m n ⟨k, hk⟩, ⟨m * k, by rw [hk, mul_add]⟩ example : ∀ m n : nat, even n → even (m * n) := begin -- say m and n are natural numbers, and assume n=2*k rintros m n ⟨k, hk⟩, -- We need to prove m*n is twice a natural. Let's show it's twice m*k. use m * k, -- substitute in for n rw hk, -- and now it's obvious ring end example : ∀ m n : nat, even n → even (m * n) := by { rintros m n ⟨k, hk⟩, use m * k, rw hk, ring } example : ∀ m n : nat, even n → even (m * n) := by intros; simp * with parity_simps
-
-
MIL/01_Introduction/02_Overview.olean (deleted)
-
-
-
-
@@ -1,6 +0,0 @@import data.nat.basic import data.nat.parity import tactic open nat -- There are no exercises in this section.
-
-
-
MIL/02_Basics/01_Calculating.lean (deleted)
-
@@ -1,186 +0,0 @@import data.real.basic /- An example. -/ import data.real.basic example (a b c : ℝ) : (a * b) * c = b * (a * c) := begin rw mul_comm a b, rw mul_assoc b a c end /- Try these.-/ example (a b c : ℝ) : (c * b) * a = b * (a * c) := begin sorry end example (a b c : ℝ) : a * (b * c) = b * (a * c) := begin sorry end /- An example. -/ example (a b c : ℝ) : a * b * c = b * c * a := begin rw mul_assoc, rw mul_comm end /- Try doing the first of these without providing any arguments at all, and the second with only one argument. -/ example (a b c : ℝ) : a * (b * c) = b * (c * a) := begin sorry end example (a b c : ℝ) : a * (b * c) = b * (a * c) := begin sorry end /- Using facts from the local context. -/ example (a b c d e f : ℝ) (h : a * b = c * d) (h' : e = f) : a * (b * e) = c * (d * f) := begin rw h', rw ←mul_assoc, rw h, rw mul_assoc end /- Try these. For the second one, use the theorem `sub_self`. -/ example (a b c d e f : ℝ) (h : b * c = e * f) : a * b * c * d = a * e * f * d := begin sorry end example (a b c d : ℝ) (hyp : c = b * a - d) (hyp' : d = a * b) : c = 0 := begin sorry end /- Examples. -/ example (a b c d e f : ℝ) (h : a * b = c * d) (h' : e = f) : a * (b * e) = c * (d * f) := by rw [h', ←mul_assoc, h, mul_assoc] section variables a b c d e f g : ℝ example (h : a * b = c * d) (h' : e = f) : a * (b * e) = c * (d * f) := by rw [h', ←mul_assoc, h, mul_assoc] end section variables a b c : ℝ #check a #check a + b #check (a : ℝ) #check mul_comm a b #check (mul_comm a b : a * b = b * a) #check mul_assoc c a b #check mul_comm a #check mul_comm #check @mul_comm end section variables a b : ℝ example : (a + b) * (a + b) = a * a + 2 * (a * b) + b * b := begin rw [mul_add, add_mul, add_mul], rw [←add_assoc, add_assoc (a * a)], rw [mul_comm b a, ←two_mul] end example : (a + b) * (a + b) = a * a + 2 * (a * b) + b * b := calc (a + b) * (a + b) = a * a + b * a + (a * b + b * b) : by rw [mul_add, add_mul, add_mul] ... = a * a + (b * a + a * b) + b * b : by rw [←add_assoc, add_assoc (a * a)] ... = a * a + 2 * (a * b) + b * b : by rw [mul_comm b a, ←two_mul] example : (a + b) * (a + b) = a * a + 2 * (a * b) + b * b := calc (a + b) * (a + b) = a * a + b * a + (a * b + b * b) : begin sorry end ... = a * a + (b * a + a * b) + b * b : by sorry ... = a * a + 2 * (a * b) + b * b : by sorry end /- Try these. For the second, use the theorems listed underneath. -/ section variables a b c d : ℝ example : (a + b) * (c + d) = a * c + a * d + b * c + b * d := sorry example (a b : ℝ) : (a + b) * (a - b) = a^2 - b^2 := begin sorry end #check pow_two a #check mul_sub a b c #check add_mul a b c #check add_sub a b c #check sub_sub a b c #check add_zero a end /- Examples. -/ section variables a b c d : ℝ example (a b c d : ℝ) (hyp : c = d * a + b) (hyp' : b = a * d) : c = 2 * a * d := begin rw hyp' at hyp, rw mul_comm d a at hyp, rw ← two_mul (a * d) at hyp, rw ← mul_assoc 2 a d at hyp, exact hyp end example : (c * b) * a = b * (a * c) := by ring example : (a + b) * (a + b) = a * a + 2 * (a * b) + b * b := by ring example : (a + b) * (a - b) = a^2 - b^2 := by ring example (hyp : c = d * a + b) (hyp' : b = a * d) : c = 2 * a * d := begin rw [hyp, hyp'], ring end end
-
-
MIL/02_Basics/01_Calculating.olean (deleted)
-
-
@@ -1,157 +0,0 @@import algebra.ring import data.real.basic import tactic section variables (R : Type*) [ring R] #check (add_assoc : ∀ a b c : R, a + b + c = a + (b + c)) #check (add_comm : ∀ a b : R, a + b = b + a) #check (zero_add : ∀ a : R, 0 + a = a) #check (add_left_neg : ∀ a : R, -a + a = 0) #check (mul_assoc : ∀ a b c : R, a * b * c = a * (b * c)) #check (mul_one : ∀ a : R, a * 1 = a) #check (one_mul : ∀ a : R, 1 * a = a) #check (mul_add : ∀ a b c : R, a * (b + c) = a * b + a * c) #check (add_mul : ∀ a b c : R, (a + b) * c = a * c + b * c) end section variables (R : Type*) [comm_ring R] variables a b c d : R example : (c * b) * a = b * (a * c) := by ring example : (a + b) * (a + b) = a * a + 2 * (a * b) + b * b := by ring example : (a + b) * (a - b) = a^2 - b^2 := by ring example (hyp : c = d * a + b) (hyp' : b = a * d) : c = 2 * a * d := begin rw [hyp, hyp'], ring end end namespace my_ring variables {R : Type*} [ring R] theorem add_zero (a : R) : a + 0 = a := by rw [add_comm, zero_add] theorem add_right_neg (a : R) : a + -a = 0 := by rw [add_comm, add_left_neg] #check @my_ring.add_zero #check @add_zero end my_ring namespace my_ring variables {R : Type*} [ring R] theorem neg_add_cancel_left (a b : R) : -a + (a + b) = b := by rw [←add_assoc, add_left_neg, zero_add] /- Prove these: -/ theorem add_neg_cancel_right (a b : R) : (a + b) + -b = a := sorry theorem add_left_cancel {a b c : R} (h : a + b = a + c) : b = c := sorry theorem add_right_cancel {a b c : R} (h : a + b = c + b) : a = c := sorry theorem mul_zero (a : R) : a * 0 = 0 := begin have h : a * 0 + a * 0 = a * 0 + 0, { rw [←mul_add, add_zero, add_zero] }, rw add_left_cancel h end theorem zero_mul (a : R) : 0 * a = 0 := sorry theorem neg_eq_of_add_eq_zero {a b : R} (h : a + b = 0) : -a = b := sorry theorem eq_neg_of_add_eq_zero {a b : R} (h : a + b = 0) : a = -b := sorry theorem neg_zero : (-0 : R) = 0 := begin apply neg_eq_of_add_eq_zero, rw add_zero end theorem neg_neg (a : R) : -(-a) = a := sorry end my_ring /- Examples. -/ section variables {R : Type*} [ring R] example (a b : R) : a - b = a + -b := sub_eq_add_neg a b end example (a b : ℝ) : a - b = a + -b := rfl example (a b : ℝ) : a - b = a + -b := by reflexivity namespace my_ring variables {R : Type*} [ring R] theorem self_sub (a : R) : a - a = 0 := sorry lemma one_add_one_eq_two : 1 + 1 = (2 : R) := by refl theorem two_mul (a : R) : 2 * a = a + a := sorry end my_ring section variables (A : Type*) [add_group A] #check (add_assoc : ∀ a b c : A, a + b + c = a + (b + c)) #check (zero_add : ∀ a : A, 0 + a = a) #check (add_left_neg : ∀ a : A, -a + a = 0) end section variables {G : Type*} [group G] #check (mul_assoc : ∀ a b c : G, a * b * c = a * (b * c)) #check (one_mul : ∀ a : G, 1 * a = a) #check (mul_left_inv : ∀ a : G, a⁻¹ * a = 1) namespace my_group theorem mul_right_inv (a : G) : a * a⁻¹ = 1 := sorry theorem mul_one (a : G) : a * 1 = a := sorry theorem mul_inv_rev (a b : G) : (a * b)⁻¹ = b⁻¹ * a ⁻¹ := sorry end my_group end
-
-
-
-
@@ -1,159 +0,0 @@import analysis.special_functions.log.basic variables a b c d e : ℝ open real #check (le_refl : ∀ a : ℝ, a ≤ a) #check (le_trans : a ≤ b → b ≤ c → a ≤ c) section variables (h : a ≤ b) (h' : b ≤ c) #check (le_refl : ∀ a : real, a ≤ a) #check (le_refl a : a ≤ a) #check (le_trans : a ≤ b → b ≤ c → a ≤ c) #check (le_trans h : b ≤ c → a ≤ c) #check (le_trans h h' : a ≤ c) end example (x y z : ℝ) (h₀ : x ≤ y) (h₁ : y ≤ z) : x ≤ z := begin apply le_trans, { apply h₀ }, apply h₁ end example (x y z : ℝ) (h₀ : x ≤ y) (h₁ : y ≤ z) : x ≤ z := begin apply le_trans h₀, apply h₁ end example (x y z : ℝ) (h₀ : x ≤ y) (h₁ : y ≤ z) : x ≤ z := by exact le_trans h₀ h₁ example (x y z : ℝ) (h₀ : x ≤ y) (h₁ : y ≤ z) : x ≤ z := le_trans h₀ h₁ example (x : ℝ) : x ≤ x := by apply le_refl example (x : ℝ) : x ≤ x := by exact le_refl x example (x : ℝ) : x ≤ x := le_refl x #check (le_refl : ∀ a, a ≤ a) #check (le_trans : a ≤ b → b ≤ c → a ≤ c) #check (lt_of_le_of_lt : a ≤ b → b < c → a < c) #check (lt_of_lt_of_le : a < b → b ≤ c → a < c) #check (lt_trans : a < b → b < c → a < c) /- Try this. -/ example (h₀ : a ≤ b) (h₁ : b < c) (h₂ : c ≤ d) (h₃ : d < e) : a < e := sorry example (h₀ : a ≤ b) (h₁ : b < c) (h₂ : c ≤ d) (h₃ : d < e) : a < e := by linarith section example (h : 2 * a ≤ 3 * b) (h' : 1 ≤ a) (h'' : d = 2) : d + a ≤ 5 * b := by linarith end example (h : 1 ≤ a) (h' : b ≤ c) : 2 + a + exp b ≤ 3 * a + exp c := by linarith [exp_le_exp.mpr h'] #check (exp_le_exp : exp a ≤ exp b ↔ a ≤ b) #check (exp_lt_exp : exp a < exp b ↔ a < b) #check (log_le_log : 0 < a → 0 < b → (log a ≤ log b ↔ a ≤ b)) #check (log_lt_log : 0 < a → a < b → log a < log b) #check (add_le_add : a ≤ b → c ≤ d → a + c ≤ b + d) #check (add_le_add_left : a ≤ b → ∀ c, c + a ≤ c + b) #check (add_le_add_right : a ≤ b → ∀ c, a + c ≤ b + c) #check (add_lt_add_of_le_of_lt : a ≤ b → c < d → a + c < b + d) #check (add_lt_add_of_lt_of_le : a < b → c ≤ d → a + c < b + d) #check (add_lt_add_left : a < b → ∀ c, c + a < c + b) #check (add_lt_add_right : a < b → ∀ c, a + c < b + c) #check (add_nonneg : 0 ≤ a → 0 ≤ b → 0 ≤ a + b) #check (add_pos : 0 < a → 0 < b → 0 < a + b) #check (add_pos_of_pos_of_nonneg : 0 < a → 0 ≤ b → 0 < a + b) #check (exp_pos : ∀ a, 0 < exp a) #check @add_le_add_left example (h : a ≤ b) : exp a ≤ exp b := begin rw exp_le_exp, exact h end example (h₀ : a ≤ b) (h₁ : c < d) : a + exp c + e < b + exp d + e := begin apply add_lt_add_of_lt_of_le, { apply add_lt_add_of_le_of_lt h₀, apply exp_lt_exp.mpr h₁ }, apply le_refl end example (h₀ : d ≤ e) : c + exp (a + d) ≤ c + exp (a + e) := begin sorry end example : (0 : ℝ) < 1 := by norm_num example (h : a ≤ b) : log (1 + exp a) ≤ log (1 + exp b) := begin have h₀ : 0 < 1 + exp a, { sorry }, have h₁ : 0 < 1 + exp b, { sorry }, apply (log_le_log h₀ h₁).mpr, sorry end example : 0 ≤ a^2 := begin -- library_search, exact pow_two_nonneg a end example (h : a ≤ b) : c - exp b ≤ c - exp a := sorry example : 2*a*b ≤ a^2 + b^2 := begin have h : 0 ≤ a^2 - 2*a*b + b^2, calc a^2 - 2*a*b + b^2 = (a - b)^2 : by ring ... ≥ 0 : by apply pow_two_nonneg, calc 2*a*b = 2*a*b + 0 : by ring ... ≤ 2*a*b + (a^2 - 2*a*b + b^2) : add_le_add (le_refl _) h ... = a^2 + b^2 : by ring end example : 2*a*b ≤ a^2 + b^2 := begin have h : 0 ≤ a^2 - 2*a*b + b^2, calc a^2 - 2*a*b + b^2 = (a - b)^2 : by ring ... ≥ 0 : by apply pow_two_nonneg, linarith end example : abs (a*b) ≤ (a^2 + b^2) / 2 := sorry #check abs_le'.mpr
-
-
-
-
@@ -1,93 +0,0 @@import data.real.basic section variables a b c d : ℝ #check (min_le_left a b : min a b ≤ a) #check (min_le_right a b : min a b ≤ b) #check (le_min : c ≤ a → c ≤ b → c ≤ min a b) example : min a b = min b a := begin apply le_antisymm, { show min a b ≤ min b a, apply le_min, { apply min_le_right }, apply min_le_left }, { show min b a ≤ min a b, apply le_min, { apply min_le_right }, apply min_le_left } end example : min a b = min b a := begin have h : ∀ x y, min x y ≤ min y x, { intros x y, apply le_min, apply min_le_right, apply min_le_left }, apply le_antisymm, apply h, apply h end example : min a b = min b a := begin apply le_antisymm, repeat { apply le_min, apply min_le_right, apply min_le_left } end example : max a b = max b a := sorry example : min (min a b) c = min a (min b c) := sorry lemma aux : min a b + c ≤ min (a + c) (b + c) := sorry example : min a b + c = min (a + c) (b + c) := sorry #check (abs_add : ∀ a b : ℝ, abs (a + b) ≤ abs a + abs b) example : abs a - abs b ≤ abs (a - b) := sorry end section variables w x y z : ℕ example (h₀ : x ∣ y) (h₁ : y ∣ z) : x ∣ z := dvd_trans h₀ h₁ example : x ∣ y * x * z := begin apply dvd_mul_of_dvd_left, apply dvd_mul_left end example : x ∣ x^2 := by apply dvd_mul_right example (h : x ∣ w) : x ∣ y * (x * z) + x^2 + w^2 := sorry end section variables m n : ℕ open nat #check (gcd_zero_right n : gcd n 0 = n) #check (gcd_zero_left n : gcd 0 n = n) #check (lcm_zero_right n : lcm n 0 = 0) #check (lcm_zero_left n : lcm 0 n = 0) example : gcd m n = gcd n m := sorry end
-
-
-
-
@@ -1,99 +0,0 @@import topology.metric_space.basic section variables {α : Type*} [partial_order α] variables x y z : α #check x ≤ y #check (le_refl x : x ≤ x) #check (le_trans : x ≤ y → y ≤ z → x ≤ z) #check x < y #check (lt_irrefl x : ¬ x < x) #check (lt_trans : x < y → y < z → x < z) #check (lt_of_le_of_lt : x ≤ y → y < z → x < z) #check (lt_of_lt_of_le : x < y → y ≤ z → x < z) example : x < y ↔ x ≤ y ∧ x ≠ y := lt_iff_le_and_ne end section variables {α : Type*} [lattice α] variables x y z : α #check x ⊓ y #check (inf_le_left : x ⊓ y ≤ x) #check (inf_le_right : x ⊓ y ≤ y) #check (le_inf : z ≤ x → z ≤ y → z ≤ x ⊓ y) #check x ⊔ y #check (le_sup_left : x ≤ x ⊔ y) #check (le_sup_right: y ≤ x ⊔ y) #check (sup_le : x ≤ z → y ≤ z → x ⊔ y ≤ z) example : x ⊓ y = y ⊓ x := sorry example : x ⊓ y ⊓ z = x ⊓ (y ⊓ z) := sorry example : x ⊔ y = y ⊔ x := sorry example : x ⊔ y ⊔ z = x ⊔ (y ⊔ z) := sorry theorem absorb1 : x ⊓ (x ⊔ y) = x := sorry theorem absorb2 : x ⊔ (x ⊓ y) = x := sorry end section variables {α : Type*} [distrib_lattice α] variables x y z : α #check (inf_sup_left : x ⊓ (y ⊔ z) = (x ⊓ y) ⊔ (x ⊓ z)) #check (inf_sup_right : (x ⊔ y) ⊓ z = (x ⊓ z) ⊔ (y ⊓ z)) #check (sup_inf_left : x ⊔ (y ⊓ z) = (x ⊔ y) ⊓ (x ⊔ z)) #check (sup_inf_right : (x ⊓ y) ⊔ z = (x ⊔ z) ⊓ (y ⊔ z)) end section variables {α : Type*} [lattice α] variables a b c : α example (h : ∀ x y z : α, x ⊓ (y ⊔ z) = (x ⊓ y) ⊔ (x ⊓ z)) : a ⊔ (b ⊓ c) = (a ⊔ b) ⊓ (a ⊔ c) := sorry example (h : ∀ x y z : α, x ⊔ (y ⊓ z) = (x ⊔ y) ⊓ (x ⊔ z)) : a ⊓ (b ⊔ c) = (a ⊓ b) ⊔ (a ⊓ c) := sorry end section variables {R : Type*} [ordered_ring R] variables a b c : R #check (add_le_add_left : a ≤ b → ∀ c, c + a ≤ c + b) #check (mul_pos : 0 < a → 0 < b → 0 < a * b) #check (mul_nonneg : 0 ≤ a → 0 ≤ b → 0 ≤ a * b) example : a ≤ b → 0 ≤ b - a := sorry example : 0 ≤ b - a → a ≤ b := sorry example (h : a ≤ b) (h' : 0 ≤ c) : a * c ≤ b * c := sorry end section variables {X : Type*} [metric_space X] variables x y z : X #check (dist_self x : dist x x = 0) #check (dist_comm x y : dist x y = dist y x) #check (dist_triangle x y z : dist x z ≤ dist x y + dist y z) example (x y : X) : 0 ≤ dist x y := sorry end
-
-
-
-
@@ -1,45 +0,0 @@import data.real.basic example (a b c : ℝ) : (c * b) * a = b * (a * c) := begin rw mul_comm c b, rw mul_assoc b c a, rw mul_comm c a end example (a b c : ℝ) : a * (b * c) = b * (a * c) := begin rw ←mul_assoc a b c, rw mul_comm a b, rw mul_assoc b a c end example (a b c : ℝ) : a * (b * c) = b * (c * a) := begin rw mul_comm, rw mul_assoc end example (a b c : ℝ) : a * (b * c) = b * (a * c) := begin rw ←mul_assoc, rw mul_comm a, rw mul_assoc end example (a b c d e f : ℝ) (h : b * c = e * f) : a * b * c * d = a * e * f * d := begin rw mul_assoc a, rw h, rw ←mul_assoc end example (a b c d : ℝ) (hyp : c = b * a - d) (hyp' : d = a * b) : c = 0 := begin rw hyp, rw hyp', rw mul_comm, rw sub_self end
-
-
-
-
@@ -1,84 +0,0 @@import algebra.ring import data.real.basic import tactic namespace my_ring variables {R : Type*} [ring R] theorem add_neg_cancel_right (a b : R) : (a + b) + -b = a := by rw [add_assoc, add_right_neg, add_zero] theorem add_left_cancel {a b c : R} (h : a + b = a + c) : b = c := by rw [←neg_add_cancel_left a b, h, neg_add_cancel_left] theorem add_right_cancel {a b c : R} (h : a + b = c + b) : a = c := by rw [←add_neg_cancel_right a b, h, add_neg_cancel_right] theorem zero_mul (a : R) : 0 * a = 0 := begin have h : 0 * a + 0 * a = 0 * a + 0, { rw [←add_mul, add_zero, add_zero] }, rw add_left_cancel h end theorem neg_eq_of_add_eq_zero {a b : R} (h : a + b = 0) : -a = b := by rw [←neg_add_cancel_left a b, h, add_zero] theorem eq_neg_of_add_eq_zero {a b : R} (h : a + b = 0) : a = -b := begin symmetry, apply neg_eq_of_add_eq_zero, rw [add_comm, h] end theorem neg_zero : (-0 : R) = 0 := begin apply neg_eq_of_add_eq_zero, rw add_zero end theorem neg_neg (a : R) : -(-a) = a := begin apply neg_eq_of_add_eq_zero, rw add_left_neg end end my_ring namespace my_ring variables {R : Type*} [ring R] theorem self_sub (a : R) : a - a = 0 := by rw [sub_eq_add_neg, add_right_neg] lemma one_add_one_eq_two : 1 + 1 = (2 : R) := by refl theorem two_mul (a : R) : 2 * a = a + a := by rw [←one_add_one_eq_two, add_mul, one_mul] end my_ring section variables {G : Type*} [group G] namespace my_group theorem mul_right_inv (a : G) : a * a⁻¹ = 1 := begin have h : (a * a⁻¹)⁻¹ * ((a * a⁻¹) * (a * a⁻¹)) = 1, { rw [mul_assoc, ←mul_assoc a⁻¹ a, mul_left_inv, one_mul, mul_left_inv] }, rw [←h, ←mul_assoc, mul_left_inv, one_mul] end theorem mul_one (a : G) : a * 1 = a := by rw [←mul_left_inv a, ←mul_assoc, mul_right_inv, one_mul] theorem mul_inv_rev (a b : G) : (a * b)⁻¹ = b⁻¹ * a ⁻¹ := by rw [←one_mul (b⁻¹ * a⁻¹), ←mul_left_inv (a * b), mul_assoc, mul_assoc, ←mul_assoc b b⁻¹, mul_right_inv, one_mul, mul_right_inv, mul_one] end my_group end
-
-
-
-
@@ -1,79 +0,0 @@import analysis.special_functions.log.basic variables a b c d e : ℝ open real example (h₀ : a ≤ b) (h₁ : b < c) (h₂ : c ≤ d) (h₃ : d < e) : a < e := begin apply lt_of_le_of_lt h₀, apply lt_trans h₁, exact lt_of_le_of_lt h₂ h₃ end example (h₀ : d ≤ e) : c + exp (a + d) ≤ c + exp (a + e) := begin apply add_le_add_left, rw exp_le_exp, apply add_le_add_left h₀ end -- an alterantive using `linarith`. example (h₀ : d ≤ e) : c + exp (a + d) ≤ c + exp (a + e) := begin have : exp (a + d) ≤ exp (a + e), { rw exp_le_exp, linarith }, linarith [this] end example (h : a ≤ b) : log (1 + exp a) ≤ log (1 + exp b) := begin have h₀ : 0 < 1 + exp a, { linarith [exp_pos a]}, have h₁ : 0 < 1 + exp b, { linarith [exp_pos b] }, apply (log_le_log h₀ h₁).mpr, apply add_le_add_left (exp_le_exp.mpr h), end -- SOLUTION. example (h : a ≤ b) : c - exp b ≤ c - exp a := begin apply sub_le_sub_left, exact exp_le_exp.mpr h end -- alternatively: example (h : a ≤ b) : c - exp b ≤ c - exp a := by linarith [exp_le_exp.mpr h] theorem fact1 : a*b*2 ≤ a^2 + b^2 := begin have h : 0 ≤ a^2 - 2*a*b + b^2, calc a^2 - 2*a*b + b^2 = (a - b)^2 : by ring ... ≥ 0 : by apply pow_two_nonneg, linarith end theorem fact2 : -(a*b)*2 ≤ a^2 + b^2 := begin have h : 0 ≤ a^2 + 2*a*b + b^2, calc a^2 + 2*a*b + b^2 = (a + b)^2 : by ring ... ≥ 0 : by apply pow_two_nonneg, linarith end example : abs (a*b) ≤ (a^2 + b^2) / 2 := begin have h : (0 : ℝ) < 2, { norm_num }, apply abs_le'.mpr, split, { rw le_div_iff h, apply fact1 }, rw le_div_iff h, apply fact2, end
-
-
-
-
@@ -1,134 +0,0 @@import data.real.basic section variables a b c d : ℝ #check (min_le_left a b : min a b ≤ a) #check (min_le_right a b : min a b ≤ b) #check (le_min : c ≤ a → c ≤ b → c ≤ min a b) example : max a b = max b a := begin apply le_antisymm, repeat { apply max_le, apply le_max_right, apply le_max_left } end example : min (min a b) c = min a (min b c) := begin apply le_antisymm, { apply le_min, { apply le_trans, apply min_le_left, apply min_le_left }, apply le_min, { apply le_trans, apply min_le_left, apply min_le_right }, apply min_le_right }, apply le_min, { apply le_min, { apply min_le_left }, apply le_trans, apply min_le_right, apply min_le_left }, apply le_trans, apply min_le_right, apply min_le_right end lemma aux : min a b + c ≤ min (a + c) (b + c) := begin apply le_min, { apply add_le_add_right, apply min_le_left }, apply add_le_add_right, apply min_le_right end example : min a b + c = min (a + c) (b + c) := begin apply le_antisymm, { apply aux }, have h : min (a + c) (b + c) = min (a + c) (b + c) - c + c, { rw sub_add_cancel }, rw h, apply add_le_add_right, rw sub_eq_add_neg, apply le_trans, apply aux, rw [add_neg_cancel_right, add_neg_cancel_right] end example : abs a - abs b ≤ abs (a - b) := calc abs a - abs b = abs (a - b + b) - abs b : by rw sub_add_cancel ... ≤ abs (a - b) + abs b - abs b : begin apply sub_le_sub_right, apply abs_add end ... ≤ abs (a - b) : by rw add_sub_cancel -- alternatively example : abs a - abs b ≤ abs (a - b) := begin have h := abs_add (a - b) b, rw sub_add_cancel at h, linarith end end section variables w x y z : ℕ example (h₀ : x ∣ y) (h₁ : y ∣ z) : x ∣ z := dvd_trans h₀ h₁ example : x ∣ y * x * z := begin apply dvd_mul_of_dvd_left, apply dvd_mul_left end example : x ∣ x^2 := by apply dvd_mul_right example (h : x ∣ w) : x ∣ y * (x * z) + x^2 + w^2 := begin apply dvd_add, { apply dvd_add, { apply dvd_mul_of_dvd_right, apply dvd_mul_right }, apply dvd_mul_right }, rw pow_two, apply dvd_mul_of_dvd_right, exact h end end section variables m n : ℕ open nat #check (gcd_zero_right n : gcd n 0 = n) #check (gcd_zero_left n : gcd 0 n = n) #check (lcm_zero_right n : lcm n 0 = 0) #check (lcm_zero_left n : lcm 0 n = 0) example : gcd m n = gcd n m := begin apply dvd_antisymm, repeat { apply dvd_gcd, apply gcd_dvd_right, apply gcd_dvd_left } end end
-
-
-
-
@@ -1,159 +0,0 @@import topology.metric_space.basic section variables {α : Type*} [lattice α] variables x y z : α example : x ⊓ y = y ⊓ x := begin apply le_antisymm, repeat { apply le_inf, { apply inf_le_right }, apply inf_le_left } end example : x ⊓ y ⊓ z = x ⊓ (y ⊓ z) := begin apply le_antisymm, { apply le_inf, { apply le_trans, apply inf_le_left, apply inf_le_left }, apply le_inf, { apply le_trans, apply inf_le_left, apply inf_le_right }, apply inf_le_right }, apply le_inf, { apply le_inf, { apply inf_le_left }, apply le_trans, apply inf_le_right, apply inf_le_left }, apply le_trans, apply inf_le_right, apply inf_le_right end example : x ⊔ y = y ⊔ x := begin apply le_antisymm, repeat { apply sup_le, { apply le_sup_right }, apply le_sup_left } end example : x ⊔ y ⊔ z = x ⊔ (y ⊔ z) := begin apply le_antisymm, { apply sup_le, { apply sup_le, apply le_sup_left, { apply le_trans, apply @le_sup_left _ _ y z, apply le_sup_right } }, apply le_trans, apply @le_sup_right _ _ y z, apply le_sup_right }, apply sup_le, { apply le_trans, apply @le_sup_left _ _ x y, apply le_sup_left }, apply sup_le, { apply le_trans, apply @le_sup_right _ _ x y, apply le_sup_left }, apply le_sup_right end theorem absorb1 : x ⊓ (x ⊔ y) = x := begin apply le_antisymm, { apply inf_le_left }, apply le_inf, { apply le_refl }, apply le_sup_left end theorem absorb2 : x ⊔ (x ⊓ y) = x := begin apply le_antisymm, { apply sup_le, { apply le_refl }, apply inf_le_left }, apply le_sup_left end end section variables {α : Type*} [distrib_lattice α] variables x y z : α #check (inf_sup_left : x ⊓ (y ⊔ z) = (x ⊓ y) ⊔ (x ⊓ z)) #check (inf_sup_right : (x ⊔ y) ⊓ z = (x ⊓ z) ⊔ (y ⊓ z)) #check (sup_inf_left : x ⊔ (y ⊓ z) = (x ⊔ y) ⊓ (x ⊔ z)) #check (sup_inf_right : (x ⊓ y) ⊔ z = (x ⊔ z) ⊓ (y ⊔ z)) end section variables {α : Type*} [lattice α] variables a b c : α example (h : ∀ x y z : α, x ⊓ (y ⊔ z) = (x ⊓ y) ⊔ (x ⊓ z)) : a ⊔ (b ⊓ c) = (a ⊔ b) ⊓ (a ⊔ c) := by rw [h, @inf_comm _ _ (a ⊔ b), absorb1, @inf_comm _ _ (a ⊔ b), h, ←sup_assoc, @inf_comm _ _ c a, absorb2, inf_comm] example (h : ∀ x y z : α, x ⊔ (y ⊓ z) = (x ⊔ y) ⊓ (x ⊔ z)) : a ⊓ (b ⊔ c) = (a ⊓ b) ⊔ (a ⊓ c) := by rw [h, @sup_comm _ _ (a ⊓ b), absorb2, @sup_comm _ _ (a ⊓ b), h, ←inf_assoc, @sup_comm _ _ c a, absorb1, sup_comm] end section variables {R : Type*} [ordered_ring R] variables a b c : R theorem aux1 : a ≤ b → 0 ≤ b - a := begin intro h, rw [←sub_self a, sub_eq_add_neg, sub_eq_add_neg, add_comm, add_comm b], apply add_le_add_left h end theorem aux2 : 0 ≤ b - a → a ≤ b := begin intro h, rw [←add_zero a, ←sub_add_cancel b a, add_comm (b - a)], apply add_le_add_left h end example (h : a ≤ b) (h' : 0 ≤ c) : a * c ≤ b * c := begin have h1 : 0 ≤ (b - a) * c, { exact mul_nonneg (aux1 _ _ h) h' }, rw sub_mul at h1, exact aux2 _ _ h1 end end section variables {X : Type*} [metric_space X] variables x y z : X example (x y : X) : 0 ≤ dist x y := begin have : 0 ≤ dist x y + dist y x, { rw [←dist_self x], apply dist_triangle }, linarith [dist_comm x y] end end
-
-
-
-
@@ -1,188 +0,0 @@import data.real.basic #check ∀ x : ℝ, 0 ≤ x → abs x = x #check ∀ x y ε : ℝ, 0 < ε → ε ≤ 1 → abs x < ε → abs y < ε → abs (x * y) < ε lemma my_lemma : ∀ x y ε : ℝ, 0 < ε → ε ≤ 1 → abs x < ε → abs y < ε → abs (x * y) < ε := sorry section variables a b δ : ℝ variables (h₀ : 0 < δ) (h₁ : δ ≤ 1) variables (ha : abs a < δ) (hb : abs b < δ) #check my_lemma a b δ #check my_lemma a b δ h₀ h₁ #check my_lemma a b δ h₀ h₁ ha hb end lemma my_lemma2 : ∀ {x y ε : ℝ}, 0 < ε → ε ≤ 1 → abs x < ε → abs y < ε → abs (x * y) < ε := sorry section variables a b δ : ℝ variables (h₀ : 0 < δ) (h₁ : δ ≤ 1) variables (ha : abs a < δ) (hb : abs b < δ) #check my_lemma2 h₀ h₁ ha hb end lemma my_lemma3 : ∀ {x y ε : ℝ}, 0 < ε → ε ≤ 1 → abs x < ε → abs y < ε → abs (x * y) < ε := begin intros x y ε epos ele1 xlt ylt, sorry end lemma my_lemma4 : ∀ {x y ε : ℝ}, 0 < ε → ε ≤ 1 → abs x < ε → abs y < ε → abs (x * y) < ε := begin intros x y ε epos ele1 xlt ylt, calc abs (x * y) = abs x * abs y : sorry ... ≤ abs x * ε : sorry ... < 1 * ε : sorry ... = ε : sorry end def fn_ub (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, f x ≤ a def fn_lb (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, a ≤ f x section variables (f g : ℝ → ℝ) (a b : ℝ) example (hfa : fn_ub f a) (hgb : fn_ub g b) : fn_ub (λ x, f x + g x) (a + b) := begin intro x, dsimp, apply add_le_add, apply hfa, apply hgb end example (hfa : fn_lb f a) (hgb : fn_lb g b) : fn_lb (λ x, f x + g x) (a + b) := sorry example (nnf : fn_lb f 0) (nng : fn_lb g 0) : fn_lb (λ x, f x * g x) 0 := sorry example (hfa : fn_ub f a) (hfb : fn_ub g b) (nng : fn_lb g 0) (nna : 0 ≤ a) : fn_ub (λ x, f x * g x) (a * b) := sorry end section variables {α : Type*} {R : Type*} [ordered_cancel_add_comm_monoid R] #check @add_le_add def fn_ub' (f : α → R) (a : R) : Prop := ∀ x, f x ≤ a theorem fn_ub_add {f g : α → R} {a b : R} (hfa : fn_ub' f a) (hgb : fn_ub' g b) : fn_ub' (λ x, f x + g x) (a + b) := λ x, add_le_add (hfa x) (hgb x) end example (f : ℝ → ℝ) (h : monotone f) : ∀ {a b}, a ≤ b → f a ≤ f b := h section variables (f g : ℝ → ℝ) example (mf : monotone f) (mg : monotone g) : monotone (λ x, f x + g x) := begin intros a b aleb, apply add_le_add, apply mf aleb, apply mg aleb end example (mf : monotone f) (mg : monotone g) : monotone (λ x, f x + g x) := λ a b aleb, add_le_add (mf aleb) (mg aleb) example {c : ℝ} (mf : monotone f) (nnc : 0 ≤ c) : monotone (λ x, c * f x) := sorry example (mf : monotone f) (mg : monotone g) : monotone (λ x, f (g x)) := sorry def fn_even (f : ℝ → ℝ) : Prop := ∀ x, f x = f (-x) def fn_odd (f : ℝ → ℝ) : Prop := ∀ x, f x = - f (-x) example (ef : fn_even f) (eg : fn_even g) : fn_even (λ x, f x + g x) := begin intro x, calc (λ x, f x + g x) x = f x + g x : rfl ... = f (-x) + g (-x) : by rw [ef, eg] end example (of : fn_odd f) (og : fn_odd g) : fn_even (λ x, f x * g x) := sorry example (ef : fn_even f) (og : fn_odd g) : fn_odd (λ x, f x * g x) := sorry example (ef : fn_even f) (og : fn_odd g) : fn_even (λ x, f (g x)) := sorry end section variables {α : Type*} (r s t : set α) example : s ⊆ s := by { intros x xs, exact xs } theorem subset.refl : s ⊆ s := λ x xs, xs theorem subset.trans : r ⊆ s → s ⊆ t → r ⊆ t := sorry end section variables {α : Type*} [partial_order α] variables (s : set α) (a b : α) def set_ub (s : set α) (a : α) := ∀ x, x ∈ s → x ≤ a example (h : set_ub s a) (h' : a ≤ b) : set_ub s b := sorry end section open function example (c : ℝ) : injective (λ x, x + c) := begin intros x₁ x₂ h', exact (add_left_inj c).mp h', end example {c : ℝ} (h : c ≠ 0) : injective (λ x, c * x) := sorry variables {α : Type*} {β : Type*} {γ : Type*} variables {g : β → γ} {f : α → β} example (injg : injective g) (injf : injective f) : injective (λ x, g (f x)) := sorry end
-
-
-
-
@@ -1,149 +0,0 @@import data.real.basic example : ∃ x : ℝ, 2 < x ∧ x < 3 := begin use 5 / 2, norm_num end example : ∃ x : ℝ, 2 < x ∧ x < 3 := begin have h : 2 < (5 : ℝ) / 2 ∧ (5 : ℝ) / 2 < 3, by norm_num, exact ⟨5 / 2, h⟩ end example : ∃ x : ℝ, 2 < x ∧ x < 3 := ⟨5 / 2, by norm_num⟩ def fn_ub (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, f x ≤ a def fn_lb (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, a ≤ f x def fn_has_ub (f : ℝ → ℝ) := ∃ a, fn_ub f a def fn_has_lb (f : ℝ → ℝ) := ∃ a, fn_lb f a theorem fn_ub_add {f g : ℝ → ℝ} {a b : ℝ} (hfa : fn_ub f a) (hgb : fn_ub g b) : fn_ub (λ x, f x + g x) (a + b) := λ x, add_le_add (hfa x) (hgb x) section variables {f g : ℝ → ℝ} example (ubf : fn_has_ub f) (ubg : fn_has_ub g) : fn_has_ub (λ x, f x + g x) := begin cases ubf with a ubfa, cases ubg with b ubfb, use a + b, apply fn_ub_add ubfa ubfb end example (lbf : fn_has_lb f) (lbg : fn_has_lb g) : fn_has_lb (λ x, f x + g x) := sorry example {c : ℝ} (ubf : fn_has_ub f) (h : c ≥ 0): fn_has_ub (λ x, c * f x) := sorry example (ubf : fn_has_ub f) (ubg : fn_has_ub g) : fn_has_ub (λ x, f x + g x) := begin rcases ubf with ⟨a, ubfa⟩, rcases ubg with ⟨b, ubfb⟩, exact ⟨a + b, fn_ub_add ubfa ubfb⟩ end example : fn_has_ub f → fn_has_ub g → fn_has_ub (λ x, f x + g x) := begin rintros ⟨a, ubfa⟩ ⟨b, ubfb⟩, exact ⟨a + b, fn_ub_add ubfa ubfb⟩ end example : fn_has_ub f → fn_has_ub g → fn_has_ub (λ x, f x + g x) := λ ⟨a, ubfa⟩ ⟨b, ubfb⟩, ⟨a + b, fn_ub_add ubfa ubfb⟩ end section variables {α : Type*} [comm_ring α] def sum_of_squares (x : α) := ∃ a b, x = a^2 + b^2 theorem sum_of_squares_mul {x y : α} (sosx : sum_of_squares x) (sosy : sum_of_squares y) : sum_of_squares (x * y) := begin rcases sosx with ⟨a, b, xeq⟩, rcases sosy with ⟨c, d, yeq⟩, rw [xeq, yeq], use [a*c - b*d, a*d + b*c], ring end theorem sum_of_squares_mul' {x y : α} (sosx : sum_of_squares x) (sosy : sum_of_squares y) : sum_of_squares (x * y) := begin rcases sosx with ⟨a, b, rfl⟩, rcases sosy with ⟨c, d, rfl⟩, use [a*c - b*d, a*d + b*c], ring end end section variables {a b c : ℕ} example (divab : a ∣ b) (divbc : b ∣ c) : a ∣ c := begin cases divab with d beq, cases divbc with e ceq, rw [ceq, beq], use (d * e), ring end example (divab : a ∣ b) (divac : a ∣ c) : a ∣ (b + c) := sorry end section open function example {c : ℝ} : surjective (λ x, x + c) := begin intro x, use x - c, dsimp, ring end example {c : ℝ} (h : c ≠ 0) : surjective (λ x, c * x) := sorry example (x y : ℝ) (h : x - y ≠ 0) : (x^2 - y^2) / (x - y) = x + y := by { field_simp [h], ring } example {f : ℝ → ℝ} (h : surjective f) : ∃ x, (f x)^2 = 4 := begin cases h 2 with x hx, use x, rw hx, norm_num end end section open function variables {α : Type*} {β : Type*} {γ : Type*} variables {g : β → γ} {f : α → β} example (surjg : surjective g) (surjf : surjective f) : surjective (λ x, g (f x)) := sorry end
-
-
-
MIL/03_Logic/03_Negation.lean (deleted)
-
@@ -1,159 +0,0 @@import data.real.basic section variables a b : ℝ example (h : a < b) : ¬ b < a := begin intro h', have : a < a, from lt_trans h h', apply lt_irrefl a this end def fn_ub (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, f x ≤ a def fn_lb (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, a ≤ f x def fn_has_ub (f : ℝ → ℝ) := ∃ a, fn_ub f a def fn_has_lb (f : ℝ → ℝ) := ∃ a, fn_lb f a variable f : ℝ → ℝ example (h : ∀ a, ∃ x, f x > a) : ¬ fn_has_ub f := begin intros fnub, cases fnub with a fnuba, cases h a with x hx, have : f x ≤ a, from fnuba x, linarith end example (h : ∀ a, ∃ x, f x < a) : ¬ fn_has_lb f := sorry example : ¬ fn_has_ub (λ x, x) := sorry #check (not_le_of_gt : a > b → ¬ a ≤ b) #check (not_lt_of_ge : a ≥ b → ¬ a < b) #check (lt_of_not_ge : ¬ a ≥ b → a < b) #check (le_of_not_gt : ¬ a > b → a ≤ b) example (h : monotone f) (h' : f a < f b) : a < b := sorry example (h : a ≤ b) (h' : f b < f a) : ¬ monotone f := sorry example : ¬ ∀ {f : ℝ → ℝ}, monotone f → ∀ {a b}, f a ≤ f b → a ≤ b := begin intro h, let f := λ x : ℝ, (0 : ℝ), have monof : monotone f, { sorry }, have h' : f 1 ≤ f 0, from le_refl _, sorry end example (x : ℝ) (h : ∀ ε > 0, x < ε) : x ≤ 0 := sorry end section variables {α : Type*} (P : α → Prop) (Q : Prop) example (h : ¬ ∃ x, P x) : ∀ x, ¬ P x := sorry example (h : ∀ x, ¬ P x) : ¬ ∃ x, P x := sorry example (h : ¬ ∀ x, P x) : ∃ x, ¬ P x := sorry example (h : ∃ x, ¬ P x) : ¬ ∀ x, P x := sorry open_locale classical example (h : ¬ ∀ x, P x) : ∃ x, ¬ P x := begin by_contradiction h', apply h, intro x, show P x, by_contradiction h'', exact h' ⟨x, h''⟩ end example (h : ¬ ¬ Q) : Q := sorry example (h : Q) : ¬ ¬ Q := sorry end open_locale classical section variable (f : ℝ → ℝ) example (h : ¬ fn_has_ub f) : ∀ a, ∃ x, f x > a := sorry example (h : ¬ ∀ a, ∃ x, f x > a) : fn_has_ub f := begin push_neg at h, exact h end example (h : ¬ fn_has_ub f) : ∀ a, ∃ x, f x > a := begin simp only [fn_has_ub, fn_ub] at h, push_neg at h, exact h end example (h : ¬ monotone f) : ∃ x y, x ≤ y ∧ f y < f x := sorry example (h : ¬ fn_has_ub f) : ∀ a, ∃ x, f x > a := begin contrapose! h, exact h end example (x : ℝ) (h : ∀ ε > 0, x ≤ ε) : x ≤ 0 := begin contrapose! h, use x / 2, split; linarith end end section variable a : ℕ example (h : 0 < 0) : a > 37 := begin exfalso, apply lt_irrefl 0 h end example (h : 0 < 0) : a > 37 := absurd h (lt_irrefl 0) example (h : 0 < 0) : a > 37 := begin have h' : ¬ 0 < 0, from lt_irrefl 0, contradiction end end
-
-
MIL/03_Logic/03_Negation.olean (deleted)
-
-
@@ -1,163 +0,0 @@import data.real.basic import data.nat.prime example {x y : ℝ} (h₀ : x ≤ y) (h₁ : ¬ y ≤ x) : x ≤ y ∧ x ≠ y := begin split, { assumption }, intro h, apply h₁, rw h end example {x y : ℝ} (h₀ : x ≤ y) (h₁ : ¬ y ≤ x) : x ≤ y ∧ x ≠ y := ⟨h₀, λ h, h₁ (by rw h)⟩ example {x y : ℝ} (h₀ : x ≤ y) (h₁ : ¬ y ≤ x) : x ≤ y ∧ x ≠ y := begin have h : x ≠ y, { contrapose! h₁, rw h₁ }, exact ⟨h₀, h⟩ end example {x y : ℝ} (h : x ≤ y ∧ x ≠ y) : ¬ y ≤ x := begin cases h with h₀ h₁, contrapose! h₁, exact le_antisymm h₀ h₁ end example {x y : ℝ} : x ≤ y ∧ x ≠ y → ¬ y ≤ x := begin rintros ⟨h₀, h₁⟩ h', exact h₁ (le_antisymm h₀ h') end example {x y : ℝ} : x ≤ y ∧ x ≠ y → ¬ y ≤ x := λ ⟨h₀, h₁⟩ h', h₁ (le_antisymm h₀ h') example {x y : ℝ} (h : x ≤ y ∧ x ≠ y) : ¬ y ≤ x := begin intro h', apply h.right, exact le_antisymm h.left h' end example {x y : ℝ} (h : x ≤ y ∧ x ≠ y) : ¬ y ≤ x := λ h', h.right (le_antisymm h.left h') example {m n : ℕ} (h : m ∣ n ∧ m ≠ n) : m ∣ n ∧ ¬ n ∣ m := sorry example : ∃ x : ℝ, 2 < x ∧ x < 4 := ⟨5/2, by norm_num, by norm_num⟩ example (x y : ℝ) : (∃ z : ℝ, x < z ∧ z < y) → x < y := begin rintros ⟨z, xltz, zlty⟩, exact lt_trans xltz zlty end example (x y : ℝ) : (∃ z : ℝ, x < z ∧ z < y) → x < y := λ ⟨z, xltz, zlty⟩, lt_trans xltz zlty example : ∃ x : ℝ, 2 < x ∧ x < 4 := begin use 5 / 2, split; norm_num end example : ∃ m n : ℕ, 4 < m ∧ m < n ∧ n < 10 ∧ nat.prime m ∧ nat.prime n := begin use [5, 7], norm_num end example {x y : ℝ} : x ≤ y ∧ x ≠ y → x ≤ y ∧ ¬ y ≤ x := begin rintros ⟨h₀, h₁⟩, use [h₀, λ h', h₁ (le_antisymm h₀ h')] end example {x y : ℝ} (h : x ≤ y) : ¬ y ≤ x ↔ x ≠ y := begin split, { contrapose!, rintro rfl, reflexivity }, contrapose!, exact le_antisymm h end example {x y : ℝ} (h : x ≤ y) : ¬ y ≤ x ↔ x ≠ y := ⟨λ h₀ h₁, h₀ (by rw h₁), λ h₀ h₁, h₀ (le_antisymm h h₁)⟩ example {x y : ℝ} : x ≤ y ∧ ¬ y ≤ x ↔ x ≤ y ∧ x ≠ y := sorry theorem aux {x y : ℝ} (h : x^2 + y^2 = 0) : x = 0 := begin have h' : x^2 = 0, { sorry }, exact pow_eq_zero h' end example (x y : ℝ) : x^2 + y^2 = 0 ↔ x = 0 ∧ y = 0 := sorry section example (x y : ℝ) : abs (x + 3) < 5 → -8 < x ∧ x < 2 := begin rw abs_lt, intro h, split; linarith end example : 3 ∣ nat.gcd 6 15 := begin rw nat.dvd_gcd_iff, split; norm_num end end theorem not_monotone_iff {f : ℝ → ℝ}: ¬ monotone f ↔ ∃ x y, x ≤ y ∧ f x > f y := by { rw monotone, push_neg } example : ¬ monotone (λ x : ℝ, -x) := sorry section variables {α : Type*} [partial_order α] variables a b : α example : a < b ↔ a ≤ b ∧ a ≠ b := begin rw lt_iff_le_not_le, sorry end end section variables {α : Type*} [preorder α] variables a b c : α example : ¬ a < a := begin rw lt_iff_le_not_le, sorry end example : a < b → b < c → a < c := begin simp only [lt_iff_le_not_le], sorry end end
-
-
-
MIL/03_Logic/05_Disjunction.lean (deleted)
-
@@ -1,108 +0,0 @@import data.real.basic section variables {x y : ℝ} example (h : y > x^2) : y > 0 ∨ y < -1 := by { left, linarith [pow_two_nonneg x] } example (h : -y > x^2 + 1) : y > 0 ∨ y < -1 := by { right, linarith [pow_two_nonneg x] } example (h : y > 0) : y > 0 ∨ y < -1 := or.inl h example (h : y < -1) : y > 0 ∨ y < -1 := or.inr h example : x < abs y → x < y ∨ x < -y := begin cases le_or_gt 0 y with h h, { rw abs_of_nonneg h, intro h, left, exact h }, rw abs_of_neg h, intro h, right, exact h end namespace my_abs theorem le_abs_self (x : ℝ) : x ≤ abs x := sorry theorem neg_le_abs_self (x : ℝ) : -x ≤ abs x := sorry theorem abs_add (x y : ℝ) : abs (x + y) ≤ abs x + abs y := sorry theorem lt_abs : x < abs y ↔ x < y ∨ x < -y := sorry theorem abs_lt : abs x < y ↔ - y < x ∧ x < y := sorry end my_abs end example {x : ℝ} (h : x ≠ 0) : x < 0 ∨ x > 0 := begin rcases lt_trichotomy x 0 with xlt | xeq | xgt, { left, exact xlt }, { contradiction }, right, exact xgt end example {m n k : ℕ} (h : m ∣ n ∨ m ∣ k) : m ∣ n * k := begin rcases h with ⟨a, rfl⟩ | ⟨b, rfl⟩, { rw [mul_assoc], apply dvd_mul_right }, rw [mul_comm, mul_assoc], apply dvd_mul_right end example {z : ℝ} (h : ∃ x y, z = x^2 + y^2 ∨ z = x^2 + y^2 + 1) : z ≥ 0 := sorry example {x : ℝ} (h : x^2 = 1) : x = 1 ∨ x = -1 := sorry example {x y : ℝ} (h : x^2 = y^2) : x = y ∨ x = -y := sorry section variables {R : Type*} [comm_ring R] [is_domain R] variables (x y : R) example (h : x^2 = 1) : x = 1 ∨ x = -1 := sorry example (h : x^2 = y^2) : x = y ∨ x = -y := sorry end example (P : Prop) : ¬ ¬ P → P := begin intro h, cases classical.em P, { assumption }, contradiction end section open_locale classical example (P : Prop) : ¬ ¬ P → P := begin intro h, by_cases h' : P, { assumption }, contradiction end example (P Q : Prop) : (P → Q) ↔ ¬ P ∨ Q := sorry end
-
-
MIL/03_Logic/05_Disjunction.olean (deleted)
-
-
@@ -1,119 +0,0 @@import data.real.basic def converges_to (s : ℕ → ℝ) (a : ℝ) := ∀ ε > 0, ∃ N, ∀ n ≥ N, abs (s n - a) < ε example : (λ x y : ℝ, (x + y)^2) = (λ x y : ℝ, x^2 + 2*x*y + y^2) := by { ext, ring } example (a b : ℝ) : abs a = abs (a - b + b) := by { congr, ring } example {a : ℝ} (h : 1 < a) : a < a * a := begin convert (mul_lt_mul_right _).2 h, { rw [one_mul] }, exact lt_trans zero_lt_one h end theorem converges_to_const (a : ℝ) : converges_to (λ x : ℕ, a) a := begin intros ε εpos, use 0, intros n nge, dsimp, rw [sub_self, abs_zero], apply εpos end theorem converges_to_add {s t : ℕ → ℝ} {a b : ℝ} (cs : converges_to s a) (ct : converges_to t b): converges_to (λ n, s n + t n) (a + b) := begin intros ε εpos, dsimp, have ε2pos : 0 < ε / 2, { linarith }, cases cs (ε / 2) ε2pos with Ns hs, cases ct (ε / 2) ε2pos with Nt ht, use max Ns Nt, sorry end theorem converges_to_mul_const {s : ℕ → ℝ} {a : ℝ} (c : ℝ) (cs : converges_to s a) : converges_to (λ n, c * s n) (c * a) := begin by_cases h : c = 0, { convert converges_to_const 0, { ext, rw [h, zero_mul] }, rw [h, zero_mul] }, have acpos : 0 < abs c, from abs_pos.mpr h, sorry end theorem exists_abs_le_of_converges_to {s : ℕ → ℝ} {a : ℝ} (cs : converges_to s a) : ∃ N b, ∀ n, N ≤ n → abs (s n) < b := begin cases cs 1 zero_lt_one with N h, use [N, abs a + 1], sorry end lemma aux {s t : ℕ → ℝ} {a : ℝ} (cs : converges_to s a) (ct : converges_to t 0) : converges_to (λ n, s n * t n) 0 := begin intros ε εpos, dsimp, rcases exists_abs_le_of_converges_to cs with ⟨N₀, B, h₀⟩, have Bpos : 0 < B, from lt_of_le_of_lt (abs_nonneg _) (h₀ N₀ (le_refl _)), have pos₀ : ε / B > 0, from div_pos εpos Bpos, cases ct _ pos₀ with N₁ h₁, sorry end theorem converges_to_mul {s t : ℕ → ℝ} {a b : ℝ} (cs : converges_to s a) (ct : converges_to t b): converges_to (λ n, s n * t n) (a * b) := begin have h₁ : converges_to (λ n, s n * (t n - b)) 0, { apply aux cs, convert converges_to_add ct (converges_to_const (-b)), ring }, convert (converges_to_add h₁ (converges_to_mul_const b cs)), { ext, ring }, ring end theorem converges_to_unique {s : ℕ → ℝ} {a b : ℝ} (sa : converges_to s a) (sb : converges_to s b) : a = b := begin by_contradiction abne, have : abs (a - b) > 0, { sorry }, let ε := abs (a - b) / 2, have εpos : ε > 0, { change abs (a - b) / 2 > 0, linarith }, cases sa ε εpos with Na hNa, cases sb ε εpos with Nb hNb, let N := max Na Nb, have absa : abs (s N - a) < ε, { sorry }, have absb : abs (s N - b) < ε, { sorry }, have : abs (a - b) < abs (a - b), { sorry }, exact lt_irrefl _ this end section variables {α : Type*} [linear_order α] def converges_to' (s : α → ℝ) (a : ℝ) := ∀ ε > 0, ∃ N, ∀ n ≥ N, abs (s n - a) < ε end
-
-
-
-
@@ -1,151 +0,0 @@import data.real.basic def fn_ub (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, f x ≤ a def fn_lb (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, a ≤ f x section variables (f g : ℝ → ℝ) (a b : ℝ) example (hfa : fn_lb f a) (hgb : fn_lb g b) : fn_lb (λ x, f x + g x) (a + b) := begin intro x, apply add_le_add, apply hfa, apply hgb end example (nnf : fn_lb f 0) (nng : fn_lb g 0) : fn_lb (λ x, f x * g x) 0 := begin intro x, apply mul_nonneg, apply nnf, apply nng end example (hfa : fn_ub f a) (hfb : fn_ub g b) (nng : fn_lb g 0) (nna : 0 ≤ a) : fn_ub (λ x, f x * g x) (a * b) := begin intro x, apply mul_le_mul, apply hfa, apply hfb, apply nng, apply nna end end section variables (f g : ℝ → ℝ) example {c : ℝ} (mf : monotone f) (nnc : 0 ≤ c) : monotone (λ x, c * f x) := begin intros a b aleb, apply mul_le_mul_of_nonneg_left _ nnc, apply mf aleb end example {c : ℝ} (mf : monotone f) (nnc : 0 ≤ c) : monotone (λ x, c * f x) := λ a b aleb, mul_le_mul_of_nonneg_left (mf aleb) nnc example (mf : monotone f) (mg : monotone g) : monotone (λ x, f (g x)) := begin intros a b aleb, apply mf, apply mg, apply aleb end example (mf : monotone f) (mg : monotone g) : monotone (λ x, f (g x)) := λ a b aleb, mf (mg aleb) def fn_even (f : ℝ → ℝ) : Prop := ∀ x, f x = f (-x) def fn_odd (f : ℝ → ℝ) : Prop := ∀ x, f x = - f (-x) example (of : fn_odd f) (og : fn_odd g) : fn_even (λ x, f x * g x) := begin intro x, calc (λ x, f x * g x) x = f x * g x : rfl ... = f (- x) * g (- x) : by rw [of, og, neg_mul_neg] end example (ef : fn_even f) (og : fn_odd g) : fn_odd (λ x, f x * g x) := begin intro x, dsimp, rw [ef, og, neg_mul_eq_mul_neg] end example (ef : fn_even f) (og : fn_odd g) : fn_even (λ x, f (g x)) := begin intro x, dsimp, rw [og, ←ef] end end section variables {α : Type*} (r s t : set α) example : r ⊆ s → s ⊆ t → r ⊆ t := begin intros rsubs ssubt x xr, apply ssubt, apply rsubs, apply xr end theorem subset.trans : r ⊆ s → s ⊆ t → r ⊆ t := λ rsubs ssubt x xr, ssubt (rsubs xr) end section variables {α : Type*} [partial_order α] variables (s : set α) (a b : α) def set_ub (s : set α) (a : α) := ∀ x, x ∈ s → x ≤ a example (h : set_ub s a) (h' : a ≤ b) : set_ub s b := begin intros x xs, apply le_trans (h x xs) h' end example (h : set_ub s a) (h' : a ≤ b) : set_ub s b := λ x xs, le_trans (h x xs) h' end section open function example {c : ℝ} (h : c ≠ 0) : injective (λ x, c * x) := begin intros x₁ x₂ h', apply (mul_right_inj' h).mp h' end variables {α : Type*} {β : Type*} {γ : Type*} variables {g : β → γ} {f : α → β} example (injg : injective g) (injf : injective f) : injective (λ x, g (f x)) := begin intros x₁ x₂ h, apply injf, apply injg, apply h end end
-
-
-
-
@@ -1,90 +0,0 @@import data.real.basic def fn_ub (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, f x ≤ a def fn_lb (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, a ≤ f x def fn_has_ub (f : ℝ → ℝ) := ∃ a, fn_ub f a def fn_has_lb (f : ℝ → ℝ) := ∃ a, fn_lb f a theorem fn_ub_add {f g : ℝ → ℝ} {a b : ℝ} (hfa : fn_ub f a) (hgb : fn_ub g b) : fn_ub (λ x, f x + g x) (a + b) := λ x, add_le_add (hfa x) (hgb x) section variables {f g : ℝ → ℝ} example (lbf : fn_has_lb f) (lbg : fn_has_lb g) : fn_has_lb (λ x, f x + g x) := begin cases lbf with a lbfa, cases lbg with b lbgb, use a + b, intro x, exact add_le_add (lbfa x) (lbgb x) end example {c : ℝ} (ubf : fn_has_ub f) (h : c ≥ 0): fn_has_ub (λ x, c * f x) := begin cases ubf with a lbfa, use c * a, intro x, exact mul_le_mul_of_nonneg_left (lbfa x) h end end section variables {a b c : ℕ} example (divab : a ∣ b) (divbc : b ∣ c) : a ∣ c := begin rcases divab with ⟨d, rfl⟩, rcases divbc with ⟨e, rfl⟩, use (d * e), ring end example (divab : a ∣ b) (divac : a ∣ c) : a ∣ (b + c) := begin rcases divab with ⟨d, rfl⟩, rcases divac with ⟨e, rfl⟩, use (d + e), ring end end section open function example {c : ℝ} (h : c ≠ 0) : surjective (λ x, c * x) := begin intro x, use x / c, dsimp, rw [mul_div_cancel' _ h] end example {c : ℝ} (h : c ≠ 0) : surjective (λ x, c * x) := begin intro x, use x / c, field_simp [h], ring end end section open function variables {α : Type*} {β : Type*} {γ : Type*} variables {g : β → γ} {f : α → β} example (surjg : surjective g) (surjf : surjective f) : surjective (λ x, g (f x)) := begin intro z, rcases surjg z with ⟨y, rfl⟩, rcases surjf y with ⟨x, rfl⟩, use [x, rfl] end end
-
-
-
-
@@ -1,132 +0,0 @@import data.real.basic section variables a b : ℝ def fn_ub (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, f x ≤ a def fn_lb (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, a ≤ f x def fn_has_ub (f : ℝ → ℝ) := ∃ a, fn_ub f a def fn_has_lb (f : ℝ → ℝ) := ∃ a, fn_lb f a variable f : ℝ → ℝ example (h : ∀ a, ∃ x, f x < a) : ¬ fn_has_lb f := begin rintros ⟨a, ha⟩, rcases h a with ⟨x, hx⟩, have := ha x, linarith end example : ¬ fn_has_ub (λ x, x) := begin rintros ⟨a, ha⟩, have : a + 1 ≤ a := ha (a + 1), linarith end example (h : monotone f) (h' : f a < f b) : a < b := begin apply lt_of_not_ge, intro h'', apply absurd h', apply not_lt_of_ge (h h'') end example (h : a ≤ b) (h' : f b < f a) : ¬ monotone f := begin intro h'', apply absurd h', apply not_lt_of_ge, apply h'' h end example : ¬ ∀ {f : ℝ → ℝ}, monotone f → ∀ {a b}, f a ≤ f b → a ≤ b := begin intro h, let f := λ x : ℝ, (0 : ℝ), have monof : monotone f, { intros a b leab, refl }, have h' : f 1 ≤ f 0, from le_refl _, have : (1 : ℝ) ≤ 0 := h monof h', linarith end example (x : ℝ) (h : ∀ ε > 0, x < ε) : x ≤ 0 := begin apply le_of_not_gt, intro h', linarith [h _ h'] end end section variables {α : Type*} (P : α → Prop) (Q : Prop) example (h : ¬ ∃ x, P x) : ∀ x, ¬ P x := begin intros x Px, apply h, use [x, Px] end example (h : ∀ x, ¬ P x) : ¬ ∃ x, P x := begin rintros ⟨x, Px⟩, exact h x Px end example (h : ∃ x, ¬ P x) : ¬ ∀ x, P x := begin intro h', rcases h with ⟨x, nPx⟩, apply nPx, apply h' end example (h : ¬ ¬ Q) : Q := begin by_contradiction h', exact h h' end example (h : Q) : ¬ ¬ Q := begin intro h', exact h' h end end open_locale classical section variable (f : ℝ → ℝ) example (h : ¬ fn_has_ub f) : ∀ a, ∃ x, f x > a := begin intro a, by_contradiction h', apply h, use a, intro x, apply le_of_not_gt, intro h'', apply h', use [x, h''] end example (h : ¬ monotone f) : ∃ x y, x ≤ y ∧ f y < f x := begin rw [monotone] at h, push_neg at h, exact h end end
-
-
-
-
@@ -1,108 +0,0 @@import data.real.basic import data.nat.prime example {m n : ℕ} (h : m ∣ n ∧ m ≠ n) : m ∣ n ∧ ¬ n ∣ m := begin cases h with h0 h1, split, { exact h0 }, intro h2, apply h1, apply nat.dvd_antisymm h0 h2, end example {x y : ℝ} : x ≤ y ∧ ¬ y ≤ x ↔ x ≤ y ∧ x ≠ y := begin split, { rintros ⟨h0, h1⟩, split, { exact h0 }, intro h2, apply h1, rw h2 }, rintros ⟨h0, h1⟩, split, { exact h0 }, intro h2, apply h1, apply le_antisymm h0 h2 end theorem aux {x y : ℝ} (h : x^2 + y^2 = 0) : x = 0 := begin have h' : x^2 = 0, { linarith [pow_two_nonneg x, pow_two_nonneg y] }, exact pow_eq_zero h' end example (x y : ℝ) : x^2 + y^2 = 0 ↔ x = 0 ∧ y = 0 := begin split, { intro h, split, { exact aux h }, rw add_comm at h, exact aux h }, rintros ⟨rfl, rfl⟩, norm_num end theorem not_monotone_iff {f : ℝ → ℝ}: ¬ monotone f ↔ ∃ x y, x ≤ y ∧ f x > f y := by { rw monotone, push_neg } example : ¬ monotone (λ x : ℝ, -x) := begin rw not_monotone_iff, use [0, 1], norm_num end section variables {α : Type*} [partial_order α] variables a b : α example : a < b ↔ a ≤ b ∧ a ≠ b := begin rw lt_iff_le_not_le, split, { rintros ⟨h0, h1⟩, split, { exact h0 }, intro h2, apply h1, rw h2 }, rintros ⟨h0, h1⟩, split, { exact h0 }, intro h2, apply h1, apply le_antisymm h0 h2 end end section variables {α : Type*} [preorder α] variables a b c : α example : ¬ a < a := begin rw lt_iff_le_not_le, rintros ⟨h0, h1⟩, exact h1 h0 end example : a < b → b < c → a < c := begin simp only [lt_iff_le_not_le], rintros ⟨h0, h1⟩ ⟨h2, h3⟩, split, { apply le_trans h0 h2 }, intro h4, apply h1, apply le_trans h2 h4 end end
-
-
-
-
@@ -1,162 +0,0 @@import data.real.basic section variables {x y : ℝ} namespace my_abs theorem le_abs_self (x : ℝ) : x ≤ abs x := begin cases le_or_gt 0 x with h h, { rw abs_of_nonneg h }, rw abs_of_neg h, linarith end theorem neg_le_abs_self (x : ℝ) : -x ≤ abs x := begin cases le_or_gt 0 x with h h, { rw abs_of_nonneg h, linarith }, rw abs_of_neg h end theorem abs_add (x y : ℝ) : abs (x + y) ≤ abs x + abs y := begin cases le_or_gt 0 (x + y) with h h, { rw abs_of_nonneg h, linarith [le_abs_self x, le_abs_self y] }, rw abs_of_neg h, linarith [neg_le_abs_self x, neg_le_abs_self y] end theorem lt_abs : x < abs y ↔ x < y ∨ x < -y := begin cases le_or_gt 0 y with h h, { rw abs_of_nonneg h, split, { intro h', left, exact h' }, intro h', cases h' with h' h', { exact h' }, linarith }, rw abs_of_neg h, split, { intro h', right, exact h' }, intro h', cases h' with h' h', { linarith }, exact h' end theorem abs_lt : abs x < y ↔ - y < x ∧ x < y := begin cases le_or_gt 0 x with h h, { rw abs_of_nonneg h, split, { intro h', split, { linarith }, exact h' }, intro h', cases h' with h1 h2, exact h2 }, rw abs_of_neg h, split, { intro h', split, { linarith }, linarith }, intro h', linarith end end my_abs end example {z : ℝ} (h : ∃ x y, z = x^2 + y^2 ∨ z = x^2 + y^2 + 1) : z ≥ 0 := by { rcases h with ⟨x, y, rfl | rfl⟩; linarith [sq_nonneg x, sq_nonneg y] } example {x : ℝ} (h : x^2 = 1) : x = 1 ∨ x = -1 := begin have h' : x^2 - 1 = 0, { rw [h, sub_self] }, have h'' : (x + 1) * (x - 1) = 0, { rw ← h', ring }, cases eq_zero_or_eq_zero_of_mul_eq_zero h'' with h1 h1, { right, exact eq_neg_iff_add_eq_zero.mpr h1 }, left, exact eq_of_sub_eq_zero h1 end example {x y : ℝ} (h : x^2 = y^2) : x = y ∨ x = -y := begin have h' : x^2 - y^2 = 0, { rw [h, sub_self] }, have h'' : (x + y) * (x - y) = 0, { rw ← h', ring }, cases eq_zero_or_eq_zero_of_mul_eq_zero h'' with h1 h1, { right, exact eq_neg_iff_add_eq_zero.mpr h1 }, left, exact eq_of_sub_eq_zero h1 end section variables {R : Type*} [comm_ring R] [is_domain R] variables (x y : R) example (h : x^2 = 1) : x = 1 ∨ x = -1 := begin have h' : x^2 - 1 = 0, { rw [h, sub_self] }, have h'' : (x + 1) * (x - 1) = 0, { rw ← h', ring }, cases eq_zero_or_eq_zero_of_mul_eq_zero h'' with h1 h1, { right, exact eq_neg_iff_add_eq_zero.mpr h1 }, left, exact eq_of_sub_eq_zero h1 end example (h : x^2 = y^2) : x = y ∨ x = -y := begin have h' : x^2 - y^2 = 0, { rw [h, sub_self] }, have h'' : (x + y) * (x - y) = 0, { rw ← h', ring }, cases eq_zero_or_eq_zero_of_mul_eq_zero h'' with h1 h1, { right, exact eq_neg_iff_add_eq_zero.mpr h1 }, left, exact eq_of_sub_eq_zero h1 end end section open_locale classical example (P Q : Prop) : (P → Q) ↔ ¬ P ∨ Q := begin split, { intro h, by_cases h' : P, { right, exact h h'}, left, exact h' }, rintros (h | h), { intro h', exact absurd h' h }, intro _, exact h end end
-
-
-
-
@@ -1,143 +0,0 @@import data.real.basic def converges_to (s : ℕ → ℝ) (a : ℝ) := ∀ ε > 0, ∃ N, ∀ n ≥ N, abs (s n - a) < ε theorem converges_to_const (a : ℝ) : converges_to (λ x : ℕ, a) a := begin intros ε εpos, use 0, intros n nge, dsimp, rw [sub_self, abs_zero], apply εpos end theorem converges_to_add {s t : ℕ → ℝ} {a b : ℝ} (cs : converges_to s a) (ct : converges_to t b): converges_to (λ n, s n + t n) (a + b) := begin intros ε εpos, dsimp, have ε2pos : 0 < ε / 2, { linarith }, cases cs (ε / 2) ε2pos with Ns hs, cases ct (ε / 2) ε2pos with Nt ht, use max Ns Nt, intros n hn, have ngeNs : n ≥ Ns := le_of_max_le_left hn, have ngeNt : n ≥ Nt := le_of_max_le_right hn, calc |s n + t n - (a + b)| = | s n - a + (t n - b) | : by { congr, ring } ... ≤ | s n - a | + | (t n - b) | : abs_add _ _ ... < ε / 2 + ε / 2 : add_lt_add (hs n ngeNs) (ht n ngeNt) ... = ε : by norm_num end theorem converges_to_mul_const {s : ℕ → ℝ} {a : ℝ} (c : ℝ) (cs : converges_to s a) : converges_to (λ n, c * s n) (c * a) := begin by_cases h : c = 0, { convert converges_to_const 0, { ext, rw [h, zero_mul] }, rw [h, zero_mul] }, have acpos : 0 < abs c, from abs_pos.mpr h, intros ε εpos, dsimp, have εcpos : 0 < ε / abs c, { apply div_pos εpos acpos }, cases cs (ε / abs c) εcpos with Ns hs, use Ns, intros n ngt, calc |c * s n - c * a| = |c| * |s n - a| : by { rw [←abs_mul, mul_sub] } ... < |c| * (ε / |c|) : mul_lt_mul_of_pos_left (hs n ngt) acpos ... = ε : mul_div_cancel' _ (ne_of_lt acpos).symm end theorem exists_abs_le_of_converges_to {s : ℕ → ℝ} {a : ℝ} (cs : converges_to s a) : ∃ N b, ∀ n, N ≤ n → abs (s n) < b := begin cases cs 1 zero_lt_one with N h, use [N, abs a + 1], intros n ngt, calc |s n| = |s n - a + a| : by { congr, abel } ... ≤ |s n - a| + |a| : abs_add _ _ ... < |a| + 1 : by linarith [h n ngt] end lemma aux {s t : ℕ → ℝ} {a : ℝ} (cs : converges_to s a) (ct : converges_to t 0) : converges_to (λ n, s n * t n) 0 := begin intros ε εpos, dsimp, rcases exists_abs_le_of_converges_to cs with ⟨N₀, B, h₀⟩, have Bpos : 0 < B, from lt_of_le_of_lt (abs_nonneg _) (h₀ N₀ (le_refl _)), have pos₀ : ε / B > 0, from div_pos εpos Bpos, cases ct _ pos₀ with N₁ h₁, use max N₀ N₁, intros n ngt, have ngeN₀ : n ≥ N₀ := le_of_max_le_left ngt, have ngeN₁ : n ≥ N₁ := le_of_max_le_right ngt, calc |s n * t n - 0| = |s n| * |t n - 0| : by rw [sub_zero, abs_mul, sub_zero] ... < B * (ε / B) : mul_lt_mul'' (h₀ n ngeN₀) (h₁ n ngeN₁) (abs_nonneg _) (abs_nonneg _) ... = ε : mul_div_cancel' _ (ne_of_lt Bpos).symm end theorem converges_to_muL {s t : ℕ → ℝ} {a b : ℝ} (cs : converges_to s a) (ct : converges_to t b): converges_to (λ n, s n * t n) (a * b) := begin have h₁ : converges_to (λ n, s n * (t n - b)) 0, { apply aux cs, convert converges_to_add ct (converges_to_const (-b)), ring }, convert (converges_to_add h₁ (converges_to_mul_const b cs)), { ext, ring }, ring end theorem converges_to_unique {s : ℕ → ℝ} {a b : ℝ} (sa : converges_to s a) (sb : converges_to s b) : a = b := begin by_contradiction abne, have : abs (a - b) > 0, { apply lt_of_le_of_ne, { apply abs_nonneg }, intro h'', apply abne, apply eq_of_abs_sub_eq_zero h''.symm, }, let ε := abs (a - b) / 2, have εpos : ε > 0, { change abs (a - b) / 2 > 0, linarith }, cases sa ε εpos with Na hNa, cases sb ε εpos with Nb hNb, let N := max Na Nb, have absa : abs (s N - a) < ε, { apply hNa, apply le_max_left }, have absb : abs (s N - b) < ε, { apply hNb, apply le_max_right }, have : abs (a - b) < abs (a - b), calc abs (a - b) = abs (- (s N - a) + (s N - b)) : by { congr, ring } ... ≤ abs (- (s N - a)) + abs (s N - b) : abs_add _ _ ... = abs (s N - a) + abs (s N - b) : by rw [abs_neg] ... < ε + ε : add_lt_add absa absb ... = abs (a - b) : by norm_num, exact lt_irrefl _ this end
-
-
-
MIL/04_Sets_and_Functions/01_Sets.lean (deleted)
-
@@ -1,273 +0,0 @@import data.set.lattice import data.nat.parity import tactic section variable {α : Type*} variables (s t u : set α) open set example (h : s ⊆ t) : s ∩ u ⊆ t ∩ u := begin rw [subset_def, inter_def, inter_def], rw subset_def at h, dsimp, rintros x ⟨xs, xu⟩, exact ⟨h _ xs, xu⟩, end example (h : s ⊆ t) : s ∩ u ⊆ t ∩ u := begin simp only [subset_def, mem_inter_eq] at *, rintros x ⟨xs, xu⟩, exact ⟨h _ xs, xu⟩, end example (h : s ⊆ t) : s ∩ u ⊆ t ∩ u := begin intros x xsu, exact ⟨h xsu.1, xsu.2⟩ end theorem foo (h : s ⊆ t) : s ∩ u ⊆ t ∩ u := λ x ⟨xs, xu⟩, ⟨h xs, xu⟩ example (h : s ⊆ t) : s ∩ u ⊆ t ∩ u := by exact λ x ⟨xs, xu⟩, ⟨h xs, xu⟩ example : s ∩ (t ∪ u) ⊆ (s ∩ t) ∪ (s ∩ u) := begin intros x hx, have xs : x ∈ s := hx.1, have xtu : x ∈ t ∪ u := hx.2, cases xtu with xt xu, { left, show x ∈ s ∩ t, exact ⟨xs, xt⟩ }, right, show x ∈ s ∩ u, exact ⟨xs, xu⟩ end example : s ∩ (t ∪ u) ⊆ (s ∩ t) ∪ (s ∩ u) := begin rintros x ⟨xs, xt | xu⟩, { left, exact ⟨xs, xt⟩ }, right, exact ⟨xs, xu⟩ end example : (s ∩ t) ∪ (s ∩ u) ⊆ s ∩ (t ∪ u):= sorry example : s \ t \ u ⊆ s \ (t ∪ u) := begin intros x xstu, have xs : x ∈ s := xstu.1.1, have xnt : x ∉ t := xstu.1.2, have xnu : x ∉ u := xstu.2, split, { exact xs }, dsimp, intro xtu, -- x ∈ t ∨ x ∈ u cases xtu with xt xu, { show false, from xnt xt }, show false, from xnu xu end example : s \ t \ u ⊆ s \ (t ∪ u) := begin rintros x ⟨⟨xs, xnt⟩, xnu⟩, use xs, rintros (xt | xu); contradiction end example : s \ (t ∪ u) ⊆ s \ t \ u := sorry example : s ∩ t = t ∩ s := begin ext x, simp only [mem_inter_eq], split, { rintros ⟨xs, xt⟩, exact ⟨xt, xs⟩ }, rintros ⟨xt, xs⟩, exact ⟨xs, xt⟩ end example : s ∩ t = t ∩ s := set.ext $ λ x, ⟨λ ⟨xs, xt⟩, ⟨xt, xs⟩, λ ⟨xt, xs⟩, ⟨xs, xt⟩⟩ example : s ∩ t = t ∩ s := by ext x; simp [and.comm] example : s ∩ t = t ∩ s := begin apply subset.antisymm, { rintros x ⟨xs, xt⟩, exact ⟨xt, xs⟩ }, rintros x ⟨xt, xs⟩, exact ⟨xs, xt⟩ end example : s ∩ t = t ∩ s := subset.antisymm sorry sorry example : s ∩ (s ∪ t) = s := sorry example : s ∪ (s ∩ t) = s := sorry example : (s \ t) ∪ t = s ∪ t := sorry example : (s \ t) ∪ (t \ s) = (s ∪ t) \ (s ∩ t) := sorry def evens : set ℕ := {n | even n} def odds : set ℕ := {n | ¬ even n} example : evens ∪ odds = univ := begin rw [evens, odds], ext n, simp, apply classical.em end example (x : ℕ) (h : x ∈ (∅ : set ℕ)) : false := h example (x : ℕ) : x ∈ (univ : set ℕ) := trivial example : { n | nat.prime n } ∩ { n | n > 2} ⊆ { n | ¬ even n } := sorry #print prime #print nat.prime example (n : ℕ) : prime n ↔ nat.prime n := nat.prime_iff.symm example (n : ℕ) (h : prime n) : nat.prime n := by { rw nat.prime_iff, exact h } example (n : ℕ) (h : prime n) : nat.prime n := by rwa nat.prime_iff end section variables (s t : set ℕ) example (h₀ : ∀ x ∈ s, ¬ even x) (h₁ : ∀ x ∈ s, prime x) : ∀ x ∈ s, ¬ even x ∧ prime x := begin intros x xs, split, { apply h₀ x xs }, apply h₁ x xs end example (h : ∃ x ∈ s, ¬ even x ∧ prime x) : ∃ x ∈ s, prime x := begin rcases h with ⟨x, xs, _, prime_x⟩, use [x, xs, prime_x] end section variable (ssubt : s ⊆ t) include ssubt example (h₀ : ∀ x ∈ t, ¬ even x) (h₁ : ∀ x ∈ t, prime x) : ∀ x ∈ s, ¬ even x ∧ prime x := sorry example (h : ∃ x ∈ s, ¬ even x ∧ prime x) : ∃ x ∈ t, prime x := sorry end end section variables {α I : Type*} variables A B : I → set α variable s : set α open set example : s ∩ (⋃ i, A i) = ⋃ i, (A i ∩ s) := begin ext x, simp only [mem_inter_eq, mem_Union], split, { rintros ⟨xs, ⟨i, xAi⟩⟩, exact ⟨i, xAi, xs⟩ }, rintros ⟨i, xAi, xs⟩, exact ⟨xs, ⟨i, xAi⟩⟩ end example : (⋂ i, A i ∩ B i) = (⋂ i, A i) ∩ (⋂ i, B i) := begin ext x, simp only [mem_inter_eq, mem_Inter], split, { intro h, split, { intro i, exact (h i).1 }, intro i, exact (h i).2 }, rintros ⟨h1, h2⟩ i, split, { exact h1 i }, exact h2 i end open_locale classical example : s ∪ (⋂ i, A i) = ⋂ i, (A i ∪ s) := sorry def primes : set ℕ := {x | nat.prime x} example : (⋃ p ∈ primes, {x | p^2 ∣ x}) = {x | ∃ p ∈ primes, p^2 ∣ x} := by { ext, rw mem_Union₂, refl } example : (⋃ p ∈ primes, {x | p^2 ∣ x}) = {x | ∃ p ∈ primes, p^2 ∣ x} := by { ext, simp } example : (⋂ p ∈ primes, {x | ¬ p ∣ x}) ⊆ {x | x = 1} := begin intro x, contrapose!, simp, apply nat.exists_prime_and_dvd end example : (⋃ p ∈ primes, {x | x ≤ p}) = univ := sorry end section open set variables {α : Type*} (s : set (set α)) example : ⋃₀ s = ⋃ t ∈ s, t := begin ext x, rw mem_Union₂, refl end example : ⋂₀ s = ⋂ t ∈ s, t := begin ext x, rw mem_Inter₂, refl end end
-
-
MIL/04_Sets_and_Functions/01_Sets.olean (deleted)
-
-
@@ -1,216 +0,0 @@import data.set.lattice import data.set.function import analysis.special_functions.log.basic section variables {α β : Type*} variable f : α → β variables s t : set α variables u v : set β open function open set example : f ⁻¹' (u ∩ v) = f ⁻¹' u ∩ f ⁻¹' v := by { ext, refl } example : f '' (s ∪ t) = f '' s ∪ f '' t := begin ext y, split, { rintros ⟨x, xs | xt, rfl⟩, { left, use [x, xs] }, right, use [x, xt] }, rintros (⟨x, xs, rfl⟩ | ⟨x, xt, rfl⟩), { use [x, or.inl xs] }, use [x, or.inr xt] end example : s ⊆ f ⁻¹' (f '' s) := begin intros x xs, show f x ∈ f '' s, use [x, xs] end example : f '' s ⊆ v ↔ s ⊆ f ⁻¹' v := sorry example (h : injective f) : f ⁻¹' (f '' s) ⊆ s := sorry example : f '' (f⁻¹' u) ⊆ u := sorry example (h : surjective f) : u ⊆ f '' (f⁻¹' u) := sorry example (h : s ⊆ t) : f '' s ⊆ f '' t := sorry example (h : u ⊆ v) : f ⁻¹' u ⊆ f ⁻¹' v := sorry example : f ⁻¹' (u ∪ v) = f ⁻¹' u ∪ f ⁻¹' v := sorry example : f '' (s ∩ t) ⊆ f '' s ∩ f '' t := sorry example (h : injective f) : f '' s ∩ f '' t ⊆ f '' (s ∩ t) := sorry example : f '' s \ f '' t ⊆ f '' (s \ t) := sorry example : f ⁻¹' u \ f ⁻¹' v ⊆ f ⁻¹' (u \ v) := sorry example : f '' s ∩ v = f '' (s ∩ f ⁻¹' v) := sorry example : f '' (s ∩ f ⁻¹' u) ⊆ f '' s ∪ u := sorry example : s ∩ f ⁻¹' u ⊆ f ⁻¹' (f '' s ∩ u) := sorry example : s ∪ f ⁻¹' u ⊆ f ⁻¹' (f '' s ∪ u) := sorry variables {I : Type*} (A : I → set α) (B : I → set β) example : f '' (⋃ i, A i) = ⋃ i, f '' A i := begin ext y, simp, split, { rintros ⟨x, ⟨i, xAi⟩, fxeq⟩, use [i, x, xAi, fxeq] }, rintros ⟨i, x, xAi, fxeq⟩, exact ⟨x, ⟨i, xAi⟩, fxeq⟩ end example : f '' (⋂ i, A i) ⊆ ⋂ i, f '' A i := begin intro y, simp, intros x h fxeq i, use [x, h i, fxeq], end example (i : I) (injf : injective f) : (⋂ i, f '' A i) ⊆ f '' (⋂ i, A i) := begin intro y, simp, intro h, rcases h i with ⟨x, xAi, fxeq⟩, use x, split, { intro i', rcases h i' with ⟨x', x'Ai, fx'eq⟩, have : f x = f x', by rw [fxeq, fx'eq], have : x = x', from injf this, rw this, exact x'Ai }, exact fxeq end example : f ⁻¹' (⋃ i, B i) = ⋃ i, f ⁻¹' (B i) := by { ext x, simp } example : f ⁻¹' (⋂ i, B i) = ⋂ i, f ⁻¹' (B i) := by { ext x, simp } end section open set real example : inj_on log { x | x > 0 } := begin intros x xpos y ypos, intro e, -- log x = log y calc x = exp (log x) : by rw exp_log xpos ... = exp (log y) : by rw e ... = y : by rw exp_log ypos end example : range exp = { y | y > 0 } := begin ext y, split, { rintros ⟨x, rfl⟩, apply exp_pos }, intro ypos, use log y, rw exp_log ypos end example : inj_on sqrt { x | x ≥ 0 } := sorry example : inj_on (λ x, x^2) { x : ℝ | x ≥ 0 } := sorry example : sqrt '' { x | x ≥ 0 } = {y | y ≥ 0} := sorry example : range (λ x, x^2) = {y : ℝ | y ≥ 0} := sorry end section variables {α β : Type*} [inhabited α] #check (default : α) variables (P : α → Prop) (h : ∃ x, P x) #check classical.some h example : P (classical.some h) := classical.some_spec h noncomputable theory open_locale classical def inverse (f : α → β) : β → α := λ y : β, if h : ∃ x, f x = y then classical.some h else default theorem inverse_spec {f : α → β} (y : β) (h : ∃ x, f x = y) : f (inverse f y) = y := begin rw inverse, dsimp, rw dif_pos h, exact classical.some_spec h end variable f : α → β open function example : injective f ↔ left_inverse (inverse f) f := sorry example : surjective f ↔ right_inverse (inverse f) f := sorry end section variable {α : Type*} open function theorem Cantor : ∀ f : α → set α, ¬ surjective f := begin intros f surjf, let S := { i | i ∉ f i}, rcases surjf S with ⟨j, h⟩, have h₁ : j ∉ f j, { intro h', have : j ∉ f j, { by rwa h at h' }, contradiction }, have h₂ : j ∈ S, sorry, have h₃ : j ∉ S, sorry, contradiction end end
-
-
-
-
@@ -1,108 +0,0 @@import data.set.lattice import data.set.function import tactic open set open function noncomputable theory open_locale classical variables {α β : Type*} [nonempty β] section variables (f : α → β) (g : β → α) def sb_aux : ℕ → set α | 0 := univ \ (g '' univ) | (n + 1) := g '' (f '' sb_aux n) def sb_set := ⋃ n, sb_aux f g n def sb_fun (x : α) : β := if x ∈ sb_set f g then f x else inv_fun g x theorem sb_right_inv {x : α} (hx : x ∉ sb_set f g) : g (inv_fun g x) = x := begin have : x ∈ g '' univ, { contrapose! hx, rw [sb_set, mem_Union], use [0], rw [sb_aux, mem_diff], sorry }, have : ∃ y, g y = x, { sorry }, sorry end theorem sb_injective (hf: injective f) (hg : injective g) : injective (sb_fun f g) := begin set A := sb_set f g with A_def, set h := sb_fun f g with h_def, intros x₁ x₂, assume hxeq : h x₁ = h x₂, show x₁ = x₂, simp only [h_def, sb_fun, ←A_def] at hxeq, by_cases xA : x₁ ∈ A ∨ x₂ ∈ A, { wlog : x₁ ∈ A := xA using [x₁ x₂, x₂ x₁], have x₂A : x₂ ∈ A, { apply not_imp_self.mp, assume x₂nA : x₂ ∉ A, rw [if_pos xA, if_neg x₂nA] at hxeq, rw [A_def, sb_set, mem_Union] at xA, have x₂eq : x₂ = g (f x₁), { sorry }, rcases xA with ⟨n, hn⟩, rw [A_def, sb_set, mem_Union], use n + 1, simp [sb_aux], exact ⟨x₁, hn, x₂eq.symm⟩ }, sorry }, push_neg at xA, sorry end theorem sb_surjective (hf: injective f) (hg : injective g) : surjective (sb_fun f g) := begin set A := sb_set f g with A_def, set h := sb_fun f g with h_def, intro y, by_cases gyA : g y ∈ A, { rw [A_def, sb_set, mem_Union] at gyA, rcases gyA with ⟨n, hn⟩, cases n with n, { simp [sb_aux] at hn, contradiction }, simp [sb_aux] at hn, rcases hn with ⟨x, xmem, hx⟩, use x, have : x ∈ A, { rw [A_def, sb_set, mem_Union], exact ⟨n, xmem⟩ }, simp only [h_def, sb_fun, if_pos this], exact hg hx }, sorry end end theorem schroeder_bernstein {f : α → β} {g : β → α} (hf: injective f) (hg : injective g) : ∃ h : α → β, bijective h := ⟨sb_fun f g, sb_injective f g hf hg, sb_surjective f g hf hg⟩ /- Auxliary information -/ section variables (g : β → α) (x : α) #check (inv_fun g : α → β) #check (left_inverse_inv_fun : injective g → left_inverse (inv_fun g) g) #check (left_inverse_inv_fun : injective g → ∀ y, inv_fun g (g y) = y) #check (inv_fun_eq : (∃ y, g y = x) → g (inv_fun g x) = x) end
-
-
-
-
@@ -1,151 +0,0 @@import data.set.lattice import data.nat.parity import tactic section variable {α : Type*} variables (s t u : set α) open set example : (s ∩ t) ∪ (s ∩ u) ⊆ s ∩ (t ∪ u):= begin rintros x (⟨xs, xt⟩ | ⟨xs, xu⟩), { use xs, left, exact xt }, use xs, right, exact xu end example : s \ (t ∪ u) ⊆ s \ t \ u := begin rintros x ⟨xs, xntu⟩, use xs, { intro xt, exact xntu (or.inl xt) }, intro xu, apply xntu (or.inr xu) end example : s ∩ t = t ∩ s := subset.antisymm (λ x ⟨xs, xt⟩, ⟨xt, xs⟩) (λ x ⟨xt, xs⟩, ⟨xs, xt⟩) example : s ∩ (s ∪ t) = s := begin ext x, split, { rintros ⟨xs, _⟩, exact xs }, intro xs, use xs, left, exact xs end example : s ∪ (s ∩ t) = s := begin ext x, split, { rintros (xs | ⟨xs, xt⟩); exact xs }, intro xs, left, exact xs end example : (s \ t) ∪ t = s ∪ t := begin ext x, split, { rintros (⟨xs, nxt⟩ | xt), { left, exact xs}, right, exact xt }, by_cases h : x ∈ t, { intro _, right, exact h }, rintros (xs | xt), { left, use [xs, h] }, right, use xt end example : (s \ t) ∪ (t \ s) = (s ∪ t) \ (s ∩ t) := begin ext x, split, { rintros (⟨xs, xnt⟩ | ⟨xt, xns⟩), { split, left, exact xs, rintros ⟨_, xt⟩, contradiction }, split , right, exact xt, rintros ⟨xs, _⟩, contradiction }, rintros ⟨xs | xt, nxst⟩, { left, use xs, intro xt, apply nxst, split; assumption }, right, use xt, intro xs, apply nxst, split; assumption end example : { n | nat.prime n } ∩ { n | n > 2} ⊆ { n | ¬ even n } := begin intro n, simp, intro nprime, cases nat.prime.eq_two_or_odd nprime with h h, { rw h, intro, linarith }, rw [nat.even_iff, h], norm_num end end section variables (s t : set ℕ) section variable (ssubt : s ⊆ t) include ssubt example (h₀ : ∀ x ∈ t, ¬ even x) (h₁ : ∀ x ∈ t, prime x) : ∀ x ∈ s, ¬ even x ∧ prime x := begin intros x xs, split, { apply h₀ x (ssubt xs) }, apply h₁ x (ssubt xs) end example (h : ∃ x ∈ s, ¬ even x ∧ prime x) : ∃ x ∈ t, prime x := begin rcases h with ⟨x, xs, _, px⟩, use [x, ssubt xs, px] end end end section variables {α I : Type*} variables A B : I → set α variable s : set α open set example : s ∪ (⋂ i, A i) = ⋂ i, (A i ∪ s) := begin ext x, simp only [mem_union, mem_Inter], split, { rintros (xs | xI), { intro i, right, exact xs }, intro i, left, exact xI i }, intro h, by_cases xs : x ∈ s, { left, exact xs }, right, intro i, cases h i, { assumption }, contradiction end def primes : set ℕ := {x | nat.prime x} example : (⋃ p ∈ primes, {x | x ≤ p}) = univ := begin apply eq_univ_of_forall, intro x, simp, rcases nat.exists_infinite_primes x with ⟨p, primep, pge⟩, use [p, pge, primep] end end
-
-
-
-
@@ -1,281 +0,0 @@import data.set.lattice import data.set.function import analysis.special_functions.log.basic section variables {α β : Type*} variable f : α → β variables s t : set α variables u v : set β open function open set example : f '' s ⊆ v ↔ s ⊆ f ⁻¹' v := begin split, { intros h x xs, have : f x ∈ f '' s, from mem_image_of_mem _ xs, exact h this }, intros h y ymem, rcases ymem with ⟨x, xs, fxeq⟩, rw ← fxeq, apply h xs end example (h : injective f) : f ⁻¹' (f '' s) ⊆ s := begin rintros x ⟨y, ys, fxeq⟩, rw ← h fxeq, exact ys end example : f '' (f⁻¹' u) ⊆ u := begin rintros y ⟨x, xmem, rfl⟩, exact xmem end example (h : surjective f) : u ⊆ f '' (f⁻¹' u) := begin intros y yu, rcases h y with ⟨x, fxeq⟩, use x, split, { show f x ∈ u, rw fxeq, exact yu }, exact fxeq end example (h : s ⊆ t) : f '' s ⊆ f '' t := begin rintros y ⟨x, xs, fxeq⟩, use [x, h xs, fxeq] end example (h : u ⊆ v) : f ⁻¹' u ⊆ f ⁻¹' v := by intro x; apply h example : f ⁻¹' (u ∪ v) = f ⁻¹' u ∪ f ⁻¹' v := by ext x; refl example : f '' (s ∩ t) ⊆ f '' s ∩ f '' t := begin rintros y ⟨x, ⟨xs, xt⟩, rfl⟩, use [x, xs, rfl, x, xt, rfl] end example (h : injective f) : f '' s ∩ f '' t ⊆ f '' (s ∩ t) := begin rintros y ⟨⟨x₁, x₁s, rfl⟩, ⟨x₂, x₂t, fx₂eq⟩⟩, use [x₁, x₁s], rw ← h fx₂eq, exact x₂t end example : f '' s \ f '' t ⊆ f '' (s \ t) := begin rintros y ⟨⟨x₁, x₁s, rfl⟩, h⟩, use [x₁, x₁s], intro h', apply h, use [x₁, h', rfl] end example : f ⁻¹' u \ f ⁻¹' v ⊆ f ⁻¹' (u \ v) := λ x, id example : f '' s ∩ v = f '' (s ∩ f ⁻¹' v) := begin ext y, split, { rintros ⟨⟨x, xs, rfl⟩, fxv⟩, use [x, xs, fxv] }, rintros ⟨x, ⟨⟨xs, fxv⟩, rfl⟩⟩, use [x, xs, rfl, fxv], end example : f '' (s ∩ f ⁻¹' u) ⊆ f '' s ∩ u := begin rintros y ⟨x, ⟨xs, fxu⟩, rfl⟩, use [x, xs, rfl, fxu], end example : s ∩ f ⁻¹' u ⊆ f ⁻¹' (f '' s ∩ u) := begin rintros x ⟨xs, fxu⟩, use [x, xs, rfl, fxu], end example : s ∪ f ⁻¹' u ⊆ f ⁻¹' (f '' s ∪ u) := begin rintros x (xs | fxu), { left, use [x, xs, rfl] }, right, use fxu end variables {I : Type*} (A : I → set α) (B : I → set β) example : f '' (⋃ i, A i) = ⋃ i, f '' A i := begin ext y, simp, split, { rintros ⟨x, ⟨i, xAi⟩, fxeq⟩, use [i, x, xAi, fxeq] }, rintros ⟨i, x, xAi, fxeq⟩, exact ⟨x, ⟨i, xAi⟩, fxeq⟩ end example : f '' (⋂ i, A i) ⊆ ⋂ i, f '' A i := begin intro y, simp, intros x h fxeq i, use [x, h i, fxeq], end example (i : I) (injf : injective f) : (⋂ i, f '' A i) ⊆ f '' (⋂ i, A i) := begin intro y, simp, intro h, rcases h i with ⟨x, xAi, fxeq⟩, use x, split, { intro i', rcases h i' with ⟨x', x'Ai, fx'eq⟩, have : f x = f x', by rw [fxeq, fx'eq], have : x = x', from injf this, rw this, exact x'Ai }, exact fxeq end example : f ⁻¹' (⋃ i, B i) = ⋃ i, f ⁻¹' (B i) := by { ext x, simp } example : f ⁻¹' (⋂ i, B i) = ⋂ i, f ⁻¹' (B i) := by { ext x, simp } end section open set real example : inj_on sqrt { x | x ≥ 0 } := begin intros x xnonneg y ynonneg, intro e, calc x = (sqrt x)^2 : by rw sq_sqrt xnonneg ... = (sqrt y)^2 : by rw e ... = y : by rw sq_sqrt ynonneg end example : inj_on (λ x, x^2) { x : ℝ | x ≥ 0 } := begin intros x xnonneg y ynonneg, intro e, dsimp at *, calc x = sqrt (x^2) : by rw sqrt_sq xnonneg ... = sqrt (y^2) : by rw e ... = y : by rw sqrt_sq ynonneg, end example : sqrt '' { x | x ≥ 0 } = {y | y ≥ 0} := begin ext y, split, { rintros ⟨x, ⟨xnonneg, rfl⟩⟩, apply sqrt_nonneg }, intro ynonneg, use y^2, dsimp at *, split, apply pow_nonneg ynonneg, apply sqrt_sq, assumption, end example : range (λ x, x^2) = {y : ℝ | y ≥ 0} := begin ext y, split, { rintros ⟨x, rfl⟩, dsimp at *, apply pow_two_nonneg }, intro ynonneg, use sqrt y, exact sq_sqrt ynonneg, end end section variables {α β : Type*} [inhabited α] noncomputable theory open_locale classical def inverse (f : α → β) : β → α := λ y : β, if h : ∃ x, f x = y then classical.some h else default theorem inverse_spec {f : α → β} (y : β) (h : ∃ x, f x = y) : f (inverse f y) = y := begin rw inverse, dsimp, rw dif_pos h, exact classical.some_spec h end variable f : α → β open function example : injective f ↔ left_inverse (inverse f) f := begin split, { intros h y, apply h, apply inverse_spec, use y }, intros h x1 x2 e, rw [←h x1, ←h x2, e] end example : injective f ↔ left_inverse (inverse f) f := ⟨λ h y, h (inverse_spec _ ⟨y, rfl⟩), λ h x1 x2 e, by rw [←h x1, ←h x2, e]⟩ example : surjective f ↔ right_inverse (inverse f) f := begin split, { intros h y, apply inverse_spec, apply h }, intros h y, use (inverse f y), apply h end example : surjective f ↔ right_inverse (inverse f) f := ⟨λ h y, inverse_spec _ (h _), λ h y, ⟨inverse f y, h _⟩⟩ end section variable {α : Type*} open function theorem Cantor : ∀ f : α → set α, ¬ surjective f := begin intros f surjf, let S := { i | i ∉ f i}, rcases surjf S with ⟨j, h⟩, have h₁ : j ∉ f j, { intro h', have : j ∉ f j, by rwa h at h', contradiction }, have h₂ : j ∈ S, from h₁, have h₃ : j ∉ S, by rwa h at h₁, contradiction end end
-
-
-
-
@@ -1,94 +0,0 @@import data.set.lattice import data.set.function import tactic open set open function noncomputable theory open_locale classical variables {α β : Type*} [nonempty β] section variables (f : α → β) (g : β → α) def sb_aux : ℕ → set α | 0 := univ \ (g '' univ) | (n + 1) := g '' (f '' sb_aux n) def sb_set := ⋃ n, sb_aux f g n def sb_fun (x : α) : β := if x ∈ sb_set f g then f x else inv_fun g x theorem sb_right_inv {x : α} (hx : x ∉ sb_set f g) : g (inv_fun g x) = x := begin have : x ∈ g '' univ, { contrapose! hx, rw [sb_set, mem_Union], use [0], rw [sb_aux, mem_diff], exact ⟨mem_univ _, hx⟩ }, have : ∃ y, g y = x, { simp at this, assumption }, exact inv_fun_eq this end theorem sb_injective (hf: injective f) (hg : injective g) : injective (sb_fun f g) := begin set A := sb_set f g with A_def, set h := sb_fun f g with h_def, intros x₁ x₂, assume hxeq : h x₁ = h x₂, show x₁ = x₂, simp only [h_def, sb_fun, ←A_def] at hxeq, by_cases xA : x₁ ∈ A ∨ x₂ ∈ A, { wlog : x₁ ∈ A := xA using [x₁ x₂, x₂ x₁], have x₂A : x₂ ∈ A, { apply not_imp_self.mp, assume x₂nA : x₂ ∉ A, rw [if_pos xA, if_neg x₂nA] at hxeq, rw [A_def, sb_set, mem_Union] at xA, have x₂eq : x₂ = g (f x₁), { rw [hxeq, sb_right_inv f g x₂nA] }, rcases xA with ⟨n, hn⟩, rw [A_def, sb_set, mem_Union], use n + 1, simp [sb_aux], exact ⟨x₁, hn, x₂eq.symm⟩ }, rw [if_pos xA, if_pos x₂A] at hxeq, exact hf hxeq }, push_neg at xA, rw [if_neg xA.1, if_neg xA.2] at hxeq, rw [←sb_right_inv f g xA.1, hxeq, sb_right_inv f g xA.2] end theorem sb_surjective (hf: injective f) (hg : injective g) : surjective (sb_fun f g) := begin set A := sb_set f g with A_def, set h := sb_fun f g with h_def, intro y, by_cases gyA : g y ∈ A, { rw [A_def, sb_set, mem_Union] at gyA, rcases gyA with ⟨n, hn⟩, cases n with n, { simp [sb_aux] at hn, contradiction }, simp [sb_aux] at hn, rcases hn with ⟨x, xmem, hx⟩, use x, have : x ∈ A, { rw [A_def, sb_set, mem_Union], exact ⟨n, xmem⟩ }, simp only [h_def, sb_fun, if_pos this], exact hg hx }, use g y, simp only [h_def, sb_fun, if_neg gyA], apply left_inverse_inv_fun hg end end
-
-
-
-
@@ -1,126 +0,0 @@import data.nat.gcd import data.real.irrational #print nat.coprime example (m n : nat) (h : m.coprime n) : m.gcd n = 1 := h example (m n : nat) (h : m.coprime n) : m.gcd n = 1 := by { rw nat.coprime at h, exact h } example : nat.coprime 12 7 := by norm_num example : nat.gcd 12 8 = 4 := by norm_num #check @nat.prime_def_lt example (p : ℕ) (prime_p : nat.prime p) : 2 ≤ p ∧ ∀ (m : ℕ), m < p → m ∣ p → m = 1 := by rwa nat.prime_def_lt at prime_p #check nat.prime.eq_one_or_self_of_dvd example (p : ℕ) (prime_p : nat.prime p) : ∀ (m : ℕ), m ∣ p → m = 1 ∨ m = p := prime_p.eq_one_or_self_of_dvd example : nat.prime 17 := by norm_num -- commonly used example : nat.prime 2 := nat.prime_two example : nat.prime 3 := nat.prime_three #check @nat.prime.dvd_mul #check nat.prime.dvd_mul nat.prime_two #check nat.prime_two.dvd_mul lemma even_of_even_sqr {m : ℕ} (h : 2 ∣ m^2) : 2 ∣ m := begin rw [pow_two, nat.prime_two.dvd_mul] at h, cases h; assumption end example {m : ℕ} (h : 2 ∣ m^2) : 2 ∣ m := nat.prime.dvd_of_dvd_pow nat.prime_two h example (a b c : nat) (h : a * b = a * c) (h' : a ≠ 0) : b = c := begin -- library_search suggests the following: exact (mul_right_inj' h').mp h end example {m n : ℕ} (coprime_mn : m.coprime n) : m^2 ≠ 2 * n^2 := begin intro sqr_eq, have : 2 ∣ m, sorry, obtain ⟨k, meq⟩ := dvd_iff_exists_eq_mul_left.mp this, have : 2 * (2 * k^2) = 2 * n^2, { rw [←sqr_eq, meq], ring }, have : 2 * k^2 = n^2, sorry, have : 2 ∣ n, sorry, have : 2 ∣ m.gcd n, sorry, have : 2 ∣ 1, sorry, norm_num at this end example {m n p : ℕ} (coprime_mn : m.coprime n) (prime_p : p.prime) : m^2 ≠ p * n^2 := sorry #check nat.factors #check nat.prime_of_mem_factors #check nat.prod_factors #check nat.factors_unique theorem factorization_mul' {m n : ℕ} (mnez : m ≠ 0) (nnez : n ≠ 0) (p : ℕ) : (m * n).factorization p = m.factorization p + n.factorization p := by { rw nat.factorization_mul mnez nnez, refl } theorem factorization_pow' (n k p : ℕ) : (n^k).factorization p = k * n.factorization p := by { rw nat.factorization_pow, refl } theorem nat.prime.factorization' {p : ℕ} (prime_p : p.prime) : p.factorization p = 1 := by { rw prime_p.factorization, simp } example {m n p : ℕ} (nnz : n ≠ 0) (prime_p : p.prime) : m^2 ≠ p * n^2 := begin intro sqr_eq, have nsqr_nez : n^2 ≠ 0, by simpa, have eq1 : nat.factorization (m^2) p = 2 * m.factorization p, sorry, have eq2 : (p * n^2).factorization p = 2 * n.factorization p + 1, sorry, have : (2 * m.factorization p) % 2 = (2 * n.factorization p + 1) % 2, { rw [←eq1, sqr_eq, eq2] }, rw [add_comm, nat.add_mul_mod_self_left, nat.mul_mod_right] at this, norm_num at this end example {m n k r : ℕ} (nnz : n ≠ 0) (pow_eq : m^k = r * n^k) {p : ℕ} (prime_p : p.prime) : k ∣ r.factorization p := begin cases r with r, { simp }, have npow_nz : n^k ≠ 0 := λ npowz, nnz (pow_eq_zero npowz), have eq1 : (m^k).factorization p = k * m.factorization p, sorry, have eq2 : (r.succ * n^k).factorization p = k * n.factorization p + r.succ.factorization p, sorry, have : r.succ.factorization p = k * m.factorization p - k * n.factorization p, { rw [←eq1, pow_eq, eq2, add_comm, nat.add_sub_cancel] }, rw this, sorry end #check multiplicity #check @irrational_nrt_of_n_not_dvd_multiplicity #check irrational_sqrt_two
-
-
-
-
@@ -1,151 +0,0 @@import data.nat.prime import algebra.big_operators import tactic example (n : nat) : n.succ ≠ nat.zero := nat.succ_ne_zero n example (m n : nat) (h : m.succ = n.succ) : m = n := nat.succ.inj h def fac : ℕ → ℕ | 0 := 1 | (n + 1) := (n + 1) * fac n example : fac 0 = 1 := rfl example : fac 0 = 1 := by rw fac example : fac 0 = 1 := by simp [fac] example (n : ℕ) : fac (n + 1) = (n + 1) * fac n := rfl example (n : ℕ) : fac (n + 1) = (n + 1) * fac n := by rw fac example (n : ℕ) : fac (n + 1) = (n + 1) * fac n := by simp [fac] theorem fac_pos (n : ℕ) : 0 < fac n := begin induction n with n ih, { rw fac, exact zero_lt_one }, rw fac, exact mul_pos n.succ_pos ih, end theorem dvd_fac {i n : ℕ} (ipos : 0 < i) (ile : i ≤ n) : i ∣ fac n := begin induction n with n ih, { exact absurd ipos (not_lt_of_ge ile) }, rw fac, cases nat.of_le_succ ile with h h, { apply dvd_mul_of_dvd_right (ih h) }, rw h, apply dvd_mul_right end theorem pow_two_le_fac (n : ℕ) : 2^(n-1) ≤ fac n := begin cases n with n, { simp [fac] }, sorry end section variables {α : Type*} (s : finset ℕ) (f : ℕ → ℕ) (n : ℕ) #check finset.sum s f #check finset.prod s f open_locale big_operators open finset example : s.sum f = ∑ x in s, f x := rfl example : s.prod f = ∏ x in s, f x := rfl example : (range n).sum f = ∑ x in range n, f x := rfl example : (range n).prod f = ∏ x in range n, f x := rfl example (f : ℕ → ℕ) : ∑ x in range 0, f x = 0 := finset.sum_range_zero f example (f : ℕ → ℕ) (n : ℕ): ∑ x in range n.succ, f x = (∑ x in range n, f x) + f n := finset.sum_range_succ f n example (f : ℕ → ℕ) : ∏ x in range 0, f x = 1 := finset.prod_range_zero f example (f : ℕ → ℕ) (n : ℕ): ∏ x in range n.succ, f x = (∏ x in range n, f x) * f n := finset.prod_range_succ f n example (n : ℕ) : fac n = ∏ i in range n, (i + 1) := begin induction n with n ih, { simp [fac] }, simp [fac, ih, prod_range_succ, mul_comm] end example (a b c d e f : ℕ) : a * ((b * c) * f * (d * e)) = d * (a * f * e) * (c * b) := by simp [mul_assoc, mul_comm, mul_left_comm] theorem sum_id (n : ℕ) : ∑ i in range (n + 1), i = n * (n + 1) / 2 := begin symmetry, apply nat.div_eq_of_eq_mul_right (by norm_num : 0 < 2), induction n with n ih, { simp }, rw [finset.sum_range_succ, mul_add 2, ←ih, nat.succ_eq_add_one], ring end theorem sum_sqr (n : ℕ) : ∑ i in range (n + 1), i^2 = n * (n + 1) * (2 *n + 1) / 6 := sorry end inductive my_nat | zero : my_nat | succ : my_nat → my_nat namespace my_nat def add : my_nat → my_nat → my_nat | x zero := x | x (succ y) := succ (add x y) def mul : my_nat → my_nat → my_nat | x zero := zero | x (succ y) := add (mul x y) x theorem zero_add (n : my_nat) : add zero n = n := begin induction n with n ih, { refl }, rw [add, ih] end theorem succ_add (m n : my_nat) : add (succ m) n = succ (add m n) := begin induction n with n ih, { refl }, rw [add, ih], refl end theorem add_comm (m n : my_nat) : add m n = add n m := begin induction n with n ih, { rw zero_add, refl }, rw [add, succ_add, ih] end theorem add_assoc (m n k : my_nat) : add (add m n) k = add m (add n k) := sorry theorem mul_add (m n k : my_nat) : mul m (add n k) = add (mul m n) (mul m k) := sorry theorem zero_mul (n : my_nat) : mul zero n = zero := sorry theorem succ_mul (m n : my_nat) : mul (succ m) n = add (mul m n) n := sorry theorem mul_comm (m n : my_nat) : mul m n = mul n m := sorry end my_nat
-
-
-
-
@@ -1,254 +0,0 @@import data.nat.prime import algebra.big_operators import tactic open_locale big_operators theorem two_le {m : ℕ} (h0 : m ≠ 0) (h1 : m ≠ 1) : 2 ≤ m := begin cases m, contradiction, cases m, contradiction, repeat { apply nat.succ_le_succ }, apply zero_le end example {m : ℕ} (h0 : m ≠ 0) (h1 : m ≠ 1) : 2 ≤ m := begin by_contradiction h, push_neg at h, interval_cases m; contradiction end example {m : ℕ} (h0 : m ≠ 0) (h1 : m ≠ 1) : 2 ≤ m := begin by_contradiction h, push_neg at h, revert m h h0 h1, dec_trivial end example {m : ℕ} (h : m < 2) : m = 0 ∨ m = 1 := by dec_trivial! example {m : ℕ} (h0 : m ≠ 0) (h1 : m ≠ 1) : 2 ≤ m := by omega theorem exists_prime_factor {n : nat} (h : 2 ≤ n) : ∃ p : nat, p.prime ∧ p ∣ n := begin by_cases np : n.prime, { use [n, np, dvd_rfl] }, induction n using nat.strong_induction_on with n ih, dsimp at ih, rw nat.prime_def_lt at np, push_neg at np, rcases np h with ⟨m, mltn, mdvdn, mne1⟩, have : m ≠ 0, { intro mz, rw [mz, zero_dvd_iff] at mdvdn, linarith }, have mgt2 : 2 ≤ m := two_le this mne1, by_cases mp : m.prime, { use [m, mp, mdvdn] }, rcases ih m mltn mgt2 mp with ⟨p, pp, pdvd⟩, use [p, pp, pdvd.trans mdvdn] end theorem primes_infinite : ∀ n, ∃ p > n, nat.prime p := begin intro n, have : 2 ≤ nat.factorial (n + 1) + 1, sorry, rcases exists_prime_factor this with ⟨p, pp, pdvd⟩, refine ⟨p, _, pp⟩, show p > n, by_contradiction ple, push_neg at ple, have : p ∣ nat.factorial (n + 1), sorry, have : p ∣ 1, sorry, show false, sorry end open finset section variables {α : Type*} [decidable_eq α] (r s t : finset α) example : r ∩ (s ∪ t) ⊆ (r ∩ s) ∪ (r ∩ t) := begin rw subset_iff, intro x, rw [mem_inter, mem_union, mem_union, mem_inter, mem_inter], tauto end example : r ∩ (s ∪ t) ⊆ (r ∩ s) ∪ (r ∩ t) := by { simp [subset_iff], intro x, tauto } example : (r ∩ s) ∪ (r ∩ t) ⊆ r ∩ (s ∪ t) := by { simp [subset_iff], intro x, tauto } example : (r ∩ s) ∪ (r ∩ t) = r ∩ (s ∪ t) := by { ext x, simp, tauto } end section variables {α : Type*} [decidable_eq α] (r s t : finset α) example : (r ∪ s) ∩ (r ∪ t) = r ∪ (s ∩ t) := sorry example : (r \ s \ t) = r \ (s ∪ t) := sorry end example (s : finset ℕ) (n : ℕ) (h : n ∈ s) : n ∣ (∏ i in s, i) := finset.dvd_prod_of_mem _ h theorem nat.prime.eq_of_dvd_of_prime {p q : ℕ} (prime_p : nat.prime p) (prime_q : nat.prime q) (h : p ∣ q) : p = q := sorry theorem mem_of_dvd_prod_primes {s : finset ℕ} {p : ℕ} (prime_p : p.prime) : (∀ n ∈ s, nat.prime n) → (p ∣ ∏ n in s, n) → p ∈ s := begin intros h₀ h₁, induction s using finset.induction_on with a s ans ih, { simp at h₁, linarith [prime_p.two_le] }, simp [finset.prod_insert ans, prime_p.dvd_mul] at h₀ h₁, rw mem_insert, sorry end example (s : finset ℕ) (x : ℕ) : x ∈ s.filter nat.prime ↔ x ∈ s ∧ x.prime := mem_filter theorem primes_infinite' : ∀ (s : finset nat), ∃ p, nat.prime p ∧ p ∉ s := begin intro s, by_contradiction h, push_neg at h, set s' := s.filter nat.prime with s'_def, have mem_s' : ∀ {n : ℕ}, n ∈ s' ↔ n.prime, { intro n, simp [s'_def], apply h }, have : 2 ≤ (∏ i in s', i) + 1, sorry, rcases exists_prime_factor this with ⟨p, pp, pdvd⟩, have : p ∣ (∏ i in s', i), sorry, have : p ∣ 1, { convert nat.dvd_sub' pdvd this, simp }, show false, sorry end theorem bounded_of_ex_finset (Q : ℕ → Prop): (∃ s : finset ℕ, ∀ k, Q k → k ∈ s) → ∃ n, ∀ k, Q k → k < n := begin rintros ⟨s, hs⟩, use s.sup id + 1, intros k Qk, apply nat.lt_succ_of_le, show id k ≤ s.sup id, apply le_sup (hs k Qk) end theorem ex_finset_of_bounded (Q : ℕ → Prop) [decidable_pred Q] : (∃ n, ∀ k, Q k → k ≤ n) → (∃ s : finset ℕ, ∀ k, Q k ↔ k ∈ s) := begin rintros ⟨n, hn⟩, use (range (n + 1)).filter Q, intro k, simp [nat.lt_succ_iff], exact hn k end example : 27 % 4 = 3 := by norm_num example (n : ℕ) : (4 * n + 3) % 4 = 3 := by { rw [add_comm, nat.add_mul_mod_self_left], norm_num } theorem mod_4_eq_3_or_mod_4_eq_3 {m n : ℕ} (h : m * n % 4 = 3) : m % 4 = 3 ∨ n % 4 = 3 := begin revert h, rw [nat.mul_mod], have : m % 4 < 4 := nat.mod_lt m (by norm_num), interval_cases m % 4 with hm; simp [hm], have : n % 4 < 4 := nat.mod_lt n (by norm_num), interval_cases n % 4 with hn; simp [hn]; norm_num end theorem two_le_of_mod_4_eq_3 {n : ℕ} (h : n % 4 = 3) : 2 ≤ n := by apply two_le; { intro neq, rw neq at h, norm_num at h } theorem aux {m n : ℕ} (h₀ : m ∣ n) (h₁ : 2 ≤ m) (h₂ : m < n) : (n / m) ∣ n ∧ n / m < n := sorry theorem exists_prime_factor_mod_4_eq_3 {n : nat} (h : n % 4 = 3) : ∃ p : nat, p.prime ∧ p ∣ n ∧ p % 4 = 3 := begin by_cases np : n.prime, { use [n, np, dvd_rfl, h] }, induction n using nat.strong_induction_on with n ih, dsimp at ih, rw nat.prime_def_lt at np, push_neg at np, rcases np (two_le_of_mod_4_eq_3 h) with ⟨m, mltn, mdvdn, mne1⟩, have mge2 : 2 ≤ m, { apply two_le _ mne1, intro mz, rw [mz, zero_dvd_iff] at mdvdn, linarith }, have neq : m * (n / m) = n := nat.mul_div_cancel' mdvdn, have : m % 4 = 3 ∨ (n / m) % 4 = 3, { apply mod_4_eq_3_or_mod_4_eq_3, rw [neq, h] }, cases this with h1 h1, { sorry }, sorry end example (m n : ℕ) (s : finset ℕ) (h : m ∈ erase s n) : m ≠ n ∧ m ∈ s := by rwa mem_erase at h example (m n : ℕ) (s : finset ℕ) (h : m ∈ erase s n) : m ≠ n ∧ m ∈ s := by { simp at h, assumption } theorem primes_mod_4_eq_3_infinite : ∀ n, ∃ p > n, nat.prime p ∧ p % 4 = 3 := begin by_contradiction h, push_neg at h, cases h with n hn, have : ∃ s : finset nat, ∀ p : ℕ, p.prime ∧ p % 4 = 3 ↔ p ∈ s, { apply ex_finset_of_bounded, use n, contrapose! hn, rcases hn with ⟨p, ⟨pp, p4⟩, pltn⟩, exact ⟨p, pltn, pp, p4⟩ }, cases this with s hs, have h₀ : 2 ≤ 4 * (∏ i in erase s 3, i) + 3, sorry, have h₁ : (4 * (∏ i in erase s 3, i) + 3) % 4 = 3, sorry, rcases exists_prime_factor_mod_4_eq_3 h₁ with ⟨p, pp, pdvd, p4eq⟩, have ps : p ∈ s, sorry, have pne3 : p ≠ 3, sorry, have : p ∣ 4 * (∏ i in erase s 3, i), sorry, have : p ∣ 3, sorry, have : p = 3, sorry, contradiction end
-
-
-
-
@@ -1,107 +0,0 @@import data.nat.gcd import data.real.irrational lemma even_of_even_sqr {m : ℕ} (h : 2 ∣ m^2) : 2 ∣ m := begin rw [pow_two, nat.prime_two.dvd_mul] at h, cases h; assumption end example {m n : ℕ} (coprime_mn : m.coprime n) : m^2 ≠ 2 * n^2 := begin intro sqr_eq, have : 2 ∣ m, { apply even_of_even_sqr, rw sqr_eq, apply dvd_mul_right }, obtain ⟨k, meq⟩ := dvd_iff_exists_eq_mul_left.mp this, have : 2 * (2 * k^2) = 2 * n^2, { rw [←sqr_eq, meq], ring }, have : 2 * k^2 = n^2, from (mul_right_inj' (by norm_num)).mp this, have : 2 ∣ n, { apply even_of_even_sqr, rw ←this, apply dvd_mul_right }, have : 2 ∣ m.gcd n, by apply nat.dvd_gcd; assumption, have : 2 ∣ 1, { convert this, symmetry, exact coprime_mn }, norm_num at this end example {m n p : ℕ} (coprime_mn : m.coprime n) (prime_p : p.prime) : m^2 ≠ p * n^2 := begin intro sqr_eq, have : p ∣ m, { apply prime_p.dvd_of_dvd_pow, rw sqr_eq, apply dvd_mul_right }, obtain ⟨k, meq⟩ := dvd_iff_exists_eq_mul_left.mp this, have : p * (p * k^2) = p * n^2, { rw [←sqr_eq, meq], ring }, have : p * k^2 = n^2, { apply (mul_right_inj' _).mp this, exact prime_p.ne_zero }, have : p ∣ n, { apply prime_p.dvd_of_dvd_pow, rw ←this, apply dvd_mul_right }, have : p ∣ nat.gcd m n, { apply nat.dvd_gcd; assumption }, have : p ∣ 1, { convert this, symmetry, exact coprime_mn }, have : 2 ≤ 1, { apply prime_p.two_le.trans, exact nat.le_of_dvd zero_lt_one this }, norm_num at this end theorem factorization_mul' {m n : ℕ} (mnez : m ≠ 0) (nnez : n ≠ 0) (p : ℕ) : (m * n).factorization p = m.factorization p + n.factorization p := by { rw nat.factorization_mul mnez nnez, refl } theorem factorization_pow' (n k p : ℕ) : (n^k).factorization p = k * n.factorization p := by { rw nat.factorization_pow, refl } theorem nat.prime.factorization' {p : ℕ} (prime_p : p.prime) : p.factorization p = 1 := by { rw prime_p.factorization, simp } example {m n p : ℕ} (nnz : n ≠ 0) (prime_p : p.prime) : m^2 ≠ p * n^2 := begin intro sqr_eq, have nsqr_nez : n^2 ≠ 0, by simpa, have eq1 : nat.factorization (m^2) p = 2 * m.factorization p, by { rw factorization_pow' }, have eq2 : (p * n^2).factorization p = 2 * n.factorization p + 1, { rw [factorization_mul' prime_p.ne_zero nsqr_nez, prime_p.factorization', factorization_pow', add_comm] }, have : (2 * m.factorization p) % 2 = (2 * n.factorization p + 1) % 2, { rw [←eq1, sqr_eq, eq2] }, rw [add_comm, nat.add_mul_mod_self_left, nat.mul_mod_right] at this, norm_num at this end example {m n k r : ℕ} (nnz : n ≠ 0) (pow_eq : m^k = r * n^k) {p : ℕ} (prime_p : p.prime) : k ∣ r.factorization p := begin cases r with r, { simp }, have npow_nz : n^k ≠ 0 := λ npowz, nnz (pow_eq_zero npowz), have eq1 : (m^k).factorization p = k * m.factorization p, by rw factorization_pow', have eq2 : (r.succ * n^k).factorization p = k * n.factorization p + r.succ.factorization p, { rw [factorization_mul' r.succ_ne_zero npow_nz, factorization_pow', add_comm] }, have : r.succ.factorization p = k * m.factorization p - k * n.factorization p, { rw [←eq1, pow_eq, eq2, add_comm, nat.add_sub_cancel] }, rw this, apply nat.dvd_sub'; apply nat.dvd_mul_right end
-
-
-
-
@@ -1,114 +0,0 @@import data.nat.prime import algebra.big_operators import tactic def fac : ℕ → ℕ | 0 := 1 | (n + 1) := (n + 1) * fac n theorem pow_two_le_fac (n : ℕ) : 2^(n-1) ≤ fac n := begin cases n with n, { simp [fac] }, induction n with n ih, { simp [fac] }, simp at *, rw [pow_succ, fac], apply nat.mul_le_mul _ ih, repeat { apply nat.succ_le_succ }, apply zero_le end section variables {α : Type*} (s : finset ℕ) (f : ℕ → ℕ) (n : ℕ) open_locale big_operators open finset theorem sum_sqr (n : ℕ) : ∑ i in range (n + 1), i^2 = n * (n + 1) * (2 *n + 1) / 6 := begin symmetry, apply nat.div_eq_of_eq_mul_right (by norm_num : 0 < 6), induction n with n ih, { simp }, rw [finset.sum_range_succ, mul_add 6, ←ih, nat.succ_eq_add_one], ring end end inductive my_nat | zero : my_nat | succ : my_nat → my_nat namespace my_nat def add : my_nat → my_nat → my_nat | x zero := x | x (succ y) := succ (add x y) def mul : my_nat → my_nat → my_nat | x zero := zero | x (succ y) := add (mul x y) x theorem zero_add (n : my_nat) : add zero n = n := begin induction n with n ih, { refl }, rw [add, ih] end theorem succ_add (m n : my_nat) : add (succ m) n = succ (add m n) := begin induction n with n ih, { refl }, rw [add, ih], refl end theorem add_comm (m n : my_nat) : add m n = add n m := begin induction n with n ih, { rw zero_add, refl }, rw [add, succ_add, ih] end theorem add_assoc (m n k : my_nat) : add (add m n) k = add m (add n k) := begin induction k with k ih, { refl }, rw [add, ih], refl end theorem mul_add (m n k : my_nat) : mul m (add n k) = add (mul m n) (mul m k) := begin induction k with k ih, { refl }, rw [add, mul, mul, ih, add_assoc] end theorem zero_mul (n : my_nat) : mul zero n = zero := begin induction n with n ih, { refl }, rw [mul, ih], refl end theorem succ_mul (m n : my_nat) : mul (succ m) n = add (mul m n) n := begin induction n with n ih, { refl }, rw [mul, mul, ih, add_assoc, add_assoc, add_comm n, succ_add], refl end theorem mul_comm (m n : my_nat) : mul m n = mul n m := begin induction n with n ih, { rw [zero_mul], refl }, rw [mul, ih, succ_mul] end end my_nat
-
-
-
-
@@ -1,246 +0,0 @@import data.nat.prime import algebra.big_operators import tactic open_locale big_operators theorem two_le {m : ℕ} (h0 : m ≠ 0) (h1 : m ≠ 1) : 2 ≤ m := begin cases m, contradiction, cases m, contradiction, repeat { apply nat.succ_le_succ }, apply zero_le end theorem exists_prime_factor {n : nat} (h : 2 ≤ n) : ∃ p : nat, p.prime ∧ p ∣ n := begin by_cases np : n.prime, { use [n, np, dvd_rfl] }, induction n using nat.strong_induction_on with n ih, dsimp at ih, rw nat.prime_def_lt at np, push_neg at np, rcases np h with ⟨m, mltn, mdvdn, mne1⟩, have : m ≠ 0, { intro mz, rw [mz, zero_dvd_iff] at mdvdn, linarith }, have mgt2 : 2 ≤ m := two_le this mne1, by_cases mp : m.prime, { use [m, mp, mdvdn] }, rcases ih m mltn mgt2 mp with ⟨p, pp, pdvd⟩, use [p, pp, pdvd.trans mdvdn] end theorem primes_infinite : ∀ n, ∃ p > n, nat.prime p := begin intro n, have : 2 ≤ nat.factorial (n + 1) + 1, { apply nat.succ_le_succ, exact nat.succ_le_of_lt (nat.factorial_pos _) }, rcases exists_prime_factor this with ⟨p, pp, pdvd⟩, refine ⟨p, _, pp⟩, show p > n, by_contradiction ple, push_neg at ple, have : p ∣ nat.factorial (n + 1), { apply nat.dvd_factorial, apply pp.pos, linarith }, have : p ∣ 1, { convert nat.dvd_sub' pdvd this, simp }, show false, have := nat.le_of_dvd zero_lt_one this, linarith [pp.two_le] end open finset section variables {α : Type*} [decidable_eq α] (r s t : finset α) example : (r ∪ s) ∩ (r ∪ t) = r ∪ (s ∩ t) := begin ext x, rw [mem_inter, mem_union, mem_union, mem_union, mem_inter], tauto end example : (r ∪ s) ∩ (r ∪ t) = r ∪ (s ∩ t) := by { ext x, simp, tauto } example : (r \ s \ t) = r \ (s ∪ t) := begin ext x, rw [mem_sdiff, mem_sdiff, mem_sdiff, mem_union], tauto end example : (r \ s \ t) = r \ (s ∪ t) := by { ext x, simp, tauto } end theorem nat.prime.eq_of_dvd_of_prime {p q : ℕ} (prime_p : nat.prime p) (prime_q : nat.prime q) (h : p ∣ q) : p = q := begin cases prime_q.eq_one_or_self_of_dvd _ h, { linarith [prime_p.two_le] }, assumption end theorem mem_of_dvd_prod_primes {s : finset ℕ} {p : ℕ} (prime_p : p.prime) : (∀ n ∈ s, nat.prime n) → (p ∣ ∏ n in s, n) → p ∈ s := begin intros h₀ h₁, induction s using finset.induction_on with a s ans ih, { simp at h₁, linarith [prime_p.two_le] }, simp [finset.prod_insert ans, prime_p.dvd_mul] at h₀ h₁, rw mem_insert, cases h₁ with h₁ h₁, { left, exact prime_p.eq_of_dvd_of_prime h₀.1 h₁ }, right, exact ih h₀.2 h₁ end theorem primes_infinite' : ∀ (s : finset nat), ∃ p, nat.prime p ∧ p ∉ s := begin intro s, by_contradiction h, push_neg at h, set s' := s.filter nat.prime with s'_def, have mem_s' : ∀ {n : ℕ}, n ∈ s' ↔ n.prime, { intro n, simp [s'_def], apply h }, have : 2 ≤ (∏ i in s', i) + 1, { apply nat.succ_le_succ, apply nat.succ_le_of_lt, apply finset.prod_pos, intros n ns', apply (mem_s'.mp ns').pos }, rcases exists_prime_factor this with ⟨p, pp, pdvd⟩, have : p ∣ (∏ i in s', i), { apply dvd_prod_of_mem, rw mem_s', apply pp }, have : p ∣ 1, { convert nat.dvd_sub' pdvd this, simp }, show false, have := nat.le_of_dvd zero_lt_one this, linarith [pp.two_le] end theorem bounded_of_ex_finset (Q : ℕ → Prop): (∃ s : finset ℕ, ∀ k, Q k → k ∈ s) → ∃ n, ∀ k, Q k → k < n := begin rintros ⟨s, hs⟩, use s.sup id + 1, intros k Qk, apply nat.lt_succ_of_le, show id k ≤ s.sup id, apply le_sup (hs k Qk) end theorem ex_finset_of_bounded (Q : ℕ → Prop) [decidable_pred Q] : (∃ n, ∀ k, Q k → k ≤ n) → (∃ s : finset ℕ, ∀ k, Q k ↔ k ∈ s) := begin rintros ⟨n, hn⟩, use (range (n + 1)).filter Q, intro k, simp [nat.lt_succ_iff], exact hn k end theorem mod_4_eq_3_or_mod_4_eq_3 {m n : ℕ} (h : m * n % 4 = 3) : m % 4 = 3 ∨ n % 4 = 3 := begin revert h, rw [nat.mul_mod], have : m % 4 < 4 := nat.mod_lt m (by norm_num), interval_cases m % 4 with hm; simp [hm], have : n % 4 < 4 := nat.mod_lt n (by norm_num), interval_cases n % 4 with hn; simp [hn]; norm_num end theorem two_le_of_mod_4_eq_3 {n : ℕ} (h : n % 4 = 3) : 2 ≤ n := by apply two_le; { intro neq, rw neq at h, norm_num at h } theorem aux {m n : ℕ} (h₀ : m ∣ n) (h₁ : 2 ≤ m) (h₂ : m < n) : (n / m) ∣ n ∧ n / m < n := begin split, { exact nat.div_dvd_of_dvd h₀ }, exact nat.div_lt_self (lt_of_le_of_lt (zero_le _) h₂) h₁ end theorem exists_prime_factor_mod_4_eq_3 {n : nat} (h : n % 4 = 3) : ∃ p : nat, p.prime ∧ p ∣ n ∧ p % 4 = 3 := begin by_cases np : n.prime, { use [n, np, dvd_rfl, h] }, induction n using nat.strong_induction_on with n ih, dsimp at ih, rw nat.prime_def_lt at np, push_neg at np, rcases np (two_le_of_mod_4_eq_3 h) with ⟨m, mltn, mdvdn, mne1⟩, have mge2 : 2 ≤ m, { apply two_le _ mne1, intro mz, rw [mz, zero_dvd_iff] at mdvdn, linarith }, have neq : m * (n / m) = n := nat.mul_div_cancel' mdvdn, have : m % 4 = 3 ∨ (n / m) % 4 = 3, { apply mod_4_eq_3_or_mod_4_eq_3, rw [neq, h] }, cases this with h1 h1, { by_cases mp : m.prime, { use [m, mp, mdvdn, h1] }, rcases ih m mltn h1 mp with ⟨p, pp, pdvd, p4eq⟩, use [p, pp, pdvd.trans mdvdn, p4eq] }, obtain ⟨nmdvdn, nmltn⟩ := aux mdvdn mge2 mltn, by_cases nmp : (n / m).prime, { use [n / m, nmp, nmdvdn, h1] }, rcases ih (n / m) nmltn h1 nmp with ⟨p, pp, pdvd, p4eq⟩, use [p, pp, pdvd.trans nmdvdn, p4eq] end theorem primes_mod_4_eq_3_infinite : ∀ n, ∃ p > n, nat.prime p ∧ p % 4 = 3 := begin by_contradiction h, push_neg at h, cases h with n hn, have : ∃ s : finset nat, ∀ p : ℕ, p.prime ∧ p % 4 = 3 ↔ p ∈ s, { apply ex_finset_of_bounded, use n, contrapose! hn, rcases hn with ⟨p, ⟨pp, p4⟩, pltn⟩, exact ⟨p, pltn, pp, p4⟩ }, cases this with s hs, have h₀ : 2 ≤ 4 * (∏ i in erase s 3, i) + 3, { apply le_add_left, norm_num }, have h₁ : (4 * (∏ i in erase s 3, i) + 3) % 4 = 3, { rw [add_comm, nat.add_mul_mod_self_left], norm_num }, rcases exists_prime_factor_mod_4_eq_3 h₁ with ⟨p, pp, pdvd, p4eq⟩, have ps : p ∈ s, { rw ←hs p, exact ⟨pp, p4eq⟩ }, have pne3 : p ≠ 3, { intro peq, rw [peq, ←nat.dvd_add_iff_left (dvd_refl 3)] at pdvd, rw nat.prime_three.dvd_mul at pdvd, norm_num at pdvd, have : 3 ∈ s.erase 3, { apply mem_of_dvd_prod_primes nat.prime_three _ pdvd, intro n, simp [← hs n], tauto }, simp at this, exact this }, have : p ∣ 4 * (∏ i in erase s 3, i), { apply dvd_trans _ (dvd_mul_left _ _), apply dvd_prod_of_mem, simp, split; assumption }, have : p ∣ 3, { convert nat.dvd_sub' pdvd this, simp }, have : p = 3, { apply pp.eq_of_dvd_of_prime nat.prime_three this }, contradiction end
-
-
-
-
@@ -1,228 +0,0 @@import algebra.big_operators.ring import data.real.basic @[ext] structure point := (x : ℝ) (y : ℝ) (z : ℝ) #check point.ext example (a b : point) (hx : a.x = b.x) (hy : a.y = b.y) (hz : a.z = b.z) : a = b := begin ext, repeat { assumption } end def my_point1 : point := { x := 2, y := -1, z := 4 } def my_point2 := { point . x := 2, y := -1, z := 4 } def my_point3 : point := ⟨2, -1, 4⟩ def my_point4 := point.mk 2 (-1) 4 structure point' := build :: (x : ℝ) (y : ℝ) (z : ℝ) #check point'.build 2 (-1) 4 namespace point def add (a b : point) : point := ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩ def add' (a b : point) : point := { x := a.x + b.x, y := a.y + b.y, z := a.z + b.z } #check add my_point1 my_point2 #check my_point1.add my_point2 end point #check point.add my_point1 my_point2 #check my_point1.add my_point2 namespace point protected theorem add_comm (a b : point) : add a b = add b a := begin rw [add, add], ext; dsimp, repeat { apply add_comm } end example (a b : point) : add a b = add b a := by simp [add, add_comm] theorem add_x (a b : point) : (a.add b).x = a.x + b.x := rfl def add_alt : point → point → point | (point.mk x₁ y₁ z₁) (point.mk x₂ y₂ z₂) := ⟨x₁ + x₂, y₁ + y₂, z₁ + z₂⟩ def add_alt' : point → point → point | ⟨x₁, y₁, z₁⟩ ⟨x₂, y₂, z₂⟩ := ⟨x₁ + x₂, y₁ + y₂, z₁ + z₂⟩ theorem add_alt_x (a b : point) : (a.add_alt b).x = a.x + b.x := by { cases a, cases b, refl } theorem add_alt_comm (a b : point) : add_alt a b = add_alt b a := begin rcases a with ⟨xa, ya, za⟩, rcases b with ⟨xb, yb, zb⟩, rw [add_alt, add_alt], ext; dsimp, apply add_comm, repeat { apply add_comm }, end example (a b : point) : add_alt a b = add_alt b a := begin rcases a with ⟨xa, ya, za⟩, rcases b with ⟨xb, yb, zb⟩, simp [add_alt, add_comm] end example : ∀ a b : point, add_alt a b = add_alt b a := begin rintros ⟨xa, ya, za⟩ ⟨xb, yb, zb⟩, simp [add_alt, add_comm] end example : ∀ a b : point, add a b = add b a := λ ⟨xa, ya, za⟩ ⟨xb, yb, zb⟩, by simp [add, add_comm] protected theorem add_assoc (a b c : point) : (a.add b).add c = a.add (b.add c) := sorry def smul (r : ℝ) (a : point) : point := sorry theorem smul_distrib (r : ℝ) (a b : point) : (smul r a).add (smul r b) = smul r (a.add b) := sorry end point structure standard_two_simplex := (x : ℝ) (y : ℝ) (z : ℝ) (x_nonneg : 0 ≤ x) (y_nonneg : 0 ≤ y) (z_nonneg : 0 ≤ z) (sum_eq : x + y + z = 1) namespace standard_two_simplex def swap_xy (a : standard_two_simplex) : standard_two_simplex := { x := a.y, y := a.x, z := a.z, x_nonneg := a.y_nonneg, y_nonneg := a.x_nonneg, z_nonneg := a.z_nonneg, sum_eq := by rw [add_comm a.y a.x, a.sum_eq] } noncomputable theory def midpoint (a b : standard_two_simplex) : standard_two_simplex := { x := (a.x + b.x) / 2, y := (a.y + b.y) / 2, z := (a.z + b.z) / 2, x_nonneg := div_nonneg (add_nonneg a.x_nonneg b.x_nonneg) (by norm_num), y_nonneg := div_nonneg (add_nonneg a.y_nonneg b.y_nonneg) (by norm_num), z_nonneg := div_nonneg (add_nonneg a.z_nonneg b.z_nonneg) (by norm_num), sum_eq := by { field_simp, linarith [a.sum_eq, b.sum_eq]} } def weighted_average (lambda : real) (lambda_nonneg : 0 ≤ lambda) (lambda_le : lambda ≤ 1) (a b : standard_two_simplex) : standard_two_simplex := sorry end standard_two_simplex open_locale big_operators structure standard_simplex (n : ℕ) := (v : fin n → ℝ) (nonneg : ∀ i : fin n, 0 ≤ v i) (sum_eq_one : ∑ i, v i = 1) namespace standard_simplex def midpoint (n : ℕ) (a b : standard_simplex n) : standard_simplex n := { v := λ i, (a.v i + b.v i) / 2, nonneg := begin intro i, apply div_nonneg, { linarith [a.nonneg i, b.nonneg i] }, norm_num end, sum_eq_one := begin simp [div_eq_mul_inv, ←finset.sum_mul, finset.sum_add_distrib, a.sum_eq_one, b.sum_eq_one], field_simp end } end standard_simplex structure is_linear (f : ℝ → ℝ) := (is_additive : ∀ x y, f (x + y) = f x + f y) (preserves_mul : ∀ x c, f (c * x) = c * f x) section variables (f : ℝ → ℝ) (linf : is_linear f) #check linf.is_additive #check linf.preserves_mul end def point'' := ℝ × ℝ × ℝ def is_linear' (f : ℝ → ℝ) := (∀ x y, f (x + y) = f x + f y) ∧ (∀ x c, f (c * x) = c * f x) def preal := { y : ℝ // 0 < y } section variable x : preal #check x.val #check x.property #check x.1 #check x.2 end def standard_two_simplex' := { p : ℝ × ℝ × ℝ // 0 ≤ p.1 ∧ 0 ≤ p.2.1 ∧ 0 ≤ p.2.2 ∧ p.1 + p.2.1 + p.2.2 = 1 } def standard_simplex' (n : ℕ) := { v : fin n → ℝ // (∀ i : fin n, 0 ≤ v i) ∧ (∑ i, v i = 1) } def std_simplex := Σ n : ℕ, standard_simplex n section variable s : std_simplex #check s.fst #check s.snd #check s.1 #check s.2 end
-
-
-
-
@@ -1,154 +0,0 @@import data.real.basic structure group₁ (α : Type*) := (mul: α → α → α) (one: α) (inv: α → α) (mul_assoc : ∀ x y z : α, mul (mul x y) z = mul x (mul y z)) (mul_one: ∀ x : α, mul x one = x) (one_mul: ∀ x : α, mul x one = x) (mul_left_inv : ∀ x : α, mul (inv x) x = one) structure Group₁ := (α : Type*) (str : group₁ α) section variables (α β γ : Type*) variables (f : α ≃ β) (g : β ≃ γ) #check equiv α β #check (f.to_fun : α → β) #check (f.inv_fun : β → α) #check (f.right_inv: ∀ x : β, f (f.inv_fun x) = x) #check (f.left_inv: ∀ x : α, f.inv_fun (f x) = x) #check (equiv.refl α : α ≃ α) #check (f.symm : β ≃ α) #check (f.trans g : α ≃ γ) example (x : α) : (f.trans g).to_fun x = g.to_fun (f.to_fun x) := rfl example (x : α) : (f.trans g) x = g (f x) := rfl example : (f.trans g : α → γ) = g ∘ f := rfl end example (α : Type*) : equiv.perm α = (α ≃ α) := rfl def perm_group {α : Type*} : group₁ (equiv.perm α) := { mul := λ f g, equiv.trans g f, one := equiv.refl α, inv := equiv.symm, mul_assoc := λ f g h, (equiv.trans_assoc _ _ _).symm, one_mul := equiv.trans_refl, mul_one := equiv.refl_trans, mul_left_inv := equiv.self_trans_symm } structure add_group₁ (α : Type*) := (add : α → α → α) -- fill in the rest @[ext] structure point := (x : ℝ) (y : ℝ) (z : ℝ) namespace point def add (a b : point) : point := ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩ def neg (a b : point) : point := sorry def zero : point := sorry def add_group_point : add_group point := sorry end point section variables {α : Type*} (f g : equiv.perm α) (n : ℕ) #check f * g #check mul_assoc f g g⁻¹ -- group power, defined for any group #check g^n example : f * g * (g⁻¹) = f := by { rw [mul_assoc, mul_right_inv, mul_one] } example : f * g * (g⁻¹) = f := mul_inv_cancel_right f g example {α : Type*} (f g : equiv.perm α) : g.symm.trans (g.trans f) = f := mul_inv_cancel_right f g end class group₂ (α : Type*) := (mul: α → α → α) (one: α) (inv: α → α) (mul_assoc : ∀ x y z : α, mul (mul x y) z = mul x (mul y z)) (mul_one: ∀ x : α, mul x one = x) (one_mul: ∀ x : α, mul x one = x) (mul_left_inv : ∀ x : α, mul (inv x) x = one) instance {α : Type*} : group₂ (equiv.perm α) := { mul := λ f g, equiv.trans g f, one := equiv.refl α, inv := equiv.symm, mul_assoc := λ f g h, (equiv.trans_assoc _ _ _).symm, one_mul := equiv.trans_refl, mul_one := equiv.refl_trans, mul_left_inv := equiv.self_trans_symm } #check @group₂.mul def my_square {α : Type*} [group₂ α] (x : α) := group₂.mul x x #check @my_square section variables {β : Type*} (f g : equiv.perm β) example : group₂.mul f g = g.trans f := rfl example : my_square f = f.trans f := rfl end instance : inhabited point := { default := ⟨0, 0, 0⟩ } #check (default : point) example : ([] : list point).head = default := rfl instance : has_add point := { add := point.add } section variables x y : point #check x + y example : x + y = point.add x y := rfl end instance has_mul_group₂ {α : Type*} [group₂ α] : has_mul α := ⟨group₂.mul⟩ instance has_one_group₂ {α : Type*} [group₂ α] : has_one α := ⟨group₂.one⟩ instance has_inv_group₂ {α : Type*} [group₂ α] : has_inv α := ⟨group₂.inv⟩ section variables {α : Type*} (f g : equiv.perm α) #check f * 1 * g⁻¹ def foo: f * 1 * g⁻¹ = g.symm.trans ((equiv.refl α).trans f) := rfl end class add_group₂ (α : Type*) := (add : α → α → α) -- fill in the rest
-
-
-
-
@@ -1,101 +0,0 @@import algebra.big_operators.ring import data.real.basic @[ext] structure point := (x : ℝ) (y : ℝ) (z : ℝ) namespace point def add (a b : point) : point := ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩ protected theorem add_assoc (a b c : point) : (a.add b).add c = a.add (b.add c) := by { simp [add, add_assoc] } def smul (r : ℝ) (a : point) : point := ⟨r * a.x, r * a.y, r * a.z⟩ theorem smul_distrib (r : ℝ) (a b : point) : (smul r a).add (smul r b) = smul r (a.add b) := by { simp [add, smul, mul_add] } end point structure standard_two_simplex := (x : ℝ) (y : ℝ) (z : ℝ) (x_nonneg : 0 ≤ x) (y_nonneg : 0 ≤ y) (z_nonneg : 0 ≤ z) (sum_eq : x + y + z = 1) namespace standard_two_simplex noncomputable theory def weighted_average (lambda : real) (lambda_nonneg : 0 ≤ lambda) (lambda_le : lambda ≤ 1) (a b : standard_two_simplex) : standard_two_simplex := { x := lambda * a.x + (1 - lambda) * b.x, y := lambda * a.y + (1 - lambda) * b.y, z := lambda * a.z + (1 - lambda) * b.z, x_nonneg := add_nonneg (mul_nonneg lambda_nonneg a.x_nonneg) (mul_nonneg (by linarith) b.x_nonneg), y_nonneg := add_nonneg (mul_nonneg lambda_nonneg a.y_nonneg) (mul_nonneg (by linarith) b.y_nonneg), z_nonneg := add_nonneg (mul_nonneg lambda_nonneg a.z_nonneg) (mul_nonneg (by linarith) b.z_nonneg), sum_eq := begin transitivity (a.x + a.y + a.z) * lambda + (b.x + b.y + b.z) * (1 - lambda), { ring }, simp [a.sum_eq, b.sum_eq] end } end standard_two_simplex open_locale big_operators structure standard_simplex (n : ℕ) := (v : fin n → ℝ) (nonneg : ∀ i : fin n, 0 ≤ v i) (sum_eq_one : ∑ i, v i = 1) namespace standard_simplex def midpoint (n : ℕ) (a b : standard_simplex n) : standard_simplex n := { v := λ i, (a.v i + b.v i) / 2, nonneg := begin intro i, apply div_nonneg, { linarith [a.nonneg i, b.nonneg i] }, norm_num end, sum_eq_one := begin simp [div_eq_mul_inv, ←finset.sum_mul, finset.sum_add_distrib, a.sum_eq_one, b.sum_eq_one], field_simp end } end standard_simplex namespace standard_simplex def weighted_average {n : ℕ} (lambda : real) (lambda_nonneg : 0 ≤ lambda) (lambda_le : lambda ≤ 1) (a b : standard_simplex n) : standard_simplex n := { v := λ i, lambda * a.v i + (1 - lambda) * b.v i, nonneg := λ i, add_nonneg (mul_nonneg lambda_nonneg (a.nonneg i)) (mul_nonneg (by linarith) (b.nonneg i)), sum_eq_one := begin transitivity lambda * (∑ i, a.v i) + (1 - lambda) * (∑ i, b.v i), { rw [finset.sum_add_distrib, finset.mul_sum, finset.mul_sum] }, simp [a.sum_eq_one, b.sum_eq_one] end } end standard_simplex
-
-
-
-
@@ -1,65 +0,0 @@import data.real.basic structure add_group₁ (α : Type*) := (add: α → α → α) (zero: α) (neg: α → α) (add_assoc : ∀ x y z : α, add (add x y) z = add x (add y z)) (add_zero: ∀ x : α, add x zero = x) (zero_add: ∀ x : α, add x zero = x) (add_left_neg : ∀ x : α, add (neg x) x = zero) @[ext] structure point := (x : ℝ) (y : ℝ) (z : ℝ) namespace point def add (a b : point) : point := ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩ def neg (a : point) : point := ⟨-a.x, -a.y, -a.z⟩ def zero : point := ⟨0, 0, 0⟩ def add_group_point : add_group₁ point := { add := point.add, zero := point.zero, neg := point.neg, add_assoc := by { simp [point.add, add_assoc] }, add_zero := by { simp [point.add, point.zero], intro, ext; refl }, zero_add := by { simp [point.add, point.zero], intro, ext; refl }, add_left_neg := by { simp [point.add, point.neg, point.zero] } } end point class add_group₂ (α : Type*) := (add: α → α → α) (zero: α) (neg: α → α) (add_assoc : ∀ x y z : α, add (add x y) z = add x (add y z)) (add_zero: ∀ x : α, add x zero = x) (zero_add: ∀ x : α, add x zero = x) (add_left_neg : ∀ x : α, add (neg x) x = zero) instance has_add_add_group₂ {α : Type*} [add_group₂ α] : has_add α := ⟨add_group₂.add⟩ instance has_zero_add_group₂ {α : Type*} [add_group₂ α] : has_zero α := ⟨add_group₂.zero⟩ instance has_neg_add_group₂ {α : Type*} [add_group₂ α] : has_neg α := ⟨add_group₂.neg⟩ instance : add_group₂ point := { add := point.add, zero := point.zero, neg := point.neg, add_assoc := by { simp [point.add, add_assoc] }, add_zero := by { simp [point.add, point.zero], intro, ext; refl }, zero_add := by { simp [point.add, point.zero], intro, ext; refl }, add_left_neg := by { simp [point.add, point.neg, point.zero] } } section variables (x y : point) #check x + -y + 0 end
-
-
-
MIL/07_Topology/01_Filters.lean (deleted)
-
@@ -1,106 +0,0 @@import topology.instances.real open set filter open_locale topological_space filter def principal {α : Type*} (s : set α) : filter α := { sets := {t | s ⊆ t}, univ_sets := sorry, sets_of_superset := sorry, inter_sets := sorry} example : filter ℕ := { sets := {s | ∃ a, ∀ b, a ≤ b → b ∈ s}, univ_sets := sorry, sets_of_superset := sorry, inter_sets := sorry } def tendsto₁ {X Y : Type*} (f : X → Y) (F : filter X) (G : filter Y) := ∀ V ∈ G, f ⁻¹' V ∈ F def tendsto₂ {X Y : Type*} (f : X → Y) (F : filter X) (G : filter Y) := map f F ≤ G example {X Y : Type*} (f : X → Y) (F : filter X) (G : filter Y) : tendsto₂ f F G ↔ tendsto₁ f F G := iff.rfl #check (@filter.map_mono : ∀ {α β} {m : α → β}, monotone (map m)) #check (@filter.map_map : ∀ {α β γ} {f : filter α} {m : α → β} {m' : β → γ}, map m' (map m f) = map (m' ∘ m) f) example {X Y Z : Type*} {F : filter X} {G : filter Y} {H : filter Z} {f : X → Y} {g : Y → Z} (hf : tendsto₁ f F G) (hg : tendsto₁ g G H) : tendsto₁ (g ∘ f) F H := sorry variables (f : ℝ → ℝ) (x₀ y₀ : ℝ) #check comap (coe : ℚ → ℝ) (𝓝 x₀) #check tendsto (f ∘ coe) (comap (coe : ℚ → ℝ) (𝓝 x₀)) (𝓝 y₀) section variables {α β γ : Type*} (F : filter α) {m : γ → β} {n : β → α} #check (comap_comap : comap m (comap n F) = comap (n ∘ m) F) end example : 𝓝 (x₀, y₀) = 𝓝 x₀ ×ᶠ 𝓝 y₀ := nhds_prod_eq #check le_inf_iff example (f : ℕ → ℝ × ℝ) (x₀ y₀ : ℝ) : tendsto f at_top (𝓝 (x₀, y₀)) ↔ tendsto (prod.fst ∘ f) at_top (𝓝 x₀) ∧ tendsto (prod.snd ∘ f) at_top (𝓝 y₀) := sorry example (x₀ : ℝ) : has_basis (𝓝 x₀) (λ ε : ℝ, 0 < ε) (λ ε, Ioo (x₀ - ε) (x₀ + ε)) := nhds_basis_Ioo_pos x₀ example (u : ℕ → ℝ) (x₀ : ℝ) : tendsto u at_top (𝓝 x₀) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, u n ∈ Ioo (x₀ - ε) (x₀ + ε) := begin have : at_top.has_basis (λ n : ℕ, true) Ici := at_top_basis, rw this.tendsto_iff (nhds_basis_Ioo_pos x₀), simp end example (P Q : ℕ → Prop) (hP : ∀ᶠ n in at_top, P n) (hQ : ∀ᶠ n in at_top, Q n) : ∀ᶠ n in at_top, P n ∧ Q n := hP.and hQ example (u v : ℕ → ℝ) (h : ∀ᶠ n in at_top, u n = v n) (x₀ : ℝ) : tendsto u at_top (𝓝 x₀) ↔ tendsto v at_top (𝓝 x₀) := tendsto_congr' h example (u v : ℕ → ℝ) (h : u =ᶠ[at_top] v) (x₀ : ℝ) : tendsto u at_top (𝓝 x₀) ↔ tendsto v at_top (𝓝 x₀) := tendsto_congr' h #check @eventually_of_forall #check @eventually.mono #check @eventually.and example (P Q R : ℕ → Prop) (hP : ∀ᶠ n in at_top, P n) (hQ : ∀ᶠ n in at_top, Q n) (hR : ∀ᶠ n in at_top, P n ∧ Q n → R n) : ∀ᶠ n in at_top, R n := begin apply (hP.and (hQ.and hR)).mono, rintros n ⟨h, h', h''⟩, exact h'' ⟨h, h'⟩ end example (P Q R : ℕ → Prop) (hP : ∀ᶠ n in at_top, P n) (hQ : ∀ᶠ n in at_top, Q n) (hR : ∀ᶠ n in at_top, P n ∧ Q n → R n) : ∀ᶠ n in at_top, R n := begin filter_upwards [hP, hQ, hR], intros n h h' h'', exact h'' ⟨h, h'⟩ end #check mem_closure_iff_cluster_pt #check le_principal_iff #check ne_bot_of_le example (u : ℕ → ℝ) (M : set ℝ) (x : ℝ) (hux : tendsto u at_top (𝓝 x)) (huM : ∀ᶠ n in at_top, u n ∈ M) : x ∈ closure M := sorry
-
-
MIL/07_Topology/01_Filters.olean (deleted)
-
MIL/07_Topology/02_Metric_Spaces.lean (deleted)
-
@@ -1,282 +0,0 @@import topology.instances.real import analysis.normed_space.banach_steinhaus open set filter open_locale topological_space filter variables {X : Type*} [metric_space X] (a b c : X) #check (dist a b : ℝ) #check (dist_nonneg : 0 ≤ dist a b) #check (dist_eq_zero : dist a b = 0 ↔ a = b) #check (dist_comm a b : dist a b = dist b a) #check (dist_triangle a b c : dist a c ≤ dist a b + dist b c) -- Note the next three lines are not quoted, their purpose is to make sure those things don't get renamed while we're looking elsewhere. #check emetric_space #check pseudo_metric_space #check pseudo_emetric_space example {u : ℕ → X} {a : X} : tendsto u at_top (𝓝 a) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, dist (u n) a < ε := metric.tendsto_at_top example {X Y : Type*} [metric_space X] [metric_space Y] {f : X → Y} : continuous f ↔ ∀ x : X, ∀ ε > 0, ∃ δ > 0, ∀ x', dist x' x < δ → dist (f x') (f x) < ε := metric.continuous_iff example {X Y : Type*} [metric_space X] [metric_space Y] {f : X → Y} (hf : continuous f) : continuous (λ p : X × X, dist (f p.1) (f p.2)) := by continuity example {X Y : Type*} [metric_space X] [metric_space Y] {f : X → Y} (hf : continuous f) : continuous (λ p : X × X, dist (f p.1) (f p.2)) := continuous_dist.comp ((hf.comp continuous_fst).prod_mk (hf.comp continuous_snd)) example {X Y : Type*} [metric_space X] [metric_space Y] {f : X → Y} (hf : continuous f) : continuous (λ p : X × X, dist (f p.1) (f p.2)) := begin apply continuous.dist, exact hf.comp continuous_fst, exact hf.comp continuous_snd end example {X Y : Type*} [metric_space X] [metric_space Y] {f : X → Y} (hf : continuous f) : continuous (λ p : X × X, dist (f p.1) (f p.2)) := (hf.comp continuous_fst).dist (hf.comp continuous_snd) example {X Y : Type*} [metric_space X] [metric_space Y] {f : X → Y} (hf : continuous f) : continuous (λ p : X × X, dist (f p.1) (f p.2)) := hf.fst'.dist hf.snd' example {f : ℝ → X} (hf : continuous f) : continuous (λ x : ℝ, f (x^2 + x)) := sorry example {X Y : Type*} [metric_space X] [metric_space Y] (f : X → Y) (a : X) : continuous_at f a ↔ ∀ ε > 0, ∃ δ > 0, ∀ {x}, dist x a < δ → dist (f x) (f a) < ε := metric.continuous_at_iff variables r : ℝ example : metric.ball a r = {b | dist b a < r} := rfl example : metric.closed_ball a r = {b | dist b a ≤ r} := rfl example (hr : 0 < r) : a ∈ metric.ball a r := metric.mem_ball_self hr example (hr : 0 ≤ r) : a ∈ metric.closed_ball a r := metric.mem_closed_ball_self hr example (s : set X) : is_open s ↔ ∀ x ∈ s, ∃ ε > 0, metric.ball x ε ⊆ s := metric.is_open_iff example {s : set X} : is_closed s ↔ is_open sᶜ := is_open_compl_iff.symm example {s : set X} (hs : is_closed s) {u : ℕ → X} (hu : tendsto u at_top (𝓝 a)) (hus : ∀ n, u n ∈ s) : a ∈ s := hs.mem_of_tendsto hu (eventually_of_forall hus) example {s : set X} : a ∈ closure s ↔ ∀ ε > 0, ∃ b ∈ s, a ∈ metric.ball b ε := metric.mem_closure_iff example {u : ℕ → X} (hu : tendsto u at_top (𝓝 a)) {s : set X} (hs : ∀ n, u n ∈ s) : a ∈ closure s := sorry example {x : X} {s : set X} : s ∈ 𝓝 x ↔ ∃ ε > 0, metric.ball x ε ⊆ s := metric.nhds_basis_ball.mem_iff example {x : X} {s : set X} : s ∈ 𝓝 x ↔ ∃ ε > 0, metric.closed_ball x ε ⊆ s := metric.nhds_basis_closed_ball.mem_iff example : is_compact (set.Icc 0 1 : set ℝ) := is_compact_Icc example {s : set X} (hs : is_compact s) {u : ℕ → X} (hu : ∀ n, u n ∈ s) : ∃ a ∈ s, ∃ φ : ℕ → ℕ, strict_mono φ ∧ tendsto (u ∘ φ) at_top (𝓝 a) := hs.tendsto_subseq hu example {s : set X} (hs : is_compact s) (hs' : s.nonempty) {f : X → ℝ} (hfs : continuous_on f s) : ∃ x ∈ s, ∀ y ∈ s, f x ≤ f y := hs.exists_forall_le hs' hfs example {s : set X} (hs : is_compact s) (hs' : s.nonempty) {f : X → ℝ} (hfs : continuous_on f s) : ∃ x ∈ s, ∀ y ∈ s, f y ≤ f x := hs.exists_forall_ge hs' hfs example {s : set X} (hs : is_compact s) : is_closed s := hs.is_closed example {X : Type*} [metric_space X] [compact_space X] : is_compact (univ : set X) := compact_univ #check is_compact.is_closed example {X : Type*} [metric_space X] {Y : Type*} [metric_space Y] {f : X → Y} : uniform_continuous f ↔ ∀ ε > 0, ∃ δ > 0, ∀ {a b : X}, dist a b < δ → dist (f a) (f b) < ε := metric.uniform_continuous_iff example {X : Type*} [metric_space X] [compact_space X] {Y : Type*} [metric_space Y] {f : X → Y} (hf : continuous f) : uniform_continuous f := sorry -- SOLUTIONs: example {X : Type*} [metric_space X] [compact_space X] {Y : Type*} [metric_space Y] {f : X → Y} (hf : continuous f) : uniform_continuous f := begin rw metric.uniform_continuous_iff, intros ε ε_pos, let φ : X × X → ℝ := λ p, dist (f p.1) (f p.2), have φ_cont : continuous φ := hf.fst'.dist hf.snd', let K := { p : X × X | ε ≤ φ p }, have K_closed : is_closed K := is_closed_le continuous_const φ_cont, have K_cpct : is_compact K := K_closed.is_compact, cases eq_empty_or_nonempty K with hK hK, { use [1, by norm_num], intros x y hxy, have : (x, y) ∉ K, by simp [hK], simpa [K] }, { rcases K_cpct.exists_forall_le hK continuous_dist.continuous_on with ⟨⟨x₀, x₁⟩, xx_in, H⟩, use dist x₀ x₁, split, { change _ < _, rw dist_pos, intro h, have : ε ≤ 0, by simpa [*] using xx_in, linarith }, { intros x x', contrapose!, intros hxx', exact H (x, x') hxx' } }, end example (u : ℕ → X) : cauchy_seq u ↔ ∀ ε > 0, ∃ N : ℕ, ∀ m ≥ N, ∀ n ≥ N, dist (u m) (u n) < ε := metric.cauchy_seq_iff example (u : ℕ → X) : cauchy_seq u ↔ ∀ ε > 0, ∃ N : ℕ, ∀ n ≥ N, dist (u n) (u N) < ε := metric.cauchy_seq_iff' example [complete_space X] (u : ℕ → X) (hu : cauchy_seq u) : ∃ x, tendsto u at_top (𝓝 x) := cauchy_seq_tendsto_of_complete hu open_locale big_operators open finset lemma cauchy_seq_of_le_geometric_two' {u : ℕ → X} (hu : ∀ (n : ℕ), dist (u n) (u (n + 1)) ≤ (1 / 2) ^ n) : cauchy_seq u := begin rw metric.cauchy_seq_iff', intros ε ε_pos, obtain ⟨N, hN⟩ : ∃ N : ℕ, 1 / 2 ^ N * 2 < ε, { sorry }, use N, intros n hn, obtain ⟨k, rfl : n = N + k⟩ := le_iff_exists_add.mp hn, calc dist (u (N + k)) (u N) = dist (u (N+0)) (u (N + k)) : sorry ... ≤ ∑ i in range k, dist (u (N + i)) (u (N + (i + 1))) : sorry ... ≤ ∑ i in range k, (1/2 : ℝ)^(N+i) : sorry ... = 1/2^N*∑ i in range k, (1 / 2) ^ i : sorry ... ≤ 1/2^N*2 : sorry ... < ε : sorry end open metric example [complete_space X] (f : ℕ → set X) (ho : ∀ n, is_open (f n)) (hd : ∀ n, dense (f n)) : dense (⋂n, f n) := begin let B : ℕ → ℝ := λ n, (1/2)^n, have Bpos : ∀ n, 0 < B n, sorry, /- Translate the density assumption into two functions `center` and `radius` associating to any n, x, δ, δpos a center and a positive radius such that `closed_ball center radius` is included both in `f n` and in `closed_ball x δ`. We can also require `radius ≤ (1/2)^(n+1)`, to ensure we get a Cauchy sequence later. -/ have : ∀ (n : ℕ) (x : X) (δ > 0), ∃ (y : X) (r > 0), r ≤ B (n+1) ∧ closed_ball y r ⊆ (closed_ball x δ) ∩ f n, { sorry }, choose! center radius Hpos HB Hball using this, intros x, rw mem_closure_iff_nhds_basis nhds_basis_closed_ball, intros ε εpos, /- `ε` is positive. We have to find a point in the ball of radius `ε` around `x` belonging to all `f n`. For this, we construct inductively a sequence `F n = (c n, r n)` such that the closed ball `closed_ball (c n) (r n)` is included in the previous ball and in `f n`, and such that `r n` is small enough to ensure that `c n` is a Cauchy sequence. Then `c n` converges to a limit which belongs to all the `f n`. -/ let F : ℕ → (X × ℝ) := λn, nat.rec_on n (prod.mk x (min ε (B 0))) (λn p, prod.mk (center n p.1 p.2) (radius n p.1 p.2)), let c : ℕ → X := λ n, (F n).1, let r : ℕ → ℝ := λ n, (F n).2, have rpos : ∀ n, 0 < r n, { sorry }, have rB : ∀n, r n ≤ B n, { sorry }, have incl : ∀n, closed_ball (c (n+1)) (r (n+1)) ⊆ (closed_ball (c n) (r n)) ∩ (f n), { sorry }, have cdist : ∀ n, dist (c n) (c (n+1)) ≤ B n, { sorry }, have : cauchy_seq c, from cauchy_seq_of_le_geometric_two' cdist, -- as the sequence `c n` is Cauchy in a complete space, it converges to a limit `y`. rcases cauchy_seq_tendsto_of_complete this with ⟨y, ylim⟩, -- this point `y` will be the desired point. We will check that it belongs to all -- `f n` and to `ball x ε`. use y, have I : ∀n, ∀ m ≥ n, closed_ball (c m) (r m) ⊆ closed_ball (c n) (r n), { sorry }, have yball : ∀n, y ∈ closed_ball (c n) (r n), { sorry }, sorry end
-
-
-
@@ -1,75 +0,0 @@import topology.instances.real open set filter open_locale topological_space filter -- In the next example we could use `tauto` in each proof instead of knowing the lemmas example {α : Type*} (s : set α) : filter α := { sets := {t | s ⊆ t}, univ_sets := subset_univ s, sets_of_superset := λ U V hU hUV, subset.trans hU hUV, inter_sets := λ U V hU hV, subset_inter hU hV } example : filter ℕ := { sets := {s | ∃ a, ∀ b, a ≤ b → b ∈ s}, univ_sets := begin use 42, finish, end, sets_of_superset := begin rintros U V ⟨N, hN⟩ hUV, use N, tauto, end, inter_sets := begin rintros U V ⟨N, hN⟩ ⟨N', hN'⟩, use max N N', intros b hb, rw max_le_iff at hb, split ; tauto, end } def tendsto₁ {X Y : Type*} (f : X → Y) (F : filter X) (G : filter Y) := ∀ V ∈ G, f ⁻¹' V ∈ F example {X Y Z : Type*} {F : filter X} {G : filter Y} {H : filter Z} {f : X → Y} {g : Y → Z} (hf : tendsto₁ f F G) (hg : tendsto₁ g G H) : tendsto₁ (g ∘ f) F H := calc map (g ∘ f) F = map g (map f F) : by rw map_map ... ≤ map g G : map_mono hf ... ≤ H : hg example {X Y Z : Type*} {F : filter X} {G : filter Y} {H : filter Z} {f : X → Y} {g : Y → Z} (hf : tendsto₁ f F G) (hg : tendsto₁ g G H) : tendsto₁ (g ∘ f) F H := begin intros V hV, rw preimage_comp, apply hf, apply hg, exact hV end example (f : ℕ → ℝ × ℝ) (x₀ y₀ : ℝ) : tendsto f at_top (𝓝 (x₀, y₀)) ↔ tendsto (prod.fst ∘ f) at_top (𝓝 x₀) ∧ tendsto (prod.snd ∘ f) at_top (𝓝 y₀) := calc tendsto f at_top (𝓝 (x₀, y₀)) ↔ map f at_top ≤ 𝓝 (x₀, y₀) : iff.rfl ... ↔ map f at_top ≤ 𝓝 x₀ ×ᶠ 𝓝 y₀ : by rw nhds_prod_eq ... ↔ map f at_top ≤ (comap prod.fst (𝓝 x₀) ⊓ comap prod.snd (𝓝 y₀)) : iff.rfl ... ↔ map f at_top ≤ comap prod.fst (𝓝 x₀) ∧ map f at_top ≤ (comap prod.snd (𝓝 y₀)) : le_inf_iff ... ↔ map prod.fst (map f at_top) ≤ 𝓝 x₀ ∧ map prod.snd (map f at_top) ≤ 𝓝 y₀ : by rw [← map_le_iff_le_comap, ← map_le_iff_le_comap] ... ↔ map (prod.fst ∘ f) at_top ≤ 𝓝 x₀ ∧ map (prod.snd ∘ f) at_top ≤ 𝓝 y₀ : by rw [map_map, map_map] -- an alternative solution example (f : ℕ → ℝ × ℝ) (x₀ y₀ : ℝ) : tendsto f at_top (𝓝 (x₀, y₀)) ↔ tendsto (prod.fst ∘ f) at_top (𝓝 x₀) ∧ tendsto (prod.snd ∘ f) at_top (𝓝 y₀) := begin rw nhds_prod_eq, unfold tendsto filter.prod, rw [le_inf_iff, ← map_le_iff_le_comap, map_map, ← map_le_iff_le_comap, map_map] end example (u : ℕ → ℝ) (M : set ℝ) (x : ℝ) (hux : tendsto u at_top (𝓝 x)) (huM : ∀ᶠ n in at_top, u n ∈ M) : x ∈ closure M := mem_closure_iff_cluster_pt.mpr (ne_bot_of_le $ le_inf hux $ le_principal_iff.mpr huM)
-
-
-
-
@@ -1,135 +0,0 @@import topology.instances.real import analysis.normed_space.banach_steinhaus open set filter open_locale topological_space filter example {f : ℝ → X} (hf : continuous f) : continuous (λ x : ℝ, f (x^2 + x)) := hf.comp $ (continuous_pow 2).add continuous_id example {u : ℕ → X} (hu : tendsto u at_top (𝓝 a)) {s : set X} (hs : ∀ n, u n ∈ s) : a ∈ closure s := begin rw metric.tendsto_at_top at hu, rw metric.mem_closure_iff, intros ε ε_pos, rcases hu ε ε_pos with ⟨N, hN⟩, refine ⟨u N, hs _, _⟩, rw dist_comm, exact hN N le_rfl end example {u : ℕ → X} (hu : ∀ (n : ℕ), dist (u n) (u (n + 1)) ≤ (1 / 2) ^ n) : cauchy_seq u := begin rw metric.cauchy_seq_iff', intros ε ε_pos, obtain ⟨N, hN⟩ : ∃ N : ℕ, 1 / 2 ^ N * 2 < ε, { have : tendsto (λ N : ℕ, (1 / 2 ^ N * 2 : ℝ)) at_top (𝓝 0), { rw ← zero_mul (2 : ℝ), apply tendsto.mul, simp_rw ← one_div_pow (2 : ℝ), apply tendsto_pow_at_top_nhds_0_of_lt_1 ; linarith, exact tendsto_const_nhds }, rcases (at_top_basis.tendsto_iff (nhds_basis_Ioo_pos (0 : ℝ))).mp this ε ε_pos with ⟨N, H, hN⟩, exact ⟨N, by simpa using (hN N le_rfl).2⟩ }, use N, intros n hn, obtain ⟨k, rfl : n = N + k⟩ := le_iff_exists_add.mp hn, calc dist (u (N + k)) (u N) = dist (u (N+0)) (u (N + k)) : by rw [dist_comm, add_zero] ... ≤ ∑ i in range k, dist (u (N + i)) (u (N + (i + 1))) : dist_le_range_sum_dist (λ i, u (N+i)) k ... ≤ ∑ i in range k, (1/2 : ℝ) ^ (N+i) : sum_le_sum (λ i hi, hu $ N+i) ... = 1/2^N*∑ i in range k, (1 / 2)^i : by simp_rw [← one_div_pow, pow_add, ← mul_sum] ... ≤ 1/2^N*2 : mul_le_mul_of_nonneg_left (sum_geometric_two_le _) (one_div_nonneg.mpr (pow_nonneg (zero_le_two : (0 : ℝ) ≤ 2)_)) ... < ε : hN end example [complete_space X] (f : ℕ → set X) (ho : ∀ n, is_open (f n)) (hd : ∀ n, dense (f n)) : dense (⋂n, f n) := begin let B : ℕ → ℝ := λ n, (1/2)^n, have Bpos : ∀ n, 0 < B n, from λ n, (pow_pos sorry n), /- Translate the density assumption into two functions `center` and `radius` associating to any n, x, δ, δpos a center and a positive radius such that `closed_ball center radius` is included both in `f n` and in `closed_ball x δ`. We can also require `radius ≤ (1/2)^(n+1)`, to ensure we get a Cauchy sequence later. -/ have : ∀ (n : ℕ) (x : X) (δ > 0), ∃ (y : X) (r > 0), r ≤ B (n+1) ∧ closed_ball y r ⊆ (closed_ball x δ) ∩ f n, { intros n x δ δpos, have : x ∈ closure (f n) := hd n x, rcases metric.mem_closure_iff.1 this (δ/2) (half_pos δpos) with ⟨y, ys, xy⟩, rw dist_comm at xy, obtain ⟨r, rpos, hr⟩ : ∃ r > 0, closed_ball y r ⊆ f n := nhds_basis_closed_ball.mem_iff.1 (is_open_iff_mem_nhds.1 (ho n) y ys), refine ⟨y, min (min (δ/2) r) (B (n+1)), _, _, λz hz, ⟨_, _⟩⟩, show 0 < min (min (δ / 2) r) (B (n+1)), from lt_min (lt_min (half_pos δpos) rpos) (Bpos (n+1)), show min (min (δ / 2) r) (B (n+1)) ≤ B (n+1), from min_le_right _ _, show z ∈ closed_ball x δ, from calc dist z x ≤ dist z y + dist y x : dist_triangle _ _ _ ... ≤ (min (min (δ / 2) r) (B (n+1))) + (δ/2) : add_le_add hz xy.le ... ≤ δ/2 + δ/2 : add_le_add_right ((min_le_left _ _).trans (min_le_left _ _)) _ ... = δ : add_halves δ, show z ∈ f n, from hr (calc dist z y ≤ min (min (δ / 2) r) (B (n+1)) : hz ... ≤ r : (min_le_left _ _).trans (min_le_right _ _)) }, choose! center radius Hpos HB Hball using this, refine λ x, (mem_closure_iff_nhds_basis nhds_basis_closed_ball).2 (λ ε εpos, _), /- `ε` is positive. We have to find a point in the ball of radius `ε` around `x` belonging to all `f n`. For this, we construct inductively a sequence `F n = (c n, r n)` such that the closed ball `closed_ball (c n) (r n)` is included in the previous ball and in `f n`, and such that `r n` is small enough to ensure that `c n` is a Cauchy sequence. Then `c n` converges to a limit which belongs to all the `f n`. -/ let F : ℕ → (X × ℝ) := λn, nat.rec_on n (prod.mk x (min ε (B 0))) (λn p, prod.mk (center n p.1 p.2) (radius n p.1 p.2)), let c : ℕ → X := λ n, (F n).1, let r : ℕ → ℝ := λ n, (F n).2, have rpos : ∀ n, 0 < r n, { assume n, induction n with n hn, exact lt_min εpos (Bpos 0), exact Hpos n (c n) (r n) hn }, have rB : ∀n, r n ≤ B n, { assume n, induction n with n hn, exact min_le_right _ _, exact HB n (c n) (r n) (rpos n) }, have incl : ∀n, closed_ball (c (n+1)) (r (n+1)) ⊆ (closed_ball (c n) (r n)) ∩ (f n) := λ n, Hball n (c n) (r n) (rpos n), have cdist : ∀ n, dist (c n) (c (n+1)) ≤ B n, { assume n, rw dist_comm, have A : c (n+1) ∈ closed_ball (c (n+1)) (r (n+1)) := mem_closed_ball_self (rpos $ n +1).le, have I := calc closed_ball (c (n+1)) (r (n+1)) ⊆ closed_ball (c n) (r n) : (incl n).trans (inter_subset_left _ _) ... ⊆ closed_ball (c n) (B n) : closed_ball_subset_closed_ball (rB n), exact I A }, have : cauchy_seq c, from cauchy_seq_of_le_geometric_two' cdist, -- as the sequence `c n` is Cauchy in a complete space, it converges to a limit `y`. rcases cauchy_seq_tendsto_of_complete this with ⟨y, ylim⟩, -- this point `y` will be the desired point. We will check that it belongs to all -- `f n` and to `ball x ε`. use y, have I : ∀n, ∀ m ≥ n, closed_ball (c m) (r m) ⊆ closed_ball (c n) (r n), { assume n, refine nat.le_induction _ (λm hnm h, _), { exact subset.rfl }, { exact (incl m).trans ((set.inter_subset_left _ _).trans h) }}, have yball : ∀n, y ∈ closed_ball (c n) (r n), { assume n, refine is_closed_ball.mem_of_tendsto ylim _, refine (filter.eventually_ge_at_top n).mono (λ m hm, _), exact I n m hm (mem_closed_ball_self (rpos _).le) }, split, { suffices : ∀ n, y ∈ f n, by rwa set.mem_Inter, intro n, have : closed_ball (c (n+1)) (r (n+1)) ⊆ f n := subset.trans (incl n) (inter_subset_right _ _), exact this (yball (n+1)) }, calc dist y x ≤ r 0 : yball 0 ... ≤ ε : min_le_left _ _, end
-
-
-
@@ -1,227 +0,0 @@import Mathlib.Algebra.BigOperators.Ring import Mathlib.Data.Real.Basic noncomputable section @[ext] structure Point where x : ℝ y : ℝ z : ℝ #check Point.ext example (a b : Point) (hx : a.x = b.x) (hy : a.y = b.y) (hz : a.z = b.z) : a = b := by ext repeat' assumption def myPoint1 : Point where x := 2 y := -1 z := 4 def myPoint2 : Point := ⟨2, -1, 4⟩ def myPoint3 := Point.mk 2 (-1) 4 structure Point' where build :: x : ℝ y : ℝ z : ℝ #check Point'.build 2 (-1) 4 namespace Point def add (a b : Point) : Point := ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩ def add' (a b : Point) : Point where x := a.x + b.x y := a.y + b.y z := a.z + b.z #check add myPoint1 myPoint2 #check myPoint1.add myPoint2 end Point #check Point.add myPoint1 myPoint2 #check myPoint1.add myPoint2 namespace Point protected theorem add_comm (a b : Point) : add a b = add b a := by rw [add, add] ext <;> dsimp repeat' apply add_comm example (a b : Point) : add a b = add b a := by simp [add, add_comm] theorem add_x (a b : Point) : (a.add b).x = a.x + b.x := rfl def addAlt : Point → Point → Point | Point.mk x₁ y₁ z₁, Point.mk x₂ y₂ z₂ => ⟨x₁ + x₂, y₁ + y₂, z₁ + z₂⟩ def addAlt' : Point → Point → Point | ⟨x₁, y₁, z₁⟩, ⟨x₂, y₂, z₂⟩ => ⟨x₁ + x₂, y₁ + y₂, z₁ + z₂⟩ theorem addAlt_x (a b : Point) : (a.addAlt b).x = a.x + b.x := by cases a cases b rfl theorem addAlt_comm (a b : Point) : addAlt a b = addAlt b a := by rcases a with ⟨xa, ya, za⟩ rcases b with ⟨xb, yb, zb⟩ rw [addAlt, addAlt] ext <;> dsimp apply add_comm repeat' apply add_comm example (a b : Point) : addAlt a b = addAlt b a := by rcases a with ⟨xa, ya, za⟩ rcases b with ⟨xb, yb, zb⟩ simp [addAlt, add_comm] example : ∀ a b : Point, addAlt a b = addAlt b a := by rintro ⟨xa, ya, za⟩ ⟨xb, yb, zb⟩ simp [addAlt, add_comm] example : ∀ a b : Point, add a b = add b a := fun ⟨xa, ya, za⟩ ⟨xb, yb, zb⟩ => by simp [add, add_comm] protected theorem add_assoc (a b c : Point) : (a.add b).add c = a.add (b.add c) := by sorry def smul (r : ℝ) (a : Point) : Point := sorry theorem smul_distrib (r : ℝ) (a b : Point) : (smul r a).add (smul r b) = smul r (a.add b) := by sorry end Point structure StandardTwoSimplex where x : ℝ y : ℝ z : ℝ x_nonneg : 0 ≤ x y_nonneg : 0 ≤ y z_nonneg : 0 ≤ z sum_eq : x + y + z = 1 namespace StandardTwoSimplex def swapXy (a : StandardTwoSimplex) : StandardTwoSimplex where x := a.y y := a.x z := a.z x_nonneg := a.y_nonneg y_nonneg := a.x_nonneg z_nonneg := a.z_nonneg sum_eq := by rw [add_comm a.y a.x, a.sum_eq] noncomputable section def midpoint (a b : StandardTwoSimplex) : StandardTwoSimplex where x := (a.x + b.x) / 2 y := (a.y + b.y) / 2 z := (a.z + b.z) / 2 x_nonneg := div_nonneg (add_nonneg a.x_nonneg b.x_nonneg) (by norm_num) y_nonneg := div_nonneg (add_nonneg a.y_nonneg b.y_nonneg) (by norm_num) z_nonneg := div_nonneg (add_nonneg a.z_nonneg b.z_nonneg) (by norm_num) sum_eq := by field_simp; linarith [a.sum_eq, b.sum_eq] def weightedAverage (lambda : Real) (lambda_nonneg : 0 ≤ lambda) (lambda_le : lambda ≤ 1) (a b : StandardTwoSimplex) : StandardTwoSimplex where sorry end end StandardTwoSimplex open BigOperators structure StandardSimplex (n : ℕ) where V : Fin n → ℝ NonNeg : ∀ i : Fin n, 0 ≤ V i sum_eq_one : (∑ i, V i) = 1 namespace StandardSimplex def midpoint (n : ℕ) (a b : StandardSimplex n) : StandardSimplex n where V i := (a.V i + b.V i) / 2 NonNeg := by intro i apply div_nonneg · linarith [a.NonNeg i, b.NonNeg i] norm_num sum_eq_one := by simp [div_eq_mul_inv, ← Finset.sum_mul, Finset.sum_add_distrib, a.sum_eq_one, b.sum_eq_one] field_simp end StandardSimplex structure IsLinear (f : ℝ → ℝ) where is_additive : ∀ x y, f (x + y) = f x + f y preserves_mul : ∀ x c, f (c * x) = c * f x section variable (f : ℝ → ℝ) (linf : IsLinear f) #check linf.is_additive #check linf.preserves_mul end def Point'' := ℝ × ℝ × ℝ def IsLinear' (f : ℝ → ℝ) := (∀ x y, f (x + y) = f x + f y) ∧ ∀ x c, f (c * x) = c * f x def PReal := { y : ℝ // 0 < y } section variable (x : PReal) #check x.val #check x.property #check x.1 #check x.2 end def StandardTwoSimplex' := { p : ℝ × ℝ × ℝ // 0 ≤ p.1 ∧ 0 ≤ p.2.1 ∧ 0 ≤ p.2.2 ∧ p.1 + p.2.1 + p.2.2 = 1 } def StandardSimplex' (n : ℕ) := { v : Fin n → ℝ // (∀ i : Fin n, 0 ≤ v i) ∧ (∑ i, v i) = 1 } def StdSimplex := Σ n : ℕ, StandardSimplex n section variable (s : StdSimplex) #check s.fst #check s.snd #check s.1 #check s.2 end
-
-
-
@@ -1,172 +0,0 @@import Mathlib.Data.Real.Basic structure Group₁ (α : Type _) where mul : α → α → α one : α inv : α → α mul_assoc : ∀ x y z : α, mul (mul x y) z = mul x (mul y z) mul_one : ∀ x : α, mul x one = x one_mul : ∀ x : α, mul one x = x mul_left_inv : ∀ x : α, mul (inv x) x = one structure Group₁Cat where α : Type _ str : Group₁ α section variable (α β γ : Type _) variable (f : α ≃ β) (g : β ≃ γ) #check Equiv α β #check (f.toFun : α → β) #check (f.invFun : β → α) #check (f.right_inv : ∀ x : β, f (f.invFun x) = x) #check (f.left_inv : ∀ x : α, f.invFun (f x) = x) #check (Equiv.refl α : α ≃ α) #check (f.symm : β ≃ α) #check (f.trans g : α ≃ γ) example (x : α) : (f.trans g).toFun x = g.toFun (f.toFun x) := rfl example (x : α) : (f.trans g) x = g (f x) := rfl example : (f.trans g : α → γ) = g ∘ f := rfl end example (α : Type _) : Equiv.Perm α = (α ≃ α) := rfl def permGroup {α : Type _} : Group₁ (Equiv.Perm α) where mul f g := Equiv.trans g f one := Equiv.refl α inv := Equiv.symm mul_assoc f g h := (Equiv.trans_assoc _ _ _).symm one_mul := Equiv.trans_refl mul_one := Equiv.refl_trans mul_left_inv := Equiv.self_trans_symm structure AddGroup₁ (α : Type _) where (add : α → α → α) -- fill in the rest @[ext] structure Point where x : ℝ y : ℝ z : ℝ namespace Point def add (a b : Point) : Point := ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩ def neg (a : point) : point := sorry def zero : point := sorry def add_group_point : add_group₁ point := sorry end Point section variable {α : Type _} (f g : Equiv.Perm α) (n : ℕ) #check f * g #check mul_assoc f g g⁻¹ -- group power, defined for any group #check g ^ n example : f * g * g⁻¹ = f := by rw [mul_assoc, mul_right_inv, mul_one] example : f * g * g⁻¹ = f := mul_inv_cancel_right f g example {α : Type _} (f g : Equiv.Perm α) : g.symm.trans (g.trans f) = f := mul_inv_cancel_right f g end class Group₂ (α : Type _) where mul : α → α → α one : α inv : α → α mul_assoc : ∀ x y z : α, mul (mul x y) z = mul x (mul y z) mul_one : ∀ x : α, mul x one = x one_mul : ∀ x : α, mul one x = x mul_left_inv : ∀ x : α, mul (inv x) x = one instance {α : Type _} : Group₂ (Equiv.Perm α) where mul f g := Equiv.trans g f one := Equiv.refl α inv := Equiv.symm mul_assoc f g h := (Equiv.trans_assoc _ _ _).symm one_mul := Equiv.trans_refl mul_one := Equiv.refl_trans mul_left_inv := Equiv.self_trans_symm #check @Group₂.mul def mySquare {α : Type _} [Group₂ α] (x : α) := Group₂.mul x x #check @mySquare section variable {β : Type _} (f g : Equiv.Perm β) example : Group₂.mul f g = g.trans f := rfl example : mySquare f = f.trans f := rfl end instance : Inhabited Point where default := ⟨0, 0, 0⟩ #check (default : Point) example : ([] : List Point).headI = default := rfl instance : Add Point where add := Point.add section variable (x y : Point) #check x + y example : x + y = Point.add x y := rfl end instance hasMulGroup₂ {α : Type _} [Group₂ α] : Mul α := ⟨Group₂.mul⟩ instance hasOneGroup₂ {α : Type _} [Group₂ α] : One α := ⟨Group₂.one⟩ instance hasInvGroup₂ {α : Type _} [Group₂ α] : Inv α := ⟨Group₂.inv⟩ section variable {α : Type _} (f g : Equiv.Perm α) #check f * 1 * g⁻¹ def foo : f * 1 * g⁻¹ = g.symm.trans ((Equiv.refl α).trans f) := rfl end class AddGroup₂ (α : Type _) where add : α → α → α -- fill in the rest
-
-
-
@@ -1,271 +0,0 @@import Mathlib.Data.Int.Basic import Mathlib.Algebra.EuclideanDomain.Basic import Mathlib.RingTheory.PrincipalIdealDomain import Mathlib.Tactic @[ext] structure gaussInt where re : ℤ im : ℤ namespace gaussInt instance : Zero gaussInt := ⟨⟨0, 0⟩⟩ instance : One gaussInt := ⟨⟨1, 0⟩⟩ instance : Add gaussInt := ⟨fun x y => ⟨x.re + y.re, x.im + y.im⟩⟩ instance : Neg gaussInt := ⟨fun x => ⟨-x.re, -x.im⟩⟩ instance : Mul gaussInt := ⟨fun x y => ⟨x.re * y.re - x.im * y.im, x.re * y.im + x.im * y.re⟩⟩ theorem zero_def : (0 : gaussInt) = ⟨0, 0⟩ := rfl theorem one_def : (1 : gaussInt) = ⟨1, 0⟩ := rfl theorem add_def (x y : gaussInt) : x + y = ⟨x.re + y.re, x.im + y.im⟩ := rfl theorem neg_def (x : gaussInt) : -x = ⟨-x.re, -x.im⟩ := rfl theorem mul_def (x y : gaussInt) : x * y = ⟨x.re * y.re - x.im * y.im, x.re * y.im + x.im * y.re⟩ := rfl @[simp] theorem zero_re : (0 : gaussInt).re = 0 := rfl @[simp] theorem zero_im : (0 : gaussInt).im = 0 := rfl @[simp] theorem one_re : (1 : gaussInt).re = 1 := rfl @[simp] theorem one_im : (1 : gaussInt).im = 0 := rfl @[simp] theorem add_re (x y : gaussInt) : (x + y).re = x.re + y.re := rfl @[simp] theorem add_im (x y : gaussInt) : (x + y).im = x.im + y.im := rfl @[simp] theorem neg_re (x : gaussInt) : (-x).re = -x.re := rfl @[simp] theorem neg_im (x : gaussInt) : (-x).im = -x.im := rfl @[simp] theorem mul_re (x y : gaussInt) : (x * y).re = x.re * y.re - x.im * y.im := rfl @[simp] theorem mul_im (x y : gaussInt) : (x * y).im = x.re * y.im + x.im * y.re := rfl instance instCommRing : CommRing gaussInt where zero := 0 one := 1 add := (· + ·) neg x := -x mul := (· * ·) add_assoc := by intros ext <;> simp <;> ring zero_add := by intros ext <;> simp add_zero := by intros ext <;> simp add_left_neg := by intros ext <;> simp add_comm := by intros ext <;> simp <;> ring mul_assoc := by intros ext <;> simp <;> ring one_mul := by intros ext <;> simp mul_one := by intros ext <;> simp left_distrib := by intros ext <;> simp <;> ring right_distrib := by intros ext <;> simp <;> ring mul_comm := by intros ext <;> simp <;> ring zero_mul := sorry mul_zero := sorry instance : Nontrivial gaussInt := by use 0, 1 rw [Ne, gaussInt.ext_iff] simp end gaussInt example (a b : ℤ) : a = b * (a / b) + a % b := Eq.symm <| Int.ediv_add_emod a b example (a b : ℤ) : b ≠ 0 → 0 ≤ a % b := Int.emod_nonneg a example (a b : ℤ) : b ≠ 0 → a % b < abs b := Int.emod_lt a namespace Int def div' (a b : ℤ) := (a + b / 2) / b def mod' (a b : ℤ) := (a + b / 2) % b - b / 2 theorem div'_add_mod' (a b : ℤ) : b * div' a b + mod' a b = a := by rw [div', mod'] linarith [Int.ediv_add_emod (a + b / 2) b] theorem abs_mod'_le (a b : ℤ) (h : 0 < b) : abs (mod' a b) ≤ b / 2 := by rw [mod', abs_le] constructor · linarith [Int.emod_nonneg (a + b / 2) h.ne'] have := Int.emod_lt_of_pos (a + b / 2) h have := Int.ediv_add_emod b 2 have := Int.emod_lt_of_pos b zero_lt_two revert this; intro this -- FIXME, this should not be needed linarith theorem mod'_eq (a b : ℤ) : mod' a b = a - b * div' a b := by linarith [div'_add_mod' a b] end Int theorem sq_add_sq_eq_zero {α : Type _} [LinearOrderedRing α] (x y : α) : x ^ 2 + y ^ 2 = 0 ↔ x = 0 ∧ y = 0 := by sorry namespace gaussInt def norm (x : gaussInt) := x.re ^ 2 + x.im ^ 2 @[simp] theorem norm_nonneg (x : gaussInt) : 0 ≤ norm x := by sorry theorem norm_eq_zero (x : gaussInt) : norm x = 0 ↔ x = 0 := by sorry theorem norm_pos (x : gaussInt) : 0 < norm x ↔ x ≠ 0 := by sorry theorem norm_mul (x y : gaussInt) : norm (x * y) = norm x * norm y := by sorry def conj (x : gaussInt) : gaussInt := ⟨x.re, -x.im⟩ @[simp] theorem conj_re (x : gaussInt) : (conj x).re = x.re := rfl @[simp] theorem conj_im (x : gaussInt) : (conj x).im = -x.im := rfl theorem norm_conj (x : gaussInt) : norm (conj x) = norm x := by simp [norm] instance : Div gaussInt := ⟨fun x y => ⟨Int.div' (x * conj y).re (norm y), Int.div' (x * conj y).im (norm y)⟩⟩ instance : Mod gaussInt := ⟨fun x y => x - y * (x / y)⟩ theorem div_def (x y : gaussInt) : x / y = ⟨Int.div' (x * conj y).re (norm y), Int.div' (x * conj y).im (norm y)⟩ := rfl theorem mod_def (x y : gaussInt) : x % y = x - y * (x / y) := rfl theorem norm_mod_lt (x : gaussInt) {y : gaussInt} (hy : y ≠ 0) : (x % y).norm < y.norm := by have norm_y_pos : 0 < norm y := by rwa [norm_pos] have : x % y * conj y = ⟨Int.mod' (x * conj y).re (norm y), Int.mod' (x * conj y).im (norm y)⟩ := by rw [mod_def, sub_mul, Int.mod'_eq, Int.mod'_eq, sub_eq_add_neg, div_def, norm] ext <;> simp <;> ring have : norm (x % y) * norm y ≤ norm y / 2 * norm y := by conv => lhs rw [← norm_conj y, ← norm_mul, this, norm] simp trans 2 * (y.norm / 2) ^ 2 · rw [two_mul] apply add_le_add <;> · rw [sq_le_sq] apply le_trans (Int.abs_mod'_le _ _ norm_y_pos) apply le_abs_self rw [pow_two, ← mul_assoc, mul_comm, mul_comm (2 : ℤ)] apply mul_le_mul_of_nonneg_left · apply Int.ediv_mul_le norm_num apply Int.ediv_nonneg (norm_nonneg y) norm_num have : norm (x % y) ≤ norm y / 2 := le_of_mul_le_mul_right this norm_y_pos apply lt_of_le_of_lt this apply Int.ediv_lt_of_lt_mul · norm_num linarith theorem coe_natAbs_norm (x : gaussInt) : (x.norm.natAbs : ℤ) = x.norm := Int.natAbs_of_nonneg (norm_nonneg _) theorem natAbs_norm_mod_lt (x y : gaussInt) (hy : y ≠ 0) : (x % y).norm.natAbs < y.norm.natAbs := by apply Int.ofNat_lt.1 simp only [Int.coe_natAbs, abs_of_nonneg, norm_nonneg] apply norm_mod_lt x hy theorem not_norm_mul_left_lt_norm (x : gaussInt) {y : gaussInt} (hy : y ≠ 0) : ¬(norm (x * y)).natAbs < (norm x).natAbs := by apply not_lt_of_ge rw [norm_mul, Int.natAbs_mul] apply le_mul_of_one_le_right (Nat.zero_le _) apply Int.ofNat_le.1 rw [coe_natAbs_norm] exact Int.add_one_le_of_lt ((norm_pos _).mpr hy) instance : EuclideanDomain gaussInt := { gaussInt.instCommRing with quotient := (· / ·) remainder := (· % ·) quotient_mul_add_remainder_eq := fun x y => by simp only; rw [mod_def, add_comm, sub_add_cancel] quotient_zero := fun x => by simp [div_def, norm, Int.div'] rfl r := Measure (Int.natAbs ∘ norm) r_wellFounded := (measure (Int.natAbs ∘ norm)).2 remainder_lt := natAbs_norm_mod_lt mul_left_not_lt := not_norm_mul_left_lt_norm } example (x : gaussInt) : Irreducible x ↔ Prime x := PrincipalIdealRing.irreducible_iff_prime end gaussInt
-
-
-
@@ -1,96 +0,0 @@import Mathlib.Algebra.BigOperators.Ring import Mathlib.Data.Real.Basic noncomputable section @[ext] structure Point where x : ℝ y : ℝ z : ℝ namespace Point def add (a b : Point) : Point := ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩ protected theorem add_assoc (a b c : Point) : (a.add b).add c = a.add (b.add c) := by simp [add, add_assoc] def smul (r : ℝ) (a : Point) : Point := ⟨r * a.x, r * a.y, r * a.z⟩ theorem smul_distrib (r : ℝ) (a b : Point) : (smul r a).add (smul r b) = smul r (a.add b) := by simp [add, smul, mul_add] end Point structure StandardTwoSimplex where x : ℝ y : ℝ z : ℝ x_nonneg : 0 ≤ x y_nonneg : 0 ≤ y z_nonneg : 0 ≤ z sum_eq : x + y + z = 1 namespace StandardTwoSimplex noncomputable section def weightedAverage (lambda : Real) (lambda_nonneg : 0 ≤ lambda) (lambda_le : lambda ≤ 1) (a b : StandardTwoSimplex) : StandardTwoSimplex where x := lambda * a.x + (1 - lambda) * b.x y := lambda * a.y + (1 - lambda) * b.y z := lambda * a.z + (1 - lambda) * b.z x_nonneg := add_nonneg (mul_nonneg lambda_nonneg a.x_nonneg) (mul_nonneg (by linarith) b.x_nonneg) y_nonneg := add_nonneg (mul_nonneg lambda_nonneg a.y_nonneg) (mul_nonneg (by linarith) b.y_nonneg) z_nonneg := add_nonneg (mul_nonneg lambda_nonneg a.z_nonneg) (mul_nonneg (by linarith) b.z_nonneg) sum_eq := by trans (a.x + a.y + a.z) * lambda + (b.x + b.y + b.z) * (1 - lambda) · ring simp [a.sum_eq, b.sum_eq] end end StandardTwoSimplex open BigOperators structure StandardSimplex (n : ℕ) where V : Fin n → ℝ NonNeg : ∀ i : Fin n, 0 ≤ V i sum_eq_one : (∑ i, V i) = 1 namespace StandardSimplex def midpoint (n : ℕ) (a b : StandardSimplex n) : StandardSimplex n where V i := (a.V i + b.V i) / 2 NonNeg := by intro i apply div_nonneg · linarith [a.NonNeg i, b.NonNeg i] norm_num sum_eq_one := by simp [div_eq_mul_inv, ← Finset.sum_mul, Finset.sum_add_distrib, a.sum_eq_one, b.sum_eq_one] field_simp end StandardSimplex namespace StandardSimplex def weightedAverage {n : ℕ} (lambda : Real) (lambda_nonneg : 0 ≤ lambda) (lambda_le : lambda ≤ 1) (a b : StandardSimplex n) : StandardSimplex n where V i := lambda * a.V i + (1 - lambda) * b.V i NonNeg i := add_nonneg (mul_nonneg lambda_nonneg (a.NonNeg i)) (mul_nonneg (by linarith) (b.NonNeg i)) sum_eq_one := by trans (lambda * ∑ i, a.V i) + (1 - lambda) * ∑ i, b.V i · rw [Finset.sum_add_distrib, Finset.mul_sum, Finset.mul_sum] simp [a.sum_eq_one, b.sum_eq_one] end StandardSimplex
-
-
-
@@ -1,73 +0,0 @@import Mathlib.Data.Real.Basic structure AddGroup₁ (α : Type _) where add : α → α → α zero : α neg : α → α add_assoc : ∀ x y z : α, add (add x y) z = add x (add y z) add_zero : ∀ x : α, add x zero = x zero_add : ∀ x : α, add x zero = x add_left_neg : ∀ x : α, add (neg x) x = zero @[ext] structure Point where x : ℝ y : ℝ z : ℝ namespace Point def add (a b : Point) : Point := ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩ def neg (a : Point) : Point := ⟨-a.x, -a.y, -a.z⟩ def zero : Point := ⟨0, 0, 0⟩ def addGroupPoint : AddGroup₁ Point where add := Point.add zero := Point.zero neg := Point.neg add_assoc := by simp [Point.add, add_assoc] add_zero := by simp [Point.add, Point.zero] zero_add := by simp [Point.add, Point.zero] add_left_neg := by simp [Point.add, Point.neg, Point.zero] end Point class AddGroup₂ (α : Type _) where add : α → α → α zero : α neg : α → α add_assoc : ∀ x y z : α, add (add x y) z = add x (add y z) add_zero : ∀ x : α, add x zero = x zero_add : ∀ x : α, add x zero = x add_left_neg : ∀ x : α, add (neg x) x = zero instance hasAddAddGroup₂ {α : Type _} [AddGroup₂ α] : Add α := ⟨AddGroup₂.add⟩ instance hasZeroAddGroup₂ {α : Type _} [AddGroup₂ α] : Zero α := ⟨AddGroup₂.zero⟩ instance hasNegAddGroup₂ {α : Type _} [AddGroup₂ α] : Neg α := ⟨AddGroup₂.neg⟩ instance : AddGroup₂ Point where add := Point.add zero := Point.zero neg := Point.neg add_assoc := by simp [Point.add, add_assoc] add_zero := by simp [Point.add, Point.zero] zero_add := by simp [Point.add, Point.zero] add_left_neg := by simp [Point.add, Point.neg, Point.zero] section variable (x y : Point) #check x + -y + 0 end
-
-
-
@@ -1,285 +0,0 @@import Mathlib.Data.Int.Basic import Mathlib.Algebra.EuclideanDomain.Basic import Mathlib.RingTheory.PrincipalIdealDomain import Mathlib.Tactic @[ext] structure gaussInt where re : ℤ im : ℤ namespace gaussInt instance : Zero gaussInt := ⟨⟨0, 0⟩⟩ instance : One gaussInt := ⟨⟨1, 0⟩⟩ instance : Add gaussInt := ⟨fun x y => ⟨x.re + y.re, x.im + y.im⟩⟩ instance : Neg gaussInt := ⟨fun x => ⟨-x.re, -x.im⟩⟩ instance : Mul gaussInt := ⟨fun x y => ⟨x.re * y.re - x.im * y.im, x.re * y.im + x.im * y.re⟩⟩ theorem zero_def : (0 : gaussInt) = ⟨0, 0⟩ := rfl theorem one_def : (1 : gaussInt) = ⟨1, 0⟩ := rfl theorem add_def (x y : gaussInt) : x + y = ⟨x.re + y.re, x.im + y.im⟩ := rfl theorem neg_def (x : gaussInt) : -x = ⟨-x.re, -x.im⟩ := rfl theorem mul_def (x y : gaussInt) : x * y = ⟨x.re * y.re - x.im * y.im, x.re * y.im + x.im * y.re⟩ := rfl @[simp] theorem zero_re : (0 : gaussInt).re = 0 := rfl @[simp] theorem zero_im : (0 : gaussInt).im = 0 := rfl @[simp] theorem one_re : (1 : gaussInt).re = 1 := rfl @[simp] theorem one_im : (1 : gaussInt).im = 0 := rfl @[simp] theorem add_re (x y : gaussInt) : (x + y).re = x.re + y.re := rfl @[simp] theorem add_im (x y : gaussInt) : (x + y).im = x.im + y.im := rfl @[simp] theorem neg_re (x : gaussInt) : (-x).re = -x.re := rfl @[simp] theorem neg_im (x : gaussInt) : (-x).im = -x.im := rfl @[simp] theorem mul_re (x y : gaussInt) : (x * y).re = x.re * y.re - x.im * y.im := rfl @[simp] theorem mul_im (x y : gaussInt) : (x * y).im = x.re * y.im + x.im * y.re := rfl instance instCommRing : CommRing gaussInt where zero := 0 one := 1 add := (· + ·) neg x := -x mul := (· * ·) add_assoc := by intros ext <;> simp <;> ring zero_add := by intros ext <;> simp add_zero := by intros ext <;> simp add_left_neg := by intros ext <;> simp add_comm := by intros ext <;> simp <;> ring mul_assoc := by intros ext <;> simp <;> ring one_mul := by intros ext <;> simp mul_one := by intros ext <;> simp left_distrib := by intros ext <;> simp <;> ring right_distrib := by intros ext <;> simp <;> ring mul_comm := by intros ext <;> simp <;> ring zero_mul := sorry mul_zero := sorry instance : Nontrivial gaussInt := by use 0, 1 rw [Ne, gaussInt.ext_iff] simp end gaussInt namespace Int def div' (a b : ℤ) := (a + b / 2) / b def mod' (a b : ℤ) := (a + b / 2) % b - b / 2 theorem div'_add_mod' (a b : ℤ) : b * div' a b + mod' a b = a := by rw [div', mod'] linarith [Int.ediv_add_emod (a + b / 2) b] theorem abs_mod'_le (a b : ℤ) (h : 0 < b) : abs (mod' a b) ≤ b / 2 := by rw [mod', abs_le] constructor · linarith [Int.emod_nonneg (a + b / 2) h.ne'] have := Int.emod_lt_of_pos (a + b / 2) h have := Int.ediv_add_emod b 2 have := Int.emod_lt_of_pos b zero_lt_two revert this; intro this -- FIXME, this should not be needed linarith theorem mod'_eq (a b : ℤ) : mod' a b = a - b * div' a b := by linarith [div'_add_mod' a b] end Int private theorem aux {α : Type _} [LinearOrderedRing α] {x y : α} (h : x ^ 2 + y ^ 2 = 0) : x = 0 := haveI h' : x ^ 2 = 0 := by apply le_antisymm _ (sq_nonneg x) rw [← h] apply le_add_of_nonneg_right (sq_nonneg y) pow_eq_zero h' theorem sq_add_sq_eq_zero {α : Type _} [LinearOrderedRing α] (x y : α) : x ^ 2 + y ^ 2 = 0 ↔ x = 0 ∧ y = 0 := by constructor · intro h constructor · exact aux h rw [add_comm] at h exact aux h rintro ⟨rfl, rfl⟩ norm_num namespace gaussInt def norm (x : gaussInt) := x.re ^ 2 + x.im ^ 2 @[simp] theorem norm_nonneg (x : gaussInt) : 0 ≤ norm x := by apply add_nonneg <;> apply sq_nonneg theorem norm_eq_zero (x : gaussInt) : norm x = 0 ↔ x = 0 := by rw [norm, sq_add_sq_eq_zero, gaussInt.ext_iff] rfl theorem norm_pos (x : gaussInt) : 0 < norm x ↔ x ≠ 0 := by rw [lt_iff_le_and_ne, ne_comm, Ne, norm_eq_zero] simp [norm_nonneg] theorem norm_mul (x y : gaussInt) : norm (x * y) = norm x * norm y := by simp [norm] ring def conj (x : gaussInt) : gaussInt := ⟨x.re, -x.im⟩ @[simp] theorem conj_re (x : gaussInt) : (conj x).re = x.re := rfl @[simp] theorem conj_im (x : gaussInt) : (conj x).im = -x.im := rfl theorem norm_conj (x : gaussInt) : norm (conj x) = norm x := by simp [norm] instance : Div gaussInt := ⟨fun x y => ⟨Int.div' (x * conj y).re (norm y), Int.div' (x * conj y).im (norm y)⟩⟩ instance : Mod gaussInt := ⟨fun x y => x - y * (x / y)⟩ theorem div_def (x y : gaussInt) : x / y = ⟨Int.div' (x * conj y).re (norm y), Int.div' (x * conj y).im (norm y)⟩ := rfl theorem mod_def (x y : gaussInt) : x % y = x - y * (x / y) := rfl theorem norm_mod_lt (x : gaussInt) {y : gaussInt} (hy : y ≠ 0) : (x % y).norm < y.norm := by have norm_y_pos : 0 < norm y := by rwa [norm_pos] have : x % y * conj y = ⟨Int.mod' (x * conj y).re (norm y), Int.mod' (x * conj y).im (norm y)⟩ := by rw [mod_def, sub_mul, Int.mod'_eq, Int.mod'_eq, sub_eq_add_neg, div_def, norm] ext <;> simp <;> ring have : norm (x % y) * norm y ≤ norm y / 2 * norm y := by conv => lhs rw [← norm_conj y, ← norm_mul, this, norm] simp trans 2 * (y.norm / 2) ^ 2 · rw [two_mul] apply add_le_add <;> · rw [sq_le_sq] apply le_trans (Int.abs_mod'_le _ _ norm_y_pos) apply le_abs_self rw [pow_two, ← mul_assoc, mul_comm, mul_comm (2 : ℤ)] apply mul_le_mul_of_nonneg_left · apply Int.ediv_mul_le norm_num apply Int.ediv_nonneg (norm_nonneg y) norm_num have : norm (x % y) ≤ norm y / 2 := le_of_mul_le_mul_right this norm_y_pos apply lt_of_le_of_lt this apply Int.ediv_lt_of_lt_mul · norm_num linarith theorem coe_natAbs_norm (x : gaussInt) : (x.norm.natAbs : ℤ) = x.norm := Int.natAbs_of_nonneg (norm_nonneg _) theorem natAbs_norm_mod_lt (x y : gaussInt) (hy : y ≠ 0) : (x % y).norm.natAbs < y.norm.natAbs := by apply Int.ofNat_lt.1 simp only [Int.coe_natAbs, abs_of_nonneg, norm_nonneg] apply norm_mod_lt x hy theorem not_norm_mul_left_lt_norm (x : gaussInt) {y : gaussInt} (hy : y ≠ 0) : ¬(norm (x * y)).natAbs < (norm x).natAbs := by apply not_lt_of_ge rw [norm_mul, Int.natAbs_mul] apply le_mul_of_one_le_right (Nat.zero_le _) apply Int.ofNat_le.1 rw [coe_natAbs_norm] exact Int.add_one_le_of_lt ((norm_pos _).mpr hy) instance : EuclideanDomain gaussInt := { gaussInt.instCommRing with quotient := (· / ·) remainder := (· % ·) quotient_mul_add_remainder_eq := fun x y => by simp only; rw [mod_def, add_comm, sub_add_cancel] quotient_zero := fun x => by simp [div_def, norm, Int.div'] rfl r := Measure (Int.natAbs ∘ norm) r_wellFounded := (measure (Int.natAbs ∘ norm)).2 remainder_lt := natAbs_norm_mod_lt mul_left_not_lt := not_norm_mul_left_lt_norm } example (x : gaussInt) : Irreducible x ↔ Prime x := PrincipalIdealRing.irreducible_iff_prime end gaussInt
-
-
MIL/C07_Topology/S01_Filters.lean (deleted)
-
@@ -1,110 +0,0 @@import Mathlib.Topology.Instances.Real open Set Filter Topology def principal {α : Type _} (s : Set α) : Filter α where sets := { t | s ⊆ t } univ_sets := sorry sets_of_superset := sorry inter_sets := sorry example : Filter ℕ := { sets := { s | ∃ a, ∀ b, a ≤ b → b ∈ s } univ_sets := sorry sets_of_superset := sorry inter_sets := sorry } def Tendsto₁ {X Y : Type _} (f : X → Y) (F : Filter X) (G : Filter Y) := ∀ V ∈ G, f ⁻¹' V ∈ F def Tendsto₂ {X Y : Type _} (f : X → Y) (F : Filter X) (G : Filter Y) := map f F ≤ G example {X Y : Type _} (f : X → Y) (F : Filter X) (G : Filter Y) : Tendsto₂ f F G ↔ Tendsto₁ f F G := Iff.rfl #check (@Filter.map_mono : ∀ {α β} {m : α → β}, Monotone (map m)) #check (@Filter.map_map : ∀ {α β γ} {f : Filter α} {m : α → β} {m' : β → γ}, map m' (map m f) = map (m' ∘ m) f) example {X Y Z : Type _} {F : Filter X} {G : Filter Y} {H : Filter Z} {f : X → Y} {g : Y → Z} (hf : Tendsto₁ f F G) (hg : Tendsto₁ g G H) : Tendsto₁ (g ∘ f) F H := sorry variable (f : ℝ → ℝ) (x₀ y₀ : ℝ) #check comap ((↑) : ℚ → ℝ) (𝓝 x₀) #check Tendsto (f ∘ (↑)) (comap ((↑) : ℚ → ℝ) (𝓝 x₀)) (𝓝 y₀) section variable {α β γ : Type _} (F : Filter α) {m : γ → β} {n : β → α} #check (comap_comap : comap m (comap n F) = comap (n ∘ m) F) end example : 𝓝 (x₀, y₀) = 𝓝 x₀ ×ᶠ 𝓝 y₀ := nhds_prod_eq #check le_inf_iff example (f : ℕ → ℝ × ℝ) (x₀ y₀ : ℝ) : Tendsto f atTop (𝓝 (x₀, y₀)) ↔ Tendsto (Prod.fst ∘ f) atTop (𝓝 x₀) ∧ Tendsto (Prod.snd ∘ f) atTop (𝓝 y₀) := sorry example (x₀ : ℝ) : HasBasis (𝓝 x₀) (fun ε : ℝ => 0 < ε) fun ε => Ioo (x₀ - ε) (x₀ + ε) := nhds_basis_Ioo_pos x₀ example (u : ℕ → ℝ) (x₀ : ℝ) : Tendsto u atTop (𝓝 x₀) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, u n ∈ Ioo (x₀ - ε) (x₀ + ε) := by have : atTop.HasBasis (fun _ : ℕ => True) Ici := atTop_basis rw [this.tendsto_iff (nhds_basis_Ioo_pos x₀)] simp example (P Q : ℕ → Prop) (hP : ∀ᶠ n in atTop, P n) (hQ : ∀ᶠ n in atTop, Q n) : ∀ᶠ n in atTop, P n ∧ Q n := hP.and hQ example (u v : ℕ → ℝ) (h : ∀ᶠ n in atTop, u n = v n) (x₀ : ℝ) : Tendsto u atTop (𝓝 x₀) ↔ Tendsto v atTop (𝓝 x₀) := tendsto_congr' h example (u v : ℕ → ℝ) (h : u =ᶠ[atTop] v) (x₀ : ℝ) : Tendsto u atTop (𝓝 x₀) ↔ Tendsto v atTop (𝓝 x₀) := tendsto_congr' h #check @eventually_of_forall #check @Eventually.mono #check @Eventually.and example (P Q R : ℕ → Prop) (hP : ∀ᶠ n in atTop, P n) (hQ : ∀ᶠ n in atTop, Q n) (hR : ∀ᶠ n in atTop, P n ∧ Q n → R n) : ∀ᶠ n in atTop, R n := by apply (hP.and (hQ.and hR)).mono rintro n ⟨h, h', h''⟩ exact h'' ⟨h, h'⟩ example (P Q R : ℕ → Prop) (hP : ∀ᶠ n in atTop, P n) (hQ : ∀ᶠ n in atTop, Q n) (hR : ∀ᶠ n in atTop, P n ∧ Q n → R n) : ∀ᶠ n in atTop, R n := by filter_upwards [hP, hQ, hR] intro n h h' h'' exact h'' ⟨h, h'⟩ #check mem_closure_iff_clusterPt #check le_principal_iff #check neBot_of_le example (u : ℕ → ℝ) (M : Set ℝ) (x : ℝ) (hux : Tendsto u atTop (𝓝 x)) (huM : ∀ᶠ n in atTop, u n ∈ M) : x ∈ closure M := sorry
-
-
MIL/C07_Topology/S02_Metric_Spaces.lean (deleted)
-
@@ -1,200 +0,0 @@import Mathlib.Topology.Instances.Real import Mathlib.Analysis.NormedSpace.BanachSteinhaus open Set Filter open Topology Filter variable {X : Type _} [MetricSpace X] (a b c : X) #check (dist a b : ℝ) #check (dist_nonneg : 0 ≤ dist a b) #check (dist_eq_zero : dist a b = 0 ↔ a = b) #check (dist_comm a b : dist a b = dist b a) #check (dist_triangle a b c : dist a c ≤ dist a b + dist b c) -- Note the next three lines are not quoted, their purpose is to make sure those things don't get renamed while we're looking elsewhere. #check EMetricSpace #check PseudoMetricSpace #check PseudoEMetricSpace example {u : ℕ → X} {a : X} : Tendsto u atTop (𝓝 a) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, dist (u n) a < ε := Metric.tendsto_atTop example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} : Continuous f ↔ ∀ x : X, ∀ ε > 0, ∃ δ > 0, ∀ x', dist x' x < δ → dist (f x') (f x) < ε := Metric.continuous_iff example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : Continuous fun p : X × X => dist (f p.1) (f p.2) := by continuity example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : Continuous fun p : X × X => dist (f p.1) (f p.2) := continuous_dist.comp ((hf.comp continuous_fst).prod_mk (hf.comp continuous_snd)) example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : Continuous fun p : X × X => dist (f p.1) (f p.2) := by apply Continuous.dist exact hf.comp continuous_fst exact hf.comp continuous_snd example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : Continuous fun p : X × X => dist (f p.1) (f p.2) := (hf.comp continuous_fst).dist (hf.comp continuous_snd) example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : Continuous fun p : X × X => dist (f p.1) (f p.2) := hf.fst'.dist hf.snd' example {f : ℝ → X} (hf : Continuous f) : Continuous fun x : ℝ => f (x ^ 2 + x) := sorry example {X Y : Type _} [MetricSpace X] [MetricSpace Y] (f : X → Y) (a : X) : ContinuousAt f a ↔ ∀ ε > 0, ∃ δ > 0, ∀ {x}, dist x a < δ → dist (f x) (f a) < ε := Metric.continuousAt_iff variable (r : ℝ) example : Metric.ball a r = { b | dist b a < r } := rfl example : Metric.closedBall a r = { b | dist b a ≤ r } := rfl example (hr : 0 < r) : a ∈ Metric.ball a r := Metric.mem_ball_self hr example (hr : 0 ≤ r) : a ∈ Metric.closedBall a r := Metric.mem_closedBall_self hr example (s : Set X) : IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, Metric.ball x ε ⊆ s := Metric.isOpen_iff example {s : Set X} : IsClosed s ↔ IsOpen (sᶜ) := isOpen_compl_iff.symm example {s : Set X} (hs : IsClosed s) {u : ℕ → X} (hu : Tendsto u atTop (𝓝 a)) (hus : ∀ n, u n ∈ s) : a ∈ s := hs.mem_of_tendsto hu (eventually_of_forall hus) example {s : Set X} : a ∈ closure s ↔ ∀ ε > 0, ∃ b ∈ s, a ∈ Metric.ball b ε := Metric.mem_closure_iff example {u : ℕ → X} (hu : Tendsto u atTop (𝓝 a)) {s : Set X} (hs : ∀ n, u n ∈ s) : a ∈ closure s := sorry example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ ε > 0, Metric.ball x ε ⊆ s := Metric.nhds_basis_ball.mem_iff example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ ε > 0, Metric.closedBall x ε ⊆ s := Metric.nhds_basis_closedBall.mem_iff example : IsCompact (Set.Icc 0 1 : Set ℝ) := isCompact_Icc example {s : Set X} (hs : IsCompact s) {u : ℕ → X} (hu : ∀ n, u n ∈ s) : ∃ a ∈ s, ∃ φ : ℕ → ℕ, StrictMono φ ∧ Tendsto (u ∘ φ) atTop (𝓝 a) := hs.tendsto_subseq hu example {s : Set X} (hs : IsCompact s) (hs' : s.Nonempty) {f : X → ℝ} (hfs : ContinuousOn f s) : ∃ x ∈ s, ∀ y ∈ s, f x ≤ f y := hs.exists_forall_le hs' hfs example {s : Set X} (hs : IsCompact s) (hs' : s.Nonempty) {f : X → ℝ} (hfs : ContinuousOn f s) : ∃ x ∈ s, ∀ y ∈ s, f y ≤ f x := hs.exists_forall_ge hs' hfs example {s : Set X} (hs : IsCompact s) : IsClosed s := hs.isClosed example {X : Type _} [MetricSpace X] [CompactSpace X] : IsCompact (univ : Set X) := isCompact_univ #check IsCompact.isClosed example {X : Type _} [MetricSpace X] {Y : Type _} [MetricSpace Y] {f : X → Y} : UniformContinuous f ↔ ∀ ε > 0, ∃ δ > 0, ∀ {a b : X}, dist a b < δ → dist (f a) (f b) < ε := Metric.uniformContinuous_iff example {X : Type _} [MetricSpace X] [CompactSpace X] {Y : Type _} [MetricSpace Y] {f : X → Y} (hf : Continuous f) : UniformContinuous f := sorry example (u : ℕ → X) : CauchySeq u ↔ ∀ ε > 0, ∃ N : ℕ, ∀ m ≥ N, ∀ n ≥ N, dist (u m) (u n) < ε := Metric.cauchySeq_iff example (u : ℕ → X) : CauchySeq u ↔ ∀ ε > 0, ∃ N : ℕ, ∀ n ≥ N, dist (u n) (u N) < ε := Metric.cauchySeq_iff' example [CompleteSpace X] (u : ℕ → X) (hu : CauchySeq u) : ∃ x, Tendsto u atTop (𝓝 x) := cauchySeq_tendsto_of_complete hu open BigOperators open Finset theorem cauchySeq_of_le_geometric_two' {u : ℕ → X} (hu : ∀ n : ℕ, dist (u n) (u (n + 1)) ≤ (1 / 2) ^ n) : CauchySeq u := by rw [Metric.cauchySeq_iff'] intro ε ε_pos obtain ⟨N, hN⟩ : ∃ N : ℕ, 1 / 2 ^ N * 2 < ε := by sorry use N intro n hn obtain ⟨k, rfl : n = N + k⟩ := le_iff_exists_add.mp hn calc dist (u (N + k)) (u N) = dist (u (N + 0)) (u (N + k)) := sorry _ ≤ ∑ i in range k, dist (u (N + i)) (u (N + (i + 1))) := sorry _ ≤ ∑ i in range k, (1 / 2 : ℝ) ^ (N + i) := sorry _ = 1 / 2 ^ N * ∑ i in range k, (1 / 2) ^ i := sorry _ ≤ 1 / 2 ^ N * 2 := sorry _ < ε := sorry open Metric example [CompleteSpace X] (f : ℕ → Set X) (ho : ∀ n, IsOpen (f n)) (hd : ∀ n, Dense (f n)) : Dense (⋂ n, f n) := by let B : ℕ → ℝ := fun n => (1 / 2) ^ n have Bpos : ∀ n, 0 < B n sorry /- Translate the density assumption into two functions `center` and `radius` associating to any n, x, δ, δpos a center and a positive radius such that `closedBall center radius` is included both in `f n` and in `closedBall x δ`. We can also require `radius ≤ (1/2)^(n+1)`, to ensure we get a Cauchy sequence later. -/ have : ∀ (n : ℕ) (x : X), ∀ δ > 0, ∃ y : X, ∃ r > 0, r ≤ B (n + 1) ∧ closedBall y r ⊆ closedBall x δ ∩ f n := by sorry choose! center radius Hpos HB Hball using this intro x rw [mem_closure_iff_nhds_basis nhds_basis_closedBall] intro ε εpos /- `ε` is positive. We have to find a point in the ball of radius `ε` around `x` belonging to all `f n`. For this, we construct inductively a sequence `F n = (c n, r n)` such that the closed ball `closedBall (c n) (r n)` is included in the previous ball and in `f n`, and such that `r n` is small enough to ensure that `c n` is a Cauchy sequence. Then `c n` converges to a limit which belongs to all the `f n`. -/ let F : ℕ → X × ℝ := fun n => Nat.recOn n (Prod.mk x (min ε (B 0))) fun n p => Prod.mk (center n p.1 p.2) (radius n p.1 p.2) let c : ℕ → X := fun n => (F n).1 let r : ℕ → ℝ := fun n => (F n).2 have rpos : ∀ n, 0 < r n := by sorry have rB : ∀ n, r n ≤ B n := by sorry have incl : ∀ n, closedBall (c (n + 1)) (r (n + 1)) ⊆ closedBall (c n) (r n) ∩ f n := by sorry have cdist : ∀ n, dist (c n) (c (n + 1)) ≤ B n := by sorry have : CauchySeq c := cauchySeq_of_le_geometric_two' cdist -- as the sequence `c n` is Cauchy in a complete space, it converges to a limit `y`. rcases cauchySeq_tendsto_of_complete this with ⟨y, ylim⟩ -- this point `y` will be the desired point. We will check that it belongs to all -- `f n` and to `ball x ε`. use y have I : ∀ n, ∀ m ≥ n, closedBall (c m) (r m) ⊆ closedBall (c n) (r n) := by sorry have yball : ∀ n, y ∈ closedBall (c n) (r n) := by sorry sorry
-
-
-
@@ -1,151 +0,0 @@import Mathlib.Topology.Instances.Real import Mathlib.Analysis.NormedSpace.BanachSteinhaus open Set Filter open Topology Filter section variable {X : Type _} [TopologicalSpace X] example : IsOpen (univ : Set X) := isOpen_univ example : IsOpen (∅ : Set X) := isOpen_empty example {ι : Type _} {s : ι → Set X} (hs : ∀ i, IsOpen <| s i) : IsOpen (⋃ i, s i) := isOpen_iUnion hs example {ι : Type _} [Fintype ι] {s : ι → Set X} (hs : ∀ i, IsOpen <| s i) : IsOpen (⋂ i, s i) := isOpen_iInter hs variable {Y : Type _} [TopologicalSpace Y] example {f : X → Y} : Continuous f ↔ ∀ s, IsOpen s → IsOpen (f ⁻¹' s) := continuous_def example {f : X → Y} {x : X} : ContinuousAt f x ↔ map f (𝓝 x) ≤ 𝓝 (f x) := Iff.rfl example {f : X → Y} {x : X} : ContinuousAt f x ↔ ∀ U ∈ 𝓝 (f x), ∀ᶠ x in 𝓝 x, f x ∈ U := Iff.rfl example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ t, t ⊆ s ∧ IsOpen t ∧ x ∈ t := mem_nhds_iff example (x : X) : pure x ≤ 𝓝 x := pure_le_nhds x example (x : X) (P : X → Prop) (h : ∀ᶠ y in 𝓝 x, P y) : P x := pure_le_nhds x h example {P : X → Prop} {x : X} (h : ∀ᶠ y in 𝓝 x, P y) : ∀ᶠ y in 𝓝 x, ∀ᶠ z in 𝓝 y, P z := eventually_eventually_nhds.mpr h #check TopologicalSpace.mkOfNhds #check TopologicalSpace.nhds_mkOfNhds example {α : Type _} (n : α → Filter α) (H₀ : ∀ a, pure a ≤ n a) (H : ∀ a : α, ∀ p : α → Prop, (∀ᶠ x in n a, p x) → ∀ᶠ y in n a, ∀ᶠ x in n y, p x) : ∀ a, ∀ s ∈ n a, ∃ t ∈ n a, t ⊆ s ∧ ∀ a' ∈ t, s ∈ n a' := sorry end -- BOTH. variable {X Y : Type _} example (f : X → Y) : TopologicalSpace X → TopologicalSpace Y := TopologicalSpace.coinduced f example (f : X → Y) : TopologicalSpace Y → TopologicalSpace X := TopologicalSpace.induced f example (f : X → Y) (T_X : TopologicalSpace X) (T_Y : TopologicalSpace Y) : TopologicalSpace.coinduced f T_X ≤ T_Y ↔ T_X ≤ TopologicalSpace.induced f T_Y := coinduced_le_iff_le_induced #check coinduced_compose #check induced_compose example {T T' : TopologicalSpace X} : T ≤ T' ↔ ∀ s, T'.IsOpen s → T.IsOpen s := Iff.rfl example (T_X : TopologicalSpace X) (T_Y : TopologicalSpace Y) (f : X → Y) : Continuous f ↔ TopologicalSpace.coinduced f T_X ≤ T_Y := continuous_iff_coinduced_le example {Z : Type _} (f : X → Y) (T_X : TopologicalSpace X) (T_Z : TopologicalSpace Z) (g : Y → Z) : @Continuous Y Z (TopologicalSpace.coinduced f T_X) T_Z g ↔ @Continuous X Z T_X T_Z (g ∘ f) := by rw [continuous_iff_coinduced_le, coinduced_compose, continuous_iff_coinduced_le] example (ι : Type _) (X : ι → Type _) (T_X : ∀ i, TopologicalSpace <| X i) : (Pi.topologicalSpace : TopologicalSpace (∀ i, X i)) = ⨅ i, TopologicalSpace.induced (fun x => x i) (T_X i) := rfl example [TopologicalSpace X] [T2Space X] {u : ℕ → X} {a b : X} (ha : Tendsto u atTop (𝓝 a)) (hb : Tendsto u atTop (𝓝 b)) : a = b := tendsto_nhds_unique ha hb example [TopologicalSpace X] [RegularSpace X] (a : X) : (𝓝 a).HasBasis (fun s : Set X => s ∈ 𝓝 a ∧ IsClosed s) id := closed_nhds_basis a example [TopologicalSpace X] {x : X} : (𝓝 x).HasBasis (fun t : Set X => t ∈ 𝓝 x ∧ IsOpen t) id := nhds_basis_opens' x theorem aux {X Y A : Type _} [TopologicalSpace X] {c : A → X} {f : A → Y} {x : X} {F : Filter Y} (h : Tendsto f (comap c (𝓝 x)) F) {V' : Set Y} (V'_in : V' ∈ F) : ∃ V ∈ 𝓝 x, IsOpen V ∧ c ⁻¹' V ⊆ f ⁻¹' V' := sorry example [TopologicalSpace X] [TopologicalSpace Y] [RegularSpace Y] {A : Set X} (hA : ∀ x, x ∈ closure A) {f : A → Y} (f_cont : Continuous f) (hf : ∀ x : X, ∃ c : Y, Tendsto f (comap (↑) <| 𝓝 x) <| 𝓝 c) : ∃ φ : X → Y, Continuous φ ∧ ∀ a : A, φ a = f a := sorry #check @HasBasis.tendsto_right_iff example [TopologicalSpace X] [TopologicalSpace.FirstCountableTopology X] {s : Set X} {a : X} : a ∈ closure s ↔ ∃ u : ℕ → X, (∀ n, u n ∈ s) ∧ Tendsto u atTop (𝓝 a) := mem_closure_iff_seq_limit variable [TopologicalSpace X] example {F : Filter X} {x : X} : ClusterPt x F ↔ NeBot (𝓝 x ⊓ F) := Iff.rfl example {s : Set X} : IsCompact s ↔ ∀ (F : Filter X) [NeBot F], F ≤ 𝓟 s → ∃ a ∈ s, ClusterPt a F := Iff.rfl example [TopologicalSpace.FirstCountableTopology X] {s : Set X} {u : ℕ → X} (hs : IsCompact s) (hu : ∀ n, u n ∈ s) : ∃ a ∈ s, ∃ φ : ℕ → ℕ, StrictMono φ ∧ Tendsto (u ∘ φ) atTop (𝓝 a) := hs.tendsto_subseq hu variable [TopologicalSpace Y] example {x : X} {F : Filter X} {G : Filter Y} (H : ClusterPt x F) {f : X → Y} (hfx : ContinuousAt f x) (hf : Tendsto f F G) : ClusterPt (f x) G := ClusterPt.map H hfx hf example [TopologicalSpace Y] {f : X → Y} (hf : Continuous f) {s : Set X} (hs : IsCompact s) : IsCompact (f '' s) := by intro F F_ne F_le have map_eq : map f (𝓟 s ⊓ comap f F) = 𝓟 (f '' s) ⊓ F := by sorry have Hne : (𝓟 s ⊓ comap f F).NeBot := by sorry have Hle : 𝓟 s ⊓ comap f F ≤ 𝓟 s := inf_le_left sorry example {ι : Type _} {s : Set X} (hs : IsCompact s) (U : ι → Set X) (hUo : ∀ i, IsOpen (U i)) (hsU : s ⊆ ⋃ i, U i) : ∃ t : Finset ι, s ⊆ ⋃ i ∈ t, U i := hs.elim_finite_subcover U hUo hsU example [CompactSpace X] : IsCompact (univ : Set X) := isCompact_univ
-
-
-
@@ -1,71 +0,0 @@import Mathlib.Topology.Instances.Real open Set Filter Topology -- In the next example we could use `tauto` in each proof instead of knowing the lemmas example {α : Type _} (s : Set α) : Filter α := { sets := { t | s ⊆ t } univ_sets := subset_univ s sets_of_superset := fun hU hUV => Subset.trans hU hUV inter_sets := fun hU hV => subset_inter hU hV } example : Filter ℕ := { sets := { s | ∃ a, ∀ b, a ≤ b → b ∈ s } univ_sets := by use 42 simp sets_of_superset := by rintro U V ⟨N, hN⟩ hUV use N tauto inter_sets := by rintro U V ⟨N, hN⟩ ⟨N', hN'⟩ use max N N' intro b hb rw [max_le_iff] at hb constructor <;> tauto } def Tendsto₁ {X Y : Type _} (f : X → Y) (F : Filter X) (G : Filter Y) := ∀ V ∈ G, f ⁻¹' V ∈ F example {X Y Z : Type _} {F : Filter X} {G : Filter Y} {H : Filter Z} {f : X → Y} {g : Y → Z} (hf : Tendsto₁ f F G) (hg : Tendsto₁ g G H) : Tendsto₁ (g ∘ f) F H := calc map (g ∘ f) F = map g (map f F) := by rw [map_map] _ ≤ map g G := (map_mono hf) _ ≤ H := hg example {X Y Z : Type _} {F : Filter X} {G : Filter Y} {H : Filter Z} {f : X → Y} {g : Y → Z} (hf : Tendsto₁ f F G) (hg : Tendsto₁ g G H) : Tendsto₁ (g ∘ f) F H := by intro V hV rw [preimage_comp] apply hf apply hg exact hV example (f : ℕ → ℝ × ℝ) (x₀ y₀ : ℝ) : Tendsto f atTop (𝓝 (x₀, y₀)) ↔ Tendsto (Prod.fst ∘ f) atTop (𝓝 x₀) ∧ Tendsto (Prod.snd ∘ f) atTop (𝓝 y₀) := calc Tendsto f atTop (𝓝 (x₀, y₀)) ↔ map f atTop ≤ 𝓝 (x₀, y₀) := Iff.rfl _ ↔ map f atTop ≤ 𝓝 x₀ ×ᶠ 𝓝 y₀ := by rw [nhds_prod_eq] _ ↔ map f atTop ≤ comap Prod.fst (𝓝 x₀) ⊓ comap Prod.snd (𝓝 y₀) := Iff.rfl _ ↔ map f atTop ≤ comap Prod.fst (𝓝 x₀) ∧ map f atTop ≤ comap Prod.snd (𝓝 y₀) := le_inf_iff _ ↔ map Prod.fst (map f atTop) ≤ 𝓝 x₀ ∧ map Prod.snd (map f atTop) ≤ 𝓝 y₀ := by rw [← map_le_iff_le_comap, ← map_le_iff_le_comap] _ ↔ map (Prod.fst ∘ f) atTop ≤ 𝓝 x₀ ∧ map (Prod.snd ∘ f) atTop ≤ 𝓝 y₀ := by rw [map_map, map_map] -- an alternative solution example (f : ℕ → ℝ × ℝ) (x₀ y₀ : ℝ) : Tendsto f atTop (𝓝 (x₀, y₀)) ↔ Tendsto (Prod.fst ∘ f) atTop (𝓝 x₀) ∧ Tendsto (Prod.snd ∘ f) atTop (𝓝 y₀) := by rw [nhds_prod_eq] unfold Tendsto Filter.prod rw [le_inf_iff, ← map_le_iff_le_comap, map_map, ← map_le_iff_le_comap, map_map] example (u : ℕ → ℝ) (M : Set ℝ) (x : ℝ) (hux : Tendsto u atTop (𝓝 x)) (huM : ∀ᶠ n in atTop, u n ∈ M) : x ∈ closure M := mem_closure_iff_clusterPt.mpr (neBot_of_le <| le_inf hux <| le_principal_iff.mpr huM)
-
-
-
@@ -1,365 +0,0 @@import Mathlib.Topology.Instances.Real import Mathlib.Analysis.NormedSpace.BanachSteinhaus open Set Filter open Topology Filter variable {X : Type _} [MetricSpace X] (a b c : X) #check (dist a b : ℝ) #check (dist_nonneg : 0 ≤ dist a b) #check (dist_eq_zero : dist a b = 0 ↔ a = b) #check (dist_comm a b : dist a b = dist b a) #check (dist_triangle a b c : dist a c ≤ dist a b + dist b c) -- Note the next three lines are not quoted, their purpose is to make sure those things don't get renamed while we're looking elsewhere. #check EMetricSpace #check PseudoMetricSpace #check PseudoEMetricSpace example {u : ℕ → X} {a : X} : Tendsto u atTop (𝓝 a) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, dist (u n) a < ε := Metric.tendsto_atTop example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} : Continuous f ↔ ∀ x : X, ∀ ε > 0, ∃ δ > 0, ∀ x', dist x' x < δ → dist (f x') (f x) < ε := Metric.continuous_iff example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : Continuous fun p : X × X => dist (f p.1) (f p.2) := by continuity example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : Continuous fun p : X × X => dist (f p.1) (f p.2) := continuous_dist.comp ((hf.comp continuous_fst).prod_mk (hf.comp continuous_snd)) example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : Continuous fun p : X × X => dist (f p.1) (f p.2) := by apply Continuous.dist exact hf.comp continuous_fst exact hf.comp continuous_snd example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : Continuous fun p : X × X => dist (f p.1) (f p.2) := (hf.comp continuous_fst).dist (hf.comp continuous_snd) example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : Continuous fun p : X × X => dist (f p.1) (f p.2) := hf.fst'.dist hf.snd' example {f : ℝ → X} (hf : Continuous f) : Continuous fun x : ℝ => f (x ^ 2 + x) := sorry example {f : ℝ → X} (hf : Continuous f) : Continuous fun x : ℝ => f (x ^ 2 + x) := hf.comp <| (continuous_pow 2).add continuous_id example {X Y : Type _} [MetricSpace X] [MetricSpace Y] (f : X → Y) (a : X) : ContinuousAt f a ↔ ∀ ε > 0, ∃ δ > 0, ∀ {x}, dist x a < δ → dist (f x) (f a) < ε := Metric.continuousAt_iff variable (r : ℝ) example : Metric.ball a r = { b | dist b a < r } := rfl example : Metric.closedBall a r = { b | dist b a ≤ r } := rfl example (hr : 0 < r) : a ∈ Metric.ball a r := Metric.mem_ball_self hr example (hr : 0 ≤ r) : a ∈ Metric.closedBall a r := Metric.mem_closedBall_self hr example (s : Set X) : IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, Metric.ball x ε ⊆ s := Metric.isOpen_iff example {s : Set X} : IsClosed s ↔ IsOpen (sᶜ) := isOpen_compl_iff.symm example {s : Set X} (hs : IsClosed s) {u : ℕ → X} (hu : Tendsto u atTop (𝓝 a)) (hus : ∀ n, u n ∈ s) : a ∈ s := hs.mem_of_tendsto hu (eventually_of_forall hus) example {s : Set X} : a ∈ closure s ↔ ∀ ε > 0, ∃ b ∈ s, a ∈ Metric.ball b ε := Metric.mem_closure_iff example {u : ℕ → X} (hu : Tendsto u atTop (𝓝 a)) {s : Set X} (hs : ∀ n, u n ∈ s) : a ∈ closure s := sorry example {u : ℕ → X} (hu : Tendsto u atTop (𝓝 a)) {s : Set X} (hs : ∀ n, u n ∈ s) : a ∈ closure s := by rw [Metric.tendsto_atTop] at hu rw [Metric.mem_closure_iff] intro ε ε_pos rcases hu ε ε_pos with ⟨N, hN⟩ refine' ⟨u N, hs _, _⟩ rw [dist_comm] exact hN N le_rfl example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ ε > 0, Metric.ball x ε ⊆ s := Metric.nhds_basis_ball.mem_iff example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ ε > 0, Metric.closedBall x ε ⊆ s := Metric.nhds_basis_closedBall.mem_iff example : IsCompact (Set.Icc 0 1 : Set ℝ) := isCompact_Icc example {s : Set X} (hs : IsCompact s) {u : ℕ → X} (hu : ∀ n, u n ∈ s) : ∃ a ∈ s, ∃ φ : ℕ → ℕ, StrictMono φ ∧ Tendsto (u ∘ φ) atTop (𝓝 a) := hs.tendsto_subseq hu example {s : Set X} (hs : IsCompact s) (hs' : s.Nonempty) {f : X → ℝ} (hfs : ContinuousOn f s) : ∃ x ∈ s, ∀ y ∈ s, f x ≤ f y := hs.exists_forall_le hs' hfs example {s : Set X} (hs : IsCompact s) (hs' : s.Nonempty) {f : X → ℝ} (hfs : ContinuousOn f s) : ∃ x ∈ s, ∀ y ∈ s, f y ≤ f x := hs.exists_forall_ge hs' hfs example {s : Set X} (hs : IsCompact s) : IsClosed s := hs.isClosed example {X : Type _} [MetricSpace X] [CompactSpace X] : IsCompact (univ : Set X) := isCompact_univ #check IsCompact.isClosed example {X : Type _} [MetricSpace X] {Y : Type _} [MetricSpace Y] {f : X → Y} : UniformContinuous f ↔ ∀ ε > 0, ∃ δ > 0, ∀ {a b : X}, dist a b < δ → dist (f a) (f b) < ε := Metric.uniformContinuous_iff example {X : Type _} [MetricSpace X] [CompactSpace X] {Y : Type _} [MetricSpace Y] {f : X → Y} (hf : Continuous f) : UniformContinuous f := sorry example {X : Type _} [MetricSpace X] [CompactSpace X] {Y : Type _} [MetricSpace Y] {f : X → Y} (hf : Continuous f) : UniformContinuous f := by rw [Metric.uniformContinuous_iff] intro ε ε_pos let φ : X × X → ℝ := fun p => dist (f p.1) (f p.2) have φ_cont : Continuous φ := hf.fst'.dist hf.snd' let K := { p : X × X | ε ≤ φ p } have K_closed : IsClosed K := isClosed_le continuous_const φ_cont have K_cpct : IsCompact K := K_closed.isCompact cases' eq_empty_or_nonempty K with hK hK · use 1, by norm_num intro x y _ have : (x, y) ∉ K := by simp [hK] simpa using this · rcases K_cpct.exists_forall_le hK continuous_dist.continuousOn with ⟨⟨x₀, x₁⟩, xx_in, H⟩ use dist x₀ x₁ constructor · change _ < _ rw [dist_pos] intro h have : ε ≤ 0 := by simpa [*] using xx_in linarith · intro x x' contrapose! intro hxx' exact H (x, x') hxx' example (u : ℕ → X) : CauchySeq u ↔ ∀ ε > 0, ∃ N : ℕ, ∀ m ≥ N, ∀ n ≥ N, dist (u m) (u n) < ε := Metric.cauchySeq_iff example (u : ℕ → X) : CauchySeq u ↔ ∀ ε > 0, ∃ N : ℕ, ∀ n ≥ N, dist (u n) (u N) < ε := Metric.cauchySeq_iff' example [CompleteSpace X] (u : ℕ → X) (hu : CauchySeq u) : ∃ x, Tendsto u atTop (𝓝 x) := cauchySeq_tendsto_of_complete hu open BigOperators open Finset theorem cauchySeq_of_le_geometric_two' {u : ℕ → X} (hu : ∀ n : ℕ, dist (u n) (u (n + 1)) ≤ (1 / 2) ^ n) : CauchySeq u := by rw [Metric.cauchySeq_iff'] intro ε ε_pos obtain ⟨N, hN⟩ : ∃ N : ℕ, 1 / 2 ^ N * 2 < ε := by sorry use N intro n hn obtain ⟨k, rfl : n = N + k⟩ := le_iff_exists_add.mp hn calc dist (u (N + k)) (u N) = dist (u (N + 0)) (u (N + k)) := sorry _ ≤ ∑ i in range k, dist (u (N + i)) (u (N + (i + 1))) := sorry _ ≤ ∑ i in range k, (1 / 2 : ℝ) ^ (N + i) := sorry _ = 1 / 2 ^ N * ∑ i in range k, (1 / 2) ^ i := sorry _ ≤ 1 / 2 ^ N * 2 := sorry _ < ε := sorry example {u : ℕ → X} (hu : ∀ n : ℕ, dist (u n) (u (n + 1)) ≤ (1 / 2) ^ n) : CauchySeq u := by rw [Metric.cauchySeq_iff'] intro ε ε_pos obtain ⟨N, hN⟩ : ∃ N : ℕ, 1 / 2 ^ N * 2 < ε := by have : Tendsto (fun N : ℕ => (1 / 2 ^ N * 2 : ℝ)) atTop (𝓝 0) := by rw [← MulZeroClass.zero_mul (2 : ℝ)] apply Tendsto.mul simp_rw [← one_div_pow (2 : ℝ)] apply tendsto_pow_atTop_nhds_0_of_lt_1 <;> linarith exact tendsto_const_nhds rcases(atTop_basis.tendsto_iff (nhds_basis_Ioo_pos (0 : ℝ))).mp this ε ε_pos with ⟨N, _, hN⟩ exact ⟨N, by simpa using (hN N left_mem_Ici).2⟩ use N intro n hn obtain ⟨k, rfl : n = N + k⟩ := le_iff_exists_add.mp hn calc dist (u (N + k)) (u N) = dist (u (N + 0)) (u (N + k)) := by rw [dist_comm, add_zero] _ ≤ ∑ i in range k, dist (u (N + i)) (u (N + (i + 1))) := (dist_le_range_sum_dist (fun i => u (N + i)) k) _ ≤ ∑ i in range k, (1 / 2 : ℝ) ^ (N + i) := (sum_le_sum fun i _ => hu <| N + i) _ = 1 / 2 ^ N * ∑ i in range k, (1 / 2 : ℝ) ^ i := by simp_rw [← one_div_pow, pow_add, ← mul_sum] _ ≤ 1 / 2 ^ N * 2 := (mul_le_mul_of_nonneg_left (sum_geometric_two_le _) (one_div_nonneg.mpr (pow_nonneg (zero_le_two : (0 : ℝ) ≤ 2) _))) _ < ε := hN open Metric example [CompleteSpace X] (f : ℕ → Set X) (ho : ∀ n, IsOpen (f n)) (hd : ∀ n, Dense (f n)) : Dense (⋂ n, f n) := by let B : ℕ → ℝ := fun n => (1 / 2) ^ n have Bpos : ∀ n, 0 < B n sorry /- Translate the density assumption into two functions `center` and `radius` associating to any n, x, δ, δpos a center and a positive radius such that `closedBall center radius` is included both in `f n` and in `closedBall x δ`. We can also require `radius ≤ (1/2)^(n+1)`, to ensure we get a Cauchy sequence later. -/ have : ∀ (n : ℕ) (x : X), ∀ δ > 0, ∃ y : X, ∃ r > 0, r ≤ B (n + 1) ∧ closedBall y r ⊆ closedBall x δ ∩ f n := by sorry choose! center radius Hpos HB Hball using this intro x rw [mem_closure_iff_nhds_basis nhds_basis_closedBall] intro ε εpos /- `ε` is positive. We have to find a point in the ball of radius `ε` around `x` belonging to all `f n`. For this, we construct inductively a sequence `F n = (c n, r n)` such that the closed ball `closedBall (c n) (r n)` is included in the previous ball and in `f n`, and such that `r n` is small enough to ensure that `c n` is a Cauchy sequence. Then `c n` converges to a limit which belongs to all the `f n`. -/ let F : ℕ → X × ℝ := fun n => Nat.recOn n (Prod.mk x (min ε (B 0))) fun n p => Prod.mk (center n p.1 p.2) (radius n p.1 p.2) let c : ℕ → X := fun n => (F n).1 let r : ℕ → ℝ := fun n => (F n).2 have rpos : ∀ n, 0 < r n := by sorry have rB : ∀ n, r n ≤ B n := by sorry have incl : ∀ n, closedBall (c (n + 1)) (r (n + 1)) ⊆ closedBall (c n) (r n) ∩ f n := by sorry have cdist : ∀ n, dist (c n) (c (n + 1)) ≤ B n := by sorry have : CauchySeq c := cauchySeq_of_le_geometric_two' cdist -- as the sequence `c n` is Cauchy in a complete space, it converges to a limit `y`. rcases cauchySeq_tendsto_of_complete this with ⟨y, ylim⟩ -- this point `y` will be the desired point. We will check that it belongs to all -- `f n` and to `ball x ε`. use y have I : ∀ n, ∀ m ≥ n, closedBall (c m) (r m) ⊆ closedBall (c n) (r n) := by sorry have yball : ∀ n, y ∈ closedBall (c n) (r n) := by sorry sorry example [CompleteSpace X] (f : ℕ → Set X) (ho : ∀ n, IsOpen (f n)) (hd : ∀ n, Dense (f n)) : Dense (⋂ n, f n) := by let B : ℕ → ℝ := fun n => (1 / 2) ^ n have Bpos : ∀ n, 0 < B n := fun n => pow_pos sorry n /- Translate the density assumption into two functions `center` and `radius` associating to any n, x, δ, δpos a center and a positive radius such that `closedBall center radius` is included both in `f n` and in `closedBall x δ`. We can also require `radius ≤ (1/2)^(n+1)`, to ensure we get a Cauchy sequence later. -/ have : ∀ (n : ℕ) (x : X), ∀ δ > 0, ∃ y : X, ∃ r > 0, r ≤ B (n + 1) ∧ closedBall y r ⊆ closedBall x δ ∩ f n := by intro n x δ δpos have : x ∈ closure (f n) := hd n x rcases Metric.mem_closure_iff.1 this (δ / 2) (half_pos δpos) with ⟨y, ys, xy⟩ rw [dist_comm] at xy obtain ⟨r, rpos, hr⟩ : ∃ r > 0, closedBall y r ⊆ f n := nhds_basis_closedBall.mem_iff.1 (isOpen_iff_mem_nhds.1 (ho n) y ys) refine' ⟨y, min (min (δ / 2) r) (B (n + 1)), _, _, fun z hz => ⟨_, _⟩⟩ show 0 < min (min (δ / 2) r) (B (n + 1)) exact lt_min (lt_min (half_pos δpos) rpos) (Bpos (n + 1)) show min (min (δ / 2) r) (B (n + 1)) ≤ B (n + 1) exact min_le_right _ _ show z ∈ closedBall x δ exact calc dist z x ≤ dist z y + dist y x := dist_triangle _ _ _ _ ≤ min (min (δ / 2) r) (B (n + 1)) + δ / 2 := (add_le_add hz xy.le) _ ≤ δ / 2 + δ / 2 := (add_le_add_right ((min_le_left _ _).trans (min_le_left _ _)) _) _ = δ := add_halves δ show z ∈ f n exact hr (calc dist z y ≤ min (min (δ / 2) r) (B (n + 1)) := hz _ ≤ r := (min_le_left _ _).trans (min_le_right _ _) ) choose! center radius Hpos HB Hball using this refine' fun x => (mem_closure_iff_nhds_basis nhds_basis_closedBall).2 fun ε εpos => _ /- `ε` is positive. We have to find a point in the ball of radius `ε` around `x` belonging to all `f n`. For this, we construct inductively a sequence `F n = (c n, r n)` such that the closed ball `closedBall (c n) (r n)` is included in the previous ball and in `f n`, and such that `r n` is small enough to ensure that `c n` is a Cauchy sequence. Then `c n` converges to a limit which belongs to all the `f n`. -/ let F : ℕ → X × ℝ := fun n => Nat.recOn n (Prod.mk x (min ε (B 0))) fun n p => Prod.mk (center n p.1 p.2) (radius n p.1 p.2) let c : ℕ → X := fun n => (F n).1 let r : ℕ → ℝ := fun n => (F n).2 have rpos : ∀ n, 0 < r n := by intro n induction' n with n hn exact lt_min εpos (Bpos 0) exact Hpos n (c n) (r n) hn have rB : ∀ n, r n ≤ B n := by intro n induction' n with n hn exact min_le_right _ _ exact HB n (c n) (r n) (rpos n) have incl : ∀ n, closedBall (c (n + 1)) (r (n + 1)) ⊆ closedBall (c n) (r n) ∩ f n := fun n => Hball n (c n) (r n) (rpos n) have cdist : ∀ n, dist (c n) (c (n + 1)) ≤ B n := by intro n rw [dist_comm] have A : c (n + 1) ∈ closedBall (c (n + 1)) (r (n + 1)) := mem_closedBall_self (rpos <| n + 1).le have I := calc closedBall (c (n + 1)) (r (n + 1)) ⊆ closedBall (c n) (r n) := (incl n).trans (inter_subset_left _ _) _ ⊆ closedBall (c n) (B n) := closedBall_subset_closedBall (rB n) exact I A have : CauchySeq c := cauchySeq_of_le_geometric_two' cdist -- as the sequence `c n` is Cauchy in a complete space, it converges to a limit `y`. rcases cauchySeq_tendsto_of_complete this with ⟨y, ylim⟩ -- this point `y` will be the desired point. We will check that it belongs to all -- `f n` and to `ball x ε`. use y have I : ∀ n, ∀ m ≥ n, closedBall (c m) (r m) ⊆ closedBall (c n) (r n) := by intro n refine' Nat.le_induction _ fun m hnm h => _ · exact Subset.rfl · exact (incl m).trans ((Set.inter_subset_left _ _).trans h) have yball : ∀ n, y ∈ closedBall (c n) (r n) := by intro n refine' isClosed_ball.mem_of_tendsto ylim _ refine' (Filter.eventually_ge_atTop n).mono fun m hm => _ exact I n m hm (mem_closedBall_self (rpos _).le) constructor · suffices ∀ n, y ∈ f n by rwa [Set.mem_iInter] intro n have : closedBall (c (n + 1)) (r (n + 1)) ⊆ f n := Subset.trans (incl n) (inter_subset_right _ _) exact this (yball (n + 1)) calc dist y x ≤ r 0 := yball 0 _ ≤ ε := min_le_left _ _
-
-
-
@@ -1,202 +0,0 @@import Mathlib.Topology.Instances.Real import Mathlib.Analysis.NormedSpace.BanachSteinhaus open Set Filter open Topology Filter section variable {X : Type _} [TopologicalSpace X] example : IsOpen (univ : Set X) := isOpen_univ example : IsOpen (∅ : Set X) := isOpen_empty example {ι : Type _} {s : ι → Set X} (hs : ∀ i, IsOpen <| s i) : IsOpen (⋃ i, s i) := isOpen_iUnion hs example {ι : Type _} [Fintype ι] {s : ι → Set X} (hs : ∀ i, IsOpen <| s i) : IsOpen (⋂ i, s i) := isOpen_iInter hs variable {Y : Type _} [TopologicalSpace Y] example {f : X → Y} : Continuous f ↔ ∀ s, IsOpen s → IsOpen (f ⁻¹' s) := continuous_def example {f : X → Y} {x : X} : ContinuousAt f x ↔ map f (𝓝 x) ≤ 𝓝 (f x) := Iff.rfl example {f : X → Y} {x : X} : ContinuousAt f x ↔ ∀ U ∈ 𝓝 (f x), ∀ᶠ x in 𝓝 x, f x ∈ U := Iff.rfl example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ t, t ⊆ s ∧ IsOpen t ∧ x ∈ t := mem_nhds_iff example (x : X) : pure x ≤ 𝓝 x := pure_le_nhds x example (x : X) (P : X → Prop) (h : ∀ᶠ y in 𝓝 x, P y) : P x := pure_le_nhds x h example {P : X → Prop} {x : X} (h : ∀ᶠ y in 𝓝 x, P y) : ∀ᶠ y in 𝓝 x, ∀ᶠ z in 𝓝 y, P z := eventually_eventually_nhds.mpr h #check TopologicalSpace.mkOfNhds #check TopologicalSpace.nhds_mkOfNhds example {α : Type _} (n : α → Filter α) (H₀ : ∀ a, pure a ≤ n a) (H : ∀ a : α, ∀ p : α → Prop, (∀ᶠ x in n a, p x) → ∀ᶠ y in n a, ∀ᶠ x in n y, p x) : ∀ a, ∀ s ∈ n a, ∃ t ∈ n a, t ⊆ s ∧ ∀ a' ∈ t, s ∈ n a' := sorry example {α : Type _} (n : α → Filter α) (H₀ : ∀ a, pure a ≤ n a) (H : ∀ a : α, ∀ p : α → Prop, (∀ᶠ x in n a, p x) → ∀ᶠ y in n a, ∀ᶠ x in n y, p x) : ∀ a, ∀ s ∈ n a, ∃ t ∈ n a, t ⊆ s ∧ ∀ a' ∈ t, s ∈ n a' := by intro a s s_in refine' ⟨{ y | s ∈ n y }, H a (fun x => x ∈ s) s_in, _, by tauto⟩ rintro y (hy : s ∈ n y) exact H₀ y hy end -- BOTH. variable {X Y : Type _} example (f : X → Y) : TopologicalSpace X → TopologicalSpace Y := TopologicalSpace.coinduced f example (f : X → Y) : TopologicalSpace Y → TopologicalSpace X := TopologicalSpace.induced f example (f : X → Y) (T_X : TopologicalSpace X) (T_Y : TopologicalSpace Y) : TopologicalSpace.coinduced f T_X ≤ T_Y ↔ T_X ≤ TopologicalSpace.induced f T_Y := coinduced_le_iff_le_induced #check coinduced_compose #check induced_compose example {T T' : TopologicalSpace X} : T ≤ T' ↔ ∀ s, T'.IsOpen s → T.IsOpen s := Iff.rfl example (T_X : TopologicalSpace X) (T_Y : TopologicalSpace Y) (f : X → Y) : Continuous f ↔ TopologicalSpace.coinduced f T_X ≤ T_Y := continuous_iff_coinduced_le example {Z : Type _} (f : X → Y) (T_X : TopologicalSpace X) (T_Z : TopologicalSpace Z) (g : Y → Z) : @Continuous Y Z (TopologicalSpace.coinduced f T_X) T_Z g ↔ @Continuous X Z T_X T_Z (g ∘ f) := by rw [continuous_iff_coinduced_le, coinduced_compose, continuous_iff_coinduced_le] example (ι : Type _) (X : ι → Type _) (T_X : ∀ i, TopologicalSpace <| X i) : (Pi.topologicalSpace : TopologicalSpace (∀ i, X i)) = ⨅ i, TopologicalSpace.induced (fun x => x i) (T_X i) := rfl example [TopologicalSpace X] [T2Space X] {u : ℕ → X} {a b : X} (ha : Tendsto u atTop (𝓝 a)) (hb : Tendsto u atTop (𝓝 b)) : a = b := tendsto_nhds_unique ha hb example [TopologicalSpace X] [RegularSpace X] (a : X) : (𝓝 a).HasBasis (fun s : Set X => s ∈ 𝓝 a ∧ IsClosed s) id := closed_nhds_basis a example [TopologicalSpace X] {x : X} : (𝓝 x).HasBasis (fun t : Set X => t ∈ 𝓝 x ∧ IsOpen t) id := nhds_basis_opens' x theorem aux {X Y A : Type _} [TopologicalSpace X] {c : A → X} {f : A → Y} {x : X} {F : Filter Y} (h : Tendsto f (comap c (𝓝 x)) F) {V' : Set Y} (V'_in : V' ∈ F) : ∃ V ∈ 𝓝 x, IsOpen V ∧ c ⁻¹' V ⊆ f ⁻¹' V' := sorry example {X Y A : Type _} [TopologicalSpace X] {c : A → X} {f : A → Y} {x : X} {F : Filter Y} (h : Tendsto f (comap c (𝓝 x)) F) {V' : Set Y} (V'_in : V' ∈ F) : ∃ V ∈ 𝓝 x, IsOpen V ∧ c ⁻¹' V ⊆ f ⁻¹' V' := by simpa [and_assoc] using ((nhds_basis_opens' x).comap c).tendsto_left_iff.mp h V' V'_in example [TopologicalSpace X] [TopologicalSpace Y] [RegularSpace Y] {A : Set X} (hA : ∀ x, x ∈ closure A) {f : A → Y} (f_cont : Continuous f) (hf : ∀ x : X, ∃ c : Y, Tendsto f (comap (↑) <| 𝓝 x) <| 𝓝 c) : ∃ φ : X → Y, Continuous φ ∧ ∀ a : A, φ a = f a := sorry #check @HasBasis.tendsto_right_iff example [TopologicalSpace X] [TopologicalSpace Y] [T3Space Y] {A : Set X} (hA : ∀ x, x ∈ closure A) {f : A → Y} (f_cont : Continuous f) (hf : ∀ x : X, ∃ c : Y, Tendsto f (comap (↑) <| 𝓝 x) <| 𝓝 c) : ∃ φ : X → Y, Continuous φ ∧ ∀ a : A, φ a = f a := by choose φ hφ using hf use φ constructor · rw [continuous_iff_continuousAt] intro x suffices ∀ V' ∈ 𝓝 (φ x), IsClosed V' → φ ⁻¹' V' ∈ 𝓝 x by simpa [ContinuousAt, (closed_nhds_basis (φ x)).tendsto_right_iff] intro V' V'_in V'_closed obtain ⟨V, V_in, V_op, hV⟩ : ∃ V ∈ 𝓝 x, IsOpen V ∧ (↑) ⁻¹' V ⊆ f ⁻¹' V' := aux (hφ x) V'_in suffices : ∀ y ∈ V, φ y ∈ V' exact mem_of_superset V_in this intro y y_in have hVx : V ∈ 𝓝 y := V_op.mem_nhds y_in haveI : (comap ((↑) : A → X) (𝓝 y)).NeBot := by simpa [mem_closure_iff_comap_neBot] using hA y apply V'_closed.mem_of_tendsto (hφ y) exact mem_of_superset (preimage_mem_comap hVx) hV · intro a have lim : Tendsto f (𝓝 a) (𝓝 <| φ a) := by simpa [nhds_induced] using hφ a exact tendsto_nhds_unique lim f_cont.continuousAt example [TopologicalSpace X] [TopologicalSpace.FirstCountableTopology X] {s : Set X} {a : X} : a ∈ closure s ↔ ∃ u : ℕ → X, (∀ n, u n ∈ s) ∧ Tendsto u atTop (𝓝 a) := mem_closure_iff_seq_limit variable [TopologicalSpace X] example {F : Filter X} {x : X} : ClusterPt x F ↔ NeBot (𝓝 x ⊓ F) := Iff.rfl example {s : Set X} : IsCompact s ↔ ∀ (F : Filter X) [NeBot F], F ≤ 𝓟 s → ∃ a ∈ s, ClusterPt a F := Iff.rfl example [TopologicalSpace.FirstCountableTopology X] {s : Set X} {u : ℕ → X} (hs : IsCompact s) (hu : ∀ n, u n ∈ s) : ∃ a ∈ s, ∃ φ : ℕ → ℕ, StrictMono φ ∧ Tendsto (u ∘ φ) atTop (𝓝 a) := hs.tendsto_subseq hu variable [TopologicalSpace Y] example {x : X} {F : Filter X} {G : Filter Y} (H : ClusterPt x F) {f : X → Y} (hfx : ContinuousAt f x) (hf : Tendsto f F G) : ClusterPt (f x) G := ClusterPt.map H hfx hf example [TopologicalSpace Y] {f : X → Y} (hf : Continuous f) {s : Set X} (hs : IsCompact s) : IsCompact (f '' s) := by intro F F_ne F_le have map_eq : map f (𝓟 s ⊓ comap f F) = 𝓟 (f '' s) ⊓ F := by sorry have Hne : (𝓟 s ⊓ comap f F).NeBot := by sorry have Hle : 𝓟 s ⊓ comap f F ≤ 𝓟 s := inf_le_left sorry example [TopologicalSpace Y] {f : X → Y} (hf : Continuous f) {s : Set X} (hs : IsCompact s) : IsCompact (f '' s) := by intro F F_ne F_le have map_eq : map f (𝓟 s ⊓ comap f F) = 𝓟 (f '' s) ⊓ F := by rw [Filter.push_pull, map_principal] have Hne : (𝓟 s ⊓ comap f F).NeBot := by apply NeBot.of_map rwa [map_eq, inf_of_le_right F_le] have Hle : 𝓟 s ⊓ comap f F ≤ 𝓟 s := inf_le_left rcases hs Hle with ⟨x, x_in, hx⟩ refine' ⟨f x, mem_image_of_mem f x_in, _⟩ apply hx.map hf.continuousAt rw [Tendsto, map_eq] exact inf_le_right example {ι : Type _} {s : Set X} (hs : IsCompact s) (U : ι → Set X) (hUo : ∀ i, IsOpen (U i)) (hsU : s ⊆ ⋃ i, U i) : ∃ t : Finset ι, s ⊆ ⋃ i ∈ t, U i := hs.elim_finite_subcover U hUo hsU example [CompactSpace X] : IsCompact (univ : Set X) := isCompact_univ
-
-
-
@@ -1,227 +0,0 @@import Mathlib.Algebra.BigOperators.Ring import Mathlib.Data.Real.Basic noncomputable section @[ext] structure Point where x : ℝ y : ℝ z : ℝ #check Point.ext example (a b : Point) (hx : a.x = b.x) (hy : a.y = b.y) (hz : a.z = b.z) : a = b := by ext repeat' assumption def myPoint1 : Point where x := 2 y := -1 z := 4 def myPoint2 : Point := ⟨2, -1, 4⟩ def myPoint3 := Point.mk 2 (-1) 4 structure Point' where build :: x : ℝ y : ℝ z : ℝ #check Point'.build 2 (-1) 4 namespace Point def add (a b : Point) : Point := ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩ def add' (a b : Point) : Point where x := a.x + b.x y := a.y + b.y z := a.z + b.z #check add myPoint1 myPoint2 #check myPoint1.add myPoint2 end Point #check Point.add myPoint1 myPoint2 #check myPoint1.add myPoint2 namespace Point protected theorem add_comm (a b : Point) : add a b = add b a := by rw [add, add] ext <;> dsimp repeat' apply add_comm example (a b : Point) : add a b = add b a := by simp [add, add_comm] theorem add_x (a b : Point) : (a.add b).x = a.x + b.x := rfl def addAlt : Point → Point → Point | Point.mk x₁ y₁ z₁, Point.mk x₂ y₂ z₂ => ⟨x₁ + x₂, y₁ + y₂, z₁ + z₂⟩ def addAlt' : Point → Point → Point | ⟨x₁, y₁, z₁⟩, ⟨x₂, y₂, z₂⟩ => ⟨x₁ + x₂, y₁ + y₂, z₁ + z₂⟩ theorem addAlt_x (a b : Point) : (a.addAlt b).x = a.x + b.x := by cases a cases b rfl theorem addAlt_comm (a b : Point) : addAlt a b = addAlt b a := by rcases a with ⟨xa, ya, za⟩ rcases b with ⟨xb, yb, zb⟩ rw [addAlt, addAlt] ext <;> dsimp apply add_comm repeat' apply add_comm example (a b : Point) : addAlt a b = addAlt b a := by rcases a with ⟨xa, ya, za⟩ rcases b with ⟨xb, yb, zb⟩ simp [addAlt, add_comm] example : ∀ a b : Point, addAlt a b = addAlt b a := by rintro ⟨xa, ya, za⟩ ⟨xb, yb, zb⟩ simp [addAlt, add_comm] example : ∀ a b : Point, add a b = add b a := fun ⟨xa, ya, za⟩ ⟨xb, yb, zb⟩ => by simp [add, add_comm] protected theorem add_assoc (a b c : Point) : (a.add b).add c = a.add (b.add c) := by sorry def smul (r : ℝ) (a : Point) : Point := sorry theorem smul_distrib (r : ℝ) (a b : Point) : (smul r a).add (smul r b) = smul r (a.add b) := by sorry end Point structure StandardTwoSimplex where x : ℝ y : ℝ z : ℝ x_nonneg : 0 ≤ x y_nonneg : 0 ≤ y z_nonneg : 0 ≤ z sum_eq : x + y + z = 1 namespace StandardTwoSimplex def swapXy (a : StandardTwoSimplex) : StandardTwoSimplex where x := a.y y := a.x z := a.z x_nonneg := a.y_nonneg y_nonneg := a.x_nonneg z_nonneg := a.z_nonneg sum_eq := by rw [add_comm a.y a.x, a.sum_eq] noncomputable section def midpoint (a b : StandardTwoSimplex) : StandardTwoSimplex where x := (a.x + b.x) / 2 y := (a.y + b.y) / 2 z := (a.z + b.z) / 2 x_nonneg := div_nonneg (add_nonneg a.x_nonneg b.x_nonneg) (by norm_num) y_nonneg := div_nonneg (add_nonneg a.y_nonneg b.y_nonneg) (by norm_num) z_nonneg := div_nonneg (add_nonneg a.z_nonneg b.z_nonneg) (by norm_num) sum_eq := by field_simp; linarith [a.sum_eq, b.sum_eq] def weightedAverage (lambda : Real) (lambda_nonneg : 0 ≤ lambda) (lambda_le : lambda ≤ 1) (a b : StandardTwoSimplex) : StandardTwoSimplex where sorry end end StandardTwoSimplex open BigOperators structure StandardSimplex (n : ℕ) where V : Fin n → ℝ NonNeg : ∀ i : Fin n, 0 ≤ V i sum_eq_one : (∑ i, V i) = 1 namespace StandardSimplex def midpoint (n : ℕ) (a b : StandardSimplex n) : StandardSimplex n where V i := (a.V i + b.V i) / 2 NonNeg := by intro i apply div_nonneg · linarith [a.NonNeg i, b.NonNeg i] norm_num sum_eq_one := by simp [div_eq_mul_inv, ← Finset.sum_mul, Finset.sum_add_distrib, a.sum_eq_one, b.sum_eq_one] field_simp end StandardSimplex structure IsLinear (f : ℝ → ℝ) where is_additive : ∀ x y, f (x + y) = f x + f y preserves_mul : ∀ x c, f (c * x) = c * f x section variable (f : ℝ → ℝ) (linf : IsLinear f) #check linf.is_additive #check linf.preserves_mul end def Point'' := ℝ × ℝ × ℝ def IsLinear' (f : ℝ → ℝ) := (∀ x y, f (x + y) = f x + f y) ∧ ∀ x c, f (c * x) = c * f x def PReal := { y : ℝ // 0 < y } section variable (x : PReal) #check x.val #check x.property #check x.1 #check x.2 end def StandardTwoSimplex' := { p : ℝ × ℝ × ℝ // 0 ≤ p.1 ∧ 0 ≤ p.2.1 ∧ 0 ≤ p.2.2 ∧ p.1 + p.2.1 + p.2.2 = 1 } def StandardSimplex' (n : ℕ) := { v : Fin n → ℝ // (∀ i : Fin n, 0 ≤ v i) ∧ (∑ i, v i) = 1 } def StdSimplex := Σ n : ℕ, StandardSimplex n section variable (s : StdSimplex) #check s.fst #check s.snd #check s.1 #check s.2 end
-
-
-
@@ -1,172 +0,0 @@import Mathlib.Data.Real.Basic structure Group₁ (α : Type _) where mul : α → α → α one : α inv : α → α mul_assoc : ∀ x y z : α, mul (mul x y) z = mul x (mul y z) mul_one : ∀ x : α, mul x one = x one_mul : ∀ x : α, mul one x = x mul_left_inv : ∀ x : α, mul (inv x) x = one structure Group₁Cat where α : Type _ str : Group₁ α section variable (α β γ : Type _) variable (f : α ≃ β) (g : β ≃ γ) #check Equiv α β #check (f.toFun : α → β) #check (f.invFun : β → α) #check (f.right_inv : ∀ x : β, f (f.invFun x) = x) #check (f.left_inv : ∀ x : α, f.invFun (f x) = x) #check (Equiv.refl α : α ≃ α) #check (f.symm : β ≃ α) #check (f.trans g : α ≃ γ) example (x : α) : (f.trans g).toFun x = g.toFun (f.toFun x) := rfl example (x : α) : (f.trans g) x = g (f x) := rfl example : (f.trans g : α → γ) = g ∘ f := rfl end example (α : Type _) : Equiv.Perm α = (α ≃ α) := rfl def permGroup {α : Type _} : Group₁ (Equiv.Perm α) where mul f g := Equiv.trans g f one := Equiv.refl α inv := Equiv.symm mul_assoc f g h := (Equiv.trans_assoc _ _ _).symm one_mul := Equiv.trans_refl mul_one := Equiv.refl_trans mul_left_inv := Equiv.self_trans_symm structure AddGroup₁ (α : Type _) where (add : α → α → α) -- fill in the rest @[ext] structure Point where x : ℝ y : ℝ z : ℝ namespace Point def add (a b : Point) : Point := ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩ def neg (a : point) : point := sorry def zero : point := sorry def add_group_point : add_group₁ point := sorry end Point section variable {α : Type _} (f g : Equiv.Perm α) (n : ℕ) #check f * g #check mul_assoc f g g⁻¹ -- group power, defined for any group #check g ^ n example : f * g * g⁻¹ = f := by rw [mul_assoc, mul_right_inv, mul_one] example : f * g * g⁻¹ = f := mul_inv_cancel_right f g example {α : Type _} (f g : Equiv.Perm α) : g.symm.trans (g.trans f) = f := mul_inv_cancel_right f g end class Group₂ (α : Type _) where mul : α → α → α one : α inv : α → α mul_assoc : ∀ x y z : α, mul (mul x y) z = mul x (mul y z) mul_one : ∀ x : α, mul x one = x one_mul : ∀ x : α, mul one x = x mul_left_inv : ∀ x : α, mul (inv x) x = one instance {α : Type _} : Group₂ (Equiv.Perm α) where mul f g := Equiv.trans g f one := Equiv.refl α inv := Equiv.symm mul_assoc f g h := (Equiv.trans_assoc _ _ _).symm one_mul := Equiv.trans_refl mul_one := Equiv.refl_trans mul_left_inv := Equiv.self_trans_symm #check @Group₂.mul def mySquare {α : Type _} [Group₂ α] (x : α) := Group₂.mul x x #check @mySquare section variable {β : Type _} (f g : Equiv.Perm β) example : Group₂.mul f g = g.trans f := rfl example : mySquare f = f.trans f := rfl end instance : Inhabited Point where default := ⟨0, 0, 0⟩ #check (default : Point) example : ([] : List Point).headI = default := rfl instance : Add Point where add := Point.add section variable (x y : Point) #check x + y example : x + y = Point.add x y := rfl end instance hasMulGroup₂ {α : Type _} [Group₂ α] : Mul α := ⟨Group₂.mul⟩ instance hasOneGroup₂ {α : Type _} [Group₂ α] : One α := ⟨Group₂.one⟩ instance hasInvGroup₂ {α : Type _} [Group₂ α] : Inv α := ⟨Group₂.inv⟩ section variable {α : Type _} (f g : Equiv.Perm α) #check f * 1 * g⁻¹ def foo : f * 1 * g⁻¹ = g.symm.trans ((Equiv.refl α).trans f) := rfl end class AddGroup₂ (α : Type _) where add : α → α → α -- fill in the rest
-
-
-
@@ -1,271 +0,0 @@import Mathlib.Data.Int.Basic import Mathlib.Algebra.EuclideanDomain.Basic import Mathlib.RingTheory.PrincipalIdealDomain import Mathlib.Tactic @[ext] structure gaussInt where re : ℤ im : ℤ namespace gaussInt instance : Zero gaussInt := ⟨⟨0, 0⟩⟩ instance : One gaussInt := ⟨⟨1, 0⟩⟩ instance : Add gaussInt := ⟨fun x y => ⟨x.re + y.re, x.im + y.im⟩⟩ instance : Neg gaussInt := ⟨fun x => ⟨-x.re, -x.im⟩⟩ instance : Mul gaussInt := ⟨fun x y => ⟨x.re * y.re - x.im * y.im, x.re * y.im + x.im * y.re⟩⟩ theorem zero_def : (0 : gaussInt) = ⟨0, 0⟩ := rfl theorem one_def : (1 : gaussInt) = ⟨1, 0⟩ := rfl theorem add_def (x y : gaussInt) : x + y = ⟨x.re + y.re, x.im + y.im⟩ := rfl theorem neg_def (x : gaussInt) : -x = ⟨-x.re, -x.im⟩ := rfl theorem mul_def (x y : gaussInt) : x * y = ⟨x.re * y.re - x.im * y.im, x.re * y.im + x.im * y.re⟩ := rfl @[simp] theorem zero_re : (0 : gaussInt).re = 0 := rfl @[simp] theorem zero_im : (0 : gaussInt).im = 0 := rfl @[simp] theorem one_re : (1 : gaussInt).re = 1 := rfl @[simp] theorem one_im : (1 : gaussInt).im = 0 := rfl @[simp] theorem add_re (x y : gaussInt) : (x + y).re = x.re + y.re := rfl @[simp] theorem add_im (x y : gaussInt) : (x + y).im = x.im + y.im := rfl @[simp] theorem neg_re (x : gaussInt) : (-x).re = -x.re := rfl @[simp] theorem neg_im (x : gaussInt) : (-x).im = -x.im := rfl @[simp] theorem mul_re (x y : gaussInt) : (x * y).re = x.re * y.re - x.im * y.im := rfl @[simp] theorem mul_im (x y : gaussInt) : (x * y).im = x.re * y.im + x.im * y.re := rfl instance instCommRing : CommRing gaussInt where zero := 0 one := 1 add := (· + ·) neg x := -x mul := (· * ·) add_assoc := by intros ext <;> simp <;> ring zero_add := by intros ext <;> simp add_zero := by intros ext <;> simp add_left_neg := by intros ext <;> simp add_comm := by intros ext <;> simp <;> ring mul_assoc := by intros ext <;> simp <;> ring one_mul := by intros ext <;> simp mul_one := by intros ext <;> simp left_distrib := by intros ext <;> simp <;> ring right_distrib := by intros ext <;> simp <;> ring mul_comm := by intros ext <;> simp <;> ring zero_mul := sorry mul_zero := sorry instance : Nontrivial gaussInt := by use 0, 1 rw [Ne, gaussInt.ext_iff] simp end gaussInt example (a b : ℤ) : a = b * (a / b) + a % b := Eq.symm <| Int.ediv_add_emod a b example (a b : ℤ) : b ≠ 0 → 0 ≤ a % b := Int.emod_nonneg a example (a b : ℤ) : b ≠ 0 → a % b < abs b := Int.emod_lt a namespace Int def div' (a b : ℤ) := (a + b / 2) / b def mod' (a b : ℤ) := (a + b / 2) % b - b / 2 theorem div'_add_mod' (a b : ℤ) : b * div' a b + mod' a b = a := by rw [div', mod'] linarith [Int.ediv_add_emod (a + b / 2) b] theorem abs_mod'_le (a b : ℤ) (h : 0 < b) : abs (mod' a b) ≤ b / 2 := by rw [mod', abs_le] constructor · linarith [Int.emod_nonneg (a + b / 2) h.ne'] have := Int.emod_lt_of_pos (a + b / 2) h have := Int.ediv_add_emod b 2 have := Int.emod_lt_of_pos b zero_lt_two revert this; intro this -- FIXME, this should not be needed linarith theorem mod'_eq (a b : ℤ) : mod' a b = a - b * div' a b := by linarith [div'_add_mod' a b] end Int theorem sq_add_sq_eq_zero {α : Type _} [LinearOrderedRing α] (x y : α) : x ^ 2 + y ^ 2 = 0 ↔ x = 0 ∧ y = 0 := by sorry namespace gaussInt def norm (x : gaussInt) := x.re ^ 2 + x.im ^ 2 @[simp] theorem norm_nonneg (x : gaussInt) : 0 ≤ norm x := by sorry theorem norm_eq_zero (x : gaussInt) : norm x = 0 ↔ x = 0 := by sorry theorem norm_pos (x : gaussInt) : 0 < norm x ↔ x ≠ 0 := by sorry theorem norm_mul (x y : gaussInt) : norm (x * y) = norm x * norm y := by sorry def conj (x : gaussInt) : gaussInt := ⟨x.re, -x.im⟩ @[simp] theorem conj_re (x : gaussInt) : (conj x).re = x.re := rfl @[simp] theorem conj_im (x : gaussInt) : (conj x).im = -x.im := rfl theorem norm_conj (x : gaussInt) : norm (conj x) = norm x := by simp [norm] instance : Div gaussInt := ⟨fun x y => ⟨Int.div' (x * conj y).re (norm y), Int.div' (x * conj y).im (norm y)⟩⟩ instance : Mod gaussInt := ⟨fun x y => x - y * (x / y)⟩ theorem div_def (x y : gaussInt) : x / y = ⟨Int.div' (x * conj y).re (norm y), Int.div' (x * conj y).im (norm y)⟩ := rfl theorem mod_def (x y : gaussInt) : x % y = x - y * (x / y) := rfl theorem norm_mod_lt (x : gaussInt) {y : gaussInt} (hy : y ≠ 0) : (x % y).norm < y.norm := by have norm_y_pos : 0 < norm y := by rwa [norm_pos] have : x % y * conj y = ⟨Int.mod' (x * conj y).re (norm y), Int.mod' (x * conj y).im (norm y)⟩ := by rw [mod_def, sub_mul, Int.mod'_eq, Int.mod'_eq, sub_eq_add_neg, div_def, norm] ext <;> simp <;> ring have : norm (x % y) * norm y ≤ norm y / 2 * norm y := by conv => lhs rw [← norm_conj y, ← norm_mul, this, norm] simp trans 2 * (y.norm / 2) ^ 2 · rw [two_mul] apply add_le_add <;> · rw [sq_le_sq] apply le_trans (Int.abs_mod'_le _ _ norm_y_pos) apply le_abs_self rw [pow_two, ← mul_assoc, mul_comm, mul_comm (2 : ℤ)] apply mul_le_mul_of_nonneg_left · apply Int.ediv_mul_le norm_num apply Int.ediv_nonneg (norm_nonneg y) norm_num have : norm (x % y) ≤ norm y / 2 := le_of_mul_le_mul_right this norm_y_pos apply lt_of_le_of_lt this apply Int.ediv_lt_of_lt_mul · norm_num linarith theorem coe_natAbs_norm (x : gaussInt) : (x.norm.natAbs : ℤ) = x.norm := Int.natAbs_of_nonneg (norm_nonneg _) theorem natAbs_norm_mod_lt (x y : gaussInt) (hy : y ≠ 0) : (x % y).norm.natAbs < y.norm.natAbs := by apply Int.ofNat_lt.1 simp only [Int.coe_natAbs, abs_of_nonneg, norm_nonneg] apply norm_mod_lt x hy theorem not_norm_mul_left_lt_norm (x : gaussInt) {y : gaussInt} (hy : y ≠ 0) : ¬(norm (x * y)).natAbs < (norm x).natAbs := by apply not_lt_of_ge rw [norm_mul, Int.natAbs_mul] apply le_mul_of_one_le_right (Nat.zero_le _) apply Int.ofNat_le.1 rw [coe_natAbs_norm] exact Int.add_one_le_of_lt ((norm_pos _).mpr hy) instance : EuclideanDomain gaussInt := { gaussInt.instCommRing with quotient := (· / ·) remainder := (· % ·) quotient_mul_add_remainder_eq := fun x y => by simp only; rw [mod_def, add_comm, sub_add_cancel] quotient_zero := fun x => by simp [div_def, norm, Int.div'] rfl r := Measure (Int.natAbs ∘ norm) r_wellFounded := (measure (Int.natAbs ∘ norm)).2 remainder_lt := natAbs_norm_mod_lt mul_left_not_lt := not_norm_mul_left_lt_norm } example (x : gaussInt) : Irreducible x ↔ Prime x := PrincipalIdealRing.irreducible_iff_prime end gaussInt
-
-
-
@@ -1,96 +0,0 @@import Mathlib.Algebra.BigOperators.Ring import Mathlib.Data.Real.Basic noncomputable section @[ext] structure Point where x : ℝ y : ℝ z : ℝ namespace Point def add (a b : Point) : Point := ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩ protected theorem add_assoc (a b c : Point) : (a.add b).add c = a.add (b.add c) := by simp [add, add_assoc] def smul (r : ℝ) (a : Point) : Point := ⟨r * a.x, r * a.y, r * a.z⟩ theorem smul_distrib (r : ℝ) (a b : Point) : (smul r a).add (smul r b) = smul r (a.add b) := by simp [add, smul, mul_add] end Point structure StandardTwoSimplex where x : ℝ y : ℝ z : ℝ x_nonneg : 0 ≤ x y_nonneg : 0 ≤ y z_nonneg : 0 ≤ z sum_eq : x + y + z = 1 namespace StandardTwoSimplex noncomputable section def weightedAverage (lambda : Real) (lambda_nonneg : 0 ≤ lambda) (lambda_le : lambda ≤ 1) (a b : StandardTwoSimplex) : StandardTwoSimplex where x := lambda * a.x + (1 - lambda) * b.x y := lambda * a.y + (1 - lambda) * b.y z := lambda * a.z + (1 - lambda) * b.z x_nonneg := add_nonneg (mul_nonneg lambda_nonneg a.x_nonneg) (mul_nonneg (by linarith) b.x_nonneg) y_nonneg := add_nonneg (mul_nonneg lambda_nonneg a.y_nonneg) (mul_nonneg (by linarith) b.y_nonneg) z_nonneg := add_nonneg (mul_nonneg lambda_nonneg a.z_nonneg) (mul_nonneg (by linarith) b.z_nonneg) sum_eq := by trans (a.x + a.y + a.z) * lambda + (b.x + b.y + b.z) * (1 - lambda) · ring simp [a.sum_eq, b.sum_eq] end end StandardTwoSimplex open BigOperators structure StandardSimplex (n : ℕ) where V : Fin n → ℝ NonNeg : ∀ i : Fin n, 0 ≤ V i sum_eq_one : (∑ i, V i) = 1 namespace StandardSimplex def midpoint (n : ℕ) (a b : StandardSimplex n) : StandardSimplex n where V i := (a.V i + b.V i) / 2 NonNeg := by intro i apply div_nonneg · linarith [a.NonNeg i, b.NonNeg i] norm_num sum_eq_one := by simp [div_eq_mul_inv, ← Finset.sum_mul, Finset.sum_add_distrib, a.sum_eq_one, b.sum_eq_one] field_simp end StandardSimplex namespace StandardSimplex def weightedAverage {n : ℕ} (lambda : Real) (lambda_nonneg : 0 ≤ lambda) (lambda_le : lambda ≤ 1) (a b : StandardSimplex n) : StandardSimplex n where V i := lambda * a.V i + (1 - lambda) * b.V i NonNeg i := add_nonneg (mul_nonneg lambda_nonneg (a.NonNeg i)) (mul_nonneg (by linarith) (b.NonNeg i)) sum_eq_one := by trans (lambda * ∑ i, a.V i) + (1 - lambda) * ∑ i, b.V i · rw [Finset.sum_add_distrib, Finset.mul_sum, Finset.mul_sum] simp [a.sum_eq_one, b.sum_eq_one] end StandardSimplex
-
-
-
@@ -1,73 +0,0 @@import Mathlib.Data.Real.Basic structure AddGroup₁ (α : Type _) where add : α → α → α zero : α neg : α → α add_assoc : ∀ x y z : α, add (add x y) z = add x (add y z) add_zero : ∀ x : α, add x zero = x zero_add : ∀ x : α, add x zero = x add_left_neg : ∀ x : α, add (neg x) x = zero @[ext] structure Point where x : ℝ y : ℝ z : ℝ namespace Point def add (a b : Point) : Point := ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩ def neg (a : Point) : Point := ⟨-a.x, -a.y, -a.z⟩ def zero : Point := ⟨0, 0, 0⟩ def addGroupPoint : AddGroup₁ Point where add := Point.add zero := Point.zero neg := Point.neg add_assoc := by simp [Point.add, add_assoc] add_zero := by simp [Point.add, Point.zero] zero_add := by simp [Point.add, Point.zero] add_left_neg := by simp [Point.add, Point.neg, Point.zero] end Point class AddGroup₂ (α : Type _) where add : α → α → α zero : α neg : α → α add_assoc : ∀ x y z : α, add (add x y) z = add x (add y z) add_zero : ∀ x : α, add x zero = x zero_add : ∀ x : α, add x zero = x add_left_neg : ∀ x : α, add (neg x) x = zero instance hasAddAddGroup₂ {α : Type _} [AddGroup₂ α] : Add α := ⟨AddGroup₂.add⟩ instance hasZeroAddGroup₂ {α : Type _} [AddGroup₂ α] : Zero α := ⟨AddGroup₂.zero⟩ instance hasNegAddGroup₂ {α : Type _} [AddGroup₂ α] : Neg α := ⟨AddGroup₂.neg⟩ instance : AddGroup₂ Point where add := Point.add zero := Point.zero neg := Point.neg add_assoc := by simp [Point.add, add_assoc] add_zero := by simp [Point.add, Point.zero] zero_add := by simp [Point.add, Point.zero] add_left_neg := by simp [Point.add, Point.neg, Point.zero] section variable (x y : Point) #check x + -y + 0 end
-
-
-
@@ -1,285 +0,0 @@import Mathlib.Data.Int.Basic import Mathlib.Algebra.EuclideanDomain.Basic import Mathlib.RingTheory.PrincipalIdealDomain import Mathlib.Tactic @[ext] structure gaussInt where re : ℤ im : ℤ namespace gaussInt instance : Zero gaussInt := ⟨⟨0, 0⟩⟩ instance : One gaussInt := ⟨⟨1, 0⟩⟩ instance : Add gaussInt := ⟨fun x y => ⟨x.re + y.re, x.im + y.im⟩⟩ instance : Neg gaussInt := ⟨fun x => ⟨-x.re, -x.im⟩⟩ instance : Mul gaussInt := ⟨fun x y => ⟨x.re * y.re - x.im * y.im, x.re * y.im + x.im * y.re⟩⟩ theorem zero_def : (0 : gaussInt) = ⟨0, 0⟩ := rfl theorem one_def : (1 : gaussInt) = ⟨1, 0⟩ := rfl theorem add_def (x y : gaussInt) : x + y = ⟨x.re + y.re, x.im + y.im⟩ := rfl theorem neg_def (x : gaussInt) : -x = ⟨-x.re, -x.im⟩ := rfl theorem mul_def (x y : gaussInt) : x * y = ⟨x.re * y.re - x.im * y.im, x.re * y.im + x.im * y.re⟩ := rfl @[simp] theorem zero_re : (0 : gaussInt).re = 0 := rfl @[simp] theorem zero_im : (0 : gaussInt).im = 0 := rfl @[simp] theorem one_re : (1 : gaussInt).re = 1 := rfl @[simp] theorem one_im : (1 : gaussInt).im = 0 := rfl @[simp] theorem add_re (x y : gaussInt) : (x + y).re = x.re + y.re := rfl @[simp] theorem add_im (x y : gaussInt) : (x + y).im = x.im + y.im := rfl @[simp] theorem neg_re (x : gaussInt) : (-x).re = -x.re := rfl @[simp] theorem neg_im (x : gaussInt) : (-x).im = -x.im := rfl @[simp] theorem mul_re (x y : gaussInt) : (x * y).re = x.re * y.re - x.im * y.im := rfl @[simp] theorem mul_im (x y : gaussInt) : (x * y).im = x.re * y.im + x.im * y.re := rfl instance instCommRing : CommRing gaussInt where zero := 0 one := 1 add := (· + ·) neg x := -x mul := (· * ·) add_assoc := by intros ext <;> simp <;> ring zero_add := by intros ext <;> simp add_zero := by intros ext <;> simp add_left_neg := by intros ext <;> simp add_comm := by intros ext <;> simp <;> ring mul_assoc := by intros ext <;> simp <;> ring one_mul := by intros ext <;> simp mul_one := by intros ext <;> simp left_distrib := by intros ext <;> simp <;> ring right_distrib := by intros ext <;> simp <;> ring mul_comm := by intros ext <;> simp <;> ring zero_mul := sorry mul_zero := sorry instance : Nontrivial gaussInt := by use 0, 1 rw [Ne, gaussInt.ext_iff] simp end gaussInt namespace Int def div' (a b : ℤ) := (a + b / 2) / b def mod' (a b : ℤ) := (a + b / 2) % b - b / 2 theorem div'_add_mod' (a b : ℤ) : b * div' a b + mod' a b = a := by rw [div', mod'] linarith [Int.ediv_add_emod (a + b / 2) b] theorem abs_mod'_le (a b : ℤ) (h : 0 < b) : abs (mod' a b) ≤ b / 2 := by rw [mod', abs_le] constructor · linarith [Int.emod_nonneg (a + b / 2) h.ne'] have := Int.emod_lt_of_pos (a + b / 2) h have := Int.ediv_add_emod b 2 have := Int.emod_lt_of_pos b zero_lt_two revert this; intro this -- FIXME, this should not be needed linarith theorem mod'_eq (a b : ℤ) : mod' a b = a - b * div' a b := by linarith [div'_add_mod' a b] end Int private theorem aux {α : Type _} [LinearOrderedRing α] {x y : α} (h : x ^ 2 + y ^ 2 = 0) : x = 0 := haveI h' : x ^ 2 = 0 := by apply le_antisymm _ (sq_nonneg x) rw [← h] apply le_add_of_nonneg_right (sq_nonneg y) pow_eq_zero h' theorem sq_add_sq_eq_zero {α : Type _} [LinearOrderedRing α] (x y : α) : x ^ 2 + y ^ 2 = 0 ↔ x = 0 ∧ y = 0 := by constructor · intro h constructor · exact aux h rw [add_comm] at h exact aux h rintro ⟨rfl, rfl⟩ norm_num namespace gaussInt def norm (x : gaussInt) := x.re ^ 2 + x.im ^ 2 @[simp] theorem norm_nonneg (x : gaussInt) : 0 ≤ norm x := by apply add_nonneg <;> apply sq_nonneg theorem norm_eq_zero (x : gaussInt) : norm x = 0 ↔ x = 0 := by rw [norm, sq_add_sq_eq_zero, gaussInt.ext_iff] rfl theorem norm_pos (x : gaussInt) : 0 < norm x ↔ x ≠ 0 := by rw [lt_iff_le_and_ne, ne_comm, Ne, norm_eq_zero] simp [norm_nonneg] theorem norm_mul (x y : gaussInt) : norm (x * y) = norm x * norm y := by simp [norm] ring def conj (x : gaussInt) : gaussInt := ⟨x.re, -x.im⟩ @[simp] theorem conj_re (x : gaussInt) : (conj x).re = x.re := rfl @[simp] theorem conj_im (x : gaussInt) : (conj x).im = -x.im := rfl theorem norm_conj (x : gaussInt) : norm (conj x) = norm x := by simp [norm] instance : Div gaussInt := ⟨fun x y => ⟨Int.div' (x * conj y).re (norm y), Int.div' (x * conj y).im (norm y)⟩⟩ instance : Mod gaussInt := ⟨fun x y => x - y * (x / y)⟩ theorem div_def (x y : gaussInt) : x / y = ⟨Int.div' (x * conj y).re (norm y), Int.div' (x * conj y).im (norm y)⟩ := rfl theorem mod_def (x y : gaussInt) : x % y = x - y * (x / y) := rfl theorem norm_mod_lt (x : gaussInt) {y : gaussInt} (hy : y ≠ 0) : (x % y).norm < y.norm := by have norm_y_pos : 0 < norm y := by rwa [norm_pos] have : x % y * conj y = ⟨Int.mod' (x * conj y).re (norm y), Int.mod' (x * conj y).im (norm y)⟩ := by rw [mod_def, sub_mul, Int.mod'_eq, Int.mod'_eq, sub_eq_add_neg, div_def, norm] ext <;> simp <;> ring have : norm (x % y) * norm y ≤ norm y / 2 * norm y := by conv => lhs rw [← norm_conj y, ← norm_mul, this, norm] simp trans 2 * (y.norm / 2) ^ 2 · rw [two_mul] apply add_le_add <;> · rw [sq_le_sq] apply le_trans (Int.abs_mod'_le _ _ norm_y_pos) apply le_abs_self rw [pow_two, ← mul_assoc, mul_comm, mul_comm (2 : ℤ)] apply mul_le_mul_of_nonneg_left · apply Int.ediv_mul_le norm_num apply Int.ediv_nonneg (norm_nonneg y) norm_num have : norm (x % y) ≤ norm y / 2 := le_of_mul_le_mul_right this norm_y_pos apply lt_of_le_of_lt this apply Int.ediv_lt_of_lt_mul · norm_num linarith theorem coe_natAbs_norm (x : gaussInt) : (x.norm.natAbs : ℤ) = x.norm := Int.natAbs_of_nonneg (norm_nonneg _) theorem natAbs_norm_mod_lt (x y : gaussInt) (hy : y ≠ 0) : (x % y).norm.natAbs < y.norm.natAbs := by apply Int.ofNat_lt.1 simp only [Int.coe_natAbs, abs_of_nonneg, norm_nonneg] apply norm_mod_lt x hy theorem not_norm_mul_left_lt_norm (x : gaussInt) {y : gaussInt} (hy : y ≠ 0) : ¬(norm (x * y)).natAbs < (norm x).natAbs := by apply not_lt_of_ge rw [norm_mul, Int.natAbs_mul] apply le_mul_of_one_le_right (Nat.zero_le _) apply Int.ofNat_le.1 rw [coe_natAbs_norm] exact Int.add_one_le_of_lt ((norm_pos _).mpr hy) instance : EuclideanDomain gaussInt := { gaussInt.instCommRing with quotient := (· / ·) remainder := (· % ·) quotient_mul_add_remainder_eq := fun x y => by simp only; rw [mod_def, add_comm, sub_add_cancel] quotient_zero := fun x => by simp [div_def, norm, Int.div'] rfl r := Measure (Int.natAbs ∘ norm) r_wellFounded := (measure (Int.natAbs ∘ norm)).2 remainder_lt := natAbs_norm_mod_lt mul_left_not_lt := not_norm_mul_left_lt_norm } example (x : gaussInt) : Irreducible x ↔ Prime x := PrincipalIdealRing.irreducible_iff_prime end gaussInt
-
-
MIL/C_Basics/S01_Calculating.lean (deleted)
-
@@ -1,164 +0,0 @@import Mathlib.Data.Real.Basic import Mathlib.Data.Real.Basic -- An example. example (a b c : ℝ) : a * b * c = b * (a * c) := by rw [mul_comm a b] rw [mul_assoc b a c] -- Try these. example (a b c : ℝ) : c * b * a = b * (a * c) := by sorry example (a b c : ℝ) : a * (b * c) = b * (a * c) := by sorry -- An example. example (a b c : ℝ) : a * b * c = b * c * a := by rw [mul_assoc] rw [mul_comm] /- Try doing the first of these without providing any arguments at all, and the second with only one argument. -/ example (a b c : ℝ) : a * (b * c) = b * (c * a) := by sorry example (a b c : ℝ) : a * (b * c) = b * (a * c) := by sorry -- Using facts from the local context. example (a b c d e f : ℝ) (h : a * b = c * d) (h' : e = f) : a * (b * e) = c * (d * f) := by rw [h'] rw [← mul_assoc] rw [h] rw [mul_assoc] -- Try these. For the second one, use the theorem `sub_self`. example (a b c d e f : ℝ) (h : b * c = e * f) : a * b * c * d = a * e * f * d := by sorry example (a b c d : ℝ) (hyp : c = b * a - d) (hyp' : d = a * b) : c = 0 := by sorry -- Examples. example (a b c d e f : ℝ) (h : a * b = c * d) (h' : e = f) : a * (b * e) = c * (d * f) := by rw [h', ← mul_assoc, h, mul_assoc] section variable (a b c d e f g : ℝ) example (h : a * b = c * d) (h' : e = f) : a * (b * e) = c * (d * f) := by rw [h', ← mul_assoc, h, mul_assoc] end section variable (a b c : ℝ) #check a #check a + b #check (a : ℝ) #check mul_comm a b #check (mul_comm a b : a * b = b * a) #check mul_assoc c a b #check mul_comm a #check mul_comm #check @mul_comm end section variable (a b : ℝ) example : (a + b) * (a + b) = a * a + 2 * (a * b) + b * b := by rw [mul_add, add_mul, add_mul] rw [← add_assoc, add_assoc (a * a)] rw [mul_comm b a, ← two_mul] example : (a + b) * (a + b) = a * a + 2 * (a * b) + b * b := calc (a + b) * (a + b) = a * a + b * a + (a * b + b * b) := by rw [mul_add, add_mul, add_mul] _ = a * a + (b * a + a * b) + b * b := by rw [← add_assoc, add_assoc (a * a)] _ = a * a + 2 * (a * b) + b * b := by rw [mul_comm b a, ← two_mul] example : (a + b) * (a + b) = a * a + 2 * (a * b) + b * b := calc (a + b) * (a + b) = a * a + b * a + (a * b + b * b) := by sorry _ = a * a + (b * a + a * b) + b * b := by sorry _ = a * a + 2 * (a * b) + b * b := by sorry end -- Try these. For the second, use the theorems listed underneath. section variable (a b c d : ℝ) example : (a + b) * (c + d) = a * c + a * d + b * c + b * d := by sorry example (a b : ℝ) : (a + b) * (a - b) = a ^ 2 - b ^ 2 := by sorry #check pow_two a #check mul_sub a b c #check add_mul a b c #check add_sub a b c #check sub_sub a b c #check add_zero a end -- Examples. section variable (a b c d : ℝ) example (a b c d : ℝ) (hyp : c = d * a + b) (hyp' : b = a * d) : c = 2 * a * d := by rw [hyp'] at hyp rw [mul_comm d a] at hyp rw [← two_mul (a * d)] at hyp rw [← mul_assoc 2 a d] at hyp exact hyp example : c * b * a = b * (a * c) := by ring example : (a + b) * (a + b) = a * a + 2 * (a * b) + b * b := by ring example : (a + b) * (a - b) = a ^ 2 - b ^ 2 := by ring example (hyp : c = d * a + b) (hyp' : b = a * d) : c = 2 * a * d := by rw [hyp, hyp'] ring end example (a b c : ℕ) (h : a + b = c) : (a + b) * (a + b) = a * c + b * c := by nth_rw 2 [h] rw [add_mul]
-
-
-
@@ -1,168 +0,0 @@import Mathlib.Algebra.Ring.Defs import Mathlib.Data.Real.Basic import Mathlib.Tactic section variable (R : Type _) [Ring R] #check (add_assoc : ∀ a b c : R, a + b + c = a + (b + c)) #check (add_comm : ∀ a b : R, a + b = b + a) #check (zero_add : ∀ a : R, 0 + a = a) #check (add_left_neg : ∀ a : R, -a + a = 0) #check (mul_assoc : ∀ a b c : R, a * b * c = a * (b * c)) #check (mul_one : ∀ a : R, a * 1 = a) #check (one_mul : ∀ a : R, 1 * a = a) #check (mul_add : ∀ a b c : R, a * (b + c) = a * b + a * c) #check (add_mul : ∀ a b c : R, (a + b) * c = a * c + b * c) end section variable (R : Type _) [CommRing R] variable (a b c d : R) example : c * b * a = b * (a * c) := by ring example : (a + b) * (a + b) = a * a + 2 * (a * b) + b * b := by ring example : (a + b) * (a - b) = a ^ 2 - b ^ 2 := by ring example (hyp : c = d * a + b) (hyp' : b = a * d) : c = 2 * a * d := by rw [hyp, hyp'] ring end namespace MyRing variable {R : Type _} [Ring R] theorem add_zero (a : R) : a + 0 = a := by rw [add_comm, zero_add] theorem add_right_neg (a : R) : a + -a = 0 := by rw [add_comm, add_left_neg] #check @MyRing.add_zero #check @add_zero end MyRing namespace MyRing variable {R : Type _} [Ring R] theorem neg_add_cancel_left (a b : R) : -a + (a + b) = b := by rw [← add_assoc, add_left_neg, zero_add] -- Prove these: theorem add_neg_cancel_right (a b : R) : a + b + -b = a := by sorry theorem add_left_cancel {a b c : R} (h : a + b = a + c) : b = c := by sorry theorem add_right_cancel {a b c : R} (h : a + b = c + b) : a = c := by sorry theorem mul_zero (a : R) : a * 0 = 0 := by have h : a * 0 + a * 0 = a * 0 + 0 := by rw [← mul_add, add_zero, add_zero] rw [add_left_cancel h] theorem zero_mul (a : R) : 0 * a = 0 := by sorry theorem neg_eq_of_add_eq_zero {a b : R} (h : a + b = 0) : -a = b := by sorry theorem eq_neg_of_add_eq_zero {a b : R} (h : a + b = 0) : a = -b := by sorry theorem neg_zero : (-0 : R) = 0 := by apply neg_eq_of_add_eq_zero rw [add_zero] theorem neg_neg (a : R) : - -a = a := by sorry end MyRing -- Examples. section variable {R : Type _} [Ring R] example (a b : R) : a - b = a + -b := sub_eq_add_neg a b end example (a b : ℝ) : a - b = a + -b := rfl example (a b : ℝ) : a - b = a + -b := by rfl namespace MyRing variable {R : Type _} [Ring R] theorem self_sub (a : R) : a - a = 0 := sorry theorem one_add_one_eq_two : 1 + 1 = (2 : R) := by norm_num theorem two_mul (a : R) : 2 * a = a + a := sorry end MyRing section variable (A : Type _) [AddGroup A] #check (add_assoc : ∀ a b c : A, a + b + c = a + (b + c)) #check (zero_add : ∀ a : A, 0 + a = a) #check (add_left_neg : ∀ a : A, -a + a = 0) end section variable {G : Type _} [Group G] #check (mul_assoc : ∀ a b c : G, a * b * c = a * (b * c)) #check (one_mul : ∀ a : G, 1 * a = a) #check (mul_left_inv : ∀ a : G, a⁻¹ * a = 1) namespace MyGroup theorem mul_right_inv (a : G) : a * a⁻¹ = 1 := by sorry theorem mul_one (a : G) : a * 1 = a := by sorry theorem mul_inv_rev (a b : G) : (a * b)⁻¹ = b⁻¹ * a⁻¹ := by sorry end MyGroup end
-
-
-
@@ -1,156 +0,0 @@import Mathlib.Analysis.SpecialFunctions.Log.Basic import Mathlib.Tactic variable (a b c d e : ℝ) open Real #check (le_refl : ∀ a : ℝ, a ≤ a) #check (le_trans : a ≤ b → b ≤ c → a ≤ c) section variable (h : a ≤ b) (h' : b ≤ c) #check (le_refl : ∀ a : Real, a ≤ a) #check (le_refl a : a ≤ a) #check (le_trans : a ≤ b → b ≤ c → a ≤ c) #check (le_trans h : b ≤ c → a ≤ c) #check (le_trans h h' : a ≤ c) end example (x y z : ℝ) (h₀ : x ≤ y) (h₁ : y ≤ z) : x ≤ z := by apply le_trans · apply h₀ . apply h₁ example (x y z : ℝ) (h₀ : x ≤ y) (h₁ : y ≤ z) : x ≤ z := by apply le_trans h₀ apply h₁ example (x y z : ℝ) (h₀ : x ≤ y) (h₁ : y ≤ z) : x ≤ z := le_trans h₀ h₁ example (x : ℝ) : x ≤ x := by apply le_refl example (x : ℝ) : x ≤ x := le_refl x #check (le_refl : ∀ a, a ≤ a) #check (le_trans : a ≤ b → b ≤ c → a ≤ c) #check (lt_of_le_of_lt : a ≤ b → b < c → a < c) #check (lt_of_lt_of_le : a < b → b ≤ c → a < c) #check (lt_trans : a < b → b < c → a < c) -- Try this. example (h₀ : a ≤ b) (h₁ : b < c) (h₂ : c ≤ d) (h₃ : d < e) : a < e := by sorry example (h₀ : a ≤ b) (h₁ : b < c) (h₂ : c ≤ d) (h₃ : d < e) : a < e := by linarith section example (h : 2 * a ≤ 3 * b) (h' : 1 ≤ a) (h'' : d = 2) : d + a ≤ 5 * b := by linarith end example (h : 1 ≤ a) (h' : b ≤ c) : 2 + a + exp b ≤ 3 * a + exp c := by linarith [exp_le_exp.mpr h'] #check (exp_le_exp : exp a ≤ exp b ↔ a ≤ b) #check (exp_lt_exp : exp a < exp b ↔ a < b) #check (log_le_log : 0 < a → 0 < b → (log a ≤ log b ↔ a ≤ b)) #check (log_lt_log : 0 < a → a < b → log a < log b) #check (add_le_add : a ≤ b → c ≤ d → a + c ≤ b + d) #check (add_le_add_left : a ≤ b → ∀ c, c + a ≤ c + b) #check (add_le_add_right : a ≤ b → ∀ c, a + c ≤ b + c) #check (add_lt_add_of_le_of_lt : a ≤ b → c < d → a + c < b + d) #check (add_lt_add_of_lt_of_le : a < b → c ≤ d → a + c < b + d) #check (add_lt_add_left : a < b → ∀ c, c + a < c + b) #check (add_lt_add_right : a < b → ∀ c, a + c < b + c) #check (add_nonneg : 0 ≤ a → 0 ≤ b → 0 ≤ a + b) #check (add_pos : 0 < a → 0 < b → 0 < a + b) #check (add_pos_of_pos_of_nonneg : 0 < a → 0 ≤ b → 0 < a + b) #check (exp_pos : ∀ a, 0 < exp a) #check @add_le_add_left example (h : a ≤ b) : exp a ≤ exp b := by rw [exp_le_exp] exact h example (h₀ : a ≤ b) (h₁ : c < d) : a + exp c + e < b + exp d + e := by apply add_lt_add_of_lt_of_le · apply add_lt_add_of_le_of_lt h₀ apply exp_lt_exp.mpr h₁ apply le_refl example (h₀ : d ≤ e) : c + exp (a + d) ≤ c + exp (a + e) := by sorry example : (0 : ℝ) < 1 := by norm_num example (h : a ≤ b) : log (1 + exp a) ≤ log (1 + exp b) := by have h₀ : 0 < 1 + exp a := by sorry have h₁ : 0 < 1 + exp b := by sorry apply (log_le_log h₀ h₁).mpr sorry example : 0 ≤ a ^ 2 := by -- library_search exact sq_nonneg a example (h : a ≤ b) : c - exp b ≤ c - exp a := by sorry example : 2 * a * b ≤ a ^ 2 + b ^ 2 := by have h : 0 ≤ a ^ 2 - 2 * a * b + b ^ 2 calc a ^ 2 - 2 * a * b + b ^ 2 = (a - b) ^ 2 := by ring _ ≥ 0 := by apply pow_two_nonneg calc 2 * a * b = 2 * a * b + 0 := by ring _ ≤ 2 * a * b + (a ^ 2 - 2 * a * b + b ^ 2) := add_le_add (le_refl _) h _ = a ^ 2 + b ^ 2 := by ring example : 2 * a * b ≤ a ^ 2 + b ^ 2 := by have h : 0 ≤ a ^ 2 - 2 * a * b + b ^ 2 calc a ^ 2 - 2 * a * b + b ^ 2 = (a - b) ^ 2 := by ring _ ≥ 0 := by apply pow_two_nonneg linarith example : abs (a * b) ≤ (a ^ 2 + b ^ 2) / 2 := by sorry #check abs_le'.mpr
-
-
-
@@ -1,98 +0,0 @@import Mathlib.Data.Real.Basic section variable (a b c d : ℝ) #check (min_le_left a b : min a b ≤ a) #check (min_le_right a b : min a b ≤ b) #check (le_min : c ≤ a → c ≤ b → c ≤ min a b) example : min a b = min b a := by apply le_antisymm · show min a b ≤ min b a apply le_min · apply min_le_right apply min_le_left · show min b a ≤ min a b apply le_min · apply min_le_right apply min_le_left example : min a b = min b a := by have h : ∀ x y : ℝ, min x y ≤ min y x := by intro x y apply le_min apply min_le_right apply min_le_left apply le_antisymm apply h apply h example : min a b = min b a := by apply le_antisymm repeat apply le_min apply min_le_right apply min_le_left example : max a b = max b a := by sorry example : min (min a b) c = min a (min b c) := by sorry theorem aux : min a b + c ≤ min (a + c) (b + c) := by sorry example : min a b + c = min (a + c) (b + c) := by sorry #check (abs_add : ∀ a b : ℝ, abs (a + b) ≤ abs a + abs b) example : abs a - abs b ≤ abs (a - b) := sorry end section variable (w x y z : ℕ) example (h₀ : x ∣ y) (h₁ : y ∣ z) : x ∣ z := dvd_trans h₀ h₁ example : x ∣ y * x * z := by apply dvd_mul_of_dvd_left apply dvd_mul_left example : x ∣ x ^ 2 := by apply dvd_mul_left example (h : x ∣ w) : x ∣ y * (x * z) + x ^ 2 + w ^ 2 := by sorry end section variable (m n : ℕ) open Nat #check (gcd_zero_right n : gcd n 0 = n) #check (gcd_zero_left n : gcd 0 n = n) #check (lcm_zero_right n : lcm n 0 = 0) #check (lcm_zero_left n : lcm 0 n = 0) example : gcd m n = gcd n m := by sorry end
-
-
-
@@ -1,141 +0,0 @@import Mathlib.Topology.MetricSpace.Basic section variable {α : Type _} [PartialOrder α] variable (x y z : α) #check x ≤ y #check (le_refl x : x ≤ x) #check (le_trans : x ≤ y → y ≤ z → x ≤ z) #check x < y #check (lt_irrefl x : ¬x < x) #check (lt_trans : x < y → y < z → x < z) #check (lt_of_le_of_lt : x ≤ y → y < z → x < z) #check (lt_of_lt_of_le : x < y → y ≤ z → x < z) example : x < y ↔ x ≤ y ∧ x ≠ y := lt_iff_le_and_ne end section variable {α : Type _} [Lattice α] variable (x y z : α) #check x ⊓ y #check (inf_le_left : x ⊓ y ≤ x) #check (inf_le_right : x ⊓ y ≤ y) #check (le_inf : z ≤ x → z ≤ y → z ≤ x ⊓ y) #check x ⊔ y #check (le_sup_left : x ≤ x ⊔ y) #check (le_sup_right : y ≤ x ⊔ y) #check (sup_le : x ≤ z → y ≤ z → x ⊔ y ≤ z) example : x ⊓ y = y ⊓ x := by sorry example : x ⊓ y ⊓ z = x ⊓ (y ⊓ z) := by sorry example : x ⊔ y = y ⊔ x := by sorry example : x ⊔ y ⊔ z = x ⊔ (y ⊔ z) := by sorry theorem absorb1 : x ⊓ (x ⊔ y) = x := by sorry theorem absorb2 : x ⊔ x ⊓ y = x := by sorry end section variable {α : Type _} [DistribLattice α] variable (x y z : α) #check (inf_sup_left : x ⊓ (y ⊔ z) = x ⊓ y ⊔ x ⊓ z) #check (inf_sup_right : (x ⊔ y) ⊓ z = x ⊓ z ⊔ y ⊓ z) #check (sup_inf_left : x ⊔ y ⊓ z = (x ⊔ y) ⊓ (x ⊔ z)) #check (sup_inf_right : x ⊓ y ⊔ z = (x ⊔ z) ⊓ (y ⊔ z)) end section variable {α : Type _} [Lattice α] variable (a b c : α) example (h : ∀ x y z : α, x ⊓ (y ⊔ z) = x ⊓ y ⊔ x ⊓ z) : a ⊔ b ⊓ c = (a ⊔ b) ⊓ (a ⊔ c) := by sorry example (h : ∀ x y z : α, x ⊔ y ⊓ z = (x ⊔ y) ⊓ (x ⊔ z)) : a ⊓ (b ⊔ c) = a ⊓ b ⊔ a ⊓ c := by sorry end section variable {R : Type _} [StrictOrderedRing R] variable (a b c : R) #check (add_le_add_left : a ≤ b → ∀ c, c + a ≤ c + b) #check (mul_pos : 0 < a → 0 < b → 0 < a * b) #check (mul_nonneg : 0 ≤ a → 0 ≤ b → 0 ≤ a * b) example : a ≤ b → 0 ≤ b - a := by sorry example : 0 ≤ b - a → a ≤ b := by sorry example (h : a ≤ b) (h' : 0 ≤ c) : a * c ≤ b * c := by sorry end section variable {X : Type _} [MetricSpace X] variable (x y z : X) #check (dist_self x : dist x x = 0) #check (dist_comm x y : dist x y = dist y x) #check (dist_triangle x y z : dist x z ≤ dist x y + dist y z) example (x y : X) : 0 ≤ dist x y := by sorry end
-
-
-
@@ -1,33 +0,0 @@import Mathlib.Data.Real.Basic import Mathlib.Data.Real.Basic example (a b c : ℝ) : c * b * a = b * (a * c) := by rw [mul_comm c b] rw [mul_assoc b c a] rw [mul_comm c a] example (a b c : ℝ) : a * (b * c) = b * (a * c) := by rw [← mul_assoc a b c] rw [mul_comm a b] rw [mul_assoc b a c] example (a b c : ℝ) : a * (b * c) = b * (c * a) := by rw [mul_comm] rw [mul_assoc] example (a b c : ℝ) : a * (b * c) = b * (a * c) := by rw [← mul_assoc] rw [mul_comm a] rw [mul_assoc] example (a b c d e f : ℝ) (h : b * c = e * f) : a * b * c * d = a * e * f * d := by rw [mul_assoc a] rw [h] rw [← mul_assoc] example (a b c d : ℝ) (hyp : c = b * a - d) (hyp' : d = a * b) : c = 0 := by rw [hyp] rw [hyp'] rw [mul_comm] rw [sub_self]
-
-
-
@@ -1,76 +0,0 @@import Mathlib.Algebra.Ring.Defs import Mathlib.Data.Real.Basic import Mathlib.Tactic namespace MyRing variable {R : Type _} [Ring R] theorem add_neg_cancel_right (a b : R) : a + b + -b = a := by rw [add_assoc, add_right_neg, add_zero] theorem add_left_cancel {a b c : R} (h : a + b = a + c) : b = c := by rw [← neg_add_cancel_left a b, h, neg_add_cancel_left] theorem add_right_cancel {a b c : R} (h : a + b = c + b) : a = c := by rw [← add_neg_cancel_right a b, h, add_neg_cancel_right] theorem zero_mul (a : R) : 0 * a = 0 := by have h : 0 * a + 0 * a = 0 * a + 0 := by rw [← add_mul, add_zero, add_zero] rw [add_left_cancel h] theorem neg_eq_of_add_eq_zero {a b : R} (h : a + b = 0) : -a = b := by rw [← neg_add_cancel_left a b, h, add_zero] theorem eq_neg_of_add_eq_zero {a b : R} (h : a + b = 0) : a = -b := by symm apply neg_eq_of_add_eq_zero rw [add_comm, h] theorem neg_zero : (-0 : R) = 0 := by apply neg_eq_of_add_eq_zero rw [add_zero] theorem neg_neg (a : R) : - -a = a := by apply neg_eq_of_add_eq_zero rw [add_left_neg] end MyRing namespace MyRing variable {R : Type _} [Ring R] theorem self_sub (a : R) : a - a = 0 := by rw [sub_eq_add_neg, add_right_neg] theorem one_add_one_eq_two : 1 + 1 = (2 : R) := by norm_num theorem two_mul (a : R) : 2 * a = a + a := by rw [← one_add_one_eq_two, add_mul, one_mul] end MyRing section variable {G : Type _} [Group G] namespace MyGroup theorem mul_right_inv (a : G) : a * a⁻¹ = 1 := by have h : (a * a⁻¹)⁻¹ * (a * a⁻¹ * (a * a⁻¹)) = 1 := by rw [mul_assoc, ← mul_assoc a⁻¹ a, mul_left_inv, one_mul, mul_left_inv] rw [← h, ← mul_assoc, mul_left_inv, one_mul] theorem mul_one (a : G) : a * 1 = a := by rw [← mul_left_inv a, ← mul_assoc, mul_right_inv, one_mul] theorem mul_inv_rev (a b : G) : (a * b)⁻¹ = b⁻¹ * a⁻¹ := by rw [← one_mul (b⁻¹ * a⁻¹), ← mul_left_inv (a * b), mul_assoc, mul_assoc, ← mul_assoc b b⁻¹, mul_right_inv, one_mul, mul_right_inv, mul_one] end MyGroup end
-
-
-
@@ -1,62 +0,0 @@import Mathlib.Analysis.SpecialFunctions.Log.Basic import Mathlib.Tactic variable (a b c d e : ℝ) open Real example (h₀ : a ≤ b) (h₁ : b < c) (h₂ : c ≤ d) (h₃ : d < e) : a < e := by apply lt_of_le_of_lt h₀ apply lt_trans h₁ exact lt_of_le_of_lt h₂ h₃ example (h₀ : d ≤ e) : c + exp (a + d) ≤ c + exp (a + e) := by apply add_le_add_left rw [exp_le_exp] apply add_le_add_left h₀ -- an alternative using `linarith`. example (h₀ : d ≤ e) : c + exp (a + d) ≤ c + exp (a + e) := by have : exp (a + d) ≤ exp (a + e) := by rw [exp_le_exp] linarith linarith [this] example (h : a ≤ b) : log (1 + exp a) ≤ log (1 + exp b) := by have h₀ : 0 < 1 + exp a := by linarith [exp_pos a] have h₁ : 0 < 1 + exp b := by linarith [exp_pos b] apply (log_le_log h₀ h₁).mpr apply add_le_add_left (exp_le_exp.mpr h) -- SOLUTION. example (h : a ≤ b) : c - exp b ≤ c - exp a := by apply sub_le_sub_left exact exp_le_exp.mpr h -- alternatively: example (h : a ≤ b) : c - exp b ≤ c - exp a := by linarith [exp_le_exp.mpr h] theorem fact1 : a * b * 2 ≤ a ^ 2 + b ^ 2 := by have h : 0 ≤ a ^ 2 - 2 * a * b + b ^ 2 calc a ^ 2 - 2 * a * b + b ^ 2 = (a - b) ^ 2 := by ring _ ≥ 0 := by apply pow_two_nonneg linarith theorem fact2 : -(a * b) * 2 ≤ a ^ 2 + b ^ 2 := by have h : 0 ≤ a ^ 2 + 2 * a * b + b ^ 2 calc a ^ 2 + 2 * a * b + b ^ 2 = (a + b) ^ 2 := by ring _ ≥ 0 := by apply pow_two_nonneg linarith example : abs (a * b) ≤ (a ^ 2 + b ^ 2) / 2 := by have h : (0 : ℝ) < 2 := by norm_num apply abs_le'.mpr constructor · rw [le_div_iff h] apply fact1 rw [le_div_iff h] apply fact2
-
-
-
@@ -1,124 +0,0 @@import Mathlib.Data.Real.Basic section variable (a b c d : ℝ) #check (min_le_left a b : min a b ≤ a) #check (min_le_right a b : min a b ≤ b) #check (le_min : c ≤ a → c ≤ b → c ≤ min a b) example : max a b = max b a := by apply le_antisymm repeat' apply max_le apply le_max_right apply le_max_left example : min (min a b) c = min a (min b c) := by apply le_antisymm · apply le_min · apply le_trans apply min_le_left apply min_le_left apply le_min · apply le_trans apply min_le_left apply min_le_right apply min_le_right apply le_min · apply le_min · apply min_le_left apply le_trans apply min_le_right apply min_le_left apply le_trans apply min_le_right apply min_le_right theorem aux : min a b + c ≤ min (a + c) (b + c) := by apply le_min · apply add_le_add_right apply min_le_left apply add_le_add_right apply min_le_right example : min a b + c = min (a + c) (b + c) := by apply le_antisymm · apply aux have h : min (a + c) (b + c) = min (a + c) (b + c) - c + c := by rw [sub_add_cancel] rw [h] apply add_le_add_right rw [sub_eq_add_neg] apply le_trans apply aux rw [add_neg_cancel_right, add_neg_cancel_right] example : abs a - abs b ≤ abs (a - b) := calc abs a - abs b = abs (a - b + b) - abs b := by rw [sub_add_cancel] _ ≤ abs (a - b) + abs b - abs b := by apply sub_le_sub_right apply abs_add _ ≤ abs (a - b) := by rw [add_sub_cancel] -- alternatively example : abs a - abs b ≤ abs (a - b) := by have h := abs_add (a - b) b rw [sub_add_cancel] at h linarith end section variable (w x y z : ℕ) example (h₀ : x ∣ y) (h₁ : y ∣ z) : x ∣ z := dvd_trans h₀ h₁ example : x ∣ y * x * z := by apply dvd_mul_of_dvd_left apply dvd_mul_left example : x ∣ x ^ 2 := by apply dvd_mul_left example (h : x ∣ w) : x ∣ y * (x * z) + x ^ 2 + w ^ 2 := by apply dvd_add · apply dvd_add · apply dvd_mul_of_dvd_right apply dvd_mul_right apply dvd_mul_left rw [pow_two] apply dvd_mul_of_dvd_right exact h end section variable (m n : ℕ) open Nat #check (gcd_zero_right n : gcd n 0 = n) #check (gcd_zero_left n : gcd 0 n = n) #check (lcm_zero_right n : lcm n 0 = 0) #check (lcm_zero_left n : lcm 0 n = 0) example : gcd m n = gcd n m := by apply _root_.dvd_antisymm repeat' apply dvd_gcd apply gcd_dvd_right apply gcd_dvd_left end
-
-
-
@@ -1,149 +0,0 @@import Mathlib.Topology.MetricSpace.Basic section variable {α : Type _} [Lattice α] variable (x y z : α) example : x ⊓ y = y ⊓ x := by apply le_antisymm repeat' apply le_inf · apply inf_le_right apply inf_le_left example : x ⊓ y ⊓ z = x ⊓ (y ⊓ z) := by apply le_antisymm · apply le_inf · apply le_trans apply inf_le_left apply inf_le_left apply le_inf · apply le_trans apply inf_le_left apply inf_le_right apply inf_le_right apply le_inf · apply le_inf · apply inf_le_left apply le_trans apply inf_le_right apply inf_le_left apply le_trans apply inf_le_right apply inf_le_right example : x ⊔ y = y ⊔ x := by apply le_antisymm repeat' apply sup_le · apply le_sup_right apply le_sup_left example : x ⊔ y ⊔ z = x ⊔ (y ⊔ z) := by apply le_antisymm · apply sup_le · apply sup_le apply le_sup_left · apply le_trans apply @le_sup_left _ _ y z apply le_sup_right apply le_trans apply @le_sup_right _ _ y z apply le_sup_right apply sup_le · apply le_trans apply @le_sup_left _ _ x y apply le_sup_left apply sup_le · apply le_trans apply @le_sup_right _ _ x y apply le_sup_left apply le_sup_right theorem absorb1 : x ⊓ (x ⊔ y) = x := by apply le_antisymm · apply inf_le_left apply le_inf · apply le_refl apply le_sup_left theorem absorb2 : x ⊔ x ⊓ y = x := by apply le_antisymm · apply sup_le · apply le_refl apply inf_le_left apply le_sup_left end section variable {α : Type _} [DistribLattice α] variable (x y z : α) #check (inf_sup_left : x ⊓ (y ⊔ z) = x ⊓ y ⊔ x ⊓ z) #check (inf_sup_right : (x ⊔ y) ⊓ z = x ⊓ z ⊔ y ⊓ z) #check (sup_inf_left : x ⊔ y ⊓ z = (x ⊔ y) ⊓ (x ⊔ z)) #check (sup_inf_right : x ⊓ y ⊔ z = (x ⊔ z) ⊓ (y ⊔ z)) end section variable {α : Type _} [Lattice α] variable (a b c : α) example (h : ∀ x y z : α, x ⊓ (y ⊔ z) = x ⊓ y ⊔ x ⊓ z) : a ⊔ b ⊓ c = (a ⊔ b) ⊓ (a ⊔ c) := by rw [h, @inf_comm _ _ (a ⊔ b), absorb1, @inf_comm _ _ (a ⊔ b), h, ← sup_assoc, @inf_comm _ _ c a, absorb2, inf_comm] example (h : ∀ x y z : α, x ⊔ y ⊓ z = (x ⊔ y) ⊓ (x ⊔ z)) : a ⊓ (b ⊔ c) = a ⊓ b ⊔ a ⊓ c := by rw [h, @sup_comm _ _ (a ⊓ b), absorb2, @sup_comm _ _ (a ⊓ b), h, ← inf_assoc, @sup_comm _ _ c a, absorb1, sup_comm] end section variable {R : Type _} [StrictOrderedRing R] variable (a b c : R) theorem aux1 : a ≤ b → 0 ≤ b - a := by intro h rw [← sub_self a, sub_eq_add_neg, sub_eq_add_neg, add_comm, add_comm b] apply add_le_add_left h theorem aux2 : 0 ≤ b - a → a ≤ b := by intro h rw [← add_zero a, ← sub_add_cancel b a, add_comm (b - a)] apply add_le_add_left h example (h : a ≤ b) (h' : 0 ≤ c) : a * c ≤ b * c := by have h1 : 0 ≤ (b - a) * c := mul_nonneg (aux1 _ _ h) h' rw [sub_mul] at h1 exact aux2 _ _ h1 end section variable {X : Type _} [MetricSpace X] variable (x y z : X) example (x y : X) : 0 ≤ dist x y :=by have : 0 ≤ dist x y + dist y x := by rw [← dist_self x] apply dist_triangle linarith [dist_comm x y] end
-
-
-
@@ -1,2 +0,0 @@#eval "Hello, World!"
-
-
MIL/C_Introduction/S02_Overview.lean (deleted)
-
@@ -1,56 +0,0 @@import Mathlib.Data.Nat.Basic import Mathlib.Data.Nat.Parity import Mathlib.Tactic open Nat -- These are pieces of data. #check 2 + 2 def f (x : ℕ) := x + 3 #check f -- These are propositions, of type `Prop`. #check 2 + 2 = 4 def FermatLastTheorem := ∀ x y z n : ℕ, n > 2 ∧ x * y * z ≠ 0 → x ^ n + y ^ n ≠ z ^ n #check FermatLastTheorem -- These are proofs of propositions. theorem easy : 2 + 2 = 4 := rfl #check easy theorem hard : FermatLastTheorem := sorry #check hard -- Here are some proofs. example : ∀ m n : Nat, Even n → Even (m * n) := fun m n ⟨k, (hk : n = k + k)⟩ => have hmn : m * n = m * k + m * k := by rw [hk, mul_add] show ∃ l, m * n = l + l from ⟨_, hmn⟩ example : ∀ m n : Nat, Even n → Even (m * n) := fun m n ⟨k, hk⟩ => ⟨m * k, by rw [hk, mul_add]⟩ example : ∀ m n : Nat, Even n → Even (m * n) := by -- say m and n are natural numbers, and assume n=2*k rintro m n ⟨k, hk⟩ -- We need to prove m*n is twice a natural number. Let's show it's twice m*k. use m * k -- substitute in for n rw [hk] -- and now it's obvious ring example : ∀ m n : Nat, Even n → Even (m * n) := by rintro m n ⟨k, hk⟩; use m * k; rw [hk]; ring example : ∀ m n : Nat, Even n → Even (m * n) := by intros; simp [*, parity_simps]
-
-
-
-
@@ -1,7 +0,0 @@import Mathlib.Data.Nat.Basic import Mathlib.Data.Nat.Parity import Mathlib.Tactic open Nat -- There are no exercises in this section.
-
-
-
@@ -1,178 +0,0 @@import Mathlib.Data.Real.Basic #check ∀ x : ℝ, 0 ≤ x → abs x = x #check ∀ x y ε : ℝ, 0 < ε → ε ≤ 1 → abs x < ε → abs y < ε → abs (x * y) < ε theorem my_lemma : ∀ x y ε : ℝ, 0 < ε → ε ≤ 1 → abs x < ε → abs y < ε → abs (x * y) < ε := sorry section variable (a b δ : ℝ) variable (h₀ : 0 < δ) (h₁ : δ ≤ 1) variable (ha : abs a < δ) (hb : abs b < δ) #check my_lemma a b δ #check my_lemma a b δ h₀ h₁ #check my_lemma a b δ h₀ h₁ ha hb end theorem my_lemma2 : ∀ {x y ε : ℝ}, 0 < ε → ε ≤ 1 → abs x < ε → abs y < ε → abs (x * y) < ε := sorry section variable (a b δ : ℝ) variable (h₀ : 0 < δ) (h₁ : δ ≤ 1) variable (ha : abs a < δ) (hb : abs b < δ) #check my_lemma2 h₀ h₁ ha hb end theorem my_lemma3 : ∀ {x y ε : ℝ}, 0 < ε → ε ≤ 1 → abs x < ε → abs y < ε → abs (x * y) < ε := by intro x y ε epos ele1 xlt ylt sorry theorem my_lemma4 : ∀ {x y ε : ℝ}, 0 < ε → ε ≤ 1 → abs x < ε → abs y < ε → abs (x * y) < ε := by intro x y ε epos ele1 xlt ylt calc abs (x * y) = abs x * abs y := sorry _ ≤ abs x * ε := sorry _ < 1 * ε := sorry _ = ε := sorry def FnUb (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, f x ≤ a def FnLb (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, a ≤ f x section variable (f g : ℝ → ℝ) (a b : ℝ) example (hfa : FnUb f a) (hgb : FnUb g b) : FnUb (fun x ↦ f x + g x) (a + b) := by intro x dsimp apply add_le_add apply hfa apply hgb example (hfa : FnLb f a) (hgb : FnLb g b) : FnLb (fun x => f x + g x) (a + b) := sorry example (nnf : FnLb f 0) (nng : FnLb g 0) : FnLb (fun x => f x * g x) 0 := sorry example (hfa : FnUb f a) (hfb : FnUb g b) (nng : FnLb g 0) (nna : 0 ≤ a) : FnUb (fun x => f x * g x) (a * b) := sorry end section variable {α : Type _} {R : Type _} [OrderedCancelAddCommMonoid R] #check @add_le_add def FnUb' (f : α → R) (a : R) : Prop := ∀ x, f x ≤ a theorem fn_ub_add {f g : α → R} {a b : R} (hfa : FnUb' f a) (hgb : FnUb' g b) : FnUb' (fun x => f x + g x) (a + b) := fun x => add_le_add (hfa x) (hgb x) end example (f : ℝ → ℝ) (h : Monotone f) : ∀ {a b}, a ≤ b → f a ≤ f b := @h section variable (f g : ℝ → ℝ) example (mf : Monotone f) (mg : Monotone g) : Monotone fun x => f x + g x := by intro a b aleb apply add_le_add apply mf aleb apply mg aleb example (mf : Monotone f) (mg : Monotone g) : Monotone fun x => f x + g x := fun a b aleb => add_le_add (mf aleb) (mg aleb) example {c : ℝ} (mf : Monotone f) (nnc : 0 ≤ c) : Monotone fun x => c * f x := sorry example (mf : Monotone f) (mg : Monotone g) : Monotone fun x => f (g x) := sorry def FnEven (f : ℝ → ℝ) : Prop := ∀ x, f x = f (-x) def FnOdd (f : ℝ → ℝ) : Prop := ∀ x, f x = -f (-x) example (ef : FnEven f) (eg : FnEven g) : FnEven fun x => f x + g x := by intro x calc (fun x => f x + g x) x = f x + g x := rfl _ = f (-x) + g (-x) := by rw [ef, eg] example (of : FnOdd f) (og : FnOdd g) : FnEven fun x => f x * g x := by sorry example (ef : FnEven f) (og : FnOdd g) : FnOdd fun x => f x * g x := by sorry example (ef : FnEven f) (og : FnOdd g) : FnEven fun x => f (g x) := by sorry end section variable {α : Type _} (r s t : Set α) example : s ⊆ s := by intro x xs exact xs theorem Subset.refl : s ⊆ s := fun x xs => xs theorem Subset.trans : r ⊆ s → s ⊆ t → r ⊆ t := by sorry end section variable {α : Type _} [PartialOrder α] variable (s : Set α) (a b : α) def SetUb (s : Set α) (a : α) := ∀ x, x ∈ s → x ≤ a example (h : SetUb s a) (h' : a ≤ b) : SetUb s b := sorry end section open Function example (c : ℝ) : Injective fun x => x + c := by intro x₁ x₂ h' exact (add_left_inj c).mp h' example {c : ℝ} (h : c ≠ 0) : Injective fun x => c * x := by sorry variable {α : Type _} {β : Type _} {γ : Type _} variable {g : β → γ} {f : α → β} example (injg : Injective g) (injf : Injective f) : Injective fun x => g (f x) := by sorry end
-
-
-
@@ -1,135 +0,0 @@import Mathlib.Data.Real.Basic example : ∃ x : ℝ, 2 < x ∧ x < 3 := by use 5 / 2 norm_num example : ∃ x : ℝ, 2 < x ∧ x < 3 := have h : 2 < (5 : ℝ) / 2 ∧ (5 : ℝ) / 2 < 3 := by norm_num ⟨5 / 2, h⟩ example : ∃ x : ℝ, 2 < x ∧ x < 3 := ⟨5 / 2, by norm_num⟩ def FnUb (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, f x ≤ a def FnLb (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, a ≤ f x def FnHasUb (f : ℝ → ℝ) := ∃ a, FnUb f a def FnHasLb (f : ℝ → ℝ) := ∃ a, FnLb f a theorem fnUb_add {f g : ℝ → ℝ} {a b : ℝ} (hfa : FnUb f a) (hgb : FnUb g b) : FnUb (fun x => f x + g x) (a + b) := fun x => add_le_add (hfa x) (hgb x) section variable {f g : ℝ → ℝ} example (ubf : FnHasUb f) (ubg : FnHasUb g) : FnHasUb fun x => f x + g x := by cases' ubf with a ubfa cases' ubg with b ubfb use a + b apply fnUb_add ubfa ubfb example (lbf : FnHasLb f) (lbg : FnHasLb g) : FnHasLb fun x => f x + g x := by sorry example {c : ℝ} (ubf : FnHasUb f) (h : c ≥ 0) : FnHasUb fun x => c * f x := by sorry example (ubf : FnHasUb f) (ubg : FnHasUb g) : FnHasUb fun x => f x + g x := by rcases ubf with ⟨a, ubfa⟩ rcases ubg with ⟨b, ubfb⟩ exact ⟨a + b, fnUb_add ubfa ubfb⟩ example : FnHasUb f → FnHasUb g → FnHasUb fun x => f x + g x := by rintro ⟨a, ubfa⟩ ⟨b, ubfb⟩ exact ⟨a + b, fnUb_add ubfa ubfb⟩ example : FnHasUb f → FnHasUb g → FnHasUb fun x => f x + g x := fun ⟨a, ubfa⟩ ⟨b, ubfb⟩ => ⟨a + b, fnUb_add ubfa ubfb⟩ end section variable {α : Type _} [CommRing α] def SumOfSquares (x : α) := ∃ a b, x = a ^ 2 + b ^ 2 theorem sumOfSquares_mul {x y : α} (sosx : SumOfSquares x) (sosy : SumOfSquares y) : SumOfSquares (x * y) := by rcases sosx with ⟨a, b, xeq⟩ rcases sosy with ⟨c, d, yeq⟩ rw [xeq, yeq] use a * c - b * d, a * d + b * c ring theorem sumOfSquares_mul' {x y : α} (sosx : SumOfSquares x) (sosy : SumOfSquares y) : SumOfSquares (x * y) := by rcases sosx with ⟨a, b, rfl⟩ rcases sosy with ⟨c, d, rfl⟩ use a * c - b * d, a * d + b * c ring end section variable {a b c : ℕ} example (divab : a ∣ b) (divbc : b ∣ c) : a ∣ c := by cases' divab with d beq cases' divbc with e ceq rw [ceq, beq] use d * e; ring example (divab : a ∣ b) (divac : a ∣ c) : a ∣ b + c := by sorry end section open Function example {c : ℝ} : Surjective fun x => x + c := by intro x use x - c dsimp; ring example {c : ℝ} (h : c ≠ 0) : Surjective fun x => c * x := by sorry example (x y : ℝ) (h : x - y ≠ 0) : (x ^ 2 - y ^ 2) / (x - y) = x + y := by field_simp [h] ring example {f : ℝ → ℝ} (h : Surjective f) : ∃ x, f x ^ 2 = 4 := by cases' h 2 with x hx use x rw [hx] norm_num end section open Function variable {α : Type _} {β : Type _} {γ : Type _} variable {g : β → γ} {f : α → β} example (surjg : Surjective g) (surjf : Surjective f) : Surjective fun x => g (f x) := by sorry end
-
-
MIL/C_Logic/S03_Negation.lean (deleted)
-
@@ -1,143 +0,0 @@import Mathlib.Data.Real.Basic section variable (a b : ℝ) example (h : a < b) : ¬b < a := by intro h' have : a < a := lt_trans h h' apply lt_irrefl a this def FnUb (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, f x ≤ a def FnLb (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, a ≤ f x def FnHasUb (f : ℝ → ℝ) := ∃ a, FnUb f a def FnHasLb (f : ℝ → ℝ) := ∃ a, FnLb f a variable (f : ℝ → ℝ) example (h : ∀ a, ∃ x, f x > a) : ¬FnHasUb f := by intro fnub cases' fnub with a fnuba cases' h a with x hx have : f x ≤ a := fnuba x linarith example (h : ∀ a, ∃ x, f x < a) : ¬FnHasLb f := sorry example : ¬FnHasUb fun x => x := sorry #check (not_le_of_gt : a > b → ¬a ≤ b) #check (not_lt_of_ge : a ≥ b → ¬a < b) #check (lt_of_not_ge : ¬a ≥ b → a < b) #check (le_of_not_gt : ¬a > b → a ≤ b) example (h : Monotone f) (h' : f a < f b) : a < b := by sorry example (h : a ≤ b) (h' : f b < f a) : ¬Monotone f := by sorry example : ¬∀ {f : ℝ → ℝ}, Monotone f → ∀ {a b}, f a ≤ f b → a ≤ b := by intro h let f := fun x : ℝ => (0 : ℝ) have monof : Monotone f := by sorry have h' : f 1 ≤ f 0 := le_refl _ sorry example (x : ℝ) (h : ∀ ε > 0, x < ε) : x ≤ 0 := by sorry end section variable {α : Type _} (P : α → Prop) (Q : Prop) example (h : ¬∃ x, P x) : ∀ x, ¬P x := by sorry example (h : ∀ x, ¬P x) : ¬∃ x, P x := by sorry example (h : ¬∀ x, P x) : ∃ x, ¬P x := by sorry example (h : ∃ x, ¬P x) : ¬∀ x, P x := by sorry example (h : ¬∀ x, P x) : ∃ x, ¬P x := by by_contra h' apply h intro x show P x by_contra h'' exact h' ⟨x, h''⟩ example (h : ¬¬Q) : Q := by sorry example (h : Q) : ¬¬Q := by sorry end section variable (f : ℝ → ℝ) example (h : ¬FnHasUb f) : ∀ a, ∃ x, f x > a := by sorry example (h : ¬∀ a, ∃ x, f x > a) : FnHasUb f := by push_neg at h exact h example (h : ¬FnHasUb f) : ∀ a, ∃ x, f x > a := by simp only [FnHasUb, FnUb] at h push_neg at h exact h example (h : ¬Monotone f) : ∃ x y, x ≤ y ∧ f y < f x := by sorry example (h : ¬FnHasUb f) : ∀ a, ∃ x, f x > a := by contrapose! h exact h example (x : ℝ) (h : ∀ ε > 0, x ≤ ε) : x ≤ 0 := by contrapose! h use x / 2 constructor <;> linarith end section variable (a : ℕ) example (h : 0 < 0) : a > 37 := by exfalso apply lt_irrefl 0 h example (h : 0 < 0) : a > 37 := absurd h (lt_irrefl 0) example (h : 0 < 0) : a > 37 := by have h' : ¬0 < 0 := lt_irrefl 0 contradiction end
-
-
-
@@ -1,138 +0,0 @@import Mathlib.Data.Real.Basic import Mathlib.Data.Nat.Prime import Mathlib.Tactic.NormNum example {x y : ℝ} (h₀ : x ≤ y) (h₁ : ¬y ≤ x) : x ≤ y ∧ x ≠ y := by constructor · assumption intro h apply h₁ rw [h] example {x y : ℝ} (h₀ : x ≤ y) (h₁ : ¬y ≤ x) : x ≤ y ∧ x ≠ y := ⟨h₀, fun h => h₁ (by rw [h])⟩ example {x y : ℝ} (h₀ : x ≤ y) (h₁ : ¬y ≤ x) : x ≤ y ∧ x ≠ y := have h : x ≠ y := by contrapose! h₁ rw [h₁] ⟨h₀, h⟩ example {x y : ℝ} (h : x ≤ y ∧ x ≠ y) : ¬y ≤ x := by cases' h with h₀ h₁ contrapose! h₁ exact le_antisymm h₀ h₁ example {x y : ℝ} : x ≤ y ∧ x ≠ y → ¬y ≤ x := by rintro ⟨h₀, h₁⟩ h' exact h₁ (le_antisymm h₀ h') example {x y : ℝ} : x ≤ y ∧ x ≠ y → ¬y ≤ x := fun ⟨h₀, h₁⟩ h' => h₁ (le_antisymm h₀ h') example {x y : ℝ} (h : x ≤ y ∧ x ≠ y) : ¬y ≤ x := by intro h' apply h.right exact le_antisymm h.left h' example {x y : ℝ} (h : x ≤ y ∧ x ≠ y) : ¬y ≤ x := fun h' => h.right (le_antisymm h.left h') example {m n : ℕ} (h : m ∣ n ∧ m ≠ n) : m ∣ n ∧ ¬n ∣ m := sorry example : ∃ x : ℝ, 2 < x ∧ x < 4 := ⟨5 / 2, by norm_num, by norm_num⟩ example (x y : ℝ) : (∃ z : ℝ, x < z ∧ z < y) → x < y := by rintro ⟨z, xltz, zlty⟩ exact lt_trans xltz zlty example (x y : ℝ) : (∃ z : ℝ, x < z ∧ z < y) → x < y := fun ⟨z, xltz, zlty⟩ => lt_trans xltz zlty example : ∃ x : ℝ, 2 < x ∧ x < 4 := by use 5 / 2 constructor <;> norm_num example : ∃ m n : ℕ, 4 < m ∧ m < n ∧ n < 10 ∧ Nat.Prime m ∧ Nat.Prime n := by use 5 use 7 norm_num sorry example {x y : ℝ} : x ≤ y ∧ x ≠ y → x ≤ y ∧ ¬y ≤ x := by rintro ⟨h₀, h₁⟩ use h₀ exact fun h' => h₁ (le_antisymm h₀ h') example {x y : ℝ} (h : x ≤ y) : ¬y ≤ x ↔ x ≠ y := by constructor · contrapose! rintro rfl rfl contrapose! exact le_antisymm h example {x y : ℝ} (h : x ≤ y) : ¬y ≤ x ↔ x ≠ y := ⟨fun h₀ h₁ => h₀ (by rw [h₁]), fun h₀ h₁ => h₀ (le_antisymm h h₁)⟩ example {x y : ℝ} : x ≤ y ∧ ¬y ≤ x ↔ x ≤ y ∧ x ≠ y := sorry theorem aux {x y : ℝ} (h : x ^ 2 + y ^ 2 = 0) : x = 0 := have h' : x ^ 2 = 0 := by sorry pow_eq_zero h' example (x y : ℝ) : x ^ 2 + y ^ 2 = 0 ↔ x = 0 ∧ y = 0 := sorry section example (x : ℝ) : abs (x + 3) < 5 → -8 < x ∧ x < 2 := by rw [abs_lt] intro h constructor <;> linarith example : 3 ∣ Nat.gcd 6 15 := by rw [Nat.dvd_gcd_iff] constructor <;> norm_num end theorem not_monotone_iff {f : ℝ → ℝ} : ¬Monotone f ↔ ∃ x y, x ≤ y ∧ f x > f y := by rw [Monotone] push_neg rfl example : ¬Monotone fun x : ℝ => -x := by sorry section variable {α : Type _} [PartialOrder α] variable (a b : α) example : a < b ↔ a ≤ b ∧ a ≠ b := by rw [lt_iff_le_not_le] sorry end section variable {α : Type _} [Preorder α] variable (a b c : α) example : ¬a < a := by rw [lt_iff_le_not_le] sorry example : a < b → b < c → a < c := by simp only [lt_iff_le_not_le] sorry end
-
-
MIL/C_Logic/S05_Disjunction.lean (deleted)
-
@@ -1,102 +0,0 @@import Mathlib.Data.Real.Basic section variable {x y : ℝ} example (h : y > x ^ 2) : y > 0 ∨ y < -1 := by left linarith [pow_two_nonneg x] example (h : -y > x ^ 2 + 1) : y > 0 ∨ y < -1 := by right linarith [pow_two_nonneg x] example (h : y > 0) : y > 0 ∨ y < -1 := Or.inl h example (h : y < -1) : y > 0 ∨ y < -1 := Or.inr h example : x < abs y → x < y ∨ x < -y := by cases' le_or_gt 0 y with h h · rw [abs_of_nonneg h] intro h left exact h rw [abs_of_neg h] intro h; right; exact h namespace MyAbs theorem le_abs_self (x : ℝ) : x ≤ abs x := by sorry theorem neg_le_abs_self (x : ℝ) : -x ≤ abs x := by sorry theorem abs_add (x y : ℝ) : abs (x + y) ≤ abs x + abs y := by sorry theorem lt_abs : x < abs y ↔ x < y ∨ x < -y := by sorry theorem abs_lt : abs x < y ↔ -y < x ∧ x < y := by sorry end MyAbs end example {x : ℝ} (h : x ≠ 0) : x < 0 ∨ x > 0 := by rcases lt_trichotomy x 0 with (xlt | xeq | xgt) · left exact xlt · contradiction right; exact xgt example {m n k : ℕ} (h : m ∣ n ∨ m ∣ k) : m ∣ n * k := by rcases h with (⟨a, rfl⟩ | ⟨b, rfl⟩) · rw [mul_assoc] apply dvd_mul_right rw [mul_comm, mul_assoc] apply dvd_mul_right example {z : ℝ} (h : ∃ x y, z = x ^ 2 + y ^ 2 ∨ z = x ^ 2 + y ^ 2 + 1) : z ≥ 0 := by sorry example {x : ℝ} (h : x ^ 2 = 1) : x = 1 ∨ x = -1 := by sorry example {x y : ℝ} (h : x ^ 2 = y ^ 2) : x = y ∨ x = -y := by sorry section variable {R : Type _} [CommRing R] [IsDomain R] variable (x y : R) example (h : x ^ 2 = 1) : x = 1 ∨ x = -1 := by sorry example (h : x ^ 2 = y ^ 2) : x = y ∨ x = -y := by sorry end example (P : Prop) : ¬¬P → P := by intro h cases em P · assumption contradiction example (P : Prop) : ¬¬P → P := by intro h by_cases h' : P · assumption contradiction example (P Q : Prop) : P → Q ↔ ¬P ∨ Q := by sorry
-
-
-
@@ -1,96 +0,0 @@import Mathlib.Data.Real.Basic def ConvergesTo (s : ℕ → ℝ) (a : ℝ) := ∀ ε > 0, ∃ N, ∀ n ≥ N, abs (s n - a) < ε example : (fun x y : ℝ => (x + y) ^ 2) = fun x y : ℝ => x ^ 2 + 2 * x * y + y ^ 2 := by ext ring example (a b : ℝ) : abs a = abs (a - b + b) := by congr ring example {a : ℝ} (h : 1 < a) : a < a * a := by convert(mul_lt_mul_right _).2 h · rw [one_mul] exact lt_trans zero_lt_one h theorem convergesTo_const (a : ℝ) : ConvergesTo (fun x : ℕ => a) a := by intro ε εpos use 0 intro n nge; dsimp rw [sub_self, abs_zero] apply εpos theorem convergesTo_add {s t : ℕ → ℝ} {a b : ℝ} (cs : ConvergesTo s a) (ct : ConvergesTo t b) : ConvergesTo (fun n => s n + t n) (a + b) := by intro ε εpos dsimp have ε2pos : 0 < ε / 2 := by linarith cases' cs (ε / 2) ε2pos with Ns hs cases' ct (ε / 2) ε2pos with Nt ht use max Ns Nt sorry theorem convergesTo_mul_const {s : ℕ → ℝ} {a : ℝ} (c : ℝ) (cs : ConvergesTo s a) : ConvergesTo (fun n => c * s n) (c * a) := by by_cases h : c = 0 · convert convergesTo_const 0 · rw [h, MulZeroClass.zero_mul] rw [h, MulZeroClass.zero_mul] have acpos : 0 < abs c := abs_pos.mpr h sorry theorem exists_abs_le_of_convergesTo {s : ℕ → ℝ} {a : ℝ} (cs : ConvergesTo s a) : ∃ N b, ∀ n, N ≤ n → abs (s n) < b := by cases' cs 1 zero_lt_one with N h use N, abs a + 1 sorry theorem aux {s t : ℕ → ℝ} {a : ℝ} (cs : ConvergesTo s a) (ct : ConvergesTo t 0) : ConvergesTo (fun n => s n * t n) 0 := by intro ε εpos dsimp rcases exists_abs_le_of_convergesTo cs with ⟨N₀, B, h₀⟩ have Bpos : 0 < B := lt_of_le_of_lt (abs_nonneg _) (h₀ N₀ (le_refl _)) have pos₀ : ε / B > 0 := div_pos εpos Bpos cases' ct _ pos₀ with N₁ h₁ sorry theorem convergesTo_mul {s t : ℕ → ℝ} {a b : ℝ} (cs : ConvergesTo s a) (ct : ConvergesTo t b) : ConvergesTo (fun n => s n * t n) (a * b) := by have h₁ : ConvergesTo (fun n => s n * (t n + -b)) 0 := by apply aux cs convert convergesTo_add ct (convergesTo_const (-b)) ring have := convergesTo_add h₁ (convergesTo_mul_const b cs) convert convergesTo_add h₁ (convergesTo_mul_const b cs) using 1 · ext; ring ring theorem convergesTo_unique {s : ℕ → ℝ} {a b : ℝ} (sa : ConvergesTo s a) (sb : ConvergesTo s b) : a = b := by by_contra abne have : abs (a - b) > 0 := by sorry let ε := abs (a - b) / 2 have εpos : ε > 0 := by change abs (a - b) / 2 > 0 linarith cases' sa ε εpos with Na hNa cases' sb ε εpos with Nb hNb let N := max Na Nb have absa : abs (s N - a) < ε := by sorry have absb : abs (s N - b) < ε := by sorry have : abs (a - b) < abs (a - b) := by sorry exact lt_irrefl _ this section variable {α : Type _} [LinearOrder α] def ConvergesTo' (s : α → ℝ) (a : ℝ) := ∀ ε > 0, ∃ N, ∀ n ≥ N, abs (s n - a) < ε end
-
-
-
@@ -1,131 +0,0 @@import Mathlib.Data.Real.Basic def FnUb (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, f x ≤ a def FnLb (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, a ≤ f x section variable (f g : ℝ → ℝ) (a b : ℝ) example (hfa : FnLb f a) (hgb : FnLb g b) : FnLb (fun x => f x + g x) (a + b) := by intro x apply add_le_add apply hfa apply hgb example (nnf : FnLb f 0) (nng : FnLb g 0) : FnLb (fun x => f x * g x) 0 := by intro x apply mul_nonneg apply nnf apply nng example (hfa : FnUb f a) (hfb : FnUb g b) (nng : FnLb g 0) (nna : 0 ≤ a) : FnUb (fun x => f x * g x) (a * b) := by intro x apply mul_le_mul apply hfa apply hfb apply nng apply nna end section variable (f g : ℝ → ℝ) example {c : ℝ} (mf : Monotone f) (nnc : 0 ≤ c) : Monotone fun x => c * f x := by intro a b aleb apply mul_le_mul_of_nonneg_left _ nnc apply mf aleb example {c : ℝ} (mf : Monotone f) (nnc : 0 ≤ c) : Monotone fun x => c * f x := fun a b aleb => mul_le_mul_of_nonneg_left (mf aleb) nnc example (mf : Monotone f) (mg : Monotone g) : Monotone fun x => f (g x) := by intro a b aleb apply mf apply mg apply aleb example (mf : Monotone f) (mg : Monotone g) : Monotone fun x => f (g x) := fun a b aleb => mf (mg aleb) def FnEven (f : ℝ → ℝ) : Prop := ∀ x, f x = f (-x) def FnOdd (f : ℝ → ℝ) : Prop := ∀ x, f x = -f (-x) example (of : FnOdd f) (og : FnOdd g) : FnEven fun x => f x * g x := by intro x calc (fun x => f x * g x) x = f x * g x := rfl _ = f (-x) * g (-x) := by rw [of, og, neg_mul_neg] example (ef : FnEven f) (og : FnOdd g) : FnOdd fun x => f x * g x := by intro x dsimp rw [ef, og, neg_mul_eq_mul_neg] example (ef : FnEven f) (og : FnOdd g) : FnEven fun x => f (g x) := by intro x dsimp rw [og, ← ef] end section variable {α : Type _} (r s t : Set α) example : r ⊆ s → s ⊆ t → r ⊆ t := by intro rsubs ssubt x xr apply ssubt apply rsubs apply xr theorem Subset.trans : r ⊆ s → s ⊆ t → r ⊆ t := fun rsubs ssubt x xr => ssubt (rsubs xr) end section variable {α : Type _} [PartialOrder α] variable (s : Set α) (a b : α) def SetUb (s : Set α) (a : α) := ∀ x, x ∈ s → x ≤ a example (h : SetUb s a) (h' : a ≤ b) : SetUb s b := by intro x xs apply le_trans (h x xs) h' example (h : SetUb s a) (h' : a ≤ b) : SetUb s b := fun x xs => le_trans (h x xs) h' end section open Function example {c : ℝ} (h : c ≠ 0) : Injective fun x => c * x := by intro x₁ x₂ h' apply (mul_right_inj' h).mp h' variable {α : Type _} {β : Type _} {γ : Type _} variable {g : β → γ} {f : α → β} example (injg : Injective g) (injf : Injective f) : Injective fun x => g (f x) := by intro x₁ x₂ h apply injf apply injg apply h end
-
-
-
@@ -1,85 +0,0 @@import Mathlib.Data.Real.Basic def FnUb (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, f x ≤ a def FnLb (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, a ≤ f x def FnHasUb (f : ℝ → ℝ) := ∃ a, FnUb f a def FnHasLb (f : ℝ → ℝ) := ∃ a, FnLb f a theorem fnUb_add {f g : ℝ → ℝ} {a b : ℝ} (hfa : FnUb f a) (hgb : FnUb g b) : FnUb (fun x => f x + g x) (a + b) := fun x => add_le_add (hfa x) (hgb x) section variable {f g : ℝ → ℝ} example (lbf : FnHasLb f) (lbg : FnHasLb g) : FnHasLb fun x => f x + g x := by cases' lbf with a lbfa cases' lbg with b lbgb use a + b intro x exact add_le_add (lbfa x) (lbgb x) example {c : ℝ} (ubf : FnHasUb f) (h : c ≥ 0) : FnHasUb fun x => c * f x := by cases' ubf with a lbfa use c * a intro x exact mul_le_mul_of_nonneg_left (lbfa x) h end section variable {a b c : ℕ} example (divab : a ∣ b) (divbc : b ∣ c) : a ∣ c := by rcases divab with ⟨d, rfl⟩ rcases divbc with ⟨e, rfl⟩ use d * e; ring example (divab : a ∣ b) (divac : a ∣ c) : a ∣ b + c := by rcases divab with ⟨d, rfl⟩ rcases divac with ⟨e, rfl⟩ use d + e; ring end section open Function example {c : ℝ} (h : c ≠ 0) : Surjective fun x => c * x := by intro x use x / c dsimp; rw [mul_div_cancel' _ h] example {c : ℝ} (h : c ≠ 0) : Surjective fun x => c * x := by intro x use x / c field_simp [h] ; ring end section open Function variable {α : Type _} {β : Type _} {γ : Type _} variable {g : β → γ} {f : α → β} example (surjg : Surjective g) (surjf : Surjective f) : Surjective fun x => g (f x) := by intro z rcases surjg z with ⟨y, rfl⟩ rcases surjf y with ⟨x, rfl⟩ use x end
-
-
-
@@ -1,113 +0,0 @@import Mathlib.Data.Real.Basic section variable (a b : ℝ) def FnUb (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, f x ≤ a def FnLb (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, a ≤ f x def FnHasUb (f : ℝ → ℝ) := ∃ a, FnUb f a def FnHasLb (f : ℝ → ℝ) := ∃ a, FnLb f a variable (f : ℝ → ℝ) example (h : ∀ a, ∃ x, f x < a) : ¬FnHasLb f := by rintro ⟨a, ha⟩ rcases h a with ⟨x, hx⟩ have := ha x linarith example : ¬FnHasUb fun x => x := by rintro ⟨a, ha⟩ have : a + 1 ≤ a := ha (a + 1) linarith example (h : Monotone f) (h' : f a < f b) : a < b := by apply lt_of_not_ge intro h'' apply absurd h' apply not_lt_of_ge (h h'') example (h : a ≤ b) (h' : f b < f a) : ¬Monotone f := by intro h'' apply absurd h' apply not_lt_of_ge apply h'' h example : ¬∀ {f : ℝ → ℝ}, Monotone f → ∀ {a b}, f a ≤ f b → a ≤ b := by intro h let f := fun x : ℝ => (0 : ℝ) have monof : Monotone f := by intro a b leab rfl have h' : f 1 ≤ f 0 := le_refl _ have : (1 : ℝ) ≤ 0 := h monof h' linarith example (x : ℝ) (h : ∀ ε > 0, x < ε) : x ≤ 0 := by apply le_of_not_gt intro h' linarith [h _ h'] end section variable {α : Type _} (P : α → Prop) (Q : Prop) example (h : ¬∃ x, P x) : ∀ x, ¬P x := by intro x Px apply h use x exact Px example (h : ∀ x, ¬P x) : ¬∃ x, P x := by rintro ⟨x, Px⟩ exact h x Px example (h : ∃ x, ¬P x) : ¬∀ x, P x := by intro h' rcases h with ⟨x, nPx⟩ apply nPx apply h' example (h : ¬¬Q) : Q := by by_contra h' exact h h' example (h : Q) : ¬¬Q := by intro h' exact h' h end section variable (f : ℝ → ℝ) example (h : ¬FnHasUb f) : ∀ a, ∃ x, f x > a := by intro a by_contra h' apply h use a intro x apply le_of_not_gt intro h'' apply h' use x exact h'' example (h : ¬Monotone f) : ∃ x y, x ≤ y ∧ f y < f x := by rw [Monotone] at h push_neg at h exact h end
-
-
-
@@ -1,97 +0,0 @@import Mathlib.Data.Real.Basic import Mathlib.Data.Nat.Prime import Mathlib.Tactic.NormNum example {m n : ℕ} (h : m ∣ n ∧ m ≠ n) : m ∣ n ∧ ¬n ∣ m := by cases' h with h0 h1 constructor · exact h0 intro h2 apply h1 apply Nat.dvd_antisymm h0 h2 example {x y : ℝ} : x ≤ y ∧ ¬y ≤ x ↔ x ≤ y ∧ x ≠ y := by constructor · rintro ⟨h0, h1⟩ constructor · exact h0 intro h2 apply h1 rw [h2] rintro ⟨h0, h1⟩ constructor · exact h0 intro h2 apply h1 apply le_antisymm h0 h2 theorem aux {x y : ℝ} (h : x ^ 2 + y ^ 2 = 0) : x = 0 := have h' : x ^ 2 = 0 := by linarith [pow_two_nonneg x, pow_two_nonneg y] pow_eq_zero h' example (x y : ℝ) : x ^ 2 + y ^ 2 = 0 ↔ x = 0 ∧ y = 0 := by constructor · intro h constructor · exact aux h rw [add_comm] at h exact aux h rintro ⟨rfl, rfl⟩ norm_num theorem not_monotone_iff {f : ℝ → ℝ} : ¬Monotone f ↔ ∃ x y, x ≤ y ∧ f x > f y := by rw [Monotone] push_neg rfl example : ¬Monotone fun x : ℝ => -x := by rw [not_monotone_iff] use 0, 1 norm_num section variable {α : Type _} [PartialOrder α] variable (a b : α) example : a < b ↔ a ≤ b ∧ a ≠ b := by rw [lt_iff_le_not_le] constructor · rintro ⟨h0, h1⟩ constructor · exact h0 intro h2 apply h1 rw [h2] rintro ⟨h0, h1⟩ constructor · exact h0 intro h2 apply h1 apply le_antisymm h0 h2 end section variable {α : Type _} [Preorder α] variable (a b c : α) example : ¬a < a := by rw [lt_iff_le_not_le] rintro ⟨h0, h1⟩ exact h1 h0 example : a < b → b < c → a < c := by simp only [lt_iff_le_not_le] rintro ⟨h0, h1⟩ ⟨h2, h3⟩ constructor · apply le_trans h0 h2 intro h4 apply h1 apply le_trans h2 h4 end
-
-
-
@@ -1,142 +0,0 @@import Mathlib.Data.Real.Basic section variable {x y : ℝ} namespace MyAbs theorem le_abs_self (x : ℝ) : x ≤ abs x := by cases' le_or_gt 0 x with h h · rw [abs_of_nonneg h] rw [abs_of_neg h] linarith theorem neg_le_abs_self (x : ℝ) : -x ≤ abs x := by cases' le_or_gt 0 x with h h · rw [abs_of_nonneg h] linarith rw [abs_of_neg h] theorem abs_add (x y : ℝ) : abs (x + y) ≤ abs x + abs y := by cases' le_or_gt 0 (x + y) with h h · rw [abs_of_nonneg h] linarith [le_abs_self x, le_abs_self y] rw [abs_of_neg h] linarith [neg_le_abs_self x, neg_le_abs_self y] theorem lt_abs : x < abs y ↔ x < y ∨ x < -y := by cases' le_or_gt 0 y with h h · rw [abs_of_nonneg h] constructor · intro h' left exact h' intro h' cases' h' with h' h' · exact h' linarith rw [abs_of_neg h] constructor · intro h' right exact h' intro h' cases' h' with h' h' · linarith exact h' theorem abs_lt : abs x < y ↔ -y < x ∧ x < y := by cases' le_or_gt 0 x with h h · rw [abs_of_nonneg h] constructor · intro h' constructor · linarith exact h' intro h' cases' h' with h1 h2 exact h2 rw [abs_of_neg h] constructor · intro h' constructor · linarith linarith intro h' linarith end MyAbs end example {z : ℝ} (h : ∃ x y, z = x ^ 2 + y ^ 2 ∨ z = x ^ 2 + y ^ 2 + 1) : z ≥ 0 := by rcases h with ⟨x, y, rfl | rfl⟩ <;> linarith [sq_nonneg x, sq_nonneg y] example {x : ℝ} (h : x ^ 2 = 1) : x = 1 ∨ x = -1 := by have h' : x ^ 2 - 1 = 0 := by rw [h, sub_self] have h'' : (x + 1) * (x - 1) = 0 := by rw [← h'] ring cases' eq_zero_or_eq_zero_of_mul_eq_zero h'' with h1 h1 · right exact eq_neg_iff_add_eq_zero.mpr h1 left exact eq_of_sub_eq_zero h1 example {x y : ℝ} (h : x ^ 2 = y ^ 2) : x = y ∨ x = -y := by have h' : x ^ 2 - y ^ 2 = 0 := by rw [h, sub_self] have h'' : (x + y) * (x - y) = 0 := by rw [← h'] ring cases' eq_zero_or_eq_zero_of_mul_eq_zero h'' with h1 h1 · right exact eq_neg_iff_add_eq_zero.mpr h1 left exact eq_of_sub_eq_zero h1 section variable {R : Type _} [CommRing R] [IsDomain R] variable (x y : R) example (h : x ^ 2 = 1) : x = 1 ∨ x = -1 := by have h' : x ^ 2 - 1 = 0 := by rw [h, sub_self] have h'' : (x + 1) * (x - 1) = 0 := by rw [← h'] ring cases' eq_zero_or_eq_zero_of_mul_eq_zero h'' with h1 h1 · right exact eq_neg_iff_add_eq_zero.mpr h1 left exact eq_of_sub_eq_zero h1 example (h : x ^ 2 = y ^ 2) : x = y ∨ x = -y := by have h' : x ^ 2 - y ^ 2 = 0 := by rw [h, sub_self] have h'' : (x + y) * (x - y) = 0 := by rw [← h'] ring cases' eq_zero_or_eq_zero_of_mul_eq_zero h'' with h1 h1 · right exact eq_neg_iff_add_eq_zero.mpr h1 left exact eq_of_sub_eq_zero h1 end example (P Q : Prop) : P → Q ↔ ¬P ∨ Q := by constructor · intro h by_cases h' : P · right exact h h' left exact h' rintro (h | h) · intro h' exact absurd h' h intro exact h
-
-
-
@@ -1,126 +0,0 @@import Mathlib.Data.Real.Basic def ConvergesTo (s : ℕ → ℝ) (a : ℝ) := ∀ ε > 0, ∃ N, ∀ n ≥ N, abs (s n - a) < ε theorem convergesTo_const (a : ℝ) : ConvergesTo (fun x : ℕ => a) a := by intro ε εpos use 0 intro n nge; dsimp rw [sub_self, abs_zero] apply εpos theorem convergesTo_add {s t : ℕ → ℝ} {a b : ℝ} (cs : ConvergesTo s a) (ct : ConvergesTo t b) : ConvergesTo (fun n => s n + t n) (a + b) := by intro ε εpos dsimp have ε2pos : 0 < ε / 2 := by linarith cases' cs (ε / 2) ε2pos with Ns hs cases' ct (ε / 2) ε2pos with Nt ht use max Ns Nt intro n hn have ngeNs : n ≥ Ns := le_of_max_le_left hn have ngeNt : n ≥ Nt := le_of_max_le_right hn calc |s n + t n - (a + b)| = |s n - a + (t n - b)| := by congr ring _ ≤ |s n - a| + |t n - b| := (abs_add _ _) _ < ε / 2 + ε / 2 := (add_lt_add (hs n ngeNs) (ht n ngeNt)) _ = ε := by norm_num theorem convergesTo_mul_const {s : ℕ → ℝ} {a : ℝ} (c : ℝ) (cs : ConvergesTo s a) : ConvergesTo (fun n => c * s n) (c * a) := by by_cases h : c = 0 · convert convergesTo_const 0 · rw [h, MulZeroClass.zero_mul] rw [h, MulZeroClass.zero_mul] have acpos : 0 < abs c := abs_pos.mpr h intro ε εpos dsimp have εcpos : 0 < ε / abs c := by apply div_pos εpos acpos cases' cs (ε / abs c) εcpos with Ns hs use Ns intro n ngt calc |c * s n - c * a| = |c| * |s n - a| := by rw [← abs_mul, mul_sub] _ < |c| * (ε / |c|) := (mul_lt_mul_of_pos_left (hs n ngt) acpos) _ = ε := mul_div_cancel' _ (ne_of_lt acpos).symm theorem exists_abs_le_of_converges_to {s : ℕ → ℝ} {a : ℝ} (cs : ConvergesTo s a) : ∃ N b, ∀ n, N ≤ n → abs (s n) < b := by cases' cs 1 zero_lt_one with N h use N, abs a + 1 intro n ngt calc |s n| = |s n - a + a| := by congr abel _ ≤ |s n - a| + |a| := (abs_add _ _) _ < |a| + 1 := by linarith [h n ngt] theorem aux {s t : ℕ → ℝ} {a : ℝ} (cs : ConvergesTo s a) (ct : ConvergesTo t 0) : ConvergesTo (fun n => s n * t n) 0 := by intro ε εpos dsimp rcases exists_abs_le_of_convergesTo cs with ⟨N₀, B, h₀⟩ have Bpos : 0 < B := lt_of_le_of_lt (abs_nonneg _) (h₀ N₀ (le_refl _)) have pos₀ : ε / B > 0 := div_pos εpos Bpos cases' ct _ pos₀ with N₁ h₁ use max N₀ N₁ intro n ngt have ngeN₀ : n ≥ N₀ := le_of_max_le_left ngt have ngeN₁ : n ≥ N₁ := le_of_max_le_right ngt calc |s n * t n - 0| = |s n| * |t n - 0| := by rw [sub_zero, abs_mul, sub_zero] _ < B * (ε / B) := (mul_lt_mul'' (h₀ n ngeN₀) (h₁ n ngeN₁) (abs_nonneg _) (abs_nonneg _)) _ = ε := mul_div_cancel' _ (ne_of_lt Bpos).symm theorem convergesTo_mul {s t : ℕ → ℝ} {a b : ℝ} (cs : ConvergesTo s a) (ct : ConvergesTo t b) : ConvergesTo (fun n => s n * t n) (a * b) := by have h₁ : ConvergesTo (fun n => s n * (t n + -b)) 0 := by apply aux cs convert convergesTo_add ct (convergesTo_const (-b)) ring have := convergesTo_add h₁ (convergesTo_mul_const b cs) convert convergesTo_add h₁ (convergesTo_mul_const b cs) using 1 · ext; ring ring theorem convergesTo_unique {s : ℕ → ℝ} {a b : ℝ} (sa : ConvergesTo s a) (sb : ConvergesTo s b) : a = b := by by_contra abne have : abs (a - b) > 0 := by apply lt_of_le_of_ne · apply abs_nonneg intro h'' apply abne apply eq_of_abs_sub_eq_zero h''.symm let ε := abs (a - b) / 2 have εpos : ε > 0 := by change abs (a - b) / 2 > 0 linarith cases' sa ε εpos with Na hNa cases' sb ε εpos with Nb hNb let N := max Na Nb have absa : abs (s N - a) < ε := by apply hNa apply le_max_left have absb : abs (s N - b) < ε := by apply hNb apply le_max_right have : abs (a - b) < abs (a - b) calc abs (a - b) = abs (-(s N - a) + (s N - b)) := by congr ring _ ≤ abs (-(s N - a)) + abs (s N - b) := (abs_add _ _) _ = abs (s N - a) + abs (s N - b) := by rw [abs_neg] _ < ε + ε := (add_lt_add absa absb) _ = abs (a - b) := by norm_num exact lt_irrefl _ this
-
-
-
@@ -1,118 +0,0 @@import Mathlib.Data.Nat.Factorization.Basic import Mathlib.Data.Nat.Prime import Mathlib.Tactic.NormNum.GCD import Mathlib.Tactic.NormNum.Prime #print Nat.coprime example (m n : Nat) (h : m.coprime n) : m.gcd n = 1 := h example (m n : Nat) (h : m.coprime n) : m.gcd n = 1 := by rw [Nat.coprime] at h exact h example : Nat.coprime 12 7 := by norm_num example : Nat.gcd 12 8 = 4 := by norm_num #check @Nat.prime_def_lt example (p : ℕ) (prime_p : Nat.Prime p) : 2 ≤ p ∧ ∀ m : ℕ, m < p → m ∣ p → m = 1 := by rwa [Nat.prime_def_lt] at prime_p #check Nat.Prime.eq_one_or_self_of_dvd example (p : ℕ) (prime_p : Nat.Prime p) : ∀ m : ℕ, m ∣ p → m = 1 ∨ m = p := prime_p.eq_one_or_self_of_dvd example : Nat.Prime 17 := by norm_num -- commonly used example : Nat.Prime 2 := Nat.prime_two example : Nat.Prime 3 := Nat.prime_three #check @Nat.Prime.dvd_mul #check Nat.Prime.dvd_mul Nat.prime_two #check Nat.prime_two.dvd_mul theorem even_of_even_sqr {m : ℕ} (h : 2 ∣ m ^ 2) : 2 ∣ m := by rw [pow_two, Nat.prime_two.dvd_mul] at h cases h <;> assumption example {m : ℕ} (h : 2 ∣ m ^ 2) : 2 ∣ m := Nat.Prime.dvd_of_dvd_pow Nat.prime_two h example (a b c : Nat) (h : a * b = a * c) (h' : a ≠ 0) : b = c := -- library_search suggests the following: (mul_right_inj' h').mp h example {m n : ℕ} (coprime_mn : m.coprime n) : m ^ 2 ≠ 2 * n ^ 2 := by intro sqr_eq have : 2 ∣ m := by sorry, obtain ⟨k, meq⟩ := dvd_iff_exists_eq_mul_left.mp this have : 2 * (2 * k ^ 2) = 2 * n ^ 2 := by rw [← sqr_eq, meq] ring have : 2 * k ^ 2 = n ^ 2 := sorry, have : 2 ∣ n := by sorry, have : 2 ∣ m.gcd n := by sorry, have : 2 ∣ 1 := by sorry, norm_num at this example {m n p : ℕ} (coprime_mn : m.coprime n) (prime_p : p.Prime) : m ^ 2 ≠ p * n ^ 2 := by sorry #check Nat.factors #check Nat.prime_of_mem_factors #check Nat.prod_factors #check Nat.factors_unique theorem factorization_mul' {m n : ℕ} (mnez : m ≠ 0) (nnez : n ≠ 0) (p : ℕ) : (m * n).factorization p = m.factorization p + n.factorization p := by rw [Nat.factorization_mul mnez nnez] rfl theorem factorization_pow' (n k p : ℕ) : (n ^ k).factorization p = k * n.factorization p := by rw [Nat.factorization_pow] rfl theorem Nat.Prime.factorization' {p : ℕ} (prime_p : p.Prime) : p.factorization p = 1 := by rw [prime_p.factorization] simp example {m n p : ℕ} (nnz : n ≠ 0) (prime_p : p.Prime) : m ^ 2 ≠ p * n ^ 2 := by intro sqr_eq have nsqr_nez : n ^ 2 ≠ 0 := by simpa have eq1 : Nat.factorization (m ^ 2) p = 2 * m.factorization p := by sorry, have eq2 : (p * n ^ 2).factorization p = 2 * n.factorization p + 1 := by sorry, have : 2 * m.factorization p % 2 = (2 * n.factorization p + 1) % 2 := by rw [← eq1, sqr_eq, eq2] rw [add_comm, Nat.add_mul_mod_self_left, Nat.mul_mod_right] at this norm_num at this example {m n k r : ℕ} (nnz : n ≠ 0) (pow_eq : m ^ k = r * n ^ k) {p : ℕ} (prime_p : p.Prime) : k ∣ r.factorization p := by cases' r with r · simp have npow_nz : n ^ k ≠ 0 := fun npowz => nnz (pow_eq_zero npowz) have eq1 : (m ^ k).factorization p = k * m.factorization p := by sorry, have eq2 : (r.succ * n ^ k).factorization p = k * n.factorization p + r.succ.factorization p := by sorry, have : r.succ.factorization p = k * m.factorization p - k * n.factorization p := by rw [← eq1, pow_eq, eq2, add_comm, Nat.add_sub_cancel] rw [this] sorry #check multiplicity
-
-
-
@@ -1,148 +0,0 @@import Mathlib.Data.Nat.GCD.Basic import Mathlib.Algebra.BigOperators.Basic import Mathlib.Tactic example (n : Nat) : n.succ ≠ Nat.zero := Nat.succ_ne_zero n example (m n : Nat) (h : m.succ = n.succ) : m = n := Nat.succ.inj h def fac : ℕ → ℕ | 0 => 1 | n + 1 => (n + 1) * fac n example : fac 0 = 1 := rfl example : fac 0 = 1 := by rw [fac] example : fac 0 = 1 := by simp [fac] example (n : ℕ) : fac (n + 1) = (n + 1) * fac n := rfl example (n : ℕ) : fac (n + 1) = (n + 1) * fac n := by rw [fac] example (n : ℕ) : fac (n + 1) = (n + 1) * fac n := by simp [fac] theorem fac_pos (n : ℕ) : 0 < fac n := by induction' n with n ih · rw [fac] exact zero_lt_one rw [fac] exact mul_pos n.succ_pos ih theorem dvd_fac {i n : ℕ} (ipos : 0 < i) (ile : i ≤ n) : i ∣ fac n := by induction' n with n ih · exact absurd ipos (not_lt_of_ge ile) rw [fac] cases' Nat.of_le_succ ile with h h · apply dvd_mul_of_dvd_right (ih h) rw [h] apply dvd_mul_right theorem pow_two_le_fac (n : ℕ) : 2 ^ (n - 1) ≤ fac n := by cases' n with n · simp [fac] sorry section variable {α : Type _} (s : Finset ℕ) (f : ℕ → ℕ) (n : ℕ) #check Finset.sum s f #check Finset.prod s f open BigOperators open Finset example : s.sum f = ∑ x in s, f x := rfl example : s.prod f = ∏ x in s, f x := rfl example : (range n).sum f = ∑ x in range n, f x := rfl example : (range n).prod f = ∏ x in range n, f x := rfl example (f : ℕ → ℕ) : (∑ x in range 0, f x) = 0 := Finset.sum_range_zero f example (f : ℕ → ℕ) (n : ℕ) : (∑ x in range n.succ, f x) = (∑ x in range n, f x) + f n := Finset.sum_range_succ f n example (f : ℕ → ℕ) : (∏ x in range 0, f x) = 1 := Finset.prod_range_zero f example (f : ℕ → ℕ) (n : ℕ) : (∏ x in range n.succ, f x) = (∏ x in range n, f x) * f n := Finset.prod_range_succ f n example (n : ℕ) : fac n = ∏ i in range n, (i + 1) := by induction' n with n ih · rw [fac, prod_range_zero] rw [fac, ih, prod_range_succ, mul_comm] example (a b c d e f : ℕ) : a * (b * c * f * (d * e)) = d * (a * f * e) * (c * b) := by simp [mul_assoc, mul_comm, mul_left_comm] theorem sum_id (n : ℕ) : (∑ i in range (n + 1), i) = n * (n + 1) / 2 := by symm; apply Nat.div_eq_of_eq_mul_right (by norm_num : 0 < 2) induction' n with n ih · simp rw [Finset.sum_range_succ, mul_add 2, ← ih, Nat.succ_eq_add_one] ring theorem sum_sqr (n : ℕ) : (∑ i in range (n + 1), i ^ 2) = n * (n + 1) * (2 * n + 1) / 6 := by sorry end inductive MyNat | zero : MyNat | succ : MyNat → MyNat namespace MyNat def add : MyNat → MyNat → MyNat | x, zero => x | x, succ y => succ (add x y) def mul : MyNat → MyNat → MyNat | x, zero => zero | x, succ y => add (mul x y) x theorem zero_add (n : MyNat) : add zero n = n := by induction' n with n ih · rfl rw [add, ih] theorem succ_add (m n : MyNat) : add (succ m) n = succ (add m n) := by induction' n with n ih · rfl rw [add, ih] rfl theorem add_comm (m n : MyNat) : add m n = add n m := by induction' n with n ih · rw [zero_add] rfl rw [add, succ_add, ih] theorem add_assoc (m n k : MyNat) : add (add m n) k = add m (add n k) := by sorry theorem mul_add (m n k : MyNat) : mul m (add n k) = add (mul m n) (mul m k) := by sorry theorem zero_mul (n : MyNat) : mul zero n = zero := by sorry theorem succ_mul (m n : MyNat) : mul (succ m) n = add (mul m n) n := by sorry theorem mul_comm (m n : MyNat) : mul m n = mul n m := by sorry end MyNat
-
-
-
@@ -1,231 +0,0 @@import Mathlib.Data.Nat.Prime import Mathlib.Algebra.BigOperators.Order import Mathlib.Tactic import Mathlib.Tactic.IntervalCases open BigOperators theorem two_le {m : ℕ} (h0 : m ≠ 0) (h1 : m ≠ 1) : 2 ≤ m := by cases m; contradiction case succ m => cases m; contradiction repeat' apply Nat.succ_le_succ apply zero_le example {m : ℕ} (h0 : m ≠ 0) (h1 : m ≠ 1) : 2 ≤ m := by by_contra h push_neg at h interval_cases m <;> contradiction example {m : ℕ} (h0 : m ≠ 0) (h1 : m ≠ 1) : 2 ≤ m := by by_contra h push_neg at h revert h0 h1 revert h m decide theorem exists_prime_factor {n : Nat} (h : 2 ≤ n) : ∃ p : Nat, p.Prime ∧ p ∣ n := by by_cases np : n.Prime · use n, np induction' n using Nat.strong_induction_on with n ih dsimp at ih rw [Nat.prime_def_lt] at np push_neg at np rcases np h with ⟨m, mltn, mdvdn, mne1⟩ have : m ≠ 0 := by intro mz rw [mz, zero_dvd_iff] at mdvdn linarith have mgt2 : 2 ≤ m := two_le this mne1 by_cases mp : m.Prime · use m, mp exact mdvdn . rcases ih m mltn mgt2 mp with ⟨p, pp, pdvd⟩ use p, pp apply pdvd.trans mdvdn theorem primes_infinite : ∀ n, ∃ p > n, Nat.Prime p := by intro n have : 2 ≤ Nat.factorial (n + 1) + 1 := by sorry, rcases exists_prime_factor this with ⟨p, pp, pdvd⟩ refine' ⟨p, _, pp⟩ show p > n by_contra ple push_neg at ple have : p ∣ Nat.factorial (n + 1) := by sorry, have : p ∣ 1 := by sorry, show False sorry open Finset section variable {α : Type _} [DecidableEq α] (r s t : Finset α) example : r ∩ (s ∪ t) ⊆ r ∩ s ∪ r ∩ t := by rw [subset_iff] intro x rw [mem_inter, mem_union, mem_union, mem_inter, mem_inter] tauto example : r ∩ (s ∪ t) ⊆ r ∩ s ∪ r ∩ t := by simp [subset_iff] intro x tauto example : r ∩ s ∪ r ∩ t ⊆ r ∩ (s ∪ t) := by simp [subset_iff] intro x tauto example : r ∩ s ∪ r ∩ t = r ∩ (s ∪ t) := by ext x simp tauto end section variable {α : Type _} [DecidableEq α] (r s t : Finset α) example : (r ∪ s) ∩ (r ∪ t) = r ∪ s ∩ t := by sorry example : (r \ s) \ t = r \ (s ∪ t) := by sorry end example (s : Finset ℕ) (n : ℕ) (h : n ∈ s) : n ∣ ∏ i in s, i := Finset.dvd_prod_of_mem _ h theorem Nat.Prime.eq_of_dvd_of_prime {p q : ℕ} (prime_p : Nat.Prime p) (prime_q : Nat.Prime q) (h : p ∣ q) : p = q := by sorry theorem mem_of_dvd_prod_primes {s : Finset ℕ} {p : ℕ} (prime_p : p.Prime) : (∀ n ∈ s, Nat.Prime n) → (p ∣ ∏ n in s, n) → p ∈ s := by intro h₀ h₁ induction' s using Finset.induction_on with a s ans ih · simp at h₁ linarith [prime_p.two_le] simp [Finset.prod_insert ans, prime_p.dvd_mul] at h₀ h₁ rw [mem_insert] sorry example (s : Finset ℕ) (x : ℕ) : x ∈ s.filter Nat.Prime ↔ x ∈ s ∧ x.Prime := mem_filter theorem primes_infinite' : ∀ s : Finset Nat, ∃ p, Nat.Prime p ∧ p ∉ s := by intro s by_contra h push_neg at h set s' := s.filter Nat.Prime with s'_def have mem_s' : ∀ {n : ℕ}, n ∈ s' ↔ n.Prime := by intro n simp [s'_def] apply h have : 2 ≤ (∏ i in s', i) + 1 := by sorry, rcases exists_prime_factor this with ⟨p, pp, pdvd⟩ have : p ∣ ∏ i in s', i := by sorry, have : p ∣ 1 := by convert Nat.dvd_sub' pdvd this simp show False sorry theorem bounded_of_ex_finset (Q : ℕ → Prop) : (∃ s : Finset ℕ, ∀ k, Q k → k ∈ s) → ∃ n, ∀ k, Q k → k < n := by rintro ⟨s, hs⟩ use s.sup id + 1 intro k Qk apply Nat.lt_succ_of_le show id k ≤ s.sup id apply le_sup (hs k Qk) theorem ex_finset_of_bounded (Q : ℕ → Prop) [DecidablePred Q] : (∃ n, ∀ k, Q k → k ≤ n) → ∃ s : Finset ℕ, ∀ k, Q k ↔ k ∈ s := by rintro ⟨n, hn⟩ use (range (n + 1)).filter Q intro k simp [Nat.lt_succ_iff] exact hn k example : 27 % 4 = 3 := by norm_num example (n : ℕ) : (4 * n + 3) % 4 = 3 := by rw [add_comm, Nat.add_mul_mod_self_left] norm_num theorem mod_4_eq_3_or_mod_4_eq_3 {m n : ℕ} (h : m * n % 4 = 3) : m % 4 = 3 ∨ n % 4 = 3 := by revert h rw [Nat.mul_mod] have : m % 4 < 4 := Nat.mod_lt m (by norm_num) interval_cases hm : m % 4 <;> simp [hm] have : n % 4 < 4 := Nat.mod_lt n (by norm_num) interval_cases hn : n % 4 <;> simp [hn] theorem two_le_of_mod_4_eq_3 {n : ℕ} (h : n % 4 = 3) : 2 ≤ n := by apply two_le <;> · intro neq rw [neq] at h norm_num at h theorem aux {m n : ℕ} (h₀ : m ∣ n) (h₁ : 2 ≤ m) (h₂ : m < n) : n / m ∣ n ∧ n / m < n := by sorry theorem exists_prime_factor_mod_4_eq_3 {n : Nat} (h : n % 4 = 3) : ∃ p : Nat, p.Prime ∧ p ∣ n ∧ p % 4 = 3 := by by_cases np : n.Prime · use n exact ⟨np, dvd_rfl, h⟩ induction' n using Nat.strong_induction_on with n ih dsimp at ih rw [Nat.prime_def_lt] at np push_neg at np rcases np (two_le_of_mod_4_eq_3 h) with ⟨m, mltn, mdvdn, mne1⟩ have mge2 : 2 ≤ m := by apply two_le _ mne1 intro mz rw [mz, zero_dvd_iff] at mdvdn linarith have neq : m * (n / m) = n := Nat.mul_div_cancel' mdvdn have : m % 4 = 3 ∨ n / m % 4 = 3 := by apply mod_4_eq_3_or_mod_4_eq_3 rw [neq, h] cases' this with h1 h1 . sorry sorry example (m n : ℕ) (s : Finset ℕ) (h : m ∈ erase s n) : m ≠ n ∧ m ∈ s := by rwa [mem_erase] at h example (m n : ℕ) (s : Finset ℕ) (h : m ∈ erase s n) : m ≠ n ∧ m ∈ s := by simp at h assumption theorem primes_mod_4_eq_3_infinite : ∀ n, ∃ p > n, Nat.Prime p ∧ p % 4 = 3 := by by_contra h push_neg at h cases' h with n hn have : ∃ s : Finset Nat, ∀ p : ℕ, p.Prime ∧ p % 4 = 3 ↔ p ∈ s := by apply ex_finset_of_bounded use n contrapose! hn rcases hn with ⟨p, ⟨pp, p4⟩, pltn⟩ exact ⟨p, pltn, pp, p4⟩ cases' this with s hs have h₁ : ((4 * ∏ i in erase s 3, i) + 3) % 4 = 3 := by sorry, rcases exists_prime_factor_mod_4_eq_3 h₁ with ⟨p, pp, pdvd, p4eq⟩ have ps : p ∈ s := by sorry, have pne3 : p ≠ 3 := by sorry, have : p ∣ 4 * ∏ i in erase s 3, i := by sorry, have : p ∣ 3 := by sorry, have : p = 3 := by sorry, contradiction
-
-
-
@@ -1,101 +0,0 @@import Mathlib.Data.Nat.Factorization.Basic import Mathlib.Data.Nat.Prime import Mathlib.Tactic.NormNum.GCD import Mathlib.Tactic.NormNum.Prime theorem even_of_even_sqr {m : ℕ} (h : 2 ∣ m ^ 2) : 2 ∣ m := by rw [pow_two, Nat.prime_two.dvd_mul] at h cases h <;> assumption example {m n : ℕ} (coprime_mn : m.coprime n) : m ^ 2 ≠ 2 * n ^ 2 := by intro sqr_eq have : 2 ∣ m := by apply even_of_even_sqr rw [sqr_eq] apply dvd_mul_right obtain ⟨k, meq⟩ := dvd_iff_exists_eq_mul_left.mp this have : 2 * (2 * k ^ 2) = 2 * n ^ 2 := by rw [← sqr_eq, meq] ring have : 2 * k ^ 2 = n ^ 2 := (mul_right_inj' (by norm_num)).mp this have : 2 ∣ n := by apply even_of_even_sqr rw [← this] apply dvd_mul_right have : 2 ∣ m.gcd n := by apply Nat.dvd_gcd <;> assumption have : 2 ∣ 1 := by convert this symm exact coprime_mn norm_num at this example {m n p : ℕ} (coprime_mn : m.coprime n) (prime_p : p.Prime) : m ^ 2 ≠ p * n ^ 2 := by intro sqr_eq have : p ∣ m := by apply prime_p.dvd_of_dvd_pow rw [sqr_eq] apply dvd_mul_right obtain ⟨k, meq⟩ := dvd_iff_exists_eq_mul_left.mp this have : p * (p * k ^ 2) = p * n ^ 2 := by rw [← sqr_eq, meq] ring have : p * k ^ 2 = n ^ 2 := by apply (mul_right_inj' _).mp this exact prime_p.ne_zero have : p ∣ n := by apply prime_p.dvd_of_dvd_pow rw [← this] apply dvd_mul_right have : p ∣ Nat.gcd m n := by apply Nat.dvd_gcd <;> assumption have : p ∣ 1 := by convert this symm exact coprime_mn have : 2 ≤ 1 := by apply prime_p.two_le.trans exact Nat.le_of_dvd zero_lt_one this norm_num at this theorem factorization_mul' {m n : ℕ} (mnez : m ≠ 0) (nnez : n ≠ 0) (p : ℕ) : (m * n).factorization p = m.factorization p + n.factorization p := by rw [Nat.factorization_mul mnez nnez] rfl theorem factorization_pow' (n k p : ℕ) : (n ^ k).factorization p = k * n.factorization p := by rw [Nat.factorization_pow] rfl theorem Nat.Prime.factorization' {p : ℕ} (prime_p : p.Prime) : p.factorization p = 1 := by rw [prime_p.factorization] simp example {m n p : ℕ} (nnz : n ≠ 0) (prime_p : p.Prime) : m ^ 2 ≠ p * n ^ 2 := by intro sqr_eq have nsqr_nez : n ^ 2 ≠ 0 := by simpa have eq1 : Nat.factorization (m ^ 2) p = 2 * m.factorization p := by rw [factorization_pow'] have eq2 : (p * n ^ 2).factorization p = 2 * n.factorization p + 1 := by rw [factorization_mul' prime_p.ne_zero nsqr_nez, prime_p.factorization', factorization_pow', add_comm] have : 2 * m.factorization p % 2 = (2 * n.factorization p + 1) % 2 := by rw [← eq1, sqr_eq, eq2] rw [add_comm, Nat.add_mul_mod_self_left, Nat.mul_mod_right] at this norm_num at this example {m n k r : ℕ} (nnz : n ≠ 0) (pow_eq : m ^ k = r * n ^ k) {p : ℕ} (prime_p : p.Prime) : k ∣ r.factorization p := by cases' r with r · simp have npow_nz : n ^ k ≠ 0 := fun npowz => nnz (pow_eq_zero npowz) have eq1 : (m ^ k).factorization p = k * m.factorization p := by rw [factorization_pow'] have eq2 : (r.succ * n ^ k).factorization p = k * n.factorization p + r.succ.factorization p := by rw [factorization_mul' r.succ_ne_zero npow_nz, factorization_pow', add_comm] have : r.succ.factorization p = k * m.factorization p - k * n.factorization p := by rw [← eq1, pow_eq, eq2, add_comm, Nat.add_sub_cancel] rw [this] apply Nat.dvd_sub' <;> apply Nat.dvd_mul_right
-
-
-
@@ -1,98 +0,0 @@import Mathlib.Data.Nat.GCD.Basic import Mathlib.Algebra.BigOperators.Basic import Mathlib.Tactic def fac : ℕ → ℕ | 0 => 1 | n + 1 => (n + 1) * fac n theorem pow_two_le_fac (n : ℕ) : 2 ^ (n - 1) ≤ fac n := by cases' n with n · simp [fac] induction' n with n ih · simp [fac] simp at * rw [pow_succ, fac] apply Nat.mul_le_mul _ ih repeat' apply Nat.succ_le_succ apply zero_le section variable {α : Type _} (s : Finset ℕ) (f : ℕ → ℕ) (n : ℕ) open BigOperators open Finset theorem sum_sqr (n : ℕ) : (∑ i in range (n + 1), i ^ 2) = n * (n + 1) * (2 * n + 1) / 6 := by symm; apply Nat.div_eq_of_eq_mul_right (by norm_num : 0 < 6) induction' n with n ih · simp rw [Finset.sum_range_succ, mul_add 6, ← ih, Nat.succ_eq_add_one] ring end inductive MyNat | zero : MyNat | succ : MyNat → MyNat namespace MyNat def add : MyNat → MyNat → MyNat | x, zero => x | x, succ y => succ (add x y) def mul : MyNat → MyNat → MyNat | x, zero => zero | x, succ y => add (mul x y) x theorem zero_add (n : MyNat) : add zero n = n := by induction' n with n ih · rfl rw [add, ih] theorem succ_add (m n : MyNat) : add (succ m) n = succ (add m n) := by induction' n with n ih · rfl rw [add, ih] rfl theorem add_comm (m n : MyNat) : add m n = add n m := by induction' n with n ih · rw [zero_add] rfl rw [add, succ_add, ih] theorem add_assoc (m n k : MyNat) : add (add m n) k = add m (add n k) := by induction' k with k ih · rfl rw [add, ih] rfl theorem mul_add (m n k : MyNat) : mul m (add n k) = add (mul m n) (mul m k) := by induction' k with k ih · rfl rw [add, mul, mul, ih, add_assoc] theorem zero_mul (n : MyNat) : mul zero n = zero := by induction' n with n ih · rfl rw [mul, ih] rfl theorem succ_mul (m n : MyNat) : mul (succ m) n = add (mul m n) n := by induction' n with n ih · rfl rw [mul, mul, ih, add_assoc, add_assoc, add_comm n, succ_add] rfl theorem mul_comm (m n : MyNat) : mul m n = mul n m := by induction' n with n ih · rw [zero_mul] rfl rw [mul, ih, succ_mul] end MyNat
-
-
-
@@ -1,241 +0,0 @@import Mathlib.Data.Nat.Prime import Mathlib.Algebra.BigOperators.Order import Mathlib.Tactic import Mathlib.Tactic.IntervalCases open BigOperators theorem two_le {m : ℕ} (h0 : m ≠ 0) (h1 : m ≠ 1) : 2 ≤ m := by cases m; contradiction case succ m => cases m; contradiction repeat' apply Nat.succ_le_succ apply zero_le theorem exists_prime_factor {n : Nat} (h : 2 ≤ n) : ∃ p : Nat, p.Prime ∧ p ∣ n := by by_cases np : n.Prime · use n, np induction' n using Nat.strong_induction_on with n ih dsimp at ih rw [Nat.prime_def_lt] at np push_neg at np rcases np h with ⟨m, mltn, mdvdn, mne1⟩ have : m ≠ 0 := by intro mz rw [mz, zero_dvd_iff] at mdvdn linarith have mgt2 : 2 ≤ m := two_le this mne1 by_cases mp : m.Prime · use m, mp exact mdvdn . rcases ih m mltn mgt2 mp with ⟨p, pp, pdvd⟩ use p, pp apply pdvd.trans mdvdn theorem primes_infinite : ∀ n, ∃ p > n, Nat.Prime p := by intro n have : 2 ≤ Nat.factorial (n + 1) + 1 := by apply Nat.succ_le_succ exact Nat.succ_le_of_lt (Nat.factorial_pos _) rcases exists_prime_factor this with ⟨p, pp, pdvd⟩ refine' ⟨p, _, pp⟩ show p > n by_contra ple push_neg at ple have : p ∣ Nat.factorial (n + 1) := by apply Nat.dvd_factorial apply pp.pos linarith have : p ∣ 1 := by convert Nat.dvd_sub' pdvd this simp show False have := Nat.le_of_dvd zero_lt_one this linarith [pp.two_le] open Finset section variable {α : Type _} [DecidableEq α] (r s t : Finset α) example : (r ∪ s) ∩ (r ∪ t) = r ∪ s ∩ t := by ext x rw [mem_inter, mem_union, mem_union, mem_union, mem_inter] tauto example : (r ∪ s) ∩ (r ∪ t) = r ∪ s ∩ t := by ext x simp tauto example : (r \ s) \ t = r \ (s ∪ t) := by ext x rw [mem_sdiff, mem_sdiff, mem_sdiff, mem_union] tauto example : (r \ s) \ t = r \ (s ∪ t) := by ext x simp tauto end theorem Nat.Prime.eq_of_dvd_of_prime {p q : ℕ} (prime_p : Nat.Prime p) (prime_q : Nat.Prime q) (h : p ∣ q) : p = q := by cases prime_q.eq_one_or_self_of_dvd _ h · linarith [prime_p.two_le] assumption theorem mem_of_dvd_prod_primes {s : Finset ℕ} {p : ℕ} (prime_p : p.Prime) : (∀ n ∈ s, Nat.Prime n) → (p ∣ ∏ n in s, n) → p ∈ s := by intro h₀ h₁ induction' s using Finset.induction_on with a s ans ih · simp at h₁ linarith [prime_p.two_le] simp [Finset.prod_insert ans, prime_p.dvd_mul] at h₀ h₁ rw [mem_insert] cases' h₁ with h₁ h₁ · left exact prime_p.eq_of_dvd_of_prime h₀.1 h₁ right exact ih h₀.2 h₁ theorem primes_infinite' : ∀ s : Finset Nat, ∃ p, Nat.Prime p ∧ p ∉ s := by intro s by_contra h push_neg at h set s' := s.filter Nat.Prime with s'_def have mem_s' : ∀ {n : ℕ}, n ∈ s' ↔ n.Prime := by intro n simp [s'_def] apply h have : 2 ≤ (∏ i in s', i) + 1 := by apply Nat.succ_le_succ apply Nat.succ_le_of_lt apply Finset.prod_pos intro n ns' apply (mem_s'.mp ns').pos rcases exists_prime_factor this with ⟨p, pp, pdvd⟩ have : p ∣ ∏ i in s', i := by apply dvd_prod_of_mem rw [mem_s'] apply pp have : p ∣ 1 := by convert Nat.dvd_sub' pdvd this simp show False have := Nat.le_of_dvd zero_lt_one this linarith [pp.two_le] theorem bounded_of_ex_finset (Q : ℕ → Prop) : (∃ s : Finset ℕ, ∀ k, Q k → k ∈ s) → ∃ n, ∀ k, Q k → k < n := by rintro ⟨s, hs⟩ use s.sup id + 1 intro k Qk apply Nat.lt_succ_of_le show id k ≤ s.sup id apply le_sup (hs k Qk) theorem ex_finset_of_bounded (Q : ℕ → Prop) [DecidablePred Q] : (∃ n, ∀ k, Q k → k ≤ n) → ∃ s : Finset ℕ, ∀ k, Q k ↔ k ∈ s := by rintro ⟨n, hn⟩ use (range (n + 1)).filter Q intro k simp [Nat.lt_succ_iff] exact hn k theorem mod_4_eq_3_or_mod_4_eq_3 {m n : ℕ} (h : m * n % 4 = 3) : m % 4 = 3 ∨ n % 4 = 3 := by revert h rw [Nat.mul_mod] have : m % 4 < 4 := Nat.mod_lt m (by norm_num) interval_cases hm : m % 4 <;> simp [hm] have : n % 4 < 4 := Nat.mod_lt n (by norm_num) interval_cases hn : n % 4 <;> simp [hn] theorem two_le_of_mod_4_eq_3 {n : ℕ} (h : n % 4 = 3) : 2 ≤ n := by apply two_le <;> · intro neq rw [neq] at h norm_num at h theorem aux {m n : ℕ} (h₀ : m ∣ n) (h₁ : 2 ≤ m) (h₂ : m < n) : n / m ∣ n ∧ n / m < n := by constructor · exact Nat.div_dvd_of_dvd h₀ exact Nat.div_lt_self (lt_of_le_of_lt (zero_le _) h₂) h₁ theorem exists_prime_factor_mod_4_eq_3 {n : Nat} (h : n % 4 = 3) : ∃ p : Nat, p.Prime ∧ p ∣ n ∧ p % 4 = 3 := by by_cases np : n.Prime · use n exact ⟨np, dvd_rfl, h⟩ induction' n using Nat.strong_induction_on with n ih dsimp at ih rw [Nat.prime_def_lt] at np push_neg at np rcases np (two_le_of_mod_4_eq_3 h) with ⟨m, mltn, mdvdn, mne1⟩ have mge2 : 2 ≤ m := by apply two_le _ mne1 intro mz rw [mz, zero_dvd_iff] at mdvdn linarith have neq : m * (n / m) = n := Nat.mul_div_cancel' mdvdn have : m % 4 = 3 ∨ n / m % 4 = 3 := by apply mod_4_eq_3_or_mod_4_eq_3 rw [neq, h] cases' this with h1 h1 · by_cases mp : m.Prime · use m exact ⟨mp, mdvdn, h1⟩ rcases ih m mltn h1 mp with ⟨p, pp, pdvd, p4eq⟩ use p exact ⟨pp, pdvd.trans mdvdn, p4eq⟩ obtain ⟨nmdvdn, nmltn⟩ := aux mdvdn mge2 mltn by_cases nmp : (n / m).Prime · use n / m exact ⟨nmp, nmdvdn, h1⟩ rcases ih (n / m) nmltn h1 nmp with ⟨p, pp, pdvd, p4eq⟩ use p exact ⟨pp, pdvd.trans nmdvdn, p4eq⟩ theorem primes_mod_4_eq_3_infinite : ∀ n, ∃ p > n, Nat.Prime p ∧ p % 4 = 3 := by by_contra h push_neg at h cases' h with n hn have : ∃ s : Finset Nat, ∀ p : ℕ, p.Prime ∧ p % 4 = 3 ↔ p ∈ s := by apply ex_finset_of_bounded use n contrapose! hn rcases hn with ⟨p, ⟨pp, p4⟩, pltn⟩ exact ⟨p, pltn, pp, p4⟩ cases' this with s hs have h₁ : ((4 * ∏ i in erase s 3, i) + 3) % 4 = 3 := by rw [add_comm, Nat.add_mul_mod_self_left] norm_num rcases exists_prime_factor_mod_4_eq_3 h₁ with ⟨p, pp, pdvd, p4eq⟩ have ps : p ∈ s := by rw [← hs p] exact ⟨pp, p4eq⟩ have pne3 : p ≠ 3 := by intro peq rw [peq, ← Nat.dvd_add_iff_left (dvd_refl 3)] at pdvd rw [Nat.prime_three.dvd_mul] at pdvd norm_num at pdvd have : 3 ∈ s.erase 3 := by apply mem_of_dvd_prod_primes Nat.prime_three _ pdvd intro n simp [← hs n] tauto simp at this have : p ∣ 4 * ∏ i in erase s 3, i := by apply dvd_trans _ (dvd_mul_left _ _) apply dvd_prod_of_mem simp constructor <;> assumption have : p ∣ 3 := by convert Nat.dvd_sub' pdvd this simp have : p = 3 := by apply pp.eq_of_dvd_of_prime Nat.prime_three this contradiction
-
-
MIL/C_Sets_and_Functions/S01_Sets.lean (deleted)
-
@@ -1,254 +0,0 @@import Mathlib.Data.Set.Lattice import Mathlib.Data.Nat.Prime import Mathlib.Data.Nat.Parity import Mathlib.Tactic section variable {α : Type _} variable (s t u : Set α) open Set example (h : s ⊆ t) : s ∩ u ⊆ t ∩ u := by rw [subset_def, inter_def, inter_def] rw [subset_def] at h dsimp rintro x ⟨xs, xu⟩ exact ⟨h _ xs, xu⟩ example (h : s ⊆ t) : s ∩ u ⊆ t ∩ u := by simp only [subset_def, mem_inter_iff] at * rintro x ⟨xs, xu⟩ exact ⟨h _ xs, xu⟩ example (h : s ⊆ t) : s ∩ u ⊆ t ∩ u := by intro x xsu exact ⟨h xsu.1, xsu.2⟩ theorem foo (h : s ⊆ t) : s ∩ u ⊆ t ∩ u := fun x ⟨xs, xu⟩ => ⟨h xs, xu⟩ example (h : s ⊆ t) : s ∩ u ⊆ t ∩ u := fun x ⟨xs, xu⟩ => ⟨h xs, xu⟩ example : s ∩ (t ∪ u) ⊆ s ∩ t ∪ s ∩ u := by intro x hx have xs : x ∈ s := hx.1 have xtu : x ∈ t ∪ u := hx.2 cases' xtu with xt xu · left show x ∈ s ∩ t exact ⟨xs, xt⟩ right show x ∈ s ∩ u exact ⟨xs, xu⟩ example : s ∩ (t ∪ u) ⊆ s ∩ t ∪ s ∩ u := by rintro x ⟨xs, xt | xu⟩ · left exact ⟨xs, xt⟩ right; exact ⟨xs, xu⟩ example : s ∩ t ∪ s ∩ u ⊆ s ∩ (t ∪ u) := by sorry example : (s \ t) \ u ⊆ s \ (t ∪ u) := by intro x xstu have xs : x ∈ s := xstu.1.1 have xnt : x ∉ t := xstu.1.2 have xnu : x ∉ u := xstu.2 constructor · exact xs intro xtu -- x ∈ t ∨ x ∈ u cases' xtu with xt xu · show False exact xnt xt show False; exact xnu xu example : (s \ t) \ u ⊆ s \ (t ∪ u) := by rintro x ⟨⟨xs, xnt⟩, xnu⟩ use xs rintro (xt | xu) <;> contradiction example : s \ (t ∪ u) ⊆ (s \ t) \ u := by sorry example : s ∩ t = t ∩ s := by ext x simp only [mem_inter_iff] constructor · rintro ⟨xs, xt⟩ exact ⟨xt, xs⟩ rintro ⟨xt, xs⟩; exact ⟨xs, xt⟩ example : s ∩ t = t ∩ s := Set.ext fun x => ⟨fun ⟨xs, xt⟩ => ⟨xt, xs⟩, fun ⟨xt, xs⟩ => ⟨xs, xt⟩⟩ example : s ∩ t = t ∩ s := by ext x; simp [and_comm] example : s ∩ t = t ∩ s := by apply Subset.antisymm · rintro x ⟨xs, xt⟩ exact ⟨xt, xs⟩ rintro x ⟨xt, xs⟩; exact ⟨xs, xt⟩ example : s ∩ t = t ∩ s := Subset.antisymm sorry sorry example : s ∩ (s ∪ t) = s := by sorry example : s ∪ s ∩ t = s := by sorry example : s \ t ∪ t = s ∪ t := by sorry example : s \ t ∪ t \ s = (s ∪ t) \ (s ∩ t) := by sorry def evens : Set ℕ := { n | Even n } def odds : Set ℕ := { n | ¬Even n } example : evens ∪ odds = univ := by rw [evens, odds] ext n simp apply Classical.em example (x : ℕ) (h : x ∈ (∅ : Set ℕ)) : False := h example (x : ℕ) : x ∈ (univ : Set ℕ) := trivial example : { n | Nat.Prime n } ∩ { n | n > 2 } ⊆ { n | ¬Even n } := by sorry #print Prime #print Nat.Prime example (n : ℕ) : Prime n ↔ Nat.Prime n := Nat.prime_iff.symm example (n : ℕ) (h : Prime n) : Nat.Prime n := by rw [Nat.prime_iff] exact h example (n : ℕ) (h : Prime n) : Nat.Prime n := by rwa [Nat.prime_iff] end section variable (s t : Set ℕ) example (h₀ : ∀ x ∈ s, ¬Even x) (h₁ : ∀ x ∈ s, Prime x) : ∀ x ∈ s, ¬Even x ∧ Prime x := by intro x xs constructor · apply h₀ x xs apply h₁ x xs example (h : ∃ x ∈ s, ¬Even x ∧ Prime x) : ∃ x ∈ s, Prime x := by rcases h with ⟨x, xs, _, prime_x⟩ use x, xs exact prime_x section variable (ssubt : s ⊆ t) example (h₀ : ∀ x ∈ t, ¬Even x) (h₁ : ∀ x ∈ t, Prime x) : ∀ x ∈ s, ¬Even x ∧ Prime x := by sorry example (h : ∃ x ∈ s, ¬Even x ∧ Prime x) : ∃ x ∈ t, Prime x := by sorry end end section variable {α I : Type _} variable (A B : I → Set α) variable (s : Set α) open Set example : (s ∩ ⋃ i, A i) = ⋃ i, A i ∩ s := by ext x simp only [mem_inter_iff, mem_iUnion] constructor · rintro ⟨xs, ⟨i, xAi⟩⟩ exact ⟨i, xAi, xs⟩ rintro ⟨i, xAi, xs⟩ exact ⟨xs, ⟨i, xAi⟩⟩ example : (⋂ i, A i ∩ B i) = (⋂ i, A i) ∩ ⋂ i, B i := by ext x simp only [mem_inter_iff, mem_iInter] constructor · intro h constructor · intro i exact (h i).1 intro i exact (h i).2 rintro ⟨h1, h2⟩ i constructor · exact h1 i exact h2 i example : (s ∪ ⋂ i, A i) = ⋂ i, A i ∪ s := by sorry def primes : Set ℕ := { x | Nat.Prime x } example : (⋃ p ∈ primes, { x | p ^ 2 ∣ x }) = { x | ∃ p ∈ primes, p ^ 2 ∣ x } :=by ext rw [mem_iUnion₂] simp example : (⋃ p ∈ primes, { x | p ^ 2 ∣ x }) = { x | ∃ p ∈ primes, p ^ 2 ∣ x } := by ext simp example : (⋂ p ∈ primes, { x | ¬p ∣ x }) ⊆ { x | x = 1 } := by intro x contrapose! simp apply Nat.exists_prime_and_dvd example : (⋃ p ∈ primes, { x | x ≤ p }) = univ := by sorry end section open Set variable {α : Type _} (s : Set (Set α)) example : ⋃₀ s = ⋃ t ∈ s, t := by ext x rw [mem_iUnion₂] simp example : ⋂₀ s = ⋂ t ∈ s, t := by ext x rw [mem_iInter₂] rfl end
-
-
-
@@ -1,217 +0,0 @@import Mathlib.Data.Set.Lattice import Mathlib.Data.Set.Function import Mathlib.Analysis.SpecialFunctions.Log.Basic section variable {α β : Type _} variable (f : α → β) variable (s t : Set α) variable (u v : Set β) open Function open Set example : f ⁻¹' (u ∩ v) = f ⁻¹' u ∩ f ⁻¹' v := by ext rfl example : f '' (s ∪ t) = f '' s ∪ f '' t := by ext y; constructor · rintro ⟨x, xs | xt, rfl⟩ · left use x, xs right use x, xt rintro (⟨x, xs, rfl⟩ | ⟨x, xt, rfl⟩) · use x, Or.inl xs use x, Or.inr xt example : s ⊆ f ⁻¹' (f '' s) := by intro x xs show f x ∈ f '' s use x, xs example : f '' s ⊆ v ↔ s ⊆ f ⁻¹' v := by sorry example (h : Injective f) : f ⁻¹' (f '' s) ⊆ s := by sorry example : f '' (f ⁻¹' u) ⊆ u := by sorry example (h : Surjective f) : u ⊆ f '' (f ⁻¹' u) := by sorry example (h : s ⊆ t) : f '' s ⊆ f '' t := by sorry example (h : u ⊆ v) : f ⁻¹' u ⊆ f ⁻¹' v := by sorry example : f ⁻¹' (u ∪ v) = f ⁻¹' u ∪ f ⁻¹' v := by sorry example : f '' (s ∩ t) ⊆ f '' s ∩ f '' t := by sorry example (h : Injective f) : f '' s ∩ f '' t ⊆ f '' (s ∩ t) := by sorry example : f '' s \ f '' t ⊆ f '' (s \ t) := by sorry example : f ⁻¹' u \ f ⁻¹' v ⊆ f ⁻¹' (u \ v) := by sorry example : f '' s ∩ v = f '' (s ∩ f ⁻¹' v) := by sorry example : f '' (s ∩ f ⁻¹' u) ⊆ f '' s ∪ u := by sorry example : s ∩ f ⁻¹' u ⊆ f ⁻¹' (f '' s ∩ u) := by sorry example : s ∪ f ⁻¹' u ⊆ f ⁻¹' (f '' s ∪ u) := by sorry variable {I : Type _} (A : I → Set α) (B : I → Set β) example : (f '' ⋃ i, A i) = ⋃ i, f '' A i := by ext y; simp constructor · rintro ⟨x, ⟨i, xAi⟩, fxeq⟩ use i, x exact ⟨xAi, fxeq⟩ rintro ⟨i, x, xAi, fxeq⟩ exact ⟨x, ⟨i, xAi⟩, fxeq⟩ example : (f '' ⋂ i, A i) ⊆ ⋂ i, f '' A i := by intro y; simp intro x h fxeq i use x exact ⟨h i, fxeq⟩ example (i : I) (injf : Injective f) : (⋂ i, f '' A i) ⊆ f '' ⋂ i, A i := by intro y; simp intro h rcases h i with ⟨x, xAi, fxeq⟩ use x; constructor · intro i' rcases h i' with ⟨x', x'Ai, fx'eq⟩ have : f x = f x' := by rw [fxeq, fx'eq] have : x = x' := injf this rw [this] exact x'Ai exact fxeq example : (f ⁻¹' ⋃ i, B i) = ⋃ i, f ⁻¹' B i := by ext x simp example : (f ⁻¹' ⋂ i, B i) = ⋂ i, f ⁻¹' B i := by ext x simp example : InjOn f s ↔ ∀ x₁ ∈ s, ∀ x₂ ∈ s, f x₁ = f x₂ → x₁ = x₂ := Iff.refl _ end section open Set Real example : InjOn log { x | x > 0 } := by intro x xpos y ypos intro e -- log x = log y calc x = exp (log x) := by rw [exp_log xpos] _ = exp (log y) := by rw [e] _ = y := by rw [exp_log ypos] example : range exp = { y | y > 0 } := by ext y; constructor · rintro ⟨x, rfl⟩ apply exp_pos intro ypos use log y rw [exp_log ypos] example : InjOn sqrt { x | x ≥ 0 } := by sorry example : InjOn (fun x => x ^ 2) { x : ℝ | x ≥ 0 } := by sorry example : sqrt '' { x | x ≥ 0 } = { y | y ≥ 0 } := by sorry example : (range fun x => x ^ 2) = { y : ℝ | y ≥ 0 } := by sorry end section variable {α β : Type _} [Inhabited α] #check (default : α) variable (P : α → Prop) (h : ∃ x, P x) #check Classical.choose h example : P (Classical.choose h) := Classical.choose_spec h noncomputable section open Classical def inverse (f : α → β) : β → α := fun y : β => if h : ∃ x, f x = y then Classical.choose h else default theorem inverse_spec {f : α → β} (y : β) (h : ∃ x, f x = y) : f (inverse f y) = y := by rw [inverse]; dsimp; rw [dif_pos h] exact Classical.choose_spec h variable (f : α → β) open Function example : Injective f ↔ LeftInverse (inverse f) f := sorry example : Surjective f ↔ RightInverse (inverse f) f := sorry end section variable {α : Type _} open Function theorem Cantor : ∀ f : α → Set α, ¬Surjective f := by intro f surjf let S := { i | i ∉ f i } rcases surjf S with ⟨j, h⟩ have h₁ : j ∉ f j := by intro h' have : j ∉ f j := by rwa [h] at h' contradiction have h₂ : j ∈ S sorry have h₃ : j ∉ S sorry contradiction -- COMMENTS: TODO: improve this end
-
-
-
@@ -1,99 +0,0 @@import Mathlib.Data.Set.Lattice import Mathlib.Data.Set.Function import Mathlib.Tactic open Set open Function noncomputable section open Classical variable {α β : Type _} [Nonempty β] section variable (f : α → β) (g : β → α) def sbAux : ℕ → Set α | 0 => univ \ g '' univ | n + 1 => g '' (f '' sbAux n) def sbSet := ⋃ n, sbAux f g n def sbFun (x : α) : β := if x ∈ sbSet f g then f x else invFun g x theorem sb_right_inv {x : α} (hx : x ∉ sbSet f g) : g (invFun g x) = x := by have : x ∈ g '' univ := by contrapose! hx rw [sbSet, mem_iUnion] use 0 rw [sbAux, mem_diff] sorry }, have : ∃ y, g y = x := by { sorry }, sorry theorem sb_injective (hf : Injective f) (hg : Injective g) : Injective (sbFun f g) := by set A := sbSet f g with A_def set h := sbFun f g with h_def intro x₁ x₂ intro (hxeq : h x₁ = h x₂) show x₁ = x₂ simp only [h_def, sbFun, ← A_def] at hxeq by_cases xA : x₁ ∈ A ∨ x₂ ∈ A · wlog x₁A : x₁ ∈ A generalizing x₁ x₂ hxeq xA · symm apply this hxeq.symm xA.symm (xA.resolve_left x₁A) have x₂A : x₂ ∈ A := by apply not_imp_self.mp intro (x₂nA : x₂ ∉ A) rw [if_pos x₁A, if_neg x₂nA] at hxeq rw [A_def, sbSet, mem_iUnion] at x₁A have x₂eq : x₂ = g (f x₁) := by . sorry rcases x₁A with ⟨n, hn⟩ rw [A_def, sbSet, mem_iUnion] use n + 1 simp [sbAux] exact ⟨x₁, hn, x₂eq.symm⟩ . sorry, push_neg at xA sorry theorem sb_surjective (hf : Injective f) (hg : Injective g) : Surjective (sbFun f g) := by set A := sbSet f g with A_def set h := sbFun f g with h_def intro y by_cases gyA : g y ∈ A · rw [A_def, sbSet, mem_iUnion] at gyA rcases gyA with ⟨n, hn⟩ cases' n with n · simp [sbAux] at hn simp [sbAux] at hn rcases hn with ⟨x, xmem, hx⟩ use x have : x ∈ A := by rw [A_def, sbSet, mem_iUnion] exact ⟨n, xmem⟩ simp only [h_def, sbFun, if_pos this] exact hg hx sorry end theorem schroeder_bernstein {f : α → β} {g : β → α} (hf : Injective f) (hg : Injective g) : ∃ h : α → β, Bijective h := ⟨sbFun f g, sb_injective f g hf hg, sb_surjective f g hf hg⟩ -- Auxiliary information section variable (g : β → α) (x : α) #check (invFun g : α → β) #check (leftInverse_invFun : Injective g → LeftInverse (invFun g) g) #check (leftInverse_invFun : Injective g → ∀ y, invFun g (g y) = y) #check (invFun_eq : (∃ y, g y = x) → g (invFun g x) = x) end
-
-
-
@@ -1,165 +0,0 @@import Mathlib.Data.Set.Lattice import Mathlib.Data.Nat.Prime import Mathlib.Data.Nat.Parity import Mathlib.Tactic section variable {α : Type _} variable (s t u : Set α) open Set example : s ∩ t ∪ s ∩ u ⊆ s ∩ (t ∪ u) := by rintro x (⟨xs, xt⟩ | ⟨xs, xu⟩) · use xs left exact xt use xs; right; exact xu example : s \ (t ∪ u) ⊆ (s \ t) \ u := by rintro x ⟨xs, xntu⟩ constructor use xs · intro xt exact xntu (Or.inl xt) intro xu apply xntu (Or.inr xu) example : s ∩ t = t ∩ s := Subset.antisymm (fun x ⟨xs, xt⟩ => ⟨xt, xs⟩) fun x ⟨xt, xs⟩ => ⟨xs, xt⟩ example : s ∩ (s ∪ t) = s := by ext x; constructor · rintro ⟨xs, _⟩ exact xs intro xs use xs; left; exact xs example : s ∪ s ∩ t = s := by ext x; constructor · rintro (xs | ⟨xs, xt⟩) <;> exact xs intro xs; left; exact xs example : s \ t ∪ t = s ∪ t := by ext x; constructor · rintro (⟨xs, nxt⟩ | xt) · left exact xs right exact xt by_cases h : x ∈ t · intro right exact h rintro (xs | xt) · left use xs exact h right; exact xt example : s \ t ∪ t \ s = (s ∪ t) \ (s ∩ t) := by ext x; constructor · rintro (⟨xs, xnt⟩ | ⟨xt, xns⟩) · constructor left exact xs rintro ⟨_, xt⟩ contradiction constructor right exact xt rintro ⟨xs, _⟩ contradiction rintro ⟨xs | xt, nxst⟩ · left use xs intro xt apply nxst constructor <;> assumption right; use xt; intro xs apply nxst constructor <;> assumption example : { n | Nat.Prime n } ∩ { n | n > 2 } ⊆ { n | ¬Even n } := by intro n simp intro nprime cases' Nat.Prime.eq_two_or_odd nprime with h h · rw [h] intro linarith rw [Nat.even_iff, h] norm_num end section variable (s t : Set ℕ) section variable (ssubt : s ⊆ t) example (h₀ : ∀ x ∈ t, ¬Even x) (h₁ : ∀ x ∈ t, Prime x) : ∀ x ∈ s, ¬Even x ∧ Prime x := by intro x xs constructor · apply h₀ x (ssubt xs) apply h₁ x (ssubt xs) example (h : ∃ x ∈ s, ¬Even x ∧ Prime x) : ∃ x ∈ t, Prime x := by rcases h with ⟨x, xs, _, px⟩ use x, ssubt xs exact px end end section variable {α I : Type _} variable (A B : I → Set α) variable (s : Set α) open Set example : (s ∪ ⋂ i, A i) = ⋂ i, A i ∪ s := by ext x simp only [mem_union, mem_iInter] constructor · rintro (xs | xI) · intro i right exact xs intro i left exact xI i intro h by_cases xs : x ∈ s · left exact xs right intro i cases h i · assumption contradiction def primes : Set ℕ := { x | Nat.Prime x } example : (⋃ p ∈ primes, { x | x ≤ p }) = univ := by apply eq_univ_of_forall intro x simp rcases Nat.exists_infinite_primes x with ⟨p, primep, pge⟩ use p, pge exact primep end
-
-
-
@@ -1,256 +0,0 @@import Mathlib.Data.Set.Lattice import Mathlib.Data.Set.Function import Mathlib.Analysis.SpecialFunctions.Log.Basic section variable {α β : Type _} variable (f : α → β) variable (s t : Set α) variable (u v : Set β) open Function open Set example : f '' s ⊆ v ↔ s ⊆ f ⁻¹' v := by constructor · intro h x xs have : f x ∈ f '' s := mem_image_of_mem _ xs exact h this intro h y ymem rcases ymem with ⟨x, xs, fxeq⟩ rw [← fxeq] apply h xs example (h : Injective f) : f ⁻¹' (f '' s) ⊆ s := by rintro x ⟨y, ys, fxeq⟩ rw [← h fxeq] exact ys example : f '' (f ⁻¹' u) ⊆ u := by rintro y ⟨x, xmem, rfl⟩ exact xmem example (h : Surjective f) : u ⊆ f '' (f ⁻¹' u) := by intro y yu rcases h y with ⟨x, fxeq⟩ use x constructor · show f x ∈ u rw [fxeq] exact yu exact fxeq example (h : s ⊆ t) : f '' s ⊆ f '' t := by rintro y ⟨x, xs, fxeq⟩ use x, h xs exact fxeq example (h : u ⊆ v) : f ⁻¹' u ⊆ f ⁻¹' v := by intro x; apply h example : f ⁻¹' (u ∪ v) = f ⁻¹' u ∪ f ⁻¹' v := by ext x; rfl example : f '' (s ∩ t) ⊆ f '' s ∩ f '' t := by rintro y ⟨x, ⟨xs, xt⟩, rfl⟩ constructor . use x, xs . use x, xt example (h : Injective f) : f '' s ∩ f '' t ⊆ f '' (s ∩ t) := by rintro y ⟨⟨x₁, x₁s, rfl⟩, ⟨x₂, x₂t, fx₂eq⟩⟩ use x₁ constructor . use x₁s rw [← h fx₂eq] exact x₂t . rfl example : f '' s \ f '' t ⊆ f '' (s \ t) := by rintro y ⟨⟨x₁, x₁s, rfl⟩, h⟩ use x₁ constructor . constructor . exact x₁s . intro h' apply h use x₁, h' . rfl example : f ⁻¹' u \ f ⁻¹' v ⊆ f ⁻¹' (u \ v) := fun x => id example : f '' s ∩ v = f '' (s ∩ f ⁻¹' v) := by ext y; constructor · rintro ⟨⟨x, xs, rfl⟩, fxv⟩ use x, ⟨xs, fxv⟩ rintro ⟨x, ⟨⟨xs, fxv⟩, rfl⟩⟩ exact ⟨⟨x, xs, rfl⟩, fxv⟩ example : f '' (s ∩ f ⁻¹' u) ⊆ f '' s ∩ u := by rintro y ⟨x, ⟨xs, fxu⟩, rfl⟩ exact ⟨⟨x, xs, rfl⟩, fxu⟩ example : s ∩ f ⁻¹' u ⊆ f ⁻¹' (f '' s ∩ u) := by rintro x ⟨xs, fxu⟩ exact ⟨⟨x, xs, rfl⟩, fxu⟩ example : s ∪ f ⁻¹' u ⊆ f ⁻¹' (f '' s ∪ u) := by rintro x (xs | fxu) · left exact ⟨x, xs, rfl⟩ right; exact fxu variable {I : Type _} (A : I → Set α) (B : I → Set β) example : (f '' ⋃ i, A i) = ⋃ i, f '' A i := by ext y; simp constructor · rintro ⟨x, ⟨i, xAi⟩, fxeq⟩ use i, x exact ⟨xAi, fxeq⟩ rintro ⟨i, x, xAi, fxeq⟩ exact ⟨x, ⟨i, xAi⟩, fxeq⟩ example : (f '' ⋂ i, A i) ⊆ ⋂ i, f '' A i := by intro y; simp intro x h fxeq i use x exact ⟨h i, fxeq⟩ example (i : I) (injf : Injective f) : (⋂ i, f '' A i) ⊆ f '' ⋂ i, A i := by intro y; simp intro h rcases h i with ⟨x, xAi, fxeq⟩ use x; constructor · intro i' rcases h i' with ⟨x', x'Ai, fx'eq⟩ have : f x = f x' := by rw [fxeq, fx'eq] have : x = x' := injf this rw [this] exact x'Ai exact fxeq example : (f ⁻¹' ⋃ i, B i) = ⋃ i, f ⁻¹' B i := by ext x simp example : (f ⁻¹' ⋂ i, B i) = ⋂ i, f ⁻¹' B i := by ext x simp end section open Set Real example : InjOn sqrt { x | x ≥ 0 } := by intro x xnonneg y ynonneg intro e calc x = sqrt x ^ 2 := by rw [sq_sqrt xnonneg] _ = sqrt y ^ 2 := by rw [e] _ = y := by rw [sq_sqrt ynonneg] example : InjOn (fun x => x ^ 2) { x : ℝ | x ≥ 0 } := by intro x xnonneg y ynonneg intro e dsimp at * calc x = sqrt (x ^ 2) := by rw [sqrt_sq xnonneg] _ = sqrt (y ^ 2) := by rw [e] _ = y := by rw [sqrt_sq ynonneg] example : sqrt '' { x | x ≥ 0 } = { y | y ≥ 0 } := by ext y; constructor · rintro ⟨x, ⟨xnonneg, rfl⟩⟩ apply sqrt_nonneg intro ynonneg use y ^ 2 dsimp at * constructor apply pow_nonneg ynonneg apply sqrt_sq assumption example : (range fun x => x ^ 2) = { y : ℝ | y ≥ 0 } := by ext y constructor · rintro ⟨x, rfl⟩ dsimp at * apply pow_two_nonneg intro ynonneg use sqrt y exact sq_sqrt ynonneg end section variable {α β : Type _} [Inhabited α] noncomputable section open Classical def inverse (f : α → β) : β → α := fun y : β => if h : ∃ x, f x = y then Classical.choose h else default theorem inverse_spec {f : α → β} (y : β) (h : ∃ x, f x = y) : f (inverse f y) = y := by rw [inverse]; dsimp; rw [dif_pos h] exact Classical.choose_spec h variable (f : α → β) open Function example : Injective f ↔ LeftInverse (inverse f) f := by constructor · intro h y apply h apply inverse_spec use y intro h x1 x2 e rw [← h x1, ← h x2, e] example : Injective f ↔ LeftInverse (inverse f) f := ⟨fun h y => h (inverse_spec _ ⟨y, rfl⟩), fun h x1 x2 e => by rw [← h x1, ← h x2, e]⟩ example : Surjective f ↔ RightInverse (inverse f) f := by constructor · intro h y apply inverse_spec apply h intro h y use inverse f y apply h example : Surjective f ↔ RightInverse (inverse f) f := ⟨fun h y => inverse_spec _ (h _), fun h y => ⟨inverse f y, h _⟩⟩ end section variable {α : Type _} open Function theorem Cantor : ∀ f : α → Set α, ¬Surjective f := by intro f surjf let S := { i | i ∉ f i } rcases surjf S with ⟨j, h⟩ have h₁ : j ∉ f j := by intro h' have : j ∉ f j := by rwa [h] at h' contradiction have h₂ : j ∈ S := h₁ have h₃ : j ∉ S := by rwa [h] at h₁ contradiction end
-
-
-
@@ -1,92 +0,0 @@import Mathlib.Data.Set.Lattice import Mathlib.Data.Set.Function import Mathlib.Tactic open Set open Function noncomputable section open Classical variable {α β : Type _} [Nonempty β] section variable (f : α → β) (g : β → α) def sbAux : ℕ → Set α | 0 => univ \ g '' univ | n + 1 => g '' (f '' sbAux n) def sbSet := ⋃ n, sbAux f g n def sbFun (x : α) : β := if x ∈ sbSet f g then f x else invFun g x theorem sb_right_inv {x : α} (hx : x ∉ sbSet f g) : g (invFun g x) = x := by have : x ∈ g '' univ := by contrapose! hx rw [sbSet, mem_iUnion] use 0 rw [sbAux, mem_diff] exact ⟨mem_univ _, hx⟩ have : ∃ y, g y = x := by simp at this assumption exact invFun_eq this theorem sb_injective (hf : Injective f) (hg : Injective g) : Injective (sbFun f g) := by set A := sbSet f g with A_def set h := sbFun f g with h_def intro x₁ x₂ intro (hxeq : h x₁ = h x₂) show x₁ = x₂ simp only [h_def, sbFun, ← A_def] at hxeq by_cases xA : x₁ ∈ A ∨ x₂ ∈ A · wlog x₁A : x₁ ∈ A generalizing x₁ x₂ hxeq xA · symm apply this hxeq.symm xA.symm (xA.resolve_left x₁A) have x₂A : x₂ ∈ A := by apply not_imp_self.mp intro (x₂nA : x₂ ∉ A) rw [if_pos x₁A, if_neg x₂nA] at hxeq rw [A_def, sbSet, mem_iUnion] at x₁A have x₂eq : x₂ = g (f x₁) := by rw [hxeq, sb_right_inv f g x₂nA] rcases x₁A with ⟨n, hn⟩ rw [A_def, sbSet, mem_iUnion] use n + 1 simp [sbAux] exact ⟨x₁, hn, x₂eq.symm⟩ rw [if_pos x₁A, if_pos x₂A] at hxeq exact hf hxeq push_neg at xA rw [if_neg xA.1, if_neg xA.2] at hxeq rw [← sb_right_inv f g xA.1, hxeq, sb_right_inv f g xA.2] theorem sb_surjective (hf : Injective f) (hg : Injective g) : Surjective (sbFun f g) := by set A := sbSet f g with A_def set h := sbFun f g with h_def intro y by_cases gyA : g y ∈ A · rw [A_def, sbSet, mem_iUnion] at gyA rcases gyA with ⟨n, hn⟩ cases' n with n · simp [sbAux] at hn simp [sbAux] at hn rcases hn with ⟨x, xmem, hx⟩ use x have : x ∈ A := by rw [A_def, sbSet, mem_iUnion] exact ⟨n, xmem⟩ simp only [h_def, sbFun, if_pos this] exact hg hx use g y simp only [h_def, sbFun, if_neg gyA] apply leftInverse_invFun hg end
-
-
MIL/C_Structures/S01_Structures.lean (deleted)
-
@@ -1,227 +0,0 @@import Mathlib.Algebra.BigOperators.Ring import Mathlib.Data.Real.Basic noncomputable section @[ext] structure Point where x : ℝ y : ℝ z : ℝ #check Point.ext example (a b : Point) (hx : a.x = b.x) (hy : a.y = b.y) (hz : a.z = b.z) : a = b := by ext repeat' assumption def myPoint1 : Point where x := 2 y := -1 z := 4 def myPoint2 : Point := ⟨2, -1, 4⟩ def myPoint3 := Point.mk 2 (-1) 4 structure Point' where build :: x : ℝ y : ℝ z : ℝ #check Point'.build 2 (-1) 4 namespace Point def add (a b : Point) : Point := ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩ def add' (a b : Point) : Point where x := a.x + b.x y := a.y + b.y z := a.z + b.z #check add myPoint1 myPoint2 #check myPoint1.add myPoint2 end Point #check Point.add myPoint1 myPoint2 #check myPoint1.add myPoint2 namespace Point protected theorem add_comm (a b : Point) : add a b = add b a := by rw [add, add] ext <;> dsimp repeat' apply add_comm example (a b : Point) : add a b = add b a := by simp [add, add_comm] theorem add_x (a b : Point) : (a.add b).x = a.x + b.x := rfl def addAlt : Point → Point → Point | Point.mk x₁ y₁ z₁, Point.mk x₂ y₂ z₂ => ⟨x₁ + x₂, y₁ + y₂, z₁ + z₂⟩ def addAlt' : Point → Point → Point | ⟨x₁, y₁, z₁⟩, ⟨x₂, y₂, z₂⟩ => ⟨x₁ + x₂, y₁ + y₂, z₁ + z₂⟩ theorem addAlt_x (a b : Point) : (a.addAlt b).x = a.x + b.x := by cases a cases b rfl theorem addAlt_comm (a b : Point) : addAlt a b = addAlt b a := by rcases a with ⟨xa, ya, za⟩ rcases b with ⟨xb, yb, zb⟩ rw [addAlt, addAlt] ext <;> dsimp apply add_comm repeat' apply add_comm example (a b : Point) : addAlt a b = addAlt b a := by rcases a with ⟨xa, ya, za⟩ rcases b with ⟨xb, yb, zb⟩ simp [addAlt, add_comm] example : ∀ a b : Point, addAlt a b = addAlt b a := by rintro ⟨xa, ya, za⟩ ⟨xb, yb, zb⟩ simp [addAlt, add_comm] example : ∀ a b : Point, add a b = add b a := fun ⟨xa, ya, za⟩ ⟨xb, yb, zb⟩ => by simp [add, add_comm] protected theorem add_assoc (a b c : Point) : (a.add b).add c = a.add (b.add c) := by sorry def smul (r : ℝ) (a : Point) : Point := sorry theorem smul_distrib (r : ℝ) (a b : Point) : (smul r a).add (smul r b) = smul r (a.add b) := by sorry end Point structure StandardTwoSimplex where x : ℝ y : ℝ z : ℝ x_nonneg : 0 ≤ x y_nonneg : 0 ≤ y z_nonneg : 0 ≤ z sum_eq : x + y + z = 1 namespace StandardTwoSimplex def swapXy (a : StandardTwoSimplex) : StandardTwoSimplex where x := a.y y := a.x z := a.z x_nonneg := a.y_nonneg y_nonneg := a.x_nonneg z_nonneg := a.z_nonneg sum_eq := by rw [add_comm a.y a.x, a.sum_eq] noncomputable section def midpoint (a b : StandardTwoSimplex) : StandardTwoSimplex where x := (a.x + b.x) / 2 y := (a.y + b.y) / 2 z := (a.z + b.z) / 2 x_nonneg := div_nonneg (add_nonneg a.x_nonneg b.x_nonneg) (by norm_num) y_nonneg := div_nonneg (add_nonneg a.y_nonneg b.y_nonneg) (by norm_num) z_nonneg := div_nonneg (add_nonneg a.z_nonneg b.z_nonneg) (by norm_num) sum_eq := by field_simp; linarith [a.sum_eq, b.sum_eq] def weightedAverage (lambda : Real) (lambda_nonneg : 0 ≤ lambda) (lambda_le : lambda ≤ 1) (a b : StandardTwoSimplex) : StandardTwoSimplex where sorry end end StandardTwoSimplex open BigOperators structure StandardSimplex (n : ℕ) where V : Fin n → ℝ NonNeg : ∀ i : Fin n, 0 ≤ V i sum_eq_one : (∑ i, V i) = 1 namespace StandardSimplex def midpoint (n : ℕ) (a b : StandardSimplex n) : StandardSimplex n where V i := (a.V i + b.V i) / 2 NonNeg := by intro i apply div_nonneg · linarith [a.NonNeg i, b.NonNeg i] norm_num sum_eq_one := by simp [div_eq_mul_inv, ← Finset.sum_mul, Finset.sum_add_distrib, a.sum_eq_one, b.sum_eq_one] field_simp end StandardSimplex structure IsLinear (f : ℝ → ℝ) where is_additive : ∀ x y, f (x + y) = f x + f y preserves_mul : ∀ x c, f (c * x) = c * f x section variable (f : ℝ → ℝ) (linf : IsLinear f) #check linf.is_additive #check linf.preserves_mul end def Point'' := ℝ × ℝ × ℝ def IsLinear' (f : ℝ → ℝ) := (∀ x y, f (x + y) = f x + f y) ∧ ∀ x c, f (c * x) = c * f x def PReal := { y : ℝ // 0 < y } section variable (x : PReal) #check x.val #check x.property #check x.1 #check x.2 end def StandardTwoSimplex' := { p : ℝ × ℝ × ℝ // 0 ≤ p.1 ∧ 0 ≤ p.2.1 ∧ 0 ≤ p.2.2 ∧ p.1 + p.2.1 + p.2.2 = 1 } def StandardSimplex' (n : ℕ) := { v : Fin n → ℝ // (∀ i : Fin n, 0 ≤ v i) ∧ (∑ i, v i) = 1 } def StdSimplex := Σ n : ℕ, StandardSimplex n section variable (s : StdSimplex) #check s.fst #check s.snd #check s.1 #check s.2 end
-
-
-
@@ -1,172 +0,0 @@import Mathlib.Data.Real.Basic structure Group₁ (α : Type _) where mul : α → α → α one : α inv : α → α mul_assoc : ∀ x y z : α, mul (mul x y) z = mul x (mul y z) mul_one : ∀ x : α, mul x one = x one_mul : ∀ x : α, mul one x = x mul_left_inv : ∀ x : α, mul (inv x) x = one structure Group₁Cat where α : Type _ str : Group₁ α section variable (α β γ : Type _) variable (f : α ≃ β) (g : β ≃ γ) #check Equiv α β #check (f.toFun : α → β) #check (f.invFun : β → α) #check (f.right_inv : ∀ x : β, f (f.invFun x) = x) #check (f.left_inv : ∀ x : α, f.invFun (f x) = x) #check (Equiv.refl α : α ≃ α) #check (f.symm : β ≃ α) #check (f.trans g : α ≃ γ) example (x : α) : (f.trans g).toFun x = g.toFun (f.toFun x) := rfl example (x : α) : (f.trans g) x = g (f x) := rfl example : (f.trans g : α → γ) = g ∘ f := rfl end example (α : Type _) : Equiv.Perm α = (α ≃ α) := rfl def permGroup {α : Type _} : Group₁ (Equiv.Perm α) where mul f g := Equiv.trans g f one := Equiv.refl α inv := Equiv.symm mul_assoc f g h := (Equiv.trans_assoc _ _ _).symm one_mul := Equiv.trans_refl mul_one := Equiv.refl_trans mul_left_inv := Equiv.self_trans_symm structure AddGroup₁ (α : Type _) where (add : α → α → α) -- fill in the rest @[ext] structure Point where x : ℝ y : ℝ z : ℝ namespace Point def add (a b : Point) : Point := ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩ def neg (a : point) : point := sorry def zero : point := sorry def add_group_point : add_group₁ point := sorry end Point section variable {α : Type _} (f g : Equiv.Perm α) (n : ℕ) #check f * g #check mul_assoc f g g⁻¹ -- group power, defined for any group #check g ^ n example : f * g * g⁻¹ = f := by rw [mul_assoc, mul_right_inv, mul_one] example : f * g * g⁻¹ = f := mul_inv_cancel_right f g example {α : Type _} (f g : Equiv.Perm α) : g.symm.trans (g.trans f) = f := mul_inv_cancel_right f g end class Group₂ (α : Type _) where mul : α → α → α one : α inv : α → α mul_assoc : ∀ x y z : α, mul (mul x y) z = mul x (mul y z) mul_one : ∀ x : α, mul x one = x one_mul : ∀ x : α, mul one x = x mul_left_inv : ∀ x : α, mul (inv x) x = one instance {α : Type _} : Group₂ (Equiv.Perm α) where mul f g := Equiv.trans g f one := Equiv.refl α inv := Equiv.symm mul_assoc f g h := (Equiv.trans_assoc _ _ _).symm one_mul := Equiv.trans_refl mul_one := Equiv.refl_trans mul_left_inv := Equiv.self_trans_symm #check @Group₂.mul def mySquare {α : Type _} [Group₂ α] (x : α) := Group₂.mul x x #check @mySquare section variable {β : Type _} (f g : Equiv.Perm β) example : Group₂.mul f g = g.trans f := rfl example : mySquare f = f.trans f := rfl end instance : Inhabited Point where default := ⟨0, 0, 0⟩ #check (default : Point) example : ([] : List Point).headI = default := rfl instance : Add Point where add := Point.add section variable (x y : Point) #check x + y example : x + y = Point.add x y := rfl end instance hasMulGroup₂ {α : Type _} [Group₂ α] : Mul α := ⟨Group₂.mul⟩ instance hasOneGroup₂ {α : Type _} [Group₂ α] : One α := ⟨Group₂.one⟩ instance hasInvGroup₂ {α : Type _} [Group₂ α] : Inv α := ⟨Group₂.inv⟩ section variable {α : Type _} (f g : Equiv.Perm α) #check f * 1 * g⁻¹ def foo : f * 1 * g⁻¹ = g.symm.trans ((Equiv.refl α).trans f) := rfl end class AddGroup₂ (α : Type _) where add : α → α → α -- fill in the rest
-
-
-
@@ -1,271 +0,0 @@import Mathlib.Data.Int.Basic import Mathlib.Algebra.EuclideanDomain.Basic import Mathlib.RingTheory.PrincipalIdealDomain import Mathlib.Tactic @[ext] structure gaussInt where re : ℤ im : ℤ namespace gaussInt instance : Zero gaussInt := ⟨⟨0, 0⟩⟩ instance : One gaussInt := ⟨⟨1, 0⟩⟩ instance : Add gaussInt := ⟨fun x y => ⟨x.re + y.re, x.im + y.im⟩⟩ instance : Neg gaussInt := ⟨fun x => ⟨-x.re, -x.im⟩⟩ instance : Mul gaussInt := ⟨fun x y => ⟨x.re * y.re - x.im * y.im, x.re * y.im + x.im * y.re⟩⟩ theorem zero_def : (0 : gaussInt) = ⟨0, 0⟩ := rfl theorem one_def : (1 : gaussInt) = ⟨1, 0⟩ := rfl theorem add_def (x y : gaussInt) : x + y = ⟨x.re + y.re, x.im + y.im⟩ := rfl theorem neg_def (x : gaussInt) : -x = ⟨-x.re, -x.im⟩ := rfl theorem mul_def (x y : gaussInt) : x * y = ⟨x.re * y.re - x.im * y.im, x.re * y.im + x.im * y.re⟩ := rfl @[simp] theorem zero_re : (0 : gaussInt).re = 0 := rfl @[simp] theorem zero_im : (0 : gaussInt).im = 0 := rfl @[simp] theorem one_re : (1 : gaussInt).re = 1 := rfl @[simp] theorem one_im : (1 : gaussInt).im = 0 := rfl @[simp] theorem add_re (x y : gaussInt) : (x + y).re = x.re + y.re := rfl @[simp] theorem add_im (x y : gaussInt) : (x + y).im = x.im + y.im := rfl @[simp] theorem neg_re (x : gaussInt) : (-x).re = -x.re := rfl @[simp] theorem neg_im (x : gaussInt) : (-x).im = -x.im := rfl @[simp] theorem mul_re (x y : gaussInt) : (x * y).re = x.re * y.re - x.im * y.im := rfl @[simp] theorem mul_im (x y : gaussInt) : (x * y).im = x.re * y.im + x.im * y.re := rfl instance instCommRing : CommRing gaussInt where zero := 0 one := 1 add := (· + ·) neg x := -x mul := (· * ·) add_assoc := by intros ext <;> simp <;> ring zero_add := by intros ext <;> simp add_zero := by intros ext <;> simp add_left_neg := by intros ext <;> simp add_comm := by intros ext <;> simp <;> ring mul_assoc := by intros ext <;> simp <;> ring one_mul := by intros ext <;> simp mul_one := by intros ext <;> simp left_distrib := by intros ext <;> simp <;> ring right_distrib := by intros ext <;> simp <;> ring mul_comm := by intros ext <;> simp <;> ring zero_mul := sorry mul_zero := sorry instance : Nontrivial gaussInt := by use 0, 1 rw [Ne, gaussInt.ext_iff] simp end gaussInt example (a b : ℤ) : a = b * (a / b) + a % b := Eq.symm <| Int.ediv_add_emod a b example (a b : ℤ) : b ≠ 0 → 0 ≤ a % b := Int.emod_nonneg a example (a b : ℤ) : b ≠ 0 → a % b < abs b := Int.emod_lt a namespace Int def div' (a b : ℤ) := (a + b / 2) / b def mod' (a b : ℤ) := (a + b / 2) % b - b / 2 theorem div'_add_mod' (a b : ℤ) : b * div' a b + mod' a b = a := by rw [div', mod'] linarith [Int.ediv_add_emod (a + b / 2) b] theorem abs_mod'_le (a b : ℤ) (h : 0 < b) : abs (mod' a b) ≤ b / 2 := by rw [mod', abs_le] constructor · linarith [Int.emod_nonneg (a + b / 2) h.ne'] have := Int.emod_lt_of_pos (a + b / 2) h have := Int.ediv_add_emod b 2 have := Int.emod_lt_of_pos b zero_lt_two revert this; intro this -- FIXME, this should not be needed linarith theorem mod'_eq (a b : ℤ) : mod' a b = a - b * div' a b := by linarith [div'_add_mod' a b] end Int theorem sq_add_sq_eq_zero {α : Type _} [LinearOrderedRing α] (x y : α) : x ^ 2 + y ^ 2 = 0 ↔ x = 0 ∧ y = 0 := by sorry namespace gaussInt def norm (x : gaussInt) := x.re ^ 2 + x.im ^ 2 @[simp] theorem norm_nonneg (x : gaussInt) : 0 ≤ norm x := by sorry theorem norm_eq_zero (x : gaussInt) : norm x = 0 ↔ x = 0 := by sorry theorem norm_pos (x : gaussInt) : 0 < norm x ↔ x ≠ 0 := by sorry theorem norm_mul (x y : gaussInt) : norm (x * y) = norm x * norm y := by sorry def conj (x : gaussInt) : gaussInt := ⟨x.re, -x.im⟩ @[simp] theorem conj_re (x : gaussInt) : (conj x).re = x.re := rfl @[simp] theorem conj_im (x : gaussInt) : (conj x).im = -x.im := rfl theorem norm_conj (x : gaussInt) : norm (conj x) = norm x := by simp [norm] instance : Div gaussInt := ⟨fun x y => ⟨Int.div' (x * conj y).re (norm y), Int.div' (x * conj y).im (norm y)⟩⟩ instance : Mod gaussInt := ⟨fun x y => x - y * (x / y)⟩ theorem div_def (x y : gaussInt) : x / y = ⟨Int.div' (x * conj y).re (norm y), Int.div' (x * conj y).im (norm y)⟩ := rfl theorem mod_def (x y : gaussInt) : x % y = x - y * (x / y) := rfl theorem norm_mod_lt (x : gaussInt) {y : gaussInt} (hy : y ≠ 0) : (x % y).norm < y.norm := by have norm_y_pos : 0 < norm y := by rwa [norm_pos] have : x % y * conj y = ⟨Int.mod' (x * conj y).re (norm y), Int.mod' (x * conj y).im (norm y)⟩ := by rw [mod_def, sub_mul, Int.mod'_eq, Int.mod'_eq, sub_eq_add_neg, div_def, norm] ext <;> simp <;> ring have : norm (x % y) * norm y ≤ norm y / 2 * norm y := by conv => lhs rw [← norm_conj y, ← norm_mul, this, norm] simp trans 2 * (y.norm / 2) ^ 2 · rw [two_mul] apply add_le_add <;> · rw [sq_le_sq] apply le_trans (Int.abs_mod'_le _ _ norm_y_pos) apply le_abs_self rw [pow_two, ← mul_assoc, mul_comm, mul_comm (2 : ℤ)] apply mul_le_mul_of_nonneg_left · apply Int.ediv_mul_le norm_num apply Int.ediv_nonneg (norm_nonneg y) norm_num have : norm (x % y) ≤ norm y / 2 := le_of_mul_le_mul_right this norm_y_pos apply lt_of_le_of_lt this apply Int.ediv_lt_of_lt_mul · norm_num linarith theorem coe_natAbs_norm (x : gaussInt) : (x.norm.natAbs : ℤ) = x.norm := Int.natAbs_of_nonneg (norm_nonneg _) theorem natAbs_norm_mod_lt (x y : gaussInt) (hy : y ≠ 0) : (x % y).norm.natAbs < y.norm.natAbs := by apply Int.ofNat_lt.1 simp only [Int.coe_natAbs, abs_of_nonneg, norm_nonneg] apply norm_mod_lt x hy theorem not_norm_mul_left_lt_norm (x : gaussInt) {y : gaussInt} (hy : y ≠ 0) : ¬(norm (x * y)).natAbs < (norm x).natAbs := by apply not_lt_of_ge rw [norm_mul, Int.natAbs_mul] apply le_mul_of_one_le_right (Nat.zero_le _) apply Int.ofNat_le.1 rw [coe_natAbs_norm] exact Int.add_one_le_of_lt ((norm_pos _).mpr hy) instance : EuclideanDomain gaussInt := { gaussInt.instCommRing with quotient := (· / ·) remainder := (· % ·) quotient_mul_add_remainder_eq := fun x y => by simp only; rw [mod_def, add_comm, sub_add_cancel] quotient_zero := fun x => by simp [div_def, norm, Int.div'] rfl r := Measure (Int.natAbs ∘ norm) r_wellFounded := (measure (Int.natAbs ∘ norm)).2 remainder_lt := natAbs_norm_mod_lt mul_left_not_lt := not_norm_mul_left_lt_norm } example (x : gaussInt) : Irreducible x ↔ Prime x := PrincipalIdealRing.irreducible_iff_prime end gaussInt
-
-
-
@@ -1,96 +0,0 @@import Mathlib.Algebra.BigOperators.Ring import Mathlib.Data.Real.Basic noncomputable section @[ext] structure Point where x : ℝ y : ℝ z : ℝ namespace Point def add (a b : Point) : Point := ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩ protected theorem add_assoc (a b c : Point) : (a.add b).add c = a.add (b.add c) := by simp [add, add_assoc] def smul (r : ℝ) (a : Point) : Point := ⟨r * a.x, r * a.y, r * a.z⟩ theorem smul_distrib (r : ℝ) (a b : Point) : (smul r a).add (smul r b) = smul r (a.add b) := by simp [add, smul, mul_add] end Point structure StandardTwoSimplex where x : ℝ y : ℝ z : ℝ x_nonneg : 0 ≤ x y_nonneg : 0 ≤ y z_nonneg : 0 ≤ z sum_eq : x + y + z = 1 namespace StandardTwoSimplex noncomputable section def weightedAverage (lambda : Real) (lambda_nonneg : 0 ≤ lambda) (lambda_le : lambda ≤ 1) (a b : StandardTwoSimplex) : StandardTwoSimplex where x := lambda * a.x + (1 - lambda) * b.x y := lambda * a.y + (1 - lambda) * b.y z := lambda * a.z + (1 - lambda) * b.z x_nonneg := add_nonneg (mul_nonneg lambda_nonneg a.x_nonneg) (mul_nonneg (by linarith) b.x_nonneg) y_nonneg := add_nonneg (mul_nonneg lambda_nonneg a.y_nonneg) (mul_nonneg (by linarith) b.y_nonneg) z_nonneg := add_nonneg (mul_nonneg lambda_nonneg a.z_nonneg) (mul_nonneg (by linarith) b.z_nonneg) sum_eq := by trans (a.x + a.y + a.z) * lambda + (b.x + b.y + b.z) * (1 - lambda) · ring simp [a.sum_eq, b.sum_eq] end end StandardTwoSimplex open BigOperators structure StandardSimplex (n : ℕ) where V : Fin n → ℝ NonNeg : ∀ i : Fin n, 0 ≤ V i sum_eq_one : (∑ i, V i) = 1 namespace StandardSimplex def midpoint (n : ℕ) (a b : StandardSimplex n) : StandardSimplex n where V i := (a.V i + b.V i) / 2 NonNeg := by intro i apply div_nonneg · linarith [a.NonNeg i, b.NonNeg i] norm_num sum_eq_one := by simp [div_eq_mul_inv, ← Finset.sum_mul, Finset.sum_add_distrib, a.sum_eq_one, b.sum_eq_one] field_simp end StandardSimplex namespace StandardSimplex def weightedAverage {n : ℕ} (lambda : Real) (lambda_nonneg : 0 ≤ lambda) (lambda_le : lambda ≤ 1) (a b : StandardSimplex n) : StandardSimplex n where V i := lambda * a.V i + (1 - lambda) * b.V i NonNeg i := add_nonneg (mul_nonneg lambda_nonneg (a.NonNeg i)) (mul_nonneg (by linarith) (b.NonNeg i)) sum_eq_one := by trans (lambda * ∑ i, a.V i) + (1 - lambda) * ∑ i, b.V i · rw [Finset.sum_add_distrib, Finset.mul_sum, Finset.mul_sum] simp [a.sum_eq_one, b.sum_eq_one] end StandardSimplex
-
-
-
@@ -1,73 +0,0 @@import Mathlib.Data.Real.Basic structure AddGroup₁ (α : Type _) where add : α → α → α zero : α neg : α → α add_assoc : ∀ x y z : α, add (add x y) z = add x (add y z) add_zero : ∀ x : α, add x zero = x zero_add : ∀ x : α, add x zero = x add_left_neg : ∀ x : α, add (neg x) x = zero @[ext] structure Point where x : ℝ y : ℝ z : ℝ namespace Point def add (a b : Point) : Point := ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩ def neg (a : Point) : Point := ⟨-a.x, -a.y, -a.z⟩ def zero : Point := ⟨0, 0, 0⟩ def addGroupPoint : AddGroup₁ Point where add := Point.add zero := Point.zero neg := Point.neg add_assoc := by simp [Point.add, add_assoc] add_zero := by simp [Point.add, Point.zero] zero_add := by simp [Point.add, Point.zero] add_left_neg := by simp [Point.add, Point.neg, Point.zero] end Point class AddGroup₂ (α : Type _) where add : α → α → α zero : α neg : α → α add_assoc : ∀ x y z : α, add (add x y) z = add x (add y z) add_zero : ∀ x : α, add x zero = x zero_add : ∀ x : α, add x zero = x add_left_neg : ∀ x : α, add (neg x) x = zero instance hasAddAddGroup₂ {α : Type _} [AddGroup₂ α] : Add α := ⟨AddGroup₂.add⟩ instance hasZeroAddGroup₂ {α : Type _} [AddGroup₂ α] : Zero α := ⟨AddGroup₂.zero⟩ instance hasNegAddGroup₂ {α : Type _} [AddGroup₂ α] : Neg α := ⟨AddGroup₂.neg⟩ instance : AddGroup₂ Point where add := Point.add zero := Point.zero neg := Point.neg add_assoc := by simp [Point.add, add_assoc] add_zero := by simp [Point.add, Point.zero] zero_add := by simp [Point.add, Point.zero] add_left_neg := by simp [Point.add, Point.neg, Point.zero] section variable (x y : Point) #check x + -y + 0 end
-
-
-
@@ -1,285 +0,0 @@import Mathlib.Data.Int.Basic import Mathlib.Algebra.EuclideanDomain.Basic import Mathlib.RingTheory.PrincipalIdealDomain import Mathlib.Tactic @[ext] structure gaussInt where re : ℤ im : ℤ namespace gaussInt instance : Zero gaussInt := ⟨⟨0, 0⟩⟩ instance : One gaussInt := ⟨⟨1, 0⟩⟩ instance : Add gaussInt := ⟨fun x y => ⟨x.re + y.re, x.im + y.im⟩⟩ instance : Neg gaussInt := ⟨fun x => ⟨-x.re, -x.im⟩⟩ instance : Mul gaussInt := ⟨fun x y => ⟨x.re * y.re - x.im * y.im, x.re * y.im + x.im * y.re⟩⟩ theorem zero_def : (0 : gaussInt) = ⟨0, 0⟩ := rfl theorem one_def : (1 : gaussInt) = ⟨1, 0⟩ := rfl theorem add_def (x y : gaussInt) : x + y = ⟨x.re + y.re, x.im + y.im⟩ := rfl theorem neg_def (x : gaussInt) : -x = ⟨-x.re, -x.im⟩ := rfl theorem mul_def (x y : gaussInt) : x * y = ⟨x.re * y.re - x.im * y.im, x.re * y.im + x.im * y.re⟩ := rfl @[simp] theorem zero_re : (0 : gaussInt).re = 0 := rfl @[simp] theorem zero_im : (0 : gaussInt).im = 0 := rfl @[simp] theorem one_re : (1 : gaussInt).re = 1 := rfl @[simp] theorem one_im : (1 : gaussInt).im = 0 := rfl @[simp] theorem add_re (x y : gaussInt) : (x + y).re = x.re + y.re := rfl @[simp] theorem add_im (x y : gaussInt) : (x + y).im = x.im + y.im := rfl @[simp] theorem neg_re (x : gaussInt) : (-x).re = -x.re := rfl @[simp] theorem neg_im (x : gaussInt) : (-x).im = -x.im := rfl @[simp] theorem mul_re (x y : gaussInt) : (x * y).re = x.re * y.re - x.im * y.im := rfl @[simp] theorem mul_im (x y : gaussInt) : (x * y).im = x.re * y.im + x.im * y.re := rfl instance instCommRing : CommRing gaussInt where zero := 0 one := 1 add := (· + ·) neg x := -x mul := (· * ·) add_assoc := by intros ext <;> simp <;> ring zero_add := by intros ext <;> simp add_zero := by intros ext <;> simp add_left_neg := by intros ext <;> simp add_comm := by intros ext <;> simp <;> ring mul_assoc := by intros ext <;> simp <;> ring one_mul := by intros ext <;> simp mul_one := by intros ext <;> simp left_distrib := by intros ext <;> simp <;> ring right_distrib := by intros ext <;> simp <;> ring mul_comm := by intros ext <;> simp <;> ring zero_mul := sorry mul_zero := sorry instance : Nontrivial gaussInt := by use 0, 1 rw [Ne, gaussInt.ext_iff] simp end gaussInt namespace Int def div' (a b : ℤ) := (a + b / 2) / b def mod' (a b : ℤ) := (a + b / 2) % b - b / 2 theorem div'_add_mod' (a b : ℤ) : b * div' a b + mod' a b = a := by rw [div', mod'] linarith [Int.ediv_add_emod (a + b / 2) b] theorem abs_mod'_le (a b : ℤ) (h : 0 < b) : abs (mod' a b) ≤ b / 2 := by rw [mod', abs_le] constructor · linarith [Int.emod_nonneg (a + b / 2) h.ne'] have := Int.emod_lt_of_pos (a + b / 2) h have := Int.ediv_add_emod b 2 have := Int.emod_lt_of_pos b zero_lt_two revert this; intro this -- FIXME, this should not be needed linarith theorem mod'_eq (a b : ℤ) : mod' a b = a - b * div' a b := by linarith [div'_add_mod' a b] end Int private theorem aux {α : Type _} [LinearOrderedRing α] {x y : α} (h : x ^ 2 + y ^ 2 = 0) : x = 0 := haveI h' : x ^ 2 = 0 := by apply le_antisymm _ (sq_nonneg x) rw [← h] apply le_add_of_nonneg_right (sq_nonneg y) pow_eq_zero h' theorem sq_add_sq_eq_zero {α : Type _} [LinearOrderedRing α] (x y : α) : x ^ 2 + y ^ 2 = 0 ↔ x = 0 ∧ y = 0 := by constructor · intro h constructor · exact aux h rw [add_comm] at h exact aux h rintro ⟨rfl, rfl⟩ norm_num namespace gaussInt def norm (x : gaussInt) := x.re ^ 2 + x.im ^ 2 @[simp] theorem norm_nonneg (x : gaussInt) : 0 ≤ norm x := by apply add_nonneg <;> apply sq_nonneg theorem norm_eq_zero (x : gaussInt) : norm x = 0 ↔ x = 0 := by rw [norm, sq_add_sq_eq_zero, gaussInt.ext_iff] rfl theorem norm_pos (x : gaussInt) : 0 < norm x ↔ x ≠ 0 := by rw [lt_iff_le_and_ne, ne_comm, Ne, norm_eq_zero] simp [norm_nonneg] theorem norm_mul (x y : gaussInt) : norm (x * y) = norm x * norm y := by simp [norm] ring def conj (x : gaussInt) : gaussInt := ⟨x.re, -x.im⟩ @[simp] theorem conj_re (x : gaussInt) : (conj x).re = x.re := rfl @[simp] theorem conj_im (x : gaussInt) : (conj x).im = -x.im := rfl theorem norm_conj (x : gaussInt) : norm (conj x) = norm x := by simp [norm] instance : Div gaussInt := ⟨fun x y => ⟨Int.div' (x * conj y).re (norm y), Int.div' (x * conj y).im (norm y)⟩⟩ instance : Mod gaussInt := ⟨fun x y => x - y * (x / y)⟩ theorem div_def (x y : gaussInt) : x / y = ⟨Int.div' (x * conj y).re (norm y), Int.div' (x * conj y).im (norm y)⟩ := rfl theorem mod_def (x y : gaussInt) : x % y = x - y * (x / y) := rfl theorem norm_mod_lt (x : gaussInt) {y : gaussInt} (hy : y ≠ 0) : (x % y).norm < y.norm := by have norm_y_pos : 0 < norm y := by rwa [norm_pos] have : x % y * conj y = ⟨Int.mod' (x * conj y).re (norm y), Int.mod' (x * conj y).im (norm y)⟩ := by rw [mod_def, sub_mul, Int.mod'_eq, Int.mod'_eq, sub_eq_add_neg, div_def, norm] ext <;> simp <;> ring have : norm (x % y) * norm y ≤ norm y / 2 * norm y := by conv => lhs rw [← norm_conj y, ← norm_mul, this, norm] simp trans 2 * (y.norm / 2) ^ 2 · rw [two_mul] apply add_le_add <;> · rw [sq_le_sq] apply le_trans (Int.abs_mod'_le _ _ norm_y_pos) apply le_abs_self rw [pow_two, ← mul_assoc, mul_comm, mul_comm (2 : ℤ)] apply mul_le_mul_of_nonneg_left · apply Int.ediv_mul_le norm_num apply Int.ediv_nonneg (norm_nonneg y) norm_num have : norm (x % y) ≤ norm y / 2 := le_of_mul_le_mul_right this norm_y_pos apply lt_of_le_of_lt this apply Int.ediv_lt_of_lt_mul · norm_num linarith theorem coe_natAbs_norm (x : gaussInt) : (x.norm.natAbs : ℤ) = x.norm := Int.natAbs_of_nonneg (norm_nonneg _) theorem natAbs_norm_mod_lt (x y : gaussInt) (hy : y ≠ 0) : (x % y).norm.natAbs < y.norm.natAbs := by apply Int.ofNat_lt.1 simp only [Int.coe_natAbs, abs_of_nonneg, norm_nonneg] apply norm_mod_lt x hy theorem not_norm_mul_left_lt_norm (x : gaussInt) {y : gaussInt} (hy : y ≠ 0) : ¬(norm (x * y)).natAbs < (norm x).natAbs := by apply not_lt_of_ge rw [norm_mul, Int.natAbs_mul] apply le_mul_of_one_le_right (Nat.zero_le _) apply Int.ofNat_le.1 rw [coe_natAbs_norm] exact Int.add_one_le_of_lt ((norm_pos _).mpr hy) instance : EuclideanDomain gaussInt := { gaussInt.instCommRing with quotient := (· / ·) remainder := (· % ·) quotient_mul_add_remainder_eq := fun x y => by simp only; rw [mod_def, add_comm, sub_add_cancel] quotient_zero := fun x => by simp [div_def, norm, Int.div'] rfl r := Measure (Int.natAbs ∘ norm) r_wellFounded := (measure (Int.natAbs ∘ norm)).2 remainder_lt := natAbs_norm_mod_lt mul_left_not_lt := not_norm_mul_left_lt_norm } example (x : gaussInt) : Irreducible x ↔ Prime x := PrincipalIdealRing.irreducible_iff_prime end gaussInt
-
-
MIL/C_Topology/S01_Filters.lean (deleted)
-
@@ -1,110 +0,0 @@import Mathlib.Topology.Instances.Real open Set Filter Topology def principal {α : Type _} (s : Set α) : Filter α where sets := { t | s ⊆ t } univ_sets := sorry sets_of_superset := sorry inter_sets := sorry example : Filter ℕ := { sets := { s | ∃ a, ∀ b, a ≤ b → b ∈ s } univ_sets := sorry sets_of_superset := sorry inter_sets := sorry } def Tendsto₁ {X Y : Type _} (f : X → Y) (F : Filter X) (G : Filter Y) := ∀ V ∈ G, f ⁻¹' V ∈ F def Tendsto₂ {X Y : Type _} (f : X → Y) (F : Filter X) (G : Filter Y) := map f F ≤ G example {X Y : Type _} (f : X → Y) (F : Filter X) (G : Filter Y) : Tendsto₂ f F G ↔ Tendsto₁ f F G := Iff.rfl #check (@Filter.map_mono : ∀ {α β} {m : α → β}, Monotone (map m)) #check (@Filter.map_map : ∀ {α β γ} {f : Filter α} {m : α → β} {m' : β → γ}, map m' (map m f) = map (m' ∘ m) f) example {X Y Z : Type _} {F : Filter X} {G : Filter Y} {H : Filter Z} {f : X → Y} {g : Y → Z} (hf : Tendsto₁ f F G) (hg : Tendsto₁ g G H) : Tendsto₁ (g ∘ f) F H := sorry variable (f : ℝ → ℝ) (x₀ y₀ : ℝ) #check comap ((↑) : ℚ → ℝ) (𝓝 x₀) #check Tendsto (f ∘ (↑)) (comap ((↑) : ℚ → ℝ) (𝓝 x₀)) (𝓝 y₀) section variable {α β γ : Type _} (F : Filter α) {m : γ → β} {n : β → α} #check (comap_comap : comap m (comap n F) = comap (n ∘ m) F) end example : 𝓝 (x₀, y₀) = 𝓝 x₀ ×ᶠ 𝓝 y₀ := nhds_prod_eq #check le_inf_iff example (f : ℕ → ℝ × ℝ) (x₀ y₀ : ℝ) : Tendsto f atTop (𝓝 (x₀, y₀)) ↔ Tendsto (Prod.fst ∘ f) atTop (𝓝 x₀) ∧ Tendsto (Prod.snd ∘ f) atTop (𝓝 y₀) := sorry example (x₀ : ℝ) : HasBasis (𝓝 x₀) (fun ε : ℝ => 0 < ε) fun ε => Ioo (x₀ - ε) (x₀ + ε) := nhds_basis_Ioo_pos x₀ example (u : ℕ → ℝ) (x₀ : ℝ) : Tendsto u atTop (𝓝 x₀) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, u n ∈ Ioo (x₀ - ε) (x₀ + ε) := by have : atTop.HasBasis (fun _ : ℕ => True) Ici := atTop_basis rw [this.tendsto_iff (nhds_basis_Ioo_pos x₀)] simp example (P Q : ℕ → Prop) (hP : ∀ᶠ n in atTop, P n) (hQ : ∀ᶠ n in atTop, Q n) : ∀ᶠ n in atTop, P n ∧ Q n := hP.and hQ example (u v : ℕ → ℝ) (h : ∀ᶠ n in atTop, u n = v n) (x₀ : ℝ) : Tendsto u atTop (𝓝 x₀) ↔ Tendsto v atTop (𝓝 x₀) := tendsto_congr' h example (u v : ℕ → ℝ) (h : u =ᶠ[atTop] v) (x₀ : ℝ) : Tendsto u atTop (𝓝 x₀) ↔ Tendsto v atTop (𝓝 x₀) := tendsto_congr' h #check @eventually_of_forall #check @Eventually.mono #check @Eventually.and example (P Q R : ℕ → Prop) (hP : ∀ᶠ n in atTop, P n) (hQ : ∀ᶠ n in atTop, Q n) (hR : ∀ᶠ n in atTop, P n ∧ Q n → R n) : ∀ᶠ n in atTop, R n := by apply (hP.and (hQ.and hR)).mono rintro n ⟨h, h', h''⟩ exact h'' ⟨h, h'⟩ example (P Q R : ℕ → Prop) (hP : ∀ᶠ n in atTop, P n) (hQ : ∀ᶠ n in atTop, Q n) (hR : ∀ᶠ n in atTop, P n ∧ Q n → R n) : ∀ᶠ n in atTop, R n := by filter_upwards [hP, hQ, hR] intro n h h' h'' exact h'' ⟨h, h'⟩ #check mem_closure_iff_clusterPt #check le_principal_iff #check neBot_of_le example (u : ℕ → ℝ) (M : Set ℝ) (x : ℝ) (hux : Tendsto u atTop (𝓝 x)) (huM : ∀ᶠ n in atTop, u n ∈ M) : x ∈ closure M := sorry
-
-
MIL/C_Topology/S02_Metric_Spaces.lean (deleted)
-
@@ -1,200 +0,0 @@import Mathlib.Topology.Instances.Real import Mathlib.Analysis.NormedSpace.BanachSteinhaus open Set Filter open Topology Filter variable {X : Type _} [MetricSpace X] (a b c : X) #check (dist a b : ℝ) #check (dist_nonneg : 0 ≤ dist a b) #check (dist_eq_zero : dist a b = 0 ↔ a = b) #check (dist_comm a b : dist a b = dist b a) #check (dist_triangle a b c : dist a c ≤ dist a b + dist b c) -- Note the next three lines are not quoted, their purpose is to make sure those things don't get renamed while we're looking elsewhere. #check EMetricSpace #check PseudoMetricSpace #check PseudoEMetricSpace example {u : ℕ → X} {a : X} : Tendsto u atTop (𝓝 a) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, dist (u n) a < ε := Metric.tendsto_atTop example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} : Continuous f ↔ ∀ x : X, ∀ ε > 0, ∃ δ > 0, ∀ x', dist x' x < δ → dist (f x') (f x) < ε := Metric.continuous_iff example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : Continuous fun p : X × X => dist (f p.1) (f p.2) := by continuity example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : Continuous fun p : X × X => dist (f p.1) (f p.2) := continuous_dist.comp ((hf.comp continuous_fst).prod_mk (hf.comp continuous_snd)) example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : Continuous fun p : X × X => dist (f p.1) (f p.2) := by apply Continuous.dist exact hf.comp continuous_fst exact hf.comp continuous_snd example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : Continuous fun p : X × X => dist (f p.1) (f p.2) := (hf.comp continuous_fst).dist (hf.comp continuous_snd) example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : Continuous fun p : X × X => dist (f p.1) (f p.2) := hf.fst'.dist hf.snd' example {f : ℝ → X} (hf : Continuous f) : Continuous fun x : ℝ => f (x ^ 2 + x) := sorry example {X Y : Type _} [MetricSpace X] [MetricSpace Y] (f : X → Y) (a : X) : ContinuousAt f a ↔ ∀ ε > 0, ∃ δ > 0, ∀ {x}, dist x a < δ → dist (f x) (f a) < ε := Metric.continuousAt_iff variable (r : ℝ) example : Metric.ball a r = { b | dist b a < r } := rfl example : Metric.closedBall a r = { b | dist b a ≤ r } := rfl example (hr : 0 < r) : a ∈ Metric.ball a r := Metric.mem_ball_self hr example (hr : 0 ≤ r) : a ∈ Metric.closedBall a r := Metric.mem_closedBall_self hr example (s : Set X) : IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, Metric.ball x ε ⊆ s := Metric.isOpen_iff example {s : Set X} : IsClosed s ↔ IsOpen (sᶜ) := isOpen_compl_iff.symm example {s : Set X} (hs : IsClosed s) {u : ℕ → X} (hu : Tendsto u atTop (𝓝 a)) (hus : ∀ n, u n ∈ s) : a ∈ s := hs.mem_of_tendsto hu (eventually_of_forall hus) example {s : Set X} : a ∈ closure s ↔ ∀ ε > 0, ∃ b ∈ s, a ∈ Metric.ball b ε := Metric.mem_closure_iff example {u : ℕ → X} (hu : Tendsto u atTop (𝓝 a)) {s : Set X} (hs : ∀ n, u n ∈ s) : a ∈ closure s := sorry example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ ε > 0, Metric.ball x ε ⊆ s := Metric.nhds_basis_ball.mem_iff example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ ε > 0, Metric.closedBall x ε ⊆ s := Metric.nhds_basis_closedBall.mem_iff example : IsCompact (Set.Icc 0 1 : Set ℝ) := isCompact_Icc example {s : Set X} (hs : IsCompact s) {u : ℕ → X} (hu : ∀ n, u n ∈ s) : ∃ a ∈ s, ∃ φ : ℕ → ℕ, StrictMono φ ∧ Tendsto (u ∘ φ) atTop (𝓝 a) := hs.tendsto_subseq hu example {s : Set X} (hs : IsCompact s) (hs' : s.Nonempty) {f : X → ℝ} (hfs : ContinuousOn f s) : ∃ x ∈ s, ∀ y ∈ s, f x ≤ f y := hs.exists_forall_le hs' hfs example {s : Set X} (hs : IsCompact s) (hs' : s.Nonempty) {f : X → ℝ} (hfs : ContinuousOn f s) : ∃ x ∈ s, ∀ y ∈ s, f y ≤ f x := hs.exists_forall_ge hs' hfs example {s : Set X} (hs : IsCompact s) : IsClosed s := hs.isClosed example {X : Type _} [MetricSpace X] [CompactSpace X] : IsCompact (univ : Set X) := isCompact_univ #check IsCompact.isClosed example {X : Type _} [MetricSpace X] {Y : Type _} [MetricSpace Y] {f : X → Y} : UniformContinuous f ↔ ∀ ε > 0, ∃ δ > 0, ∀ {a b : X}, dist a b < δ → dist (f a) (f b) < ε := Metric.uniformContinuous_iff example {X : Type _} [MetricSpace X] [CompactSpace X] {Y : Type _} [MetricSpace Y] {f : X → Y} (hf : Continuous f) : UniformContinuous f := sorry example (u : ℕ → X) : CauchySeq u ↔ ∀ ε > 0, ∃ N : ℕ, ∀ m ≥ N, ∀ n ≥ N, dist (u m) (u n) < ε := Metric.cauchySeq_iff example (u : ℕ → X) : CauchySeq u ↔ ∀ ε > 0, ∃ N : ℕ, ∀ n ≥ N, dist (u n) (u N) < ε := Metric.cauchySeq_iff' example [CompleteSpace X] (u : ℕ → X) (hu : CauchySeq u) : ∃ x, Tendsto u atTop (𝓝 x) := cauchySeq_tendsto_of_complete hu open BigOperators open Finset theorem cauchySeq_of_le_geometric_two' {u : ℕ → X} (hu : ∀ n : ℕ, dist (u n) (u (n + 1)) ≤ (1 / 2) ^ n) : CauchySeq u := by rw [Metric.cauchySeq_iff'] intro ε ε_pos obtain ⟨N, hN⟩ : ∃ N : ℕ, 1 / 2 ^ N * 2 < ε := by sorry use N intro n hn obtain ⟨k, rfl : n = N + k⟩ := le_iff_exists_add.mp hn calc dist (u (N + k)) (u N) = dist (u (N + 0)) (u (N + k)) := sorry _ ≤ ∑ i in range k, dist (u (N + i)) (u (N + (i + 1))) := sorry _ ≤ ∑ i in range k, (1 / 2 : ℝ) ^ (N + i) := sorry _ = 1 / 2 ^ N * ∑ i in range k, (1 / 2) ^ i := sorry _ ≤ 1 / 2 ^ N * 2 := sorry _ < ε := sorry open Metric example [CompleteSpace X] (f : ℕ → Set X) (ho : ∀ n, IsOpen (f n)) (hd : ∀ n, Dense (f n)) : Dense (⋂ n, f n) := by let B : ℕ → ℝ := fun n => (1 / 2) ^ n have Bpos : ∀ n, 0 < B n sorry /- Translate the density assumption into two functions `center` and `radius` associating to any n, x, δ, δpos a center and a positive radius such that `closedBall center radius` is included both in `f n` and in `closedBall x δ`. We can also require `radius ≤ (1/2)^(n+1)`, to ensure we get a Cauchy sequence later. -/ have : ∀ (n : ℕ) (x : X), ∀ δ > 0, ∃ y : X, ∃ r > 0, r ≤ B (n + 1) ∧ closedBall y r ⊆ closedBall x δ ∩ f n := by sorry choose! center radius Hpos HB Hball using this intro x rw [mem_closure_iff_nhds_basis nhds_basis_closedBall] intro ε εpos /- `ε` is positive. We have to find a point in the ball of radius `ε` around `x` belonging to all `f n`. For this, we construct inductively a sequence `F n = (c n, r n)` such that the closed ball `closedBall (c n) (r n)` is included in the previous ball and in `f n`, and such that `r n` is small enough to ensure that `c n` is a Cauchy sequence. Then `c n` converges to a limit which belongs to all the `f n`. -/ let F : ℕ → X × ℝ := fun n => Nat.recOn n (Prod.mk x (min ε (B 0))) fun n p => Prod.mk (center n p.1 p.2) (radius n p.1 p.2) let c : ℕ → X := fun n => (F n).1 let r : ℕ → ℝ := fun n => (F n).2 have rpos : ∀ n, 0 < r n := by sorry have rB : ∀ n, r n ≤ B n := by sorry have incl : ∀ n, closedBall (c (n + 1)) (r (n + 1)) ⊆ closedBall (c n) (r n) ∩ f n := by sorry have cdist : ∀ n, dist (c n) (c (n + 1)) ≤ B n := by sorry have : CauchySeq c := cauchySeq_of_le_geometric_two' cdist -- as the sequence `c n` is Cauchy in a complete space, it converges to a limit `y`. rcases cauchySeq_tendsto_of_complete this with ⟨y, ylim⟩ -- this point `y` will be the desired point. We will check that it belongs to all -- `f n` and to `ball x ε`. use y have I : ∀ n, ∀ m ≥ n, closedBall (c m) (r m) ⊆ closedBall (c n) (r n) := by sorry have yball : ∀ n, y ∈ closedBall (c n) (r n) := by sorry sorry
-
-
-
@@ -1,151 +0,0 @@import Mathlib.Topology.Instances.Real import Mathlib.Analysis.NormedSpace.BanachSteinhaus open Set Filter open Topology Filter section variable {X : Type _} [TopologicalSpace X] example : IsOpen (univ : Set X) := isOpen_univ example : IsOpen (∅ : Set X) := isOpen_empty example {ι : Type _} {s : ι → Set X} (hs : ∀ i, IsOpen <| s i) : IsOpen (⋃ i, s i) := isOpen_iUnion hs example {ι : Type _} [Fintype ι] {s : ι → Set X} (hs : ∀ i, IsOpen <| s i) : IsOpen (⋂ i, s i) := isOpen_iInter hs variable {Y : Type _} [TopologicalSpace Y] example {f : X → Y} : Continuous f ↔ ∀ s, IsOpen s → IsOpen (f ⁻¹' s) := continuous_def example {f : X → Y} {x : X} : ContinuousAt f x ↔ map f (𝓝 x) ≤ 𝓝 (f x) := Iff.rfl example {f : X → Y} {x : X} : ContinuousAt f x ↔ ∀ U ∈ 𝓝 (f x), ∀ᶠ x in 𝓝 x, f x ∈ U := Iff.rfl example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ t, t ⊆ s ∧ IsOpen t ∧ x ∈ t := mem_nhds_iff example (x : X) : pure x ≤ 𝓝 x := pure_le_nhds x example (x : X) (P : X → Prop) (h : ∀ᶠ y in 𝓝 x, P y) : P x := pure_le_nhds x h example {P : X → Prop} {x : X} (h : ∀ᶠ y in 𝓝 x, P y) : ∀ᶠ y in 𝓝 x, ∀ᶠ z in 𝓝 y, P z := eventually_eventually_nhds.mpr h #check TopologicalSpace.mkOfNhds #check TopologicalSpace.nhds_mkOfNhds example {α : Type _} (n : α → Filter α) (H₀ : ∀ a, pure a ≤ n a) (H : ∀ a : α, ∀ p : α → Prop, (∀ᶠ x in n a, p x) → ∀ᶠ y in n a, ∀ᶠ x in n y, p x) : ∀ a, ∀ s ∈ n a, ∃ t ∈ n a, t ⊆ s ∧ ∀ a' ∈ t, s ∈ n a' := sorry end -- BOTH. variable {X Y : Type _} example (f : X → Y) : TopologicalSpace X → TopologicalSpace Y := TopologicalSpace.coinduced f example (f : X → Y) : TopologicalSpace Y → TopologicalSpace X := TopologicalSpace.induced f example (f : X → Y) (T_X : TopologicalSpace X) (T_Y : TopologicalSpace Y) : TopologicalSpace.coinduced f T_X ≤ T_Y ↔ T_X ≤ TopologicalSpace.induced f T_Y := coinduced_le_iff_le_induced #check coinduced_compose #check induced_compose example {T T' : TopologicalSpace X} : T ≤ T' ↔ ∀ s, T'.IsOpen s → T.IsOpen s := Iff.rfl example (T_X : TopologicalSpace X) (T_Y : TopologicalSpace Y) (f : X → Y) : Continuous f ↔ TopologicalSpace.coinduced f T_X ≤ T_Y := continuous_iff_coinduced_le example {Z : Type _} (f : X → Y) (T_X : TopologicalSpace X) (T_Z : TopologicalSpace Z) (g : Y → Z) : @Continuous Y Z (TopologicalSpace.coinduced f T_X) T_Z g ↔ @Continuous X Z T_X T_Z (g ∘ f) := by rw [continuous_iff_coinduced_le, coinduced_compose, continuous_iff_coinduced_le] example (ι : Type _) (X : ι → Type _) (T_X : ∀ i, TopologicalSpace <| X i) : (Pi.topologicalSpace : TopologicalSpace (∀ i, X i)) = ⨅ i, TopologicalSpace.induced (fun x => x i) (T_X i) := rfl example [TopologicalSpace X] [T2Space X] {u : ℕ → X} {a b : X} (ha : Tendsto u atTop (𝓝 a)) (hb : Tendsto u atTop (𝓝 b)) : a = b := tendsto_nhds_unique ha hb example [TopologicalSpace X] [RegularSpace X] (a : X) : (𝓝 a).HasBasis (fun s : Set X => s ∈ 𝓝 a ∧ IsClosed s) id := closed_nhds_basis a example [TopologicalSpace X] {x : X} : (𝓝 x).HasBasis (fun t : Set X => t ∈ 𝓝 x ∧ IsOpen t) id := nhds_basis_opens' x theorem aux {X Y A : Type _} [TopologicalSpace X] {c : A → X} {f : A → Y} {x : X} {F : Filter Y} (h : Tendsto f (comap c (𝓝 x)) F) {V' : Set Y} (V'_in : V' ∈ F) : ∃ V ∈ 𝓝 x, IsOpen V ∧ c ⁻¹' V ⊆ f ⁻¹' V' := sorry example [TopologicalSpace X] [TopologicalSpace Y] [RegularSpace Y] {A : Set X} (hA : ∀ x, x ∈ closure A) {f : A → Y} (f_cont : Continuous f) (hf : ∀ x : X, ∃ c : Y, Tendsto f (comap (↑) <| 𝓝 x) <| 𝓝 c) : ∃ φ : X → Y, Continuous φ ∧ ∀ a : A, φ a = f a := sorry #check @HasBasis.tendsto_right_iff example [TopologicalSpace X] [TopologicalSpace.FirstCountableTopology X] {s : Set X} {a : X} : a ∈ closure s ↔ ∃ u : ℕ → X, (∀ n, u n ∈ s) ∧ Tendsto u atTop (𝓝 a) := mem_closure_iff_seq_limit variable [TopologicalSpace X] example {F : Filter X} {x : X} : ClusterPt x F ↔ NeBot (𝓝 x ⊓ F) := Iff.rfl example {s : Set X} : IsCompact s ↔ ∀ (F : Filter X) [NeBot F], F ≤ 𝓟 s → ∃ a ∈ s, ClusterPt a F := Iff.rfl example [TopologicalSpace.FirstCountableTopology X] {s : Set X} {u : ℕ → X} (hs : IsCompact s) (hu : ∀ n, u n ∈ s) : ∃ a ∈ s, ∃ φ : ℕ → ℕ, StrictMono φ ∧ Tendsto (u ∘ φ) atTop (𝓝 a) := hs.tendsto_subseq hu variable [TopologicalSpace Y] example {x : X} {F : Filter X} {G : Filter Y} (H : ClusterPt x F) {f : X → Y} (hfx : ContinuousAt f x) (hf : Tendsto f F G) : ClusterPt (f x) G := ClusterPt.map H hfx hf example [TopologicalSpace Y] {f : X → Y} (hf : Continuous f) {s : Set X} (hs : IsCompact s) : IsCompact (f '' s) := by intro F F_ne F_le have map_eq : map f (𝓟 s ⊓ comap f F) = 𝓟 (f '' s) ⊓ F := by sorry have Hne : (𝓟 s ⊓ comap f F).NeBot := by sorry have Hle : 𝓟 s ⊓ comap f F ≤ 𝓟 s := inf_le_left sorry example {ι : Type _} {s : Set X} (hs : IsCompact s) (U : ι → Set X) (hUo : ∀ i, IsOpen (U i)) (hsU : s ⊆ ⋃ i, U i) : ∃ t : Finset ι, s ⊆ ⋃ i ∈ t, U i := hs.elim_finite_subcover U hUo hsU example [CompactSpace X] : IsCompact (univ : Set X) := isCompact_univ
-
-
-
@@ -1,71 +0,0 @@import Mathlib.Topology.Instances.Real open Set Filter Topology -- In the next example we could use `tauto` in each proof instead of knowing the lemmas example {α : Type _} (s : Set α) : Filter α := { sets := { t | s ⊆ t } univ_sets := subset_univ s sets_of_superset := fun hU hUV => Subset.trans hU hUV inter_sets := fun hU hV => subset_inter hU hV } example : Filter ℕ := { sets := { s | ∃ a, ∀ b, a ≤ b → b ∈ s } univ_sets := by use 42 simp sets_of_superset := by rintro U V ⟨N, hN⟩ hUV use N tauto inter_sets := by rintro U V ⟨N, hN⟩ ⟨N', hN'⟩ use max N N' intro b hb rw [max_le_iff] at hb constructor <;> tauto } def Tendsto₁ {X Y : Type _} (f : X → Y) (F : Filter X) (G : Filter Y) := ∀ V ∈ G, f ⁻¹' V ∈ F example {X Y Z : Type _} {F : Filter X} {G : Filter Y} {H : Filter Z} {f : X → Y} {g : Y → Z} (hf : Tendsto₁ f F G) (hg : Tendsto₁ g G H) : Tendsto₁ (g ∘ f) F H := calc map (g ∘ f) F = map g (map f F) := by rw [map_map] _ ≤ map g G := (map_mono hf) _ ≤ H := hg example {X Y Z : Type _} {F : Filter X} {G : Filter Y} {H : Filter Z} {f : X → Y} {g : Y → Z} (hf : Tendsto₁ f F G) (hg : Tendsto₁ g G H) : Tendsto₁ (g ∘ f) F H := by intro V hV rw [preimage_comp] apply hf apply hg exact hV example (f : ℕ → ℝ × ℝ) (x₀ y₀ : ℝ) : Tendsto f atTop (𝓝 (x₀, y₀)) ↔ Tendsto (Prod.fst ∘ f) atTop (𝓝 x₀) ∧ Tendsto (Prod.snd ∘ f) atTop (𝓝 y₀) := calc Tendsto f atTop (𝓝 (x₀, y₀)) ↔ map f atTop ≤ 𝓝 (x₀, y₀) := Iff.rfl _ ↔ map f atTop ≤ 𝓝 x₀ ×ᶠ 𝓝 y₀ := by rw [nhds_prod_eq] _ ↔ map f atTop ≤ comap Prod.fst (𝓝 x₀) ⊓ comap Prod.snd (𝓝 y₀) := Iff.rfl _ ↔ map f atTop ≤ comap Prod.fst (𝓝 x₀) ∧ map f atTop ≤ comap Prod.snd (𝓝 y₀) := le_inf_iff _ ↔ map Prod.fst (map f atTop) ≤ 𝓝 x₀ ∧ map Prod.snd (map f atTop) ≤ 𝓝 y₀ := by rw [← map_le_iff_le_comap, ← map_le_iff_le_comap] _ ↔ map (Prod.fst ∘ f) atTop ≤ 𝓝 x₀ ∧ map (Prod.snd ∘ f) atTop ≤ 𝓝 y₀ := by rw [map_map, map_map] -- an alternative solution example (f : ℕ → ℝ × ℝ) (x₀ y₀ : ℝ) : Tendsto f atTop (𝓝 (x₀, y₀)) ↔ Tendsto (Prod.fst ∘ f) atTop (𝓝 x₀) ∧ Tendsto (Prod.snd ∘ f) atTop (𝓝 y₀) := by rw [nhds_prod_eq] unfold Tendsto Filter.prod rw [le_inf_iff, ← map_le_iff_le_comap, map_map, ← map_le_iff_le_comap, map_map] example (u : ℕ → ℝ) (M : Set ℝ) (x : ℝ) (hux : Tendsto u atTop (𝓝 x)) (huM : ∀ᶠ n in atTop, u n ∈ M) : x ∈ closure M := mem_closure_iff_clusterPt.mpr (neBot_of_le <| le_inf hux <| le_principal_iff.mpr huM)
-
-
-
@@ -1,365 +0,0 @@import Mathlib.Topology.Instances.Real import Mathlib.Analysis.NormedSpace.BanachSteinhaus open Set Filter open Topology Filter variable {X : Type _} [MetricSpace X] (a b c : X) #check (dist a b : ℝ) #check (dist_nonneg : 0 ≤ dist a b) #check (dist_eq_zero : dist a b = 0 ↔ a = b) #check (dist_comm a b : dist a b = dist b a) #check (dist_triangle a b c : dist a c ≤ dist a b + dist b c) -- Note the next three lines are not quoted, their purpose is to make sure those things don't get renamed while we're looking elsewhere. #check EMetricSpace #check PseudoMetricSpace #check PseudoEMetricSpace example {u : ℕ → X} {a : X} : Tendsto u atTop (𝓝 a) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, dist (u n) a < ε := Metric.tendsto_atTop example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} : Continuous f ↔ ∀ x : X, ∀ ε > 0, ∃ δ > 0, ∀ x', dist x' x < δ → dist (f x') (f x) < ε := Metric.continuous_iff example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : Continuous fun p : X × X => dist (f p.1) (f p.2) := by continuity example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : Continuous fun p : X × X => dist (f p.1) (f p.2) := continuous_dist.comp ((hf.comp continuous_fst).prod_mk (hf.comp continuous_snd)) example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : Continuous fun p : X × X => dist (f p.1) (f p.2) := by apply Continuous.dist exact hf.comp continuous_fst exact hf.comp continuous_snd example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : Continuous fun p : X × X => dist (f p.1) (f p.2) := (hf.comp continuous_fst).dist (hf.comp continuous_snd) example {X Y : Type _} [MetricSpace X] [MetricSpace Y] {f : X → Y} (hf : Continuous f) : Continuous fun p : X × X => dist (f p.1) (f p.2) := hf.fst'.dist hf.snd' example {f : ℝ → X} (hf : Continuous f) : Continuous fun x : ℝ => f (x ^ 2 + x) := sorry example {f : ℝ → X} (hf : Continuous f) : Continuous fun x : ℝ => f (x ^ 2 + x) := hf.comp <| (continuous_pow 2).add continuous_id example {X Y : Type _} [MetricSpace X] [MetricSpace Y] (f : X → Y) (a : X) : ContinuousAt f a ↔ ∀ ε > 0, ∃ δ > 0, ∀ {x}, dist x a < δ → dist (f x) (f a) < ε := Metric.continuousAt_iff variable (r : ℝ) example : Metric.ball a r = { b | dist b a < r } := rfl example : Metric.closedBall a r = { b | dist b a ≤ r } := rfl example (hr : 0 < r) : a ∈ Metric.ball a r := Metric.mem_ball_self hr example (hr : 0 ≤ r) : a ∈ Metric.closedBall a r := Metric.mem_closedBall_self hr example (s : Set X) : IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, Metric.ball x ε ⊆ s := Metric.isOpen_iff example {s : Set X} : IsClosed s ↔ IsOpen (sᶜ) := isOpen_compl_iff.symm example {s : Set X} (hs : IsClosed s) {u : ℕ → X} (hu : Tendsto u atTop (𝓝 a)) (hus : ∀ n, u n ∈ s) : a ∈ s := hs.mem_of_tendsto hu (eventually_of_forall hus) example {s : Set X} : a ∈ closure s ↔ ∀ ε > 0, ∃ b ∈ s, a ∈ Metric.ball b ε := Metric.mem_closure_iff example {u : ℕ → X} (hu : Tendsto u atTop (𝓝 a)) {s : Set X} (hs : ∀ n, u n ∈ s) : a ∈ closure s := sorry example {u : ℕ → X} (hu : Tendsto u atTop (𝓝 a)) {s : Set X} (hs : ∀ n, u n ∈ s) : a ∈ closure s := by rw [Metric.tendsto_atTop] at hu rw [Metric.mem_closure_iff] intro ε ε_pos rcases hu ε ε_pos with ⟨N, hN⟩ refine' ⟨u N, hs _, _⟩ rw [dist_comm] exact hN N le_rfl example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ ε > 0, Metric.ball x ε ⊆ s := Metric.nhds_basis_ball.mem_iff example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ ε > 0, Metric.closedBall x ε ⊆ s := Metric.nhds_basis_closedBall.mem_iff example : IsCompact (Set.Icc 0 1 : Set ℝ) := isCompact_Icc example {s : Set X} (hs : IsCompact s) {u : ℕ → X} (hu : ∀ n, u n ∈ s) : ∃ a ∈ s, ∃ φ : ℕ → ℕ, StrictMono φ ∧ Tendsto (u ∘ φ) atTop (𝓝 a) := hs.tendsto_subseq hu example {s : Set X} (hs : IsCompact s) (hs' : s.Nonempty) {f : X → ℝ} (hfs : ContinuousOn f s) : ∃ x ∈ s, ∀ y ∈ s, f x ≤ f y := hs.exists_forall_le hs' hfs example {s : Set X} (hs : IsCompact s) (hs' : s.Nonempty) {f : X → ℝ} (hfs : ContinuousOn f s) : ∃ x ∈ s, ∀ y ∈ s, f y ≤ f x := hs.exists_forall_ge hs' hfs example {s : Set X} (hs : IsCompact s) : IsClosed s := hs.isClosed example {X : Type _} [MetricSpace X] [CompactSpace X] : IsCompact (univ : Set X) := isCompact_univ #check IsCompact.isClosed example {X : Type _} [MetricSpace X] {Y : Type _} [MetricSpace Y] {f : X → Y} : UniformContinuous f ↔ ∀ ε > 0, ∃ δ > 0, ∀ {a b : X}, dist a b < δ → dist (f a) (f b) < ε := Metric.uniformContinuous_iff example {X : Type _} [MetricSpace X] [CompactSpace X] {Y : Type _} [MetricSpace Y] {f : X → Y} (hf : Continuous f) : UniformContinuous f := sorry example {X : Type _} [MetricSpace X] [CompactSpace X] {Y : Type _} [MetricSpace Y] {f : X → Y} (hf : Continuous f) : UniformContinuous f := by rw [Metric.uniformContinuous_iff] intro ε ε_pos let φ : X × X → ℝ := fun p => dist (f p.1) (f p.2) have φ_cont : Continuous φ := hf.fst'.dist hf.snd' let K := { p : X × X | ε ≤ φ p } have K_closed : IsClosed K := isClosed_le continuous_const φ_cont have K_cpct : IsCompact K := K_closed.isCompact cases' eq_empty_or_nonempty K with hK hK · use 1, by norm_num intro x y _ have : (x, y) ∉ K := by simp [hK] simpa using this · rcases K_cpct.exists_forall_le hK continuous_dist.continuousOn with ⟨⟨x₀, x₁⟩, xx_in, H⟩ use dist x₀ x₁ constructor · change _ < _ rw [dist_pos] intro h have : ε ≤ 0 := by simpa [*] using xx_in linarith · intro x x' contrapose! intro hxx' exact H (x, x') hxx' example (u : ℕ → X) : CauchySeq u ↔ ∀ ε > 0, ∃ N : ℕ, ∀ m ≥ N, ∀ n ≥ N, dist (u m) (u n) < ε := Metric.cauchySeq_iff example (u : ℕ → X) : CauchySeq u ↔ ∀ ε > 0, ∃ N : ℕ, ∀ n ≥ N, dist (u n) (u N) < ε := Metric.cauchySeq_iff' example [CompleteSpace X] (u : ℕ → X) (hu : CauchySeq u) : ∃ x, Tendsto u atTop (𝓝 x) := cauchySeq_tendsto_of_complete hu open BigOperators open Finset theorem cauchySeq_of_le_geometric_two' {u : ℕ → X} (hu : ∀ n : ℕ, dist (u n) (u (n + 1)) ≤ (1 / 2) ^ n) : CauchySeq u := by rw [Metric.cauchySeq_iff'] intro ε ε_pos obtain ⟨N, hN⟩ : ∃ N : ℕ, 1 / 2 ^ N * 2 < ε := by sorry use N intro n hn obtain ⟨k, rfl : n = N + k⟩ := le_iff_exists_add.mp hn calc dist (u (N + k)) (u N) = dist (u (N + 0)) (u (N + k)) := sorry _ ≤ ∑ i in range k, dist (u (N + i)) (u (N + (i + 1))) := sorry _ ≤ ∑ i in range k, (1 / 2 : ℝ) ^ (N + i) := sorry _ = 1 / 2 ^ N * ∑ i in range k, (1 / 2) ^ i := sorry _ ≤ 1 / 2 ^ N * 2 := sorry _ < ε := sorry example {u : ℕ → X} (hu : ∀ n : ℕ, dist (u n) (u (n + 1)) ≤ (1 / 2) ^ n) : CauchySeq u := by rw [Metric.cauchySeq_iff'] intro ε ε_pos obtain ⟨N, hN⟩ : ∃ N : ℕ, 1 / 2 ^ N * 2 < ε := by have : Tendsto (fun N : ℕ => (1 / 2 ^ N * 2 : ℝ)) atTop (𝓝 0) := by rw [← MulZeroClass.zero_mul (2 : ℝ)] apply Tendsto.mul simp_rw [← one_div_pow (2 : ℝ)] apply tendsto_pow_atTop_nhds_0_of_lt_1 <;> linarith exact tendsto_const_nhds rcases(atTop_basis.tendsto_iff (nhds_basis_Ioo_pos (0 : ℝ))).mp this ε ε_pos with ⟨N, _, hN⟩ exact ⟨N, by simpa using (hN N left_mem_Ici).2⟩ use N intro n hn obtain ⟨k, rfl : n = N + k⟩ := le_iff_exists_add.mp hn calc dist (u (N + k)) (u N) = dist (u (N + 0)) (u (N + k)) := by rw [dist_comm, add_zero] _ ≤ ∑ i in range k, dist (u (N + i)) (u (N + (i + 1))) := (dist_le_range_sum_dist (fun i => u (N + i)) k) _ ≤ ∑ i in range k, (1 / 2 : ℝ) ^ (N + i) := (sum_le_sum fun i _ => hu <| N + i) _ = 1 / 2 ^ N * ∑ i in range k, (1 / 2 : ℝ) ^ i := by simp_rw [← one_div_pow, pow_add, ← mul_sum] _ ≤ 1 / 2 ^ N * 2 := (mul_le_mul_of_nonneg_left (sum_geometric_two_le _) (one_div_nonneg.mpr (pow_nonneg (zero_le_two : (0 : ℝ) ≤ 2) _))) _ < ε := hN open Metric example [CompleteSpace X] (f : ℕ → Set X) (ho : ∀ n, IsOpen (f n)) (hd : ∀ n, Dense (f n)) : Dense (⋂ n, f n) := by let B : ℕ → ℝ := fun n => (1 / 2) ^ n have Bpos : ∀ n, 0 < B n sorry /- Translate the density assumption into two functions `center` and `radius` associating to any n, x, δ, δpos a center and a positive radius such that `closedBall center radius` is included both in `f n` and in `closedBall x δ`. We can also require `radius ≤ (1/2)^(n+1)`, to ensure we get a Cauchy sequence later. -/ have : ∀ (n : ℕ) (x : X), ∀ δ > 0, ∃ y : X, ∃ r > 0, r ≤ B (n + 1) ∧ closedBall y r ⊆ closedBall x δ ∩ f n := by sorry choose! center radius Hpos HB Hball using this intro x rw [mem_closure_iff_nhds_basis nhds_basis_closedBall] intro ε εpos /- `ε` is positive. We have to find a point in the ball of radius `ε` around `x` belonging to all `f n`. For this, we construct inductively a sequence `F n = (c n, r n)` such that the closed ball `closedBall (c n) (r n)` is included in the previous ball and in `f n`, and such that `r n` is small enough to ensure that `c n` is a Cauchy sequence. Then `c n` converges to a limit which belongs to all the `f n`. -/ let F : ℕ → X × ℝ := fun n => Nat.recOn n (Prod.mk x (min ε (B 0))) fun n p => Prod.mk (center n p.1 p.2) (radius n p.1 p.2) let c : ℕ → X := fun n => (F n).1 let r : ℕ → ℝ := fun n => (F n).2 have rpos : ∀ n, 0 < r n := by sorry have rB : ∀ n, r n ≤ B n := by sorry have incl : ∀ n, closedBall (c (n + 1)) (r (n + 1)) ⊆ closedBall (c n) (r n) ∩ f n := by sorry have cdist : ∀ n, dist (c n) (c (n + 1)) ≤ B n := by sorry have : CauchySeq c := cauchySeq_of_le_geometric_two' cdist -- as the sequence `c n` is Cauchy in a complete space, it converges to a limit `y`. rcases cauchySeq_tendsto_of_complete this with ⟨y, ylim⟩ -- this point `y` will be the desired point. We will check that it belongs to all -- `f n` and to `ball x ε`. use y have I : ∀ n, ∀ m ≥ n, closedBall (c m) (r m) ⊆ closedBall (c n) (r n) := by sorry have yball : ∀ n, y ∈ closedBall (c n) (r n) := by sorry sorry example [CompleteSpace X] (f : ℕ → Set X) (ho : ∀ n, IsOpen (f n)) (hd : ∀ n, Dense (f n)) : Dense (⋂ n, f n) := by let B : ℕ → ℝ := fun n => (1 / 2) ^ n have Bpos : ∀ n, 0 < B n := fun n => pow_pos sorry n /- Translate the density assumption into two functions `center` and `radius` associating to any n, x, δ, δpos a center and a positive radius such that `closedBall center radius` is included both in `f n` and in `closedBall x δ`. We can also require `radius ≤ (1/2)^(n+1)`, to ensure we get a Cauchy sequence later. -/ have : ∀ (n : ℕ) (x : X), ∀ δ > 0, ∃ y : X, ∃ r > 0, r ≤ B (n + 1) ∧ closedBall y r ⊆ closedBall x δ ∩ f n := by intro n x δ δpos have : x ∈ closure (f n) := hd n x rcases Metric.mem_closure_iff.1 this (δ / 2) (half_pos δpos) with ⟨y, ys, xy⟩ rw [dist_comm] at xy obtain ⟨r, rpos, hr⟩ : ∃ r > 0, closedBall y r ⊆ f n := nhds_basis_closedBall.mem_iff.1 (isOpen_iff_mem_nhds.1 (ho n) y ys) refine' ⟨y, min (min (δ / 2) r) (B (n + 1)), _, _, fun z hz => ⟨_, _⟩⟩ show 0 < min (min (δ / 2) r) (B (n + 1)) exact lt_min (lt_min (half_pos δpos) rpos) (Bpos (n + 1)) show min (min (δ / 2) r) (B (n + 1)) ≤ B (n + 1) exact min_le_right _ _ show z ∈ closedBall x δ exact calc dist z x ≤ dist z y + dist y x := dist_triangle _ _ _ _ ≤ min (min (δ / 2) r) (B (n + 1)) + δ / 2 := (add_le_add hz xy.le) _ ≤ δ / 2 + δ / 2 := (add_le_add_right ((min_le_left _ _).trans (min_le_left _ _)) _) _ = δ := add_halves δ show z ∈ f n exact hr (calc dist z y ≤ min (min (δ / 2) r) (B (n + 1)) := hz _ ≤ r := (min_le_left _ _).trans (min_le_right _ _) ) choose! center radius Hpos HB Hball using this refine' fun x => (mem_closure_iff_nhds_basis nhds_basis_closedBall).2 fun ε εpos => _ /- `ε` is positive. We have to find a point in the ball of radius `ε` around `x` belonging to all `f n`. For this, we construct inductively a sequence `F n = (c n, r n)` such that the closed ball `closedBall (c n) (r n)` is included in the previous ball and in `f n`, and such that `r n` is small enough to ensure that `c n` is a Cauchy sequence. Then `c n` converges to a limit which belongs to all the `f n`. -/ let F : ℕ → X × ℝ := fun n => Nat.recOn n (Prod.mk x (min ε (B 0))) fun n p => Prod.mk (center n p.1 p.2) (radius n p.1 p.2) let c : ℕ → X := fun n => (F n).1 let r : ℕ → ℝ := fun n => (F n).2 have rpos : ∀ n, 0 < r n := by intro n induction' n with n hn exact lt_min εpos (Bpos 0) exact Hpos n (c n) (r n) hn have rB : ∀ n, r n ≤ B n := by intro n induction' n with n hn exact min_le_right _ _ exact HB n (c n) (r n) (rpos n) have incl : ∀ n, closedBall (c (n + 1)) (r (n + 1)) ⊆ closedBall (c n) (r n) ∩ f n := fun n => Hball n (c n) (r n) (rpos n) have cdist : ∀ n, dist (c n) (c (n + 1)) ≤ B n := by intro n rw [dist_comm] have A : c (n + 1) ∈ closedBall (c (n + 1)) (r (n + 1)) := mem_closedBall_self (rpos <| n + 1).le have I := calc closedBall (c (n + 1)) (r (n + 1)) ⊆ closedBall (c n) (r n) := (incl n).trans (inter_subset_left _ _) _ ⊆ closedBall (c n) (B n) := closedBall_subset_closedBall (rB n) exact I A have : CauchySeq c := cauchySeq_of_le_geometric_two' cdist -- as the sequence `c n` is Cauchy in a complete space, it converges to a limit `y`. rcases cauchySeq_tendsto_of_complete this with ⟨y, ylim⟩ -- this point `y` will be the desired point. We will check that it belongs to all -- `f n` and to `ball x ε`. use y have I : ∀ n, ∀ m ≥ n, closedBall (c m) (r m) ⊆ closedBall (c n) (r n) := by intro n refine' Nat.le_induction _ fun m hnm h => _ · exact Subset.rfl · exact (incl m).trans ((Set.inter_subset_left _ _).trans h) have yball : ∀ n, y ∈ closedBall (c n) (r n) := by intro n refine' isClosed_ball.mem_of_tendsto ylim _ refine' (Filter.eventually_ge_atTop n).mono fun m hm => _ exact I n m hm (mem_closedBall_self (rpos _).le) constructor · suffices ∀ n, y ∈ f n by rwa [Set.mem_iInter] intro n have : closedBall (c (n + 1)) (r (n + 1)) ⊆ f n := Subset.trans (incl n) (inter_subset_right _ _) exact this (yball (n + 1)) calc dist y x ≤ r 0 := yball 0 _ ≤ ε := min_le_left _ _
-
-
-
@@ -1,202 +0,0 @@import Mathlib.Topology.Instances.Real import Mathlib.Analysis.NormedSpace.BanachSteinhaus open Set Filter open Topology Filter section variable {X : Type _} [TopologicalSpace X] example : IsOpen (univ : Set X) := isOpen_univ example : IsOpen (∅ : Set X) := isOpen_empty example {ι : Type _} {s : ι → Set X} (hs : ∀ i, IsOpen <| s i) : IsOpen (⋃ i, s i) := isOpen_iUnion hs example {ι : Type _} [Fintype ι] {s : ι → Set X} (hs : ∀ i, IsOpen <| s i) : IsOpen (⋂ i, s i) := isOpen_iInter hs variable {Y : Type _} [TopologicalSpace Y] example {f : X → Y} : Continuous f ↔ ∀ s, IsOpen s → IsOpen (f ⁻¹' s) := continuous_def example {f : X → Y} {x : X} : ContinuousAt f x ↔ map f (𝓝 x) ≤ 𝓝 (f x) := Iff.rfl example {f : X → Y} {x : X} : ContinuousAt f x ↔ ∀ U ∈ 𝓝 (f x), ∀ᶠ x in 𝓝 x, f x ∈ U := Iff.rfl example {x : X} {s : Set X} : s ∈ 𝓝 x ↔ ∃ t, t ⊆ s ∧ IsOpen t ∧ x ∈ t := mem_nhds_iff example (x : X) : pure x ≤ 𝓝 x := pure_le_nhds x example (x : X) (P : X → Prop) (h : ∀ᶠ y in 𝓝 x, P y) : P x := pure_le_nhds x h example {P : X → Prop} {x : X} (h : ∀ᶠ y in 𝓝 x, P y) : ∀ᶠ y in 𝓝 x, ∀ᶠ z in 𝓝 y, P z := eventually_eventually_nhds.mpr h #check TopologicalSpace.mkOfNhds #check TopologicalSpace.nhds_mkOfNhds example {α : Type _} (n : α → Filter α) (H₀ : ∀ a, pure a ≤ n a) (H : ∀ a : α, ∀ p : α → Prop, (∀ᶠ x in n a, p x) → ∀ᶠ y in n a, ∀ᶠ x in n y, p x) : ∀ a, ∀ s ∈ n a, ∃ t ∈ n a, t ⊆ s ∧ ∀ a' ∈ t, s ∈ n a' := sorry example {α : Type _} (n : α → Filter α) (H₀ : ∀ a, pure a ≤ n a) (H : ∀ a : α, ∀ p : α → Prop, (∀ᶠ x in n a, p x) → ∀ᶠ y in n a, ∀ᶠ x in n y, p x) : ∀ a, ∀ s ∈ n a, ∃ t ∈ n a, t ⊆ s ∧ ∀ a' ∈ t, s ∈ n a' := by intro a s s_in refine' ⟨{ y | s ∈ n y }, H a (fun x => x ∈ s) s_in, _, by tauto⟩ rintro y (hy : s ∈ n y) exact H₀ y hy end -- BOTH. variable {X Y : Type _} example (f : X → Y) : TopologicalSpace X → TopologicalSpace Y := TopologicalSpace.coinduced f example (f : X → Y) : TopologicalSpace Y → TopologicalSpace X := TopologicalSpace.induced f example (f : X → Y) (T_X : TopologicalSpace X) (T_Y : TopologicalSpace Y) : TopologicalSpace.coinduced f T_X ≤ T_Y ↔ T_X ≤ TopologicalSpace.induced f T_Y := coinduced_le_iff_le_induced #check coinduced_compose #check induced_compose example {T T' : TopologicalSpace X} : T ≤ T' ↔ ∀ s, T'.IsOpen s → T.IsOpen s := Iff.rfl example (T_X : TopologicalSpace X) (T_Y : TopologicalSpace Y) (f : X → Y) : Continuous f ↔ TopologicalSpace.coinduced f T_X ≤ T_Y := continuous_iff_coinduced_le example {Z : Type _} (f : X → Y) (T_X : TopologicalSpace X) (T_Z : TopologicalSpace Z) (g : Y → Z) : @Continuous Y Z (TopologicalSpace.coinduced f T_X) T_Z g ↔ @Continuous X Z T_X T_Z (g ∘ f) := by rw [continuous_iff_coinduced_le, coinduced_compose, continuous_iff_coinduced_le] example (ι : Type _) (X : ι → Type _) (T_X : ∀ i, TopologicalSpace <| X i) : (Pi.topologicalSpace : TopologicalSpace (∀ i, X i)) = ⨅ i, TopologicalSpace.induced (fun x => x i) (T_X i) := rfl example [TopologicalSpace X] [T2Space X] {u : ℕ → X} {a b : X} (ha : Tendsto u atTop (𝓝 a)) (hb : Tendsto u atTop (𝓝 b)) : a = b := tendsto_nhds_unique ha hb example [TopologicalSpace X] [RegularSpace X] (a : X) : (𝓝 a).HasBasis (fun s : Set X => s ∈ 𝓝 a ∧ IsClosed s) id := closed_nhds_basis a example [TopologicalSpace X] {x : X} : (𝓝 x).HasBasis (fun t : Set X => t ∈ 𝓝 x ∧ IsOpen t) id := nhds_basis_opens' x theorem aux {X Y A : Type _} [TopologicalSpace X] {c : A → X} {f : A → Y} {x : X} {F : Filter Y} (h : Tendsto f (comap c (𝓝 x)) F) {V' : Set Y} (V'_in : V' ∈ F) : ∃ V ∈ 𝓝 x, IsOpen V ∧ c ⁻¹' V ⊆ f ⁻¹' V' := sorry example {X Y A : Type _} [TopologicalSpace X] {c : A → X} {f : A → Y} {x : X} {F : Filter Y} (h : Tendsto f (comap c (𝓝 x)) F) {V' : Set Y} (V'_in : V' ∈ F) : ∃ V ∈ 𝓝 x, IsOpen V ∧ c ⁻¹' V ⊆ f ⁻¹' V' := by simpa [and_assoc] using ((nhds_basis_opens' x).comap c).tendsto_left_iff.mp h V' V'_in example [TopologicalSpace X] [TopologicalSpace Y] [RegularSpace Y] {A : Set X} (hA : ∀ x, x ∈ closure A) {f : A → Y} (f_cont : Continuous f) (hf : ∀ x : X, ∃ c : Y, Tendsto f (comap (↑) <| 𝓝 x) <| 𝓝 c) : ∃ φ : X → Y, Continuous φ ∧ ∀ a : A, φ a = f a := sorry #check @HasBasis.tendsto_right_iff example [TopologicalSpace X] [TopologicalSpace Y] [T3Space Y] {A : Set X} (hA : ∀ x, x ∈ closure A) {f : A → Y} (f_cont : Continuous f) (hf : ∀ x : X, ∃ c : Y, Tendsto f (comap (↑) <| 𝓝 x) <| 𝓝 c) : ∃ φ : X → Y, Continuous φ ∧ ∀ a : A, φ a = f a := by choose φ hφ using hf use φ constructor · rw [continuous_iff_continuousAt] intro x suffices ∀ V' ∈ 𝓝 (φ x), IsClosed V' → φ ⁻¹' V' ∈ 𝓝 x by simpa [ContinuousAt, (closed_nhds_basis (φ x)).tendsto_right_iff] intro V' V'_in V'_closed obtain ⟨V, V_in, V_op, hV⟩ : ∃ V ∈ 𝓝 x, IsOpen V ∧ (↑) ⁻¹' V ⊆ f ⁻¹' V' := aux (hφ x) V'_in suffices : ∀ y ∈ V, φ y ∈ V' exact mem_of_superset V_in this intro y y_in have hVx : V ∈ 𝓝 y := V_op.mem_nhds y_in haveI : (comap ((↑) : A → X) (𝓝 y)).NeBot := by simpa [mem_closure_iff_comap_neBot] using hA y apply V'_closed.mem_of_tendsto (hφ y) exact mem_of_superset (preimage_mem_comap hVx) hV · intro a have lim : Tendsto f (𝓝 a) (𝓝 <| φ a) := by simpa [nhds_induced] using hφ a exact tendsto_nhds_unique lim f_cont.continuousAt example [TopologicalSpace X] [TopologicalSpace.FirstCountableTopology X] {s : Set X} {a : X} : a ∈ closure s ↔ ∃ u : ℕ → X, (∀ n, u n ∈ s) ∧ Tendsto u atTop (𝓝 a) := mem_closure_iff_seq_limit variable [TopologicalSpace X] example {F : Filter X} {x : X} : ClusterPt x F ↔ NeBot (𝓝 x ⊓ F) := Iff.rfl example {s : Set X} : IsCompact s ↔ ∀ (F : Filter X) [NeBot F], F ≤ 𝓟 s → ∃ a ∈ s, ClusterPt a F := Iff.rfl example [TopologicalSpace.FirstCountableTopology X] {s : Set X} {u : ℕ → X} (hs : IsCompact s) (hu : ∀ n, u n ∈ s) : ∃ a ∈ s, ∃ φ : ℕ → ℕ, StrictMono φ ∧ Tendsto (u ∘ φ) atTop (𝓝 a) := hs.tendsto_subseq hu variable [TopologicalSpace Y] example {x : X} {F : Filter X} {G : Filter Y} (H : ClusterPt x F) {f : X → Y} (hfx : ContinuousAt f x) (hf : Tendsto f F G) : ClusterPt (f x) G := ClusterPt.map H hfx hf example [TopologicalSpace Y] {f : X → Y} (hf : Continuous f) {s : Set X} (hs : IsCompact s) : IsCompact (f '' s) := by intro F F_ne F_le have map_eq : map f (𝓟 s ⊓ comap f F) = 𝓟 (f '' s) ⊓ F := by sorry have Hne : (𝓟 s ⊓ comap f F).NeBot := by sorry have Hle : 𝓟 s ⊓ comap f F ≤ 𝓟 s := inf_le_left sorry example [TopologicalSpace Y] {f : X → Y} (hf : Continuous f) {s : Set X} (hs : IsCompact s) : IsCompact (f '' s) := by intro F F_ne F_le have map_eq : map f (𝓟 s ⊓ comap f F) = 𝓟 (f '' s) ⊓ F := by rw [Filter.push_pull, map_principal] have Hne : (𝓟 s ⊓ comap f F).NeBot := by apply NeBot.of_map rwa [map_eq, inf_of_le_right F_le] have Hle : 𝓟 s ⊓ comap f F ≤ 𝓟 s := inf_le_left rcases hs Hle with ⟨x, x_in, hx⟩ refine' ⟨f x, mem_image_of_mem f x_in, _⟩ apply hx.map hf.continuousAt rw [Tendsto, map_eq] exact inf_le_right example {ι : Type _} {s : Set X} (hs : IsCompact s) (U : ι → Set X) (hUo : ∀ i, IsOpen (U i)) (hsU : s ⊆ ⋃ i, U i) : ∃ t : Finset ι, s ⊆ ⋃ i ∈ t, U i := hs.elim_finite_subcover U hUo hsU example [CompactSpace X] : IsCompact (univ : Set X) := isCompact_univ
-
-