Problem 623
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
In particular don't post any code fragments or results.
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
-
hexadoodle
- Posts: 10
- Joined: Tue Jan 16, 2018 9:27 pm
Problem 623
I think I mostly understand this...
Why is (Lx.(Lx.x)) not listed as a possibility in the table?
Would ((Lx.x)(Lx.x)) be alpha-equivalent to ((Lx.x)(Ly.y))?
Why is (Lx.(Lx.x)) not listed as a possibility in the table?
Would ((Lx.x)(Lx.x)) be alpha-equivalent to ((Lx.x)(Ly.y))?
-
traxex
- Posts: 66
- Joined: Thu Oct 19, 2017 1:30 pm
Re: Problem 623
It's alpha-equivalent to (Lx.(Ly.y)).hexadoodle wrote: Sun Mar 25, 2018 7:55 pm Why is (Lx.(Lx.x)) not listed as a possibility in the table?
Yes.hexadoodle wrote: Sun Mar 25, 2018 7:55 pm Would ((Lx.x)(Lx.x)) be alpha-equivalent to ((Lx.x)(Ly.y))?
Technically, everyone is full of himself.
-
hexadoodle
- Posts: 10
- Joined: Tue Jan 16, 2018 9:27 pm
Re: Problem 623
Hmm. And yet the problem says "(λx.(λy.(xy))) and (λx.(λx.(xx))) are not α-equivalent." To me it seems like a term with two abstractions, each of a different variable, would be considered distinct from a version of the same "structure" in which the variables are all the same. I'm having trouble identifying where I'm going wrong.traxex wrote: Sun Mar 25, 2018 8:00 pmIt's alpha-equivalent to (Lx.(Ly.y)).hexadoodle wrote: Sun Mar 25, 2018 7:55 pm Why is (Lx.(Lx.x)) not listed as a possibility in the table?
Also, is an expression with nested abstractions using the same variable (such as (Lx.(Lx.x)) ) even valid at all? (Disregarding the fact that it's alpha-equivalent to something else valid.)
-
traxex
- Posts: 66
- Joined: Thu Oct 19, 2017 1:30 pm
Re: Problem 623
Scoping in lambda calculus works very much like in C-family languages.
Consider these two lines of pseudo-code:
They are not equivalent, because the first one prints "foo bar" and the second one prints "bar bar".
Now consider these:
Both lines print "bar bar", so they are equivalent. Hiding the outer variable does not change the meaning in this case.
The lambda term (Lx.(Lx.x)) is valid, just like hiding variables in C is allowed.
Consider these two lines of pseudo-code:
Code: Select all
{ string x = "foo"; { string y = "bar"; print(x, y); } }
{ string x = "foo"; { string x = "bar"; print(x, x); } }
Now consider these:
Code: Select all
{ string x = "foo"; { string y = "bar"; print(y, y); } }
{ string x = "foo"; { string x = "bar"; print(x, x); } }
The lambda term (Lx.(Lx.x)) is valid, just like hiding variables in C is allowed.
Technically, everyone is full of himself.
-
Sardaai
- Posts: 3
- Joined: Mon Mar 26, 2018 12:21 am
Re: Problem 623
The description of variables as "non-empty alphabetical strings" implies that variables can be more than one letter, but this could create some syntactic ambiguity. E.g. in "(λa.(λc.(λab.(λbc.(abc)))))", the "(abc)" could be interpreted as the application of "ab" to "c", or as the application of "a" to "bc".
This isn't relevant at lower symbol caps, but it should become relevant when the cap is high enough that more than 26 symbols can be defined. How should we handle this? Should we assume that there are inherent delimiters around each variable name?
This isn't relevant at lower symbol caps, but it should become relevant when the cap is high enough that more than 26 symbols can be defined. How should we handle this? Should we assume that there are inherent delimiters around each variable name?
-
traxex
- Posts: 66
- Joined: Thu Oct 19, 2017 1:30 pm
Re: Problem 623
Yes, that is one way to put it. The $\Lambda(35)$ value given is also big enough to confirm that two adjacent variables do not cause ambiguity in parsing.Sardaai wrote: Mon Mar 26, 2018 12:29 am Should we assume that there are inherent delimiters around each variable name?
Technically, everyone is full of himself.
-
jpaulson
- Posts: 17
- Joined: Thu Dec 05, 2013 7:46 am
Re: Problem 623
I share Sardaai's concern, and I don't think traxex's reply resolves the ambiguity (what is the interpretation of Sardaai's example lambda term?)
Also, are variables allowed to contain uppercase characters? (i.e. I find "alphabetical string" ambiguous)
Also, are variables allowed to contain uppercase characters? (i.e. I find "alphabetical string" ambiguous)

