1module Decidable.Equality
5--------------------------------------------------------------------------------
7--------------------------------------------------------------------------------
9total negEqSym : {a : t} -> {b : t} -> (a = b -> _|_) -> (b = a -> _|_)
10negEqSym p h = p (sym h)
13--------------------------------------------------------------------------------
15--------------------------------------------------------------------------------
18 total decEq : (x1 : t) -> (x2 : t) -> Dec (x1 = x2)
20--------------------------------------------------------------------------------
22--------------------------------------------------------------------------------
24instance DecEq () where
25 decEq () () = Yes refl
27--------------------------------------------------------------------------------
29--------------------------------------------------------------------------------
31total trueNotFalse : True = False -> _|_
32trueNotFalse refl impossible
34instance DecEq Bool where
35 decEq True True = Yes refl
36 decEq False False = Yes refl
37 decEq True False = No trueNotFalse
38 decEq False True = No (negEqSym trueNotFalse)
40--------------------------------------------------------------------------------
42--------------------------------------------------------------------------------
44total OnotS : O = S n -> _|_
47instance DecEq Nat where
49 decEq O (S _) = No OnotS
50 decEq (S _) O = No (negEqSym OnotS)
51 decEq (S n) (S m) with (decEq n m)
52 | Yes p = Yes $ cong p
53 | No p = No $ \h : (S n = S m) => p $ succInjective n m h
55--------------------------------------------------------------------------------
57--------------------------------------------------------------------------------
59total nothingNotJust : {x : t} -> (Nothing {a = t} = Just x) -> _|_
60nothingNotJust refl impossible
62instance (DecEq t) => DecEq (Maybe t) where
63 decEq Nothing Nothing = Yes refl
64 decEq (Just x') (Just y') with (decEq x' y')
65 | Yes p = Yes $ cong p
66 | No p = No $ \h : Just x' = Just y' => p $ justInjective h
67 decEq Nothing (Just _) = No nothingNotJust
68 decEq (Just _) Nothing = No (negEqSym nothingNotJust)
70--------------------------------------------------------------------------------
72--------------------------------------------------------------------------------
74total leftNotRight : {x : a} -> {y : b} -> Left {b = b} x = Right {a = a} y -> _|_
75leftNotRight refl impossible
77instance (DecEq a, DecEq b) => DecEq (Either a b) where
78 decEq (Left x') (Left y') with (decEq x' y')
79 | Yes p = Yes $ cong p
80 | No p = No $ \h : Left x' = Left y' => p $ leftInjective {b = b} h
81 decEq (Right x') (Right y') with (decEq x' y')
82 | Yes p = Yes $ cong p
83 | No p = No $ \h : Right x' = Right y' => p $ rightInjective {a = a} h
84 decEq (Left x') (Right y') = No leftNotRight
85 decEq (Right x') (Left y') = No $ negEqSym leftNotRight
87--------------------------------------------------------------------------------
89--------------------------------------------------------------------------------
91total fONotfS : {f : Fin n} -> fO {k = n} = fS f -> _|_
92fONotfS refl impossible
94instance DecEq (Fin n) where
95 decEq fO fO = Yes refl
96 decEq fO (fS f) = No fONotfS
97 decEq (fS f) fO = No $ negEqSym fONotfS
98 decEq (fS f) (fS f') with (decEq f f')
99 | Yes p = Yes $ cong p
100 | No p = No $ \h => p $ fSinjective {f = f} {f' = f'} h
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list