SlideShare a Scribd company logo
Call-by-value non-determinism
      in a linear logic type discipline

 Alejandro Díaz-Caro                          Giulio Manzonetto
Université Paris-Ouest & INRIA               LIPN, Université Paris 13

                        Michele Pagani
                     LIPN, Université Paris 13

   Symposium on Logical Foundations of Computer Science
          San Diego, California, U.S.A., January 6–8, 2013




                                         Supported by the DIGITEO project 2011-070D “ALAL”
Intersection types discipline             [Coppo-Dezani’78]

                               M :α∩β
                    M enjoys both properties α and β

   With this idea in mind intersection is idempotent α ∩ α = α.




                                                                  2 / 16
Intersection types discipline             [Coppo-Dezani’78]

                               M :α∩β
                    M enjoys both properties α and β

   With this idea in mind intersection is idempotent α ∩ α = α.
   Used to capture various notions of termination:
   Head, Weak and Strong normalisation [Coppo-Dezani’78, Sallé’80]




                                                                     2 / 16
Intersection types discipline             [Coppo-Dezani’78]

                               M :α∩β
                    M enjoys both properties α and β

   With this idea in mind intersection is idempotent α ∩ α = α.
   Used to capture various notions of termination:
   Head, Weak and Strong normalisation [Coppo-Dezani’78, Sallé’80]

Resource-aware intersection types                   [De Carvalho’07]
   Let us change point of view:
                                M :α∩β
   M will be called once as data of type α and once as data of type β
                   Hence α ∩ α = α       =⇒      Multisets
   Used to capture quantitative properties of programs, e.g.:
   CBN λ-calculus: number of linear head-reduction steps [De Carvalho’07]
   CBV λ-calculus: number of weak head-reduction steps [Ehrhard’12]


                                                                            2 / 16
Intersection types discipline             [Coppo-Dezani’78]

                               M :α∩β
                    M enjoys both properties α and β

   With this idea in mind intersection is idempotent α ∩ α = α.
   Used to capture various notions of termination:
   Head, Weak and Strong normalisation [Coppo-Dezani’78, Sallé’80]

Resource-aware intersection types                   [De Carvalho’07]
   Let us change point of view:
                                M :α∩β
   M will be called once as data of type α and once as data of type β
                   Hence α ∩ α = α       =⇒      Multisets
   Used to capture quantitative properties of programs, e.g.:
   CBN λ-calculus: number of linear head-reduction steps [De Carvalho’07]
   CBV λ-calculus: number of weak head-reduction steps [Ehrhard’12]

        Our goal: extend Ehrhard’s system with non-determinism
                                                                            2 / 16
May/Must-convergent non-determinism

              Consider the CBV λ-calculus extended with. . .

  Non-deterministic choice
     M +N            The machine choses either M or N




  Parallel composition
     M N              The machine interleaves reductions in M and in N




                                                                         3 / 16
May/Must-convergent non-determinism

              Consider the CBV λ-calculus extended with. . .

  Non-deterministic choice
     M +N            The machine choses either M or N

      The non-deterministic choice M + N is may-convergent:
          it converges if either M or N converges

  Parallel composition
     M N              The machine interleaves reductions in M and in N

      The parallel composition M N is must-convergent:
          it converges if both M and N do




                                                                         3 / 16
Λ+ : Its syntax and operational semantics

  Grammar of Λ+ terms
   Terms:     M, N, P, Q ::= V | MN | M + N | M N
   Values:             V ::= x | λx.M

  Reduction semantics
      βv -reduction            +-reductions            -reductions
                               M +N →M            (M N)P → MP NP
   (λx.M)V → M[V /x]
                               M +N →N            V (M N) → VM VN

   + Contextual rules selecting the head redex. . .

  The reduction is lazy (it does not reduce under λ-abstractions)




                                                                     4 / 16
Λ+ : Its syntax and operational semantics

  Grammar of Λ+ terms
   Terms:     M, N, P, Q ::= V | MN | M + N | M N
   Values:             V ::= x | λx.M

  Reduction semantics
      βv -reduction            +-reductions            -reductions
                               M +N →M            (M N)P → MP NP
   (λx.M)V → M[V /x]
                               M +N →N            V (M N) → VM VN

   + Contextual rules selecting the head redex. . .

  The reduction is lazy (it does not reduce under λ-abstractions)

  Convergence
               M converges        ⇔       M →∗ V1     ···   Vn



                                                                     4 / 16
Examples and remarks

  Application is bilinear
                                   op
        (M + M )(N + N )           ≡         MN + MN + M N + M N


  . . . but λ-abstraction is not
                                        op
                   λx.(M + N)           ≡      λx.M + λx.N




                                                                   5 / 16
