@@ -100,9 +100,9 @@ Here is a summary of the steps required to add and verify a new operation:
100
100
* Connect the implementation on lists and associative lists in `Internal.AssocList.Lemmas` via a
101
101
lemma `AssocList.operation_eq`.
102
102
3. Write the model implementation
103
- * Write the model implementation `Raw₀.operationₘ` in `Internal.List. Model`
103
+ * Write the model implementation `Raw₀.operationₘ` in `Internal.Model`
104
104
* Prove that the model implementation is equal to the actual implementation in
105
- `Internal.List. Model` via a lemma `operation_eq_operationₘ`.
105
+ `Internal.Model` via a lemma `operation_eq_operationₘ`.
106
106
4. Verify the model implementation
107
107
* In `Internal.WF`, prove `operationₘ_eq_List.operation` (for access operations) or
108
108
`wfImp_operationₘ` and `toListModel_operationₘ`
@@ -121,18 +121,18 @@ Here is a summary of the steps required to add and verify a new operation:
121
121
might also have to prove that your list operation is invariant under permutation and add that to
122
122
the tactic.
123
123
7. State and prove the user-facing lemmas
124
- * Restate all of your lemmas for `DHashMap.Raw` in `DHashMap.Lemmas ` and prove them using the
124
+ * Restate all of your lemmas for `DHashMap.Raw` in `DHashMap.RawLemmas ` and prove them using the
125
125
provided tactic after hooking in your `operation_eq` and `operation_val` from step 5.
126
126
* Restate all of your lemmas for `DHashMap` in `DHashMap.Lemmas` and prove them by reducing to
127
127
`Raw₀`.
128
- * Restate all of your lemmas for `HashMap.Raw` in `HashMap.Lemmas ` and prove them by reducing to
128
+ * Restate all of your lemmas for `HashMap.Raw` in `HashMap.RawLemmas ` and prove them by reducing to
129
129
`DHashMap.Raw`.
130
130
* Restate all of your lemmas for `HashMap` in `HashMap.Lemmas` and prove them by reducing to
131
131
`DHashMap`.
132
- * Restate all of your lemmas for `HashSet.Raw` in `HashSet.Lemmas ` and prove them by reducing to
133
- `DHashSet .Raw`.
132
+ * Restate all of your lemmas for `HashSet.Raw` in `HashSet.RawLemmas ` and prove them by reducing to
133
+ `HashMap .Raw`.
134
134
* Restate all of your lemmas for `HashSet` in `HashSet.Lemmas` and prove them by reducing to
135
- `DHashSet `.
135
+ `HashMap `.
136
136
137
137
This sounds like a lot of work (and it is if you have to add a lot of user-facing lemmas), but the
138
138
framework is set up in such a way that each step is really easy and the proofs are all really short
@@ -420,6 +420,30 @@ variable {β : Type v}
420
420
421
421
end
422
422
423
+ /-- Internal implementation detail of the hash map -/
424
+ @[inline] def getKey? [BEq α] [Hashable α] (m : Raw₀ α β) (a : α) : Option α :=
425
+ let ⟨⟨_, buckets⟩, h⟩ := m
426
+ let ⟨i, h⟩ := mkIdx buckets.size h (hash a)
427
+ buckets[i].getKey? a
428
+
429
+ /-- Internal implementation detail of the hash map -/
430
+ @[inline] def getKey [BEq α] [Hashable α] (m : Raw₀ α β) (a : α) (hma : m.contains a) : α :=
431
+ let ⟨⟨_, buckets⟩, h⟩ := m
432
+ let idx := mkIdx buckets.size h (hash a)
433
+ buckets[idx.1 ].getKey a hma
434
+
435
+ /-- Internal implementation detail of the hash map -/
436
+ @[inline] def getKeyD [BEq α] [Hashable α] (m : Raw₀ α β) (a : α) (fallback : α) : α :=
437
+ let ⟨⟨_, buckets⟩, h⟩ := m
438
+ let idx := mkIdx buckets.size h (hash a)
439
+ buckets[idx.1 ].getKeyD a fallback
440
+
441
+ /-- Internal implementation detail of the hash map -/
442
+ @[inline] def getKey! [BEq α] [Hashable α] [Inhabited α] (m : Raw₀ α β) (a : α) : α :=
443
+ let ⟨⟨_, buckets⟩, h⟩ := m
444
+ let idx := mkIdx buckets.size h (hash a)
445
+ buckets[idx.1 ].getKey! a
446
+
423
447
end Raw₀
424
448
425
449
/-- Internal implementation detail of the hash map -/
0 commit comments