Compare commits

...

3 Commits

Author SHA1 Message Date
Kim Morrison
af91c6a69e don't need Lawful 2025-08-28 15:51:55 +10:00
Kim Morrison
1e203567ca . 2025-08-28 07:53:53 +10:00
Kim Morrison
eb4376a78a . 2025-08-27 11:04:19 +02:00
11 changed files with 44 additions and 0 deletions

View File

@@ -37,6 +37,10 @@ namespace ReflCmp
theorem cmp_eq_of_eq {α : Type u} {cmp : α α Ordering} [Std.ReflCmp cmp] {a b : α} : a = b cmp a b = .eq := by
intro h; subst a; apply compare_self
theorem ne_of_cmp_ne_eq {α : Type u} {cmp : α α Ordering} [Std.ReflCmp cmp] {a b : α} :
cmp a b .eq a b :=
mt cmp_eq_of_eq
end ReflCmp
/-- A typeclasses for ordered types for which `compare a a = .eq` for all `a`. -/

View File

@@ -1167,6 +1167,10 @@ theorem distinct_keys [EquivBEq α] [LawfulHashable α] :
m.keys.Pairwise (fun a b => (a == b) = false) :=
Raw₀.distinct_keys m.1, m.2.size_buckets_pos m.2
theorem nodup_keys [EquivBEq α] [LawfulHashable α] :
m.keys.Nodup :=
m.distinct_keys.imp ne_of_beq_false
@[simp]
theorem toArray_keys :
m.keys.toArray = m.keysArray :=

View File

@@ -1232,6 +1232,10 @@ theorem distinct_keys [EquivBEq α] [LawfulHashable α] (h : m.WF) :
m.keys.Pairwise (fun a b => (a == b) = false) := by
simp_to_raw using Raw₀.distinct_keys m, h.size_buckets_pos h
theorem nodup_keys [EquivBEq α] [LawfulHashable α] (h : m.WF) :
m.keys.Nodup :=
(m.distinct_keys h).imp ne_of_beq_false
@[simp, grind _=_]
theorem map_fst_toList_eq_keys [EquivBEq α] [LawfulHashable α] (h : m.WF) :
m.toList.map Sigma.fst = m.keys := by

View File

@@ -1086,6 +1086,10 @@ theorem distinct_keys [TransCmp cmp] :
t.keys.Pairwise (fun a b => ¬ cmp a b = .eq) :=
Impl.distinct_keys t.wf
theorem nodup_keys [TransCmp cmp] :
t.keys.Nodup :=
t.distinct_keys.imp Std.ReflCmp.ne_of_cmp_ne_eq
theorem ordered_keys [TransCmp cmp] :
t.keys.Pairwise (fun a b => cmp a b = .lt) :=
Impl.ordered_keys t.wf

View File

@@ -1097,6 +1097,10 @@ theorem distinct_keys [TransCmp cmp] (h : t.WF) :
t.keys.Pairwise (fun a b => ¬ cmp a b = .eq) :=
Impl.distinct_keys h.out
theorem nodup_keys [TransCmp cmp] (h : t.WF) :
t.keys.Nodup :=
(t.distinct_keys h).imp Std.ReflCmp.ne_of_cmp_ne_eq
theorem ordered_keys [TransCmp cmp] (h : t.WF) :
t.keys.Pairwise (fun a b => cmp a b = .lt) :=
Impl.ordered_keys h.out

View File

@@ -1040,6 +1040,10 @@ theorem distinct_keys [TransCmp cmp] :
t.keys.Pairwise (fun a b => ¬ cmp a b = .eq) :=
t.inductionOn fun _ => DTreeMap.distinct_keys
theorem nodup_keys [TransCmp cmp] :
t.keys.Nodup :=
t.distinct_keys.imp Std.ReflCmp.ne_of_cmp_ne_eq
theorem ordered_keys [TransCmp cmp] :
t.keys.Pairwise (fun a b => cmp a b = .lt) :=
t.inductionOn fun _ => DTreeMap.ordered_keys

View File

@@ -792,6 +792,10 @@ theorem distinct_keys [TransCmp cmp] :
t.keys.Pairwise (fun a b => ¬ cmp a b = .eq) :=
ExtDTreeMap.distinct_keys
theorem nodup_keys [TransCmp cmp] :
t.keys.Nodup :=
t.distinct_keys.imp Std.ReflCmp.ne_of_cmp_ne_eq
theorem ordered_keys [TransCmp cmp] :
t.keys.Pairwise (fun a b => cmp a b = .lt) :=
ExtDTreeMap.ordered_keys

View File

@@ -859,6 +859,10 @@ theorem distinct_keys [EquivBEq α] [LawfulHashable α] :
m.keys.Pairwise (fun a b => (a == b) = false) :=
DHashMap.distinct_keys
theorem nodup_keys [EquivBEq α] [LawfulHashable α] :
m.keys.Nodup :=
m.distinct_keys.imp ne_of_beq_false
@[simp]
theorem toArray_keys :
m.keys.toArray = m.keysArray :=

View File

@@ -874,6 +874,10 @@ theorem distinct_keys [EquivBEq α] [LawfulHashable α] (h : m.WF) :
m.keys.Pairwise (fun a b => (a == b) = false) :=
DHashMap.Raw.distinct_keys h.out
theorem nodup_keys [EquivBEq α] [LawfulHashable α] (h : m.WF) :
m.keys.Nodup :=
(m.distinct_keys h).imp ne_of_beq_false
@[simp]
theorem toArray_keys (h : m.WF) :
m.keys.toArray = m.keysArray :=

View File

@@ -820,6 +820,10 @@ theorem distinct_keys [TransCmp cmp] :
t.keys.Pairwise (fun a b => ¬ cmp a b = .eq) :=
DTreeMap.distinct_keys
theorem nodup_keys [TransCmp cmp] :
t.keys.Nodup :=
t.distinct_keys.imp Std.ReflCmp.ne_of_cmp_ne_eq
theorem ordered_keys [TransCmp cmp] :
t.keys.Pairwise (fun a b => cmp a b = .lt) :=
DTreeMap.ordered_keys

View File

@@ -815,6 +815,10 @@ theorem distinct_keys [TransCmp cmp] (h : t.WF) :
t.keys.Pairwise (fun a b => ¬ cmp a b = .eq) :=
DTreeMap.Raw.distinct_keys h
theorem nodup_keys [TransCmp cmp] (h : t.WF) :
t.keys.Nodup :=
(t.distinct_keys h).imp Std.ReflCmp.ne_of_cmp_ne_eq
theorem ordered_keys [TransCmp cmp] (h : t.WF) :
t.keys.Pairwise (fun a b => cmp a b = .lt) :=
DTreeMap.Raw.ordered_keys h