-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve Beta-Normal Eta-Long Form #60
Comments
Not urgent since Gabe is doing eta-expansion on their end, however we absolutely do want this for dreamcoder-identicalness |
Studying the current cases where dreamcoder fails in EtaLongVisitor: Here's a crash example:
It turns out the line So more generally I believe that this means when you try to unify some function type with its list of arguments you should from left to right across the arguments because things like The solution is to add some code right before for i,x in enumerate(xs):
self.context.unify(
ft.functionArguments()[i],
x.infer().instantiateMutable(self.context))
ft = ft.applyMutable(self.context) I'd love someone to review this because I have not actually worked with applyMutable() instantiateMutable() or unify() before. I'll push this to the laps repo |
de-escalating from critical. Might be nice to add but is nontrivialded |
Actually this is not correct. Well, it's correct except that if you think about how top down synthesis works you always unify the RETURN type of each primitive with your hole, so you DO always unify the return type and you never go left to right across the arguments. |
This should be considerably easier now that we have types :) we just need to include the types in compression ofc |
see also my notes |
Beta-normal eta-long form
This is the form that dreamcoder programs are in.
beta-normal
: there are no redexes aka no unapplied lambdas aka nothing of the form(lambda body) arg
eta-long
:map double xs
isn't allowed becausedouble
has an arrow type yet is not syntactically lambda and is not syntactically immediately applied to any arguments. Instead this should be eta-expanded to becomemap (lambda (double $0)) xs
. Specifically the eta-expansion ofe
is(lambda (upshift(e) $0))
. For an arity-2 expression eta-expansion would look like(lambda (lambda (e $1 $0)))
which you can get by just applying eta expansion twice in a row, specifically look for a term thats an arrow type but isnt applied to anything and eta-expand it. So we getfoo
->(lambda (foo $0))
->(lambda (lambda (foo $1 $0)))
where in the second eta expansion we didnt do another eta expansion offoo
since it was already applied to an arg, but we saw thatfoo $0
is itself an arrow type so we eta expanded it.If you're familiar with dreamcoders topdown search that's an easy way to think about this. Since it never produces unapplied lambdas it is clearly maintains
beta-normal
form, and since it autofills lambdas whenever it encounters an arrow-typed hole this maintainseta-long
form.Maintaining eta-long form during compression
(double 5)
showed up in the original set of programs and we abstracteddouble
we'd end up withdouble
as an invention argument, but since double is an arrow type it should be written like(lambda (double $0))
when used as an argumentTodo think about:
(lam (lam foo $1 $0))
and you abstract it at various points?foo $1 $0
will create a term with free variables that will need 2 lambdas before it's closedlam lam foo $1 $0
as an argument? I guess if you actually had something likefoo 5 7
instead though the abstractions would have to be different. I don't know exactly but worth thinking this all throughThe text was updated successfully, but these errors were encountered: