## 1.2 Terms

### 1.2.1 Syntax of terms

Figure 1.1 describes the basic set of terms which form the Calculus of Inductive Constructions (also called Cic). The formal presentation of Cic is given in chapter 4. Extensions of this syntax are given in chapter 2. How to customize the syntax is described in chapter 9.

> term | ::= | qualid
> | | | sort
> | | | term `->` term
> | | | `(` typed_idents `;` ... `;` typed_idents `)` term
> | | | `[` local_decls `;` ... `;` local_decls `]` term
> | | | `(` term ... term `)`
> | | | `[`annotation`]` `Cases` term `of` [equation `|` ... `|` equation] `end`
> | | | `Fix` ident `{` fix_body `with` ... `with` fix_body `}`
> | | | `CoFix` ident `{` cofix_body `with` ... `with` cofix_body `}`
> qualid | ::= | ident
> | | | qualid access_ident
> sort | ::= | `Prop`
> | | | `Set`
> | | | `Type`
> annotation | ::= | `<` term `>`
> typed_idents | ::= | ident `,` ... `,` ident `:` term
> local_assums | ::= | ident `,` ... `,` ident [`:` term]
> local_def | ::= | ident `:=` term [`:` term]
> local_decls | ::= | local_assums
> | | | local_def
> fix_body | ::= | ident `[` typed_idents `;` ... `;` typed_idents `]``:` term `:=` term
> cofix_body | ::= | ident `:` term `:=` term
> simple_pattern | ::= | ident
> | | | `(` ident ... ident `)`
> equation | ::= | simple_pattern `=>` term

> Figure 1.1: Syntax of terms

### 1.2.2 Qualified identifiers and simple identifiers

Qualified identifiers (qualid) denote global constants (definitions, lemmas, theorems, remarks or facts), global variables (parameters or axioms), inductive types or constructors of inductive types. Simple identifiers (or shortly identifiers) are a syntactic subset of qualified identifiers. Identifiers may also denote local variables, what qualified identifiers do not.

### 1.2.3 Sorts

There are three sorts Set, Prop and Type.

- Prop is the universe of logical propositions. The logical propositions themselves are typing the proofs. We denote propositions by form. This constitutes a semantic subclass of the syntactic class term.
- Set is is the universe of program types or specifications. The specifications themselves are typing the programs. We denote specifications by specif. This constitutes a semantic subclass of the syntactic class term.
- Type is the type of Set and Prop

More on sorts can be found in section 4.1.1.

### 1.2.4 Types

Coq terms are typed. Coq types are recognized by the same syntactic class as term. We denote by type the semantic subclass of types inside the syntactic class term.

### 1.2.5 Abstractions

The expression ```[` ident `:` type`]` term'' denotes the abstraction of the variable ident of type type, over the term term.
One can abstract several variables successively: the notation `[` ident1 `,` ... `,` identn `:` type`]` term stands for `[` ident1 `:` type`](` ... `([` identn `:` type`]` term `)` ...`)` and the notation `[` local_assums1 `;` ... `;` local_assumsm `]` term is a shorthand for `[` local_assums1 `](` ... `([` local_assumsm `]` term `)`.
Remark: The types of variables may be omitted in an abstraction when they can be synthesized by the system.
Remark: Local definitions may appear inside brackets mixed with assumptions. Obviously, this is expanded into unary abstractions separated by let-in's.

### 1.2.6 Products

The expression ```(` ident `:` type`)` term'' denotes the product of the variable ident of type type, over the term term.
Similarly, the expression `(` ident1 `,` ... `,` identn `:` type`)` term is equivalent to `(` ident1 `:` type`)(` ... `((` identn `:` type`)` term `)` ...`)` and the expression `(` typed_idents1 `;` ... `;` typed_identsm `)` term is a equivalent to `(` typed_idents1 `)(` ... `((` typed_identsm `)` term `)` ...`)`

### 1.2.7 Applications

`(`term0 term1`)` denotes the application of term term0 to term1.
The expression `(`term0 term1 ... termn`)` denotes the application of the term term0 to the arguments term1 ... then termn. It is equivalent to `(` ... `(` term0 term1 `)` ... termn `)`: associativity is to the left.

### 1.2.8 Local definitions (let-in)

`[`ident`:=`term1`]`term2 denotes the local binding of term1 to the variable ident in term2.
Remark: The expression `[`ident`:=`term1`:`type`]`term2 is an alternative form for the expression `[`ident`:=(`term1`::`type`)]`term2.
Remark: An alternative equivalent syntax for let-in is `let` ident `=` term `in` term. For historical reasons, the syntax `[` ident `=` term `]` term is also available but is not recommended.

### 1.2.9 Definition by case analysis

In a simple pattern `(` ident ... ident `)`, the first ident is intended to be a constructor.
The expression `[`annotation`]` `Cases` term0 `of` pattern1 `=>` term1 `|` ... `|` patternn `=>` termn `end`, denotes a pattern-matching over the term term0 (expected to be of an inductive type).
The annotation is the resulting type of the whole `Cases` expression. Most of the time, when this type is the same as the types of all the termi, the annotation is not needed2. The annotation has to be given when the resulting type of the whole `Cases` depends on the actual term0 matched.

### 1.2.10 Recursive functions

The expression `Fix` identi `{` ident1 `[` bindings1 `] :` type1 `:=` term1 `with` ... `with` identn `[` bindingsn `]``:` typen `:=` termn `}` denotes the ith component of a block of functions defined by mutual well-founded recursion.
The expression `CoFix` identi `{` ident1 `:` type1 `with` ... `with` identn `[` bindingsn `] :` typen `}` denotes the ith component of a block of terms defined by a mutual guarded recursion.