natural-number-game

Solututions to the Natural Number Game

advanced-addition.lean (1760B)

 1 theorem succ_inj' {a b : mynat} (hs : succ(a) = succ(b)) :  a = b := 
 2 begin
 3   apply succ_inj,
 4   exact hs,
 5 end
 6 
 7 theorem succ_succ_inj {a b : mynat} 
 8                       (h : succ(succ(a)) = succ(succ(b))) : a = b := 
 9 begin
10   apply succ_inj,
11   apply succ_inj,
12   exact h,
13 end
14 
15 theorem succ_eq_succ_of_eq {a b : mynat} : a = b → succ(a) = succ(b) :=
16 begin
17   intro h,
18   rw h,
19   refl,
20 end
21 
22 theorem succ_eq_succ_iff (a b : mynat) : succ a = succ b ↔ a = b :=
23 begin
24   split,
25   exact succ_inj,
26   exact succ_eq_succ_of_eq,
27 end
28 
29 theorem add_right_cancel (a t b : mynat) : a + t = b + t → a = b :=
30 begin
31   induction t,
32   intro h,
33   repeat {rw add_zero at h},
34   exact h,
35   intro h,
36   repeat {rw add_succ at h},
37   apply t_ih,
38   exact succ_inj h,
39 end
40 
41 theorem add_left_cancel (t a b : mynat) : t + a = t + b → a = b :=
42 begin
43   rw add_comm t,
44   rw add_comm t,
45   exact add_right_cancel a t b,
46 end
47 
48 lemma eq_zero_of_add_right_eq_self {a b : mynat} : a + b = a → b = 0 :=
49 begin
50   intro h,
51   rw ← add_zero a at h,
52   rw add_assoc at h,
53   rw zero_add at h,
54   apply add_left_cancel a b 0,
55   exact h,
56 end
57 
58 theorem succ_ne_zero (a : mynat) : succ a ≠ 0 := 
59 begin
60   symmetry,
61   exact zero_ne_succ a,
62 end
63 
64 lemma add_left_eq_zero {a b : mynat} (h : a + b = 0) : b = 0 :=
65 begin
66   cases b with d,
67   refl,
68   exfalso,
69   rw add_succ at h,
70   apply succ_ne_zero (a + d),
71   exact h,
72 end
73 
74 lemma add_right_eq_zero {a b : mynat} : a + b = 0 → a = 0 :=
75 begin
76   rw add_comm,
77   apply add_left_eq_zero,
78 end
79 
80 lemma ne_succ_self (n : mynat) : n ≠ succ n :=
81 begin
82   intro h,
83   rw succ_eq_add_one at h,
84   rw ← add_zero n at h,
85   rw add_assoc at h,
86   rw zero_add at h,
87   have p := add_left_cancel n 0 1 h,
88   rw one_eq_succ_zero at p,
89   apply succ_ne_zero 0,
90   symmetry,
91   exact p,
92 end
93