## 4.3 Conversion rules

##### b-reduction.

We want to be able to identify some terms as we can identify the application of a function to a given argument with its result. For instance the identity function over a given type T can be written [x:T]x. In any environment E and context G, we want to identify any object a (of type T) with the application ([x:T]x a). We define for this a reduction (or a conversion) rule we call b:
E[G] |- ([x:T]t u) |>b t{x/u}
We say that t{x/u} is the b-contraction of ([x:T]t u) and, conversely, that ([x:T]t u) is the b-expansion of t{x/u}.
According to b-reduction, terms of the Calculus of Inductive Constructions enjoy some fundamental properties such as confluence, strong normalization, subject reduction. These results are theoretically of great importance but we will not detail them here and refer the interested reader to [Coq85].

##### i-reduction.

A specific conversion rule is associated to the inductive objects in the environment. We shall give later on (section 4.5.4) the precise rules but it just says that a destructor applied to an object built from a constructor behaves as expected. This reduction is called i-reduction and is more precisely studied in [Moh93, Wer94].

##### d-reduction.

We may have defined variables in contexts or constants in the global environment. It is legal to identify such a reference with its value, that is to expand (or unfold) it into its value. This reduction is called d-reduction and shows as follows.
E[G] |- x |>d t if (x:=t:T)ÎG E[G] |- c |>d t if (c:=t:T)Î E

##### z-reduction.

Coq allows also to remove local definitions occurring in terms by replacing the defined variable by its value. The declaration being destroyed, this reduction differs from d-reduction. It is called z-reduction and shows as follows.
E[G] |- [x:=u]t |>z t{x/u}

##### Convertibility.

Let us write E[G] |- t |> u for the contextual closure of the relation t reduces to u in the environment E and context G with one of the previous reduction b, i, d or z.
We say that two terms t1 and t2 are convertible (or equivalent) in the environment E and context G iff there exists a term u such that E[G] |- t1 |> ... |> u and E[G] |- t2 |> ... |> u. We then write E[G] |- t1 =bdiz t2.
The convertibility relation allows to introduce a new typing rule which says that two convertible well-formed types have the same inhabitants.
At the moment, we did not take into account one rule between universes which says that any term in a universe of index i is also a term in the universe of index i+1. This property is included into the conversion rule by extending the equivalence relation of convertibility into an order inductively defined by:

1. if E[G] |- t =bdiz u then E[G] |- t £bdiz u,
2. if i £ j then E[G] |- Type(i) £bdiz Type(j),
3. for any i, E[G] |- Prop £bdiz Type(i),
4. for any i, E[G] |- Set £bdiz Type(i),
5. if E[G] |- T =bdiz U and E[G::(x:T)] |- T' £bdiz U' then E[G] |- (x:T)T' £bdiz (x:U)U'.

The conversion rule is now exactly:

- Conv

  E[G] |- U : s E[G] |- t : T E[G] |- T £bdiz U
  E[G] |- t : U

##### h-conversion.

An other important rule is the h-conversion. It is to identify terms over a dummy abstraction of a variable followed by an application of this variable. Let T be a type, t be a term in which the variable x doesn't occurs free. We have
E[G] |- [x:T](t x) |> t
Indeed, as x doesn't occur free in t, for any u one applies to [x:T](t x), it b-reduces to (t u). So [x:T](t x) and t can be identified.
Remark: The h-reduction is not taken into account in the convertibility rule of Coq.

##### Normal form.

A term which cannot be any more reduced is said to be in normal form. There are several ways (or strategies) to apply the reduction rule. Among them, we have to mention the head reduction which will play an important role (see chapter 7). Any term can be written as [x1:T1]...[xk:Tk](t0 t1... tn) where t0 is not an application. We say then that t0 is the head of t. If we assume that t0 is [x:T]u0 then one step of b-head reduction of t is:
[x1:T1]...[xk:Tk]([x:T]u0 t1... tn) |> [x1:T1]...[xk:Tk](u0{x/t1} t2 ... tn)
Iterating the process of head reduction until the head of the reduced term is no more an abstraction leads to the b-head normal form of t:
t |> ... |> [x1:T1]...[xk:Tk](v u1 ... um)
where v is not an abstraction (nor an application). Note that the head normal form must not be confused with the normal form since some ui can be reducible.
Similar notions of head-normal forms involving d, i and z reductions or any combination of those can also be defined.