Giter Site home page Giter Site logo

Wrong reduction about bend HOT 11 OPEN

notoria avatar notoria commented on July 29, 2024
Wrong reduction

from bend.

Comments (11)

developedby avatar developedby commented on July 29, 2024 1

Note that all the reductions are correct, just not in the form that you expected

from bend.

developedby avatar developedby commented on July 29, 2024

1: The result is the eta-reduced form of the expected.

2 and 3:
The inner lambdas are combinators, which are converted into lazy references to top-level functions and so didn't get executed.
I understand that for the main function this is generally not what users want. This is being tracked here #424

from bend.

notoria avatar notoria commented on July 29, 2024

Sometimes eta-reduction isn't done:

Main = λa λb (a ((λc c b)))  |  Result: λa λb (a b)

and:

Main = λa λb (a b)  |  Result: λa a

Which one would be the right answer?

from bend.

developedby avatar developedby commented on July 29, 2024

We eta-reduce the input but not the output. But they're equivalent in effect so both are correct

from bend.

notoria avatar notoria commented on July 29, 2024

Missing some beta-reduction:

Main = (λa a λa (λb b a))  |  Result: λa (λb b a)

and:

Main = λa (λb b a)  |  Result: λa a

It's not clear why the reduction is missing.

from bend.

developedby avatar developedby commented on July 29, 2024

2 and 3: The inner lambdas are combinators, which are converted into lazy references to top-level functions and so didn't get executed. I understand that for the main function this is generally not what users want. This is being tracked here #424

from bend.

notoria avatar notoria commented on July 29, 2024

I have an unexpected result:

Main = λa (λb (λc b b) λb (b (a b)))  |  Result: λa λb (b (a *))

While I expected something like λa λb (b (a b)).

Is this the same issue?

from bend.

developedby avatar developedby commented on July 29, 2024

No, thats a different problem. Your program duplicates a function that duplicates a value, which is currently not valid in Bend.
In some cases this is caught during runtime and the program panics, but we don't know of any way to detect all cases besides type checking.

from bend.

developedby avatar developedby commented on July 29, 2024

With #548, it should be much rarer to trigger the second and third cases of your original comment

from bend.

notoria avatar notoria commented on July 29, 2024

Indeed it seems to be gone.

Without duplication:

Main = λa λb (λc b (a λc c))  |  Result: ((λa a, *), λb b)  |  Expected: λa λb b

from bend.

developedby avatar developedby commented on July 29, 2024

Indeed it seems to be gone.

Without duplication:

Main = λa λb (λc b (a λc c))  |  Result: ((λa a, *), λb b)  |  Expected: λa λb b

Conversion from HVM to Bend can have more than one possible interpretation.
The resulting net, in HVM syntax is (((a a) *) (b b))
((λa a, *), λb b) is one valid form of the result.
Another equally valid result would be let * = (a λc c); λa λb b, which is the one you're expecting.

Currently the heuristic for deciding if a node is a lambda or a tuple is very simplistic and will give some unexpected results.

from bend.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.