Skip to content
Documentation out of dateLearn more

Judgment

In the context of this wiki, we use the word judgment (or judgement) to refer to a relation that is defined inductively by a collection of inference rules. The judgments as types principle is a name for the methodology by which judgments are represented in LF.

For example, we can define a judgment that a natural number is even. The judgement even(n)\mathsf{even}(n) holds when nn is even. It is inductively defined by the following inference rules:

even(zero)even(n)even(succ(succ(n))){ \over \mathsf{even}(\mathsf{zero}) } \qquad { \mathsf{even}(n) \over \mathsf{even}(\mathsf{succ}(\mathsf{succ}(n))) }

A judgment is represented in LF using the judgments as types methodology: we represent a judgment with an LF type, where the inhabitants of this type correspond exactly to derivations of the judgement.

For example, we represent the judgment even(n)\mathsf{even}(n) using the following signature:

%sort even {_ nat} %.
%term even-z even z %.
%term even-s {N nat} %pi (even N) %-> (even (s (s N))) %.

The first declaration says that even is a family of types indexed by a nat. This means that for every term N : nat, there is a type even N. Note that the syntax -> is overloaded: it is used to classify both type-level families and term-level functions. We then use this type family to define the types of two term constants.

The first term constant, even-z, has type even z. This constant represents the derivation that consists of the first inference rule above, which concludes even(zero)\mathsf{even}(\mathsf{zero}).

The second term constant even-s, corresponds to the second inference rule above, which, for any nn, constructs a derivation of even(succ(succ(n)))\mathsf{even}(\mathsf{succ}(\mathsf{succ}(n))) from a derivation of even(n)\mathsf{even}(n). To encode this inference rule, the constant even-s is given a dependent function type.

For example, the LF term {/* syntax highlighting looks weird when it’s not actually STELF code */}

even-s z even-z

represents the derivation

even(zero)even(succ(succ(zero))){ \overline{\mathsf{even}(\mathsf{zero})} \over \mathsf{even}(\mathsf{succ}(\mathsf{succ}(\mathsf{zero}))) }

The term even-s (s (s z)) (even-s z even-z) represents a derivation that 4 is even, and so on.