Imports
import Mathlib.Tactic

Analysis I, Appendix A.2: Implication

An introduction to implications. Showcases some basic tactics and Lean syntax.

example {X Y: Prop} (hX: X) : (X → Y) ↔ Y := X:PropY:ProphX:X⊢ X → Y ↔ Y All goals completed! 🐙example {X Y: Prop} (hX: ¬X) : X → Y := X:PropY:ProphX:¬X⊢ X → Y X:PropY:ProphX:¬XhX':X⊢ Y All goals completed! 🐙example {X Y: Prop} (hXY: X → Y) (hX: X) : Y := X:PropY:ProphXY:X → YhX:X⊢ Y All goals completed! 🐙example {X Y: Prop} (hXY: X → Y) (hX: X) : Y := hXY hXexample {X Y: Prop} (hXY: X → Y) (hY: ¬ Y) : ¬ X := X:PropY:ProphXY:X → YhY:¬Y⊢ ¬X X:PropY:ProphXY:X → YhY:X⊢ Y All goals completed! 🐙theorem example_A_2_1 (x:ℤ) : x = 2 → x^2 = 4 := x:ℤ⊢ x = 2 → x ^ 2 = 4 x:ℤh:x = 2⊢ x ^ 2 = 4 x:ℤh:x = 2⊢ 2 ^ 2 = 4 All goals completed! 🐙example : (2:ℤ) = 2 → (2:ℤ)^2 = 4 := example_A_2_1 2example : (3:ℤ) = 2 → (3:ℤ)^2 = 4 := example_A_2_1 3example : (-2:ℤ) = 2 → (-2:ℤ)^2 = 4 := example_A_2_1 (-2)_root_.not_imp {a b : Prop} : ¬(a → b) ↔ a ∧ ¬b#check _root_.not_imp
_root_.not_imp {a b : Prop} : ¬(a → b) ↔ a ∧ ¬b
example : ¬ ((2+2=4) → (4+4)=2) := ⊢ ¬(2 + 2 = 4 → 4 + 4 = 2) ⊢ 2 + 2 = 4 ∧ ¬4 + 4 = 2 ⊢ 2 + 2 = 4⊢ ¬4 + 4 = 2 ⊢ 2 + 2 = 4 All goals completed! 🐙 All goals completed! 🐙example {X Y: Prop} : (X → Y) ↔ (Y ≥ X) := X:PropY:Prop⊢ X → Y ↔ Y ≥ X All goals completed! 🐙example {X Y: Prop} : (X → Y) ↔ ((¬X) ≥ ¬Y) := X:PropY:Prop⊢ X → Y ↔ (¬X) ≥ ¬Y X:PropY:Prop⊢ X → Y ↔ ¬Y → ¬X; All goals completed! 🐙example {John_left_at_five John_here_now:Prop} (h1: John_left_at_five → John_here_now) (h2: ¬ John_here_now) : ¬ John_left_at_five := John_left_at_five:PropJohn_here_now:Proph1:John_left_at_five → John_here_nowh2:¬John_here_now⊢ ¬John_left_at_five John_left_at_five:PropJohn_here_now:Proph1:John_left_at_five → John_here_nowh2:John_left_at_five⊢ John_here_now All goals completed! 🐙example {Washington_capital_US:Prop} (h: Washington_capital_US) : (1+1=2) → Washington_capital_US := Washington_capital_US:Proph:Washington_capital_US⊢ 1 + 1 = 2 → Washington_capital_US Washington_capital_US:Proph:Washington_capital_USh':1 + 1 = 2⊢ Washington_capital_US All goals completed! 🐙example {NYC_capital_US:Prop} : (2+2=3) → NYC_capital_US := NYC_capital_US:Prop⊢ 2 + 2 = 3 → NYC_capital_US NYC_capital_US:Proph:2 + 2 = 3⊢ NYC_capital_US All goals completed! 🐙/-- Proposition A.2.2 -/ example : ((2+2:ℤ)=5) → (4=(10-4:ℤ)) := ⊢ 2 + 2 = 5 → 4 = 10 - 4 h:2 + 2 = 5⊢ 4 = 10 - 4 have : (4 + 4:ℤ) = 10 := ⊢ 2 + 2 = 5 → 4 = 10 - 4 h:2 * (2 + 2) = 2 * 5⊢ 4 + 4 = 10 All goals completed! 🐙 rwa [←eq_sub_iff_add_eqh:2 + 2 = 5this:4 = 10 - 4⊢ 4 = 10 - 4 at this

Theorem A.2.4

