Kind/book/A.zero.kind2
Victor Taelin d059c82c1f ADTs & match - complete
ADTs can be defined with the syntax:

data Vector T (len: Nat)
| cons (len: Nat) (head: T) (tail: (Vector T len)) : (Vector T (Nat.succ len))
| nil : (Vector T Nat.zero)

Which will convert to the equivalent inductive λ-encoding (via self).

Pattern-matching has the syntax:

match x = expr with (a: A) (b: B) ... {
  ctr0: ret0
  ctr1: ret1
}: motive

The 'with' syntax is used to explicitly move values down the cases,
crating lambdas for them. This linearizes them (which avoids cloning)
and specializes their type w.r.t. the matched value, for proving.

We also allow a shorthand for top-level definitions, as:

foo (a: A) (b: B) ... : R =
  body

This will auto-add lambdas before 'body'. If 'body' is a pattern-match,
the lambdas will be automatically moved down, so this has the effect of
linearizing top-level args, without needing explicit 'with' annotations.
2024-03-13 15:05:52 -03:00

3 lines
42 B
Plaintext

A.zero : A =
~λP λs λz (z λTλt(t))