Std. Proof
(Cure Standard Library v0.37.2)
View Source
Genuine propositional-equality proofs over the inductive Std.Nat
(spec 2026-07-04-identity-type-as-inductive).
These are NOT runtime tokens. Each law is checked by the dependent
kernel: the proofs proceed by induction (match on the Nat index)
and close each case with reflexive or rewrite, exactly the technique
Agda's Data.Nat.Properties uses. plus is Std.Nat.plus, whose
definition the kernel unfolds during conversion, so plus(Z, Z)
reduces to Z and the reflexive cases type-check.
The previous version of this module returned the :cure_refl atom
from Equivalent(...)-shaped signatures whose propositions were either
vacuous (Equivalent(Int, n, n)) or unstated (a "commutativity" law with
return type Equivalent(Int, a, a)). Those tokens carried no propositional
content; the laws below actually prove what they claim.
Examples
use Std.Proof
plus_zero_right(n) # : Equivalent(Nat, plus(n, Z), n)
plus_comm(m, n) # : Equivalent(Nat, plus(m, n), plus(n, m))
Summary
Functions
Associativity of addition, (a + b) + c = a + (b + c).
Commutativity of addition, m + n = n + m. Induction on m, using
plus_zero_right for the base case and plus_succ_right together
with the inductive hypothesis for the successor case.
Binary congruence for Nat addition.
Left-commutativity of addition, a + (b + c) = b + (a + c).
m + S(n) = S(m + n). Induction on m; the successor case pushes
the S outward via the inductive hypothesis.
n + 0 = n. Induction on n: the Z case is reflexive, and the
S case rewrites by the inductive hypothesis before closing on
reflexive(S(k)).
Functions
fn plus_assoc(a: Nat, b: Nat, c: Nat) -> Equivalent(Nat, plus(plus(a, b), c), plus(a, plus(b, c)))
Associativity of addition, (a + b) + c = a + (b + c).
fn plus_comm(m: Nat, n: Nat) -> Equivalent(Nat, plus(m, n), plus(n, m))
Commutativity of addition, m + n = n + m. Induction on m, using
plus_zero_right for the base case and plus_succ_right together
with the inductive hypothesis for the successor case.
fn plus_cong(a1: Nat, a2: Nat, b1: Nat, b2: Nat, p: Equivalent(Nat, a1, a2), q: Equivalent(Nat, b1, b2)) -> Equivalent(Nat, plus(a1, b1), plus(a2, b2))
Binary congruence for Nat addition.
fn plus_left_comm(a: Nat, b: Nat, c: Nat) -> Equivalent(Nat, plus(a, plus(b, c)), plus(b, plus(a, c)))
Left-commutativity of addition, a + (b + c) = b + (a + c).
fn plus_succ_right(m: Nat, n: Nat) -> Equivalent(Nat, plus(m, S(n)), S(plus(m, n)))
m + S(n) = S(m + n). Induction on m; the successor case pushes
the S outward via the inductive hypothesis.
fn plus_zero_right(n: Nat) -> Equivalent(Nat, plus(n, Z), n)
n + 0 = n. Induction on n: the Z case is reflexive, and the
S case rewrites by the inductive hypothesis before closing on
reflexive(S(k)).