diff --git a/lib/Quox/Syntax/Qty.idr b/lib/Quox/Syntax/Qty.idr index e5ed436..2318649 100644 --- a/lib/Quox/Syntax/Qty.idr +++ b/lib/Quox/Syntax/Qty.idr @@ -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 diff --git a/lib/Quox/Syntax/Qty/Three.idr b/lib/Quox/Syntax/Qty/Three.idr index 702cafd..2bc6585 100644 --- a/lib/Quox/Syntax/Qty/Three.idr +++ b/lib/Quox/Syntax/Qty/Three.idr @@ -99,13 +99,13 @@ IsQty Three where IsSubj = IsSubj3 isSubj = isSubj3 - zeroIsSubj = SZero + zeroIsSubj = \Refl => SZero oneIsSubj = SOne timesSubj = timesSubj3 IsGlobal = IsGlobal3 isGlobal = isGlobal3 - zeroIsGlobal = GZero + zeroIsGlobal = \Refl => GZero export Uninhabited (IsGlobal3 One) where uninhabited _ impossible diff --git a/lib/Quox/Typechecker.idr b/lib/Quox/Typechecker.idr index c875078..436023e 100644 --- a/lib/Quox/Typechecker.idr +++ b/lib/Quox/Typechecker.idr @@ -52,15 +52,6 @@ private %inline lookupFree : CanTC' q g m => Name -> m (Definition' q g) 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} mutual