circuits-chu
Safe HaskellNone
LanguageGHC2024

Circuit.Chu

Description

The Chu construction over a monoidal base category.

A Chu object is a polarity pair A⁺ and A⁻ together with a pairing A⁺ ⊗ A⁻ → ⊥ into a dualising object. A Chu morphism is an adjoint pair satisfying the equation

e_B (f⁺ a, d) = e_A (a, f⁻ d)

This is the only genuinely star-autonomous, non-compact structure in the library: proper ⊗ vs ⅋, proper additives, a real negation, and an internal hom that is not just A⊥ ⊗ B. Promoting it to a base arrow makes the linear-logic distinctions measurable for the first time.

Synopsis

Dualising semiring

class ChuSemiring r where Source #

A semiring, kept local to this module so the delivery instance does not pull in an external numeric prelude.

Methods

sZero :: r Source #

sOne :: r Source #

sPlus :: r -> r -> r Source #

sTimes :: r -> r -> r Source #

Instances

Instances details
ChuSemiring Integer Source # 
Instance details

Defined in Circuit.Chu

ChuSemiring Bool Source # 
Instance details

Defined in Circuit.Chu

ChuSemiring Double Source # 
Instance details

Defined in Circuit.Chu

Chu objects and morphisms

newtype ChuObj (t :: k -> k1 -> k2) (r :: k3) (arr :: k2 -> k3 -> Type) (a :: k) (b :: k1) Source #

An object of Chu(C, ⊥).

  • a is the positive carrier.
  • b is the negative carrier.
  • chuPair is the pairing a ⊗ b → r into the dualising object.

Constructors

ChuObj 

Fields

  • chuPair :: arr (t a b) r

    Pairing into the dualising object.

data PointedChuObj (t :: Type -> Type -> k) (r :: k1) (arr :: k -> k1 -> Type) a b Source #

A pointed Chu object: a ChuObj together with a chosen point pair.

This is the separate wrapper used by polesAsChu to retain the positive and negative points that witness a self-dual channel.

Constructors

PointedChuObj 

Fields

data ChuMorphism (t :: k) (r :: k1) (arr :: k2 -> k3 -> Type) (a :: k2) (b :: k3) (c :: k3) (d :: k2) Source #

A Chu morphism A → B is a pair of base arrows:

  • chuForward :: arr a c runs forward from A⁺ to B⁺.
  • chuBackward :: arr d b runs backward from B⁻ to A⁻.

Constructors

ChuMorphism 

Fields

newtype Chu (t :: Type -> Type -> Type) r (arr :: Type -> Type -> Type) a b where Source #

Chu t r arr is the Chu construction as a base arrow. Objects are ChuObjs; morphisms are adjoint pairs wrapped by the Chu constructor.

Constructors

Chu :: forall (t :: Type -> Type -> Type) r (arr :: Type -> Type -> Type) a b. ChuMorphism t r arr (ChuPosType a) (ChuNegType a) (ChuPosType b) (ChuNegType b) -> Chu t r arr a b 

Instances

Instances details
Category arr => Category (Chu t r arr :: Type -> Type -> Type) Source # 
Instance details

Defined in Circuit.Chu

Methods

id :: Chu t r arr a a #

(.) :: Chu t r arr b c -> Chu t r arr a b -> Chu t r arr a c #

type family ChuPosType a where ... Source #

Closed type family giving the positive carrier of a Chu object tag.

Every object of Chu(C, ⊥) is ultimately a ChuObj; this family exposes the positive carrier so that identity and composition can be typed uniformly without a separate type class.

type family ChuNegType a where ... Source #

Closed type family giving the negative carrier of a Chu object tag.

See ChuPosType for motivation; this is the dual side.

negateChu :: forall {k} (t :: k -> k -> k) (arr :: k -> k -> Type) (r :: k) (a :: k) (b :: k). Action t arr => ChuObj t r arr a b -> ChuObj t r arr b a Source #

Negation swaps the carriers via the symmetric braiding.

Involution is definitional for a symmetric braiding: braid . braid = id.

idChu :: forall {k1} {k2} {k3} (arr :: k1 -> k1 -> Type) (t :: k2) (r :: k3) (a :: k1) (b :: k1). Category arr => ChuMorphism t r arr a b a b Source #

Identity Chu morphism.

composeChu :: forall {k1} {k2} {k3} (arr :: k1 -> k1 -> Type) (t :: k2) (r :: k3) (c :: k1) (d :: k1) (e :: k1) (f :: k1) (a :: k1) (b :: k1). Category arr => ChuMorphism t r arr c d e f -> ChuMorphism t r arr a b c d -> ChuMorphism t r arr a b e f Source #

Sequential composition of Chu morphisms.

Forward components compose covariantly; backward components compose contravariantly.

Adjoint law

chuLaw :: Eq r => ChuObj (,) r (->) a b -> ChuObj (,) r (->) c d -> ChuMorphism (,) r (->) a b c d -> a -> d -> Bool Source #

The adjoint law for arr = (->) and the cartesian tensor.

A pair (f⁺, f⁻) is a Chu morphism exactly when e_B (f⁺ a, d) = e_A (a, f⁻ d) for all a and d.

chuLawAt :: Eq s => ChuObj (,) r (->) a b -> ChuObj (,) r (->) c d -> ChuMorphism (,) r (->) a b c d -> a -> d -> (r -> s) -> Bool Source #

Pointwise adjoint law for arr = (->).

When the dualising object r does not have an Eq instance (e.g. it is itself a function), supply a probe k :: r -> s with Eq s.

Delivery pairing

deliversToSemiring Source #

Arguments

:: (ChuSemiring r, Eq a) 
=> [a]

Recipients on the post.

-> a

Recipient name.

-> r 

Named-recipient delivery predicate over an arbitrary semiring.

A post whose recipient list contains who delivers with sOne; an empty list delivers to no one with sZero.

deliveryMatrix Source #

Arguments

:: (ChuSemiring r, Eq col) 
=> [col]

Agents (column labels).

-> [[col]]

Recipient lists for each post (row labels are implicit).

