2020-08-19 00:26:56 +03:00
|
|
|
module Decidable.Decidable
|
|
|
|
|
|
|
|
import Data.Rel
|
|
|
|
import Data.Fun
|
|
|
|
|
2020-12-29 00:41:12 +03:00
|
|
|
||| An n-ary relation is decidable if we can make a `Dec`
|
|
|
|
||| of its result type for each combination of inputs
|
|
|
|
public export
|
|
|
|
IsDecidable : (k : Nat) -> (ts : Vect k Type) -> Rel ts -> Type
|
|
|
|
IsDecidable k ts p = liftRel (the (Vect k Type) ts) (the (Rel ts) p) Dec
|
|
|
|
|
2020-08-19 00:26:56 +03:00
|
|
|
||| Interface for decidable n-ary Relations
|
|
|
|
public export
|
2020-12-11 14:58:26 +03:00
|
|
|
interface Decidable k ts p where
|
2020-12-29 00:41:12 +03:00
|
|
|
total decide : IsDecidable k ts p
|
2020-08-19 00:26:56 +03:00
|
|
|
|
|
|
|
||| Given a `Decidable` n-ary relation, provides a decision procedure for
|
|
|
|
||| this relation.
|
2020-12-11 14:58:26 +03:00
|
|
|
decision : (ts : Vect k Type) -> (p : Rel ts) -> (Decidable k ts p) => liftRel ts p Dec
|
2020-08-19 00:26:56 +03:00
|
|
|
decision ts p = decide {ts} {p}
|
|
|
|
|
|
|
|
using (a : Type, x : a)
|
|
|
|
public export
|
|
|
|
data Given : Dec a -> Type where
|
|
|
|
Always : Given (Yes x)
|