Analysis I, Appendix A.1: Mathematical Statements
An introduction to mathematical statements. Showcases some basic tactics and Lean syntax.
Every well-formed statement is either true or false...
example (P:Prop) : (P=true) ∨ (P=false) := P:Prop⊢ P = (true = true) ∨ P = (false = true) P:Prop⊢ P ∨ ¬P; All goals completed! 🐙.. but not both.
example (P:Prop) : ¬ ((P=true) ∧ (P=false)) := P:Prop⊢ ¬(P = (true = true) ∧ P = (false = true)) All goals completed! 🐙-- Note: `P=true` and `P=false` simplify to `P` and `¬P` respectively.To prove that a statement is true, it suffices to show that it is not false,
example {P:Prop} (h: P ≠ false) : P = true := P:Proph:P ≠ (false = true)⊢ P = (true = true) P:Proph:P ≠ (false = true)⊢ P; All goals completed! 🐙while to show that a statement is false, it suffices to show that it is not true.
example {P:Prop} (h: P ≠ true) : P = false := P:Proph:P ≠ (true = true)⊢ P = (false = true) P:Proph:P ≠ (true = true)⊢ ¬P; All goals completed! 🐙This statement is also true, but not very efficient.
example : 4 ≤ 4 := ⊢ 4 ≤ 4 All goals completed! 🐙Conjunction
example {X Y: Prop} (hX: X) (hY: Y) : X ∧ Y := X:PropY:ProphX:XhY:Y⊢ X ∧ Y
X:PropY:ProphX:XhY:Y⊢ XX:PropY:ProphX:XhY:Y⊢ Y
X:PropY:ProphX:XhY:Y⊢ X All goals completed! 🐙
All goals completed! 🐙example {X Y: Prop} (hXY: X ∧ Y) : X := X:PropY:ProphXY:X ∧ Y⊢ X
All goals completed! 🐙example {X Y: Prop} (hXY: X ∧ Y) : Y := X:PropY:ProphXY:X ∧ Y⊢ Y
All goals completed! 🐙example {X Y: Prop} (hX: ¬ X) : ¬ (X ∧ Y) := X:PropY:ProphX:¬X⊢ ¬(X ∧ Y)
X:PropY:ProphX:X ∧ Y⊢ X
All goals completed! 🐙example {X Y: Prop} (hY: ¬ Y) : ¬ (X ∧ Y) := X:PropY:ProphY:¬Y⊢ ¬(X ∧ Y)
X:PropY:ProphY:X ∧ Y⊢ Y
All goals completed! 🐙example : (2+2=4) ∧ (3+3=6) := ⊢ 2 + 2 = 4 ∧ 3 + 3 = 6
⊢ 2 + 2 = 4⊢ 3 + 3 = 6
⊢ 2 + 2 = 4 All goals completed! 🐙
All goals completed! 🐙Disjunction
example {X Y: Prop} (hX: X) : X ∨ Y := X:PropY:ProphX:X⊢ X ∨ Y
X:PropY:ProphX:X⊢ X
All goals completed! 🐙example {X Y: Prop} (hY: Y) : X ∨ Y := X:PropY:ProphY:Y⊢ X ∨ Y
X:PropY:ProphY:Y⊢ Y
All goals completed! 🐙example {X Y: Prop} (hX: ¬ X) (hY: ¬ Y) : ¬ (X ∨ Y) := X:PropY:ProphX:¬XhY:¬Y⊢ ¬(X ∨ Y)
X:PropY:ProphX:¬XhY:¬Y⊢ ¬X ∧ ¬Y
X:PropY:ProphX:¬XhY:¬Y⊢ ¬XX:PropY:ProphX:¬XhY:¬Y⊢ ¬Y
X:PropY:ProphX:¬XhY:¬Y⊢ ¬X All goals completed! 🐙
All goals completed! 🐙example : (2+2=4) ∨ (3+3=5) := ⊢ 2 + 2 = 4 ∨ 3 + 3 = 5
⊢ 2 + 2 = 4
All goals completed! 🐙example : ¬ ((2+2=5) ∨ (3+3=5)) := ⊢ ¬(2 + 2 = 5 ∨ 3 + 3 = 5)
All goals completed! 🐙example : (2+2=4) ∨ (3+3=6) := ⊢ 2 + 2 = 4 ∨ 3 + 3 = 6
⊢ 2 + 2 = 4
All goals completed! 🐙example : (2+2=4) ∧ (3+3=6) := ⊢ 2 + 2 = 4 ∧ 3 + 3 = 6
⊢ 2 + 2 = 4⊢ 3 + 3 = 6
⊢ 2 + 2 = 4 All goals completed! 🐙
All goals completed! 🐙example : (2+2=4) ∨ (2353 + 5931 = 7284) := ⊢ 2 + 2 = 4 ∨ 2353 + 5931 = 7284
⊢ 2 + 2 = 4
All goals completed! 🐙Negation
example {X:Prop} : (¬ X = true) ↔ (X = false) := X:Prop⊢ ¬X = (true = true) ↔ X = (false = true) All goals completed! 🐙example {X:Prop} : (¬ X = false) ↔ (X = true) := X:Prop⊢ ¬X = (false = true) ↔ X = (true = true) All goals completed! 🐙example : ¬ (2+2=5) := ⊢ ¬2 + 2 = 5 All goals completed! 🐙example : 2+2 ≠ 5 := ⊢ 2 + 2 ≠ 5 All goals completed! 🐙example (Jane_black_hair Jane_blue_eyes:Prop) :
(¬ (Jane_black_hair ∧ Jane_blue_eyes)) ↔ (¬ Jane_black_hair ∨ ¬ Jane_blue_eyes) := Jane_black_hair:PropJane_blue_eyes:Prop⊢ ¬(Jane_black_hair ∧ Jane_blue_eyes) ↔ ¬Jane_black_hair ∨ ¬Jane_blue_eyes
Jane_black_hair:PropJane_blue_eyes:Prop⊢ Jane_black_hair → ¬Jane_blue_eyes ↔ ¬Jane_black_hair ∨ ¬Jane_blue_eyes; All goals completed! 🐙example (x:ℤ) : ¬ (Even x ∧ x ≥ 0) ↔ (Odd x ∨ x < 0) := x:ℤ⊢ ¬(Even x ∧ x ≥ 0) ↔ Odd x ∨ x < 0
x:ℤthis:¬Odd _fvar.17324 ↔ Even _fvar.17324 := Int.not_odd_iff_even⊢ ¬(Even x ∧ x ≥ 0) ↔ Odd x ∨ x < 0
x:ℤthis✝:¬Odd _fvar.17324 ↔ Even _fvar.17324 := Int.not_odd_iff_eventhis:¬_fvar.17324 ≥ 0 ↔ _fvar.17324 < 0 := Int.not_le⊢ ¬(Even x ∧ x ≥ 0) ↔ Odd x ∨ x < 0
All goals completed! 🐙example (x:ℤ) : ¬ (x ≥ 2 ∧ x ≤ 6) ↔ (x < 2 ∨ x > 6) := x:ℤ⊢ ¬(x ≥ 2 ∧ x ≤ 6) ↔ x < 2 ∨ x > 6
x:ℤthis:¬_fvar.29943 ≥ 2 ↔ _fvar.29943 < 2 := Int.not_le⊢ ¬(x ≥ 2 ∧ x ≤ 6) ↔ x < 2 ∨ x > 6
x:ℤthis✝:¬_fvar.29943 ≥ 2 ↔ _fvar.29943 < 2 := Int.not_lethis:¬_fvar.29943 ≤ 6 ↔ _fvar.29943 > 6 := Int.not_le⊢ ¬(x ≥ 2 ∧ x ≤ 6) ↔ x < 2 ∨ x > 6
All goals completed! 🐙example (John_brown_hair John_black_hair:Prop) :
(¬ (John_brown_hair ∨ John_black_hair)) ↔ (¬ John_brown_hair ∧ ¬ John_black_hair) := John_brown_hair:PropJohn_black_hair:Prop⊢ ¬(John_brown_hair ∨ John_black_hair) ↔ ¬John_brown_hair ∧ ¬John_black_hair
All goals completed! 🐙example (x:ℝ) : ¬ (x ≥ 1 ∧ x ≤ -1) ↔ (x < 1 ∨ x > -1) := x:ℝ⊢ ¬(x ≥ 1 ∧ x ≤ -1) ↔ x < 1 ∨ x > -1
x:ℝthis:¬_fvar.46563 ≥ 1 ↔ _fvar.46563 < 1 := not_le⊢ ¬(x ≥ 1 ∧ x ≤ -1) ↔ x < 1 ∨ x > -1
x:ℝthis✝:¬_fvar.46563 ≥ 1 ↔ _fvar.46563 < 1 := not_lethis:¬_fvar.46563 ≤ -1 ↔ _fvar.46563 > -1 := not_le⊢ ¬(x ≥ 1 ∧ x ≤ -1) ↔ x < 1 ∨ x > -1
All goals completed! 🐙example (x:ℤ) : ¬ (Even x ∨ Odd x) ↔ (¬ Even x ∧ ¬ Odd x) := x:ℤ⊢ ¬(Even x ∨ Odd x) ↔ ¬Even x ∧ ¬Odd x
All goals completed! 🐙example (X:Prop) : ¬ (¬ X) ↔ X := X:Prop⊢ ¬¬X ↔ X
All goals completed! 🐙If and only if (iff)
example {X Y: Prop} (hXY: X ↔ Y) (hX: X) : Y := X:PropY:ProphXY:X ↔ YhX:X⊢ Y
X:PropY:ProphXY:X ↔ YhX:Y⊢ Y
All goals completed! 🐙example {X Y: Prop} (hXY: X ↔ Y) (hY: Y) : X := X:PropY:ProphXY:X ↔ YhY:Y⊢ X
X:PropY:ProphXY:X ↔ YhY:X⊢ X
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) (hY: Y) : X := X:PropY:ProphXY:X ↔ YhY:Y⊢ X
All goals completed! 🐙example {X Y: Prop} (hXY: X ↔ Y) : X=Y := X:PropY:ProphXY:X ↔ Y⊢ X = Y
All goals completed! 🐙example (x:ℝ) : x = 3 ↔ 2 * x = 6 := x:ℝ⊢ x = 3 ↔ 2 * x = 6
x:ℝ⊢ x = 3 → 2 * x = 6x:ℝ⊢ 2 * x = 6 → x = 3
x:ℝ⊢ x = 3 → 2 * x = 6 x:ℝh:x = 3⊢ 2 * x = 6
All goals completed! 🐙
x:ℝh:2 * x = 6⊢ x = 3
All goals completed! 🐙example : ¬ (∀ x:ℝ, x = 3 ↔ x^2 = 9) := ⊢ ¬∀ (x : ℝ), x = 3 ↔ x ^ 2 = 9
⊢ ∃ x, ¬(x = 3 ↔ x ^ 2 = 9)
⊢ ¬(-3 = 3 ↔ (-3) ^ 2 = 9)
All goals completed! 🐙example {X Y: Prop} (hXY: X ↔ Y) (hX: ¬ X) : ¬ Y := X:PropY:ProphXY:X ↔ YhX:¬X⊢ ¬Y
X:PropY:ProphXY:X ↔ YhX:¬Xthis:Y⊢ False
X:PropY:ProphXY:X ↔ YhX:¬Xthis:X⊢ False
All goals completed! 🐙example : (2+2=5) ↔ (4+4=10) := ⊢ 2 + 2 = 5 ↔ 4 + 4 = 10
All goals completed! 🐙example {X Y Z:Prop} (hXY: X ↔ Y) (hXZ: X ↔ Z) : [X,Y,Z].TFAE := X:PropY:PropZ:ProphXY:X ↔ YhXZ:X ↔ Z⊢ [X, Y, Z].TFAE
tfae_have 1 ↔ 2 := X:PropY:PropZ:ProphXY:X ↔ YhXZ:X ↔ Z⊢ [X, Y, Z].TFAE All goals completed! 🐙 -- This line is optional
tfae_have 1 ↔ 3 := X:PropY:PropZ:ProphXY:X ↔ YhXZ:X ↔ Z⊢ [X, Y, Z].TFAE All goals completed! 🐙 -- This line is optional
All goals completed! 🐙
Note for the .out method that one indexes starting from 0, in contrast to the tfae_have tactic.
example {X Y Z:Prop} (h: [X,Y,Z].TFAE) : X ↔ Y := X:PropY:PropZ:Proph:[X, Y, Z].TFAE⊢ X ↔ Y
All goals completed! 🐙
Exercise A.1.1. Fill in the first sorry with something reasonable.
example {X Y:Prop} : ¬ ((X ∨ Y) ∧ ¬ (X ∧ Y)) ↔ sorry := X:PropY:Prop⊢ ¬((X ∨ Y) ∧ ¬(X ∧ Y)) ↔ sorry All goals completed! 🐙
Exercise A.1.2. Fill in the first sorry with something reasonable.
example {X Y:Prop} : ¬ (X ↔ Y) ↔ sorry := X:PropY:Prop⊢ ¬(X ↔ Y) ↔ sorry All goals completed! 🐙Exercise A.1.3.
def Exercise_A_1_3 : Decidable (∀ (X Y: Prop), (X → Y) → (¬X → ¬ Y) → (X ↔ Y)) := ⊢ Decidable (∀ (X Y : Prop), (X → Y) → (¬X → ¬Y) → (X ↔ Y))
-- the first line of this construction should be either `apply isTrue` or `apply isFalse`, depending on whether you believe the given statement to be true or false.
All goals completed! 🐙Exercise A.1.4.
def Exercise_A_1_4 : Decidable (∀ (X Y: Prop), (X → Y) → (¬Y → ¬ X) → (X ↔ Y)) := ⊢ Decidable (∀ (X Y : Prop), (X → Y) → (¬Y → ¬X) → (X ↔ Y))
-- the first line of this construction should be either `apply isTrue` or `apply isFalse`.
All goals completed! 🐙Exercise A.1.5.
def Exercise_A_1_5 : Decidable (∀ (X Y Z: Prop), (X ↔ Y) → (Y ↔ Z) → [X,Y,Z].TFAE) := ⊢ Decidable (∀ (X Y Z : Prop), (X ↔ Y) → (Y ↔ Z) → [X, Y, Z].TFAE)
-- the first line of this construction should be either `apply isTrue` or `apply isFalse`.
All goals completed! 🐙Exercise A.1.6.
def Exercise_A_1_6 : Decidable (∀ (X Y Z: Prop), (X → Y) → (Y → Z) → (Z → X) → [X,Y,Z].TFAE) := ⊢ Decidable (∀ (X Y Z : Prop), (X → Y) → (Y → Z) → (Z → X) → [X, Y, Z].TFAE)
-- the first line of this construction should be either `apply isTrue` or `apply isFalse`.
All goals completed! 🐙