File tree Expand file tree Collapse file tree 3 files changed +10
-15
lines changed
Expand file tree Collapse file tree 3 files changed +10
-15
lines changed Original file line number Diff line number Diff line change @@ -94,10 +94,8 @@ theorem List.palindrome_of_eq_reverse (h : as.reverse = as) : Palindrome as := b
9494 next => exact Palindrome.nil
9595 next a => exact Palindrome.single a
9696 next a b as ih =>
97- have : a = b := by simp_all
98- subst this
99- have : as.reverse = as := by simp_all
100- exact Palindrome.sandwich a (ih this)
97+ obtain ⟨rfl, h, -⟩ := by simpa using h
98+ exact Palindrome.sandwich b (ih h)
10199
102100/-!
103101We now define a function that returns `true` iff `as` is a palindrome.
Original file line number Diff line number Diff line change @@ -245,26 +245,20 @@ theorem back_eq_of_push_eq {a b : α} {xs ys : Array α} (h : xs.push a = ys.pus
245245 replace h := List.append_inj_right' h (by simp)
246246 simpa using h
247247
248- theorem pop_eq_of_push_eq {a b : α} {xs ys : Array α} (h : xs.push a = ys.push b) : xs = ys := by
248+ theorem push_eq_push {a b : α} {xs ys : Array α} : xs.push a = ys.push b ↔ a = b ∧ xs = ys := by
249249 cases xs
250250 cases ys
251- simp at h
252- replace h := List.append_inj_left' h (by simp)
253- simp [h]
251+ simp [And.comm]
252+
253+ theorem pop_eq_of_push_eq {a b : α} {xs ys : Array α} (h : xs.push a = ys.push b) : xs = ys :=
254+ (push_eq_push.1 h).2
254255
255256theorem push_inj_left {a : α} {xs ys : Array α} : xs.push a = ys.push a ↔ xs = ys :=
256257 ⟨pop_eq_of_push_eq, fun h => by simp [h]⟩
257258
258259theorem push_inj_right {a b : α} {xs : Array α} : xs.push a = xs.push b ↔ a = b :=
259260 ⟨back_eq_of_push_eq, fun h => by simp [h]⟩
260261
261- theorem push_eq_push {a b : α} {xs ys : Array α} : xs.push a = ys.push b ↔ a = b ∧ xs = ys := by
262- constructor
263- · intro h
264- exact ⟨back_eq_of_push_eq h, pop_eq_of_push_eq h⟩
265- · rintro ⟨rfl, rfl⟩
266- rfl
267-
268262theorem exists_push_of_ne_empty {xs : Array α} (h : xs ≠ #[]) :
269263 ∃ (ys : Array α) (a : α), xs = ys.push a := by
270264 rcases xs with ⟨xs⟩
Original file line number Diff line number Diff line change @@ -2494,6 +2494,9 @@ theorem flatten_reverse {L : List (List α)} :
24942494 ⟨by rw [length_reverse, length_replicate],
24952495 fun _ h => eq_of_mem_replicate (mem_reverse.1 h)⟩
24962496
2497+ @[simp]
2498+ theorem append_singleton_inj {as bs : List α} : as ++ [a] = bs ++ [b] ↔ as = bs ∧ a = b := by
2499+ rw [← List.reverse_inj, And.comm]; simp
24972500
24982501/-! ### foldlM and foldrM -/
24992502
You can’t perform that action at this time.
0 commit comments