towards a mathematical theory of substitutionmpf23/talks/ct2007.pdf · substitution aspects i...

61
Towards a Mathematical Theory of Substitution Marcelo Fiore Computer Laboratory University of Cambridge Invited talk at CT2007 20.VI.2007 /1

Upload: others

Post on 22-Mar-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Towards a

Mathematical Theory

of Substitution

Marcelo FioreComputer Laboratory

University of Cambridge

Invited talk at CT200720.VI.2007

/1

Page 2: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Substitution

Examples:

I Logic/algebra/rewriting.t [ u/x ] t [ u1/x1

, . . . ,un/xn]

I Type theory.T [ t/x ]

I Formal languages.w0X1w1 . . . Xnwn Xi 7→ Wi

_

��w0W1w1 . . . Wnwn

/2

Page 3: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

I Proof theory.

P1 · · · Pn

P

OP1

· · · OPn

_

��

OP1 · · ·

OPn

P

I Structural combinatorics.

• •

••

• ◦

◦◦

••

��???

????

??

• ••

••

••

/3

Page 4: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Substitution

Aspects

I syntactic vs. semantic modelsI homogeneous vs. heterogeneousI typed vs. untypedI variables vs. occurrences

I single vs. simultaneousI bindingI higher order

I algorithms

Plan

ANALYSE substitution from a foundationalstandpoint in a variety of scenarios andSYNTHESISE a mathematical theory.

/4

Page 5: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Substitution

Aspects

I syntactic vs. semantic modelsI homogeneous vs. heterogeneousI typed vs. untypedI variables vs. occurrences

I single vs. simultaneousI bindingI higher order

I algorithms

Plan

ANALYSE substitution from a foundationalstandpoint in a variety of scenarios andSYNTHESISE a mathematical theory.

/4-a

Page 6: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Algebraic theories

Clone of operations { Cn×(Cm)n → Cm | ··· }

≡Lawvere theories

≡Finitary monads

≡Monoids for the substitution tensor product

Substitution tensor product

on SetF

finite sets and functions↑

Endofin(Set) ' SetF

Id, ◦ ↔ V, •

V(n) = n

(X • Y)(n) =∫k∈F

X(k) × (Yn)k

/5

Page 7: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Algebraic theories

Clone of operations { Cn×(Cm)n → Cm | ··· }

≡Lawvere theories

≡Finitary monads

≡Monoids for the substitution tensor product

Substitution tensor product

on SetF

finite sets and functions↑

Endofin(Set) ' SetF

Id, ◦ ↔ V, •

V(n) = n

(X • Y)(n) =∫k∈F

X(k) × (Yn)k

/5-a

Page 8: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Cartesian mono-sortedsubstitution

monoid structure for the substitutiontensor product on Set

F

Examples:I Finitary algebraic syntax.

Σ = signature of operators with aritiesin N

Σ? = free monad on Σ(X) =∐

o∈Σ X|o|

SUBSTITUTION STRUCTURE:• n → Σ?(n)

• Σ?(n) × (Σ?m)n → Σ?(m)

NB: Arises from the universal propertyof Σ? by structural recursion (; correctsubstitution algorithm).

see e.g. [31]

/6

Page 9: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

I Lambda-calculus syntax.Λ(n) = { λ-terms with free variables in n }

with functorial action given by(capture-avoiding) variable renaming

x ∈ n

x ∈ Λ(n)

t1, t2 ∈ Λ(n)

t1(t2) ∈ Λ(n)

t ∈ Λ(n ] { x }

)

λx. t ∈ Λ(n)(†)

(†) SUBTLETY: α-equivalence

SUBSTITUTION STRUCTURE:• n → Λ(n)

• Λ(n) × (Λm)n → Λ(m)

t, (i 7→ ti)i∈n 7→ t [ ti/i ]i∈n

b� (capture-avoiding)

simultaneoussubstitution

/7

Page 10: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

I Lambda-calculus syntax.Λ(n) = { λ-terms with free variables in n }

with functorial action given by(capture-avoiding) variable renaming

x ∈ n

x ∈ Λ(n)

t1, t2 ∈ Λ(n)

t1(t2) ∈ Λ(n)

t ∈ Λ(n ] { x }

)

λx. t ∈ Λ(n)(†)

(†) SUBTLETY: α-equivalenceSUBSTITUTION STRUCTURE:• n → Λ(n)

