Skip to content

Commit 4681ef7

Browse files
committed
Some attempts
1 parent 1ae680c commit 4681ef7

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

src/Std/Data/DTreeMap/Internal/Lemmas.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ prelude
99
public import Std.Data.HashMap.Basic
1010
meta import Std.Data.HashMap.Basic
1111
public import Std.Data.DTreeMap.Internal.WF.Lemmas
12+
public import Init.Data.Order.ClassesExtra
1213

1314
@[expose] public section
1415

@@ -6135,6 +6136,14 @@ theorem minKey?_mem [TransOrd α] (h : t.WF) {km} :
61356136
km ∈ t := by
61366137
simp_to_model [minKey?, contains] using List.containsKey_minKey?
61376138

6139+
6140+
theorem minKey?_ofList [Ord α] [TransOrd α] [Min α] [LE α] [Std.LawfulOrderOrd α] [Std.LawfulOrderMin α] (h : t.WF):
6141+
t.minKey? = (t.toList.map Sigma.fst).min? := by
6142+
simp_to_model
6143+
sorry
6144+
6145+
6146+
61386147
theorem isSome_minKey?_of_contains [TransOrd α] (h : t.WF) {k} :
61396148
(hc : t.contains k) → t.minKey?.isSome := by
61406149
simp_to_model [minKey?, contains] using List.isSome_minKey?_of_containsKey

src/Std/Data/Internal/List/Associative.lean

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public import Std.Data.Internal.List.Defs
1313
import all Std.Data.Internal.List.Defs
1414
public import Init.Data.Order.Ord
1515
import Init.Data.Subtype.Order
16+
public import Init.Data.Order.ClassesExtra
1617

1718
public section
1819

@@ -8249,6 +8250,90 @@ theorem containsKey_minKey? [Ord α] [TransOrd α] [BEq α] [LawfulBEqOrd α] {l
82498250
obtain ⟨e, ⟨hm, _⟩, rfl⟩ := hkm
82508251
exact containsKey_of_mem hm
82518252

8253+
theorem List.minKey?_compare_eq_min?_map_fst [Ord α] [TransOrd α] [LE α] [Min α] [Std.LawfulOrderOrd α] [Std.LawfulOrderMin α] [Std.LawfulEqOrd α]
8254+
(l : List ((a : α) × β a)) :
8255+
List.minKey? l = (l.map Sigma.fst).min? := by
8256+
induction l
8257+
case nil =>
8258+
simp [minKey?_of_isEmpty]
8259+
case cons h t ih =>
8260+
simp [minKey?, minEntry?_cons]
8261+
simp [minEntry?]
8262+
split
8263+
case h_1 => sorry
8264+
case h_2 _ w heq =>
8265+
have : Associative (min : α → α → α) := by sorry
8266+
simp [List.min?_cons]
8267+
simp [min]
8268+
split
8269+
case isTrue heq2 =>
8270+
rw [← ih]
8271+
simp [Option.elim]
8272+
split
8273+
case h_1 _ _ v heq3 =>
8274+
rw [minKey?, minEntry?] at heq3
8275+
rw [heq] at heq3
8276+
simp at heq3
8277+
rw [← heq3]
8278+
have leq := (@Std.LawfulOrderOrd.isLE_compare α _ _ _ h.fst w.fst).1 heq2
8279+
apply Or.elim <| @MinEqOr.min_eq_or α _ _ h.fst w.fst
8280+
case left =>
8281+
intro hyp
8282+
rw [hyp]
8283+
case right =>
8284+
intro hyp
8285+
rw [hyp]
8286+
have := @LawfulOrderInf.le_min_iff α _ _ _ w.fst h.fst w.fst
8287+
rw [hyp] at this
8288+
have := this.1 (by simp [← Std.LawfulOrderOrd.isLE_compare])
8289+
letI inst : Antisymm (α := α) (· ≤ ·) := by
8290+
constructor
8291+
intro a b
8292+
sorry
8293+
apply @Antisymm.antisymm (α := α) (· ≤ ·) inst
8294+
· exact leq
8295+
· exact this.1
8296+
8297+
8298+
8299+
8300+
case isFalse => sorry
8301+
8302+
8303+
8304+
8305+
8306+
8307+
8308+
8309+
8310+
8311+
8312+
8313+
8314+
8315+
8316+
case isFalse heq =>
8317+
sorry
8318+
8319+
8320+
8321+
8322+
8323+
8324+
8325+
8326+
8327+
8328+
8329+
8330+
8331+
8332+
8333+
8334+
8335+
8336+
82528337
theorem minKey?_eraseKey_eq_iff_beq_minKey?_eq_false [Ord α] [TransOrd α] [BEq α] [LawfulBEqOrd α]
82538338
{k} {l : List ((a : α) × β a)} (hd : DistinctKeys l) :
82548339
minKey? (eraseKey k l) = minKey? l ↔ ∀ {km}, minKey? l = some km → (k == km) = false := by

0 commit comments

Comments
 (0)