Solutions to all twelve numbered subparts of the University of Oxford computer science Finals paper held on 4 June 2015. Question 2(d) has a wording issue: its literal impossibility claim is false, and the solution gives the exact condition for a valid typing judgment.[ref]
Choose all auxiliary bound variables fresh for the free variables of ; alpha equivalence permits this. The operation is composition of lambda terms, so expand its definition and use beta reduction:
The two lambda terms have the same reduct, up to alpha equivalence, hence they are related by beta equivalence:
No eta conversion is needed for this associativity calculation.
Write for the I combinator, and choose outside the free variables of . Both orders of composition of lambda terms first give the same lambda abstraction by beta reduction:
The freshness condition is exactly the side condition for eta conversion, which contracts to . Therefore
Here eta conversion matters: a free variable is already in beta-normal form, as is , and beta equivalence alone does not equate them.
The argument order in is a cyclic permutation. Undo it by rotating in the other direction. For , choose the lambda term
Use fresh bound variables throughout. Substituting for the first argument of and then performing beta reduction gives
Indeed, the arguments received by are , so its last argument moves back to the front. Apply eta conversion successively, starting with the innermost lambda abstraction. At each step the bound variable being removed is absent from the preceding expression. Thus the last expression is related to by beta-eta equivalence, and consequently
For the induction needed in the next part, also compute the reverse composition of lambda terms:
So this is a two-sided inverse. The empty argument list at means ; choose . For , both displayed rotations give , which is also related to by eta conversion. These boundary cases require no exceptional inverse construction.
Use structural induction on the construction of , with the stronger induction claim that is an invertible lambda term: there is a lambda term satisfying both
The base constructor has exactly the two-sided inverse proved in part (c). Strengthening the claim is useful because the inductive construction needs inverses of its constituent lambda terms in both orders.
For the inductive constructor, let be the two-sided inverse supplied for . Thus, for a fresh variable , beta-eta equivalence gives
For , define
This lambda term reverses the cyclic permutation and applies the appropriate inverse to each argument. First use beta reduction to expand one order of composition of lambda terms:
For the other order, beta reduction gives
These computations close the stronger induction. For , each formula has the single argument involving and ; for , the constructor is and its inverse is . Every construction is finite, so the inverse is a finite lambda term. There is no requirement that this inverse itself belong to .
The universal typing axiom supplies for every lambda term . Use this as the argument premise of the lambda application rule. The empty typing context is consistent with , and its union with is :
Hence
The free variables of need not appear in the resulting typing context: the universal typing axiom deliberately assigns without recording them.
Choose as the domain of the new function type. Since , the assumption is consistent with and deleting leaves unchanged. The lambda abstraction rule gives
Use the universal typing axiom for , then the lambda application rule:
Therefore
The condition is about the typing context, not the free variables of . Some occurrences of in might have been hidden by a use of the universal typing axiom; the derivation above still follows the printed rules.
Begin with the variable typing judgment . Because is absent from this typing context, the lambda abstraction rule permits to have type :
Assign the entire lambda application type using the universal typing axiom, without attempting to assign a function type to . Then
Although is a free variable of the body, it is absent from its recorded typing context. Consequently the lambda abstraction rule allows any simple type for . Abstract over and then :
The side condition for holds because is absent; the side condition for holds because its recorded simple type is . Thus
The exact restriction in the ordinary simply typed lambda calculus is
Thus the unrestricted choice of available in part (c) fails. A reading of the printed sentence as asserting impossibility for every choice of is false. This issue occurs in the original PDF as well as its transcription.[ref]
To prove necessity, first observe why the ordinary rules cannot hide assumptions. Structural induction on a derivation proves
For a variable, both sides are the singleton containing that variable. For lambda application, both sides are the union of the two premise supports. For lambda abstraction, both sides delete the bound variable. There is no universal typing axiom to interrupt this equality.
Now invert the proposed derivation. Each outer lambda abstraction must have been introduced by the abstraction rule, since the other ordinary rules conclude a variable or a lambda application. The body must therefore have the typing judgment
The support equality just proved ensures that both displayed assumptions occur; consistency fixes their simple types to those specified by the outer function type. Inverting the lambda application gives a simple type for its argument and the following premises:
There is no flexibility in the supports: has the single free variable , whereas has both free variables . Invert the second lambda application. Its two premises must be
for some simple type . The variable rule is the only possible final rule for each premise. It forces and , yielding .
Conversely, suppose . The ordinary rules give
The typing contexts are consistent, so another lambda application gives the body type . Two lambda abstractions discharge and , establishing
This proves sufficiency and supplies a family of counterexamples to the literal impossibility claim. For a concrete failure of the unrestricted claim, choose and as atomic type variables. The type variable is not a function type , so no derivation exists for that fixed pair. Here the atomic type variables are fixed type expressions, rather than unknowns that one may change during type inference.
The reason for the restriction is the otherwise discarded lambda application : the ordinary rules still type-check it. Its subsequent disappearance under beta reduction does not license reversing that beta reduction while preserving every simple type of the result. The beta-normal form admits arbitrary , whereas the unreduced lambda term has the additional constraint just derived.
Take an infinite supply of variables and the two distinguished constants of combinatory logic, the K combinator and the S combinator. The combinatory logic terms are exactly the finite expressions generated by
Thus every variable and each distinguished constant is a combinatory logic term, and the application of two combinatory logic terms is a combinatory logic term. Nothing else is a combinatory logic term. Application associates to the left, so means ; it is not assumed to be associative. The I combinator can be used as the abbreviation , without adding a new primitive constant.
The basic equality is the least relation containing the two axiom schemes
for all combinatory logic terms , and closed under the rules of equational reasoning:
The final rule permits replacing equal combinatory logic terms inside either side of an application; repeated use permits replacement at any depth. Uniform substitution of combinatory logic terms for variables preserves equality, either included as a rule or proved by induction on these derivations, since the displayed axioms are schemes. No rule equating two combinatory logic terms merely because they agree after an extra argument belongs to this basic theory. Its equality is the symmetric, reflexive and transitive closure of weak combinatory reduction.
Write for the paper's bracket abstraction and for the I combinator. Prove the result by structural induction following the three clauses of bracket abstraction.
For , the rules for the S combinator and the K combinator give
If does not occur in , then substitution for leaves unchanged and
These two cases cover all variables and constants as well as applications not containing .
In the remaining case, and occurs in at least one of . The bracket abstraction clause, the rule for the S combinator, the induction hypotheses and compatibility of equality with application give
The last line is the defining application clause of substitution. Therefore
The conclusion is equality in combinatory logic; it need not be literal identity of strings. There are no binders in a combinatory logic term, so this substitution introduces no variable capture.
Again write for bracket abstraction. In combinatory logic, all variable occurrences are free variables. Under and , substitution for preserves the presence or absence of :
An existing is not replaced because ; replacing cannot introduce an because contains none. This ensures that the same clause of bracket abstraction applies before and after substitution.
Use structural induction on , respecting those clauses. If , then
because substitution leaves the S combinator, the K combinator and unchanged.
If is absent from , it is also absent from . Therefore
This includes : even when is a large application, the absence of means bracket abstraction still produces .
Finally, let with occurring in or . By the occurrence observation, also occurs in or , so the application clause applies on both sides. Apply the induction hypotheses:
Every step uses the definitions of substitution and bracket abstraction, without applying the equality axioms for the S combinator or the K combinator. Thus the result is the stronger syntactic identity
The side condition on is essential for this identity. For example, substituting for in gives , whereas , a different string.
Successive bracket abstractions are processed from the inside out: . Retain only as a temporary abbreviation for the I combinator. Since is absent from , the first bracket abstraction is
For the outer bracket abstraction, is absent from and the S combinator, while it occurs in . Hence
Substituting upward and then expanding gives the following fully bracketed string, consisting solely of the S combinator, the K combinator and parentheses:
For readability, the same result with the usual left association convention and the temporary abbreviation is
The syntactic result comes from the specified bracket abstraction algorithm. Replacing it by the shorter K combinator, despite agreement after two arguments, would not answer the requested computation. As a check using the result of part (b), applying the computed combinatory logic term to gives .

Articles by others on the same topic (0)

There are currently no matching articles.