-> [[r]] 

Delivery matrix for a fixed list of posts and a roster of agents.

Rows are posts (in the order given), columns are agents (in the order given), and entry (p, a) is the delivery weight of post p to agent a.

Tensor and par over Set

data ChuTensorNeg a b c d Source #

Negative part of the Chu tensor A ⊗ B.

A value (f, g) lives here when e_A(a, g(b)) = e_B(b, f(a)) for all a ∈ A⁺, b ∈ B⁺.

Constructors

ChuTensorNeg 

Fields

data ChuParPos a b c d Source #

Positive part of the Chu par A ⅋ B.

A value (f, g) lives here when e_A(g(d), a) = e_B(f(a), d) for all a ∈ A⁻, d ∈ B⁻.

Constructors

ChuParPos 

Fields

tensorChuObj :: Eq r => ChuObj (,) r (->) a b -> ChuObj (,) r (->) c d -> ChuObj (,) r (->) (a, c) (ChuTensorNeg a b c d) Source #

Tensor product of Chu objects over Set.

parChuObj :: Eq r => ChuObj (,) r (->) a b -> ChuObj (,) r (->) c d -> ChuObj (,) r (->) (ChuParPos a b c d) (b, d) Source #

Par product of Chu objects over Set.

lolliChuObj :: Eq r => ChuObj (,) r (->) a b -> ChuObj (,) r (->) c d -> ChuObj (,) r (->) (ChuParPos b a c d) (a, d) Source #

Linear implication A ⊸ B = A⊥ ⅋ B over Set.

The positive carrier is the set of Chu morphisms A → B, packaged as ChuParPos after negating A.

withChuObj :: ChuObj (,) r (->) a b -> ChuObj (,) r (->) c d -> ChuObj (,) r (->) (a, c) (Either b d) Source #

Additive conjunction A & B over Set.

Positive carrier is A⁺ × B⁺; negative carrier is the disjoint union A⁻ + B⁻.

oplusChuObj :: ChuObj (,) r (->) a b -> ChuObj (,) r (->) c d -> ChuObj (,) r (->) (Either a c) (b, d) Source #

Additive disjunction A ⊕ B over Set.

Positive carrier is the disjoint union A⁺ + B⁺; negative carrier is A⁻ × B⁻.

topChuObj :: ChuObj (,) r (->) () Void Source #

Additive unit over Set.

Positive carrier is the terminal object 1; negative carrier is the initial object 0.

zeroChuObj :: ChuObj (,) r (->) Void () Source #

Additive unit 0 over Set.

Positive carrier is the initial object 0; negative carrier is the terminal object 1.

proj1Chu :: forall {k} (r :: k) a c b d. ChuMorphism (,) r (->) (a, c) (Either b d) a b Source #

First projection A & B → A.

proj2Chu :: forall {k} (r :: k) a c b d. ChuMorphism (,) r (->) (a, c) (Either b d) c d Source #

Second projection A & B → B.

inj1Chu :: forall {k} (r :: k) a b c d. ChuMorphism (,) r (->) a b (Either a c) (b, d) Source #

Left injection A → A ⊕ B.

inj2Chu :: forall {k} (r :: k) c d a b. ChuMorphism (,) r (->) c d (Either a c) (b, d) Source #

Right injection A → A ⊕ B.

unitTopChu :: forall {k} (r :: k) a b. ChuMorphism (,) r (->) a b () Void Source #

Unique morphism A → ⊤.

unitZeroChu :: forall {k} (r :: k) a b. ChuMorphism (,) r (->) Void () a b Source #

Unique morphism 0 → A.

pairChu :: forall {k} (r :: k) c d a b e f. ChuMorphism (,) r (->) c d a b -> ChuMorphism (,) r (->) c d e f -> ChuMorphism (,) r (->) c d (a, e) (Either b f) Source #

Pairing of morphisms into the additive conjunction.

Universal property of A & B: given f : C → A and g : C → B, produce ⟨f,g⟩ : C → A & B.

copairChu :: forall {k} (r :: k) a b c d e f. ChuMorphism (,) r (->) a b c d -> ChuMorphism (,) r (->) e f c d -> ChuMorphism (,) r (->) (Either a e) (b, f) c d Source #

Copairing of morphisms out of the additive disjunction.

Universal property of A ⊕ B: given f : A → C and g : B → C, produce [f,g] : A ⊕ B → C.

withTopLChu :: forall {k} (r :: k) a b. ChuMorphism (,) r (->) a b ((), a) (Either Void b) Source #

Left unit isomorphism A → ⊤ & A.

withTopLInvChu :: forall {k} (r :: k) a b. ChuMorphism (,) r (->) ((), a) (Either Void b) a b Source #

Inverse of withTopLChu.

withTopRChu :: forall {k} (r :: k) a b. ChuMorphism (,) r (->) a b (a, ()) (Either b Void) Source #

Right unit isomorphism A → A & ⊤.

withTopRInvChu :: forall {k} (r :: k) a b. ChuMorphism (,) r (->) (a, ()) (Either b Void) a b Source #

Inverse of withTopRChu.

zeroPlusLChu :: forall {k} (r :: k) a b. ChuMorphism (,) r (->) a b (Either Void a) ((), b) Source #

Left unit isomorphism A → 0 ⊕ A.

zeroPlusLInvChu :: forall {k} (r :: k) a b. ChuMorphism (,) r (->) (Either Void a) ((), b) a b Source #

Inverse of zeroPlusLChu.

zeroPlusRChu :: forall {k} (r :: k) a b. ChuMorphism (,) r (->) a b (Either a Void) (b, ()) Source #

Right unit isomorphism A → A ⊕ 0.

zeroPlusRInvChu :: forall {k} (r :: k) a b. ChuMorphism (,) r (->) (Either a Void) (b, ()) a b Source #

Inverse of zeroPlusRChu.

evalChu :: ChuObj (,) r (->) a b -> ChuObj (,) r (->) c d -> ChuMorphism (,) r (->) (a, ChuParPos b a c d) (ChuTensorNeg a b (ChuParPos b a c d) (a, d)) c d Source #

