SlideShare a Scribd company logo
0/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
Categorical Semantics for Explicit Substitutions
Valeria de Paiva
XIII Summer Workshop in Mathematics
University of Brasilia
(joint work with Eike Ritter and Neil Ghani)
11 February 2021
0 / 31
1/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
Thanks for the invitation, Dani
1 / 31
2/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
... and Jaqueline!
2 / 31
3/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
The Topos Institute
3 / 31
4/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
Applied perspective: CAM (categorical abstract machine)
4 / 31
5/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
xSLAM: eXplicit Substitutions Linear Abstract Machine
Ritter’s PhD thesis on categorical combinators for the
Calculus of Constructions (Cambridge 1992, TCS 1994)
de Paiva’s PhD thesis on models of Linear Logic & linear
lambda-calculus (Cambridge 1991)
Put the two together for Categorical Abstract Machines for
Linear Functional Programming
Project xSLAM Explicit Substitutions for Linear Abstract
Machines (EPSRC 1997-2000)
5 / 31
6/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
xSLAM: eXplicit Substitutions Linear Abstract Machine
Twenty years later
More than 10 papers submitted to conferences
Only two in journals: Linear Explicit Substitutions. (Ghani, de
Paiva, Ritter, 2000) and Relating Categorical Semantics for
Intuitionistic Linear Logic (Maneggia, Maietti, de Paiva, Ritter
2005)
Master’s thesis: An Abstract Machine based on Linear Logic
and Explicit Substitutions. Francisco Alberti, 1997
Two international workshops: Logical Abstract Machines
(Saarbruecken, 1998), Logical Abstract Machines
(Birmingham, 1999)
An international meeting at Dagstuhl: Linear Logic and
Applications (1999)
6 / 31
7/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
xSLAM Project Work
1 E. Ritter. A calculus for Resource allocation. Technical Report, University of Birmingham, 2000.
2 Maietti, de Paiva, Ritter. Linear primitive recursion. manuscript 2000.
3 Maietti, de Paiva, Ritter. Categorical Models for Intuitionistic and Linear Type Theory. FoSSaCS 2000.
4 Cervesato, de Paiva, Ritter. Explicit Substitutions for Linear Logical Frameworks. LFM 1999
5 E. Ritter. Characterising Explicit Substitutions which Preserve Termination. TLCA 1999
6 Ghani, de Paiva, Ritter. Explicit Substitutions for Constructive Necessity. ICALP 1998
7 Ghani, de Paiva, Ritter. Categorical Models for Explicit Substitutions. FoSSaCS 1999.
8 de Paiva, E. Ritter. On Explicit Substitutions and Names. ICALP 1997.
9 Nesi, de Paiva, Ritter. Rewriting Properties of Combinators for Intuitionistic Linear Logic. Higher Order
Algebra, Logic and Term Rewriting, HOA’1993.
10 Maietti, de Paiva and Ritter. Normalization Bounds in Rudimentary Linear Logic ICC, 2002.
11 de Paiva and Eike Ritter. Variations on Linear PCF. WESTAPP, 1999.
7 / 31
8/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
Twenty years later
time to try again?
8 / 31
9/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
Categorical Models for what?
Explicit substitutions
In computer science, lambda calculi are said to have expli-
cit substitutions if they pay special attention to the forma-
lization of the process of substitution. This is in contrast
to the standard lambda calculus where substitutions are
performed by beta reductions in an implicit manner which
is not expressed within the calculus.
The concept of explicit substitutions has become notorious
(despite a large number of published calculi of explicit
substitutions in the literature with quite di↵erent characteristics)
because the notion often turns up (implicitly and explicitly) in
formal descriptions [...] Wikipedia, Feb 2021
Syntactic calculi, plenty of them. No models?
9 / 31
10/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
The cat amongst the pigeons
10 / 31
11/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
What you will NOT see in this talk
Intersection types (idempotent or not)
Evaluation strategies
Dynamic types
Patterns
Proof-nets
Nominal syntax
Geometry of Interaction
explicit substitutions reductions
11 / 31
12/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
Why Categorical Semantics?
Any syntactic calculus worth our attention will have a
categorical semantics
Mathematics as a source of intuition
Showing this for IPL and ILL (works for CS4⇤ too) 12 / 31
13/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
What is a functional language?
Idea: Program as mathematical function transforming inputs into
outputs
Work on inductively defined data structures like lists, trees
) no side e↵ects
) can employ mathematical reasoning and substitute equals for
equals
) function definition and application central part of languages like
ML, Haskell, CAML, OCAML
(usually) Have strong typechecking
) can detect many errors already at compile-time
13 / 31
14/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
Prototypical language -calculus
Terms:
M ::= x | x : A.M | MM
Types:
A ::= G | A ! A
Meaning of terms:
x: Variable (placeholder)
x : A.M: Function expecting input of type A
MM: Function application
Single out well-formed terms (check whether correct kind of
argument supplied)
14 / 31
15/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
Lambda calculus
Judgements ` M : A
, x : A ` x : A
, x : A ` M : B
` x : A.M : A ! B
` M : A ! B ` N : A
` MN : B
To obtain a Turing-complete language, add recursively defined
functions via letrec and add means for defining inductively
defined data structures like lists, trees, etc
Computation done via -reduction
( x : A.M)N M[N/x]
where M[N/x] is M with x replaced by N
15 / 31
16/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
Environment machines
Implementing reduction efficiently is very hard
Traditional solution:
Reduce -terms in an environment
storing bindings of terms for variables separately
) have two kinds of expressions:
Environments hMi /xi i: lists of bindings
Terms: as before plus new closures f ⇤ M
Modified -reduction stores substitution in the environment
( x.t)u ) hu/xi ⇤ t
New rewrite rules to eliminate substitutions
hu/xi ⇤ t )⇤ t[u/x]
Transforming this ‘trick’ of implementation into a logical calculus
) the reason for ‘explicit substitutions’
16 / 31
17/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
The -Calculus (Abadi, Curien, Lévy 1991)
Term constructs:
Terms of the -calculus +
Application of a substitution to a term: f ⇤ t
Start substitution: hi
Parallel and sequential composition: hf , t/xi, f ; g
Typing Rules:
Substitutions are judgements ` f :
0 ✓
` hi : 0
` f : ` t :A
` hf , t/xi : , x : A
` f : ` t : A
` f ⇤ t : A
` f : ` g :
` f ; g :
Key Idea 1: Every -term is equivalent to a -term.
Key Idea 2: Contexts z :A⇥B and x :A, y :B are not equal 17 / 31
18/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
Kesner Summing-up ES (2009)
All explicit substitutions (ES): decomposing implicit
substitutions into atomic steps allows a better understanding
of the execution models of higher-order languages;
-calculus with ES: incorporate substitution operators into the
language, and transforms the equalities of the specification
into a set of rewriting rules;
composition of substitution allows more sophisticated
interactions;
-calculi with ES can be defined either with unary or n-ary
substitutions, by using de Bruijn notation or levels or nominal
logic, or combinators, or director strings or by named variables;
a calculus with ES can be also seen as a term notation for a
logical system where the reduction rules behave like cut
elimination transformations;
Mellies counter-example 1995 shows ‘a flaw in the design of
ES calculi since they are supposed to implement their
underlying calculus (in our case the -calculus) without losing
its good properties’
18 / 31
19/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
Kesner ES (2009)
ways to avoid Mellies counter-example in order to recover the
SN property;
one solution: weak lambda calculi, not good for proof
assistants;
another: terms with explicit weakening constructors;
Her way: a perpetual reduction strategy and normalisation of
“Implicit substitution implies normalisation of Explicit
substitution”IE property;
This extends ideas in [Kes07, Kes08], by the use of
intersection types as well as the use of the Z-property of van
Oostrom [vO] to show confluence.
19 / 31
20/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
What do we want from a Categorical Semantics?
Motivation: What should calculi of explicit substitutions
contain?
What term constructs should we require
What equations should we require
how to discover this for di↵erent logics
Methodology: Extend the Curry Howard correspondence
Category theory as syntax debugging
Internal language gives term constructs & equational theory
Key Ideas:
A model should contain a model of the underlying -calculus
Contexts z :A⇥B and x :A, y :B are isomorphic
20 / 31
21/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
Intuitions from Mathematics
21 / 31
22/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
Models of Explicit Substitutions — Indexed Categories
Contexts: Modelled by a cartesian category
Objects are contexts, morphisms are substitutions
Cartesian structure is given by parallel composition
Terms: For every context , define the category D( )
Objects are variable-type pairs x : A
Morphisms (x : A) ! (y : B) are judgements , x : A ` t : B
Re-indexing: ` f : induces a functor D(f ):D( ) ! D( )
Summary: An indexed category is a functor D : Cop ! Cat
22 / 31
23/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
What’s Wrong with Indexed Categories?
Plus Points: Indexed categories induce -equations
hi; h = h Identity of C
h; hi = h Identity of C
hi ⇤ t = t Functoriality of D
(f ; g); h = f ; (g; h) Assoc of C-comp
(f ; g) ⇤ t = f ⇤ (g ⇤ t) Functoriality of D
Lemma: Soundness and completeness
Problem 1: Indexed Categories are inherently non linear
Identities in the fibres require judgements , x : A ` x : A
Problem 2: No syntax for forming substitutions from terms
23 / 31
24/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
Context-Handling Categories
Solution 1: Remove identities by changing codomain to Set
Solution 2: Add two new natural transformations
Defn: Let B be a SMC (CCC) with T ✓ |B|. A linear
(cartesian) context handling category is a functor
L: Bop ! SetsT and for each type, natural isomorphisms
SubA : L( )A ) B( , A) TermA : B( , A) ) L( )A
Yoneda lemma: There exists VarA 2 L(A)A with
TermA(f ) = f ⇤ VarA
Equations: We get the following equations
h(f ⇤ t)/xi = f ; ht/xi Naturality of Sub
ht/xi ⇤ x = t One half of the iso
h(f ⇤ x)/xi = f Other half of the iso
24 / 31
25/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
Adding Type Structure — E-Categories
Context handling categories model the behaviour of explicit
substitutions, eg their formation and application to terms
Types: Since terms are defined on the fibres, modelling type
constructors requires extra structure on the fibres.
Examples: Given types A, B 2 T , there are types
A ! B, A ⇥ B 2 T . In addition there are isomorphisms,
natural in
E(( , A))B
E( )A!B
E( )A ⇥ E( )B
E( A⇥B
Naturality: Equations distribute explicit subs over terms
f ⇤ x.t = x.f ⇤ t f ⇤ (tu) = (f ⇤ t)(f ⇤ u)
Model Collapse: Contexts z :A⇥B and x :A, y :B are
isomorphic 25 / 31
26/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
Adding Linear Type Structure — L-Categories
Functions: As before, given types A, B 2 T , there is a type
A B 2 T and isomorphisms, natural in
E(( , A))B
E( )A B
Tensor: But the following doesn’t give an iso
z :A⌦B ⇠
= x :A, y :B
E(( , A, B))C
E( , A ⌦ B)C
Solution: Demand x :A, y :B ` h(x ⌦ y)/zi :A⌦B has an
inverse.
, x : A, y : B ` f :
, z : A ⌦ B ` let z be x ⌦ y in f :
Key Idea: Category theory guiding the design of the calculus 26 / 31
27/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
Modelling the !-type Constructor
Key Idea: !-arises as the comonad of a monoidal adjunction
between CCCs and SMCCs
Recall: Models of explicit substitutions
E categories model calculi with !, ⇥, 1 types
L categories model calculi with , ⌦, I types
Defn: A !L-category is a monoidal adjunction where C is an
E category, B is an L-category and F, G preserve types.
Crucially: Requires an isomorphism x : A| ⇠
= |z :!A
, x : A| ` f :
| , z :!A ` let z be !x in f :
27 / 31
28/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
Categorical Theorems
Please read the paper, but we have three theorems for E-categories
(CCCs), three for L-categories (SMCCs), two for putting the E-
and L-categories together into a !L-category.
(right defn) Every E-category contains an underlying CCC and
every CCC extends to an E-category, in an iso way;
(soundness) We can model the calculus in an E-category;
(completeness) If for every E-category, the interpretation of
two morphisms f , f 0 is the same, then the equality of the
morphisms is proved by the theory.
Similarly for L-categories.
For !L-categories, we use Barber’s DILL calculus with explicit
substitutions xDILL, described in Linear Explicit Substitutions
28 / 31
29/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
Conclusions
Indexed categories are inherently non linear so we use
presheaves
Explicit substitutions are tricky to model as extensionally they
are equivalent to their underlying -calculus
Our models reflect this by “taking the isomorphisms seriously”
We get a Curry-Howard correspondence justifying our calculus
Other possibilities: replace isomorphisms with
Identities — loose syntax for substitutions
Retracts — loose relationship with usual semantics
29 / 31
30/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
More Conclusions
Maybe more important to have models for explicit
substitutions than for linear ones?
Which fibrations? interesting ones?
Can we model patterns too?
other logics?
Can we say something about the others we skipped?
30 / 31
31/31
Motivation
Abstract Machines
Our Explicit substitutions
Categorical Semantics
Conclusions
Obrigada!
31 / 31

