File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,38 @@ lemma succ_add_own (m n : Nat) : Nat.succ m + n = Nat.succ (m + n) := by
8282 rw [ih]
8383 rfl
8484
85+ lemma append_nil_own (l : List Nat) : l ++ [] = l := by
86+ induction l with
87+ | nil =>
88+ rfl
89+ | cons hd tl ih =>
90+ simp [List.append]
91+
92+ lemma nil_append_own (l : List Nat) : [] ++ l = l := by
93+ induction l with
94+ | nil =>
95+ rfl
96+ | cons hd tl ih =>
97+ simp [List.append]
98+
99+ lemma sum_append (l1 l2 : List Nat) : (l1 ++ l2).sum = l1.sum + l2.sum := by
100+ induction l1 with
101+ | nil =>
102+ -- base case: [] ++ l2 = l2
103+ -- ([] ++ l2).sum = l2.sum, and [].sum = 0
104+ -- so goal: l2.sum = 0 + l2.sum
105+ rw [List.sum_nil]
106+ rw [Nat.zero_add]
107+ rw [List.nil_append]
108+ | cons hd tl ih =>
109+ -- Goal: ((hd :: tl) ++ l2).sum = (hd :: tl).sum + l2.sum
110+ change (hd :: (tl ++ l2)).sum = (hd :: tl).sum + l2.sum
111+ -- Expand sums of cons on both sides
112+ change hd + (tl ++ l2).sum = (hd + tl.sum) + l2.sum
113+ -- Use the inductive hypothesis
114+ rw [ih]
115+ -- Reassociate
116+ rw [Nat.add_assoc]
85117
86118theorem and_comm_own (p q : Prop ) : p ∧ q ↔ q ∧ p := by
87119 constructor
You can’t perform that action at this time.
0 commit comments