Evaluation counit A ⊗ (A ⊸ B) → B over Set.

Forward applies the Chu morphism stored in the implication object. Backward pairs the argument with its own positive point, recovering the adjoint condition.

tensorChu :: forall {k} (r :: k) a b c d e f g h. ChuMorphism (,) r (->) a b c d -> ChuMorphism (,) r (->) e f g h -> ChuMorphism (,) r (->) (a, e) (ChuTensorNeg a b e f) (c, g) (ChuTensorNeg c d g h) Source #

Tensor of two Chu morphisms.

parChu :: forall {k} (r :: k) a b c d e f g h. ChuMorphism (,) r (->) a b c d -> ChuMorphism (,) r (->) e f g h -> ChuMorphism (,) r (->) (ChuParPos a b e f) (b, f) (ChuParPos c d g h) (d, h) Source #

Par of two Chu morphisms.

chuUnitObj :: ChuObj (,) r (->) () r Source #

Unit object I = (1, K) with pairing snd.

chuBottomObj :: ChuObj (,) r (->) r () Source #

Bottom object ⊥ = (K, 1), dual of the unit.

chuTensorNegs :: (Eq r, Eq (ChuPosType a), Eq (ChuPosType b), ChuObject r a, ChuObject r b) => Proxy a -> Proxy b -> [ChuTensorNeg (ChuPosType a) (ChuNegType a) (ChuPosType b) (ChuNegType b)] Source #

Enumerate all ChuTensorNeg values for finite carriers.

chuParPoss :: (Eq r, Eq (ChuNegType a), Eq (ChuNegType b), ChuObject r a, ChuObject r b) => Proxy a -> Proxy b -> [ChuParPos (ChuPosType a) (ChuNegType a) (ChuPosType b) (ChuNegType b)] Source #

Enumerate all ChuParPos values for finite carriers.

chuSeparated :: (Eq r, Eq (ChuPosType a), ChuObject r a) => Proxy a -> Bool Source #

A Chu object is separated when the pairing distinguishes every pair of positive points. Equivalently, the transposed pairing A⁺ -> (A⁻ ⊸ ⊥) is injective.

chuExtensional :: (Eq r, Eq (ChuNegType a), ChuObject r a) => Proxy a -> Bool Source #

A Chu object is extensional when the pairing distinguishes every pair of negative points. Equivalently, the pairing A⁻ -> (A⁺ ⊸ ⊥) is injective.

leftUnitorChu :: ChuObj (,) r (->) a b -> ChuMorphism (,) r (->) ((), a) (ChuTensorNeg () r a b) a b Source #

Left unitor λ_A : I ⊗ A → A over Set.

Forward drops the unit; backward maps a negative point b to the unique Chu tensor negative with f() = b and g a = e(a, b).

leftUnitorChuInv :: ChuObj (,) r (->) a b -> ChuMorphism (,) r (->) a b ((), a) (ChuTensorNeg () r a b) Source #

Inverse of the left unitor.

rightUnitorChu :: ChuObj (,) r (->) a b -> ChuMorphism (,) r (->) (a, ()) (ChuTensorNeg a b () r) a b Source #

Right unitor ρ_A : A ⊗ I → A over Set.

rightUnitorChuInv :: ChuObj (,) r (->) a b -> ChuMorphism (,) r (->) a b (a, ()) (ChuTensorNeg a b () r) Source #

Inverse of the right unitor.

assocChu :: forall {k} (r :: k) a c e b d f. ChuMorphism (,) r (->) ((a, c), e) (ChuTensorNeg (a, c) (ChuTensorNeg a b c d) e f) (a, (c, e)) (ChuTensorNeg a b (c, e) (ChuTensorNeg c d e f)) Source #

Associator (A ⊗ B) ⊗ C → A ⊗ (B ⊗ C) over Set.

Positives reassociate as pairs. Negatives reassociate the adjoint pairs: a negative of A ⊗ (B ⊗ C) is sent to a negative of (A ⊗ B) ⊗ C by unpacking the inner ChuTensorNeg.

assocChuInv :: forall {k} (r :: k) a c e b d f. ChuMorphism (,) r (->) (a, (c, e)) (ChuTensorNeg a b (c, e) (ChuTensorNeg c d e f)) ((a, c), e) (ChuTensorNeg (a, c) (ChuTensorNeg a b c d) e f) Source #

Inverse associator A ⊗ (B ⊗ C) → (A ⊗ B) ⊗ C over Set.

slideChu :: forall {k} (r :: k) a c e b d f. ChuMorphism (,) r (->) (a, (c, e)) (ChuTensorNeg a b (c, e) (ChuTensorNeg c d e f)) (c, (a, e)) (ChuTensorNeg c d (a, e) (ChuTensorNeg a b e f)) Source #

Slide A ⊗ (B ⊗ C) → B ⊗ (A ⊗ C) over Set.

This is the Channel slide, derived as assoc . tensor braid id . assoc' and written directly so the instance does not have to manufacture intermediate object constraints.

Embedding from Poles

polesAsChu :: forall {k1} arr (a :: k1). Poles arr a a -> PointedChuObj (,) (arr a a) (->) (In arr a) (Out arr a) Source #

Embed a symmetric pole into a pointed Chu object.

A self-dual channel Poles arr a a has write pole In arr a and read pole Out arr a. close is already the pairing In ⊗ Out → arr a a, so the embedding is direct. The point pair (conjoint e, companion e) is retained as the chosen point of the pointed object.

lawfulDimap :: forall {k1} arr (a :: k1). ChuMorphism (,) (arr a a) (->) (In arr a) (Out arr a) (In arr a) (Out arr a) -> Poles arr a a -> Poles arr a a Source #

Apply a Chu endomorphism to a symmetric pole.

This is the lawful counterpart to the free dimap: the forward and backward maps are an adjoint pair by construction of ChuMorphism. The Chu law is discharged by the type, not just tested.

Object-indexed Chu category (SepChu / OChu)

class ChuObject r a where Source #

