Source/Packages

Std.Natural

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

376 lines51 declarations16.0 KiBSHA-256 7e7128c5e781

def · lines 317–324

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.)
317def naturalFailuresBelow =
318  (lambda unrestricted count : Nat . unrestricted f : (pi unrestricted index : Nat . Nat) .
319    nat-eliminate
320      (lambda unrestricted current : Nat . Nat)
321      0
322      (lambda unrestricted predecessor : Nat . unrestricted induction : Nat .
323        naturalAdd (naturalIsZero (f predecessor)) induction)
324      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.