• Λ(n) × (Λm)n → Λ(m)

t, (i 7→ ti)i∈n 7→ t [ ti/i ]i∈n

b� (capture-avoiding)

simultaneoussubstitution

/7-a

Page 11: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

I Clone of maps.The clone of maps 〈C,C〉 on an object C

in a cartesian category is given by

〈C,C〉(n) = [Cn, C]

SUBSTITUTION STRUCTURE:

• n // [Cn, C] : i 7→ πi

• [Cn, C] × [Cm, C]n // [Cm, C]

∼=LLLL

%%LLLLL

[Cn, C] × [Cm, Cn]

99rrrrrrrrrr

/8

Page 12: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

The substitution tensor product ...

free cartesian categoryon one generator

↑1 � � //

Y

,,

∼=

F◦ � � //

Y(−)

CCCC

C

!!CCC

CCC a

SetF

− •Y

||yyyyyyyyyyyyy

SetF

Lan∼=

〈Y,−〉

<<yyyyyyyyyyyyy

〈Y,Z〉(n) = [Yn,Z]

... is closed

/9

Page 13: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Algebraic theories in SetF

syntax with variable binding

Example: Σλ = { app : 2, abs : V } NB: V = y(1)

Then,

SetF

Σλ(X) = X2+XV

oo

and

(Σλ)?V = µX. V + X2 + XV ∼= Λ

see [16, 31]

NB:X2 → X ≡ { (Xn)2 → Xn | · · · }

XV → X ≡ {X(n + 1) → Xn | · · · }

��

�O�O

α-equivalence

F◦

(−)+1

��

� � //Set

F

a(−)×V��

F◦ � � //Set

F

(−)V = ((−)+1)∗

OO

/10

Page 14: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Algebraic theories in SetF

syntax with variable binding

Example: Σλ = { app : 2, abs : V } NB: V = y(1)

Then,

SetF

Σλ(X) = X2+XV

oo

and

(Σλ)?V = µX. V + X2 + XV ∼= Λ

see [16, 31]

NB:X2 → X ≡ { (Xn)2 → Xn | · · · }

XV → X ≡ {X(n + 1) → Xn | · · · }

��

�O�O

α-equivalence

F◦

(−)+1

��

� � //Set

F

a(−)×V��

F◦ � � //Set

F

(−)V = ((−)+1)∗

OO

/10-a

Page 15: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Algebraic theories in SetF

syntax with variable binding

Example: Σλ = { app : 2, abs : V } NB: V = y(1)

Then,

SetF

Σλ(X) = X2+XV

oo

and

(Σλ)?V = µX. V + X2 + XV ∼= Λ

see [16, 31]

NB:X2 → X ≡ { (Xn)2 → Xn | · · · }

XV → X ≡ {X(n + 1) → Xn | · · · }

��

�O�O

α-equivalence

F◦

(−)+1

��

� � //Set

F

a(−)×V��

F◦ � � //Set

F

(−)V = ((−)+1)∗

OO

/10-b

Page 16: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Λ is (universally characterised as) the freeΣλ-algebra on V

(†)

, and its substitution structureis derived by parameterised structural recursionas follows:

Σλ(Λ) • Λ

��

(‡)

// Σλ(Λ • Λ)Σλ(s) // Σλ(Λ)

��Λ • Λ

s // Λ

V • Λ

OO∼=ggggggggggggg

33ggggggggggggg

; correct (capture-avoiding) simultaneoussubstitution algorithm

see [16, 31]

(†) yields an induction principle see [19, 31]

(‡) SUBTLETY: pointed strength

!!capture avoidance

/11

Page 17: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Λ is (universally characterised as) the freeΣλ-algebra on V(†), and its substitution structureis derived by parameterised structural recursionas follows:

Σλ(Λ) • Λ

��

(‡) // Σλ(Λ • Λ)Σλ(s) // Σλ(Λ)

��Λ • Λ

s // Λ

V • Λ

OO∼=ggggggggggggg

33ggggggggggggg

; correct (capture-avoiding) simultaneoussubstitution algorithm

see [16, 31]

(†) yields an induction principle see [19, 31]

(‡) SUBTLETY: pointed strength

!!capture avoidance

/11-a

Page 18: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

General theorySETTING:

I/C

U��

CΣ 77

��

��a monoidal closed category

an endofunctor with a U-strength:

Σ(X) ⊗ YσX,(I→Y) // Σ(X ⊗ Y)