A type-level Chu object: a tag with a canonical ChuObj value and finite carrier enumerations.

chuPosAll and chuNegAll are used by separation / extensionality oracles and by enumeration of tensor / par negatives. They default to a runtime error; only objects that actually participate in finite oracles need to supply them.

Minimal complete definition

chuObject

Instances

Instances details
ChuObject Bool ChuAny Source # 
Instance details

Defined in Circuit.Chu

ChuObject Bool ChuDelivery Source # 
Instance details

Defined in Circuit.Chu

ChuObject Bool ChuThree Source # 
Instance details

Defined in Circuit.Chu

ChuObject Bool ChuTwo Source # 
Instance details

Defined in Circuit.Chu

ChuObject Double ChuDouble01 Source # 
Instance details

Defined in Circuit.Chu

ChuObject r (ChuOTop r) Source # 
Instance details

Defined in Circuit.Chu

ChuObject r (ChuOUnit r) Source # 
Instance details

Defined in Circuit.Chu

ChuObject r (ChuOZero r) Source # 
Instance details

Defined in Circuit.Chu

ChuObject r a => ChuObject r (ChuOBang r a) Source # 
Instance details

Defined in Circuit.Chu

ChuObject r a => ChuObject r (ChuONeg r a) Source # 
Instance details

Defined in Circuit.Chu

ChuObject r a => ChuObject r (ChuOWhyNot r a) Source # 
Instance details

Defined in Circuit.Chu

(Eq r, ChuObject r a, ChuObject r b) => ChuObject r (ChuOLolli r a b) Source # 
Instance details

Defined in Circuit.Chu

(Eq r, ChuObject r a, ChuObject r b) => ChuObject r (ChuOPar r a b) Source # 
Instance details

Defined in Circuit.Chu

(ChuObject r a, ChuObject r b) => ChuObject r (ChuOPlus r a b) Source # 
Instance details

Defined in Circuit.Chu

(Eq r, ChuObject r a, ChuObject r b) => ChuObject r (ChuOTensor r a b) Source # 
Instance details

Defined in Circuit.Chu

(ChuObject r a, ChuObject r b) => ChuObject r (ChuOWith r a b) Source # 
Instance details

Defined in Circuit.Chu

class ChuObject r a => ChuSeparated r a Source #

Marker: the pairing distinguishes positive points.

Runtime evidence is available through chuSeparated. Instances close the constructors we admit (ChuTwo, ChuOUnit, tensor, negation).

Instances

Instances details
ChuSeparated Bool ChuAny Source # 
Instance details

Defined in Circuit.Chu

ChuSeparated Bool ChuDelivery Source # 
Instance details

Defined in Circuit.Chu

ChuSeparated Bool ChuThree Source # 
Instance details

Defined in Circuit.Chu

ChuSeparated Bool ChuTwo Source # 
Instance details

Defined in Circuit.Chu

ChuSeparated Double ChuDouble01 Source # 
Instance details

Defined in Circuit.Chu

ChuSeparated r (ChuOTop r) Source # 
Instance details

Defined in Circuit.Chu

ChuSeparated r (ChuOUnit r) Source # 
Instance details

Defined in Circuit.Chu

ChuSeparated r (ChuOZero r) Source # 
Instance details

Defined in Circuit.Chu

ChuSeparated r a => ChuSeparated r (ChuOBang r a) Source # 
Instance details

Defined in Circuit.Chu

ChuExtensional r a => ChuSeparated r (ChuONeg r a) Source # 
Instance details

Defined in Circuit.Chu

ChuObject r a => ChuSeparated r (ChuOWhyNot r a) Source # 
Instance details

Defined in Circuit.Chu

(Eq r, ChuSeparated r a, ChuSeparated r b) => ChuSeparated r (ChuOLolli r a b) Source # 
Instance details

Defined in Circuit.Chu

(Eq r, ChuSeparated r a, ChuSeparated r b) => ChuSeparated r (ChuOPar r a b) Source # 
Instance details

Defined in Circuit.Chu

(ChuSeparated r a, ChuSeparated r b, ChuNegNonEmpty a ~ 'True, ChuNegNonEmpty b ~ 'True) => ChuSeparated r (ChuOPlus r a b) Source # 
Instance details

Defined in Circuit.Chu

(Eq r, ChuSeparated r a, ChuSeparated r b) => ChuSeparated r (ChuOTensor r a b) Source # 
Instance details

Defined in Circuit.Chu

(ChuSeparated r a, ChuSeparated r b) => ChuSeparated r (ChuOWith r a b) Source # 
Instance details

Defined in Circuit.Chu

class ChuObject r a => ChuExtensional r a Source #

Marker: the pairing distinguishes negative points.

Runtime evidence is available through chuExtensional. Negation swaps this with ChuSeparated.

Instances

Instances details
ChuExtensional Bool ChuAny Source # 
Instance details

Defined in Circuit.Chu

ChuExtensional Bool ChuDelivery Source # 
Instance details

Defined in Circuit.Chu

ChuExtensional Bool ChuThree Source # 
Instance details

Defined in Circuit.Chu

ChuExtensional Bool ChuTwo Source # 
Instance details

Defined in Circuit.Chu

ChuExtensional Double ChuDouble01 Source # 
Instance details

Defined in Circuit.Chu

ChuExtensional r (ChuOTop r) Source # 
Instance details

Defined in Circuit.Chu

ChuExtensional r (ChuOUnit r) Source # 
Instance details

Defined in Circuit.Chu

ChuExtensional r (ChuOZero r) Source # 
Instance details

Defined in Circuit.Chu

ChuObject r a => ChuExtensional r (ChuOBang r a) Source # 
Instance details

Defined in Circuit.Chu

ChuSeparated r a => ChuExtensional r (ChuONeg r a) Source # 
Instance details

Defined in Circuit.Chu

ChuExtensional r a => ChuExtensional r (ChuOWhyNot r a) Source # 
Instance details

Defined in Circuit.Chu

(Eq r, ChuExtensional r a, ChuExtensional r b) => ChuExtensional r (ChuOLolli r a b) Source # 
Instance details