theorem theorem_A_2_4 (n:ℤ) : Even (n * (n+1)) := n:ℤ⊢ Even (n * (n + 1)) n:ℤthis:Even n ∨ Odd n⊢ Even (n * (n + 1)) n:ℤheven:Even n⊢ Even (n * (n + 1))n:ℤhodd:Odd n⊢ Even (n * (n + 1)) -- can also use `rcases this with heven | hodd` n:ℤheven:Even n⊢ Even (n * (n + 1)) All goals completed! 🐙 n:ℤhodd:Odd nthis:Even (n + 1)⊢ Even (n * (n + 1)) All goals completed! 🐙
/-- Corollary A.2.5 -/ example : let n:ℤ := (253+142)*123-(423+198)^342+538-213 Even (n * (n+1)) := theorem_A_2_4 _example : ∀ x:ℝ, x = 2 → x^2 = 4 := ⊢ ∀ (x : ℝ), x = 2 → x ^ 2 = 4 intro x x:ℝh:x = 2⊢ x ^ 2 = 4 x:ℝh:x = 2⊢ 2 ^ 2 = 4 All goals completed! 🐙example : ¬ ∀ x:ℝ, x^2 = 4 → x = 2 := ⊢ ¬∀ (x : ℝ), x ^ 2 = 4 → x = 2 ⊢ ∃ x, x ^ 2 = 4 ∧ ¬x = 2 ⊢ (-2) ^ 2 = 4 ∧ ¬-2 = 2 All goals completed! 🐙example {X Y : Prop} : (X ↔ Y) = ((X → Y) ∧ (Y → X)) := X:PropY:Prop⊢ (X ↔ Y) = ((X → Y) ∧ (Y → X)) X:PropY:Prop⊢ (X ↔ Y) ↔ (X → Y) ∧ (Y → X); All goals completed! 🐙example (x:ℝ) : x = 2 ↔ 2*x = 4 := x:ℝ⊢ x = 2 ↔ 2 * x = 4 x:ℝ⊢ x = 2 → 2 * x = 4x:ℝ⊢ 2 * x = 4 → x = 2 x:ℝ⊢ x = 2 → 2 * x = 4 x:ℝh:x = 2⊢ 2 * x = 4 All goals completed! 🐙 x:ℝh:2 * x = 4⊢ x = 2 All goals completed! 🐙example {X Y :Prop} : (X ↔ Y) = (X = Y) := X:PropY:Prop⊢ (X ↔ Y) = (X = Y) All goals completed! 🐙example : (3 = 2) → (6 = 4) := ⊢ 3 = 2 → 6 = 4 All goals completed! 🐙example : ∃ (X Y:Prop), (X → Y) ≠ (Y → X) := ⊢ ∃ X Y, (X → Y) ≠ (Y → X) x:ℤ := -2⊢ ∃ X Y, (X → Y) ≠ (Y → X) x:ℤ := -2⊢ (x = 2 → x ^ 2 = 4) ≠ (x ^ 2 = 4 → x = 2) All goals completed! 🐙theorem contrapositive {X Y: Prop} (hXY: X → Y) : ¬ Y → ¬ X := X:PropY:ProphXY:X → Y⊢ ¬Y → ¬X X:PropY:ProphXY:X → YhY:¬Y⊢ ¬X X:PropY:ProphXY:X → YhY:¬YhX:X⊢ False X:PropY:ProphXY:X → YhY:¬YhX:Xthis:Y⊢ False All goals completed! 🐙theorem imp_example (x:ℝ) : (x = 2) → (x^2 = 4) := x:ℝ⊢ x = 2 → x ^ 2 = 4 x:ℝh:x = 2⊢ x ^ 2 = 4 x:ℝh:x = 2⊢ 2 ^ 2 = 4 All goals completed! 🐙theorem imp_contrapositive (x:ℝ) : (x^2 ≠ 4) → (x ≠ 2) := x:ℝ⊢ x ^ 2 ≠ 4 → x ≠ 2 All goals completed! 🐙/-- Proposition A.2.6 -/ example {x:ℝ} (h:x>0) (hsin: Real.sin x = 1) : x ≥ Real.pi / 2 := x:ℝh:x > 0hsin:Real.sin x = 1⊢ x ≥ Real.pi / 2 x:ℝh:x > 0hsin:Real.sin x = 1h':x < Real.pi / 2⊢ False have h1 : Real.sin 0 < Real.sin x := x:ℝh:x > 0hsin:Real.sin x = 1⊢ x ≥ Real.pi / 2 x:ℝh:x > 0hsin:Real.sin x = 1h':x < Real.pi / 2⊢ -(Real.pi / 2) ≤ 0x:ℝh:x > 0hsin:Real.sin x = 1h':x < Real.pi / 2⊢ x ≤ Real.pi / 2 x:ℝh:x > 0hsin:Real.sin x = 1h':x < Real.pi / 2⊢ -(Real.pi / 2) ≤ 0 x:ℝh:x > 0hsin:Real.sin x = 1h':x < Real.pi / 2this:Real.pi > 0⊢ -(Real.pi / 2) ≤ 0 All goals completed! 🐙 All goals completed! 🐙 have h2 : Real.sin x < Real.sin (Real.pi / 2) := x:ℝh:x > 0hsin:Real.sin x = 1⊢ x ≥ Real.pi / 2 -- the <;> tactic applies the next tactic to all currently visible goals. x:ℝh:x > 0hsin:Real.sin x = 1h':x < Real.pi / 2h1:Real.sin 0 < Real.sin x⊢ -(Real.pi / 2) ≤ xx:ℝh:x > 0hsin:Real.sin x = 1h':x < Real.pi / 2h1:Real.sin 0 < Real.sin x⊢ Real.pi / 2 ≤ Real.pi / 2 x:ℝh:x > 0hsin:Real.sin x = 1h':x < Real.pi / 2h1:Real.sin 0 < Real.sin x⊢ -(Real.pi / 2) ≤ xx:ℝh:x > 0hsin:Real.sin x = 1h':x < Real.pi / 2h1:Real.sin 0 < Real.sin x⊢ Real.pi / 2 ≤ Real.pi / 2 All goals completed! 🐙 x:ℝh:x > 0hsin:Real.sin x = 1h':x < Real.pi / 2h1:0 < Real.sin xh2:Real.sin x < 1⊢ False All goals completed! 🐙