37 lines
742 B
Idris
37 lines
742 B
Idris
module Quox.Decidable
|
|
|
|
import public Decidable.Decidable
|
|
import public Decidable.Equality
|
|
import public Control.Relation
|
|
|
|
|
|
public export
|
|
0 REL : Type -> Type -> Type
|
|
REL a b = a -> b -> Type
|
|
|
|
|
|
public export
|
|
0 Pred : Type -> Type
|
|
Pred a = a -> Type
|
|
|
|
|
|
public export
|
|
0 Dec1 : Pred a -> Type
|
|
Dec1 p = (x : a) -> Dec (p x)
|
|
|
|
public export
|
|
0 Dec2 : REL a b -> Type
|
|
Dec2 p = (x : a) -> (y : b) -> Dec (p x y)
|
|
|
|
|
|
public export
|
|
(||) : Dec p -> Dec q -> Dec (Either p q)
|
|
Yes y1 || _ = Yes $ Left y1
|
|
No _ || Yes y2 = Yes $ Right y2
|
|
No n1 || No n2 = No $ \case Left y1 => n1 y1; Right y2 => n2 y2
|
|
|
|
public export
|
|
(&&) : Dec p -> Dec q -> Dec (p, q)
|
|
Yes y1 && Yes y2 = Yes (y1, y2)
|
|
Yes _ && No n2 = No $ n2 . snd
|
|
No n1 && _ = No $ n1 . fst
|