Defined in Circuit.Chu

(Eq r, ChuExtensional r a, ChuExtensional r b) => ChuExtensional r (ChuOPar r a b) Source # 
Instance details

Defined in Circuit.Chu

(ChuExtensional r a, ChuExtensional r b) => ChuExtensional r (ChuOPlus r a b) Source # 
Instance details

Defined in Circuit.Chu

(Eq r, ChuExtensional r a, ChuExtensional r b) => ChuExtensional r (ChuOTensor r a b) Source # 
Instance details

Defined in Circuit.Chu

(ChuExtensional r a, ChuExtensional r b, ChuPosNonEmpty a ~ 'True, ChuPosNonEmpty b ~ 'True) => ChuExtensional r (ChuOWith r a b) Source # 
Instance details

Defined in Circuit.Chu

type family ChuPosNonEmpty a :: Bool where ... Source #

Type-level non-emptiness of an object's positive carrier.

Used to guard additive marker instances: A & B can only be extensional when both A and B have at least one positive point, because the negative carrier is the disjoint union and distinct injections must be separated by a positive pair.

type family ChuNegNonEmpty a :: Bool where ... Source #

Type-level non-emptiness of an object's negative carrier.

Used to guard additive marker instances: A ⊕ B can only be separated when both A and B have at least one negative point, because the positive carrier is the disjoint union and distinct injections must be separated by a negative pair.

newtype OChu r a b Source #

The object-indexed Chu construction as a base arrow.

Constructors

OChu 

Fields

Instances

Instances details
Category (OChu r :: Type -> Type -> Type) Source # 
Instance details

Defined in Circuit.Chu

Methods

id :: OChu r a a #

(.) :: OChu r b c -> OChu r a b -> OChu r a c #

Eq r => Channel (ChuOTensor r :: Type -> Type -> Type) (OChu r :: Type -> Type -> Type) Source #

Monoidal structure on the object-level Chu tensor.

assoc assoc' slide are the Set-level maps assocChu, assocChuInv, and slideChu. The pentagon is checked on ChuTwo by finite enumeration in circuits-axioma.

Instance details

Defined in Circuit.Chu

Methods

assoc :: OChu r (ChuOTensor r (ChuOTensor r a b) c) (ChuOTensor r a (ChuOTensor r b c)) #

assoc' :: OChu r (ChuOTensor r a (ChuOTensor r b c)) (ChuOTensor r (ChuOTensor r a b) c) #

slide :: OChu r (ChuOTensor r a (ChuOTensor r b c)) (ChuOTensor r b (ChuOTensor r a c)) #

type SepChu = OChu Source #

Documentation alias for OChu.

This is a plain type synonym, not a separate category: the separated-extensional conditions are enforced only by the Ob constraint of OChu. If you need Barr's subcategory to be tracked in the type system, wrap OChu in a newtype with its own Category instance.

OChu constrained combinators (evidence at use sites)

parOChu :: OChu r a b -> OChu r c d -> OChu r (ChuOTensor r a c) (ChuOTensor r b d) Source #

Parallel composition for OChu.

unitlOChu :: ChuObject r a => OChu r (ChuOTensor r (ChuOUnit r) a) a Source #

Left unitor I ⊗ A → A for OChu.

unitlOChu' :: ChuObject r a => OChu r a (ChuOTensor r (ChuOUnit r) a) Source #

Inverse left unitor A → I ⊗ A for OChu.

unitrOChu :: ChuObject r a => OChu r (ChuOTensor r a (ChuOUnit r)) a Source #

Right unitor A ⊗ I → A for OChu.

unitrOChu' :: ChuObject r a => OChu r a (ChuOTensor r a (ChuOUnit r)) Source #

Inverse right unitor A → A ⊗ I for OChu.

swapOChu :: OChu r (ChuOTensor r a b) (ChuOTensor r b a) Source #

Symmetric braiding A ⊗ B → B ⊗ A for OChu.

parPOChu :: OChu r a b -> OChu r c d -> OChu r (ChuOPar r a c) (ChuOPar r b d) Source #

Par structure on the object-indexed Chu category.

The par product of objects is ChuOPar; the structural morphisms are the Set-level par maps already defined for Chu morphisms.

Parallel composition for the par product on OChu.

unitlPOChu :: OChu r (ChuOPar r (Bot (ChuOPar r :: Type -> Type -> Type)) a) a Source #

Left unitor ⊥ ⅋ A → A for OChu.

unitlPOChu' :: ChuObject r a => OChu r a (ChuOPar r (Bot (ChuOPar r :: Type -> Type -> Type)) a) Source #

Inverse left unitor A → ⊥ ⅋ A for OChu.

unitrPOChu :: OChu r (ChuOPar r a (Bot (ChuOPar r :: Type -> Type -> Type))) a Source #

Right unitor A ⅋ ⊥ → A for OChu.

unitrPOChu' :: ChuObject r a => OChu r a (ChuOPar r a (Bot (ChuOPar r :: Type -> Type -> Type))) Source #

Inverse right unitor A → A ⅋ ⊥ for OChu.

evalOChu :: (ChuObject r a, ChuObject r b) => OChu r (ChuOTensor r a (ChuOLolli r a b)) b Source #

Evaluation counit A ⊗ (A ⊸ B) → B for OChu.

curryOChu :: OChu r (ChuOTensor r a b) c -> OChu r a (ChuOLolli r b c) Source #

Curry (A ⊗ B → C) → (A → B ⊸ C) for OChu.

uncurryOChu :: OChu r a (ChuOLolli r b c) -> OChu r (ChuOTensor r a b) c Source #

Uncurry (A → B ⊸ C) → (A ⊗ B → C) for OChu.

discardEOChu :: OChu r (ChuOBang r a) (ChuOUnit r) Source #

Discard !A → I for OChu.

derelictOChu :: ChuObject r a => OChu r (ChuOBang r a) a Source #

Dereliction !A → A for OChu.

introduceOChu :: ChuObject r a => OChu r a (ChuOWhyNot r a) Source #

Introduction A → ?A for OChu.

