<p>The term that you gave does have one duplication, i.e.: <code>ones</code> is used in the body and returned in form of a free variable. The following example illustrates the same effect but is smaller:</p>

<pre><code>loop = λ_. loop
</code></pre>

<p>To make the graph structure clear, let's make sure that each identifier is used exactly twice (<code>_</code> represents connected erasing node):</p>

<pre><code>C[loop, loop_rec] = λ[_, loop_rec]
</code></pre>

<p>EAL gives you termination proof if you can stratify all the terms. I don't see how you can stratify this one.
If the level of <code>loop_rec</code> is <span class="math-container">$n$</span> then the level of whole λ is also <span class="math-container">$n$</span>. And after the contraction the level of both <code>loop</code> and <code>loop_rec</code> should be <span class="math-container">$n-1$</span> which gives you contradiction.</p>

<p>On the other hand you are right that this copy can't escape the definition (assuming <code>1</code> and <code>cons</code> are closed), so it is equal to an actual infinite list. Yet I don't see how to generalize this into an argument about arbitrary recursive let statements.</p>

CC BY-SA 4.0
2019-02-21T19:19:34.627Z
I'm not familiar what persistent upwards and downwards mean. I ignored that part of your description. I'm my experiments nodes could go through 'wiring' that would change their apparent direction, so 'upward/downward' distinction wasn't really useful for me so far. Perhaps some photos of hand drawn graphs would be illuminating to explain your intuitions.
Łukasz Lew
CC BY-SA 4.0
2019-02-21T05:05:01.640Z
2019-02-21T05:05:01.640Z
Łukasz Lew
<p>A few years ago, I've asked if <a href="https://cstheory.stackexchange.com/questions/36767/can-elementary-affine-logic-be-used-as-the-core-type-system-of-a-practical-progr">Elementary Affine Logic can be used as the core type system of a practical programming language</a>. The accepted answer argues that, yes, although such language would be awkward to use because you can not iterate over terms that were themselves produced as the result of an iteration. EAL calculus is compatible with Lamping's abstract algorithm because, due to its stratification condition, substitution doesn't alter the level of the substituted term. As such, by using the label approach to mark fan nodes with their levels, and only duplicating terms of higher levels, we'll never have an unsound reduction. If we, though, add recursion in the form of recursive let-bindings, then this argument shouldn't be affected at all. Take the infinite list of ones, for example:</p>

<pre><code>ones = λcons. λnil. (cons 1 ones)
</code></pre>

<p>This term doesn't duplicate λ-bound variables and, as such, doesn't require boxes at all. It can be seen as no different than writing a very huge list at the level 0. From the interaction net perspective, its only fan-node is pointing downwards, i.e., it is not pointing upwards towards the variable slot of a λ-node, so it obviously can't interact with a fan-node with the same label coming from a different duplication process. Am I wrong in concluding that, thus, extending the EAL calculus with mutually recursive <code>let</code> shouldn't make it incompatible with the label approach of optimal reduction?</p>