MODELS: (Σ, σ)-monoids.

ΣX

ξ

��an algebra

X ⊗ X m// X Ie

oo a monoidsuch that

Σ(X) ⊗ X

ξ⊗X

��

σX,e // Σ(X ⊗ X)Σm // ΣX

ξ

��X ⊗ X m

// X

/12

Page 19: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

General theorySETTING:

I/C

U��

CΣ 77

��

��a monoidal closed category

an endofunctor with a U-strength:

Σ(X) ⊗ YσX,(I→Y) // Σ(X ⊗ Y)

MODELS: (Σ, σ)-monoids.

ΣX

ξ

��an algebra

X ⊗ X m// X Ie

oo a monoidsuch that

Σ(X) ⊗ X

ξ⊗X

��

σX,e // Σ(X ⊗ X)Σm // ΣX

ξ

��X ⊗ X m

// X

/12-a

Page 20: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Thefree Σ-algebra and free monoid

constructionsΣ-alg(C )

//> Coo // Mon(C )>

oo

µX.C + ΣX C�oo � // µX. I + C ⊗ X

unify to(Σ, σ)-Mon(C )

��a

C

OO

S

XX

whereS(C) = µX. I + C ⊗ X + ΣX

NB: The initial (Σ, σ)-monoid has underlyingobject S0 = µX. I + ΣX = Σ?I.

see [26, 30]

/13

Page 21: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Initial-algebra semanticswith substitution

The unique (Σ, σ)-monoid homomorphismfrom the initial (Σ, σ)-monoid provides aninitial-algebra semantics that is bothcompositional and respects substitution.

see [16, 24]

/14

Page 22: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Example: Lambda calculus.For D C DD in a cartesian closed category,the clone of maps 〈D,D〉 has a canonicalΣλ-algebra structure

〈D,D〉 × 〈D,D〉 // 〈D,D〉

��〈D,D〉 × 〈D,DD〉 ∼= // 〈D,D × DD〉

OO

〈D,D〉V // 〈D,D〉

∼=HH

HH

$$HHH

H

〈D,DD〉

::vvvvvvvvv

making it into a Σλ-monoid for the canonicalpointed strength.The induced initial-algebra semantics amountsto the standard interpretation of the λ-calculus.

see [16, 19]

/15

Page 23: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Single-variable andsimultaneous substitution

The theory of monoids in SetF for the

substitution tensor product is enrichedalgebraic for the cartesian closedstructure.

MonV,•(SetF) is (equivalent to) the category of

algebras X with operations

XV+1 → X and 1 → XV

subject to

. . . 4 axioms . . .see [16]

/16

Page 24: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Second-order syntaxwith variable binding

and substitution

Example:

Σλ-Mon(SetF)

��a

SetF

OO

wwoooooooooooSλ

SS

SetN

g(−)77ooooooooooo a

For M ∈ SetN,

Sλ(M) ∼= V + M • Sλ(M) + Σλ(SλM)

see [22]

/17

Page 25: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Sλ(M) can be syntactically presented as follows:

x ∈ n

var(x) ∈ Sλ(M)(n)

t1, t2 ∈ Sλ(M)(n)

app(t1, t2) ∈ Sλ(M)(n)

t ∈ Sλ(M)(n ] { x }

)

abs((x)t

)∈ Sλ(M)(n)

(up to α-equivalence)

t1, . . . , tk ∈ Sλ(M)(n)

T [t1, . . . , tk] ∈ Sλ(M)(n)

(T ∈ M(k)

)

and the monoid multiplication structure

Sλ(M) • Sλ(M) → Sλ(M)

amounts to (capture-avoiding) simultaneoussubstitution. see [31]

/18

Page 26: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

MOREOVER, the action of Sλ enriches over SetF

with respect to its cartesian closed structure,and we obtain a further substitution structure

Sλ(M) × (SλN)fM → Sλ(N)

that amounts to SECOND-ORDER SUBSTITUTIONfor metavariables.

As usual, this arises by universal properties andis given by parameterised structural recursion;yielding a correct substitution algorithm.

see [31]

/19

Page 27: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Many-sorted contexts

For S a set of sorts, let F[S] be the freecocartesian category on S.

The substitution tensor product on(Set

F[S])S is

given as follows:

S

X

������

����

X •Y

qq

S� � //

Y++

∼=

F[S]◦ � � //

Y#

DDD

""DDD