mergeEOChu :: OChu r (ChuOPar r (ChuOWhyNot r a) (ChuOWhyNot r a)) (ChuOWhyNot r a) Source #

Merge ?A ⅋ ?A → ?A for OChu.

zeroEOChu :: OChu r (ChuONeg r (ChuOUnit r)) (ChuOWhyNot r a) Source #

Unit ⊥ → ?A for OChu.

copyTOChu :: OChu r (ChuOBang r a) (ChuOTensor r (ChuOBang r a) (ChuOBang r a)) Source #

Copy !A → !A ⊗ !A for OChu.

discardTOChu :: OChu r (ChuOBang r a) (ChuOUnit r) Source #

Discard !A → I for OChu.

plusTOChu :: forall r a. Monoid (ChuPosType a) => OChu r (ChuOTensor r (ChuOBang r a) (ChuOBang r a)) (ChuOBang r a) Source #

Merge !A ⊗ !A → !A for OChu.

zeroTOChu :: forall r a. Monoid (ChuPosType a) => OChu r (ChuOUnit r) (ChuOBang r a) Source #

Zero I → !A for OChu.

data ChuOUnit r Source #

Unit object type for OChu.

Constructors

ChuOUnit 

Instances

Instances details
ChuExtensional r (ChuOUnit r) Source # 
Instance details

Defined in Circuit.Chu

ChuObject r (ChuOUnit r) Source # 
Instance details

Defined in Circuit.Chu

ChuSeparated r (ChuOUnit r) Source # 
Instance details

Defined in Circuit.Chu

data ChuOTensor r (a :: k) (b :: k1) Source #

Tensor object type for OChu.

Constructors

ChuOTensor 

Instances

Instances details
Eq r => Channel (ChuOTensor r :: Type -> Type -> Type) (OChu r :: Type -> Type -> Type) Source #

Monoidal structure on the object-level Chu tensor.

assoc assoc' slide are the Set-level maps assocChu, assocChuInv, and slideChu. The pentagon is checked on ChuTwo by finite enumeration in circuits-axioma.

Instance details

Defined in Circuit.Chu

Methods

assoc :: OChu r (ChuOTensor r (ChuOTensor r a b) c) (ChuOTensor r a (ChuOTensor r b c)) #

assoc' :: OChu r (ChuOTensor r a (ChuOTensor r b c)) (ChuOTensor r (ChuOTensor r a b) c) #

slide :: OChu r (ChuOTensor r a (ChuOTensor r b c)) (ChuOTensor r b (ChuOTensor r a c)) #

(Eq r, ChuExtensional r a, ChuExtensional r b) => ChuExtensional r (ChuOTensor r a b) Source # 
Instance details

Defined in Circuit.Chu

(Eq r, ChuObject r a, ChuObject r b) => ChuObject r (ChuOTensor r a b) Source # 
Instance details

Defined in Circuit.Chu

(Eq r, ChuSeparated r a, ChuSeparated r b) => ChuSeparated r (ChuOTensor r a b) Source # 
Instance details

Defined in Circuit.Chu

type Unit (ChuOTensor r :: Type -> Type -> Type) Source # 
Instance details

Defined in Circuit.Chu

type Unit (ChuOTensor r :: Type -> Type -> Type) = ChuOUnit r

data ChuONeg r (a :: k) Source #

Object-level negation A⊥.

Carriers swap; the pairing is negateChu of the underlying object. Separation and extensionality swap: if A is separated then A⊥ is extensional, and conversely.

Constructors

ChuONeg 

Instances

Instances details
ChuSeparated r a => ChuExtensional r (ChuONeg r a) Source # 
Instance details

Defined in Circuit.Chu

ChuObject r a => ChuObject r (ChuONeg r a) Source # 
Instance details

Defined in Circuit.Chu

ChuExtensional r a => ChuSeparated r (ChuONeg r a) Source # 
Instance details

Defined in Circuit.Chu

data ChuOWith r (a :: k) (b :: k1) Source #

Object-level additive conjunction A & B.

ChuSeparated is available whenever both summands are separated. ChuExtensional is guarded by ChuPosNonEmpty: when one summand has an empty positive carrier (e.g. A & 0), distinct negative injections cannot be separated, so the instance is not asserted.

Constructors

ChuOWith 

Instances

Instances details
(ChuExtensional r a, ChuExtensional r b, ChuPosNonEmpty a ~ 'True, ChuPosNonEmpty b ~ 'True) => ChuExtensional r (ChuOWith r a b) Source # 
Instance details

Defined in Circuit.Chu

(ChuObject r a, ChuObject r b) => ChuObject r (ChuOWith r a b) Source # 
Instance details

Defined in Circuit.Chu

(ChuSeparated r a, ChuSeparated r b) => ChuSeparated r (ChuOWith r a b) Source # 
Instance details

Defined in Circuit.Chu

data ChuOPlus r (a :: k) (b :: k1) Source #

Object-level additive disjunction A ⊕ B.

ChuExtensional is available whenever both summands are extensional. ChuSeparated is guarded by ChuNegNonEmpty: when one summand has an empty negative carrier (e.g. ⊤ ⊕ B), distinct positive injections cannot be separated, so the instance is not asserted.

Constructors

ChuOPlus 

Instances

Instances details
(ChuExtensional r a, ChuExtensional r b) => ChuExtensional r (ChuOPlus r a b) Source # 
Instance details

Defined in Circuit.Chu

(ChuObject r a, ChuObject r b) => ChuObject r (ChuOPlus r a b) Source # 
Instance details

Defined in Circuit.Chu

(ChuSeparated r a, ChuSeparated r b, ChuNegNonEmpty a ~ 'True, ChuNegNonEmpty b ~ 'True) => ChuSeparated r (ChuOPlus r a b) Source # 
Instance details

Defined in Circuit.Chu

data ChuOPar r (a :: k) (b :: k1) Source #

Object-level multiplicative disjunction A ⅋ B.

Positive carrier is the set of ChuParPos witnesses; negative carrier is the product A⁻ × B⁻. This is the real par, distinct from the additive disjunction ChuOPlus.

