Logic & kernel theory

Semantics

This page gives the logic its standard set-theoretic semantics, in the style of Pitts's semantics for HOL [Gordon and Melham 1993, the chapters on the HOL logic], and proves that the kernel's calculus is sound, that the logic core and the classical axioms are consistent, and that definitions are conservative. These are the theorems on which the trust in every checked judgment rests.

The metatheory is ZFC.

Models

Definition M-1 (universe). A universe is a set \(\mathcal U\) of nonempty sets such that, for all \(X, Y \in \mathcal U\):

  1. the cartesian product \(X \times Y\) and the set \(Y^X\) of all functions from \(X\) to \(Y\) belong to \(\mathcal U\);
  2. every nonempty subset of \(X\) belongs to \(\mathcal U\);
  3. \(\mathbb B = \{0, 1\} \in \mathcal U\), and some infinite set belongs to \(\mathcal U\);
  4. there is a function \(\operatorname{ch}\) on \(\mathcal U\) with \(\operatorname{ch}(X) \in X\).

Such universes exist in ZFC: take the nonempty sets of rank below \(\omega + \omega\), with a choice function given by the axiom of choice.

Definition M-2 (interpretation). An interpretation \(M\) of a signature \(\Sigma\) in a universe \(\mathcal U\) assigns:

  • to each type constructor \(\kappa\) of arity \(n\), a function \(M(\kappa): \mathcal U^n \to \mathcal U\), with \(M(\mathsf{Prop}) = \mathbb B\);
  • to each constant \(c\) with \(m\) type parameters, for every \(\bar X \in \mathcal U^m\), an element \(M(c)(\bar X) \in \sem{\sigma_c}_{\bar\alpha_c \mapsto \bar X}\);
  • to each literal kind \(k\) and value \(v \in V_k \setminus \{0, 1\}\), an element \(M(k)(v) \in \sem{C_k}\), the denotation of the atom \(\mathsf{lit}_k(v)\). The values \(0\) and \(1\) are not atoms but the constants bound to ZERO and ONE (Definition T-7), which \(M\) interprets as constants.

Given a type valuation \(\nu: \mathcal V \to \mathcal U\), types denote sets:

\[ \sem{\alpha}_\nu = \nu(\alpha), \qquad \sem{\kappa(\bar\tau)}_\nu = M(\kappa)(\sem{\bar\tau}_\nu), \qquad \sem{\tau \to \tau'}_\nu = \sem{\tau'}_\nu^{\,\sem{\tau}_\nu}. \]

Given also a local valuation \(\rho\) with \(\rho(\ell) \in \sem{L(\ell)}_\nu\) and a binder valuation \(\eta\) with \(\eta_i \in \sem{\Delta_i}_\nu\), a well-typed term denotes an element of its type's denotation:

\[ \begin{aligned} \sem{\#i} &= \eta_i, \qquad \sem{\ell} = \rho(\ell), \qquad \sem{c[\bar\tau]} = M(c)(\sem{\bar\tau}_\nu), \qquad \sem{\mathsf{lit}_k(v)} = M(k)(v),\\ \sem{f(a_1, \dots, a_n)} &= \sem{f}(\sem{a_1})\cdots(\sem{a_n}) \quad \text{(App)},\\ \sem{c(a_1, \dots, a_n)} &= \sem{c}(\sem{a_1})\big(\sem{c(a_2, \dots, a_n)}\big) \quad \text{(ACU, } n \ge 3\text{)},\\ \sem{\lambda{:}\tau.\, b}_\eta &= \big(x \in \sem{\tau}_\nu \mapsto \sem{b}_{x \cdot \eta}\big), \qquad \sem{\mathsf{let}{:}\tau = v \;\mathsf{in}\; b}_\eta = \sem{b}_{\sem{v}_\eta \cdot \eta}. \end{aligned} \]

By Theorem T-2 every well-typed term falls under exactly one clause.

Definition M-3 (models). An interpretation \(M\) is a model of a theory \(T\) when:

  1. the logic core has its standard meaning: \(M(\mathsf{True}) = 1\), \(M(\mathsf{False}) = 0\), \(\land\), \(\lor\), \(\to\) are the Boolean operations, \(M(\mathsf{forall})(X)(f) = 1\) exactly when \(f(x) = 1\) for all \(x \in X\), and \(M(\mathsf{eq})(X)(a)(b) = 1\) exactly when \(a = b\);
  2. every definition \(c:= b\) is interpreted by its body: \(M(c)(\bar X) = \sem{b}_{\bar\alpha_c \mapsto \bar X}\), which is well defined because every type variable of \(b\) is among \(\bar\alpha_c\);
  3. every axiom \(A\) holds: \(\sem{A}_\nu = 1\) for every type valuation \(\nu\);
  4. every literal kind \(k\) denotes the canonical embedding of its values: \(M(k)(v) = \iota_M(v)\) for \(v \ne 0, 1\), where \(\iota_M\) is the map of Theorem C-11, so that every literal \(\underline v\) denotes \(\iota_M(v)\). The map exists and is unique in every interpretation satisfying \(k\)'s literal laws, so this clause adds no constraint beyond those laws (see literal kinds).

Each clause concerns one declaration and mentions only the symbols of that declaration's theory. A model of \(T\) is therefore a model of every theory \(H \sqsubseteq T\) once the symbols outside \(\Sigma(H)\) are forgotten (its reduct to \(H\)).

Definition M-4 (validity). A judgment \(\Gamma \vdash A\) is valid in \(M\) when, for every type valuation \(\nu\) and every local valuation \(\rho\) that satisfies \(\Gamma\) (each \(\rho(\ell)\) in the denotation of \(\ell\)'s type, each hypothesis of \(\Gamma\) denoting \(1\)), \(\sem{A}_{\nu,\rho} = 1\).

Semantic lemmas

Lemma M-L1 (substitution). For well-typed terms:

  1. \(\sem{b\{0:= s\}}_\eta = \sem{b}_{\sem{s}_\eta \cdot \eta}\);
  2. \(\sem{t[\ell:= s]}_\rho = \sem{t}_{\rho[\ell \mapsto \sem{s}_\rho]}\) for bound-closed \(s\);
  3. \(\sem{\operatorname{abs}^0_\ell\, t}_{x \cdot \eta,\, \rho} = \sem{t}_{\eta,\, \rho[\ell \mapsto x]}\) for bound-closed \(t\).

Proof. Induction on the term, generalizing the depth as in Lemmas S-1 to S-4; shifting by \(d\) at cutoff \(c\) corresponds to inserting \(d\) values into \(\eta\) at position \(c\). These are the standard semantic substitution lemmas of the simply typed λ-calculus [Barendregt 1984; Gordon and Melham 1993]. The (ACU) clause is a composition of (App) clauses and needs no separate argument. \(\square\)

Lemma M-L2 (type substitution). \(\sem{t\theta}_\nu = \sem{t}_{\nu'}\) where \(\nu'(\alpha) = \sem{\theta(\alpha)}_\nu\), and likewise for types.

Proof. Induction; for constants, \(M(c)\) is applied to the denotations of the type arguments, which are the same on both sides. \(\square\)

Lemma M-L3 (conversion is valid). If \(t \equiv u\) in \(T\), then \(\sem{t} = \sem{u}\) in every model of \(T\), under every valuation.

This is Theorem C-10 on the conversion page.

Soundness

Theorem M-1 (soundness). If \(\Gamma \vdash A\) is derivable in \(T\), it is valid in every model of \(T\).

Theorem M-1 and Theorem C-10 (conversion is valid) depend on each other: the case (Conv) of Theorem M-1 for \(T\) needs Theorem C-10 for \(T\), and Theorem C-10 for \(T\) needs the ACU laws and literal laws that \(T\) cites to be valid, which, for a theorem among them, is Theorem M-1 for its parent. They are proved together, once, by induction on theories under strict inclusion (Definition T-1): assume both for every theory strictly included in \(T\). Theorem C-10 then holds for \(T\), because its proof uses Theorem M-1 only for parents of declarations of \(T\), each strictly included in \(T\); and Theorem M-1 holds for \(T\) by induction on the derivation, below, using Theorem C-10 for \(T\) in the case (Conv). No linear order of declarations is used, so the argument covers theories built by merges.

Proof. Induction on the derivation; for each rule, assume the premises valid and let \(\nu, \rho\) satisfy the conclusion's context. A premise, hypothesis, or statement that the kernel lifts to the canonical signature of \(T\) denotes the same value as before (Theorem C-10, since lifting is \(=_E\), Corollary C-9a).

  • (Hyp): \(\rho\) satisfies \(\Gamma\), which contains \(h: A\).
  • (Use): an axiom holds under every type valuation, so its instance holds by Lemma M-L2. A theorem's closed judgment is derivable in the theorem's parent (Definition T-1), a theory strictly included in \(T\), hence valid in the reduct of \(M\) to the parent, by the induction hypothesis of the joint induction; its instance holds likewise. A definition equation holds by Definition M-3, clause 2.
  • \((\top\mathrm I)\): \(M(\mathsf{True}) = 1\).
  • \((\bot\mathrm E)\): the premise forces \(\sem{\mathsf{False}} = 1\) under every satisfying valuation, which is impossible; so no valuation satisfies \(\Gamma\) and the conclusion holds vacuously.
  • \((\to\mathrm I)\): if \(\sem{A}_\rho = 1\), then \(\rho\) satisfies \(\Gamma, h: A\), so \(\sem{B}_\rho = 1\); hence \(\sem{A \to B}_\rho = 1\).
  • \((\to\mathrm E)\), \((\land\mathrm I)\), \((\land\mathrm E_i)\), \((\lor\mathrm I_i)\), \((\lor\mathrm E)\): Boolean reasoning on the denotations.
  • \((\forall\mathrm I)\): for each \(x \in \sem{\tau}\), \(\rho[\ell \mapsto x]\) satisfies \(\Gamma, \ell: \tau\) (no hypothesis of \(\Gamma\) mentions \(\ell\)), so \(\sem{P}_{\rho[\ell \mapsto x]} = 1\), which by Lemma M-L1(3) is \(\sem{\lambda{:}\tau.\, \operatorname{abs}^0_\ell P}_\rho(x)\). Hence the universal statement denotes \(1\).
  • \((\forall\mathrm E)\): \(\sem{f}(x) = 1\) for all \(x\), in particular for \(x = \sem{t}\), and \(\sem{\mathrm{app}(f, t)} = \sem{f}(\sem{t})\).
  • (Refl), (Sym), (Trans): equality in the metatheory.
  • (Cong): equal functions applied to equal arguments give equal values.
  • \((\xi)\): for every \(x\), \(\sem{s}_{\rho[\ell \mapsto x]} = \sem{t}_{\rho[\ell \mapsto x]}\); by Lemma M-L1(3) the two λ-terms denote functions with the same values, which are equal sets.
  • (Subst): \(\sem{P}(\sem{a}) = 1\) and \(\sem{a} = \sem{b}\).
  • (Conv): Lemma M-L3.
  • (Weak): a valuation satisfying \(\Gamma'\) satisfies its subsequence \(\Gamma\), and \(A\)'s locals are declared in \(\Gamma\).
  • Certificates: by the admitted checker's correctness theorem. \(\square\)

Consistency

Theorem M-2 (consistency of the logic core). \(\vdash \mathsf{False}\) is not derivable in the logic core.

Proof. The logic core has a model: interpret it in any universe as in Definition M-3, clause 1. Its one axiom, propositional extensionality, holds there because two elements of \(\mathbb B\) that imply each other are equal. In it, \(\sem{\mathsf{False}} = 0\), so \(\vdash \mathsf{False}\) is not valid, hence not derivable by Theorem M-1. \(\square\)

Theorem M-3 (consistency of classical HOL). The logic core together with excluded middle, function extensionality, choice, and infinity (the list after Theorem D-1) has a model, and is therefore consistent relative to ZFC.

Proof. In a universe \(\mathcal U\) (Definition M-1), interpret \(\mathsf{ind}\) as an infinite set \(I \in \mathcal U\) and the infinity witness as an injective, non-surjective map \(I \to I\), which exists because infinite sets are Dedekind-infinite under choice. Interpret \(\varepsilon[X](P) = \operatorname{ch}(\{x \in X \mid P(x) = 1\})\) when that set is nonempty (it is then in \(\mathcal U\) by clause 2), and \(\operatorname{ch}(X)\) otherwise. Excluded middle holds because \(\mathbb B\) has two elements; function extensionality holds because functions are sets of pairs; choice holds by construction. \(\square\)

Theorem M-4 (admission of profiles). Let \(T\) have a model, and let \(T'\) include \(T\).

  1. If \(T'\) adds only type constructors and constants, \(T'\) has a model: interpret the new constructors by any set of \(\mathcal U\) and the new constants by any element of their types' denotations (all are nonempty). The same holds when \(T'\) adds a literal kind whose laws are theorems or axioms of \(T\): every model of \(T\) expands to interpret its literals (Theorem C-11).
  2. If \(T'\) adds axioms, it has a model only if some model of \(T\) expands to one in which they hold; the kernel cannot check this.
  3. Let \(T_1\) and \(T_2\) be theories whose merge is defined, and let \(T_0 = T_1 \cap T_2\), a theory by Lemma T-8. If every model of \(T_0\) expands to a model of \(T_2\), then every model of \(T_1\) expands to a model of \(T_1 \sqcup T_2\). This holds whenever \(T_2\) adds no axiom to \(T_0\), taking its other declarations in an order in which each follows the declarations of its parent: type constructors, constants, and literal kinds by statement 1, definitions by Theorem M-5, and theorems by Theorem M-1; ACU declarations add no symbol.

In each case, a theory with a model is consistent, by Theorem M-1.

Hence session theories, which add only constants, preserve having a model, and therefore consistency; so does merging them with each other or with libraries that add no axioms; and every profile that adds axioms must exhibit a model. The hypothesis is a model, not consistency, because consistency alone is not preserved. For example, without choice, a type constructor \(E\) with the axiom \(\forall x{:}E.\, \mathsf{False}\) is consistent, since nothing provides a term of type \(E\) to instantiate the axiom (it is true when \(E\) denotes the empty set, in a semantics that allows empty types); yet it has no model, because types denote nonempty sets (Definition M-1), and adding a constant \(c: E\) derives \(\mathsf{False}\). Two theories that each have a model, and both add axioms, can merge into an inconsistent one (one assumes \(c = 0\) and the other \(c = 1\), for a constant \(c\) of their common part); the kernel cannot detect this, and the axioms of both appear in the dependencies of every result that uses them. The scalar profile's model is the extended complex carrier of the scalar carrier (Theorem X-8). Admitted axioms are recorded in every dependency summary so that a result's reliance on them is visible.

Proof. Statement 1 as given. Statement 2 is the definition of a model of \(T'\). Statement 3: let \(M_1\) be a model of \(T_1\). Its reduct to \(T_0\) is a model of \(T_0\), which expands to a model \(M_2\) of \(T_2\). The symbols of \(T_1\) and of \(T_2\) outside \(T_0\) are disjoint, because symbols are declarations and a declaration of both is in \(T_0\); so \(M_1 \cup M_2\) interprets \(\Sigma(T_1 \sqcup T_2)\), agreeing with \(M_i\) on \(\Sigma(T_i)\). Each clause of Definition M-3 mentions only the symbols of one \(T_i\), where it holds. Finally, in a model \(\sem{\mathsf{False}} = 0\), so \(\vdash \mathsf{False}\) is not valid, hence not derivable by Theorem M-1. \(\square\)

Conservative definitions

Theorem M-5 (definitions are conservative). Let \(T' = T + (c:= b)\), with the conditions of Definition T-1: \(b\) closed and well typed, not mentioning \(c\), and \(\operatorname{tv}(b) \subseteq \operatorname{tv}(\sigma_c)\).

  1. Every model of \(T\) expands to a model of \(T'\).
  2. For every proposition \(A\) of the language of \(T\): if \(T' \vdash A\) in a context of the language of \(T\), then \(T \vdash A\) in that context.

Proof. (1) Set \(M(c)(\bar X) = \sem{b}_{\bar\alpha_c \mapsto \bar X}\). This is well defined because the type variables of \(b\) are among \(\bar\alpha_c\), so the valuation \(\bar\alpha_c \mapsto \bar X\) determines the denotation of \(b\); it lies in \(\sem{\sigma_c}\) because \(\vdash b: \sigma_c\).

(2) Define the translation \(t^\circ\): replace every occurrence \(c[\bar\tau]\) by \(b[\bar\alpha_c:= \bar\tau]\), then take the canonical form. Since \(b\)'s type variables are among \(\bar\alpha_c\), the replacement is a closed term of the same type (Theorem T-5). Translate a derivation in \(T'\) judgment by judgment. (Use) of the definition equation becomes \(b[\bar\tau] = b[\bar\tau]\), an instance of (Refl). (Use) of any other declaration is unchanged, since declarations of \(T\) do not mention \(c\). (Conv) with unfolding set \(U\) becomes (Conv) with \(U \setminus \{c\}\): a δ-step unfolding \(c\) becomes an identity, and every other generator step remains one, because the translation replaces a constant by a closed term and no definition of \(T\) mentions \(c\) (Lemma C-9(2)). The canonical signatures of \(T\) and \(T'\) are equal, since a definition is not canonical, so canonical forms agree. A certificate step is translated by its checker's obligation (the deduction page). Every other rule commutes with the translation. The translated tree is a derivation in \(T\), and \(A^\circ = A\) for \(A\) in the language of \(T\). \(\square\)

Why the type-variable condition matters. Without it, \(c: \mathsf{Prop}\) could be defined as \(\exists x\, y{:}\alpha.\, x \ne y\) with \(\alpha\) not in the type of \(c\). The definition equation is then a scheme over \(\alpha\): instantiated at \(\mathsf{Prop}\) it makes \(c\) true, and at any type provably having one element (such as HOL's unit) it makes \(c\) false, so \(\mathsf{True} = \mathsf{False}\). HOL Light imposes the same condition [Harrison 2009], and its necessity is analyzed for Isabelle/HOL by Kunčar and Popescu [2017]. A verified HOL Light kernel with this definitional principle is described by Kumar et al. [2016].

Constructive profiles

A profile that leaves out the classical axioms is sound for the same standard models; it simply proves fewer theorems. The logic core's propositional extensionality does not make it classical: it holds in the internal logic of every topos, which is intuitionistic [Lambek and Scott 1986; Mac Lane and Moerdijk 1992]. This page claims no constructive (realizability or Kripke) semantics, and none is needed for soundness.

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