-
MuthuVeerappanR
- Posts: 539
- Joined: Sun Mar 22, 2015 2:30 pm
- Location: India
- Contact:
Re: Problem 623
Can you please give the lambda-calculus representation for each of the four lines of code?traxex wrote: Sun Mar 25, 2018 9:45 pm Scoping in lambda calculus works very much like in C-family languages.
Consider these two lines of pseudo-code:
They are not equivalent, because the first one prints "foo bar" and the second one prints "bar bar".Code: Select all
{ string x = "foo"; { string y = "bar"; print(x, y); } } { string x = "foo"; { string x = "bar"; print(x, x); } }
Now consider these:
Both lines print "bar bar", so they are equivalent. Hiding the outer variable does not change the meaning in this case.Code: Select all
{ string x = "foo"; { string y = "bar"; print(y, y); } } { string x = "foo"; { string x = "bar"; print(x, x); } }
The lambda term (Lx.(Lx.x)) is valid, just like hiding variables in C is allowed.

It is not knowledge, but the act of learning, not possession but the act of getting there, which grants the greatest enjoyment.
-
mclo
- Posts: 178
- Joined: Fri Oct 21, 2016 6:53 pm
Re: Problem 623
@Sardaai/jpaulson
For the purpose of this problem, variables are considered to be single symbols/tokens, at the same level of parenthesis/dots/etc. The syntactic representation of a $\lambda$-term is a sequence of symbols, not characters. Hence the ambiguity $(\lambda ab.(\lambda c. (abc)))$ does not really arise because the description of the term should be the symbol sequence
Finally, the precise format of alphabetical strings (lowercase, uppercase, CamelCase, snake_case, etc...) does not matter since you can rename all variables to fit your favorite format.
For the purpose of this problem, variables are considered to be single symbols/tokens, at the same level of parenthesis/dots/etc. The syntactic representation of a $\lambda$-term is a sequence of symbols, not characters. Hence the ambiguity $(\lambda ab.(\lambda c. (abc)))$ does not really arise because the description of the term should be the symbol sequence
"(","$\lambda$","ab",".","(","$\lambda$","c",".","(","ab","c",")",")",")"
Alternatively, one way to achieve the same result with character strings is to consider that there is a delimiting space between the members of an application: $(\lambda ab. (\lambda c. (ab\;\!c)))$Finally, the precise format of alphabetical strings (lowercase, uppercase, CamelCase, snake_case, etc...) does not matter since you can rename all variables to fit your favorite format.
-
traxex
- Posts: 66
- Joined: Thu Oct 19, 2017 1:30 pm
Re: Problem 623
They were meant to explain why $(\lambda x{.}(\lambda y{.}(xy)))$ and $(\lambda x{.}(\lambda x{.}(xx)))$ are not $\alpha$-equivalent, but $(\lambda x{.}(\lambda y{.}(yy)))$ and $(\lambda x{.}(\lambda x{.}(xx)))$ are.MuthuVeerappanR wrote: Mon Mar 26, 2018 6:48 am Can you please give the lambda-calculus representation for each of the four lines of code?
But perhaps I only caused more confusion.
Technically, everyone is full of himself.
-
hexadoodle
- Posts: 10
- Joined: Tue Jan 16, 2018 9:27 pm
Re: Problem 623
Forgot to say, your explanation helped me understand the problem. Thanks!traxex wrote: Mon Mar 26, 2018 10:49 amThey were meant to explain why $(\lambda x{.}(\lambda y{.}(xy)))$ and $(\lambda x{.}(\lambda x{.}(xx)))$ are not $\alpha$-equivalent, but $(\lambda x{.}(\lambda y{.}(yy)))$ and $(\lambda x{.}(\lambda x{.}(xx)))$ are.MuthuVeerappanR wrote: Mon Mar 26, 2018 6:48 am Can you please give the lambda-calculus representation for each of the four lines of code?
But perhaps I only caused more confusion.
-
Sardaai
- Posts: 3
- Joined: Mon Mar 26, 2018 12:21 am
Re: Problem 623
Hm... In many contexts, "symbols" and "characters" have equivalent meaning, which is why I and others were confused. I feel like this could be made clearer in the problem description.mclo wrote: Mon Mar 26, 2018 7:33 am The syntactic representation of a $\lambda$-term is a sequence of symbols, not characters.
Also, $\Lambda(n)$ is described as the number of distinct $\alpha$-equivalent lambda-terms that can be written using at most $n$ symbols, but it's actually the number of such symbols which are closed. Even though this is obvious from the sample values of $\Lambda$, the description should still be corrected in the problem.
- RobertStanforth
- Administrator
- Posts: 2666
- Joined: Mon Dec 30, 2013 11:25 pm
Re: Problem 623
Thank you for pointing that out, Sardaai. The description has now been updated to ask for closed lambda-terms.Sardaai wrote: Mon Mar 26, 2018 7:47 pm Also, $\Lambda(n)$ is described as the number of distinct $\alpha$-equivalent lambda-terms that can be written using at most $n$ symbols, but it's actually the number of such symbols which are closed.
-
jpaulson
- Posts: 17
- Joined: Thu Dec 05, 2013 7:46 am
Re: Problem 623
I missed that variables were atomic "symbols". Thank you!mclo wrote: Mon Mar 26, 2018 7:33 am @Sardaai/jpaulson
For the purpose of this problem, variables are considered to be single symbols/tokens, at the same level of parenthesis/dots/etc. The syntactic representation of a $\lambda$-term is a sequence of symbols, not characters. Hence the ambiguity $(\lambda ab.(\lambda c. (abc)))$ does not really arise because the description of the term should be the symbol sequence"(","$\lambda$","ab",".","(","$\lambda$","c",".","(","ab","c",")",")",")"Alternatively, one way to achieve the same result with character strings is to consider that there is a delimiting space between the members of an application: $(\lambda ab. (\lambda c. (ab\;\!c)))$
Finally, the precise format of alphabetical strings (lowercase, uppercase, CamelCase, snake_case, etc...) does not matter since you can rename all variables to fit your favorite format.