Constructors

ChuOPar 

Instances

Instances details
(Eq r, ChuExtensional r a, ChuExtensional r b) => ChuExtensional r (ChuOPar r a b) Source # 
Instance details

Defined in Circuit.Chu

(Eq r, ChuObject r a, ChuObject r b) => ChuObject r (ChuOPar r a b) Source # 
Instance details

Defined in Circuit.Chu

(Eq r, ChuSeparated r a, ChuSeparated r b) => ChuSeparated r (ChuOPar r a b) Source # 
Instance details

Defined in Circuit.Chu

type Bot (ChuOPar r :: Type -> Type -> Type) Source #

The par unit is the dual of the tensor unit: ⊥ = I⊥.

Instance details

Defined in Circuit.Chu

type Bot (ChuOPar r :: Type -> Type -> Type) = ChuONeg r (ChuOUnit r)

data ChuOTop r Source #

Object-level additive unit .

Constructors

ChuOTop 

Instances

Instances details
ChuExtensional r (ChuOTop r) Source # 
Instance details

Defined in Circuit.Chu

ChuObject r (ChuOTop r) Source # 
Instance details

Defined in Circuit.Chu

ChuSeparated r (ChuOTop r) Source # 
Instance details

Defined in Circuit.Chu

data ChuOZero r Source #

Object-level additive zero 0.

Constructors

ChuOZero 

Instances

Instances details
ChuExtensional r (ChuOZero r) Source # 
Instance details

Defined in Circuit.Chu

ChuObject r (ChuOZero r) Source # 
Instance details

Defined in Circuit.Chu

ChuSeparated r (ChuOZero r) Source # 
Instance details

Defined in Circuit.Chu

data ChuTwo Source #

The self-dual two-point Chu object used in the oracles.

Constructors

ChuTwo 

Instances

Instances details
ChuExtensional Bool ChuTwo Source # 
Instance details

Defined in Circuit.Chu

ChuObject Bool ChuTwo Source # 
Instance details

Defined in Circuit.Chu

ChuSeparated Bool ChuTwo Source # 
Instance details

Defined in Circuit.Chu

data ChuThree Source #

A non-self-dual three-point Chu object over Bool.

Both carriers are Maybe Bool, but the pairing is the non-symmetric partial-order relation (Nothing <= Just False <= Just True), not equality. This breaks the self-duality coincidence of ChuTwo while keeping the object separated and extensional.

Constructors

ChuThree 

Instances

Instances details
ChuExtensional Bool ChuThree Source # 
Instance details

Defined in Circuit.Chu

ChuObject Bool ChuThree Source # 
Instance details

Defined in Circuit.Chu

ChuSeparated Bool ChuThree Source # 
Instance details

Defined in Circuit.Chu

data ChuDouble01 Source #

A finite Double-semiring Chu object.

Carriers are the two-element type Bool, representing the subset {0, 1} of Double. The full real line is replaced by this tiny subset so the finite oracles remain runnable. The pairing lands in Double via the existing ChuSemiring instance.

Constructors

ChuDouble01 

data ChuDelivery Source #

A concrete delivery-matrix Chu object: two posts and two agents.

The pairing is the boolean delivery matrix computed by deliveryMatrix and deliversToSemiring. Posts and agents are indexed by Bool so the carriers stay finite and the oracles remain runnable.

Constructors

ChuDelivery 

data ChuAny Source #

A tiny self-dual Chu object over Any (disjunction monoid) with equality pairing. Used to test the bimonoid on !A from a Monoid on A⁺.

Constructors

ChuAny 

Instances

Instances details
ChuExtensional Bool ChuAny Source # 
Instance details

Defined in Circuit.Chu

ChuObject Bool ChuAny Source # 
Instance details

Defined in Circuit.Chu

ChuSeparated Bool ChuAny Source # 
Instance details

Defined in Circuit.Chu

dnUnitChu :: OChu r a (ChuONeg r (ChuONeg r a)) Source #

Double-negation unit A → A⊥⊥.

On carriers this is the identity: two braids restore A⁺ and A⁻, and the pairing is e . braid . braid = e. It is an isomorphism precisely on separated-extensional objects.

dnCounitChu :: OChu r (ChuONeg r (ChuONeg r a)) a Source #

Double-negation counit A⊥⊥ → A.

data ChuOLolli r (a :: k) (b :: k1) Source #

Object-level linear implication A ⊸ B = A⊥ ⅋ B.

Constructors

ChuOLolli 

Instances

Instances details
(Eq r, ChuExtensional r a, ChuExtensional r b) => ChuExtensional r (ChuOLolli r a b) Source # 
Instance details

Defined in Circuit.Chu

(Eq r, ChuObject r a, ChuObject r b) => ChuObject r (ChuOLolli r a b) Source # 
Instance details

Defined in Circuit.Chu

(Eq r, ChuSeparated r a, ChuSeparated r b) => ChuSeparated r (ChuOLolli r a b) Source # 
Instance details

Defined in Circuit.Chu

curryChu :: forall {k} (r :: k) a c b d e f. ChuMorphism (,) r (->) (a, c) (ChuTensorNeg a b c d) e f -> ChuMorphism (,) r (->) a b (ChuParPos d c e f) (c, f) Source #

Curry (A ⊗ B → C) → (A → B ⊸ C) over Set.

uncurryChu :: forall {k} (r :: k) a b d c e f. ChuMorphism (,) r (->) a b (ChuParPos d c e f) (c, f) -> ChuMorphism (,) r (->) (a, c) (ChuTensorNeg a b c d) e f Source #

Uncurry (A → B ⊸ C) → (A ⊗ B → C) over Set.

chuFunctionals :: Eq a => [a] -> [r] -> [a -> r] Source #

All functions from a finite domain to a finite codomain.

bangChuObj :: ChuObj (,) r (->) a b -> ChuObj (,) r (->) a (a -> r) Source #

Cofree cocommutative comonoid on a Set-based Chu object.

