Std.Proof.WellFounded

View source →

Kernel-checked well-founded recursion via the accessibility predicate Acc.

Rather than widening the trusted kernel with bespoke measure-termination rules, well-founded recursion is encoded as structural recursion over Acc(a, rel, x) — the standard Martin-Löf / Agda / Lean encoding.

Every proof and recursion combinator in this module is checked by the dependent kernel and certified total by Cure's size-change checker.

Functions

  • # fn absurd_acc(y: Nat, void: Empty) -> Acc(Nat, nat_lt, y)

    Eliminate Empty into any Acc(Nat, nat_lt, y).

  • # fn absurd_measure_acc(a: Type, measure: Function(a, Nat), x: a, void: Empty) -> Acc(a, measure_lt(a, measure), x)

    Eliminate Empty into any Acc(a, measure_lt(a, measure), x).

  • # fn lt_implies_succ_le(a: Nat, b: Nat, proof: IsLessThan(a, b)) -> IsLessThanOrEqual(S(a), b)

    a < b implies S(a) <= b.

  • # fn lt_le_trans(a: Nat, b: Nat, c: Nat, hab: IsLessThan(a, b), hbc: IsLessThanOrEqual(b, c)) -> IsLessThan(a, c)

    Mixed transitivity: a < b and b <= c imply a < c.

  • # fn lt_succ_implies_le(y: Nat, k: Nat, proof: IsLessThan(y, S(k))) -> IsLessThanOrEqual(y, k)

    y < S(k) implies y <= k.

  • # fn lt_zero_absurd(y: Nat) -> Function(IsLessThan(y, Z), Empty)

    Nothing is strictly less than zero.

  • # fn lt_zero_acc(y: Nat, proof: IsLessThan(y, Z)) -> Acc(Nat, nat_lt, y)

    Nothing is strictly less than zero, so any IsLessThan(y, Z) discharges Acc.

  • # fn measure_lt(a: Type, measure: Function(a, Nat), left: a, right: a) -> Type

    Measure-induced strict order: u precedes v when measure(u) < measure(v).

  • # fn measure_wf(a: Type, measure: Function(a, Nat), x: a) -> Acc(a, measure_lt(a, measure), x)

    Well-foundedness of any Nat-valued measure measure : (a) -> Nat.

  • # fn measure_wf_aux(a: Type, measure: Function(a, Nat), bound: Nat) -> (x: a) -> Function(IsLessThan(measure(x), bound), Acc(a, measure_lt(a, measure), x))

    Every x with measure(x) < bound is accessible under measure_lt(a, measure).

  • # fn measure_wf_inv(a: Type, measure: Function(a, Nat), k: Nat, x: a, proof: IsLessThan(measure(x), S(k)), y: a, hy: IsLessThan(measure(y), measure(x))) -> Acc(a, measure_lt(a, measure), y)
  • # fn measure_wf_rec(a: Type, motive: Function(a, Type), measure: Function(a, Nat), step: (x: a) -> Function((y: a) -> Function(IsLessThan(measure(y), measure(x)), motive(y)), motive(x)), x: a) -> motive(x)

    Well-founded recursion over any type a driven by a Nat measure measure : (a) -> Nat.

  • # fn measure_wf_step(a: Type, measure: Function(a, Nat), k: Nat, x: a, proof: IsLessThan(measure(x), S(k))) -> Acc(a, measure_lt(a, measure), x)
  • # fn measure_wf_zero(a: Type, measure: Function(a, Nat), x: a, proof: IsLessThan(measure(x), Z)) -> Acc(a, measure_lt(a, measure), x)
  • # fn nat_lt(left: Nat, right: Nat) -> Type

    First-class relation wrapper around Std.Proof.Math.IsLessThan.

  • # fn nat_lt_wf(n: Nat) -> Acc(Nat, nat_lt, n)

    Well-foundedness of strict less-than (nat_lt / IsLessThan) on Nat.

  • # fn nat_lt_wf_aux(bound: Nat) -> (y: Nat) -> Function(IsLessThan(y, bound), Acc(Nat, nat_lt, y))

    Every natural number strictly below bound is accessible under nat_lt.

  • # fn nat_lt_wf_step(k: Nat, y: Nat, proof: IsLessThan(y, S(k))) -> Acc(Nat, nat_lt, y)
  • # fn nat_wf_rec(motive: Function(Nat, Type), step: (n: Nat) -> Function((m: Nat) -> Function(IsLessThan(m, n), motive(m)), motive(n)), n: Nat) -> motive(n)

    Well-founded recursion over Nat using IsLessThan (strong / course-of-values induction and non-structural certified algorithms).

  • # fn wf_rec(a: Type, rel: Function(a, a, Type), motive: Function(a, Type), step: (x: a) -> Function((y: a) -> Function(rel(y, x), motive(y)), motive(x)), x: a, acc: Acc(a, rel, x)) -> motive(x)

    Generic well-founded recursion eliminator over an accessibility witness.