2023-01-08 14:44:25 -05:00
|
|
|
|
module Quox.Syntax.Qty.Three
|
|
|
|
|
|
|
|
|
|
import Quox.Pretty
|
|
|
|
|
import public Quox.Syntax.Qty
|
|
|
|
|
import Generics.Derive
|
|
|
|
|
|
|
|
|
|
%default total
|
|
|
|
|
%language ElabReflection
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public export
|
|
|
|
|
data Three = Zero | One | Any
|
|
|
|
|
%name Three pi, rh
|
|
|
|
|
|
|
|
|
|
%runElab derive "Three" [Generic, Meta, Eq, Ord, DecEq, Show]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export
|
|
|
|
|
PrettyHL Three where
|
|
|
|
|
prettyM pi = hl Qty <$>
|
|
|
|
|
case pi of
|
|
|
|
|
Zero => ifUnicode "𝟬" "0"
|
|
|
|
|
One => ifUnicode "𝟭" "1"
|
|
|
|
|
Any => ifUnicode "𝛚" "*"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public export
|
|
|
|
|
plus : Three -> Three -> Three
|
|
|
|
|
plus Zero rh = rh
|
|
|
|
|
plus pi Zero = pi
|
|
|
|
|
plus _ _ = Any
|
|
|
|
|
|
|
|
|
|
public export
|
|
|
|
|
times : Three -> Three -> Three
|
|
|
|
|
times Zero _ = Zero
|
|
|
|
|
times _ Zero = Zero
|
|
|
|
|
times One rh = rh
|
|
|
|
|
times pi One = pi
|
|
|
|
|
times Any Any = Any
|
|
|
|
|
|
|
|
|
|
public export
|
2023-01-09 17:43:23 -05:00
|
|
|
|
data Compat3 : Rel Three where
|
|
|
|
|
CmpRefl : Compat3 rh rh
|
|
|
|
|
CmpAny : Compat3 rh Any
|
2023-01-08 14:44:25 -05:00
|
|
|
|
|
|
|
|
|
public export
|
2023-01-09 17:43:23 -05:00
|
|
|
|
compat3 : Dec2 Compat3
|
2023-01-09 17:45:21 -05:00
|
|
|
|
compat3 pi rh with (decEq pi rh) | (decEq rh Any)
|
|
|
|
|
compat3 pi pi | Yes Refl | _ = Yes CmpRefl
|
|
|
|
|
compat3 pi Any | No _ | Yes Refl = Yes CmpAny
|
|
|
|
|
compat3 pi rh | No ne | No na =
|
|
|
|
|
No $ \case CmpRefl => ne Refl; CmpAny => na Refl
|
2023-01-08 14:44:25 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public export
|
2023-01-09 17:43:23 -05:00
|
|
|
|
data IsSubj3 : Pred Three where
|
2023-01-08 14:44:25 -05:00
|
|
|
|
SZero : IsSubj3 Zero
|
|
|
|
|
SOne : IsSubj3 One
|
|
|
|
|
|
|
|
|
|
public export
|
2023-01-09 17:43:23 -05:00
|
|
|
|
isSubj3 : Dec1 IsSubj3
|
2023-01-08 14:44:25 -05:00
|
|
|
|
isSubj3 Zero = Yes SZero
|
|
|
|
|
isSubj3 One = Yes SOne
|
|
|
|
|
isSubj3 Any = No $ \case _ impossible
|
|
|
|
|
|
2023-01-09 17:43:55 -05:00
|
|
|
|
public export
|
|
|
|
|
timesSubj3 : forall pi, rh. IsSubj3 pi -> IsSubj3 rh -> IsSubj3 (times pi rh)
|
|
|
|
|
timesSubj3 SZero SZero = SZero
|
|
|
|
|
timesSubj3 SZero SOne = SZero
|
|
|
|
|
timesSubj3 SOne SZero = SZero
|
|
|
|
|
timesSubj3 SOne SOne = SOne
|
|
|
|
|
|
2023-01-08 14:44:25 -05:00
|
|
|
|
|
|
|
|
|
public export
|
2023-01-09 17:43:23 -05:00
|
|
|
|
data IsGlobal3 : Pred Three where
|
2023-01-08 14:44:25 -05:00
|
|
|
|
GZero : IsGlobal3 Zero
|
|
|
|
|
GAny : IsGlobal3 Any
|
|
|
|
|
|
2023-01-09 17:43:23 -05:00
|
|
|
|
isGlobal3 : Dec1 IsGlobal3
|
2023-01-08 14:44:25 -05:00
|
|
|
|
isGlobal3 Zero = Yes GZero
|
|
|
|
|
isGlobal3 One = No $ \case _ impossible
|
|
|
|
|
isGlobal3 Any = Yes GAny
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public export
|
|
|
|
|
IsQty Three where
|
|
|
|
|
zero = Zero
|
|
|
|
|
one = One
|
|
|
|
|
|
|
|
|
|
(+) = plus
|
|
|
|
|
(*) = times
|
|
|
|
|
|
|
|
|
|
IsZero = Equal Zero
|
|
|
|
|
isZero = decEq Zero
|
|
|
|
|
zeroIsZero = Refl
|
|
|
|
|
|
|
|
|
|
Compat = Compat3
|
|
|
|
|
compat = compat3
|
|
|
|
|
|
|
|
|
|
IsSubj = IsSubj3
|
|
|
|
|
isSubj = isSubj3
|
|
|
|
|
zeroIsSubj = SZero
|
|
|
|
|
oneIsSubj = SOne
|
2023-01-09 17:43:55 -05:00
|
|
|
|
timesSubj = timesSubj3
|
2023-01-08 14:44:25 -05:00
|
|
|
|
|
|
|
|
|
IsGlobal = IsGlobal3
|
|
|
|
|
isGlobal = isGlobal3
|
|
|
|
|
zeroIsGlobal = GZero
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export Uninhabited (IsGlobal3 One) where uninhabited _ impossible
|
|
|
|
|
|
|
|
|
|
export Uninhabited (IsSubj3 Any) where uninhabited _ impossible
|