Safe Haskell | None |
---|---|
Language | Haskell2010 |
Set-theoretic ordinals for general peano arithmetic models
- data Ordinal n where
- pattern OZ :: forall nat n. IsPeano nat => (~) Bool ((:<) nat (Zero nat) n) True => Ordinal nat n
- pattern OS :: forall nat t. (PeanoOrder nat, SingI nat t) => IsPeano nat => Ordinal nat t -> Ordinal nat (Succ nat t)
- class (PeanoOrder nat, Monomorphicable (Sing :: nat -> *), Integral (MonomorphicRep (Sing :: nat -> *)), Show (MonomorphicRep (Sing :: nat -> *))) => HasOrdinal nat
- mkOrdinalQQ :: TypeQ -> QuasiQuoter
- odPN :: QuasiQuoter
- odLit :: QuasiQuoter
- sNatToOrd' :: (PeanoOrder nat, (m :< n) ~ True) => Sing (n :: nat) -> Sing m -> Ordinal n
- sNatToOrd :: (PeanoOrder nat, SingI (n :: nat), (m :< n) ~ True) => Sing m -> Ordinal n
- ordToInt :: (HasOrdinal nat, int ~ MonomorphicRep (Sing :: nat -> *)) => Ordinal (n :: nat) -> int
- ordToSing :: PeanoOrder nat => Ordinal (n :: nat) -> SomeSing nat
- unsafeFromInt :: forall n. (HasOrdinal nat, SingI (n :: nat)) => MonomorphicRep (Sing :: nat -> *) -> Ordinal n
- inclusion :: (n :<= m) ~ True => Ordinal n -> Ordinal m
- inclusion' :: (n :<= m) ~ True => Sing m -> Ordinal n -> Ordinal m
- (@+) :: forall n m. (PeanoOrder nat, SingI (n :: nat), SingI m) => Ordinal n -> Ordinal m -> Ordinal (n :+ m)
- enumOrdinal :: PeanoOrder nat => Sing (n :: nat) -> [Ordinal n]
- absurdOrd :: PeanoOrder nat => Ordinal (Zero nat) -> a
- vacuousOrd :: (PeanoOrder nat, Functor f) => f (Ordinal (Zero nat)) -> f a
Data-types
Set-theoretic (finite) ordinals:
n = {0, 1, ..., n-1}
So, Ordinal n
has exactly n inhabitants. So especially Ordinal 'Z
is isomorphic to Void
.
Since 0.6.0.0
(SingI Nat m, SingI Nat n, (~) Nat n ((+) m 1)) => Bounded (Ordinal Nat n) Source # | |
SingI Nat n => Bounded (Ordinal Nat (S n)) Source # | |
(HasOrdinal nat1, SingI nat1 n) => Enum (Ordinal nat1 n) Source # | |
HasOrdinal nat1 => Eq (Ordinal nat1 n) Source # | |
(HasOrdinal nat1, SingI nat1 n) => Num (Ordinal nat1 n) Source # | |
HasOrdinal nat1 => Ord (Ordinal nat1 n) Source # | |
(SingI nat1 n, HasOrdinal nat1) => Show (Ordinal nat1 n) Source # | |
pattern OZ :: forall nat n. IsPeano nat => (~) Bool ((:<) nat (Zero nat) n) True => Ordinal nat n Source #
Pattern synonym representing the 0-th ordinal.
Since 0.6.0.0
pattern OS :: forall nat t. (PeanoOrder nat, SingI nat t) => IsPeano nat => Ordinal nat t -> Ordinal nat (Succ nat t) Source #
Pattern synonym
represents (n+1)-th ordinal.OS
n
Since 0.6.0.0
class (PeanoOrder nat, Monomorphicable (Sing :: nat -> *), Integral (MonomorphicRep (Sing :: nat -> *)), Show (MonomorphicRep (Sing :: nat -> *))) => HasOrdinal nat Source #
Class synonym for Peano numerals with ordinals.
Since 0.5.0.0
(PeanoOrder nat1, Monomorphicable nat1 (Sing nat1), Integral (MonomorphicRep nat1 (Sing nat1)), Show (MonomorphicRep nat1 (Sing nat1))) => HasOrdinal nat1 Source # | |
Quasi Quoter
This section provides QuasiQuoter and general generator for ordinals.
Note that,
instance for Num
s DOES NOT
checks boundary; with Ordinal
, we can use literal with
boundary check.
For example, with od
-XQuasiQuotes
language extension enabled,
[
doesn't typechecks and causes compile-time error,
whilst od
| 12 |] :: Ordinal 112 :: Ordinal 1
compiles but raises run-time error.
So, to enforce correctness, we recommend to use these quoters
instead of bare
numerals.Num
mkOrdinalQQ :: TypeQ -> QuasiQuoter Source #
Quasiquoter generator for ordinals
odPN :: QuasiQuoter Source #
Quasiquoter for ordinal indexed by Peano numeral
.Nat
odLit :: QuasiQuoter Source #
Quasiquoter for ordinal indexed by built-in numeral
.Nat
Conversion from cardinals to ordinals.
sNatToOrd' :: (PeanoOrder nat, (m :< n) ~ True) => Sing (n :: nat) -> Sing m -> Ordinal n Source #
sNatToOrd'
n m
injects m
as Ordinal n
.
Since 0.5.0.0
sNatToOrd :: (PeanoOrder nat, SingI (n :: nat), (m :< n) ~ True) => Sing m -> Ordinal n Source #
sNatToOrd'
with n
inferred.
ordToInt :: (HasOrdinal nat, int ~ MonomorphicRep (Sing :: nat -> *)) => Ordinal (n :: nat) -> int Source #
Convert ordinal into Int
.
ordToSing :: PeanoOrder nat => Ordinal (n :: nat) -> SomeSing nat Source #
Convert Ordinal n
into monomorphic Sing
Since 0.5.0.0
unsafeFromInt :: forall n. (HasOrdinal nat, SingI (n :: nat)) => MonomorphicRep (Sing :: nat -> *) -> Ordinal n Source #
inclusion :: (n :<= m) ~ True => Ordinal n -> Ordinal m Source #
Inclusion function for ordinals with codomain inferred.
Since 0.7.0.0 (constraint was weakened since last released)
inclusion' :: (n :<= m) ~ True => Sing m -> Ordinal n -> Ordinal m Source #
Inclusion function for ordinals.
Since 0.7.0.0 (constraint was weakened since last released)
Ordinal arithmetics
(@+) :: forall n m. (PeanoOrder nat, SingI (n :: nat), SingI m) => Ordinal n -> Ordinal m -> Ordinal (n :+ m) Source #
Ordinal addition.
enumOrdinal :: PeanoOrder nat => Sing (n :: nat) -> [Ordinal n] Source #
Enumerate all
s less than Ordinal
n
.
Elimination rules for Ordinal
Z
.
Ordinal
Z
absurdOrd :: PeanoOrder nat => Ordinal (Zero nat) -> a Source #
Since Ordinal 'Z
is logically not inhabited, we can coerce it to any value.
Since 0.2.3.0
vacuousOrd :: (PeanoOrder nat, Functor f) => f (Ordinal (Zero nat)) -> f a Source #