DD

SetF[S]

def− •Y

||xxxxxxxxxx

SetF[S]

Lan∼=

That is,

(X • Y)σ(Γ) =

∫∆∈F[S]

Xσ(∆) ×∏

τ∈∆

Yτ(Γ)

see [19, 23, 24, 26]

/20

Page 28: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Simply typed lambda calculus,

algebraically

Let T be a set of base types, and let T be itsclosure under 1, *, =>.Consider

Σ ??(Set

F[T ])T

induced by

(†) app(σ,τ) : (σ=>τ, σ) → τ

(‡) abs(σ,τ) :((σ)τ

)→ σ=>τ

proj1(σ,τ) : (σ, τ) → σ , proj2(σ,τ) : (σ, τ) → τ

pair(σ,τ) : (σ, τ) → σ*τ

ter : () → 1

(†) Xσ=>τ × Xσ → Xτ

(‡) XτVσ → Xσ=>τ

see [19, 23]

/21

Page 29: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Furthermore, let CC be the following equationaltheory for Σ-monoids:

(β) F : [σ]τ, T : [ ]σ

` app(abs

((x : σ)F[var(x)]

), T [ ]

)

=

F [T [ ]] : τ

(η) F : [ ](σ=>τ)

` abs((x : σ)app

(F[ ], var(x)

))

=

F[ ] : σ=>τ

informally:(λx. F)T = F [ T/x ]

λx. Fx = F(x 6∈ FV(F)

)

/22

Page 30: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Furthermore, let CC be the following equationaltheory for Σ-monoids:

(β) F : [σ]τ, T : [ ]σ

` app(abs

((x : σ)F[var(x)]

), T [ ]

)

=

F [T [ ]] : τ

(η) F : [ ](σ=>τ)

` abs((x : σ)app

(F[ ], var(x)

))

=

F[ ] : σ=>τ

informally:(λx. F)T = F [ T/x ]

λx. Fx = F(x 6∈ FV(F)

)

/22-a

Page 31: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

(proj) M : [ ]σ,N : [ ]τ

` proj1(M[ ],N[ ]) = M[ ] : σ

` proj2(M[ ],N[ ]) = N[ ] : τ

(pair) T : [ ](σ*τ)

` pair(proj1(T [ ]), proj2(T [ ])

)

=

T [ ] : σ*τ

(ter) T : [ ]1 ` T [ ] = ter : 1

/23

Page 32: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Then

Γ -alg

��

(†)

77ooooooooooooo

77oooooooooooooΣ-Mon/CC ⊥� �

eq// Σ-Mon

oo

%%KKKKKKKKKK

a

(Set

F[T ])T

eeKKKKKKKKKK

and the Lawvere theory associated to the initialΣ-Mon/CC is the free cartesian closed categoryon T .

(†) induced by CC

[NB: This generalises to free cartesian closedcategories on small categories.]

/24

Page 33: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

(†)Example: The parallel pair induced by (β).

For N[X] =∐

n∈NXn, let M ∈

(Set

N[T ])T bedefined from the context of (β) as

Mτ(σ) = { F } , Mσ() = { T }

and empty otherwise.The terms of (β) correspond to global elements

1 −→ S(M)

that induce functorsΣ-Mon ' S-alg −→ (−)

fM-alg

over(Set

F[T ])T as follows

S(X)

��X

7→

XfM

��

S(X)S(fM)

��S(X)1

��X

see [30]

/25

Page 34: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Dependent sorts

For a small category C, let FC ' (SetC◦

)fp bethe free finite colimit completion of C.

The substitution tensor product on (SetF C)C◦

is given as follows:

C◦

X

~~}}}}

}}}}

}

X •Y

qq

C◦ � � //

Y,,

∼=

(FC)◦ � � //

Y#

EEE

""EEE

EE

SetF C

def− •Y

||yyyyyyyyyy

SetF C

Lan∼=

That is,

(X • Y)C(Γ) =

∫∆∈F C

XC(∆) × limD∈El(∆)

Yp∆D(Γ)

/26

Page 35: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

PROGRAMME

The various developments of the previousslides carry over to this more general setting.

Following Makkai [13], after Lawvere [9] andOtto [11], the syntactic theory is consideredfor simple categories (= skeletal and one-way,with finite fan-out).

This amounts to extending the theory toincorporate DEPENDENT SORTS.

