on master help sign in
Merge pull request #3905 from clayrat/patch-1

add proof of `decEq x x = Yes Refl`

commit05fbd119066bfbc7398ff4a07ad1d627562f4357 authorDavid Christiansen <david@davidchristiansen.dk> dateWed 12 Jul 2017, 12:02 (9 years ago) parent9fb9d7f2c8c1cd
2 files changed+18−9
CHANGELOG.md+3 libs/prelude/Decidable/Equality.idr+15−9
CHANGELOG.md+3
@@ -22,6 +22,9 @@
2222 with a (strictly) smaller `size`.
2323
2424 A good example of this idiom at work is `Data.List.Views.splitRec` from `base`.
25++ Added utility lemma `decEqSelfIsYes : decEq x x = Yes Refl` to
26+ `Decidable.Equality`. This is primarily useful for proving properties of
27+ functions defined with the help of `decEq`.
2528
2629## Tool Updates
2730
libs/prelude/Decidable/Equality.idr+15−9
@@ -8,18 +8,10 @@ import Prelude.Either
88import Prelude.List
99import Prelude.Nat
1010import Prelude.Maybe
11+import Prelude.Uninhabited
1112
1213%access public export
1314
14−--------------------------------------------------------------------------------
15−-- Utility lemmas
16−--------------------------------------------------------------------------------
17−
18−||| The negation of equality is symmetric (follows from symmetry of equality)
19−total negEqSym : {a : t} -> {b : t} -> (a = b -> Void) -> (b = a -> Void)
20−negEqSym p h = p (sym h)
21−
22−
2315--------------------------------------------------------------------------------
2416-- Decidable equality
2517--------------------------------------------------------------------------------
@@ -29,6 +21,20 @@ interface DecEq t where
2921 ||| Decide whether two elements of `t` are propositionally equal
3022 total decEq : (x1 : t) -> (x2 : t) -> Dec (x1 = x2)
3123
24+--------------------------------------------------------------------------------
25+-- Utility lemmas
26+--------------------------------------------------------------------------------
27+
28+||| The negation of equality is symmetric (follows from symmetry of equality)
29+total negEqSym : {a : t} -> {b : t} -> (a = b -> Void) -> (b = a -> Void)
30+negEqSym p h = p (sym h)
31+
32+||| Everything is decidably equal to itself
33+total decEqSelfIsYes : DecEq a => {x : a} -> decEq x x = Yes Refl
34+decEqSelfIsYes {x} with (decEq x x)
35+ | Yes Refl = Refl
36+ | No contra = absurd $ contra Refl
37+
3238--------------------------------------------------------------------------------
3339--- Unit
3440--------------------------------------------------------------------------------