CC BY-SA 4.0
2019-02-21T05:11:04.090Z
My advice to make progress here is to exercise tons of examples until you gain an intuition what will happen in each of them (or find the counter-example you asked for). Then try to formulate the intuition into a proof or if you'll find it challenging post the examples and your findings in a new question. That will demonstrate your due diligence, move the work that has to be done to you from the readers that you ask for help. Hopefully this will also prevent negative comments from some knowledgeable readers that otherwise might help you :)
Łukasz Lew
CC BY-SA 4.0
2019-02-21T12:27:11.240Z
@ŁukaszLew Just to be sure, from your comment you mean that you & others felt I didn't put enough work on the question? If that's the case, thanks for letting me know, I can delete it as I definitely don't want to sound demanding. But note I've been exploring this language for years and believe that is the case. You're right I never tried to write an actual proof, though. This is because I'm really bad with handwritten proofs (to be honest I don't get them) and I don't have an implementation of it in Agda or similar. I think I can try doing that now though. What do you think?
MaiaVictor
CC BY-SA 4.0
2019-02-21T19:13:36.903Z
Hey Victor, I can only present my own opinion, I don't know about others. If I were to start working on solving the problem you presented. I start looking at more examples of let-recursive definitions and how they translate to graphs and why do the copy operation never escapes. Then whether that still is the case in mutually recursive definitions. Then I'd start looking at graphs where to copy operator does escape and think why these are not examples of recursive let definitions. If I'm stuck I'd select most illustrative examples and show them asking for more guidance.
Łukasz Lew
CC BY-SA 4.0
2019-02-21T19:16:50.043Z
Also I think asking incomplete question is better than not asking it at all ! You definitely shouldn't be deleting anything. I'm enjoying this interaction. All I wanted to say is how I think the question can be improved to match the standards of some of the other members of our community.
Łukasz Lew
CC BY-SA 4.0
2019-02-21T19:39:14.567Z
@ŁukaszLew I see, I appreciate your inputs and I see where you're getting at. I can definitely improve this question's quality, but I'll need some time for that. I'm right now implementing both EAL calculus and the abstract algorithm in Agda (something I should definitely have done already!).
MaiaVictor
<lambda-calculus><interaction-nets>
Extending EAL with recursion makes it incompatible with the abstract algorithm?
MaiaVictor
# Extending EAL with recursion makes it incompatible with the abstract algorithm?

(Asked by: username_0 on 2019-02-20)

A few years ago, I've asked if Elementary Affine Logic can be used as the core type system of a practical programming language. The accepted answer argues that, yes, although such language would be awkward to use because you can not iterate over terms that were themselves produced as the result of an iteration. EAL calculus is compatible with Lamping's abstract algorithm because, due to its stratification condition, substitution doesn't alter the level of the substituted term. As such, by using the label approach to mark fan nodes with their levels, and only duplicating terms of higher levels, we'll never have an unsound reduction. If we, though, add recursion in the form of recursive let-bindings, then this argument shouldn't be affected at all. Take the infinite list of ones, for example:
ones = λcons. λnil. (cons 1 ones)

This term doesn't duplicate λ-bound variables and, as such, doesn't require boxes at all. It can be seen as no different than writing a very huge list at the level 0. From the interaction net perspective, its only fan-node is pointing downwards, i.e., it is not pointing upwards towards the variable slot of a λ-node, so it obviously can't interact with a fan-node with the same label coming from a different duplication process. Am I wrong in concluding that, thus, extending the EAL calculus with mutually recursive let shouldn't make it incompatible with the label approach of optimal reduction?

**Tags:** lambda-calculus, interaction-nets

> **Comments:**
> **username_1**: My advice to make progress here is to exercise tons of examples until you gain an intuition what will happen in each of them (or find the counter-example you asked for). Then try to formulate the intuition into a proof or if you'll find it challenging post the examples and your findings in a new question. That will demonstrate your due diligence, move the work that has to be done to you from the readers that you ask for help. Hopefully this will also prevent negative comments from some knowledgeable readers that otherwise might help you :)  
> **username_0**: @ŁukaszLew Just to be sure, from your comment you mean that you & others felt I didn't put enough work on the question? If that's the case, thanks for letting me know, I can delete it as I definitely don't want to sound demanding. But note I've been exploring this language for years and believe that is the case. You're right I never tried to write an actual proof, though. This is because I'm really bad with handwritten proofs (to be honest I don't get them) and I don't have an implementation of it in Agda or similar. I think I can try doing that now though. What do you think?  
> **username_1**: Hey Victor, I can only present my own opinion, I don't know about others. If I were to start working on solving the problem you presented. I start looking at more examples of let-recursive definitions and how they translate to graphs and why do the copy operation never escapes. Then whether that still is the case in mutually recursive definitions. Then I'd start looking at graphs where to copy operator does escape and think why these are not examples of recursive let definitions. If I'm stuck I'd select most illustrative examples and show them asking for more guidance.  
> **username_1**: Also I think asking incomplete question is better than not asking it at all ! You definitely shouldn't be deleting anything. I'm enjoying this interaction. All I wanted to say is how I think the question can be improved to match the standards of some of the other members of our community.  
> **username_0**: @ŁukaszLew I see, I appreciate your inputs and I see where you're getting at. I can definitely improve this question's quality, but I'll need some time for that. I'm right now implementing both EAL calculus and the abstract algorithm in Agda (something I should definitely have done already!).  

---

## 1 answers

### Answer by username_1 on 2019-02-21. Score: 1

The term that you gave does have one duplication, i.e.: ones is used in the body and returned in form of a free variable. The following example illustrates the same effect but is smaller:
loop = λ_. loop

To make the graph structure clear, let's make sure that each identifier is used exactly twice (_ represents connected erasing node):
C[loop, loop_rec] = λ[_, loop_rec]

EAL gives you termination proof if you can stratify all the terms. I don't see how you can stratify this one.
If the level of loop_rec is $n$ then the level of whole λ is also $n$. And after the contraction the level of both loop and loop_rec should be $n-1$ which gives you contradiction.
On the other hand you are right that this copy can't escape the definition (assuming 1 and cons are closed), so it is equal to an actual infinite list. Yet I don't see how to generalize this into an argument about arbitrary recursive let statements.

> **Comments:**
> **username_1**: I'm not familiar what persistent upwards and downwards mean. I ignored that part of your description. I'm my experiments nodes could go through 'wiring' that would change their apparent direction, so 'upward/downward' distinction wasn't really useful for me so far. Perhaps some photos of hand drawn graphs would be illuminating to explain your intuitions.  

---

