zeroIsSubj/zeroIsGlobal work on all zeroes
This commit is contained in:
parent
e375d008e5
commit
810de09f61
3 changed files with 17 additions and 15 deletions
|
@ -48,7 +48,7 @@ interface Eq q => IsQty q where
|
||||||
||| subject of a typing judgement [@qtt, §2.3].
|
||| subject of a typing judgement [@qtt, §2.3].
|
||||||
IsSubj : Pred q
|
IsSubj : Pred q
|
||||||
isSubj : Dec1 IsSubj
|
isSubj : Dec1 IsSubj
|
||||||
zeroIsSubj : IsSubj zero
|
zeroIsSubj : forall pi. IsZero pi -> IsSubj pi
|
||||||
oneIsSubj : IsSubj one
|
oneIsSubj : IsSubj one
|
||||||
timesSubj : forall pi, rh. IsSubj pi -> IsSubj rh -> IsSubj (pi * rh)
|
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.
|
||| quantity. so not exact usage counts, maybe.
|
||||||
IsGlobal : Pred q
|
IsGlobal : Pred q
|
||||||
isGlobal : Dec1 IsGlobal
|
isGlobal : Dec1 IsGlobal
|
||||||
zeroIsGlobal : IsGlobal zero
|
zeroIsGlobal : forall pi. IsZero pi -> IsGlobal zero
|
||||||
|
|
||||||
public export
|
public export
|
||||||
0 SQty : (q : Type) -> IsQty q => Type
|
0 SQty : (q : Type) -> IsQty q => Type
|
||||||
|
@ -64,16 +64,27 @@ SQty q = Subset q IsSubj
|
||||||
|
|
||||||
public export %inline
|
public export %inline
|
||||||
szero : IsQty q => SQty q
|
szero : IsQty q => SQty q
|
||||||
szero = Element zero zeroIsSubj
|
szero = Element zero $ zeroIsSubj zeroIsZero
|
||||||
|
|
||||||
public export %inline
|
public export %inline
|
||||||
sone : IsQty q => SQty q
|
sone : IsQty q => SQty q
|
||||||
sone = Element one oneIsSubj
|
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
|
public export
|
||||||
0 GQty : (q : Type) -> IsQty q => Type
|
0 GQty : (q : Type) -> IsQty q => Type
|
||||||
GQty q = Subset q IsGlobal
|
GQty q = Subset q IsGlobal
|
||||||
|
|
||||||
public export %inline
|
public export %inline
|
||||||
gzero : IsQty q => GQty q
|
gzero : IsQty q => GQty q
|
||||||
gzero = Element zero zeroIsGlobal
|
gzero = Element zero $ zeroIsGlobal zeroIsZero
|
||||||
|
|
|
@ -99,13 +99,13 @@ IsQty Three where
|
||||||
|
|
||||||
IsSubj = IsSubj3
|
IsSubj = IsSubj3
|
||||||
isSubj = isSubj3
|
isSubj = isSubj3
|
||||||
zeroIsSubj = SZero
|
zeroIsSubj = \Refl => SZero
|
||||||
oneIsSubj = SOne
|
oneIsSubj = SOne
|
||||||
timesSubj = timesSubj3
|
timesSubj = timesSubj3
|
||||||
|
|
||||||
IsGlobal = IsGlobal3
|
IsGlobal = IsGlobal3
|
||||||
isGlobal = isGlobal3
|
isGlobal = isGlobal3
|
||||||
zeroIsGlobal = GZero
|
zeroIsGlobal = \Refl => GZero
|
||||||
|
|
||||||
|
|
||||||
export Uninhabited (IsGlobal3 One) where uninhabited _ impossible
|
export Uninhabited (IsGlobal3 One) where uninhabited _ impossible
|
||||||
|
|
|
@ -52,15 +52,6 @@ private %inline
|
||||||
lookupFree : CanTC' q g m => Name -> m (Definition' q g)
|
lookupFree : CanTC' q g m => Name -> m (Definition' q g)
|
||||||
lookupFree x = lookupFree' !ask x
|
lookupFree x = lookupFree' !ask x
|
||||||
|
|
||||||
||| ``sg `subjMult` pi`` is zero if either argument is, otherwise it
|
|
||||||
||| is equal to `sg`. (written as "σ ⨴ π" to emphasise its left bias.)
|
|
||||||
|||
|
|
||||||
||| only certain quantities can occur for a typing judgement to avoid losing
|
|
||||||
||| subject reduction [@qtt, §2.3], which is why this is not just `sg*pi`.
|
|
||||||
private %inline
|
|
||||||
subjMult : IsQty q => SQty q -> q -> SQty q
|
|
||||||
subjMult sg pi = if isYes $ isZero pi then szero else sg
|
|
||||||
|
|
||||||
|
|
||||||
parameters {auto _ : IsQty q} {auto _ : CanTC q m}
|
parameters {auto _ : IsQty q} {auto _ : CanTC q m}
|
||||||
mutual
|
mutual
|
||||||
|
|
Loading…
Reference in a new issue