-
jpaulson
- Posts: 17
- Joined: Thu Dec 05, 2013 7:46 am
Re: Problem 623
Roughly speaking: (lambda calculus doesn't have "print" or builtin strings, but this is the equivalent scoping):MuthuVeerappanR wrote: Mon Mar 26, 2018 6:48 amCan you please give the lambda-calculus representation for each of the four lines of code?traxex wrote: Sun Mar 25, 2018 9:45 pm Scoping in lambda calculus works very much like in C-family languages.
Consider these two lines of pseudo-code:
They are not equivalent, because the first one prints "foo bar" and the second one prints "bar bar".Code: Select all
{ string x = "foo"; { string y = "bar"; print(x, y); } } { string x = "foo"; { string x = "bar"; print(x, x); } }
Now consider these:
Both lines print "bar bar", so they are equivalent. Hiding the outer variable does not change the meaning in this case.Code: Select all
{ string x = "foo"; { string y = "bar"; print(y, y); } } { string x = "foo"; { string x = "bar"; print(x, x); } }
The lambda term (Lx.(Lx.x)) is valid, just like hiding variables in C is allowed.
(Lfoo.(Lbar.(foo bar)))
(Lfoo.(Lbar.(bar bar)))
(Lfoo.(Lbar.(bar bar)))
(Lfoo.(Lbar.(bar bar)))
A more exact translation of the first line would be (assuming we have a "print" function defined elsewhere):
((Lx.(Ly.((print x) y))) "foo") "bar"

-
MuthuVeerappanR
- Posts: 539
- Joined: Sun Mar 22, 2015 2:30 pm
- Location: India
- Contact:
Re: Problem 623
Thank you all.. Solved it...
For someone who didn't study computer science, the whole problem seemed very convoluted but fortunately the structure of the problem was quite simple..
EDIT:ed after seeing the point in hk's reply. I'm not saying it should be hidden all the time. I tried suggesting hiding the number of solvers until a particular user have solved it. But PE being a Educational site rather than a competitive site refutes everything. Thanks.
For someone who didn't study computer science, the whole problem seemed very convoluted but fortunately the structure of the problem was quite simple..
Expand
EDIT:ed after seeing the point in hk's reply. I'm not saying it should be hidden all the time. I tried suggesting hiding the number of solvers until a particular user have solved it. But PE being a Educational site rather than a competitive site refutes everything. Thanks.
Last edited by MuthuVeerappanR on Tue Mar 27, 2018 11:53 am, edited 2 times in total.

It is not knowledge, but the act of learning, not possession but the act of getting there, which grants the greatest enjoyment.
- hk
- Administrator
- Posts: 12832
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: Problem 623
First of all: your post is very much off-topic: this forum is meant for clarifications if you have trouble understanding a problem.MuthuVeerappanR wrote: Tue Mar 27, 2018 8:04 am Thank you all.. Solved it...
For someone who didn't study computer science, the whole problem seemed very convoluted but fortunately the structure of the problem was quite simple..
One more thing.. Should the number of solvers be hidden until we solve a problem? At least recently for me, I'm taking hints from the rate at which the problem is solved.. Problem 623 (View Problem) and Problem 619 (View Problem) are two problem I can quote which I thought were hard for me but the number of solvers hinted me that there is a much easier way.. Eventually I solved both which I don't think I would've had I not been aware of number.
Just a thought...
Secondly: Project Euler isn't in the first place a competitive environment but an educational one. I don't think your suggestion is helpful for the general Project Euler member: the solve count is a good measure which problems to try.
And even if it were mainly a competitive environment:
Knowledge of the times performed by your fellow competitors is also important with many sports, like e.g. skating.
I heard many of our medal winners at the games in PyeongChang (and we had a lot of them) for e.g. long track speed skating talk about the times that were reached by their competitors that had done the tasks before them.
I still see some of them sitting on the bench not daring to look what some of the later ones got for timings.

War ruins the life and health of untold numbers of innocent children.
- RobertStanforth
- Administrator
- Posts: 2666
- Joined: Mon Dec 30, 2013 11:25 pm
Re: Problem 623
With regard to the earlier comments in this thread about characters versus symbols for variable names, the problem description has now been amended to specify that a variable is a single letter (drawn from an infinite alphabet). This does not change the answer but should avoid some confusion.
Thank you to those who pointed out the potential ambiguity.
Thank you to those who pointed out the potential ambiguity.
-
pjt33
- Posts: 140
- Joined: Mon Oct 06, 2008 6:14 pm
Re: Problem 623
It would improve the clarity of the question to also update the text before the table of the 20 closed lambda-terms which contribute to $\Lambda(15)$.RobertStanforth wrote: Mon Mar 26, 2018 10:57 pmThank you for pointing that out, Sardaai. The description has now been updated to ask for closed lambda-terms.Sardaai wrote: Mon Mar 26, 2018 7:47 pm Also, $\Lambda(n)$ is described as the number of distinct $\alpha$-equivalent lambda-terms that can be written using at most $n$ symbols, but it's actually the number of such symbols which are closed.