Lectures onType Theory
ch:univalent-set-mathematics: ch:univalent-set-mathematics
appendix sectiontutorials

ch:univalent-set-mathematics: ch:univalent-set-mathematics

Exercise 210.5.

Problem and invariant. Evaluate a finite syntax of cardinal expressions. Maintain the invariant that each syntax constructor is interpreted by the corresponding natural cardinality operation.

Two representations. One can enumerate finite carriers and construct explicit bijections. The companion instead evaluates cardinalities directly. Enumeration retains the witnesses behind the chapter’s equivalences; direct evaluation makes the arithmetic clauses and their mutation tests smaller.

First complete version. Define constructors for 0, 1, natural constants, sum, product, and exponentiation. Interpret the first five by natural arithmetic and define exponentiation by structural recursion on the exponent. Add named checks for a sum, distributivity, the iterated-exponent law, and 3<23.

Observable result. The accepted corpus prints four named PASS lines and then All 4 Chapter 195 corpus cases passed.

A failing version. Replace the sum clause by its left operand. This mutation still typechecks, but the named finite-sum oracle changes and the inline test exits nonzero.

Acceptance test. Run the four commands in appendix E. Require a silent check, one passing inline test, the exact five-line run transcript, and an empty audit. Restore the accepted source after replaying the mutation and repeat all four commands.

Mathematical boundary. Natural evaluation decides only the finite syntax and cases represented by the program. Its distributivity and iterated-exponent probes are finite instances of lemma 74.49, and 3<23 is the displayed finite instance of theorem 74.51. The run neither decides equality of arbitrary cardinals nor proves either result.

Search the book

Type to search the local edition.