Examples and remarks

  Application is bilinear
                                   op
        (M + M )(N + N )           ≡         MN + MN + M N + M N


  . . . but λ-abstraction is not
                                        op
                   λx.(M + N)           ≡      λx.M + λx.N


  Example of parallel composition and non-deterministic choice

        (λx.(x   x))(V + V ) converges to either V      V or V   V

              (λx.(x + x))(V       V ) converges to V   V only




                                                                     5 / 16
Linear logic based type system
  Translation: Intuitionistic Logic → Polarized fragment of LL

      ιv = ι,      (α → β)v = αc          β ,       αc = !αv ,       α =?αc

  Based on [Ehrhard’12], based on second Girard’s translation.
  Intuitions from the relational semantics of LL
      The type for computations (·)c is a multiset [α1 , . . . , αn ] of value
                                                        v         v
                                                                v
      types (representing n calls to a single value of type αi ),
      The type of parallel compositions (·) is another multiset
        c            c
      [α1 , . . . , αn ] of types of each term in the composition,
      The type for values (·)v are either basic types or functional types,
      A functional type in this system is a pair (αc , [α1 , . . . , αn ]).
                                                         c            c




                                                                                 6 / 16
Linear logic based type system
  Translation: Intuitionistic Logic → Polarized fragment of LL

       ιv = ι,       (α → β)v = αc              β ,   αc = !αv ,      α =?αc

  Based on [Ehrhard’12], based on second Girard’s translation.
  Intuitions from the relational semantics of LL
       The type for computations (·)c is a multiset [α1 , . . . , αn ] of value
                                                         v         v
                                                                 v
       types (representing n calls to a single value of type αi ),
       The type of parallel compositions (·) is another multiset
         c            c
       [α1 , . . . , αn ] of types of each term in the composition,
       The type for values (·)v are either basic types or functional types,
       A functional type in this system is a pair (αc , [α1 , . . . , αn ]).
                                                          c            c


  Notation
                   First multiset layer          −→   ⊗
                Second multiset layer            −→   `
    Functional type (αc , [α1 , . . . , αn ])
                            c            c
                                                 −→   αc    α1 ` · · · ` αn
                                                             c            c

       Empty computational multiset              −→   1
                                                                                  6 / 16
Linear logic based type system              (cont.)


  Grammar of Types:

         parallel-types:            α, β ::= α ` β | τ
         computational-types:       τ, ρ ::= 1 | τ ⊗ ρ | τ    α

   ⊗   tensor product
                                associative and commutative
   `   par
   1   neutral element of ⊗




                                                                  7 / 16
Linear logic based type system                       (cont.)


  Grammar of Types:

           parallel-types:                  α, β ::= α ` β | τ
           computational-types:             τ, ρ ::= 1 | τ ⊗ ρ | τ   α

   ⊗     tensor product
                                      associative and commutative
   `     par
   1     neutral element of ⊗

  Type environments:
  Γ = x1 : τ1 , . . . , xn : τn represents the map

                                       τi    if y = xi ,
                           Γ(y ) =
                                       1     otherwise.

  Tensor is extended to environments pointwise (Γ ⊗ ∆)(x) = Γ(x) ⊗ ∆(x).



                                                                           7 / 16
Linear logic based type system                    (cont.)
Type inference rules
         ∆    M:α              ∆    N:α            + is may-convergent, so it
                       +                     +r    is enough that one term is
     ∆       M +N :α       ∆       M +N :α         typable




                                                                                8 / 16
Linear logic based type system                               (cont.)
Type inference rules
         ∆    M:α                       ∆    N:α              + is may-convergent, so it
                           +                          +r      is enough that one term is
     ∆       M +N :α                ∆       M +N :α           typable

          ∆     M : α1          Γ   N : α2                   is must-convergent, so both
                                               I
             ∆⊗Γ       M       N : α1 ` α2                 components must be typable




                                                                                           8 / 16
