does not work. It works if I mark the function with abbrev.
mwe
code
importLeannamespaceHoskinsonset_optionpp.notationtrueset_optionpp.rawOnErrortrueset_optionhygienefalseset_optionmaxRecDepth1000000set_optionmaxHeartbeats1000000inductiveTp:Typewhere|natural:Tp|function:Tp→Tp→Tpnotation:max"ℕ"=>Tp.naturalinfixr:70"⇒"=>Tp.functionexample:Tp:=ℕ⇒ℕinductiveTpEnv:Typewhere|empty:TpEnv|extend:TpEnv→Tp→TpEnvnotation:max"∅"=>TpEnv.emptyinfixl:50"▷"=>TpEnv.extendexample:TpEnv:=∅▷ℕ⇒ℕ▷ℕinfix:40"∋"=>lookupinductivelookup:TpEnv→Tp→Typewhere|stop:----------------Γ▷A∋A|pop:Γ∋B----------------→Γ▷A∋BderivingReprprefix:90"S"=>lookup.popnotation:max"Z"=>lookup.stopinfix:40"⊢"=>terminductiveterm:TpEnv→Tp→Typewhere|var:Γ∋A----------→Γ⊢A|lambda:Γ▷A⊢B-----------→Γ⊢A⇒B|application:Γ⊢A⇒B→Γ⊢A--------→Γ⊢B|zero:--------Γ⊢ℕ|succ:Γ⊢ℕ--------→Γ⊢ℕ|case:Γ⊢ℕ→Γ⊢A→Γ▷ℕ⊢A---------------→Γ⊢A|mu:Γ▷A⊢A--------------→Γ⊢AderivingReprprefix:90"#"=>term.varprefix:50"ƛ"=>term.lambdainfixl:70"⬝"=>term.applicationnotation:max"o"=>term.zeropostfix:80"+1"=>term.succnotation:max"switch"=>term.caseprefix:50"μ"=>term.mudefsuc_c:Γ⊢ℕ⇒ℕ:=ƛ(#Z+1)defrmap(ΓΔ:TpEnv):Type:=∀{A:Tp},(Γ∋A)→(Δ∋A)defsmap(ΓΔ:TpEnv):Type:=∀{A:Tp},(Γ∋A)→(Δ⊢A)deftmap(ΓΔ:TpEnv):Type:=∀{A:Tp},(Γ⊢A)→(Δ⊢A)infix:30"→ʳ"=>rmapinfix:30"→ˢ"=>smapinfix:30"→ᵗ"=>tmapdefren_ext{ΓΔ:TpEnv}{A:Tp}(ρ:Γ→ʳΔ):(Γ▷A→ʳΔ▷A)|_,Z=>Z|_,Sx=>S(ρx)defren{ΓΔ:TpEnv}(ρ:Γ→ʳΔ):Γ→ᵗΔ|_,(#x)=>#(ρx)|_,(ƛN)=>ƛ(ren(ren_extρ)N)|_,(L⬝M)=>renρL⬝renρM|_,o=>o|_,M+1=>renρM+1|_,switchLMN=>switch(renρL)(renρM)(ren(ren_extρ)N)|_,μN=>μ(ren(ren_extρ)N)deflift{Γ:TpEnv}{A:Tp}:Γ→ᵗΓ▷A:=ren(funx=>Sx)defsub_ext{ΓΔ:TpEnv}{A:Tp}(σ:Γ→ˢΔ):(Γ▷A→ˢΔ▷A)|_,Z=>#Z|_,Sx=>lift(σx)defsub{ΓΔ:TpEnv}(σ:Γ→ˢΔ):Γ→ᵗΔ|_,(#x)=>σx|_,(ƛN)=>ƛ(sub(sub_extσ)N)|_,(L⬝M)=>subσL⬝subσM|_,o=>o|_,M+1=>subσM+1|_,switchLMN=>switch(subσL)(subσM)(sub(sub_extσ)N)|_,μN=>μ(sub(sub_extσ)N)defsigma_0(M:Γ⊢A):Γ▷A→ˢΓ|_,Z=>M|_,Sx=>#xdefsubst{Γ:TpEnv}{AB:Tp}(N:Γ▷A⊢B)(M:Γ⊢A):Γ⊢B:=sub(sigma_0M)Nexample:subst(ƛ(#SZ⬝(#SZ⬝#Z)))suc_c=(ƛ(suc_c⬝(suc_c⬝#Z)):∅⊢ℕ⇒ℕ):=rflinductiveValue:Γ⊢A→Typewhere|lambda:Value(ƛN)|zero:Valueo|succ:ValueV→Value(V+1)derivingReprinductivereduce:Γ⊢A→Γ⊢A→Typewhere|xi_app_1:reduceLL'→reduce(L⬝M)(L'⬝M)|xi_app_2:ValueV→reduceMM'→reduce(V⬝M)(V⬝M')|beta:ValueW→reduce((ƛN)⬝W)(substNW)|xi_succ:reduceMM'→reduce(M+1)(M'+1)|xi_case:reduceLL'→reduce(switchLMN)(switchL'MN)|beta_zero:reduce(switchoMN)M|beta_succ:ValueV→reduce(switch(V+1)MN)(substNV)|beta_mu:reduce(μN)(substN(μN))derivingRepropenreduceinfix:20"~>"=>reduceinductiveProgress:Γ⊢A→Typewhere|step:(M~>N)→ProgressM|done:ValueV→ProgressVderivingRepropenProgressdefprogress:∀(M:∅⊢A),ProgressM|(#x)=>bycontradiction|(ƛN)=>doneValue.lambda|(L⬝M)=>matchprogressLwith|stepL_to_L'=>step(xi_app_1L_to_L')|donev=>matchprogressMwith|stepM_to_M'=>step(xi_app_2vM_to_M')|donew=>matchvwith|Value.lambda=>step(betaw)|o=>doneValue.zero|(M+1)=>matchprogressMwith|stepM_to_M'=>step(xi_succM_to_M')|donev=>done(Value.succv)|(switchLMN)=>matchprogressLwith|stepL_to_L'=>step(xi_caseL_to_L')|donev=>matchvwith|Value.zero=>stepbeta_zero|Value.succv=>step(beta_succv)|(μN)=>stepbeta_muexample:progresso=doneValue.zero:=byrfl-- failsexample:progresso=doneValue.zero:=bydsimp[progress]-- failsexample:progresso=doneValue.zero:=byunfoldprogress;rfl-- worksexample:progresso=doneValue.zero:=bysimp[progress]-- works
If you #print progress and then #print progress._unary, you can see that it's using WellFounded.fix, so it's well-founded recursion. Definitions using well-founded recursion are irreducible.