lean4-htt/tests/lean/run/exthashset_deceq.lean
Wojciech Różowski 07645775e6
feat: add decidable equality to DHashMap/HashMap/HashSet and their extensional variants (#11421)
This PR adds decidable equality to `DHashMap`/`HashMap`/`HashSet` and
their extensional variants.

Stacked on top of #11266.
2025-12-12 09:55:55 +00:00

24 lines
528 B
Text

import Std.Data.ExtHashSet
open Std
@[ext]
structure A where
a : Nat
b : Nat
deriving Hashable
instance : BEq A where
beq x y := x.b == y.b && x.a == y.a
@[simp]
theorem A.beq_eq {x y : A} : (x == y) = (x.b == y.b && x.a == y.a) := rfl
instance : LawfulBEq A where
rfl {x} := by simp
eq_of_beq {x y} := by grind [A.beq_eq, A.ext]
instance : DecidableEq A :=
fun x y => by simp [A.ext_iff]; infer_instance
example : Decidable (ExtHashSet.ofList [A.mk 1 2] = ExtHashSet.ofList [A.mk 1 2]) := by
infer_instance