Source/Packages

Std.Natural

packages/foundation/standard/src/Std/Natural.alpha

335 lines48 declarations13.5 KiBSHA-256 0a0af2339e6a

def · lines 276–283

naturalFailuresBelow

Full file
How many of f 0, f 1, ..., f (count - 1) are zero: a plain fold over a closed count, so the checker runs it as a strict loop -- one cell at a time, each forgotten once counted. (The first formulation nested each cell's select inside the previous one; a verdict of 40 cells that each run a program kept every earlier cell alive: 51 s against 7.6 s, two thirds of it garbage collection.)
276def naturalFailuresBelow =
277  (lambda unrestricted count : Nat . unrestricted f : (pi unrestricted index : Nat . Nat) .
278    nat-eliminate
279      (lambda unrestricted current : Nat . Nat)
280      0
281      (lambda unrestricted predecessor : Nat . unrestricted induction : Nat .
282        naturalAdd (naturalIsZero (f predecessor)) induction)
283      count)

The compiler supplied declaration spans and resolved links from this source snapshot. This page does not assert that this file belongs to a checked closure.