Linear logic based type system                                                (cont.)
Type inference rules
         ∆    M:α                              ∆       N:α                         + is may-convergent, so it
                            +                                     +r               is enough that one term is
     ∆       M +N :α                     ∆         M +N :α                         typable

          ∆     M : α1             Γ          N : α2                      is must-convergent, so both
                                                         I
             ∆⊗Γ        M        N : α1 ` α2                            components must be typable

                    ¸
                    k       ni                                      ¸
                                                                    ni
          ∆    M:                (τij         αij )     Γi     N:            τij    1≤i ≤k
                       i=1 j=1                                      j=1                             k ≥1
                                                                                                E
                                        k                    ¸¸
                                                             k ni                                   ni ≥ 1
                            ∆⊗                Γi      MN :             αij
                                        i=1                  i=1 j=1
       It reflects the distribution of the parallel operator over the application




                                                                                                                8 / 16
Linear logic based type system                                                     (cont.)
Type inference rules
         ∆      M:α                            ∆         N:α                            + is may-convergent, so it
                            +                                          +r               is enough that one term is
     ∆       M +N :α                     ∆          M +N :α                             typable

          ∆      M : α1            Γ          N : α2                           is must-convergent, so both
                                                              I
             ∆⊗Γ        M        N : α1 ` α2                                 components must be typable

                     ¸
                     k      ni                                           ¸
                                                                         ni
          ∆     M:               (τij         αij )       Γi        N:            τij    1≤i ≤k
                       i=1 j=1                                           j=1                                  k ≥1
                                                                                                      E
                                        k                         ¸¸
                                                                  k ni                                        ni ≥ 1
                            ∆⊗                Γi        MN :                αij
                                        i=1                       i=1 j=1
       It reflects the distribution of the parallel operator over the application
                                              ∆i , x : τ i          M : αi               1≤i ≤n
                                                    n                              n                      I    n≥0
                          ax
         x :τ     x :τ                                   ∆i        λx.M :               (τi    αi )
                                                   i=1                            i=1
                The axiom and the intersection type for values respectively
                                                                                                                       8 / 16
Examples

         ∆ = x : (τ1      α1 ) ⊗ (τ2           α2 )        Γ = y : τ1 , y : τ2

     ∆     x : (τ1     α1 ) ⊗ (τ2       α2 )          Γ      y   y : τ1 ` τ2
                                                                                 E
                     ∆⊗Γ          x(y    y ) : α1 ` α2

                            x(y     y ) → xy          xy




                                                                                     9 / 16
Examples

         ∆ = x : (τ1       α1 ) ⊗ (τ2             α2 )         Γ = y : τ1 , y : τ2

     ∆     x : (τ1     α1 ) ⊗ (τ2          α2 )          Γ       y      y : τ1 ` τ2
                                                                                      E
                     ∆⊗Γ             x(y    y ) : α1 ` α2

                               x(y     y ) → xy           xy



                     ∆ = x : (τ1             α3 ) ⊗ (τ2              α4 )

   ∆⊗∆     x   x : ((τ1 α1 ) ⊗ (τ2                 α2 )) ` ((τ1  α3 ) ⊗ (τ2           α4 ))
           Γ    y y : τ1 ` τ2                       Γ      y y : τ1 ` τ2
                                                                                               E
         ∆⊗∆ ⊗Γ⊗Γ               (x     x )(y        y ) : α1 ` α2 ` α3 ` α4

                (x     x )(y     y ) →∗ xy           xy        xy       xy


                                                                                              9 / 16
Measuring derivation trees
   π=              ax                                 |π| = 0
            S
          π1 · · · πn                                           n
   π=                            I                    |π| =     i=1   |πi |
                   S
          π1           π2
   π=                       I                         |π| = |π1 | + |π2 |
                   S

          π0       π1 . . . πk                                  k                 k
   π=                                E       ni ≥ 1   |π| =     i=0   |πi | + (   i=1   2ni ) − 1
                       S
          π                              π
   π=          +           or π =             +r      |π| = |π | + 1
          S                              S
                                                         βv and redexes are typed by                E
  Only        E,   + and +r type redexes
                                                         + redexes by + and +r
  Each + and +r counts for 1 because a +-red. does not create new rules
  in the derivation typing the contractum
    E    counts the number of “active” connectives in the principal premise
                                                                                                        10 / 16
