zeroIsSubj/zeroIsGlobal work on all zeroes

This commit is contained in:
rhiannon morris 2023-02-19 17:42:11 +01:00
parent e375d008e5
commit 810de09f61
3 changed files with 17 additions and 15 deletions

View file

@ -48,7 +48,7 @@ interface Eq q => IsQty q where
||| subject of a typing judgement [@qtt, §2.3].
IsSubj : Pred q
isSubj : Dec1 IsSubj
zeroIsSubj : IsSubj zero
zeroIsSubj : forall pi. IsZero pi -> IsSubj pi
oneIsSubj : IsSubj one
timesSubj : forall pi, rh. IsSubj pi -> IsSubj rh -> IsSubj (pi * rh)
@ -56,7 +56,7 @@ interface Eq q => IsQty q where
||| quantity. so not exact usage counts, maybe.
IsGlobal : Pred q
isGlobal : Dec1 IsGlobal
zeroIsGlobal : IsGlobal zero
zeroIsGlobal : forall pi. IsZero pi -> IsGlobal zero
public export
0 SQty : (q : Type) -> IsQty q => Type
@ -64,16 +64,27 @@ SQty q = Subset q IsSubj
public export %inline
szero : IsQty q => SQty q
szero = Element zero zeroIsSubj
szero = Element zero $ zeroIsSubj zeroIsZero
public export %inline
sone : IsQty q => SQty q
sone = Element one oneIsSubj
||| "σ ⨴ π"
|||
||| ``sg `subjMult` pi`` is equal to `pi` if it is zero, otherwise it
||| is equal to `sg`.
public export %inline
subjMult : IsQty q => SQty q -> q -> SQty q
subjMult sg pi = case isZero pi of
Yes y => Element pi $ zeroIsSubj y
No _ => sg
public export
0 GQty : (q : Type) -> IsQty q => Type
GQty q = Subset q IsGlobal
public export %inline
gzero : IsQty q => GQty q
gzero = Element zero zeroIsGlobal
gzero = Element zero $ zeroIsGlobal zeroIsZero