# Judgment

### From The Twelf Project

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.

## A judgment in standard notation

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

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

## Judgments as types

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 $\mathsf{even}(n)$ using the following signature:

```even    : nat -> type.
even-z  : even z.
even-s  : {N:nat} 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 $\mathsf{even}(\mathsf{zero})$.

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

For example, the LF term

```even-s z even-z
```

represents the derivation

${\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.

## See also

• Hypothetical judgements can be represented in LF in a higher-order manner, using LF binding to represent hypotheses.
• The introductions to Twelf discuss how judgments are represented in LF in more detail.
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 10, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9303566217422485, "perplexity_flag": "middle"}