I have been learning Haskell for a number of months now and am now trying to understand the underpinning $\lambda$-calculus, but I have run into a bit of a mental block! How would I go about writing a $λ$-term corresponding to an infinite list (for example $[0, 1, 2, \dots]$)?
2026-03-28 20:03:29.1774728209
Infinite lists in Lambda calculus....
985 Views Asked by user156182 https://math.techqa.club/user/user156182/detail At
1
There are 1 best solutions below
Related Questions in DISCRETE-MATHEMATICS
- What is (mathematically) minimal computer architecture to run any software
- What's $P(A_1\cap A_2\cap A_3\cap A_4) $?
- The function $f(x)=$ ${b^mx^m}\over(1-bx)^{m+1}$ is a generating function of the sequence $\{a_n\}$. Find the coefficient of $x^n$
- Given is $2$ dimensional random variable $(X,Y)$ with table. Determine the correlation between $X$ and $Y$
- Given a function, prove that it's injective
- Surjective function proof
- How to find image of a function
- Find the truth value of... empty set?
- Solving discrete recursion equations with min in the equation
- Determine the marginal distributions of $(T_1, T_2)$
Related Questions in COMPUTER-SCIENCE
- What is (mathematically) minimal computer architecture to run any software
- Simultaneously multiple copies of each of a set of substrings of a string.
- Ackermann Function for $(2,n)$
- Algorithm for diophantine equation
- transforming sigma notation into harmonic series. CLRS A.1-2
- Show that if f(n) is O(g(n) and d(n) is O(h(n)), then f(n) + d(n) is O(g(n) + h(n))
- Show that $2^{n+1}$ is $O(2^n)$
- If true, prove (01+0)*0 = 0(10+0)*, else provide a counter example.
- Minimum number of edges that have to be removed in a graph to make it acyclic
- Mathematics for Computer Science, Problem 2.6. WOP
Related Questions in COMPUTABILITY
- Are all infinite sets of indices of computable functions extensional?
- Simple applications of forcing in recursion theory?
- Proof of "Extension" for Rice's Theorem
- How to interpret Matiyasevich–Robinson–Davis–Putnam in term of algebraic geometry or geometry?
- Does there exist a weakly increasing cofinal function $\kappa \to \kappa$ strictly below the diagonal?
- Why isn't the idea of "an oracle for the halting problem" considered self-contradictory?
- is there any set membership of which is not decidable in polynomial time but semidecidable in P?
- The elementary theory of finite commutative rings
- Is there any universal algorithm converting grammar to Turing Machine?
- Is the sign of a real number decidable?
Related Questions in LAMBDA-CALCULUS
- Finding a term $s$ such that for all terms $t$, $st$ = $ss$
- 'Logically symmetric' expressions in lambda calculus
- Who introduced the Kite to Smullyan's combinator birds?
- Can F be diverging in "forall M FM = F"?
- First-Order Logic: Simplifying $\exists x. (P(x))\,(\lambda y.see(y,x))$
- Encoding of booleans in lambda calculus
- parentheses in free and bound variable in lambda calculus
- Define lambda calculus encoding for boolean implication (⇒)
- Beta reduction in Lambda-Calculus
- Normative vs applicative order in reduction in the Lambda Calculus
Trending Questions
- Induction on the number of equations
- How to convince a math teacher of this simple and obvious fact?
- Find $E[XY|Y+Z=1 ]$
- Refuting the Anti-Cantor Cranks
- What are imaginary numbers?
- Determine the adjoint of $\tilde Q(x)$ for $\tilde Q(x)u:=(Qu)(x)$ where $Q:U→L^2(Ω,ℝ^d$ is a Hilbert-Schmidt operator and $U$ is a Hilbert space
- Why does this innovative method of subtraction from a third grader always work?
- How do we know that the number $1$ is not equal to the number $-1$?
- What are the Implications of having VΩ as a model for a theory?
- Defining a Galois Field based on primitive element versus polynomial?
- Can't find the relationship between two columns of numbers. Please Help
- Is computer science a branch of mathematics?
- Is there a bijection of $\mathbb{R}^n$ with itself such that the forward map is connected but the inverse is not?
- Identification of a quadrilateral as a trapezoid, rectangle, or square
- Generator of inertia group in function field extension
Popular # Hahtags
second-order-logic
numerical-methods
puzzle
logic
probability
number-theory
winding-number
real-analysis
integration
calculus
complex-analysis
sequences-and-series
proof-writing
set-theory
functions
homotopy-theory
elementary-number-theory
ordinary-differential-equations
circles
derivatives
game-theory
definite-integrals
elementary-set-theory
limits
multivariable-calculus
geometry
algebraic-number-theory
proof-verification
partial-derivative
algebra-precalculus
Popular Questions
- What is the integral of 1/x?
- How many squares actually ARE in this picture? Is this a trick question with no right answer?
- Is a matrix multiplied with its transpose something special?
- What is the difference between independent and mutually exclusive events?
- Visually stunning math concepts which are easy to explain
- taylor series of $\ln(1+x)$?
- How to tell if a set of vectors spans a space?
- Calculus question taking derivative to find horizontal tangent line
- How to determine if a function is one-to-one?
- Determine if vectors are linearly independent
- What does it mean to have a determinant equal to zero?
- Is this Batman equation for real?
- How to find perpendicular vector to another vector?
- How to find mean and median from histogram
- How many sides does a circle have?
The infinite list $[0, 1, 2, \dots]$ satisfies the following identity in Haskell (see here): $$\tag{1} [0,1,2, \dots] = 0 : \mathtt{map} \, (+1) \, [0,1,2,\dots] $$ where $(+1)$ is the function computing the successor of an integer, and $:$ is the function that appends an element to the front of a list. Indeed, $$\mathtt{map} \, (+1) \, [0,1,2,\dots] = [(+1) \, 0, (+1) \, 1, (+1) \, 2, \dots] = [1, 2, 3, \dots]$$ and clearly $$0 : [1, 2, 3, \dots] = [0,1, 2, \dots]$$ therefore, Identity $(1)$ holds.
Can Identity $(1)$ be expressed in the $\lambda$-calculus? Yes! Indeed:
Apparently, the only missing $\lambda$-term to represent $(1)$ in the $\lambda$-calculus is $[0,1,2,\dots]$, that is, the $\lambda$-term that we want to define! Let us denote it by $X$, as an unknown variable in a mathematical equation. Thus, $(1)$ can be rewritten as an equation in the $\lambda$-calculus $$\tag{2} X =_\beta \mathsf{cons} \, \underline{0} \, (\mathsf{map} \, \mathsf{succ} \, X)$$ where $=_\beta$ is $\beta$-equivalence, that is (roughly), the unoriented version of $\beta$-reduction. If we can solve Equation $(2)$ (i.e. we find a $\lambda$-term $X$ such that $(2)$ holds), then such a $\lambda$-term represents the infinite list $[0,1,2,\dots]$. Since $(\lambda x.N)x \to_\beta N$ for any $\lambda$-term $N$, Equation $(2)$ can be equivalently rewritten as $$\tag{3} X =_\beta (\lambda x. \mathsf{cons} \, \underline{0} \, (\mathsf{map} \, \mathsf{succ} \, x)) X $$ Equation $(3)$ is of interest because it says that the $\lambda$-term $X$ we are looking for is a fixed point of the $\lambda$-term $\lambda x. \mathsf{cons} \, \underline{0} \, (\mathsf{map} \, \mathsf{succ} \, x)$. This is where the fixpoint combinator $Y$ of the $\lambda$-calculus becomes relevant, as correctly suggested by @MJD in his comment. Indeed, $Y = \lambda f. (\lambda x. f(xx))(\lambda x. f(xx))$ is a "magic" $\lambda$-term such that, for every $\lambda$-term $M$, $$\tag{4} YM =_\beta M(YM)$$ that is, $YM$ is a fixed point of any $\lambda$-term $M$. Who cares? From Identity $(4)$, replace the generic $M$ with the $\lambda$-term $\lambda x. \mathsf{cons} \, \underline{0} \, (\mathsf{map} \, \mathsf{succ} \, x)$, so the following identity holds: $$ Y(\lambda x. \mathsf{cons} \, \underline{0} \, (\mathsf{map} \, \mathsf{succ} \, x)) =_\beta (\lambda x. \mathsf{cons} \, \underline{0} \, (\mathsf{map} \, \mathsf{succ} \, x)) \big( Y (\lambda x. \mathsf{cons} \, \underline{0} \, (\mathsf{map} \, \mathsf{succ} \, x))\big) $$ This shows that $X = Y (\lambda x. \mathsf{cons} \, \underline{0} \, (\mathsf{map} \, \mathsf{succ} \, x))$ is a solution of Equation $(3)$: just rewrite $(3)$ by replacing $X$ with $Y (\lambda x. \mathsf{cons} \, \underline{0} \, (\mathsf{map} \, \mathsf{succ} \, x))$. And a solution of Equation $(3)$, and hence of Equation $(2)$, is what we are looking for!
Summing up, the infinite list $[0,1,2,\dots]$ is represented in the $\lambda$-calculus by the $\lambda$-term: $$ Y (\lambda x. \mathsf{cons} \, \underline{0} \, (\mathsf{map} \, \mathsf{succ} \, x))$$
Digression. There are different ways to define the $\lambda$-terms $\mathsf{cons}$ and $\mathsf{map}$, depending on the way lists are encoded in the $\lambda$-calculus.
According to the encoding of lists presented here, a list $[N_1, \dots, N_k]$ is represented by the $\lambda$-term $$\lambda c. \lambda n.c N_1 (c N_2 (\dots(c N_k n)\dots))$$ and the definitions of $\mathsf{cons}$ and $\mathsf{map}$ above work for this encoding.
An alternative encoding of lists is presented here, it requires other (just slightly different) definitions of $\mathsf{cons}$ and $\mathsf{map}$. Note that $Y (\lambda x. \mathsf{cons} \, \underline{0} \, (\mathsf{map} \, \mathsf{succ} \, x))$ always represents the infinite list $[0, 1, 2,\dots]$, provided that $\mathsf{cons}$ and $\mathsf{map}$ are suitable for the encoding of lists under consideration.