Positives are those of A; negatives are every functional A⁺ → r; the pairing is evaluation. Original negatives embed by Yoneda d ↦ \a -> e(a, d), and constants k ↦ const k supply discard.

whyNotChuObj :: ChuObj (,) r (->) a b -> ChuObj (,) r (->) (b -> r) b Source #

Free commutative monoid ?A = (!A⊥)⊥.

Positives are the functionals A⁻ → r; negatives are those of A.

copyBangChu :: ChuMorphism (,) r (->) a (a -> r) (a, a) (ChuTensorNeg a (a -> r) a (a -> r)) Source #

Copy !A → !A ⊗ !A: diagonal on points, contraction on functionals.

discardBangChu :: ChuMorphism (,) r (->) a (a -> r) () r Source #

Discard !A → I: the constant functionals.

mergeBangChu :: Monoid a => ChuMorphism (,) r (->) (a, a) (ChuTensorNeg a (a -> r) a (a -> r)) a (a -> r) Source #

Merge !A ⊗ !A → !A: the monoid operation on points, bilinearly extended to functionals.

zeroBangChu :: Monoid a => ChuMorphism (,) r (->) () r a (a -> r) Source #

Zero I → !A: the monoid unit as a point of A⁺.

derelictChu :: ChuObj (,) r (->) a b -> ChuMorphism (,) r (->) a (a -> r) a b Source #

Dereliction !A → A: identity on points, Yoneda on negatives.

zeroWhyNotChu :: ChuSemiring r => ChuMorphism (,) r (->) () r (b -> r) b Source #

Zero I → ?A. The unit functional is constantly sZero.

This is not the ⅋-monoid unit (that is zeroWhyNotParChu : ⊥ → ?A).

introduceChu :: ChuObj (,) r (->) a b -> ChuMorphism (,) r (->) a b (b -> r) b Source #

Introduction A → ?A: Yoneda on positives, identity on negatives.

digChu :: ChuMorphism (,) r (->) a (a -> r) a (a -> r) Source #

Digging !A → !!A.

Over the Set-based ! of this module, !!A is the same object as !A (positive carrier A⁺, negative carrier A⁺ → r), so digging is the identity. This is an observable fact about the model, not a stub.

promoteChu :: ChuMorphism (,) r (->) (a, c) (ChuTensorNeg a (a -> r) c (c -> r)) (a, c) ((a, c) -> r) Source #

Promotion !A ⊗ !B → !(A & B).

Forward is the identity on the shared positive carrier (A⁺, B⁺). Backward turns a bilinear element of !A ⊗ !B into a functional on (A⁺, B⁺) using either leg of the bilinear condition.

mergeWhyNotParChu :: ChuMorphism (,) r (->) (ChuParPos (b -> r) b (b -> r) b) (b, b) (b -> r) b Source #

Merge ?A ⅋ ?A → ?A: the dual of copyBangChu.

A par-positive is a pair of functionals A⁻ → (A⁻ → r) satisfying g y x = f x y. Merge contracts the diagonal \x -> g x x.

zeroWhyNotParChu :: ChuMorphism (,) r (->) r () (b -> r) b Source #

⅋-monoid unit ⊥ → ?A: constants, dual of discardBangChu.

leftUnitorParChu :: ChuMorphism (,) r (->) (ChuParPos r () p n) ((), n) p n Source #

Left unitor ⊥ ⅋ A → A over Set.

leftUnitorParChuInv :: ChuObj (,) r (->) a b -> ChuMorphism (,) r (->) a b (ChuParPos r () a b) ((), b) Source #

Inverse of the left par unitor: A → ⊥ ⅋ A over Set.

rightUnitorParChu :: ChuMorphism (,) r (->) (ChuParPos p n r ()) (n, ()) p n Source #

Right unitor A ⅋ ⊥ → A over Set.

rightUnitorParChuInv :: ChuObj (,) r (->) a b -> ChuMorphism (,) r (->) a b (ChuParPos a b r ()) (b, ()) Source #

Inverse of the right par unitor: A → A ⅋ ⊥ over Set.

assocParChu :: forall {k} (r :: k) a b c d e f. ChuMorphism (,) r (->) (ChuParPos (ChuParPos a b c d) (b, d) e f) ((b, d), f) (ChuParPos a b (ChuParPos c d e f) (d, f)) (b, (d, f)) Source #

Associator (A ⅋ B) ⅋ C → A ⅋ (B ⅋ C) over Set.

assocParChuInv :: forall {k} (r :: k) a b c d e f. ChuMorphism (,) r (->) (ChuParPos a b (ChuParPos c d e f) (d, f)) (b, (d, f)) (ChuParPos (ChuParPos a b c d) (b, d) e f) ((b, d), f) Source #

Inverse associator A ⅋ (B ⅋ C) → (A ⅋ B) ⅋ C over Set.

swapParChu :: forall {k} (r :: k) a b c d. ChuMorphism (,) r (->) (ChuParPos a b c d) (b, d) (ChuParPos c d a b) (d, b) Source #

Symmetric braiding A ⅋ B → B ⅋ A over Set.

data ChuOBang r (a :: k) Source #

Object-level !A.

Constructors

ChuOBang 

Instances

Instances details
ChuObject r a => ChuExtensional r (ChuOBang r a) Source # 
Instance details

Defined in Circuit.Chu

ChuObject r a => ChuObject r (ChuOBang r a) Source # 
Instance details

Defined in Circuit.Chu

ChuSeparated r a => ChuSeparated r (ChuOBang r a) Source # 
Instance details

Defined in Circuit.Chu

data ChuOWhyNot r (a :: k) Source #

Object-level ?A = (!A⊥)⊥.

Constructors

ChuOWhyNot 

Instances

Instances details
ChuExtensional r a => ChuExtensional r (ChuOWhyNot r a) Source # 
Instance details

Defined in Circuit.Chu

ChuObject r a => ChuObject r (ChuOWhyNot r a) Source # 
Instance details

Defined in Circuit.Chu

ChuObject r a => ChuSeparated r (ChuOWhyNot r a) Source # 
Instance details

Defined in Circuit.Chu