Zulip Chat Archive
Stream: new members
Topic: free type variables in λ2 terms
rzeta0 (Jul 23 2025 at 01:23):
I'm working my way through Type Theory and Formal Proof, based in a recommendation here some months ago because I wanted to under how proof assistants like Lean work.
I'm stuck on the last exercise of Chapter 3 (second order lambda calculus). I'd welcome feedback on my attempted solution.
Exercise 3.21
Give a recursive definition for , the set of free type variables in , for an expression in or in .
Let's remind ourselves of the recursive definition for free variables in untyped λ-terms.
Definition 1.4.1 (, the set of free variables of a λ-term)
(1) (Variable)
(2) (Application)
(3) (Abstraction)
Let's also remind ourselves of the sets and .
Our recursive definition will need to cover all these cases. In the following section we'll consider each case, before rationalising the final definition.
in , the λ2 Types
Let's consider the syntax cases for λ2 types.
. These are type variables, for which we usually use lower case greek symbols, eg . In this case the type variable is free, and so $$$$FTV(α)=\{α\}$$$$
. These are arrow types between other type variables, for example . In this case the free type variables are those in the "from" and "to" expressions. So $$$$FTV(M→N)=FTV(M) \cup FTV(N)$$$$
. These are the abstractions over a single type variable. An example is . In this case, the abstracted variable is bound, not free, and so $$$$FTV(Πα:*.M) = FTV(M) \setminus \{α\}$$$$
in , the Pre-Typed λ2 Terms
Let's now consider the syntax cases for the pre-typed λ2-terms.
. This is the simple case of a single term variable annotated with a type, eg . These variables are pre-typed, and so the expression has no type variables in it. This means $$$$FTV(x)=\emptyset$$$$
. This is the application of one term to another, for example . Here we have $$$$FTV(MN)=FTV(M) \cup FTV(N)$$$$
. This is the application of a term to a type, for example . In this case is free, and so we have $$$$FTV(Mα)=FTV(M) \cup \{α\}$$$$
. This is an abstraction over a term variable, for example . Since is not a type variable, we have $$$$FTV(λx.M)=FTV(M)$$$$
. This is an abstraction over a type variable, for example . Here is not free, and so $$$$FTV(λα.M) = FTV(M) \setminus \{α\}$$$$
My Attempt At A Recursive Definition
Consolidating the above observations we have
(Type Variable)
(Term Variable)
(Arrow Type)
(Application)
(Abstraction)
(Abstraction)
rzeta0 (Jul 23 2025 at 01:25):
Apologies in advance if the above is a little muddled. I'm self-teaching with no degree in maths / cs.
rzeta0 (Jul 23 2025 at 01:42):
(deleted)
rzeta0 (Jul 23 2025 at 15:50):
I've updated mu original question with my latest attempt at a solution, after some sleep and a walk.
Last updated: Dec 20 2025 at 21:32 UTC