Skip to content

Instantly share code, notes, and snippets.

@Kazark
Last active October 25, 2019 01:02
Show Gist options
  • Save Kazark/089896e622cbb900d0fd084fa32342b7 to your computer and use it in GitHub Desktop.
Save Kazark/089896e622cbb900d0fd084fa32342b7 to your computer and use it in GitHub Desktop.
Who needs constructivism? Make types out of Boolean predicates! (Encoded constructively...)
module Guard
%default total
%access public export
data Guarded : (a -> Bool) -> a -> Type where
Guard : (pred : a -> Bool) -> (subject : a) -> (prf : pred subject = True)
-> Guarded pred subject
data GuardedIsBogus : Type where
BogusIf : (pred : a -> Bool) -> (subject : a)
-> (counter : pred subject = False) -> Guarded pred subject
-> GuardedIsBogus
Uninhabited GuardedIsBogus where
uninhabited (BogusIf pred subject counter (Guard pred subject prf)) =
trueNotFalse $ trans (sym prf) counter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment