Proof library & interchange theory

Theory interpretations

The kernel's home theories let a result be reused in any theory that contains its declarations. A result about one session's constants cannot be reused in another session, whose constants are different declarations. An interpretation bridges that gap [Farmer, Guttman and Thayer 1992].

Definition IN-1 (interpretation). Let \(S\) and \(T\) be theories that both include a common base theory \(B\) (for example, a profile). An interpretation \(\iota : S \to T\) over \(B\) maps:

  • each type constructor of \(S\) outside \(B\), with arity \(n\), to a type of \(T\) with \(n\) designated type variables;
  • each constant \(c\) of \(S\) outside \(B\) to a closed term \(\iota(c)\) of \(T\) whose type is the translation of \(c\)'s type;
  • each axiom of \(S\) outside \(B\), and the equation of each definition, to a theorem of \(T\) whose statement is the translation of the axiom or equation;

and is the identity on \(B\). It extends homomorphically to types, terms, and propositions; the translation of a term is rebuilt canonically in \(T\).

Theorem IN-1 (interpretation lemma). If \(\Gamma \vdash A\) is derivable in \(S\), then \(\iota(\Gamma) \vdash \iota(A)\) is derivable in \(T\), provided that \(S\)'s ACU declarations and literal kinds outside \(B\) are mapped to ACU instances and literal kinds of \(T\) with corresponding units and bindings, or that the derivation is first freed of conversion steps by the kernel's Theorem C-12.

Proof. Translate the derivation rule by rule, as in the proof of the kernel's Theorem M-5(2): each rule instance of \(S\) translates to a rule instance of \(T\), because the translation commutes with substitution, type instantiation, and the canonical constructors; a use of an axiom or definition equation of \(S\) becomes a use of the theorem \(\iota\) assigns to it; uses of \(B\)'s declarations are unchanged. A conversion step's identifications are instances of \(S\)'s declared ACU and literal laws (the kernel's Theorem C-10): with the correspondence assumed, their translations are identifications of \(T\); without it, Theorem C-12 first replaces them by inference steps citing the laws, which translate like axioms. \(\square\)

Algorithm IN-2 (reuse by translation). To reuse a result of \(S\) in \(T\): translate its derivation through \(\iota\), replacing each citation of a theorem by the fact \(\iota\) assigns it, and check the translated derivation in \(T\).

Theorem IN-3. If Algorithm IN-2's check succeeds, the result is a checked judgment of \(\iota\) of the source statement in \(T\).

Proof. Every step of the translated derivation is checked by \(T\)'s checker, and the result's statement is compared with the translated statement. \(\square\)

Whether the translated derivation checks depends on its steps being translatable: rule steps and theorem citations always are; a conversion by an ACU or literal declaration of \(S\) without a corresponding declaration of \(T\) is eliminated first (Theorem C-12) and translated as inference steps. Theorem IN-1 guarantees that a translated derivation exists; Algorithm IN-2 finds it when the derivation is translatable, and reports the first step that is not.

The typical use: a lemma proved in one CAS session about its symbols \(x, y\) is reused in another session with symbols \(u, v\), by the interpretation \(x \mapsto u\), \(y \mapsto v\) over the scalar profile, whose axioms are shared and need no mapping.

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