Initial commit

This commit is contained in:
Lyes Saadi 2026-01-15 17:47:56 +01:00
commit 08f2664cec
Signed by: lyes
GPG key ID: 55A1D803917CF39A
5 changed files with 1494 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.pdf

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "template"]
path = template
url = ssh://forgejo@git.lyes.eu/lyes/template.git

678
1.typ Normal file
View file

@ -0,0 +1,678 @@
#import "template/lib.typ": *
#import "@preview/fletcher:0.5.8" as fletcher: diagram, node, edge
#let scheme = dark
#let edge = edge.with(stroke: scheme.fg, crossing-fill: scheme.bg)
#show: paper.with(scheme: scheme, title: "SEMPL", subtitle: "Lesson 1")
#let environment = environment.with(scheme: scheme)
#let environment_ = environment_.with(scheme: scheme)
#let theorem = environment.with(name: "Theorem")
#let definition = environment.with(name: "Definition")
#let exercise = environment.with(name: "Exercise")
#let proof = environment_.with(name: "Proof of", follows: true)
#outline()
= Course Organization <nonumber>
Paul-André Melliès
Website : `https://www.irif.fr/~mellies/mpri/mpri-m2/mpri-mellies-slides-1.pdf`
E-mail : `mellies@irif.fr`
= Introduction : $lambda$-calculus <nonumber>
There are two ways to work with $lambda$-calculus semantics:
- Denotational Semantics
- Operational Semantics
With two syntax evaluations:
- big step
- small step
And three strategies:
- call-by-name (CBN)
- call-by-value (CBV)
- call-by-need
And using Curry-Howard, we have a correspondance between proofs and programs.
With C, pointers allows you access memory without knowing all the details
behind it.
The course will mainly speak about semantics and points of view about programs.
The shift of C to Rust, and seperation logic were born from semantics.
How do we have access to god ?
= Domains and continuous functions
It's intuitionistic logic.
== Cartesian Closed Categories <nonumber>
Intuitionistic (minimal) logic.
It is deeply connected to the simply-typed $lambda$-calculus.
Domains
Can be seen as Domains = ordered set structure.
$A times B$, $A => B$. A type is a Domain.
== Introduction to domain theory
=== Category Theory
#let Hom = "Hom"
#definition(subtitle: "Category")[
A category is a _class_ of vertices (called objects) and a set of edges
(called maps or morphisms) equiped with a family of functions
$compose : Hom(B, C) times Hom(A, B) -> Hom(A, C)$ with:
1. An identity map $id_A in Hom(A, A)$ such that $id_A compose f = f$ and $g = g compose id_A$
2. Associativity $h compose (g compose f) = (h compose g) compose f$
]
#environment(name: "Ad", counter: none)[
1-2-3 october at the Institut Henri Poincaré
URL : https://www.ihp.fr/en/events/bridging-linguistic-gap-between-mathematician-and-machine ?
]
#definition[
The inf of $a$ and $b$ is an element $a and b$ such that:
1. $a and b <= a$
2. $a and b <= b$
3. $forall x, x <= a and x <= b => x <= a and b$
#diagram(
node((0, 0), $a$),
node((2, 0), $b$),
node((1, 1), $a and b$),
node((1, 2), $x$),
edge((1, 1), (0, 0), "->"),
edge((1, 1), (2, 0), "->"),
edge((1, 2), (1, 1), "->"),
edge((1, 2), (0, 0), "-->", bend: 20deg),
edge((1, 2), (2, 0), "-->", bend: -20deg),
)
]
#definition[
A cartesian product of $A$ and $B$ is a triple $(A times B, A times B arrow.r^(pi_1) A, A times B arrow.r^(pi_2) B)$
#diagram(
node((0, 0), $A$),
node((2, 0), $B$),
node((1, 1), $A times B$),
node((1, 2), $X$),
edge((1, 1), (0, 0), "->", $pi_1$),
edge((1, 1), (2, 0), "->", $pi_2$),
edge((1, 2), (1, 1), "->", $h$),
edge((1, 2), (0, 0), "-->", bend: 20deg),
edge((1, 2), (2, 0), "-->", bend: -20deg),
)
]
#definition[
Given two objects $A$, $B$ in a category $C$, we define the category $"Span"(A, B)$:
- whose objects are triples $(X, X ->^f A, X ->^g B)$
- whose maps are $(X, X ->^f A, X ->^g B) -> (Y, Y ->^f A, Y ->^g B)$ is a
map $h: X -> Y$ in the category $C$ such that $f_X = f_Y compose h$ and $g_X = g_Y compose h$.
]
#exercise[
Show that $(A times B, pi_1, pi_2)$ is a cartesian product of $A$ and $B$ iff
it is *terminal* in $bold("Span"(A, B))$.
]
= Coherence spaces and cliques
It's linear logic (Girard late 80's).
A type is a set of points (or states). M a program is among those points when
seen as a type.
Monoidal Closed Categories.
$(A -o B)^bot ~= (A (x) B)^bot$
Linear from A to B => One input produces one output.
$
n |-> n + 1 &: NN -o NN\
n |-> n + n &: !NN -o NN\
f |-> sum^(f(7))_(i=0)(f(i)) &: !(NN -o NN) -o NN
$
= Dialogue games and strategies
heh
= Categories ?
#definition[
A cartesian closed category (CCC) is a cartesian category $(cal(C), times, bb(1))$
equipped for all $A, B$ objects of $cal(C)$ with an object $A => B$ and a map
$
"eval"_(A, B) : A times (A => B) --> B
$
Such that for all objects $C$ and for all maps
$
f : A times C --> B
$
there is a unique map
$
h : C --> (A => B)
$
such that the diagramm commute
#align(center, diagram($
A times (A => B) edge("->", label: "eval") &B\
A times C edge("-->", "u", label: A times h) edge("->", "ur")
$))
]
== Functors and natural transformations
#definition[
A functor $F : cal(A) -> cal(B)$ between categories $cal(A), cal(B)$ is the
data of an object $F A$ of $cal(B)$ for all objects $A$ of $cal(A)$, and a
family of functions:
$
Hom_cal(A)(A, A') &--> Hom_cal(B)(F A, F A')\
f : A --> A' &mapsto.long F f : F A --> F A'
$
Such that the composition law and identities are preserved.
]
#definition[
Given two functiors $F, G : cal(A) --> cal(B)$,
a natural transformation $theta : F => G$ is a family of maps
$theta_A : F A --> G A$ indexed by objects $A$ of $cal(A)$.
]
#definition[
If $cal(A)$ and $cal(B)$ are categories, $cal(A) times cal(B)$ whose
objects are pairs, whose maps are pairs.
]
Claim : every cartesian category $(cal(C), times, bb(1))$ comes equipped with a
functor:
$
times : &cal(C) times cal(C) --> cal(C)\
&(A, B) mapsto A times B
$
#exercise[
1. Show that $x times x$ defines a functor.
2. Show that the functor $times : cal(C) times cal(C) --> cal(C)$ comes
with two natural transformations.
$
phi_(A, B) : A times B ==>^(pi_1) A = "fst"(A, B)\
psi_(A, B) : A times B ==>^(pi_2) B = "snd"(A, B)
$
3. $Delta_A : A --> A times A$
#align(center, diagram({
node((-2, 0), [$cal(C)$])
node((0, 0), [$cal(C)$])
node((-3, 0), [$A$])
node((1, 0), [$A times A$])
node((-1, -2), [$(A, A)$])
node((-1, -1), [$cal(C) times cal(C)$])
edge((-2, 0), (0, 0), [$"Id"$], label-side: right, "->", bend: -36deg)
edge((-2, 0), (-1, -1), [$"diag"$], label-side: left, "->", bend: 18deg)
edge((-1, -1), (0, 0), [$times$], label-side: left, "->", bend: 18deg)
edge((-3, 0), (-1, -2), "|->", bend: 36deg)
edge((-1, -2), (1, 0), "|->", bend: 36deg)
edge((-3, 0), (1, 0), "|->", bend: -50deg)
edge((-1, 0.4), (-1, -1), [$Delta$], label-side: right, "=>")
}))
4. $gamma_(A, B) : A times B --> B times A$
#align(center, diagram({
node((-2, 0), [$cal(C)$])
node((0, 0), [$cal(C)$])
node((-3, 0), [$A$])
node((1, 0), [$A times A$])
node((-1, -2), [$(A, A)$])
node((-1, -1), [$cal(C) times cal(C)$])
edge((-2, 0), (0, 0), [$"Id"$], label-side: right, "->", bend: -36deg)
edge((-2, 0), (-1, -1), [$"diag"$], label-side: left, "->", bend: 18deg)
edge((-1, -1), (0, 0), [$times$], label-side: left, "->", bend: 18deg)
edge((-3, 0), (-1, -2), "|->", bend: 36deg)
edge((-1, -2), (1, 0), "|->", bend: 36deg)
edge((-3, 0), (1, 0), "|->", bend: -50deg)
edge((-1, 0.4), (-1, -1), [$gamma$], label-side: right, "=>")
}))
]
== Adjunctions
#environment(name: "Fact")[
Every category $cal(C)$ comes equipped with a functor structure on the hom sets:
$Hom_cal(C)(A, B)$.
$
Hom_cal(C) : &cal(C)^"op" times cal(C) --> &"Set"\
&(A, B) mapsto.long &Hom_cal(C)(A, B)
$
]
== Cartesian closed categories
#definition[
1. Based on $"eval" : A times (A => B) --> B$
2. Based on adjunctions :
A cartesian closed category $cal(C)$ is closed when for all objects $A$ in $cal(C)$,
the functor $A times \_ : &cal(C) --> cal(C)\ &B mapsto.long A times B$ has a right
adjoint $A_(=>) : &cal(C) --> cal(C)\ &B mapsto.long A => B$.
The two definitions are equivalent.
Given definition 2, we want to recover the family of maps $"eval" : A times (A => B) --> B$.
]
#environment_(name: "Geneal facts about adjunctions", counter: none)[
// #diagram($
// "Set" edge(->, label: "Free") edge(<-, label: "Forgetful") &"Mon"
// $)
Example 1 :
#align(center, diagram({
node((0, 0), [$"Set"$])
node((1, 0), [$"Mon"$])
node((.5, 0), [$bot$])
edge((0, 0), (1, 0), [Free], label-side: left, shift: 0.2, "->")
edge((1, 0), (0, 0), [Forgetful], label-side: left, shift: 0.2, "->")
}))
$
"Set"(A, M)\
tilde.equiv\
"Mon"(A^*, (M, eta, mu))
$
Example 2 :
#align(center, diagram({
node((0, 0), [$"Set"$])
node((1, 0), [$"Set"$])
node((.5, 0), [$bot$])
edge((0, 0), (1, 0), [$A times \_$], label-side: left, shift: 0.2, "->")
edge((1, 0), (0, 0), [$A => \_$], label-side: left, shift: 0.2, "->")
}))
$
"Set"(A times B, C)\
tilde.equiv\
"Mon"(A, B => C)
$
It's currification.
General case :
#align(center, diagram({
node((0, 0), [$A$])
node((1, 0), [$B$])
node((.5, 0), [$bot$])
edge((0, 0), (1, 0), [$L$], label-side: left, shift: 0.2, "->")
edge((1, 0), (0, 0), [$R$], label-side: left, shift: 0.2, "->")
}))
Suppose $L : A --> B$ left adjoint to $R : B --> A$
In that case, there exists families of maps / arrows
$eta : A --> R L A$ (unit of the adjonction) and $epsilon : L R B --> B$
(co unit of the adjunction).
*Adjunction* $L tack.l R : cal(B)(L -, =) tilde.equiv cal(A)(-, R =)$
$Phi_(A, B) : cal(B)(L A, B) tilde.equiv cal(A)(A, R B)$ (natural in A and B)
$B = L A : cal(B)(L A, L A) tilde.equiv cal(A)(A, R L A)$ ($eta_A = Phi_(A, L A)(id_(L A))$)
$A = R B : cal(B)(L R B, B) tilde.equiv cal(A)(R B, R B)$ ($epsilon_B = Phi^(-1)_(R B, B)(id_(R B))$)
#align(center, diagram({
node((0, -1), [$cal(A)^(op) times cal(B)$])
node((0, 1), [$"Set"$])
node((-1, 0), [$cal(A)^op times cal(A)$])
node((1, 0), [$cal(B)^op times cal(B)$])
node((2, 0), [$(L A, B)$])
node((-2, 0), [$(A, R B)$])
edge((0, -1), (-1, 0), [$\_ times R$], label-side: right, "->")
edge((0, -1), (1, 0), [$L^op times \_$], label-side: left, "->")
edge((-1, 0), (0, 1), [$"Hom"_cal(A)$], label-side: right, "->")
edge((1, 0), (0, 1), [$"Hom"_cal(B)$], label-side: left, "->")
edge((1, 0), (-1, 0), "=>")
}))
$eta$ is a natural transformation :
#align(center, diagram({
node((-1, -1), [$A$])
node((0, -1), [$R L A$])
node((-1, 0), [$A'$])
node((0, 0), [$R L A'$])
edge((-1, -1), (0, -1), [$eta_A$], label-side: left, "->")
edge((-1, -1), (-1, 0), [$h$], label-side: right, "->")
edge((0, -1), (0, 0), [$R L h$], label-side: left, "->")
edge((-1, 0), (0, 0), [$epsilon_A'$], "->")
}))
Which commutes for all $h : A --> A'$.
#align(center, diagram({
node((-1, -1), [$L R B$])
node((0, -1), [$B$])
node((-1, 0), [$L R B'$])
node((0, 0), [$B'$])
edge((-1, -1), (0, -1), [$epsilon_B$], label-side: left, "->")
edge((-1, -1), (-1, 0), [$L R h$], label-side: right, "->")
edge((0, -1), (0, 0), [$h$], label-side: left, "->")
edge((-1, 0), (0, 0), [$epsilon_B'$], label-side: right, "->")
}))
Which commutes for all $h : B --> B'$.
We have $eta : "Id"_cal(A) => R compose L$ and $epsilon : L compose R => "Id"_cal(B)$.
#align(center, diagram({
node((-1, -1), [$cal(A)$])
node((1, -1), [$cal(A)$])
node((0, 0), [$cal(B)$])
node((0, -2))
edge((-1, -1), (1, -1), [$"Id"_cal(A)$], label-side: left, "->", bend: 54deg)
edge((-1, -1), (0, 0), [$L$], label-side: right, "->", bend: -18deg)
edge((0, 0), (1, -1), [$R$], label-side: right, "->", bend: -18deg)
edge((0, -1.5), (0, 0), [$eta$], label-side: left, "=>")
}))
Back to example 1 :
A a set,
$eta_A : A &--> A^*\ a &mapsto.long [a]$
M a monoid,
$"eval"_M = epsilon_M ; M^* &--> M\ [m_1, ..., m_k] &mapsto.long m_A ... m_k$
Back to example 2 :
unit of $A times \_ tack.l A => \_$ is a CCC.
$eta^A_B : B &--> (A => (A times B))\ b &mapsto.long (a mapsto (A, B))$ (it's coeval)
counit of $A times \_ tack.l A => \_$ is a CCC.
$epsilon^A_B ; (A times (A => B)) &--> B\ (a, f) &mapsto.long f(A)$ (it's eval)
]
== Coherence Categories
Category *Coh* :
$
f : A --> B
$
is a relation
$
f subset.eq |A| times |B|
$
such that :
$
forall (a, b) in f, (a', b') in f, a "coh"_A a' => b "coh"_B b' => a "ncoh"_A a'
$
i.e., $f$ is a clique of $A -> B$.
$f : 1 -> A$ is a clique of A.
$g : A -> bot tilde.eq 1$ an anticlique of $A$ <=> a clique of $A multimap bot tilde.eq A^bot$.
#align(center, diagram({
node((-3, -1), [$A$])
node((-5, -1), [$1$])
node((-1, -1), [$bot tilde.equiv 1$])
node((-6, -1), [$*$])
node((0, -1), [$*$])
edge((-5, -1), (-3, -1), [$f "(clique)"$], label-side: left, "->")
edge((-3, -1), (-1, -1), [$g "(anti clique)"$], label-side: left, "->")
edge((-5, -1), (-1, -1), "->", bend: -30deg)
edge((-6, -1), (-5, -1), [$in$], label-side: center, " ")
edge((0, -1), (-1, -1), [$in.rev$], label-side: center, " ")
}))
=== Categorical structure of *Coh*
==== The cartesian product of A and B
#align(center, diagram({
node((-1, -1), [$A \& B$])
node((-2, -2), [$A$])
node((0, -2), [$B$])
node((-1, 1), [$X$])
edge((-1, 1), (-1, -1), [$exists!h$], label-side: center, "-->")
edge((-1, -1), (-2, -2), [$pi_1$], label-side: center, "->")
edge((-1, -1), (0, -2), [$pi_2$], label-side: center, "->")
edge((-1, 1), (-2, -2), [$f$], label-side: center, "->", bend: 18deg)
edge((-1, 1), (0, -2), [$g$], label-side: center, "->", bend: -18deg)
}))
$
&pi_1 = {("inl" a, a) | a in |A|}\
&pi_2 = {("inr" b, b) | b in |B|}\
&|A \& B| = {"inl" a | a in |A|} union.plus {"inr" b | b in |B|}\
&"given" f : X -> A "and" g : X -> B\
&h = {(x, "inl" a) | (x, a) in f} union.plus {(x, "inr" b) | (x, b) in f}
$
Why is $h$ a clique ?
terminal object : empty clique
==== The category of Coh is cartesian, but not cartesian closed
#import "@preview/pinit:0.2.2": *
$
pin("1") A \& B --> C pin("2")
$
#pinit-highlight("1", "2", fill: blue.transparentize(75%))
#pinit-point-from("2", "No way to currify", offset-dy: 10pt, body-dy: 0pt, fill: white)
==== On the other hand, there is a bijection
$
"Coh"(A (times) B, C) tilde.eq "Coh"(B, A -o C)
$
=== Exponentials in coherence spaces and linear logic
#let coh = "⁐"
#let ncoh = "ncoh"
$!A "has web" |!A|$ defined as the set of finite clique
$coh_(A!)$ when
1. $exists w$ a finite clique $u, v subset.eq w$.
2. (equiv) $forall a in u, forall tau' in v$, $a coh_(A!) a'$
==== Two main structures
$!A$ defines a _commutative comonoid_ in Coh.
#definition[
A monoid $(M, m, e)$ in a monoidal category $(cal(C), (times), bb(1))$ is an object
$M$ of $cal(C)$ equipped with two maps :
$m : M times M --> M$ $e : bb(1) --> M$
#align(center, diagram({
node((0, 0), [$M times M times M$])
node((1, 0), [$M times M$])
node((0, 1), [$M times M$])
node((1, 1), [$M$])
node((3, 0), [$M$])
node((4, 0), [$bb(1) times M$])
node((4, 1), [$M times M$])
node((6, 0), [$M$])
node((7, 0), [$M times bb(1)$])
node((7, 1), [$M times M$])
edge((0, 0), (1, 0), [$M times m$], label-side: left, "->")
edge((0, 0), (0, 1), [$m times M$], label-side: right, "->")
edge((0, 1), (1, 1), [$m$], label-side: right, "->")
edge((1, 0), (1, 1), [$m$], label-side: left, "->")
edge((3, 0), (4, 0), [$lambda^(-1)_M$], "->")
edge((4, 0), (4, 1), [$e times M$], label-side: left, "->")
edge((4, 1), (3, 0), [$m$], label-side: left, "->")
edge((7, 1), (6, 0), [$m$], label-side: left, "->")
edge((7, 0), (7, 1), [$M times e$], label-side: left, "->")
edge((6, 0), (7, 0), [$lambda^(-1)_M$], "->")
}))
#align(center, diagram({
node((3, 0), [$M$])
node((3, 1), [$M$])
edge((3, 0), (3, 1), [$id$], label-side: right, "->", bend: -36deg)
edge((3, 0), (3, 1), [$m compose (e times M) compose lambda^(-1)_M$], label-side: left, "->", bend: 36deg)
}))
]
#definition[
A comonoid in $(cal(C), (times), bb(A))$ is a monoid in the opposite monoidal category
$(cal(C)"op", (times), bb(1))$.
$d : M --> M (times) M$ $u : M --> bb(1)$
#align(center, diagram({
node((1, 0), [$M$])
node((2, 0), [$M times.o M$])
node((2, 1), [$M times.o M times.o M$])
node((1, 1), [$M times.o M$])
node((4, 0), [$M times.o M$])
node((4, 1), [$bb(1) times.o M$])
node((5, 0), [$M$])
node((6, 0), [$M times.o M$])
node((6, 1), [$M times.o bb(1)$])
edge((1, 0), (2, 0), [$d$], label-side: left, "->")
edge((1, 0), (1, 1), [$d$], label-side: right, "->")
edge((1, 1), (2, 1), [$M times.o d$], label-side: right, "->")
edge((2, 0), (2, 1), [$M times.o d$], label-side: left, "->")
edge((5, 0), (4, 0), [$d$], label-side: right, "->")
edge((5, 0), (6, 0), [$d$], label-side: left, "->")
edge((4, 0), (4, 1), [$u times.o M$], label-side: right, "->")
edge((6, 0), (6, 1), [$M times.o u$], label-side: left, "->")
edge((4, 1), (5, 0), [$lambda_M$], label-side: right, "->")
edge((6, 1), (5, 0), [$Gamma_M$], label-side: left, "->")
}))
#align(center, diagram({
node((1, 0), [$!A$])
node((2, 0), [$!A times.o !A$])
node((1, 1), [$!A times.o !A$])
node((2, 1), [$!A times.o !A times.o !A$])
edge((1, 0), (2, 0), [$d_A$], label-side: left, "->")
edge((1, 0), (1, 1), [$d_A$], label-side: right, "->")
edge((1, 1), (2, 1), [$!A times.o d_A$], label-side: right, "->")
edge((2, 0), (2, 1), [$d_A times.o !A$], label-side: left, "->")
edge((1, 0), (2, 1), [$d_a times.o d_a$], label-side: center, "->")
}))
]
#definition[
A commutative monoid in a symmetric monoidal category is a monoid $(M, m, e)$
such that this commutes :
#align(center, diagram({
node((1, 0), [$M times.o M$])
node((2, .5), [$M$])
node((1, 1), [$M times.o M$])
edge((1, 0), (2, .5), [$m$], label-side: left, "->")
edge((1, 1), (2, .5), [$m$], label-side: right, "->")
edge((1, 0), (1, 1), [$gamma_(M,M)$], label-side: right, "->")
}))
By duality, a commutative comonoid :
#align(center, diagram({
node((2, 0), [$M times.o M$])
node((1, .5), [$M$])
node((2, 1), [$M times.o M$])
edge((1, .5), (2, 0), [$d_m$], label-side: left, "->")
edge((1, .5), (2, 1), [$d_m$], label-side: right, "->")
edge((2, 0), (2, 1), [$gamma_(M,M)$], label-side: right, "->")
}))
]
#definition[
A monad is a monoid in the category of endofunctors.
A monad $T : cal(C) --> cal(C)$ is a functor equipped with a pair of natural
transformations.
$
eta_A : A --> A quad mu_A : T T A --> T A
$
]
#definition[
A comonad $K: cal(C) --> cal(C)$ on $cal(C)$ is defined as a monad on $cal(C)op$.
$
delta_A : A --> A quad epsilon_A : K A --> A
$
]
The exponential modality $!$ as a comonad $! : "Coh" --> "Coh"$ defines a functor.
$
[f : A --> B] mapsto.long [! f : !A --> !B]
$
$f$ a clique of $A -o B$.
$
!f = { (u, v) cases(forall a in u\, exists b in v \, (a\, b) in f, forall b in v\, exists a in u \, (a\, b) in f, delim: "|") }
$
$
delta_A = {(u, {v_1, ..., v_n}) | u = v_1 union ... union v_n} "(each "v_i" is a finite clique of "A")"
$
$
epsilon_A = {({a}, a)}
$
Intuitionistic linear logic :
$
A_1, ..., A_n tack B arrow.r.squiggly.long [A_1] (times) ... (times) [A_n] --> [B]
$
Contraction : $(Gamma, !A, !A tack B)/(Gamma, !A tack B)$ which is $!A -->^(d_A) !A (times) !A$
Weakening : $(Gamma tack B)/(Gamma, !A tack B)$ which is $!A -->^(u_A) bb(1)$
Dereliction : $(Gamma, A tack B)/(Gamma, !A tack B)$ which is $!A -->^(epsilon_A) A$
Digging : $(!A_1, ..., !A_n tack B)/(!A_1, ..., !A_n tack !B)$
Which is $!A -->^(delta_A) !!A$ and $!A (times) !B tilde.equiv !(A \& B)$
$
!(A \& A') tilde.equiv !A (times) !A' &-->f B\
!!(A \& A') tilde.equiv !A (times) !A' &-->^(!f) !B
$

811
2.typ Normal file
View file

@ -0,0 +1,811 @@
#import "template/lib.typ": *
#import "template/math.typ": *
#import "@preview/fletcher:0.5.8" as fletcher: diagram, node, edge
#import "@preview/curryst:0.6.0": rule, prooftree
#import "@preview/pinit:0.2.2": *
#let scheme = dark
#let edge = edge.with(stroke: scheme.fg, crossing-fill: scheme.bg)
#let prooftree = prooftree.with(stroke: stroke(thickness: 0.05em, paint: scheme.fg))
#show: paper.with(scheme: scheme, title: "SEMPL", subtitle: "Lesson 1")
#let environment = environment.with(scheme: scheme)
#let environment_ = environment_.with(scheme: scheme)
#let theorem = environment.with(name: "Theorem")
#let proposition = environment.with(name: "Proposition")
#let definition = environment.with(name: "Definition")
#let remark = environment.with(name: "Remark", counter: none)
#let exercise = environment.with(name: "Exercise")
#let proof = environment_.with(name: "Proof of", follows: true)
#let solution = environment_.with(name: "Solution of", follows: true)
#let example = environment_.with(name: "Example")
#let notation = environment_.with(name: "Notation", counter: none)
`guillaume.geoffroy@irif.fr`
#outline()
= (Some) Universal algrebra with binders
E.g. monoid = "Structure" over signature $(, 1)$ satisfying some equations
Idea :
- Model of the $lambda$-calculus
- Structure over signature $("Lambda", "App")$ satisfying
$
&beta : "App"("Lambda"(x . t), u) = t[x := u]\
&eta : "Lambda"(x . "App"(t, x)) = t
$
== Algrebraic syntax with binders
For a formal and abstract presentation
- #link("https://lics.siglog.org/archive/1999/GabbayPitts-ANewApproachtoAbstr.html")[Gabbay & Pitts (LICS 1999)]
- #link("https://lics.siglog.org/1999/FiorePlotkinTuri-AbstractSyntaxandVa.html")[Fiore, Plotkin & Tury (LICS 1999)]
An algebraic signature with binders is a pair $Sigma = ("Op"_Sigma, "Ar"_Sigma)$ with
- $"Op"_Sigma$ is a set (operations)
- $"Ar"_Sigma$ is $in "Op"_Sigma --> "List"(NN)$ (arity)
#example[
$
Sigma_1 = ({"Lam", "App"}, cases("Lam" mapsto (1), "App" mapsto (0, 0))})
$
]
#definition[
Let $Sigma$ be an algebraic signature.
The set of terms over $Lambda$ is defined by the following grammar, modulo
$alpha$-renaming.
$
t := &x " (variable)"\
&alpha((x_(1, 1), ..., x_(1, n_1))⋅t_1, ..., (x_(k, 1), ..., x_(k, n_k))⋅t_k)\
&"Where " alpha in "Op"_Sigma " and " (n_1, ..., n_k) = "Ar"_Sigma (alpha)
&"and " forall i, x_(i, 1), ..., x_(i, n_i) " are pairwise " eq.not
$
]
#example[
$"Term"(Sigma_Lambda)$ is the set of pure $lambda$-terms (modulo $alpha$)
]
#exercise[
Find a construction in an actual programming language that has arity $(1, 2)$.
]
#solution[
```
function [] -> e
| h::t -> f -> (0, 2)
function Leaf(x) -> e
| Node(l, r) -> f
```
]
#notation[
Let $Sigma$ be a signature, $x_1, ..., x_n$ pairwise $eq.not$ variables and
t, u_1, ..., u_n terms over $Lambda$.
We write $t[x_1 := u_1, ..., x_n := u_1]$ for the simultaneous capture-avoiding
(#sym.arrow.l.r.double compatible with $eq.not$) substitution of each free
occurrence of $x_i$ with $u_i$.
]
#let Lam = $"Lam"$
#let App = $"App"$
#let Op = $"Op"$
#let Ar = $"Ar"$
#let Type = $"Type"$
#let Rule = $"Rule"$
#exercise[
- $(Lam(x App(x, y)))[x := a, y := b] = Lam(x App(x, b))$
- $(App(x, y))[x := y, y := x] = App(y, x)$
- $(Lam(x App(y, x)))[y := x] = Lam(z App(x, z))$
]
#exercise[
$Sigma$ signature, $t$, $u$, $v$ terms, $x$, $y$ variables.
If $y$ not free in $t$, prove $t[x := u[y := v]] = t[x := u][y := v]$
]
#solution[
$
y[x := u[y := z]] := y\
y[x := u][y := z] := z
$
]
#proposition[
Let $Sigma$ signature, $t, u_1, ..., u_n, v_1, ..., v_n$ terms over $Sigma$
$x_1, ..., x_n, y_1, ..., y_n$ variables. If no $y_i$ is free in $t$ then
$t[x_1 := u_1[overline(y) := overline(v)], ..., x_n := u_m [overline(y) := overline(v)]]
= t[overline(x) := overline(u)][overline(y) := overline(v)]$
]
#remark[
Also true if the list $overline(x)$ contains all of the free variables of $t$,
regardless of whether any $y_i$ is free in $t$.
]
#definition[
Given a signature $Sigma$, a simple type system over $Sigma$ is a pair
$tau = ("Type"_tau, "Rule"_tau)$ where :
- $"Type"_tau$ is a set
- $"Rule"_tau in product_cases(delim: #none, alpha in "Op"_Sigma, (n_1, ..., n_k)=Ar_Sigma(alpha))$
]
Intuitively :
#prooftree(
rule(
$Gamma, x_(1, 1) : A_(1, 1), ..., x_(1, n_1) : A_(1, n_1) tack t_1 : B_1$,
$...$,
$Gamma, x_(k, 1) : A_(k, 1), ..., x_(k, n_k) : A_(k, n_k) tack t_k : B_k$,
$Gamma tack alpha((overline(x_1))t_1, ..., (overline(x_k))t_k) : C$
),
)
$
<=> Rule_tau (alpha) = (overline(A_1), B_1, ..., overline(A_k), B_k, C)
$
#example[
Let $Type_tau_(S T)$ be generated by
$
A, b ::= &a | b | ... " (atomic types)"\
| &A -> B
$
$
Sigma_S T = (union_(A, B) {Lam_(A, B), App_(A, B)}, cases(Lam_(A, B) mapsto (1), App_(A, B) mapsto (0, 0))})
$
$Rule_tau_(S T) (App_(A, B)) = (A -> B, A, B)$
#prooftree(
rule(
$Gamma tack t : A -> B$,
$Gamma tack u : B$,
$Gamma tack App_(A, B)(t, u) : B$
),
)
$Rule_tau_(S T) (Lam_(A, B)) = (A, B, A -> B)$
#prooftree(
rule(
$Gamma tack t : A$,
$Gamma tack u : B$,
$Gamma tack Lam(A, B)(xt) : A -> B$
),
)
]
#definition[
Let $Sigma, tau$ be a simply typed algebraic signature (STAS).
- A context is a tuple $((x_1 : A_1), ..., (x_n : A_n))$ (written $x_1 : A_1, ..., x_n : A_n$) when the $x_i$ are
pairwise $eq.not$ variables and the $A_i$ are types.
- The context $Gamma = x_i : A_i, ..., x_n : A_n$ binds the variables $x_1, ..., x_n : B_k$
- A context $Gamma$ _closes_ a term $t$ if it binds all its free variables
- A _term with context_ is a pair $(Gamma, t)$ (written $Gamma tack t$) where
$t$ is a term and $Gamma$ is a context that closes $t$.
- A _typing judgement_ is a triple $(Gamma, t, B)$ (written $Gamma tack t : B$)
where $Gamma tack t$ is a term with context and $B$ is a type.
]
#let ol = overline
#definition[
Let $(Sigma, tau)$ be a STAS. The set of (intuistionistically) valid judgements
for $(Sigma, tau)$ is the least set of typing judgements s.t :
- $forall x, A quad x : A tack x : A$ is valid
- $forall alpha in Op_Sigma$ with $(n_1, ..., n_k) = Ar_Sigma(alpha)$ and
$(overline(A_1), B_1, ..., overline(A_k), ..., B_k, C) = Rule_Sigma (alpha)$
$
forall Gamma, overline(x_1) : overline(A_1) tack t_1, B_1, ..., Gamma, ol(x_k) : ol(A_k) tack t_k : B_k "valid"\
forall Gamma tack alpha((ol(x_1))⋅t_1, ..., (ol(x_k))⋅t_k) : C "is valid"
$
- permutation
$ &forall m in NN quad forall sigma : {1, ..., m} --> {1, ..., m} "bijection"\
&forall A_1, ..., A_m "types"\
&forall x_1 : A_(sigma(1)), ..., x_m : A_(sigma(m)) tack t : B "valid"\
&forall y_1, ..., y_m "pairwise" eq.not "variables"
y_1 : A_1, ..., y_m : A_m tack t[x_1 := y_(sigma(1)), ..., x_m := y_(sigma(m))] : B "is valid"
$
- contraction
$ &forall m in NN quad forall sigma : {1, ..., m} --> {1, ..., n}\
&forall A_1, ..., A_n "types"\
&forall x_1 : A_(sigma(1)), ..., x_m : A_(sigma(m)) tack t : B "valid"\
&forall y_1, ..., y_n "pairwise" eq.not "variables"
y_1 : A_1, ..., y_n : A_n tack t[x_1 := y_(sigma(1)), ..., x_m := y_(sigma(m))] : B "is valid"
$
]
#exercise[
State the cut rule
]
== Cartesian models
Intuition :
$
A &~> [[A]] "Set with structure"\
t: A &~> [[t : A]] in [[A]]
$
2 paths :
- « Objects = Types, Morphims = Terms »
$
"(valid)" x_1 : A_1, ..., x_n : A_n tack t : B ~> [[Gamma tack t : B]] in space ??? [[A_1]], ..., [[A_n]]; [[B]] eq.not cal(C)([[A]], [[B]])
$
- « Objects = Contexts = Lists of types, Morphisms = Substitutions = Lists of terms »
$
"(valid)" underbrace(underbrace(x_1 : A_1\, ...\, x_n : A_n, Gamma) tack t_1 : B_B ... Gamma tack t_n : B_n, Gamma : overline(A) tack Delta : overline(B))
~> cases(
delim: "|",
overline(A) |-> [|overline(A)|],
Gamma : overline(A) |- Delta : overline(B) |->
[|Gamma |- Delta|] in ???_[|overline(A), overline(B)|]
)
$
#let List = "List"
#let lA = $overline(A)$
#let lB = $overline(B)$
#let lC = $overline(C)$
#let lD = $overline(D)$
#let lx = $overline(x)$
#let ly = $overline(y)$
#let lz = $overline(z)$
#let cC = $cal(C)$
#let lC = $overline(cC)$
#let lt = $overline(t)$
#let lu = $overline(u)$
#let lv = $overline(v)$
#let pair(r, l) = $chevron.l #r, #l chevron.r$
#let Types = $"Types"$
#exercise[
Let $(Sigma, tau)$ be a simply typed algebraic signature.\
- For all $overline(A), overline(B)$ list of types, let $cal(C)(overline(A), overline(B))$ be a set.\
- For all $Gamma : overline(A) |- Delta : overline(B)$ valid,
let $[|Gamma |- Delta|] in cal(C)(overline(A), overline(B))$
- For all $overline(A), overline(B), overline(C)$ and all
$b in cal(C)(overline(A), overline(B)),
c in cal(C)(overline(B), overline(C))$,
let $c[b] in cal(C)(overline(A), overline(C))$
Assume that
- $
&forall overline(A), overline(B), overline(C),\
&forall
Gamma_1 : overline(A) |- Delta_1 : overline(B) "and" Gamma_2 : overline(B) |- Delta_2 : overline(C) "valid",\
&[|Gamma_1 |- Delta_1|][[|Gamma_2 |- Delta_2|]] = [|Gamma_1 |- Delta_1[Gamma_2 |- Delta_2]|]
$
- $forall overline(A) overline(B), [| - |]_(overline(A), overline(B))$ is surjective
- $
forall "types" lA, B_1, ..., B_n\
forall "valid judgements"\
cases(delim: "(",
lz : lA tack t_1 : B_1,
lz : lA tack t_n : B_n
)\
cases(delim: "(",
lz : lA tack u_1 : B_1,
lz : lA tack u_n : B_n
)
$
- $[| lz |- alpha(lx_1 t_1, ..., lx_n t_n) |]$ depends only on $[| |- t_1 |], ..., [| |- t_n |]$
Prove that:
- $(List(Type), cal(C))$ defines a category with all finite products
- It is cartesian
- each $alpha in Op_Sigma$ is interpreted by a natural transformation (natural wrt the context)
]
#environment(name: "Erratum", counter: none)[
Terms in context are defined up to renaming :
$
x: A, y: B &tack t\
x': A, y': B &tack t[x := x', y := y']
$
]
#solution[
$"Id"$ morphism : $A_1, ..., A_n = overline(A)$
$
id_overline(A) = [[ overline(x) : overline(A) tack x_1 : A_1 ]], ..., [[ overline(x) : overline(A) tack x_n : A_n ]]
$
Composition : $overline(A), overline(B), overline(C)$
$
b in cal(C)(overline(A), overline(B)) quad c in cal(C)(overline(B), overline(C))\
c compose b = ? quad c[b]
$
Associativity : $overline(A), overline(B), overline(C), overline(D)$
$
b in cal(C)(overline(A), overline(B)) quad c in cal(C)(overline(B), overline(C)) quad d in cal(C)(overline(C), overline(D))\
"surjective : " b = [[overline(x) tack overline(t)]] quad c = [[overline(y) tack overline(u)]] quad d = [[overline(z) tack overline(v)]]\
d compose (c compose b) &= d[c[b]] \
&= [|overline(z) |- overline(v)|][[|overline(y) |- overline(u)|][[|overline(x) |- overline(t)|]]] \
&= [|overline(z) |- overline(v)|][[|overline(x) |- overline(u)[overline(y) := overline(t)]|]] \
&= [|overline(x) |- overline(v)[overline(z) := overline(u)[overline(y) := overline(t)]]|] \
&= [|overline(x) |- overline(v)[overline(z) := overline(u)][overline(y) := overline(t)]|] \
&= d[c][b] quad #[by unrolling in the other way]\
&= (d compose c) compose b
$
Unit : $overline(A), overline(B) quad b = [|overline(x) tack overline(t) in cal(C)(overline(A), overline(B))|]$
$
id_overline(B) &= [| overline(y) tack overline(y) |]\
id_overline(B) compose b &= [| overline(y) tack overline(y) |] compose [| overline(x) tack overline(t) |]\
&= [| overline(x) tack overline(y)[ overline(y) := overline(t) ]|]
&= [| overline(x) tack overline(t) |]
&= b
id_overline(A) &= [| overline(x') tack overline(x') |]\
b compose id_overline(A) &= [| overline(x) tack overline(t) |] compose [| overline(x') tack overline(x') |]\
&= [| overline(x') tack overline(t)[ overline(x) := overline(x') ]|]
&= [| overline(x) tack overline(t) |]
&= b
$
It is cartesian
- Terminal object : $[]$
- Product of $lA, lB$:
$
lA times lB & := [lA, lB] && quad ("concatenation") \
pi_lA & := [|lx : lA, ly : lB |- lx : lA|] \
pi_lB & := [|lx : lA, ly : lB |- ly : lB|] \
$
For $f := [|lz |- lt|] in cC(lC, lA), g := [|lz |- lu|] in cC(lC, lA)$,
$
pair(f, g) := [|z |- lt, lu|] quad (= [| [lz |- t_1, ..., lz |- t_m, lz |- u_1, ..., lz |- u_n] |])
$
Uniqueness:
Let $h = [|lz |- lv : lA, lB|] in cC(lC, [lA, lB])$.
$
lv &= [lv_lA, lv_lB] \
f &= pi_A compose h = [|lx, ly |- lx|] compose [|lz |- lv_lA, lv_lB|] \
&= [|lz |- lx[lx := lv_lA, ly := lv_lB]|] \
&= [|lz |- lv_lA|] \
g &= [|lz |- lv_lB|]
$
$h = pair(f, g)$ now follows from (3)
Prove that for all $alpha in Op_Sigma$ where $Rule(alpha) = (lA_1, B_1..., lA_n, B_n, C)$
the map $lD in List(Types) t-> cases(delim: "(",
b_1 = [| lz, lx_1 in cC((lD, lA_1), B_1) |],
...,
b_n = [| lz, lx_n in cC((lD, lA_n), B_n) |],
) t-> [| lz |- alpha(lx_1 ⋅ t_1, ..., lx_n ⋅ t_n) |]$ is a natural transformation (wrt $lD$).
$
cC((-, lA_1), B_1) times ... times cC((-, lA_n), B_n) => cC(-, C)
$
$
underbrace([| ly : lE |- lu : lD |], d) in cC(lE, lD)\
[| ly |- alpha(lx_1 ⋅ t_1[lz := lu], ..., lx_n ⋅ t_n[lz := lu]) |]
= [| lz |- alpha(lx_1 ⋅ t_1, ..., lx_n ⋅ t_n) |] compose [| ly |- lu |]
$
]
#show "STAS": "Simply Typed Algebraic Signature (STAS)"
#let Ob = $"Ob"$
#let Set = $"Set"$
#definition[
Let $(Sigma, tau)$ be a STAS.
A structure on $(Sigma, tau)$ is :
- A locally small#footnote[$forall A, B, cC(A, B) "is a set"$] cartesian category $cC$. Notation :
- $(A times B, pi_1 "or" pi_A, pi_2 "or" pi_B)$ product
- $pair(f, g) in cC(C, A times B)$ universal map
- $T$ terminal object
- $T_A in cC(A, T)$
- A function $[| ... |] : Types --> Ob(cC)$
- $forall alpha in Op_Sigma$ with $Rule(alpha) = (lA_1, B_1, ..., lA_n, B_n, C)$
a natural transformation (wrt $D$)
$[| alpha |] : D in Ob(cC) t-> [| alpha |]_D in Set(cC(D times [| lA_1 |], [[B_1]]) times ... times cC(D times [| lA_n |], [[B_n]]), cC(D, [|C|]))$ ($[|A_1|]$ meaning $[|A_(1, 1)|] times ... times [|A_(1, m_1)|]$)
]
#example[
$AA$ set of atomic types $~> Lambda_("ST", AA) = (Sigma_(Lambda_("ST", AA)), tau_(Lambda_("ST", AA)))$.
$cC = Set$. $forall a in AA "choose" [|a|] "set"$. Let $[| A --> B |] = cC([|A|], [|B|])$.
$
[|Lam_(A, B)|]_D = f t-> (x t-> y t-> f(x, y)) in Set(cC(D times [|A|], [|B|]), cC(D, cC([|A|], [|B|])))
$
]
#exercise[
Given $Gamma : lA |- lt : lB$ valid typing judgements.
Define $[| Gamma : lA |- lt : lB |] in tau([|lA|], [|lB|])$.
Such that $[| Gamma_1 |- Delta_2[Gamma_2 := Delta_1] |] = [| Gamma_2 |- Delta_2 |] compose [| Gamma_1 |- Delta_1 |] in cC(D, A) => cC(D, B)$
$cC(A, B)$
]
== Models of the Simply-Typed $lambda$-Calculus
#let ST = "ST"
#let app = "app"
#let lam = "lam"
Interpret $Lambda_(ST, AA)$ so that
$beta : [| lz : D |- app_(A, B)(lam_(A, B)(xt), u) : B |] = [| z |- t[x := u] |]$
and $eta : [| lz : D |- lam_(A, B)(x app_(A, B)(t, x)) : A -> B |] = [| lz : D |- t : A -> B |]$
Equivalently, so that $t =_(beta, eta) u => [| Gamma |- t |] = [| Gamma |- u |]$.
Take $cC$ locally small category.
Let $A -> B in Ob(cC), forall A, B in Ob(cC)$.
Let $cC(D times A, B) <--_(lam_(A, B, D)) cC(D, A -> B)$,
$cC(D, A -> B) times cC(D, A), -->_(app_(A, B, D)) cC(D, B)$ be a natural
transformation wrt D.
Assume that $forall t in cC(D times A, B), forall u in cC(D, u)$.
$beta : app(lam(t), u) = t compose pair(id_D, u)$
$eta : forall t e cC(D, A -> B)$
$t = lam(app(t compose pi_D, pi_A))$
Then $cC$ is cartesian closed (and this is equivalent).
#exercise[
Given $Gamma : lA |- lt : lB$ valid typing judgements.
Define $[| Gamma : lA |- lt : lB |] in tau([|lA|], [|lB|])$.
]
In Ocaml, is it true that $("fun" x -> t) u eq.triple t[x := u]$ ?
- find a sufficient condition on $f$ : if $f$ "uses $x$ exactly once"
- find a sufficient condition on $e$ : if $e$ has no side-effects
Attention : Non-commutative side-effects
== Interlude : Yoneda's Lemma
#let Cat = $cal("C")"at"$
#definition[
Let $cC$, $cD$ be locally small categories.
The category of functions $Cat(cC, cD)$ defined by:
]
#proposition[
Let $cC$ be a locally small category.
Then $Cat(cC^"op", Set)$ is a Grothendieck topos, in particular:
- It has all small limits and colimits
- It is cartesian closed
]
#let yo = $$
#definition(subtitle: "The Yoneda embedding")[
Let $cC$ a locally small category, we define a functor:
$
: cC --> Cat(cC^op, Set)
$
- On objects : $forall A in Ob(cC)$, $yo(A) : cC^"op" --> Set$ is defined by :
- $forall B in Ob(cC), yo(A)(B) = cC(B, A)$
- $forall f in cC(B_2, B_1), yo(A)(f) = cases(cC(B_1, A) &--> cC(B_2, A), g &t--> g compose f)$
$
yo(A)(f_1)(y(A)(f_2)(g)) &= (g compose f_2) compose f_1\
&= g compose (f_2 compose f_1)\
&= yo(A) (f_2 compose f_1) (g)
$
- On morphisms : $forall h in cC(A_1, A_2), yo(h) : yo(A_1) => y(A_2)$ is defined by :
$
forall B in Ob(cC), yo(h)(B) = cases(underbrace(yo(A_1)(B), cC(B, A_1)) &-->^(Set) underbrace(yo(A_2)(B), cC(B, A_2)),
g &t--> h compose g)
$
]
#exercise[
Prove that $forall h, yo(h)$ is natural : $forall f in cC^(B_1, B_2) = cC(B_2, B_1)$
#align(center, diagram({
node((-1, -1), [$cC(B_1, A_1)$])
node((-1, 1), [$cC(B_1, A_2)$])
node((3, -1), [$cC(B_2, A_1)$])
node((3, 1), [$cC(B_2, A_2)$])
edge((-1, -1), (-1, 1), [$h compose -$], label-side: right, "->")
edge((-1, -1), (-1, 1), [$yo(h)(B_1)$], label-side: left, " ")
edge((-1, -1), (3, -1), [$- compose f$], label-side: left, "->")
edge((3, -1), (3, 1), [$h compose -$], label-side: left, "->")
edge((3, -1), (3, 1), [$yo(h)(B_2)$], label-side: right, " ")
edge((-1, 1), (3, 1), [$- compose f$], label-side: right, "->")
edge((-1, 1), (3, 1), [$yo(A_2)(f)$], label-side: left, "->")
edge((-1, -1), (3, -1), [$yo(A_1)(f)$], label-side: right, " ")
}))
]
#theorem(subtitle: "Yoneda")[
For all $F in Cat(cC^"op", Set)$, the natural transformation :
$
cases(
Cat(cC^"op", Set)(yo(-), F) &==> F(-),
underbrace(A, in Ob(cC)) t-> underbrace(alpha, in yo(A) => F = Cat(cC^"op", Set)(yo(A), F)) &t--> underbrace(underbrace(alpha_A, in Set(yo(A)(A), F(A)))(underbrace(id_A, in cC(A, A) = yo(A)(A))), in F(A)),
)
$
is a bijection.
]
#exercise[
- Prove naturality
- Prove Yoneda (i.e. bijection)
- Prove that $yo : cC --> Cat(cC^"op", Set)$ which is full & faithful (Apply
yoneda to $F = yo(B)$)
- Prove that $yo$ is continuous (= preserves all small limits that exists in $cC$)
]
= Models of linear logic
== Nomenclature the various fragments of linear logic
$
#pin(1)&(times) quad &-o quad &1 quad & quad &par quad &bot quad &"multiplicative"\
&(+) quad &\& quad &0 quad &top quad & quad &&"additive"\
&! quad & quad & quad & #pin(2) quad & quad &&"exponential"\
$
$
"intuitionistic fragment"
$
// #pinit-highlight(1, 2)
- MALL : $(times) (+) \& par 1 space 0 space top bot -o$
- ILL : $(times) (+) \& space 1 space 0 space top -o !$
- MEILL : $(times) (+) \& par 1 space 0 space top bot -o ! space ?$
== Standard notions of models for fragments of MALL
$(times) 1$ : Symmetric monoidal category
- adding $-o$ : Symmetrict monoidal closed category
- adding $par bot$ : \*-autonomous
- adding $& top$ : Finite products
- adding $(+) 0$ : Finite coproducts
#definition[
Let $cC$ be a category and $A, B in Ob(cC)$.
A coproduct of A and B is:
- An object $A (+) B$
- Two morphisms $i_A in cC(A, A (+) B), i_B in cC(B, A(+) B)$
such that $forall C in Ob(cC), forall f in cC(A, C), forall g in cC(B, C)$
$exists ! [f, g] in cC(A (+) B, C)$ such that
#align(center, diagram({
node((-1, -1), [$A (+) B$])
node((0, -1), [$B$])
node((-2, -1), [$A$])
node((-1, 0), [$C$])
edge((0, -1), (-1, -1), [$iota_B$], label-side: right, "->")
edge((-2, -1), (-1, -1), [$iota_A$], label-side: left, "->")
edge((-1, -1), (-1, 0), [$[f, g]$], label-side: right, "->")
edge((0, -1), (-1, 0), [$g$], label-side: left, "->", bend: 18deg)
edge((-2, -1), (-1, 0), [$f$], label-side: right, "->", bend: -18deg)
}))
]
#let FinBan = $"FinBan"$
#example[
Let $FinBan$ (finite Banard) be the category defined by :
- $Ob(FinBan)$ : All finite-dimensional normed ($RR$-)vector spaces
- $FinBan(A, B)$ =
${ &f : A --> B "linear"\ &"s.t." forall ||f(a)|| <= ||a|| }$
- $FinBan(A_1, ..., A_n, B)$ =
${ &f : A_1 times ... times A_n --> B space n"-linear (linear wrt each variable)"\ &"s.t." forall ||f(a_1, ..., a_n)|| <= ||a_1|| ... ||a_n|| }$
- $top = 0 = { 0 }$
- $A & B = A times B space (= A + B)$, $||(a, b)|| = max(||a||, ||b||)$\
Exercise : Prove that product\
$||pi_A(a, b)|| = ||a|| <= max(||a||, ||b||)$\
$||pi_B(a, b)|| = ||b|| <= max(||a||, ||b||)$
Let $f in FinBan(C, A)$, $g in FinBan(C, B)$.
$<f, g>$ must be defined by $<f, g>(c) = (f(c), g(c))$
let $c in C$, $underbrace(||f(c)|| <= c quad ||g(c)|| <= c, ||(f(c), g(c))|| <= c)$
- $A (+) B = A + B space (= A times B)$\
$||inj_A(a, b)|| = ||(a, 0)|| "and" ||(a, 0)||, ||a||$\
$||inj_B(a, b)|| = ||(0, b)|| "and" ||(0, b)||, ||b||$
Let $f in FinBan(A, C)$, $g in FinBan(B, C)$.
$exists ! h : A (+) B --> C$ linear s.t $h compose inj_1 = f$ ($h(a, 0) = f(a)$) and $h compose inj_2 = g$ ($f(0, b) = g(b)$)
So, $h(a, b) = h((a, 0) + (0, b)) = f(a) + g(b)$.
$||h(a, b)|| = ||f(a) + g(b)|| <= ||f(a)|| + ||g(b)|| <= ||a|| + ||b||$
- $A -o B$ = Linear maps $A -> B$
$||f|| = sup_"max" {||f(a)||, ||a|| <= 1}$
- $bot = 1 = (RR, |.|)$
$
1 -o B &arrow.r.double^~ B\
underbrace(f, ||f|| = ||f(1)|| = ||f(-1)||) &t-> f(1) quad quad (|r| <= 1)
$
$((a -o bot) -o bot) tilde.eq A$
- $(A (*) B, (a, b) t-> a (*) b)$ is characterised by the following universal property.
#align(center, diagram({
node((-2, -1), [$(A, B)$])
node((0, -1), [$FinBan(A, B\; C)$])
node((-1, -1), [$C$])
node((-2, 0), [$A (times) B$])
node((-2, 1), [$FinBan(A, B\; A (times) B)$])
edge((-2, 0), (-1, -1), [$exists !$], label-side: right, "-->")
edge((-2, -1), (-1, -1), [$forall$], label-side: left, "->")
edge((-2, -1), (-2, 0), [$(a, b) t-> a (times) b$], label-side: right, "->")
edge((-2, 1), (-2, 0), [$in$], label-side: center, " ")
edge((-1, -1), (0, -1), [$in$], label-side: center, " ")
edge((-2, -1), (-2, -1), "->", bend: 140deg, loop-angle: 135deg)
}))
]
#exercise[
Find a symmetrical monoidal category $(cC, (*), 1)$
s.t. $cC$ has finite coproducts but $(*)$ does not distribute over them.
i.e., in general :
- $A (*) (B (+) C) tilde.eq.not (A (*) B) (+) (B (*) C)$
- $A (*) 0 tilde.eq.not 0$
]
#solution[
$cC = FinBan$
$(*) = \&$
$I = top$
$(1 (+) 1) \& 1 tilde.eq.not (1 \& 1) (+) (1 \& 1)$
]
== Interpreting $!$ Linean/Non-Linear adjunctions
#definition[
Let $(cC, , I) space (cD, (x), 1)$ be symmetric monoidal categories.
A _symmetric lax monoidal functor_ from $cC$ to $cD$ is a functor
$F : cC --> cD$ equipped with :
- A natural transformation (wrt $A, B$) :
$m^2_(A, B) in cD(F A (*) F B, F (A B)), forall A, B in Ob(cC)$
- A morphism $m^0 in cD(1, F I)$
Such that :
1.
#align(center, diagram({
node((0, 0), [$(F A (*) F B) (*) F C$])
node((1, 0), [$F A (*) (F B (*) F C)$])
node((0, 1), [$F(AB) (*) F C$])
node((0, 2), [$F((AB)C)$])
node((1, 1), [$F A (*) F (B C)$])
node((1, 2), [$F (A (B C))$])
edge((0, 0), (1, 0), [$"assoc"^cD$], label-side: left, "->")
edge((0, 2), (1, 2), [$"assoc"^cD$], label-side: left, "->")
edge((0, 0), (0, 1), [$m^2_(A, B) (*) F C$], label-side: right, "->")
edge((0, 1), (0, 2), [$m^2_(AB, C)$], label-side: right, "->")
edge((1, 0), (1, 1), [$F A (*) m^2_(B, C)$], label-side: left, "->")
edge((1, 1), (1, 2), [$m^2_(A, BC)$], label-side: left, "->")
}))
2.
// https://q.uiver.app/#r=typst&q=WzAsNCxbMCwwLCJGIEEgKCopIDEiXSxbMSwwLCJGIEEiXSxbMCwxLCJGIEEgKCopIEYgSSJdLFsxLDEsIkYgKEEg4ouF4oCvSSkiXSxbMCwxLCJcInVuaXRcIl5jRCJdLFswLDIsImlkXyhGIEEpICgqKSBtXjAiLDJdLFszLDEsIkYgKFwidW5pdFwiXmNDKSIsMl0sWzIsMywibV4yIiwyXV0=
#align(center, diagram({
node((-2, -2), [$F A (*) 1$])
node((-1, -2), [$F A$])
node((-2, -1), [$F A (*) F I$])
node((-1, -1), [$F (A I)$])
edge((-2, -2), (-1, -2), [$"unit"^cD$], label-side: left, "->")
edge((-2, -2), (-2, -1), [$id_(F A) (*) m^0$], label-side: right, "->")
edge((-1, -1), (-1, -2), [$F ("unit"^cC)$], label-side: right, "->")
edge((-2, -1), (-1, -1), [$m^2$], label-side: right, "->")
}))
3.
// https://q.uiver.app/#r=typst&q=WzAsNCxbMCwwLCJGIEEgKCopIEYgQiJdLFsxLDAsIkYgQiAoKikgRiBBIl0sWzAsMSwiRiAoQSDii4UgQikiXSxbMSwxLCJGIChCIOKLhSBBKSJdLFswLDIsIm1fMiJdLFsxLDMsIm1eMiJdLFswLDEsIlwiU3dhcFwiXmNEIiwxXSxbMiwzLCJGIChcIlN3YXBcIl5jQykiLDFdXQ==
#align(center, diagram({
node((-2, -1), [$F A (*) F B$])
node((-1, -1), [$F B (*) F A$])
node((-2, 0), [$F (A B)$])
node((-1, 0), [$F (B A)$])
edge((-2, -1), (-2, 0), [$m^2$], label-side: right, "->")
edge((-1, -1), (-1, 0), [$m^2$], label-side: left, "->")
edge((-2, -1), (-1, -1), [$"Swap"^cD$], label-side: center, "->")
edge((-2, 0), (-1, 0), [$F ("Swap"^cC)$], label-side: center, "->")
}))
A _strong monoidal functor_ is a lax monoidal functor (F, m) s.t. $m^2$ and
$m^0$ are isomophisms.
]
#definition[
A _symmetric monoidal adjunction_ :
#align(center, diagram({
node((-1, 0), [$(cal(C), dot, I)$])
node((1, 0), [$(cal(D), (*), 1)$])
node((0, 0), [$bot_(underline(m), underline(eta), underline(epsilon))$])
edge((-1, 0), (1, 0), [$L$], label-side: left, "->", bend: 40deg)
edge((1, 0), (-1, 0), [$B$], label-side: left, "->", bend: 40deg)
}))
Is the data of :
- A strong monoidal functor $(L, m) : (cC, , I) --> (cD, (*), 1)$
- A functor $R : cD --> cC$
- An adjunction $L attach(tack.l, br:(eta, epsilon)) R$
$
// https://q.uiver.app/#r=typst&q=WzAsMixbMCwwLCJjQyJdLFsxLDAsImNEIl0sWzAsMSwiTCIsMCx7Im9mZnNldCI6LTN9XSxbMSwwLCJSIiwwLHsib2Zmc2V0IjotM31dLFswLDEsImJvdF8oZXRhLCBlcHNpbG9uKSIsMSx7InN0eWxlIjp7ImJvZHkiOnsibmFtZSI6Im5vbmUifSwiaGVhZCI6eyJuYW1lIjoibm9uZSJ9fX1dXQ==
#align(center, diagram({
node((0, 0), [$cC$])
node((1, 0), [$cD$])
edge((0, 0), (1, 0), [$L$], label-side: left, shift: 0.3, "->")
edge((1, 0), (0, 0), [$R$], label-side: left, shift: 0.3, "->")
edge((0, 0), (1, 0), [$bot_(eta, epsilon)$], label-side: center, " ")
}))
$
]
#definition[
A _linear/non-linear adjunction_ is a summetric monoidal adjunction
#align(center, diagram({
node((-1, 0), [$(VV, times, I)$])
node((1, 0), [$(LL, (*), 1)$])
node((0, 0), [$bot_(m, eta, epsilon)$])
edge((-1, 0), (1, 0), [$L$], label-side: left, "->", bend: 40deg)
edge((1, 0), (-1, 0), [$V$], label-side: left, "->", bend: 40deg)
}))
]
=== The exponential comonoad $!$
Let $! = L compose V : bb(L) -> bb(L)$.
$forall a in "OB" bb(L), $ let $mu_A = L( eta_(V A)) in bb(L)(L V A, L V L V A)$ \
($L V A "is" !A$, $L V L V A "is" !!A$,) \
Then $(!, epsilon, mu)$ is a comonad.
We then have
#diagram({
node((0, 0), [$(LL_!, par, T)$])
node((2, 0), [$(LL, (*), 1)$])
node((1, 0), [$bot$])
edge((0, 0), (2, 0), [$!$], label-side: left, "->", bend: 18deg)
edge((2, 0), (0, 0), [$id$], label-side: left, "->", bend: 18deg)
})
where $bb(L)_!(A,B) := bb(L)(!A, B)$
#let big_adjunction(L, R, f, g, a: $bot$) = diagram({
node((-1, 0), L)
node((1, 0), R)
node((0, 0), a)
edge((-1, 0), (1, 0), f, label-side: left, "->", bend: 18deg)
edge((1, 0), (-1, 0), g, label-side: left, "->", bend: 18deg)
})
#big_adjunction($(LL^!, (*), 1)$, $(LL, (*), 1)$, $"forget"$, $!$)
#definition[
Let $cC$ be a category and $(!, epsilon, nu)$ a command on $cC$
- The Kleisli category $cC_!$ is defined by
$ &Ob(cC_!) = Ob(cC)\
&cC_! (A, B) = cC(!A, B)\
&"for" f in cC_! (A, B), g in cC_! (B, C)\
&g << f in cC_!(A, C) "is defined by"\
&g << f = f compose !f compose nu_A
$
]

1
template Submodule

@ -0,0 +1 @@
Subproject commit 41831f17bcfbf3773bc8c91692f4b4ee35ecf580