lean4-htt/tests/lean/run/issue8939wf.lean
Joachim Breitner 6995f280b4
fix: unfold abstracted proofs before processing recursion (#9191)
This PR lets the equation compiler unfold abstracted proofs again if
they would otherwise hide recursive calls.
    
This fixes #8939.

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2025-07-25 08:00:57 +00:00

43 lines
1.3 KiB
Text

module
/-!
variant of issue8939 with well-founded recursion
(Or is this just 8938 showing up with 8939 fixed? anwways, more tests don't hurt)
-/
public axiom g : Nat → Nat → Nat
public axiom magic_dec : f - 1 < f
set_option warn.sorry false
set_option pp.proofs true
-- set_option trace.Elab.definition.wf true
-- set_option trace.Kernel true in
@[expose] public
def ackermann_fuel : (n m : Nat) → (fuel : Nat) → (h : g n m < fuel) → Nat
| 0, m, _, _ => m+1
| n + 1, 0, f, h => ackermann_fuel n 1 (f - 1) (by sorry)
| n + 1, m + 1, f, h =>
ackermann_fuel n (ackermann_fuel (n + 1) m (f - 1) (by sorry)) (f - 1) (by as_aux_lemma => sorry)
termination_by _ _ fuel => fuel
decreasing_by
-- At some point, using as_aux_lemma in decreasing_by did not work
as_aux_lemma => sorry
as_aux_lemma => sorry
as_aux_lemma => sorry
done
def ackermann_fuel'' : (n m : Nat) → (fuel : Nat) → (h : g n m < fuel) → Nat
| 0, m, _, _ => m+1
| n + 1, 0, f, h => ackermann_fuel'' n 1 (f - 1) (by sorry)
| n + 1, m + 1, f, h =>
ackermann_fuel'' n (ackermann_fuel'' (n + 1) m (f - 1) (by sorry)) (f - 1) (by as_aux_lemma => sorry)
termination_by _ _ fuel => fuel
decreasing_by
as_aux_lemma => sorry
as_aux_lemma => sorry
as_aux_lemma => sorry
done
#print ackermann_fuel''._unary