NB: The limit in the substitution tensor productaccounts for the heavy dependency required inthe substitution operation.

see [26]

/27

Page 36: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

General theory : Idea

For T a 2-monad on CAT, consider

C

X

������

����

X •Y

qq

C //

Y,,

I

))

∼=

TC� � //

Y#

????

��???

?

TC

def− •Y

������

����

TC

Lan∼=

!!equipped with a T -algebra structure

Examples:

I T = identity

I T = free cartesian completion

I T = free finite limit completion

/28

Page 37: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

I T = free monoidal completion

I T = free symmetric monoidalcompletion

xx

the T -algebra structure on TC

is given by Day’s tensor product [2, 7]

&&

planar(I, •)-monoids =

symmetric

operads

see e.g. [3, 15, 20]

QUESTION: Are there applications of theprevious theory to the theory of operads!?

/29

Page 38: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

I T = free monoidal completion

I T = free symmetric monoidalcompletion

xx

the T -algebra structure on TC

is given by Day’s tensor product [2, 7]

&&

planar(I, •)-monoids =

symmetric

operads

see e.g. [3, 15, 20]

QUESTION: Are there applications of theprevious theory to the theory of operads!?

/29-a

Page 39: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

More generally :

From substitution to composition

For (T, η, µ) a 2-monad on CAT, considerA

F

������

����

F •G

qq

BηB //

G,,

IB

))

∼=

TB� � yB //

G#

AAAA

AAA

AA

TB

def− •G

��~~~~

~~~~

~

TC

Lan∼=

with respect to T -algebra structures

τC : T(TC

)→ TC

such thatyC : (TC, µC) → (TC, τC)

andLanyX

(h) : (TC, τC) → (TD, τD)

for all h : (TC, µC) → (TD, τD)

NB: The above can be axiomatised further.[Hyland, Gambino, Fiore]

(see also [24])

/30

Page 40: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Kleisli bicategory

TC�_ // B TB

�_ // A

TC�_ // A

I T = identity; profunctors

I T = free symmetric monoidal completion; JOYAL SPECIES OF STRUCTURES[6, 8] arise

as the endomorphisms of 1; GENERALISED SPECIES OF STRUCTURES

(†)

see [23, 25]

Coherence (idea):

