Source/Packages

Std.List

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

317 lines21 declarations13.5 KiBSHA-256 0d04bb5f90d2

def · lines 295–317

stdListNaturalEqual

Full file
Structural equality of two lists of naturals: same length, same elements in the same order. The first list is eliminated into a FUNCTION of the second, so the recursion walks both spines together. A proof about two computed lists states this closed verdict rather than an equation between them: an equation between two lists built by the same builder is compared symbolically first (the builders' element functions, under a binder), which costs far more than computing them (Proof.CheckedHMMATile's instance words: 580 s against 34 s).
295def stdListNaturalEqual =
296  (lambda unrestricted expected : (family StdList Nat) .
297    unrestricted actual : (family StdList Nat) .
298    app
299      (eliminate
300        StdList
301        (lambda unrestricted current : (family StdList Nat) .
302          pi unrestricted other : (family StdList Nat) . family StdBool)
303        expected
304        (branch StdListEmpty .
305          lambda unrestricted other : (family StdList Nat) . stdListIsEmpty Nat other)
306        (branch StdListCons head tail induction .
307          lambda unrestricted other : (family StdList Nat) .
308          eliminate
309            StdList
310            (lambda unrestricted current : (family StdList Nat) . family StdBool)
311            other
312            (branch StdListEmpty . constructor StdBool StdFalse)
313            (branch StdListCons otherHead otherTail otherInduction .
314              stdBoolAnd
315                (stdOrderIsEqual (stdOrderCompareNatural head otherHead))
316                (induction otherTail))))
317      actual)

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.