natural-number-game

Solututions to the Natural Number Game

inequality.lean (3159B)

  1 lemma one_add_le_self (x : ℕ) : x ≤ 1 + x :=
  2 begin
  3   rw le_iff_exists_add,
  4   use 1,
  5   rw add_comm,
  6 end
  7 
  8 lemma le_refl (x : ℕ) : x ≤ x :=
  9 begin
 10   use 0,
 11   rw add_zero,
 12   refl,
 13 end
 14 
 15 theorem le_succ (a b : ℕ) : a ≤ b → a ≤ (succ b) :=
 16 begin
 17   intro h,
 18   cases h with c hc,
 19   use c + 1,
 20   rw add_one_eq_succ,
 21   rw add_succ,
 22   rw hc,
 23   refl,
 24 end
 25 
 26 lemma zero_le (a : ℕ) : 0 ≤ a :=
 27 begin
 28   use a,
 29   rw zero_add,
 30   refl,
 31 end
 32 
 33 theorem le_trans (a b c : ℕ) (hab : a ≤ b) (hbc : b ≤ c) : a ≤ c :=
 34 begin
 35   cases hab with b' hb',
 36   cases hbc with c' hc',
 37   use b' + c',
 38   rw ← add_assoc,
 39   rw ← hb',
 40   exact hc',
 41 end
 42 
 43 theorem le_antisymm (a b : ℕ) (hab : a ≤ b) (hba : b ≤ a) : a = b :=
 44 begin
 45   cases hab with c hc,
 46   cases hba with d hd,
 47   rw hd at hc,
 48   rw add_assoc at hc,
 49   symmetry at hc,
 50   have p := eq_zero_of_add_right_eq_self hc,
 51   have q := add_right_eq_zero p,
 52   rw hd,
 53   rw q,
 54   rw add_zero,
 55   refl,
 56 end
 57 
 58 lemma le_zero (a : ℕ) (h : a ≤ 0) : a = 0 := le_antisymm _ _ h (zero_le _)
 59 
 60 lemma succ_le_succ (a b : ℕ) (h : a ≤ b) : succ a ≤ succ b :=
 61 begin
 62   cases h with c hc,
 63   use c,
 64   rw succ_add,
 65   rw hc,
 66   refl,
 67 end
 68 
 69 theorem le_total (a b : ℕ) : a ≤ b ∨ b ≤ a :=
 70 begin
 71   induction b with c,
 72   right,
 73   exact zero_le a,
 74   cases b_ih with hac hca,
 75   left,
 76   apply le_succ,
 77   exact hac,
 78   cases hca with d hd,
 79   cases d with e,
 80   rw add_zero at hd,
 81   left,
 82   rw hd,
 83   rw succ_eq_add_one,
 84   use 1,
 85   refl,
 86   right,
 87   use e,
 88   rw succ_add,
 89   rw ← add_succ,
 90   exact hd,
 91 end
 92 
 93 lemma le_succ_self (a : ℕ) : a ≤ succ a :=
 94 begin
 95   use 1,
 96   exact succ_eq_add_one a,
 97 end
 98 
 99 theorem add_le_add_right {a b : ℕ} : a ≤ b → ∀ t, (a + t) ≤ (b + t) :=
100 begin
101   intros h t,
102   cases h with c hc,
103   use c,
104   rw add_assoc,
105   rw ← add_comm c,
106   rw ← add_assoc,
107   rw hc,
108   refl,
109 end
110 
111 theorem le_of_succ_le_succ (a b : ℕ) : succ a ≤ succ b → a ≤ b :=
112 begin
113   intro h,
114   cases h with c hc,
115   use c,
116   rw succ_add at hc,
117   apply succ_inj,
118   exact hc,
119 end
120 
121 theorem not_succ_le_self (a : ℕ) : ¬ (succ a ≤ a) :=
122 begin
123   intro h,
124   cases h with c hc,
125   rw succ_add at hc,
126   rw ← add_succ at hc,
127   symmetry at hc,
128   apply succ_ne_zero,
129   apply eq_zero_of_add_right_eq_self,
130   exact hc,
131 end
132 
133 theorem add_le_add_left {a b : ℕ} (h : a ≤ b) (t : ℕ) : t + a ≤ t + b :=
134 begin
135   repeat {rw add_comm t},
136   exact add_le_add_right h t,
137 end
138 
139 lemma lt_aux_one (a b : ℕ) : a ≤ b ∧ ¬ (b ≤ a) → succ a ≤ b :=
140 begin
141   intro h,
142   have p := le_total (succ a) b,
143   cases p with hab hba,
144   exact hab,
145   cases hba with c hc,
146   cases c with d,
147   use 0,
148   rw add_zero,
149   rw add_zero at hc,
150   symmetry at hc,
151   exact hc,
152   exfalso,
153   apply h.2,
154   use d,
155   apply succ_inj,
156   rw add_succ at hc,
157   exact hc,
158 end
159 
160 lemma lt_aux_two (a b : ℕ) : succ a ≤ b → a ≤ b ∧ ¬ (b ≤ a) :=
161 begin
162   intro h,
163   split,
164   exact le_trans _ _ _ (le_succ_self a) h,
165   intro p,
166   apply not_succ_le_self b,
167   exact le_trans _ _ _ (succ_le_succ _ _ p) h,
168 end
169 
170 lemma lt_iff_succ_le (a b : ℕ) : a < b ↔ succ a ≤ b :=
171 begin
172   split,
173   intro h,
174   apply lt_aux_one,
175   exact h,
176   intro h,
177   apply lt_aux_two,
178   exact h,
179 end