Proof authoring theory

Conversions

A conversion rewrites a term and proves that the rewrite is an equality, possibly under a guard. Combinators build conversions from smaller ones, as in Isabelle's and HOL Light's conversions [Paulson 1983; Harrison 2009], with guards and budgets explicit (the architecture note, section 25.3).

Definition C-1 (conversion). A conversion is a procedure that, given a context \(\Gamma\) and a term \(t\) usable there, either fails or returns a term \(t'\), a guard \(g\), and a kernel judgment \(\Gamma \vdash \sem g \to t = t'\) (or \(\Gamma \vdash t = t'\) when \(g = \top\)).

Theorem C-1 (the combinators preserve validity). If the component conversions satisfy Definition C-1, so do:

Combinator Result Proof of the equation
then(a, b) \(t \to t' \to t''\), guard \(\mathrm{All}(g_a, g_b)\) assume both guards, imp_elim each, eq_trans, export
or_else(a, b) \(a\)'s result, else \(b\)'s the one that succeeded
try_(a) \(a\)'s result, else \(t\) itself with \(\top\) eq_refl
repeat(a) \(a\) applied until it fails or returns its input, within the budget then folded; the guards conjoined
under_head(a_1, \dots, a_n) each argument of a spine rewritten eq_apply with eq_refl for the head (DR-3), guards conjoined

Proof. Each row is a kernel derivation from its components' judgments, under the conjunction of their guards (assumed, used by and_left and and_right, and exported). \(\square\)

Theorem C-2 (rewriting under a binder). Let \(a\) be a conversion that, for the body \(b(x)\) of \(\lambda x.\, b(x)\) opened with a fresh local \(x\), returns \(b'(x)\) with guard \(g(x)\). Then under_binder(a) returns \(\lambda x.\, b'(x)\) with the guard \(\forall x.\, \sem{g(x)}\), and the judgment \(\Gamma \vdash (\forall x.\, \sem{g(x)}) \to (\lambda x.\, b) = (\lambda x.\, b')\).

Proof. In the context \(\Gamma, h : \forall y.\, \sem{g(y)}, x\), the local \(x\) is innermost; forall_elim(h, x) gives \(\sem{g(x)}\), which discharges the component's guard, giving \(b(x) = b'(x)\); eq_abstract(x, ·) (the ξ-rule, whose side condition holds since \(x\) is innermost) gives \((\lambda x.\, b) = (\lambda x.\, b')\) in \(\Gamma, h\); imp_intro(h) gives the result. \(\square\)

A guard that mentions the bound variable therefore never escapes as a free assumption: it is universally closed, as the note requires. A caller that knows a weaker sufficient guard (for example, a domain restriction) proves the implication to \(\forall x.\, \sem{g(x)}\) separately.

Proposition C-3 (guards of conversions normalize). Replacing a conversion's guard by its normal form (Definition G-2) keeps Definition C-1, using the implication \(\sem{\operatorname{norm}(g)} \to \sem g\) of Theorem G-1. \(\square\)

Proposition C-4 (relations other than equality). For a relation \(R\) other than equality, under_head needs a theorem that the head respects \(R\), and then a composition theorem; without them the combinators refuse. The library implements equality only. \(\square\)

judgment v1.0.0 for Mojo 1.2 · Apache License 2.0 with LLVM Exceptions · Source on GitHub