import Mathlib.Tactic
import Mathlib.Data.Real.Basic
import Mathlib.Tactic
universe u1 u2 u3
-- See Help.lean for a full list of tactics
/-
The following follows Lean series on writing tactics
https://www.vladasedlacek.cz/en/posts/lean-02-demo
-/
class incidence_geometry : Type (max (max (u1 + 1) (u2 + 1)) (u3 + 1))
incidence_geometry :=
( point : [self : incidence_geometry] β Type u1
point : Type u1)
( line : [self : incidence_geometry] β Type u2
line : Type u2)
( circle : [self : incidence_geometry] β Type u3
circle : Type u3)
( length : [self : incidence_geometry] β incidence_geometry.point β incidence_geometry.point β β
length : point β point β β )
( B : [self : incidence_geometry] β incidence_geometry.point β incidence_geometry.point β incidence_geometry.point β Prop
B : point β point β point β Prop ) -- Betweenness
( length_nonneg : β [self : incidence_geometry] (a b : incidence_geometry.point), 0 β€ incidence_geometry.length a b
length_nonneg : β ( a b : point ), 0 β€ length : point β point β β
length a b )
( length_symm : β [self : incidence_geometry] (a b : incidence_geometry.point),
incidence_geometry.length a b = incidence_geometry.length b a
length_symm : β ( a b : point ), length : point β point β β
length a b = length : point β point β β
length b a )
( length_eq_zero_iff : β [self : incidence_geometry] {a b : incidence_geometry.point}, incidence_geometry.length a b = 0 β a = b
length_eq_zero_iff : β { a b : point }, length : point β point β β
length a b = 0 β a = b )
( length_sum_of_B : β [self : incidence_geometry] {a b c : incidence_geometry.point},
incidence_geometry.B a b c β
incidence_geometry.length a b + incidence_geometry.length b c = incidence_geometry.length a c
length_sum_of_B : β { a b c : point },
B : point β point β point β Prop
B a b c β length : point β point β β
length a b + length : point β point β β
length b c = length : point β point β β
length a c )
( ne_12_of_B : β [self : incidence_geometry] {a b c : incidence_geometry.point}, incidence_geometry.B a b c β a β b
ne_12_of_B : β { a b c : point }, B : point β point β point β Prop
B a b c β a β b )
( ne_13_of_B : β [self : incidence_geometry] {a b c : incidence_geometry.point}, incidence_geometry.B a b c β a β c
ne_13_of_B : β { a b c : point }, B : point β point β point β Prop
B a b c β a β c )
( ne_23_of_B : β [self : incidence_geometry] {a b c : incidence_geometry.point}, incidence_geometry.B a b c β b β c
ne_23_of_B : β { a b c : point }, B : point β point β point β Prop
B a b c β b β c )
variable [ i : incidence_geometry : Type (max (max (u_1 + 1) (u_2 + 1)) (u_3 + 1))
incidence_geometry]
open incidence_geometry
lemma len_pos_of_neqβ : β [i : incidence_geometry] {a b : point}, a β b β 0 < length a b
len_pos_of_neqβ ( ab : a β b ) : 0 < length : [self : incidence_geometry] β point β point β β
length a b := by
have hβ : length : [self : incidence_geometry] β point β point β β
length a b β 0 := i : incidence_geometry a, b : point ab : a β b
0 < length a b
by
by_contra h i : incidence_geometry a, b : point ab : a β b h : length a b = 0
False
rw [ i : incidence_geometry a, b : point ab : a β b h : length a b = 0
False
length_eq_zero_iff : β [self : incidence_geometry] {a b : point}, length a b = 0 β a = b
length_eq_zero_iffi : incidence_geometry a, b : point ab : a β b h : a = b
False
] i : incidence_geometry a, b : point ab : a β b h : a = b
False
at h i : incidence_geometry a, b : point ab : a β b h : a = b
False
exact ( absurd : β {a b : Prop}, a β Β¬a β b
absurd h ab )
have hβ : 0 β€ length : [self : incidence_geometry] β point β point β β
length a b := length_nonneg : β [self : incidence_geometry] (a b : point), 0 β€ length a b
length_nonneg a b i : incidence_geometry a, b : point ab : a β b hβ : length a b β 0 hβ : 0 β€ length a b
0 < length a b
exact lt_of_le_of_ne : β {Ξ± : Type} [inst : PartialOrder Ξ±] {a b : Ξ±}, a β€ b β a β b β a < b
lt_of_le_of_ne hβ hβ . symm : β {Ξ± : Type} {a b : Ξ±}, a β b β b β a
symm
-- #find |- ?a β ?b
lemma len_pos_of_neqβ (ab : a β b) : 0 < length a b := by
have h1 : length : [self : incidence_geometry] β point β point β β
length a b β 0 := length_eq_zero_iff : β [self : incidence_geometry] {a b : point}, length a b = 0 β a = b
length_eq_zero_iff. not : β {a b : Prop}, (a β b) β (Β¬a β Β¬b)
not. mpr : β {a b : Prop}, (a β b) β b β a
mpr ab i : incidence_geometry a, b : point ab : a β b h1 : length a b β 0
0 < length a b
have h2 := length_nonneg : β [self : incidence_geometry] (a b : point), 0 β€ length a b
length_nonneg a b i : incidence_geometry a, b : point ab : a β b h1 : length a b β 0 h2 : 0 β€ length a b
0 < length a b
exact lt_of_le_of_ne : β {Ξ± : Type} [inst : PartialOrder Ξ±] {a b : Ξ±}, a β€ b β a β b β a < b
lt_of_le_of_ne h2 h1 . symm : β {Ξ± : Type} {a b : Ξ±}, a β b β b β a
symm
lemma len_pos_of_neqβ : β {a b : point}, a β b β 0 < length a b
len_pos_of_neqβ ( ab : a β b ) : 0 < length : [self : incidence_geometry] β point β point β β
length a b := by
have h1 : length : [self : incidence_geometry] β point β point β β
length a b β 0 := length_eq_zero_iff : β [self : incidence_geometry] {a b : point}, length a b = 0 β a = b
length_eq_zero_iff. not : β {a b : Prop}, (a β b) β (Β¬a β Β¬b)
not. mpr : β {a b : Prop}, (a β b) β b β a
mpr ab i : incidence_geometry a, b : point ab : a β b h1 : length a b β 0
0 < length a b
have h2 := length_nonneg : β [self : incidence_geometry] (a b : point), 0 β€ length a b
length_nonneg a b i : incidence_geometry a, b : point ab : a β b h1 : length a b β 0 h2 : 0 β€ length a b
0 < length a b
exact lt_of_le_of_ne : β {Ξ± : Type} [inst : PartialOrder Ξ±] {a b : Ξ±}, a β€ b β a β b β a < b
lt_of_le_of_ne h2 h1 . symm : β {Ξ± : Type} {a b : Ξ±}, a β b β b β a
symm
lemma len_pos_of_neqβ : β [i : incidence_geometry] {a b : point}, a β b β 0 < length a b
len_pos_of_neqβ ( ab : a β b ) : 0 < length : [self : incidence_geometry] β point β point β β
length a b := by
have h1 : length : [self : incidence_geometry] β point β point β β
length a b β 0 := length_eq_zero_iff : β [self : incidence_geometry] {a b : point}, length a b = 0 β a = b
length_eq_zero_iff. not : β {a b : Prop}, (a β b) β (Β¬a β Β¬b)
not. mpr : β {a b : Prop}, (a β b) β b β a
mpr ab i : incidence_geometry a, b : point ab : a β b h1 : length a b β 0
0 < length a b
have h2 := length_nonneg : β [self : incidence_geometry] (a b : point), 0 β€ length a b
length_nonneg a b i : incidence_geometry a, b : point ab : a β b h1 : length a b β 0 h2 : 0 β€ length a b
0 < length a b
exact lt_of_le_of_ne : β {Ξ± : Type} [inst : PartialOrder Ξ±] {a b : Ξ±}, a β€ b β a β b β a < b
lt_of_le_of_ne h2 h1 . symm : β {Ξ± : Type} {a b : Ξ±}, a β b β b β a
symm
lemma len_pos_of_neq : β [i : incidence_geometry] {a b : point}, a β b β 0 < length a b
len_pos_of_neq ( ab : a β b ) : 0 < length : [self : incidence_geometry] β point β point β β
length a b := len_pos_of_neqβ : β [i : incidence_geometry] {a b : point}, a β b β 0 < length a b
len_pos_of_neqβ ab
theorem length_sum_perm_of_Bβ : β {a b c : point}, B a b c β 0 < length a b β§ 0 < length b a
length_sum_perm_of_Bβ ( Babc : B : [self : incidence_geometry] β point β point β point β Prop
B a b c ) :
0 < length : [self : incidence_geometry] β point β point β β
length a b β§ 0 < length : [self : incidence_geometry] β point β point β β
length b a := by
have ab : a β b := ne_12_of_B : β [self : incidence_geometry] {a b c : point}, B a b c β a β b
ne_12_of_B Babc i : incidence_geometry a, b, c : point Babc : B a b c ab : a β b
0 < length a b β§ 0 < length b a
have ab_pos : 0 < length : [self : incidence_geometry] β point β point β β
length a b := len_pos_of_neq : β [i : incidence_geometry] {a b : point}, a β b β 0 < length a b
len_pos_of_neq ab i : incidence_geometry a, b, c : point Babc : B a b c ab : a β b ab_pos : 0 < length a b
0 < length a b β§ 0 < length b a
constructor i : incidence_geometry a, b, c : point Babc : B a b c ab : a β b ab_pos : 0 < length a b
left 0 < length a b
. i : incidence_geometry a, b, c : point Babc : B a b c ab : a β b ab_pos : 0 < length a b
left 0 < length a b
exact ab_pos
. i : incidence_geometry a, b, c : point Babc : B a b c ab : a β b ab_pos : 0 < length a b
right 0 < length b a
rw [ i : incidence_geometry a, b, c : point Babc : B a b c ab : a β b ab_pos : 0 < length a b
right 0 < length b a
length_symm : β [self : incidence_geometry] (a b : point), length a b = length b a
length_symmi : incidence_geometry a, b, c : point Babc : B a b c ab : a β b ab_pos : 0 < length b a
right 0 < length b a
] i : incidence_geometry a, b, c : point Babc : B a b c ab : a β b ab_pos : 0 < length b a
right 0 < length b a
at ab_pos i : incidence_geometry a, b, c : point Babc : B a b c ab : a β b ab_pos : 0 < length b a
right 0 < length b a
exact ab_pos
theorem length_sum_perm_of_Bβ : β {a b c : point}, B a b c β 0 < length a b β§ 0 < length b a
length_sum_perm_of_Bβ ( Babc : B : [self : incidence_geometry] β point β point β point β Prop
B a b c ) :
0 < length : [self : incidence_geometry] β point β point β β
length a b β§ 0 < length : [self : incidence_geometry] β point β point β β
length b a := by
constructor i : incidence_geometry a, b, c : point Babc : B a b c
left 0 < length a b
. i : incidence_geometry a, b, c : point Babc : B a b c
left 0 < length a b
exact ne_12_of_B : β [self : incidence_geometry] {a b c : point}, B a b c β a β b
ne_12_of_B Babc |> len_pos_of_neq : β [i : incidence_geometry] {a b : point}, a β b β 0 < length a b
len_pos_of_neq
. i : incidence_geometry a, b, c : point Babc : B a b c
right 0 < length b a
exact ne_12_of_B : β [self : incidence_geometry] {a b c : point}, B a b c β a β b
ne_12_of_B Babc |> ( length_symm : β [self : incidence_geometry] (a b : point), length a b = length b a
length_symm a b βΈ len_pos_of_neq : β [i : incidence_geometry] {a b : point}, a β b β 0 < length a b
len_pos_of_neq)
theorem length_sum_perm_of_Bβ : β {a b c : point}, B a b c β 0 < length a b β§ 0 < length b a
length_sum_perm_of_Bβ ( Babc : B : [self : incidence_geometry] β point β point β point β Prop
B a b c ) : 0 < length : [self : incidence_geometry] β point β point β β
length a b β§ 0 < length : [self : incidence_geometry] β point β point β β
length b a := by
simp only [ ne_eq : β {Ξ± : Sort ?u.2314} (a b : Ξ±), (a β b) = Β¬a = b
ne_eq, ne_12_of_B : β [self : incidence_geometry] {a b c : point}, B a b c β a β b
ne_12_of_B Babc , len_pos_of_neq : β [i : incidence_geometry] {a b : point}, a β b β 0 < length a b
len_pos_of_neq, length_symm : β [self : incidence_geometry] (a b : point), length a b = length b a
length_symm, and_self : β (p : Prop), (p β§ p) = p
and_self] i : incidence_geometry a, b, c : point Babc : B a b c
0 < length a b
exact len_pos_of_neq : β [i : incidence_geometry] {a b : point}, a β b β 0 < length a b
len_pos_of_neq ( ne_12_of_B : β [self : incidence_geometry] {a b c : point}, B a b c β a β b
ne_12_of_B Babc )