fix nat elim quantities

This commit is contained in:
rhiannon morris 2023-04-01 16:01:53 +02:00
parent 036e2bd4a5
commit 15f6f4c8a4
4 changed files with 41 additions and 9 deletions

View file

@ -10,9 +10,10 @@ import Data.DPair
public export
interface Eq q => IsQty q where
zero, one : q
(+), (*) : q -> q -> q
lub : q -> q -> Maybe q
zero, one, any : q
(+), (*) : q -> q -> q
lub : q -> q -> Maybe q
||| true if bindings of this quantity will be erased
||| and must not be runtime relevant
@ -20,6 +21,12 @@ interface Eq q => IsQty q where
isZero : Dec1 IsZero
zeroIsZero : IsZero zero
||| true if bindings of this quantity can be used any number of times.
||| this is needed for natural elimination
IsAny : Pred q
isAny : Dec1 IsAny
anyIsAny : IsAny any
||| ``p `Compat` q`` if it is ok for a binding of quantity `q` to be used
||| exactly `p` times. e.g. ``1 `Compat` 1``, ``1 `Compat` ω``.
||| if ``π `lub` ρ`` exists, then both `π` and `ρ` must be compatible with it
@ -38,7 +45,8 @@ interface Eq q => IsQty q where
||| quantity. so not exact usage counts, maybe.
IsGlobal : Pred q
isGlobal : Dec1 IsGlobal
zeroIsGlobal : forall pi. IsZero pi -> IsGlobal zero
zeroIsGlobal : forall pi. IsZero pi -> IsGlobal pi
anyIsGlobal : forall pi. IsAny pi -> IsGlobal pi
||| prints in a form that can be a suffix of "case"
prettySuffix : Pretty.HasEnv m => q -> m (Doc HL)
@ -74,6 +82,10 @@ public export %inline
gzero : IsQty q => GQty q
gzero = Element zero $ zeroIsGlobal zeroIsZero
public export %inline
gany : IsQty q => GQty q
gany = Element any $ anyIsGlobal anyIsAny
export %inline
globalToSubj : IsQty q => GQty q -> SQty q
globalToSubj q = if isYes $ isZero q.fst then szero else sone