Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lemma 3.5 — Subject reduction

Open
AehligSchwichtenberg2002V2.lemma_3_5

by kmehltretter82 · Nov 20, 2026 · Mathlib 0df444a (Lean v4.33.1)

implicit-complexitylambda-calculustype-theory

If Γ\GammaΓ types ttt at τ\tauτ and ttt reduces to t′t^\primet′ in one step, then the same context types t′t^\primet′ at τ\tauτ.

Preamble
import Definitions.Def_AehligSchwichtenberg2002V2_Syntax
Formal statement
namespace AehligSchwichtenberg2002V2

theorem lemma_3_5 {Γ : Context} {t t' : Term} {τ : Ty}
    (ht : HasType Γ t τ) (hred : RedStep t t') :
    HasType Γ t' τ := by sorry

end AehligSchwichtenberg2002V2
Source
Klaus Aehlig and Helmut Schwichtenberg (2002), A syntactical analysis of non-size-increasing polynomial time computation, Lemma 3.5. https://arxiv.org/abs/cs/0011037
Read-back

What the Lean code literally says, in plain math · OpenAI Codex (GPT-6)

For every context Γ\GammaΓ, terms t,t′t,t't,t′ and type AAA, if Γ⊢t:A\Gamma\vdash t:AΓ⊢t:A and a single step takes ttt to t′t't′, then Γ⊢t′:A\Gamma\vdash t':AΓ⊢t′:A. The context may be empty, and the target may admit further steps. The types are generated by ◊\Diamond◊, Bool\mathsf{Bool}Bool, arrows A⊸BA\multimap BA⊸B, tensors A⊗BA\otimes BA⊗B, products A×BA\times BA×B, and lists L(A)\mathsf L(A)L(A). A variable is a pair of a natural-number identifier and a type. Equality of variables compares both entries. The terms are variables, constants, abstractions λx.r\lambda x.rλx.r, pairs ⟨r,s⟩\langle r,s\rangle⟨r,s⟩, applications rsrsrs, and braces {r}\{r\}{r}. Successive applications associate to the left and arrow chains associate to the right. The constants tt\mathsf{tt}tt and ff\mathsf{ff}ff have declared type Bool\mathsf{Bool}Bool. For every type AAA, the constants nilA\mathsf{nil}_AnilA​ and consA\mathsf{cons}_AconsA​ have declared types L(A)\mathsf L(A)L(A) and ◊⊸A⊸L(A)⊸L(A)\Diamond\multimap A\multimap\mathsf L(A)\multimap\mathsf L(A)◊⊸A⊸L(A)⊸L(A). For all types A,BA,BA,B, tpA,B\mathsf{tp}_{A,B}tpA,B​ has declared type A⊸B⊸(A⊗B)A\multimap B\multimap(A\otimes B)A⊸B⊸(A⊗B). Contexts are lists of variables. A context is a union of two operand contexts if each variable belongs to the result exactly when it belongs to at least one operand. A disjoint union additionally requires that the operands have no common variable. These relations permit arbitrary ordering and repetitions within a context. The typing relation Γ⊢r:A\Gamma\vdash r:AΓ⊢r:A is generated by the variable rule in any context containing that variable, and the constant rule in any context with the declared constant type. An abstraction λx.r\lambda x.rλx.r has type A⊸BA\multimap BA⊸B in Γ\GammaΓ if xxx has declared type AAA and rrr has type BBB in a union of Γ\GammaΓ and the singleton list [x][x][x]. An application rsrsrs has type BBB in a disjoint union of contexts typing rrr at A⊸BA\multimap BA⊸B and sss at AAA. The pair ⟨r,s⟩\langle r,s\rangle⟨r,s⟩ has type A×BA\times BA×B if rrr has type AAA and sss has type BBB in the same context. A term rrr of product type A×BA\times BA×B gives applications r ttr\,\mathsf{tt}rtt and r ffr\,\mathsf{ff}rff of types AAA and BBB in its context. If rrr has Boolean type and both sss and uuu have type AAA in a shared context disjoint from the context of rrr, then r⟨s,u⟩r\langle s,u\rangler⟨s,u⟩ has type AAA in their disjoint union. For distinct variables x,yx,yx,y of types A,BA,BA,B, respectively, r(λx.λy.s)r(\lambda x.\lambda y.s)r(λx.λy.s) has type CCC in a disjoint union of a context typing rrr at A⊗BA\otimes BA⊗B and a context Δ\DeltaΔ disjoint from [x,y][x,y][x,y], provided sss has type CCC in a union of Δ\DeltaΔ and [x,y][x,y][x,y]. If rrr has type L(A)\mathsf L(A)L(A) and hhh has type ◊⊸A⊸R⊸R\Diamond\multimap A\multimap R\multimap R◊⊸A⊸R⊸R in the empty context, r{h}r\{h\}r{h} has type R⊸RR\multimap RR⊸R in the context of rrr. The optional list entry count CCC returns 000 on any nilA\mathsf{nil}_AnilA​, returns 1+C(l)1+C(l)1+C(l) on consA d a l\mathsf{cons}_A\,d\,a\,lconsA​dal if C(l)C(l)C(l) returns a number, and is undefined otherwise. It looks at the rightmost tail argument of each fully applied cons\mathsf{cons}cons, permits any parameters AAA on the constructors along that chain, and ignores the contents of the other two arguments. The free occurrences of a variable term are its singleton list and a constant contributes none. An abstraction filters the occurrences of its binder from those of its body, a pair or application concatenates the two occurrence lists from left to right, and braces use the occurrence list of their contents. The list FV⁡(r)\operatorname{FV}(r)FV(r) retains the first occurrence of each distinct variable in the resulting list. For a term rrr, M(r)M(r)M(r) is the maximum of 000 and every variable identifier in rrr, including the identifiers of abstraction binders. For variables x,yx,yx,y and a term rrr, renaming free xxx to yyy in rrr replaces each variable node equal to xxx by yyy, leaves constants as they are and recurses into pairs, applications and braces. At an abstraction with binder xxx it returns that abstraction as it is. At other abstractions it keeps the binder and recurses into the body, which permits the new occurrences of yyy to be bound by an existing binder. For a natural bound bbb, term rrr, variable xxx and replacement term sss, the substitution auxiliary function replaces a variable node by sss exactly when its variable equals xxx, preserves constants, and recurses with bound bbb into both children of pairs and applications and into the contents of braces. At a binder vvv it returns the whole abstraction if v=xv=xv=x. If v≠xv\ne xv=x and vvv occurs free in sss, it gives the binder a new identifier b′=1+max⁡(b,M(body),M(s),id⁡(x))b'=1+\max(b,M(\text{body}),M(s),\operatorname{id}(x))b′=1+max(b,M(body),M(s),id(x)) and keeps its type. It renames free occurrences of vvv in the body to the new variable, and recurses on the renamed body with bound b′b'b′. In the remaining case it preserves the binder and recurses on the body with bound max⁡(b,id⁡(v))\max(b,\operatorname{id}(v))max(b,id(v)). Write r[x:=s]r[x:=s]r[x:=s] for substitution of sss for xxx in rrr, starting the auxiliary function with bound 000. A binder may be freshened by this operation even when xxx has no free occurrence in its body. For terms r,t,sr,t,sr,t,s and variables x,yx,yx,y, the two-variable substitution returns (r[x:=t])[y:=s](r[x:=t])[y:=s](r[x:=t])[y:=s] if yyy is absent from the free occurrences of ttt. If yyy occurs free in ttt, it chooses y′y'y′ of yyy's type and identifier 1+max⁡(M(r),M(t),M(s),id⁡(x),id⁡(y))1+\max(M(r),M(t),M(s),\operatorname{id}(x),\operatorname{id}(y))1+max(M(r),M(t),M(s),id(x),id(y)). It renames free yyy to y′y'y′ in rrr, substitutes ttt for xxx in that result, then substitutes sss for y′y'y′. This function accepts any x,yx,yx,y, including x=yx=yx=y. The direct conversions are (λx.r)s⇝r[x:=s](\lambda x.r)s\leadsto r[x:=s](λx.r)s⇝r[x:=s], ⟨r,s⟩ tt⇝r\langle r,s\rangle\,\mathsf{tt}\leadsto r⟨r,s⟩tt⇝r, ⟨r,s⟩ ff⇝s\langle r,s\rangle\,\mathsf{ff}\leadsto s⟨r,s⟩ff⇝s, tt⟨r,s⟩⇝r\mathsf{tt}\langle r,s\rangle\leadsto rtt⟨r,s⟩⇝r and ff⟨r,s⟩⇝s\mathsf{ff}\langle r,s\rangle\leadsto sff⟨r,s⟩⇝s. They also include tpA,B t s (λx.λy.r)\mathsf{tp}_{A,B}\,t\,s\,(\lambda x.\lambda y.r)tpA,B​ts(λx.λy.r) converting to the two-variable substitution in rrr of ttt for xxx and sss for yyy, for distinct x,yx,yx,y with respective types A,BA,BA,B. The iteration conversions are nilA {h} s⇝s\mathsf{nil}_A\,\{h\}\,s\leadsto snilA​{h}s⇝s and consA d a l {h} s⇝h d a (l {h} s)\mathsf{cons}_A\,d\,a\,l\,\{h\}\,s\leadsto h\,d\,a\,(l\,\{h\}\,s)consA​dal{h}s⇝hda(l{h}s), with the latter requiring C(l)C(l)C(l) to return a number. The term arguments in these patterns range over raw terms. A single step r→sr\to sr→s performs one direct conversion at the root or at a subterm reached by descending through any number of application nodes, on either side of each application.

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me