More Related Content

PDF
Categorical Explicit Substitutions
PDF
Dialectica Comonads
PDF
Constructive Modalities
PDF
Constructive Modalities
PDF
Dialectica Categories for the Lambek Calculus
PDF
Going Without: a modality and its role
PDF
Dialectica amongst friends
PDF
Modal Type Theory
Categorical Explicit Substitutions
Dialectica Comonads
Constructive Modalities
Constructive Modalities
Dialectica Categories for the Lambek Calculus
Going Without: a modality and its role
Dialectica amongst friends
Modal Type Theory

What's hot (20)

PDF
Intuitionistic Modal Logic: fifteen years later
PDF
A Dialectica Model of Relevant Type Theory
PDF
Constructive Modal and Linear Logics
PDF
Negation in the Ecumenical System
PDF
Categorical Semantics for Explicit Substitutions
PDF
Fun with Constructive Modalities
PDF
Going Without: a modality and its role
PDF
Pure Algebra to Applied AI: a personal journey
PDF
Relevant Dialectica Categories
PDF
Constructive Modal Logics, Once Again
PDF
Dialectica Categories for the Lambek Calculus
PDF
Intuitive Semantics for Full Intuitionistic Linear Logic (2014)
PDF
Benchmarking Linear Logic Proofs, Valeria de Paiva
PDF
Benchmarking Linear Logic Proofs
PDF
Dialectica Categories and Petri Nets
PDF
Going Without: a modality and its role
PDF
Dialectica Categories: the mathematical version
PDF
Logics of Context and Modal Type Theories
PDF
Dialectica Categories and Petri Nets
PDF
Dialectica Categories: the Relevant version, Valeria de Paiva
Intuitionistic Modal Logic: fifteen years later
A Dialectica Model of Relevant Type Theory
Constructive Modal and Linear Logics
Negation in the Ecumenical System
Categorical Semantics for Explicit Substitutions
Fun with Constructive Modalities
Going Without: a modality and its role
Pure Algebra to Applied AI: a personal journey
Relevant Dialectica Categories
Constructive Modal Logics, Once Again
Dialectica Categories for the Lambek Calculus
Intuitive Semantics for Full Intuitionistic Linear Logic (2014)
Benchmarking Linear Logic Proofs, Valeria de Paiva
Benchmarking Linear Logic Proofs
Dialectica Categories and Petri Nets
Going Without: a modality and its role
Dialectica Categories: the mathematical version
Logics of Context and Modal Type Theories
Dialectica Categories and Petri Nets
Dialectica Categories: the Relevant version, Valeria de Paiva
Ad

