@@ -95,42 +95,14 @@ theorem minBalance_eq_zero_iff {l : List Paren} : minBalance l = 0 ↔ ∀ k, 0
9595 Nat.zero_le, true_and, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂]
9696 exact ⟨fun h n => List.take_eq_take_min ▸ h (min n l.length) (by simp), fun h n _ => h n⟩
9797
98- theorem add_min [Add α] [Min α] [LE α] [comm : Std.Commutative (α := α) (· + ·)] [Std.IsPartialOrder α] [Std.LawfulOrderMin α]
99- [Lean.Grind.OrderedAdd α] {a b c : α} : a + min b c = min (a + b) (a + c) := by
100- refine Std.le_antisymm ?_ ?_
101- · rw [Std.le_min_iff, comm.comm a, comm.comm a, ← Lean.Grind.OrderedAdd.add_le_left_iff,
102- comm.comm a, ← Lean.Grind.OrderedAdd.add_le_left_iff]
103- exact ⟨Std.min_le_left, Std.min_le_right⟩
104- · rw [Std.min_le, comm.comm a, comm.comm a, ← Lean.Grind.OrderedAdd.add_le_left_iff,
105- comm.comm a, ← Lean.Grind.OrderedAdd.add_le_left_iff]
106- obtain (h|h) := Std.min_eq_or (a := b) (b := c)
107- · rw (occs := [1 ]) [← h]
108- simp
109- · rw (occs := [2 ]) [← h]
110- simp
111-
112- theorem List.add_min [Add α] [Min α] [LE α] [comm : Std.Commutative (α := α) (· + ·)] [Std.IsPartialOrder α] [Std.LawfulOrderMin α]
113- [Lean.Grind.OrderedAdd α] {a : α} {l : List α} {h} :
114- a + l.min h = (l.map (a + ·)).min (by simpa) := by
115- generalize hlen : l.length = n
116- induction n generalizing l with
117- | zero => simp_all
118- | succ n ih =>
119- match n, l, hlen with
120- | 0 , [b], _ => simp
121- | 1 , [b, c], _ => simp [_root_.add_min]
122- | n + 2 , b :: c :: tl, _ =>
123- simp only [min_cons_cons, map_cons]
124- rw [ih (by grind)]
125- simp [map_cons, _root_.add_min]
126-
12798@[simp]
12899theorem minBalance_cons {l : List Paren} {p : Paren} :
129100 minBalance (p :: l) = min 0 (p.toInt + minBalance l) := by
130101 rw [minBalance]
131102 simp [Nat.toList_rcc_succ_right_eq_cons_map]
132103 rw [List.min_cons, List.min?_eq_some_min (by simp)]
133- simp only [Option.elim_some, minBalance, List.add_min, List.map_map]
104+ simp only [Option.elim_some, minBalance, ← (List.min_map_eq_min (f := (p.toInt + ·)) (by simp)),
105+ List.map_map]
134106 congr 1
135107
136108@[simp]
0 commit comments