<p>I think that the type system you want is elementary affine logic with fixpoints.</p>

<p>A distinctive feature (actually, <em>the</em> distinctive feature) of light logics, including elementary linear/affine logic, is that types do not ensure termination: unlike usual logical system, cut-elimination follows from a structural property of proofs (namely, <em>stratification</em>), the logical complexity of formulas does not play any role.  Types in EAL only give you well-formedness properties (like progress, i.e., normalization doesn't get stuck; or the fact that the normal form will have a certain shape).</p>

<p>The fact that cut-elimination holds regardless of types means that you can add arbitrary type fixpoints to EAL and you still get normalization with the same complexity bounds (elementary), because you still have stratification.  With type fixpoints, Scott numerals get the following type:</p>

<p>$$\mu \beta.\forall \alpha.(\beta\multimap\alpha)\multimap\alpha\multimap\alpha$$</p>

<p>A paper that uses EAL+type fixpoints explicitly is</p>

<p>Patrick Baillot. <a href="http://perso.ens-lyon.fr/patrick.baillot/Publications/MESPAPIERS/ELL_Ptime_Long_final.pdf"><em>On the expressivity of elementary linear logic: Characterizing Ptime and an exponential time hierarchy</em></a>.
Information and Computation 241: 3-31, 2015. </p>

<p>You will find formal definitions there.  However, I am afraid that no implementation exists.</p>

CC BY-SA 3.0
2016-01-21T11:10:11.927Z
That's the answer I was looking for, thank you! (Are you sure that is the type of Scott numerals, though? Shouldn't be `μβ.∀α.(β⊸α)⊸α⊸α`?)
MaiaVictor
CC BY-SA 3.0
2016-01-22T13:07:41.370Z
Yes, sorry, that's right!  The one I wrote was the type of Scott binary strings.  I just edited the answer accordingly.
Damiano Mazza
CC BY-SA 3.0
2016-01-21T09:01:54.070Z
2016-01-23T12:14:50.553Z
2016-01-23T12:14:50.553Z
Damiano Mazza
<p>There is a subset of λ-calculus terms that can be reduced by Lamping's Abstract Algorithm without using the Oracle. That is an interesting subset, because only for those terms it is proven that Lamping's algorithm is optimal and superior to naive strategies. </p>

<p>In order to use this in practice, one can write programs on the untyped lambda calculus and experimentally test if Lamping's Algorithm works on them for some inputs. It it does, the term is probably on that subset. For example, my answer to <a href="https://cstheory.stackexchange.com/questions/32406/is-sort-typeable-on-elementary-afine-logic/33583#33583">this question</a> is a Church-nat sorting algorithm that was developed this way. That is inconvenient for 2 obvious reasons:</p>

<ol>
<li><p>You can't be 100% sure an algorithm will work for all inputs by experimenting it on some.</p></li>
<li><p>Programming on the untyped lambda calculus can lead to human type errors.</p></li>
</ol>

<p>An immediate solution to problem #2 would be to instead write your programs in a type system on the Lambda Cube (such as System F), but that doesn't work quite well in practice because algorithms on the optimal subset often rely on Scott-encoded data structures (as depicted on my answer above), which are excluded from those type systems. And about problem #1, I'm aware of some type systems based on light logics, but I found them overly complicated and I'm not sure how they could be used in practice. </p>

<p>What type system better fits the subclass of λ-terms that can be reduced optimally, in a way that could be used as the type system of a practical programming language?</p>

<type-theory><lambda-calculus><functional-programming><type-systems>
What type system fits the subclass of λ-terms that can be reduced optimally?
MaiaVictor
# What type system fits the subclass of λ-terms that can be reduced optimally?

(Asked by: username_0 on 2016-01-16)

There is a subset of λ-calculus terms that can be reduced by Lamping's Abstract Algorithm without using the Oracle. That is an interesting subset, because only for those terms it is proven that Lamping's algorithm is optimal and superior to naive strategies.

In order to use this in practice, one can write programs on the untyped lambda calculus and experimentally test if Lamping's Algorithm works on them for some inputs. It it does, the term is probably on that subset. For example, my answer to [this question](https://cstheory.stackexchange.com/questions/32406/is-sort-typeable-on-elementary-afine-logic/33583#33583) is a Church-nat sorting algorithm that was developed this way. That is inconvenient for 2 obvious reasons:

1. You can't be 100% sure an algorithm will work for all inputs by experimenting it on some.
2. Programming on the untyped lambda calculus can lead to human type errors.

An immediate solution to problem #2 would be to instead write your programs in a type system on the Lambda Cube (such as System F), but that doesn't work quite well in practice because algorithms on the optimal subset often rely on Scott-encoded data structures (as depicted on my answer above), which are excluded from those type systems. And about problem #1, I'm aware of some type systems based on light logics, but I found them overly complicated and I'm not sure how they could be used in practice.

What type system better fits the subclass of λ-terms that can be reduced optimally, in a way that could be used as the type system of a practical programming language?

**Tags:** type-theory, lambda-calculus, functional-programming, type-systems

---

## 1 answers

### Answer by username_1 on 2016-01-21. Score: 9 | Accepted answer

I think that the type system you want is elementary affine logic with fixpoints.

A distinctive feature (actually, *the* distinctive feature) of light logics, including elementary linear/affine logic, is that types do not ensure termination: unlike usual logical system, cut-elimination follows from a structural property of proofs (namely, *stratification*), the logical complexity of formulas does not play any role. Types in EAL only give you well-formedness properties (like progress, i.e., normalization doesn't get stuck; or the fact that the normal form will have a certain shape).

The fact that cut-elimination holds regardless of types means that you can add arbitrary type fixpoints to EAL and you still get normalization with the same complexity bounds (elementary), because you still have stratification. With type fixpoints, Scott numerals get the following type:

$$\mu \beta.\forall \alpha.(\beta\multimap\alpha)\multimap\alpha\multimap\alpha$$

A paper that uses EAL+type fixpoints explicitly is

Patrick Baillot. [*On the expressivity of elementary linear logic: Characterizing Ptime and an exponential time hierarchy*](http://perso.ens-lyon.fr/patrick.baillot/Publications/MESPAPIERS/ELL_Ptime_Long_final.pdf).
Information and Computation 241: 3-31, 2015.

You will find formal definitions there. However, I am afraid that no implementation exists.

> **Comments:**
> **username_0**: That's the answer I was looking for, thank you! (Are you sure that is the type of Scott numerals, though? Shouldn't be `μβ.∀α.(β⊸α)⊸α⊸α`?)  
> **username_1**: Yes, sorry, that's right!  The one I wrote was the type of Scott binary strings.  I just edited the answer accordingly.  

---