Measuring derivation trees                                  (cont.)


                ¸
                k          ni                                          ¸
                                                                       ni
      ∆    M:                   (τij         αij )     Γi         N:         τij     1≤i ≤k
                i=1 j=1                                                j=1
                                                                                               E
                                       k                    ¸¸
                                                            k ni
                           ∆⊗                Γi      MN :              αij
                                       i=1                  i=1 j=1


                k                 k                                          k
                      ni +              (ni − 1) + (k − 1) = (                     2ni ) − 1
                i=1              i=1                                     i=1
                                                            `’s
                      ’s                   ⊗’s


  The -reduction creates two new                       E    rules in the derivation typing the
  contractum

  The measure decreases because the sum of their weights is less than the
  weight of the eliminated rule

                                                                                                   11 / 16
Properties of the type system
  Our system enjoys a quantitative version of standard properties.

  Subject reduction
  Let π = ∆    M:α
      If      M → N without +-red.       then      ∃π = ∆       N:α
      If    M → N1 and M → N2 with +-red.
           then  ∃π = ∆ N1 : α or π = ∆                N2 : α
  In both cases, |π | = |π| − 1




                                                                      12 / 16
Properties of the type system
  Our system enjoys a quantitative version of standard properties.

  Subject reduction
  Let π = ∆    M:α
      If      M → N without +-red.       then      ∃π = ∆       N:α
      If    M → N1 and M → N2 with +-red.
           then  ∃π = ∆ N1 : α or π = ∆                N2 : α
  In both cases, |π | = |π| − 1

  Subject expansion
  If   M→N    and    π=∆ N:α
  then  ∃π = ∆ M : α   s.t. |π | = |π| + 1




                                                                      12 / 16
Properties of the type system
  Our system enjoys a quantitative version of standard properties.

  Subject reduction
  Let π = ∆    M:α
      If      M → N without +-red.       then      ∃π = ∆       N:α
      If    M → N1 and M → N2 with +-red.
           then  ∃π = ∆ N1 : α or π = ∆                N2 : α
  In both cases, |π | = |π| − 1

  Subject expansion
  If   M→N    and    π=∆ N:α
  then  ∃π = ∆ M : α   s.t. |π | = |π| + 1

  Characterization of convergence
  Let M closed.            M typable     ⇔      M converges
  Can we say anything more quantitative?
                                                                      12 / 16
Combinatorial proof of normalization

  Measure
  Let M be a closed term. If π is a derivation of

                                    M : α,

  then |π| gives a bound on the number of steps M converges.

  More precisely. . .

  Exact bound
  Let M be a closed term. If π is a derivation of

                               M : 1 ` · · · ` 1,

  then M reaches its normal form in exactly |π| steps



                                                               13 / 16
Properties of the underlying relational model

   Let M, N and P be closed terms.


   Definitions
       A closed term M is interpreted by       M = {α |       M : α}
       M    N      iff    ∀P       M P converges     ⇒      N P converges



   As a corollary of the Convergence Theorem we get:

   Adequacy
                        M ⊆ N        implies    M      N




                                                                           14 / 16
Lack of full abstraction
   Lack of full abstraction
                 M     N      does not imply       M ⊆ N

   CBV λ-calculus admits the creation of an ogre

                      Y = ∆ ∆ where ∆ = λxy .xx.

   Remark: The ogre Y is a top of    :

               Y V V → (λy .Y )V V → Y V → · · · → Y .
                                     n
   All types of Y have shape α =     i=0 (1    αi ).




                                                           15 / 16
Lack of full abstraction
   Lack of full abstraction
                   M        N       does not imply       M ⊆ N

   CBV λ-calculus admits the creation of an ogre

                        Y = ∆ ∆ where ∆ = λxy .xx.

   Remark: The ogre Y is a top of          :

               Y V V → (λy .Y )V V → Y V → · · · → Y .
                                           n
   All types of Y have shape α =           i=0 (1    αi ).

   Counterexample (independent from + and                    )
   Let I = λx.x, then
                                I   Y , while I ⊆ Y
   since (1   1)       (1       1) ∈ I − Y

                                                                 15 / 16
Summarising



     We introduced a call-by-value non-deterministic λ-calculus with a
     type system ensuring convergence


     The type system gives a bound of the length of the lazy cbv
     reduction sequences (exact when the typing is minimal)


     We show an adequate (but not fully abstract) model capturing the
     type system




                                                                         16 / 16

More Related Content

DOC
The Estimations Based on the Kolmogorov Complexity and ...
PDF
Slides SAS'2002
PDF
Linear models for classification
PDF
FDA and Statistical learning theory
PDF
Dragisa Zunic - Classical computing with explicit structural rules - the *X c...
PDF
Lecture2 xing
PDF
2008 : A Case Study: How to Speed Up the Simplex Algorithms on Problems Minim...
PDF
Dealing with intractability: Recent Bayesian Monte Carlo methods for dealing ...
The Estimations Based on the Kolmogorov Complexity and ...
Slides SAS'2002
Linear models for classification
FDA and Statistical learning theory
Dragisa Zunic - Classical computing with explicit structural rules - the *X c...
Lecture2 xing
2008 : A Case Study: How to Speed Up the Simplex Algorithms on Problems Minim...
Dealing with intractability: Recent Bayesian Monte Carlo methods for dealing ...

What's hot (19)

PDF
01 graphical models
PDF
A type system for the vectorial aspects of the linear-algebraic lambda-calculus
PDF
M098 outcomes and assessment matrix
PDF
11X1 T11 01 graphing quadratics
PDF
11X1 T10 01 graphing quadratics (2010)
PDF
004 parabola
PDF
An implicit partial pivoting gauss elimination algorithm for linear system of...
PDF
Johan Suykens: "Models from Data: a Unifying Picture"
PDF
Stochastic Differentiation
PDF
Masters Thesis Defense
PDF
Theme 12
PDF
Lecture1
PDF
D-Branes and The Disformal Dark Sector - Danielle Wills and Tomi Koivisto
DOCX
Advanced algebra (some terminologies)
PDF
Who's afraid of Categorical models?
PDF
A System F accounting for scalars
PDF
/.Amd mnt/lotus/host/home/jaishakthi/presentation/tencon/tencon
PDF
Ben Gal
01 graphical models
A type system for the vectorial aspects of the linear-algebraic lambda-calculus
M098 outcomes and assessment matrix
11X1 T11 01 graphing quadratics
11X1 T10 01 graphing quadratics (2010)
004 parabola
An implicit partial pivoting gauss elimination algorithm for linear system of...
Johan Suykens: "Models from Data: a Unifying Picture"
Stochastic Differentiation
Masters Thesis Defense
Theme 12
Lecture1
D-Branes and The Disformal Dark Sector - Danielle Wills and Tomi Koivisto
Advanced algebra (some terminologies)
Who's afraid of Categorical models?
A System F accounting for scalars
/.Amd mnt/lotus/host/home/jaishakthi/presentation/tencon/tencon
Ben Gal
Ad

Similar to Call-by-value non-determinism in a linear logic type discipline (20)

PDF
Equivalence of algebraic λ-calculi
PDF
Slides QuAND 2011
PDF
Vectorial types, non-determinism and probabilistic systems: Towards a computa...
PDF
Slides used during my thesis defense "Du typage vectoriel"
PPTX
Introduction to the lambda calculus
PDF
Rough set on concept lattice
PDF
Linear logic (and Linear Lisp)
PDF
Intuitionistic First-Order Logic: Categorical semantics via the Curry-Howard ...
PDF
Intro To Agda
PDF
PDF
Temporal logic and functional reactive programming
PDF
Can two fixpoint types in Mendler style unite?
PDF
Cálculo lambda
KEY
Verification with LoLA: 2 The LoLA Input Language
PDF
Expressiveness and Model of the Polymorphic λ Calculus
PDF
Linearity in the non-deterministic call-by-value setting
PDF
Functional Programming in C++
PPTX
Formal methods 5 - Pi calculus
PPT
PDF
Domain Modeling in a Functional World
Equivalence of algebraic λ-calculi
Slides QuAND 2011
Vectorial types, non-determinism and probabilistic systems: Towards a computa...
Slides used during my thesis defense "Du typage vectoriel"
Introduction to the lambda calculus
Rough set on concept lattice
Linear logic (and Linear Lisp)
Intuitionistic First-Order Logic: Categorical semantics via the Curry-Howard ...
Intro To Agda
Temporal logic and functional reactive programming
Can two fixpoint types in Mendler style unite?
Cálculo lambda
Verification with LoLA: 2 The LoLA Input Language
Expressiveness and Model of the Polymorphic λ Calculus
Linearity in the non-deterministic call-by-value setting
Functional Programming in C++
Formal methods 5 - Pi calculus
Domain Modeling in a Functional World
Ad

More from Alejandro Díaz-Caro (8)

PDF
Typing quantum superpositions and measurement
PDF
A lambda calculus for density matrices with classical and probabilistic controls
PDF
Towards a quantum lambda-calculus with quantum control
PDF
Affine computation and affine automaton
PDF
Simply typed lambda-calculus modulo isomorphisms
PDF
The probability of non-confluent systems
PDF
Quantum computing, non-determinism, probabilistic systems... and the logic be...
PDF
Non determinism through type isomophism
Typing quantum superpositions and measurement
A lambda calculus for density matrices with classical and probabilistic controls
Towards a quantum lambda-calculus with quantum control
Affine computation and affine automaton
Simply typed lambda-calculus modulo isomorphisms
The probability of non-confluent systems
Quantum computing, non-determinism, probabilistic systems... and the logic be...
Non determinism through type isomophism

Call-by-value non-determinism in a linear logic type discipline

  • 1. Call-by-value non-determinism in a linear logic type discipline Alejandro Díaz-Caro Giulio Manzonetto Université Paris-Ouest & INRIA LIPN, Université Paris 13 Michele Pagani LIPN, Université Paris 13 Symposium on Logical Foundations of Computer Science San Diego, California, U.S.A., January 6–8, 2013 Supported by the DIGITEO project 2011-070D “ALAL”
  • 2. Intersection types discipline [Coppo-Dezani’78] M :α∩β M enjoys both properties α and β With this idea in mind intersection is idempotent α ∩ α = α. 2 / 16
  • 3. Intersection types discipline [Coppo-Dezani’78] M :α∩β M enjoys both properties α and β With this idea in mind intersection is idempotent α ∩ α = α. Used to capture various notions of termination: Head, Weak and Strong normalisation [Coppo-Dezani’78, Sallé’80] 2 / 16
  • 4. Intersection types discipline [Coppo-Dezani’78] M :α∩β M enjoys both properties α and β With this idea in mind intersection is idempotent α ∩ α = α. Used to capture various notions of termination: Head, Weak and Strong normalisation [Coppo-Dezani’78, Sallé’80] Resource-aware intersection types [De Carvalho’07] Let us change point of view: M :α∩β M will be called once as data of type α and once as data of type β Hence α ∩ α = α =⇒ Multisets Used to capture quantitative properties of programs, e.g.: CBN λ-calculus: number of linear head-reduction steps [De Carvalho’07] CBV λ-calculus: number of weak head-reduction steps [Ehrhard’12] 2 / 16
  • 5. Intersection types discipline [Coppo-Dezani’78] M :α∩β M enjoys both properties α and β With this idea in mind intersection is idempotent α ∩ α = α. Used to capture various notions of termination: Head, Weak and Strong normalisation [Coppo-Dezani’78, Sallé’80] Resource-aware intersection types [De Carvalho’07] Let us change point of view: M :α∩β M will be called once as data of type α and once as data of type β Hence α ∩ α = α =⇒ Multisets Used to capture quantitative properties of programs, e.g.: CBN λ-calculus: number of linear head-reduction steps [De Carvalho’07] CBV λ-calculus: number of weak head-reduction steps [Ehrhard’12] Our goal: extend Ehrhard’s system with non-determinism 2 / 16
  • 6. May/Must-convergent non-determinism Consider the CBV λ-calculus extended with. . . Non-deterministic choice M +N The machine choses either M or N Parallel composition M N The machine interleaves reductions in M and in N 3 / 16
  • 7. May/Must-convergent non-determinism Consider the CBV λ-calculus extended with. . . Non-deterministic choice M +N The machine choses either M or N The non-deterministic choice M + N is may-convergent: it converges if either M or N converges Parallel composition M N The machine interleaves reductions in M and in N The parallel composition M N is must-convergent: it converges if both M and N do 3 / 16
  • 8. Λ+ : Its syntax and operational semantics Grammar of Λ+ terms Terms: M, N, P, Q ::= V | MN | M + N | M N Values: V ::= x | λx.M Reduction semantics βv -reduction +-reductions -reductions M +N →M (M N)P → MP NP (λx.M)V → M[V /x] M +N →N V (M N) → VM VN + Contextual rules selecting the head redex. . . The reduction is lazy (it does not reduce under λ-abstractions) 4 / 16
  • 9. Λ+ : Its syntax and operational semantics Grammar of Λ+ terms Terms: M, N, P, Q ::= V | MN | M + N | M N Values: V ::= x | λx.M Reduction semantics βv -reduction +-reductions -reductions M +N →M (M N)P → MP NP (λx.M)V → M[V /x] M +N →N V (M N) → VM VN + Contextual rules selecting the head redex. . . The reduction is lazy (it does not reduce under λ-abstractions) Convergence M converges ⇔ M →∗ V1 ··· Vn 4 / 16
  • 10. Examples and remarks Application is bilinear op (M + M )(N + N ) ≡ MN + MN + M N + M N . . . but λ-abstraction is not op λx.(M + N) ≡ λx.M + λx.N 5 / 16
  • 11. Examples and remarks Application is bilinear op (M + M )(N + N ) ≡ MN + MN + M N + M N . . . but λ-abstraction is not op λx.(M + N) ≡ λx.M + λx.N Example of parallel composition and non-deterministic choice (λx.(x x))(V + V ) converges to either V V or V V (λx.(x + x))(V V ) converges to V V only 5 / 16
  • 12. Linear logic based type system Translation: Intuitionistic Logic → Polarized fragment of LL ιv = ι, (α → β)v = αc β , αc = !αv , α =?αc Based on [Ehrhard’12], based on second Girard’s translation. Intuitions from the relational semantics of LL The type for computations (·)c is a multiset [α1 , . . . , αn ] of value v v v types (representing n calls to a single value of type αi ), The type of parallel compositions (·) is another multiset c c [α1 , . . . , αn ] of types of each term in the composition, The type for values (·)v are either basic types or functional types, A functional type in this system is a pair (αc , [α1 , . . . , αn ]). c c 6 / 16
  • 13. Linear logic based type system Translation: Intuitionistic Logic → Polarized fragment of LL ιv = ι, (α → β)v = αc β , αc = !αv , α =?αc Based on [Ehrhard’12], based on second Girard’s translation. Intuitions from the relational semantics of LL The type for computations (·)c is a multiset [α1 , . . . , αn ] of value v v v types (representing n calls to a single value of type αi ), The type of parallel compositions (·) is another multiset c c [α1 , . . . , αn ] of types of each term in the composition, The type for values (·)v are either basic types or functional types, A functional type in this system is a pair (αc , [α1 , . . . , αn ]). c c Notation First multiset layer −→ ⊗ Second multiset layer −→ ` Functional type (αc , [α1 , . . . , αn ]) c c −→ αc α1 ` · · · ` αn c c Empty computational multiset −→ 1 6 / 16
  • 14. Linear logic based type system (cont.) Grammar of Types: parallel-types: α, β ::= α ` β | τ computational-types: τ, ρ ::= 1 | τ ⊗ ρ | τ α ⊗ tensor product associative and commutative ` par 1 neutral element of ⊗ 7 / 16
  • 15. Linear logic based type system (cont.) Grammar of Types: parallel-types: α, β ::= α ` β | τ computational-types: τ, ρ ::= 1 | τ ⊗ ρ | τ α ⊗ tensor product associative and commutative ` par 1 neutral element of ⊗ Type environments: Γ = x1 : τ1 , . . . , xn : τn represents the map τi if y = xi , Γ(y ) = 1 otherwise. Tensor is extended to environments pointwise (Γ ⊗ ∆)(x) = Γ(x) ⊗ ∆(x). 7 / 16
  • 16. Linear logic based type system (cont.) Type inference rules ∆ M:α ∆ N:α + is may-convergent, so it + +r is enough that one term is ∆ M +N :α ∆ M +N :α typable 8 / 16
  • 17. Linear logic based type system (cont.) Type inference rules ∆ M:α ∆ N:α + is may-convergent, so it + +r is enough that one term is ∆ M +N :α ∆ M +N :α typable ∆ M : α1 Γ N : α2 is must-convergent, so both I ∆⊗Γ M N : α1 ` α2 components must be typable 8 / 16
  • 18. Linear logic based type system (cont.) Type inference rules ∆ M:α ∆ N:α + is may-convergent, so it + +r is enough that one term is ∆ M +N :α ∆ M +N :α typable ∆ M : α1 Γ N : α2 is must-convergent, so both I ∆⊗Γ M N : α1 ` α2 components must be typable ¸ k ni ¸ ni ∆ M: (τij αij ) Γi N: τij 1≤i ≤k i=1 j=1 j=1 k ≥1 E k ¸¸ k ni ni ≥ 1 ∆⊗ Γi MN : αij i=1 i=1 j=1 It reflects the distribution of the parallel operator over the application 8 / 16
  • 19. Linear logic based type system (cont.) Type inference rules ∆ M:α ∆ N:α + is may-convergent, so it + +r is enough that one term is ∆ M +N :α ∆ M +N :α typable ∆ M : α1 Γ N : α2 is must-convergent, so both I ∆⊗Γ M N : α1 ` α2 components must be typable ¸ k ni ¸ ni ∆ M: (τij αij ) Γi N: τij 1≤i ≤k i=1 j=1 j=1 k ≥1 E k ¸¸ k ni ni ≥ 1 ∆⊗ Γi MN : αij i=1 i=1 j=1 It reflects the distribution of the parallel operator over the application ∆i , x : τ i M : αi 1≤i ≤n n n I n≥0 ax x :τ x :τ ∆i λx.M : (τi αi ) i=1 i=1 The axiom and the intersection type for values respectively 8 / 16
  • 20. Examples ∆ = x : (τ1 α1 ) ⊗ (τ2 α2 ) Γ = y : τ1 , y : τ2 ∆ x : (τ1 α1 ) ⊗ (τ2 α2 ) Γ y y : τ1 ` τ2 E ∆⊗Γ x(y y ) : α1 ` α2 x(y y ) → xy xy 9 / 16
  • 21. Examples ∆ = x : (τ1 α1 ) ⊗ (τ2 α2 ) Γ = y : τ1 , y : τ2 ∆ x : (τ1 α1 ) ⊗ (τ2 α2 ) Γ y y : τ1 ` τ2 E ∆⊗Γ x(y y ) : α1 ` α2 x(y y ) → xy xy ∆ = x : (τ1 α3 ) ⊗ (τ2 α4 ) ∆⊗∆ x x : ((τ1 α1 ) ⊗ (τ2 α2 )) ` ((τ1 α3 ) ⊗ (τ2 α4 )) Γ y y : τ1 ` τ2 Γ y y : τ1 ` τ2 E ∆⊗∆ ⊗Γ⊗Γ (x x )(y y ) : α1 ` α2 ` α3 ` α4 (x x )(y y ) →∗ xy xy xy xy 9 / 16
  • 22. Measuring derivation trees π= ax |π| = 0 S π1 · · · πn n π= I |π| = i=1 |πi | S π1 π2 π= I |π| = |π1 | + |π2 | S π0 π1 . . . πk k k π= E ni ≥ 1 |π| = i=0 |πi | + ( i=1 2ni ) − 1 S π π π= + or π = +r |π| = |π | + 1 S S βv and redexes are typed by E Only E, + and +r type redexes + redexes by + and +r Each + and +r counts for 1 because a +-red. does not create new rules in the derivation typing the contractum E counts the number of “active” connectives in the principal premise 10 / 16
  • 23. Measuring derivation trees (cont.) ¸ k ni ¸ ni ∆ M: (τij αij ) Γi N: τij 1≤i ≤k i=1 j=1 j=1 E k ¸¸ k ni ∆⊗ Γi MN : αij i=1 i=1 j=1 k k k ni + (ni − 1) + (k − 1) = ( 2ni ) − 1 i=1 i=1 i=1 `’s ’s ⊗’s The -reduction creates two new E rules in the derivation typing the contractum The measure decreases because the sum of their weights is less than the weight of the eliminated rule 11 / 16
  • 24. Properties of the type system Our system enjoys a quantitative version of standard properties. Subject reduction Let π = ∆ M:α If M → N without +-red. then ∃π = ∆ N:α If M → N1 and M → N2 with +-red. then ∃π = ∆ N1 : α or π = ∆ N2 : α In both cases, |π | = |π| − 1 12 / 16
  • 25. Properties of the type system Our system enjoys a quantitative version of standard properties. Subject reduction Let π = ∆ M:α If M → N without +-red. then ∃π = ∆ N:α If M → N1 and M → N2 with +-red. then ∃π = ∆ N1 : α or π = ∆ N2 : α In both cases, |π | = |π| − 1 Subject expansion If M→N and π=∆ N:α then ∃π = ∆ M : α s.t. |π | = |π| + 1 12 / 16
  • 26. Properties of the type system Our system enjoys a quantitative version of standard properties. Subject reduction Let π = ∆ M:α If M → N without +-red. then ∃π = ∆ N:α If M → N1 and M → N2 with +-red. then ∃π = ∆ N1 : α or π = ∆ N2 : α In both cases, |π | = |π| − 1 Subject expansion If M→N and π=∆ N:α then ∃π = ∆ M : α s.t. |π | = |π| + 1 Characterization of convergence Let M closed. M typable ⇔ M converges Can we say anything more quantitative? 12 / 16
  • 27. Combinatorial proof of normalization Measure Let M be a closed term. If π is a derivation of M : α, then |π| gives a bound on the number of steps M converges. More precisely. . . Exact bound Let M be a closed term. If π is a derivation of M : 1 ` · · · ` 1, then M reaches its normal form in exactly |π| steps 13 / 16
  • 28. Properties of the underlying relational model Let M, N and P be closed terms. Definitions A closed term M is interpreted by M = {α | M : α} M N iff ∀P M P converges ⇒ N P converges As a corollary of the Convergence Theorem we get: Adequacy M ⊆ N implies M N 14 / 16
  • 29. Lack of full abstraction Lack of full abstraction M N does not imply M ⊆ N CBV λ-calculus admits the creation of an ogre Y = ∆ ∆ where ∆ = λxy .xx. Remark: The ogre Y is a top of : Y V V → (λy .Y )V V → Y V → · · · → Y . n All types of Y have shape α = i=0 (1 αi ). 15 / 16
  • 30. Lack of full abstraction Lack of full abstraction M N does not imply M ⊆ N CBV λ-calculus admits the creation of an ogre Y = ∆ ∆ where ∆ = λxy .xx. Remark: The ogre Y is a top of : Y V V → (λy .Y )V V → Y V → · · · → Y . n All types of Y have shape α = i=0 (1 αi ). Counterexample (independent from + and ) Let I = λx.x, then I Y , while I ⊆ Y since (1 1) (1 1) ∈ I − Y 15 / 16
  • 31. Summarising We introduced a call-by-value non-deterministic λ-calculus with a type system ensuring convergence The type system gives a bound of the length of the lazy cbv reduction sequences (exact when the typing is minimal) We show an adequate (but not fully abstract) model capturing the type system 16 / 16