lean4-htt/tests/lean/derivingDecidableEq.lean
ammkrn 102e957bb5 feat: support proofs in deriving DecidableEq
The derive handler for `DecidableEq` does not currently support proofs
in constructor arguments/structure fields. For example, deriving
`DecidableEq` for `Fin n` will fail, because of the field `isLt`. This
change checks whether the elements being tested are proofs, and if so,
changes the equality proof to just `rfl`.
2022-05-30 07:36:30 -07:00

25 lines
566 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

structure Fin' (n : Nat) where
val : Nat
isLt : val < n
deriving DecidableEq
#eval
(Fin'.mk 0 (Nat.lt.step (Nat.lt.base 0)): Fin' 2)
= (Fin'.mk 0 (Nat.lt.step (Nat.lt.base 0)) : Fin' 2)
#eval
(Fin'.mk 0 (Nat.lt.step (Nat.lt.base 0)): Fin' 2)
= (Fin'.mk 1 (Nat.lt.base 1) : Fin' 2)
inductive List' (α : Type u) where
| nil : List' α
| cons (head : α) (tail : List' α) (h : head = head) : List' α
deriving DecidableEq
#eval
List'.nil.cons 0 rfl
= List'.nil.cons 0 rfl
#eval
List'.nil.cons 0 rfl
= (List'.nil.cons 0 rfl).cons 1 rfl