Lany((Lany H#)G

)#

∼= Lany((Lany H#)G#

)

∼= (Lany H#) (Lany G#)

(†) The coherence isomorphisms can also be given formally (compare [3])

in a theory of Lawvere’s generalized logic [4], providing a logical view ofcoherence. The coherence laws can be then established elementwise.

PROGRAMME: Extend generalized logic to a type theory within whichthe coherence laws may be also established formally.

/31

Page 41: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Kleisli bicategory

TC�_ // B TB

�_ // A

TC�_ // A

I T = identity; profunctors

I T = free symmetric monoidal completion; JOYAL SPECIES OF STRUCTURES[6, 8] arise

as the endomorphisms of 1; GENERALISED SPECIES OF STRUCTURES(†)

see [23, 25]

Coherence (idea):

Lany((Lany H#)G

)#

∼= Lany((Lany H#)G#

)

∼= (Lany H#) (Lany G#)

(†) The coherence isomorphisms can also be given formally (compare [3])

in a theory of Lawvere’s generalized logic [4], providing a logical view ofcoherence. The coherence laws can be then established elementwise.

PROGRAMME: Extend generalized logic to a type theory within whichthe coherence laws may be also established formally.

/31-a

Page 42: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Linear modelsSubstitution operations on

linear species[6]

finite linear orders and monotone bijections↑

For X, Y ∈ SetL with Y(∅) = ∅:

1. (X • Y)(L) =∑

P∈LinPart(L)

X(P) ×∏

`∈P

Y(`)

; composition of ordinary generating series [Joyal]see [6]

2. (X • Y)(L) =∑

P∈Part(L)

X(P) ×∏

`∈P

Y(`)

; composition of exponential generating series [Foata]see [1, 14]

/32

Page 43: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Substitution tensor productson linear species

For X, Y ∈ SetL:

1. (X • Y)(`)

=

∫P∈LX(P) ×

∫ `p(p∈P) ∏

p∈P

Y(`p) × L(⊕p∈P `p, `)

arises from the general theory for T thefree monoidal completion, noting that L is(equivalent to) the free monoidal categoryon one object.

2. (X • Y)(`)

=

∫ P∈L

X(P) ×

∫ `p(p∈P)∏

p∈P

Y(`p) × Monbij( ∨

p∈P

`p, `)

where∨

p∈P `p has underlying set⊎

p∈P `p

ordered by (p, x) ≤ (p ′, x ′) iff either p = p ′

and x ≤ x ′, or p < p ′ and x = min(`p) andx ′ = min(`p ′).

; GENERALISED LINEAR SPECIES OF STRUCTURES

/33

Page 44: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Substitution tensor productson linear species

For X, Y ∈ SetL:

1. (X • Y)(`)

=

∫P∈LX(P) ×

∫ `p(p∈P) ∏

p∈P

Y(`p) × L(⊕p∈P `p, `)

arises from the general theory for T thefree monoidal completion, noting that L is(equivalent to) the free monoidal categoryon one object.

2. (X • Y)(`)

=

∫ P∈L

X(P) ×

∫ `p(p∈P)∏

p∈P

Y(`p) × Monbij( ∨

p∈P

`p, `)

where∨

p∈P `p has underlying set⊎

p∈P `p

ordered by (p, x) ≤ (p ′, x ′) iff either p = p ′

and x ≤ x ′, or p < p ′ and x = min(`p) andx ′ = min(`p ′).

; GENERALISED LINEAR SPECIES OF STRUCTURES

/33-a

Page 45: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Mixed models

Example: DILL = Dual Intuitionistic Linear Logicsee [12]

Γ ;∆ ` t : τ

ppintuitionistic(cartesian)

context

// linear(symmetric monoidal)

context

CUT RULE:

x1 : σ1, . . . , xm : σm ; y1 : τ1, . . . , yn : τn ` t : α

Γ ; −−− ` ui : σi (1 ≤ i ≤ m)

Γ ;∆j ` vj : τj (1 ≤ j ≤ n)

Γ ;∆1, . . . , ∆n ` t [ ui/xi,vj/yj

]1≤i≤m,1≤j≤n : α

I NEW FEATURE absent in mathematical examples

/34

Page 46: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

MATHEMATICAL MODEL

The category of (mono-sorted) mixed contexts Mis the free symmetric monoidal category over thefollowing symmetric monoidal theory:

0

������

L // I I ⊕ Ioo

a commutativemonoid

weakening& contractionlinear variables canbecome intuitionistictype theoretically:

Γ ; x,∆ ` t

Γ, x ; ∆ ` t

/35

Page 47: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

CONTEXT INDEXING

In fact

1

M F? _oo

??�����// F × F in Cat

;C����M

&&MMMMMMMMMMMM

��===

==== +3

+

��M F? _oo��

;C����

induces

M ◦ M //Cat

;C����M

· · · ⊕ L ⊕ · · · ⊕ I ⊕ · · · � // . . . × M × . . . × F × . . .

↓M

/36

Page 48: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

CONTEXT INDEXING

In fact

1

M F? _oo

??�����// F × F in Cat ;C

����M&&MMMMMMMMMMMM

��===

==== +3

+

��M F? _oo��

;C����

induces

M ◦ M //Cat ;C

����M

· · · ⊕ L ⊕ · · · ⊕ I ⊕ · · · � // . . . × M × . . . × F × . . .↓M

/36-a

Page 49: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Mixed substitution tensor product

For X, Y ∈ SetM:

(X • Y)(D)

=

∫C∈MX(C) ×

∫∆∈M(C) ∏

i∈|C|

Y(∆i) × M(⊕C(∆),D

)

NEW FEATURE

M(C)

⊕C��

M

I Monoids = Mixed operadsgeneralise and combine Lawveretheories and (symmetric) operads

I A combinatorial model of DILL. . . and more

/37

Page 50: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

A unifying framework

C

D +3

zzuuuuuuuuuuuu

C

��

S //Cat

C(−)

wwCat ;C����C dom

// Cat

contexts shapes

ΣΓ ��C

DΓ : CΓ → CSΓ

I Substitution tensor product ?

For X, Y ∈ SetC◦ :

(X • Y)(C)

=

∫ Γ∈C

X(Γ) ×

∫∆∈CΓ (limi∈S∆

Y(DΓ∆)i

)× [ΣΓ∆,C]

/38

Page 51: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Further generalisations

D-sorted(

Cat ;C����D

)◦

C

D +3

zzuuuuuuuuuuuu

C

��

S //Cat

C(−)

uuCat ;C����C

′ dom// Cat

ΣΓ ��C

C� � // C ′

<<zzzzzzzzzzzzzz ��

SΓσΓ��

D

I Substitution tensor product ?For X, Y ∈

(Set

C◦)D:

(X • Y)τ(C)

=

∫ Γ∈C

Xτ(Γ) ×

∫∆∈CΓ (limi∈S∆

Yσ∆(i)(DΓ∆)i

)× [ΣΓ∆,C]

/39

Page 52: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

PROGRAMME

Obtain a substitution tensor product from(cartesian (compare [5, 10])) monad structure on

S(X) = S ;C����X

NB: eS(1) ∼= C

induced by structure on C.

/40

Page 53: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Developments

I Mathematical theory of substitution� typed vs. untyped� homogeneous vs. heterogeneoussee [18]

� single variable vs. simultaneoussubstitution

� cartesian, linear, mixed, etc. substitution� specification and algorithms� syntax and semantics

I Reduction of type theory to algebra� admissibility of cut� second-order theories� dependent sorts

/41

Page 54: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

I Equational and inequational theories� free constructions� modularity� rewriting

I Structural combinatorics� Generalised species

− cartesian closed− differentialsee [23]

structure

� Groupoids and generalised analyticfunctorssee [27]

I Profunctors� Groupoids and strong (= †) compact

closuresee [28]

� Annihilation/creation operatorssee [28, 32] (and also [17, 29])

/42

Page 55: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Programme

I Categories of contexts as free monoidaltheories

I Comparison with/extension to Kelly’sclubs[5, 10]

I Generalized logic type-theoretically andcoherence

I Extraction of syntactic theory from modeltheory

I Applications� Theory of operads� Combinatorics� Domain Theorysee [27]

/43

Page 56: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

References

[1] P. Cartier and D. Foata. Problemes Combinatoiresde Commutation et de Rearrangements. LectureNotes in Mathematics, vol. 85, 1969.

[2] B.J. Day. On closed categories of functors. LectureNotes in Mathematics, vol. 137, pages 1–38, 1970.

[3] G.M. Kelly. On the operads of J.P. May. Manuscript,1972. (Reprints in Theory and Applications ofCategories, No. 13, pages 1-13, 2005.)

[4] F.W. Lawvere. Metric spaces, generalized logic andclosed categories. Rendiconti del SeminarioMatematico e Fisico di Milano, vol. XLIII,pages 135–166, 1973. (Reprints in Theory andApplications of Categories, No. 1, pages 1-37, 2002.)

[5] G.M. Kelly. On clubs and doctrines. In CategorySeminar, Lecture Notes in Mathematics, vol. 420,pages 181–256, 1974.

[6] A. Joyal. Une theorie combinatoire des seriesformelles. Advances in Mathematics, vol. 42,pages 1–82, 1981.

/44

Page 57: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

[7] G.B. Im and G.M. Kelly. A universal property of theconvolution monoidal structure. Journal of Pure andApplied Algebra, vol. 43, pages 75–88, 1986.

[8] A. Joyal. Foncteurs analytiques et especes destructures, Combinatoire enumerative, Lecture Notesin Mathematics, vol. 1234, pages 126–159, 1986.

[9] F.W. Lawvere. More on graphic toposes. Cah. deTop. et Geom. Diff, vol. 32, pages 5–10, 1991.

[10] G.M. Kelly. On clubs and data-type constructors. InApplications of Categories in Computer Science,London Mathematical Society Lecture Note Series,vol. 177, 1992.

[11] J. Otto. Complexity doctrines. Ph.D. thesis,Department of Mathematics and Statistics, McGillUniversity, Montreal, 1995.

[12] A. Barber. Dual Intuitionistic Linear Logic. Technicalreport ECS-LFCS-96-347, University of Edinburgh,School of Informatics, 1996.

[13] M. Makkai. First order logic with dependent sorts,with applications to category theory. Manuscript,1997. (Available from〈http://www.math.mcgill.ca/∼makkai/〉.)

/45

Page 58: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

[14] F. Bergeron, G. Labelle, and P. Leroux.Combinatorial Species and Tree-Like Structures.Encyclopedia of Mathematics, vol. 67. CambridgeUniversity Press, 1998.

[15] J. Baez and J. Dolan. Higher-dimensional algebra III:n-categories and the algebra of opetopes. Advancesin Mathematics, vol. 135, pages 145–206, 1998.

[16] M. Fiore, G. Plotkin and D. Turi. Abstract syntax andvariable binding. In Proceedings of the 14th AnnualIEEE Symposium on Logic in ComputerScience (LICS’99), pages 193–202, 1999.

[17] J. Baez and J. Dolan. From finite sets to Feynmandiagrams. Mathematics unlimited - 2001 andbeyond, 2001.

[18] M. Fiore and D. Turi. Semantics of name and valuepassing. In Proceedings of the 16th Annual IEEESymposium on Logic in ComputerScience (LICS’01), pages 93–104, 2001.

[19] M. Fiore. Semantic analysis of normalisation byevaluation for typed lambda calculus. In Proceedingsof the 4th International Conference on Principles andPractice of Declarative Programming (PPDP 2002),pages 26–37, 2002.

/46

Page 59: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

[20] B.J. Day and R. Street. Lax monoids,pseudo-operads, and convolution. In DiagrammaticMorphisms and Applications, ContemporaryMathematics, vol. 318, pages 75–96, 2003.

[21] G.L. Cattani and G. Winskel. Profunctors, openmaps and bisimulation. Mathematical Structuresin Computer Science, Vol. 15, Issue 03,pages 553–614, 2005.

[22] M. Hamana. Free Σ-monoids: A higher-order syntaxwith metavariables. In Proceedings of the 2nd AsianSymposium on Programming Languages andSystems (APLAS 2004), Lecture Notes in ComputerScience, vol. 3202, pages 348–363, 2005.

[23] M. Fiore. Mathematical models of computationaland combinatorial structures. Invited address forFoundations of Software Science and ComputationStructures (FOSSACS 2005) at the European JointConferences on Theory and Practice of Software(ETAPS), Lecture Notes in Computer Science,vol. 3441, pages 25-46, 2005.

[24] J. Power and M. Tanaka. A unified category-theoreticformulation of typed binding signatures. InProceedings of the 3rd ACM SIGPLAN workshop on

/47

Page 60: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Mechanized reasoning about languages withvariable binding, pages 13–24, 2005.

[25] M. Fiore, N. Gambino, M. Hyland and G. Winskel.The cartesian closed bicategory of generalisedspecies of structures. To appear in the Journal ofthe London Mathematical Society. (Available from〈http://www.cl.cam.ac.uk/∼mpf23/〉.)

[26] M. Fiore. On the structure of substitution. Invitedaddress for the 22nd Mathematical Foundations ofProgramming Semantics Conference (MFPS XXII),DISI, University of Genova, 2006. (Available from〈http://www.cl.cam.ac.uk/∼mpf23/〉.)

[27] M. Fiore. Analytic functors and domain theory.Invited talk at the Symposium for Gordon Plotkin,LFCS, University of Edinburgh, 2006. (Availablefrom 〈http://www.cl.cam.ac.uk/∼mpf23/〉.)

[28] M. Fiore. Adjoints and Fock space in the contextof profunctors. Talk given at the Cats, Kets andCloisters Workshop (CKC in OXFORD), ComputingLaboratory, Oxford University, 2006. (Availablefrom 〈http://www.cl.cam.ac.uk/∼mpf23/〉.)

[29] J. Morton. Categorified algebra and quantummechanics. Theory and Applications of Categories,

/48

Page 61: Towards a Mathematical Theory of Substitutionmpf23/talks/CT2007.pdf · Substitution Aspects I syntactic vs. semantic models I homogeneous vs. heterogeneous I typed vs. untyped I variables

Vol. 16, No. 29, pages 785–854, 2006.

[30] M. Fiore and C.-K. Hur. Equational systems andfree constructions. In International Colloquium onAutomata, Language and Programming (ICALP2007), Lecture Notes in Computer Science,vol. 4596, pages 607-619, 2007.

[31] M. Fiore. A mathematical theory of substitution andits applications to syntax and semantics. Invitedtutorial for the Workshop on Mathematical Theoriesof Abstraction, Substitution and Naming in ComputerScience, International Centre for MathematicalSciences (ICMS), Edinburgh, 2007.

[32] M. Fiore. An axiomatics and a combinatorial modelof creation/annihilation operators and differentialstructure. Invited talk at the Categorical QuantumLogic Workshop (CQL), Computing Laboratory,Oxford University, 2007. (Available from〈http://www.cl.cam.ac.uk/∼mpf23/〉.)

/49