| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Circuit.Linear
Description
Linear-logic connectives over a base category.
This module surfaces linear implication (⊸) and the exponential
modalities ! / ? as type-class structure. The tensor product ⅋ and
its unit ⊥ live in Circuit.Par.
Synopsis
- class Category arr => Lolli (t :: Type -> Type -> Type) (arr :: Type -> Type -> Type) where
- class Tensor t arr => Exponential (t :: k -> k -> k) (arr :: k -> k -> Type) where
- class Exponential t arr => BangCopy (t :: Type -> Type -> Type) (arr :: Type -> Type -> Type) where
- class Exponential t arr => BangWeaken (t :: Type -> Type -> Type) (arr :: Type -> Type -> Type) where
- class Exponential t arr => WhyNotIntro (t :: Type -> Type -> Type) (arr :: Type -> Type -> Type) where
- class (Exponential t arr, Par p arr) => WhyNotMonoid (t :: Type -> Type -> Type) (p :: Type -> Type -> Type) (arr :: Type -> Type -> Type) where
- type LinearBang (t :: Type -> Type -> Type) (arr :: Type -> Type -> Type) = (Exponential t arr, BangCopy t arr, BangWeaken t arr)
- type AffineBang (t :: Type -> Type -> Type) (arr :: Type -> Type -> Type) = (Exponential t arr, BangWeaken t arr)
- type RelevantBang (t :: Type -> Type -> Type) (arr :: Type -> Type -> Type) = (Exponential t arr, BangCopy t arr)
Linear implication (internal hom)
class Category arr => Lolli (t :: Type -> Type -> Type) (arr :: Type -> Type -> Type) where Source #
Closed monoidal structure: A ⊸ B is the right adjoint of tensor.
Maps A ⊗ B -> C correspond to maps A -> B ⊸ C via curry/uncurry.
eval is the counit A ⊗ (A ⊸ B) -> B (hom on the right of the tensor).
That is the existing Chu convention; it differs from uncurry id by a
braid. lolli is identity on the implication object, used to mention
it.
Kind is fixed to Type so type applications stay concrete (GHC 9.14
panics on kind-polymorphic TypeApplications here).
Associated Types
type LolliT (t :: Type -> Type -> Type) (arr :: Type -> Type -> Type) a b Source #
The implication object A ⊸ B.
Indexed by the base arrow as well as the tensor, so (->) and
Mat can both close (,) without colliding.
Methods
lolli :: arr a b -> arr (LolliT t arr a b) (LolliT t arr a b) Source #
Identity at the implication object. The argument is a type proxy.
eval :: arr (t a (LolliT t arr a b)) b Source #
Evaluation counit A ⊗ (A ⊸ B) -> B.
curry :: arr (t a b) c -> arr a (LolliT t arr b c) Source #
Curry the left factor: (A ⊗ B -> C) -> (A -> B ⊸ C).
uncurry :: arr a (LolliT t arr b c) -> arr (t a b) c Source #
Uncurry the left factor: (A -> B ⊸ C) -> (A ⊗ B -> C).
Instances
| Lolli (,) (->) Source # | Cartesian closed structure on functions: implication collapses to function space. | ||||
Defined in Circuit.Linear Associated Types
| |||||
Exponentials
class Tensor t arr => Exponential (t :: k -> k -> k) (arr :: k -> k -> Type) Source #
Exponential modality: object-level types for !A and ?A.
The structural rules are split into independent subclasses so that
affine and linear uses of the modality differ only in their constraint
sets, mirroring the Copy/Discard split at the base-arrow level.
!Ahas a contraction half (BangCopy) and a weakening half (BangWeaken). Linear logic requires both; affine logic requires only weakening.?Acurrently exposes only its unit rule (WhyNotIntro); the ⅋-monoid multiplication on?A(WhyNotMerge) is missing. In the vocabulary ofDagger,?Ais currentlyCoAffine-only (the unitZero) and the missing half isCoRelevant(the mergeMerge).
Associated Types
type Bang (t :: k -> k -> k) (arr :: k -> k -> Type) a Source #
type WhyNot (t :: k -> k -> k) (arr :: k -> k -> Type) a = (result :: Type) | result -> a Source #
Instances
| Exponential (,) (->) Source # | Cartesian collapse: | ||||||||
Defined in Circuit.Linear Associated Types
| |||||||||
class Exponential t arr => BangCopy (t :: Type -> Type -> Type) (arr :: Type -> Type -> Type) where Source #
Contraction half of !A: copy !A → !A ⊗ !A.
class Exponential t arr => BangWeaken (t :: Type -> Type -> Type) (arr :: Type -> Type -> Type) where Source #
Weakening half of !A: dereliction !A → A and discard !A → I.
class Exponential t arr => WhyNotIntro (t :: Type -> Type -> Type) (arr :: Type -> Type -> Type) where Source #
Unit rule for ?A: introduction A → ?A.
Instances
| WhyNotIntro (,) (->) Source # | |
class (Exponential t arr, Par p arr) => WhyNotMonoid (t :: Type -> Type -> Type) (p :: Type -> Type -> Type) (arr :: Type -> Type -> Type) where Source #
The ⅋-monoid structure on ?A.
Dual to the !-comonoid (BangCopy / BangWeaken), but living on the
tensor product rather than the tensor product. mergeE is the
multiplication ?A ⅋ ?A → ?A and zeroE is the unit ⊥ → ?A.
type LinearBang (t :: Type -> Type -> Type) (arr :: Type -> Type -> Type) = (Exponential t arr, BangCopy t arr, BangWeaken t arr) Source #
Linear !A: both contraction and weakening.
type AffineBang (t :: Type -> Type -> Type) (arr :: Type -> Type -> Type) = (Exponential t arr, BangWeaken t arr) Source #
Affine !A: weakening only.