A bridge between semirings
Flavien BREUVART
PPS, Paris Denis Diderot & LIPN, Paris Nord
march 11th-26th 2014
Introduction
Semirings S , R for resource management
Many papers are using semirings for modelizing quantitative resources.
Bounded logics B
SLL [Ghica&Al13,Brunel&Al13]
Generalisation of previous works that decompose LL exponential along semirings.
No generic concrete model.
Model Rel
Rof LL [CarraroEhrhardSalibra09]
The relational model endowed with a non free exponential using semiring-indexed multisets.
General theorem
Every bounded logic B
SLL has as model REL
(R,˜∈,S).
Table of content
Logic
•
Ordered semirings
•
Curry Howard
•
The logic B
SLL
•
Examples
Categorical semantic
•
Ghica&Smith vs Brunel&Al
•
Refining models of LL
•
Brunel&Al’s
Concrete semantic
•
Rel
•
Our Rel
(R,˜∈,S)•
Carraro&All’s Rel
R•
Universality
Table of content
Logic
•
Ordered semirings
•
Curry Howard
•
The logic B
SLL
•
Examples
Categorical semantic
•
Ghica&Smith vs Brunel&Al
•
Refining models of LL
•
Brunel&Al’s
Concrete semantic
•
Rel
•
Our Rel
(R,˜∈,S)•
Carraro&All’s Rel
R•
Universality
Definition of ordered semirings
Ordered semiring S
An ordered semiring is a structure S = (|S|, +, 0, ∗, 1, ≤) where (|S|, ≤) is a poset, 0, 1 ∈ |S| and where +, · : |S|
2→ S such that:
•
+ and ∗ are associative,
•
+ is commutative and distribute over ∗,
•
0 is neutral for + and 1 is neutral for ∗,
•
if J ≤ J
0and K ≤ K
0then J ∗ J
0≤ K ∗ K
0and J+J
0≤ K +K
0.
Examples of ordered semirings
•
1 : the trivial Semiring with just one element.
•
P oly : the polynomials with their usual sum, product and order.
•
T rop = ( N , max, −∞, +, 0, ≤) and A rt = ( ¯ N , min, ∞, +, 0, ≤),
•
A ut
M: for any commutative monoid ( M , +, 0), the automorphisms
(Mon( M , M ), +, cst
0, ◦, id
M, id
Mon(M,M))
Grammar of B S LL
Formulas
(formulas) A, B , C := α | A ⊗ B | A ( B | !
KA ,∀K ∈ S This is only IMB
RLL and can be generalised.
Sequents Γ ` A
IMLL plus:
Γ ` B (!w) Γ, !
0A ` B
Γ, A ` B Γ, !
1A ` B (!d)
Γ, !
JA, !
KA ` B Γ, !
J+KA ` B (!c)
!
J1A
1, · · · , !
JnA
n` B
!
K∗J1A
1, · · ·!
K∗JnA
n`!
KB (!s)
Γ, !
JA ` B K ≥ J
(Sw )
Γ, !
KA ` B
Curry-Howard: Λ S
Grammar of Λ
SGiven a semiring S we define typed lambda calculus:
(terms) Λ M, N ::= x | λx.M | M N
(types) T
S`θ := α | K ·θ ( θ ,∀K ∈ S
Some examples (with S = Hom( N ))
λxy .y: 0·θ ( 1·θ
0( θ
0λxy.x(xy ): 4·(3·θ ( θ) ( 9·θ ( θ λxy.xyy: 1·(2·θ ( 3·θ ( θ
0) ( 5·θ ( θ
0λxyz.x (yz ): 1·(f ·θ ( θ) ( f ·(g ·θ ( θ) ( f ◦g ·θ ( θ
λxyz .y (xz ): g ·(f ·θ ( θ) ( 1·(g ·θ ( θ) ( g ◦f ·θ ( θ
Typing judgements
Ghica’s linear type system
x:1·θ ` x:θ Id Γ ` M :θ Γ, x :0·θ
0` M:θ Weak
Γ, x:K ·θ ` M:θ
0Γ ` λx .M:K ·θ ( θ
0Abs Γ ` M:K ·θ ( θ
0Γ
0` N:θ |Γ| = |Γ
0|
Γ+ K ∗Γ
0` M N : θ
0App
where |Γ| = |Γ
0| means the equality of contexts except for the multiplicity of the types:
|(x
i:K
i·θ
i)
i≤k| = |(y
i:L
i·θ
0i)
i≤k0| ⇔ (k = k
0∧ x
i= y
i∧ θ
i= θ
0i) and where Γ+ K ·Γ
0is the context obtain by applying addition and multiplication to the semiring:
(x
i:K
i·θ
i)
i+(x
i:L
i·θ
i)
i:= (x
i:(K +L)·θ
i)
iK ∗(x
i:L·θ
i)
i:= (x
i:K ∗L·θ
i)
iExamples and interest
Counting resources
N : if M : n·A ( U then the KAM on M N will evaluate at most n times the N.
P oly : if M is typable then M N has a polynomial head reduction on the size on N.
A rt: with streams of type Str and the operations tl : 1·Str ( Str and hd : 1·Str ( U , if M : n·Str ( A, its argument will be explored at depth at most n.
A more complicated example: Ghica&Smith’s
[ ]+[ , ] = [ , , ]
[ ] ∗ [ , ] = [ , ]
This computes the sequentially of an execution.
Table of content
Logic
•
Ordered semirings
•
Curry Howard
•
The logic B
SLL
•
Examples
Categorical semantic
•
Ghica&Smith vs Brunel&Al
•
Refining models of LL
•
Brunel&Al’s
Concrete semantic
•
Rel
•
Our Rel
(R,˜∈,S)•
Carraro&All’s Rel
R•
Universality
Categorical semantic
There is two choices of categorical semantic in the literature:
Brunel&al’s categorical semantic
– Difficult to understand – Over 20 commutative
diagrams
+ Accept any model of LL as a degenerative model + The syntax itself is a model
GhicaSmith’s categorical semantic
+ Quite simple to understand and realise
– The only accepted model of LL is the singleton (up-to iso)
– The syntax is not a model
Restricting models of LL into models of B
SLL
LL model + π
J:!A →!
JA + ι,
J:!
JA →!A + 5 diagrams = B
SLL
model
Brunel&al’s categorical semantic
Ordered semirings as categories
Any ordered semiring can be seen as bimonoidal category whose objects are the elements of the semirings and whose homesets S(J, K ) are either singleton (when J ≤ K ) or empty.
Bounded exponential situation
A bounded exponential situation is the given of:
•
a symmetric monoidal category (model of MLL) (A, ⊗, ( , 1),
•
a bifunctor: • : S × A → A
•
6 naturals transformations:
δ
0: (J∗K )•A = ⇒ J •K •A
0: 1•A = ⇒ A c
0: (J+K )•A = ⇒ J•A ⊗ K •A w
0: 0•A = ⇒ 1 m
0: J•A ⊗ J•B = ⇒ J •(A ⊗ B) n
0: 1 = ⇒ J•1
•
and more than 20 commutative diagrams.
An example of wanted diagram
(J+K )•A ⊗ (J +K )•B
((J •A) ⊗ (K •A)) ⊗ ((J•B) ⊗ (K •B )) (J+K )•(A ⊗ B)
((J•A) ⊗ (J •B)) ⊗ (K •A ⊗ K •B) J•(A ⊗ B) ⊗ K •(A ⊗ B)
c
0⊗ c
0m
0α
⊗c
0m
0⊗ m
0Obtaining bounded exponential as retractions of usual exponential
Bounded exponential situation by retraction-embedding
A bounded exponential situation by retraction-embedding is the given of:
•
a model of MELL (A, ⊗, !, 1, ( , δ, , c, w , m, n),
•
a bifunctor: • : S × A → A
•
2 naturals transformations:
ι : J •A = ⇒!A π :!A = ⇒ J•A
•
and 5 commutative diagrams.
The retraction-embedding diagram
The equation ι
J,A; π
J,A= id
J•Ais not a priori needed, but is true in every
interesting considered model.
An examples and interest of wanted diagrams
!A !A⊗!A !A⊗!B !(A ⊗ B)
(J +K )•A J • A ⊗ K •A J•A ⊗ J•B J •(A ⊗ B)
!A !A⊗!A !A⊗!B !(A ⊗ B)
c
π π ⊗ π
ι π
c
m
π π ⊗ π
ι π
m
An examples and interest of wanted diagrams
!A !A⊗!A !A⊗!B !(A ⊗ B)
(J +K )•A J • A ⊗ K •A J•A ⊗ J•B J •(A ⊗ B)
def .c
0def .m
0!A !A⊗!A !A⊗!B !(A ⊗ B)
c
π π ⊗ π
c
π π ⊗ π
c
0ι π
c
m
π π ⊗ π
m
π π ⊗ π
m
0ι π
m
An examples and interest of wanted diagrams
!A !A⊗!A !A⊗!B !(A ⊗ B)
C M
(J +K )•A J • A ⊗ K •A J•A ⊗ J•B J •(A ⊗ B)
!A !A⊗!A !A⊗!B !(A ⊗ B)
c
π π ⊗ π
c
0ι π
c
ι π
c
m
π π ⊗ π
m
0ι π
m
ι π
m
Theorem
Theorem:
LL model + π
J:!A → J•A + ι,
J: J•A →!A + 5 diagrams = B
SLL model
δ
J,K,A0= ι
J∗K,A; δ
A; !π
K,A; π
J,K•A 0A= ι
1,A;
Ac
J,K,A0= ι
J+K,A; c
A; (π
J,A⊗ π
K,A) w
A0= ι
0,A; w
Am
0J,A,B= (ι
J,A⊗ ι
J,B); m
A,B; π
J,A⊗Bn
0J= n; π
J,1An example of wanted diagram
(J+K )•A ⊗ (J +K )•B
((J •A) ⊗ (K •A)) ⊗ ((J•B) ⊗ (K •B )) (J+K )•(A ⊗ B)
LL
((J•A) ⊗ (J •B)) ⊗ (K •A ⊗ K •B) J•(A ⊗ B) ⊗ K •(A ⊗ B) def c
0⊗ def c
0def m
0nat α
⊗C
M ⊗ M
c
0⊗ c
0m
0α
⊗c
0m
0⊗ m
0ι ⊗ ι
c ⊗ c
(π ⊗ π) ⊗ (π ⊗ π) m π
α
⊗(π ⊗ π) ⊗ (π ⊗ π)
c
π ⊗ π
m ⊗ m
Table of content
Logic
•
Ordered semirings
•
Curry Howard
•
The logic B
SLL
•
Examples
Categorical semantic
•
Ghica&Smith vs Brunel&Al
•
Refining models of LL
•
Brunel&Al’s
Concrete semantic
•
Rel
•
Our Rel
(R,˜∈,S)•
Carraro&All’s Rel
R•
Universality
The model Rel of LL [folklore]
The category Rel : a model of MLL
Objects: Sets Morphisms: Relations Multiplicatifs: A ⊗ B = A ( B = A × B and 1 = {∗}
Rel
N: a model of MELL
Exponential: !A = M
f(A)
δ
A= {(u, V ) | V ∈!!A, u = ΣV }
A= {([a], a) | a ∈ A}
c
A= {(u, (v, w )) | u = v +w } w
A= {([], ∗)} n = {(∗, [∗, ..., ∗])}
m
A,B= {((u, v ), w ) | ∀a, u(a) = Σ
b∈Bw (a, b), ∀b, v (b) = Σ
a∈Aw (a, b)}
Hypothesis: multiplicity [Carraro&Al]
A semiring R has multiplicities if
(MS1) it is positive: m+n = 0 ⇒ m = n = 0 (MS2) it is discreet: m+n = 1 ⇒ m = 0 or n = 0 (MS3) it has additive splitting properties.
m
1+n
1= m
2+n
2⇒ ∃(p
ij)
1≤i,j≤2, m
i= p
i1+p
i2, n
j= p
1j+p
2j.(MS4) it has multiplicative k-ary splitting property:
n
1+n
2= pm ⇒ ∃k, p
1, p
2, m
11, m
12, m
21, m
22, p = X
j≤k
p
j,
n
i= X
j≤k
p
jm
ji, ∀j ≤ k , m = m
j1+mj 2
Examples
•
N
•
N ¯
•
N × N
•
M
f( N )
R morally behave like N
•
R contain N as sub semiring
•
The sum in R is the one of N
The model Rel R of LL [Carraro&Al]
Definition of R
fhAi
Given a semiring R and a set A, the space of functions f : A → R of finite support is denoted R
fhAi. It is a semimodule over R with:
•
A commutative sum: (f +g )(x) = f (x)+g (x )
•
An external product: (K ·f )(x ) = K ·f (x )
Rel
R: a model of MELL
Exponential: !A = R
fhAi
δ
A= {(u, V ) | V ∈!!A, u = Σ
v∈!AV (v)·v }
A= {([1·a], a) | a ∈ A}
c
A= {(u, (v , w ) | u = v+w ∈!A} w
A= {([], ∗)} n = {(∗, [J·∗])|J ∈R}
m
A,B= {((u, v ), w ) | ∀a, u(a) = Σ
b∈Bw (a, b), ∀b, v (b) = Σ
a∈Aw (a, b)}
It is a generalisation of Rel
NIndeed M
f(A) is an other notation for N hAi.
The model Rel (R,˜ ∈,S) of B S LL
Semiring refinement (R, ∈, ˜ S)
•
R is a semiring with multiplicities,
•
S is an ordered semiring,
•
∈ ˜ is a relation between those,
•
1
R∈1 ˜
Sand 0
R∈0 ˜
S,
•
n ∈J ˜ and m ∈K ˜ imply n+m ∈ ˜ J+K and n∗m ∈ ˜ J∗K ,
•
J ≤ K iff J ⊆K ˜ .
Rel
(R,∈,S)˜: a model of B
SLL
Bounded exponential: J•A = {u ∈ R
fhAi | Σ
a∈Au(a)˜ ∈J}
projection and injection:: π
J,A= ι
J,A= {(u, u) | u ∈ J•A}
Since !A = RhAi, we have that i•A ⊆!A
Some examples
R S ∈ ˜ 0•A 1•A
( B ool, id ) {(0, 0)} ∪ {(n + 1, 1)} {[]} M
f(A)−{[]}
( B ool, 0≤1) {(0, 0)} ∪ {(n, 1)} {[]} M
f(A) ( B ool, 1≤0) {(n, 0), (n+1, 1)} M
f(A) M
f(A)−{[]}
( B ool, id ) R × B ool − {(0, 1), (1, 0)} M
f(A)−{[a]} M
f(A)−{[]}
N ( Z /2 Z , id ) {(2n, 0), (2n+1, 1)} even size odd size ( N , id ) {(n, n) | n ∈ N } n•A = {[a
1, ..., a
n]}
( N , ≤
N) {(m, n) | m ≤ n} n•A = {[a
1, ..., a
m] | m ≤ n}
( ¯ N , ≤
N¯) {(m, n) | m ≤ n} n•A : idem ω•A = M
f(A)
(P
∗( N ), ⊆) {(n, U ) | n ∈ U } U•A = {[a
1, ..., a
n] | n ∈ U }
The semiring M f ( M )
M
f( M )
Given a monoid M , M
f( M ) is a semiring with:
•
A commutative sum:
(f +g )(x ) = f (x)+g (x)
•
A product (Dirichlet convolution):
(f ·g )(x) = X
x=yy,z·z
f (y)·g (z )
Example of such semirings
•
N = M
f( B ool)
•
Ghica’s M
f(Aff
1c)
•
P oly = M
f( N
+)
M
f( M ) has multiplicities M
f(S
∗) refines S
[K
1, ..., K
n] ˜ ∈
SJ iff Σ
iK
i≤ J
The two level of semirings
R: semantic semiring
•
R represent the actual resources.
•
0 : the absence of resources.
•
1 : the unitary amount of resources.
•
Any bag of resources can be separated and reformed
S : syntactical semiring
•
S represent information on resources.
•
0: you may not have resources.
•
Sames goes for 1.
•
≤
Sis the accuracy of the information.
S as a quotient
With R = M
f(S
∗) where you forgot
“paralleled history”.
S as non-determinism
S = (P
f(R), ⊆) can encode non deterministic operators.
S as a limit
S = (P (R), ⊆) or
S = R can encode
fixpoints.
Extensions
Does S have to be a semiring?
Remark: only 0 ∈J ˜ is necessary to perform weakening in J and 1 ∈J ˜ to perform dereliction.
One can replace 0 and 1 by sets Z and U such that:
•
if J ∈ Z then J +K ≥ K
•
if J ∈ U then J ∗ K ≥ K
•
if J ∈ Z then J ∗ K ∈ Z
Alex’s intersection type
[[J
1·A
1· · · J
n·A
n]] = {σ
iu
u∈![[A]] | ∀i ≤ n, u
i∈ [[J
i·A
i]]}
Where A is the simple type obtained by forgetting resource annotation in
any of the A
i.
Theorem and conclusion
General theorem
Any bounded logic B
SLL has as model REL
Mf(S),˜∈S,S. but it may has other more accurate relational models Current works:
•
Identifying the categorical sens of the relation ˜ ∈.
•
Investigate the Locals of 1.
•
Identifying the sens of the natural transformations ι and π.
•
Creating non degenerated models via double gluing.
•
Find models when S is a bimonoidal category and not a semiring.
•