Similar to Categorical Semantics for Explicit Substitutions (20)

PDF
Towards a General Approach for Symbolic Model-Checker Prototyping
PDF
Weapons of Math Construction
PDF
Point-free foundation of Mathematics
PDF
Categorical Proof Theory for Everyone
PPTX
Programming in python
PPTX
Problems of function based syntax
PDF
Slides used during my thesis defense "Du typage vectoriel"
PDF
Cerutti--Knowledge Representation and Reasoning (postgrad seminar @ Universit...
PDF
20130928 automated theorem_proving_harrison
PDF
Logicrevo15
PDF
Writing a SAT solver as a hobby project
PPT
PDF
Theorem proving and the real numbers: overview and challenges
PDF
Edwardian Proofs as futuristic Programs for Personal Assistants
PDF
Compiling fµn language
PDF
Dragisa Zunic - Classical computing with explicit structural rules - the *X c...
PDF
Edwardian Proofs as Futuristic Programs
PDF
Learn a language : LISP
PPT
jelia2002-tutorial.ppt answer set programming
PDF
Cálculo lambda
Towards a General Approach for Symbolic Model-Checker Prototyping
Weapons of Math Construction
Point-free foundation of Mathematics
Categorical Proof Theory for Everyone
Programming in python
Problems of function based syntax
Slides used during my thesis defense "Du typage vectoriel"
Cerutti--Knowledge Representation and Reasoning (postgrad seminar @ Universit...
20130928 automated theorem_proving_harrison
Logicrevo15
Writing a SAT solver as a hobby project
Theorem proving and the real numbers: overview and challenges
Edwardian Proofs as futuristic Programs for Personal Assistants
Compiling fµn language
Dragisa Zunic - Classical computing with explicit structural rules - the *X c...
Edwardian Proofs as Futuristic Programs
Learn a language : LISP
jelia2002-tutorial.ppt answer set programming
Cálculo lambda
Ad

More from Valeria de Paiva (19)

PDF
Dialectica Comonoids
PDF
Dialectica Categorical Constructions
PDF
Logic & Representation 2021
PDF
Constructive Modal and Linear Logics
PDF
Dialectica Categories Revisited
PDF
PLN para Tod@s
PDF
Networked Mathematics: NLP tools for Better Science
PDF
Problemas de Kolmogorov-Veloso
PDF
Natural Language Inference: for Humans and Machines
PDF
Dialectica Petri Nets
PDF
The importance of Being Erneast: Open datasets in Portuguese
PDF
Semantics and Reasoning for NLP, AI and ACT
PDF
NLCS 2013 opening slides
PDF
Logic and Probabilistic Methods for Dialog
PDF
Dialectica and Kolmogorov Problems
PDF
Gender Gap in Computing 2014
PDF
Dialectica and Kolmogorov Problems
PDF
Linear Logic and Constructive Mathematics, after Shulman
PDF
A Semantica Nossa de Cada Dia
Dialectica Comonoids
Dialectica Categorical Constructions
Logic & Representation 2021
Constructive Modal and Linear Logics
Dialectica Categories Revisited
PLN para Tod@s
Networked Mathematics: NLP tools for Better Science
Problemas de Kolmogorov-Veloso
Natural Language Inference: for Humans and Machines
Dialectica Petri Nets
The importance of Being Erneast: Open datasets in Portuguese
Semantics and Reasoning for NLP, AI and ACT
NLCS 2013 opening slides
Logic and Probabilistic Methods for Dialog
Dialectica and Kolmogorov Problems
Gender Gap in Computing 2014
Dialectica and Kolmogorov Problems
Linear Logic and Constructive Mathematics, after Shulman
A Semantica Nossa de Cada Dia

Recently uploaded (20)

PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
737-MAX_SRG.pdf student reference guides
PPTX
Nature of X-rays, X- Ray Equipment, Fluoroscopy
PDF
Categorization of Factors Affecting Classification Algorithms Selection
PPT
Occupational Health and Safety Management System
PPTX
communication and presentation skills 01
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Information Storage and Retrieval Techniques Unit III
PPTX
Safety Seminar civil to be ensured for safe working.
PPT
introduction to datamining and warehousing
PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PDF
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
PPTX
Fundamentals of Mechanical Engineering.pptx
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PDF
Integrating Fractal Dimension and Time Series Analysis for Optimized Hyperspe...
PPT
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
737-MAX_SRG.pdf student reference guides
Nature of X-rays, X- Ray Equipment, Fluoroscopy
Categorization of Factors Affecting Classification Algorithms Selection
Occupational Health and Safety Management System
communication and presentation skills 01
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Information Storage and Retrieval Techniques Unit III
Safety Seminar civil to be ensured for safe working.
introduction to datamining and warehousing
Exploratory_Data_Analysis_Fundamentals.pdf
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
Fundamentals of Mechanical Engineering.pptx
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
Integrating Fractal Dimension and Time Series Analysis for Optimized Hyperspe...
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf

Categorical Semantics for Explicit Substitutions

  • 1. 0/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions Categorical Semantics for Explicit Substitutions Valeria de Paiva XIII Summer Workshop in Mathematics University of Brasilia (joint work with Eike Ritter and Neil Ghani) 11 February 2021 0 / 31
  • 2. 1/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions Thanks for the invitation, Dani 1 / 31
  • 3. 2/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions ... and Jaqueline! 2 / 31
  • 4. 3/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions The Topos Institute 3 / 31
  • 5. 4/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions Applied perspective: CAM (categorical abstract machine) 4 / 31
  • 6. 5/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions xSLAM: eXplicit Substitutions Linear Abstract Machine Ritter’s PhD thesis on categorical combinators for the Calculus of Constructions (Cambridge 1992, TCS 1994) de Paiva’s PhD thesis on models of Linear Logic & linear lambda-calculus (Cambridge 1991) Put the two together for Categorical Abstract Machines for Linear Functional Programming Project xSLAM Explicit Substitutions for Linear Abstract Machines (EPSRC 1997-2000) 5 / 31
  • 7. 6/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions xSLAM: eXplicit Substitutions Linear Abstract Machine Twenty years later More than 10 papers submitted to conferences Only two in journals: Linear Explicit Substitutions. (Ghani, de Paiva, Ritter, 2000) and Relating Categorical Semantics for Intuitionistic Linear Logic (Maneggia, Maietti, de Paiva, Ritter 2005) Master’s thesis: An Abstract Machine based on Linear Logic and Explicit Substitutions. Francisco Alberti, 1997 Two international workshops: Logical Abstract Machines (Saarbruecken, 1998), Logical Abstract Machines (Birmingham, 1999) An international meeting at Dagstuhl: Linear Logic and Applications (1999) 6 / 31
  • 8. 7/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions xSLAM Project Work 1 E. Ritter. A calculus for Resource allocation. Technical Report, University of Birmingham, 2000. 2 Maietti, de Paiva, Ritter. Linear primitive recursion. manuscript 2000. 3 Maietti, de Paiva, Ritter. Categorical Models for Intuitionistic and Linear Type Theory. FoSSaCS 2000. 4 Cervesato, de Paiva, Ritter. Explicit Substitutions for Linear Logical Frameworks. LFM 1999 5 E. Ritter. Characterising Explicit Substitutions which Preserve Termination. TLCA 1999 6 Ghani, de Paiva, Ritter. Explicit Substitutions for Constructive Necessity. ICALP 1998 7 Ghani, de Paiva, Ritter. Categorical Models for Explicit Substitutions. FoSSaCS 1999. 8 de Paiva, E. Ritter. On Explicit Substitutions and Names. ICALP 1997. 9 Nesi, de Paiva, Ritter. Rewriting Properties of Combinators for Intuitionistic Linear Logic. Higher Order Algebra, Logic and Term Rewriting, HOA’1993. 10 Maietti, de Paiva and Ritter. Normalization Bounds in Rudimentary Linear Logic ICC, 2002. 11 de Paiva and Eike Ritter. Variations on Linear PCF. WESTAPP, 1999. 7 / 31
  • 9. 8/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions Twenty years later time to try again? 8 / 31
  • 10. 9/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions Categorical Models for what? Explicit substitutions In computer science, lambda calculi are said to have expli- cit substitutions if they pay special attention to the forma- lization of the process of substitution. This is in contrast to the standard lambda calculus where substitutions are performed by beta reductions in an implicit manner which is not expressed within the calculus. The concept of explicit substitutions has become notorious (despite a large number of published calculi of explicit substitutions in the literature with quite di↵erent characteristics) because the notion often turns up (implicitly and explicitly) in formal descriptions [...] Wikipedia, Feb 2021 Syntactic calculi, plenty of them. No models? 9 / 31
  • 11. 10/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions The cat amongst the pigeons 10 / 31
  • 12. 11/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions What you will NOT see in this talk Intersection types (idempotent or not) Evaluation strategies Dynamic types Patterns Proof-nets Nominal syntax Geometry of Interaction explicit substitutions reductions 11 / 31
  • 13. 12/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions Why Categorical Semantics? Any syntactic calculus worth our attention will have a categorical semantics Mathematics as a source of intuition Showing this for IPL and ILL (works for CS4⇤ too) 12 / 31
  • 14. 13/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions What is a functional language? Idea: Program as mathematical function transforming inputs into outputs Work on inductively defined data structures like lists, trees ) no side e↵ects ) can employ mathematical reasoning and substitute equals for equals ) function definition and application central part of languages like ML, Haskell, CAML, OCAML (usually) Have strong typechecking ) can detect many errors already at compile-time 13 / 31
  • 15. 14/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions Prototypical language -calculus Terms: M ::= x | x : A.M | MM Types: A ::= G | A ! A Meaning of terms: x: Variable (placeholder) x : A.M: Function expecting input of type A MM: Function application Single out well-formed terms (check whether correct kind of argument supplied) 14 / 31
  • 16. 15/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions Lambda calculus Judgements ` M : A , x : A ` x : A , x : A ` M : B ` x : A.M : A ! B ` M : A ! B ` N : A ` MN : B To obtain a Turing-complete language, add recursively defined functions via letrec and add means for defining inductively defined data structures like lists, trees, etc Computation done via -reduction ( x : A.M)N M[N/x] where M[N/x] is M with x replaced by N 15 / 31
  • 17. 16/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions Environment machines Implementing reduction efficiently is very hard Traditional solution: Reduce -terms in an environment storing bindings of terms for variables separately ) have two kinds of expressions: Environments hMi /xi i: lists of bindings Terms: as before plus new closures f ⇤ M Modified -reduction stores substitution in the environment ( x.t)u ) hu/xi ⇤ t New rewrite rules to eliminate substitutions hu/xi ⇤ t )⇤ t[u/x] Transforming this ‘trick’ of implementation into a logical calculus ) the reason for ‘explicit substitutions’ 16 / 31
  • 18. 17/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions The -Calculus (Abadi, Curien, Lévy 1991) Term constructs: Terms of the -calculus + Application of a substitution to a term: f ⇤ t Start substitution: hi Parallel and sequential composition: hf , t/xi, f ; g Typing Rules: Substitutions are judgements ` f : 0 ✓ ` hi : 0 ` f : ` t :A ` hf , t/xi : , x : A ` f : ` t : A ` f ⇤ t : A ` f : ` g : ` f ; g : Key Idea 1: Every -term is equivalent to a -term. Key Idea 2: Contexts z :A⇥B and x :A, y :B are not equal 17 / 31
  • 19. 18/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions Kesner Summing-up ES (2009) All explicit substitutions (ES): decomposing implicit substitutions into atomic steps allows a better understanding of the execution models of higher-order languages; -calculus with ES: incorporate substitution operators into the language, and transforms the equalities of the specification into a set of rewriting rules; composition of substitution allows more sophisticated interactions; -calculi with ES can be defined either with unary or n-ary substitutions, by using de Bruijn notation or levels or nominal logic, or combinators, or director strings or by named variables; a calculus with ES can be also seen as a term notation for a logical system where the reduction rules behave like cut elimination transformations; Mellies counter-example 1995 shows ‘a flaw in the design of ES calculi since they are supposed to implement their underlying calculus (in our case the -calculus) without losing its good properties’ 18 / 31
  • 20. 19/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions Kesner ES (2009) ways to avoid Mellies counter-example in order to recover the SN property; one solution: weak lambda calculi, not good for proof assistants; another: terms with explicit weakening constructors; Her way: a perpetual reduction strategy and normalisation of “Implicit substitution implies normalisation of Explicit substitution”IE property; This extends ideas in [Kes07, Kes08], by the use of intersection types as well as the use of the Z-property of van Oostrom [vO] to show confluence. 19 / 31
  • 21. 20/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions What do we want from a Categorical Semantics? Motivation: What should calculi of explicit substitutions contain? What term constructs should we require What equations should we require how to discover this for di↵erent logics Methodology: Extend the Curry Howard correspondence Category theory as syntax debugging Internal language gives term constructs & equational theory Key Ideas: A model should contain a model of the underlying -calculus Contexts z :A⇥B and x :A, y :B are isomorphic 20 / 31
  • 22. 21/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions Intuitions from Mathematics 21 / 31
  • 23. 22/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions Models of Explicit Substitutions — Indexed Categories Contexts: Modelled by a cartesian category Objects are contexts, morphisms are substitutions Cartesian structure is given by parallel composition Terms: For every context , define the category D( ) Objects are variable-type pairs x : A Morphisms (x : A) ! (y : B) are judgements , x : A ` t : B Re-indexing: ` f : induces a functor D(f ):D( ) ! D( ) Summary: An indexed category is a functor D : Cop ! Cat 22 / 31
  • 24. 23/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions What’s Wrong with Indexed Categories? Plus Points: Indexed categories induce -equations hi; h = h Identity of C h; hi = h Identity of C hi ⇤ t = t Functoriality of D (f ; g); h = f ; (g; h) Assoc of C-comp (f ; g) ⇤ t = f ⇤ (g ⇤ t) Functoriality of D Lemma: Soundness and completeness Problem 1: Indexed Categories are inherently non linear Identities in the fibres require judgements , x : A ` x : A Problem 2: No syntax for forming substitutions from terms 23 / 31
  • 25. 24/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions Context-Handling Categories Solution 1: Remove identities by changing codomain to Set Solution 2: Add two new natural transformations Defn: Let B be a SMC (CCC) with T ✓ |B|. A linear (cartesian) context handling category is a functor L: Bop ! SetsT and for each type, natural isomorphisms SubA : L( )A ) B( , A) TermA : B( , A) ) L( )A Yoneda lemma: There exists VarA 2 L(A)A with TermA(f ) = f ⇤ VarA Equations: We get the following equations h(f ⇤ t)/xi = f ; ht/xi Naturality of Sub ht/xi ⇤ x = t One half of the iso h(f ⇤ x)/xi = f Other half of the iso 24 / 31
  • 26. 25/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions Adding Type Structure — E-Categories Context handling categories model the behaviour of explicit substitutions, eg their formation and application to terms Types: Since terms are defined on the fibres, modelling type constructors requires extra structure on the fibres. Examples: Given types A, B 2 T , there are types A ! B, A ⇥ B 2 T . In addition there are isomorphisms, natural in E(( , A))B E( )A!B E( )A ⇥ E( )B E( A⇥B Naturality: Equations distribute explicit subs over terms f ⇤ x.t = x.f ⇤ t f ⇤ (tu) = (f ⇤ t)(f ⇤ u) Model Collapse: Contexts z :A⇥B and x :A, y :B are isomorphic 25 / 31
  • 27. 26/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions Adding Linear Type Structure — L-Categories Functions: As before, given types A, B 2 T , there is a type A B 2 T and isomorphisms, natural in E(( , A))B E( )A B Tensor: But the following doesn’t give an iso z :A⌦B ⇠ = x :A, y :B E(( , A, B))C E( , A ⌦ B)C Solution: Demand x :A, y :B ` h(x ⌦ y)/zi :A⌦B has an inverse. , x : A, y : B ` f : , z : A ⌦ B ` let z be x ⌦ y in f : Key Idea: Category theory guiding the design of the calculus 26 / 31
  • 28. 27/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions Modelling the !-type Constructor Key Idea: !-arises as the comonad of a monoidal adjunction between CCCs and SMCCs Recall: Models of explicit substitutions E categories model calculi with !, ⇥, 1 types L categories model calculi with , ⌦, I types Defn: A !L-category is a monoidal adjunction where C is an E category, B is an L-category and F, G preserve types. Crucially: Requires an isomorphism x : A| ⇠ = |z :!A , x : A| ` f : | , z :!A ` let z be !x in f : 27 / 31
  • 29. 28/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions Categorical Theorems Please read the paper, but we have three theorems for E-categories (CCCs), three for L-categories (SMCCs), two for putting the E- and L-categories together into a !L-category. (right defn) Every E-category contains an underlying CCC and every CCC extends to an E-category, in an iso way; (soundness) We can model the calculus in an E-category; (completeness) If for every E-category, the interpretation of two morphisms f , f 0 is the same, then the equality of the morphisms is proved by the theory. Similarly for L-categories. For !L-categories, we use Barber’s DILL calculus with explicit substitutions xDILL, described in Linear Explicit Substitutions 28 / 31
  • 30. 29/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions Conclusions Indexed categories are inherently non linear so we use presheaves Explicit substitutions are tricky to model as extensionally they are equivalent to their underlying -calculus Our models reflect this by “taking the isomorphisms seriously” We get a Curry-Howard correspondence justifying our calculus Other possibilities: replace isomorphisms with Identities — loose syntax for substitutions Retracts — loose relationship with usual semantics 29 / 31
  • 31. 30/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions More Conclusions Maybe more important to have models for explicit substitutions than for linear ones? Which fibrations? interesting ones? Can we model patterns too? other logics? Can we say something about the others we skipped? 30 / 31
  • 32. 31/31 Motivation Abstract Machines Our Explicit substitutions Categorical Semantics Conclusions Obrigada! 31 / 31