1

The constructor tactic allows you to discharge a goal which is an inductive datatype by automatically applying constructors. However, definitional equality is not an inductive product in Coq. Then why does Coq accept this proof?

Example zeqz : 0 = 0. constructor.
NJay
  • 130
  • 8

1 Answers1

5

The equality type in Coq is defined as follows

Inductive eq (A : Type) (x : A) : A -> Prop :=  
   eq_refl : x = x

that is it has a single reflexivity constructor.

To prove that 0 = 0 you need to construct a term of this type. The only way to do this is to invoke eq_refl. However in order to invoke eq_refl the type checker needs to know that 0 is convertible to 0 (that is they are definitionally equal).


The type eq is a semantic notion of equality, whereas definitional equality is a syntactic notion. This means that the proof assistant cannot distinguish between definitionally equal terms, but it can distinguish between semantically equal terms. So the constructor eq_refl can be seen as a guarantee that definitional (syntactic) equality subsumes semantic equality.

It is fruitful to ask whether terms may be semantically equal without being syntactically equal. Such examples may only be obtained through an axiom. For example, by the definition of the recursor (nat_rec, or more technically, nat_ind) for the natural numbers, or by an extensionality axiom.

Couchy
  • 753
  • 1
  • 5
  • 25
  • 3
    Small technical comment, the type check will check that `0` is convertible to `0`, not unify them, this is done in the tactic layer, i.e. when building the proof term. – ejgallego Jan 29 '21 at 23:39
  • Apparently my belief that definitional equality was not an inductive product was just flat out wrong. Thanks for the clarification! – NJay Feb 03 '21 at 15:36
  • 1
    @NJay No, you are correct that definitional equality is not an inductive definition (I'm not sure what you mean by inductive *product*)! Definitional equality means that terms are equal *syntactically* or *computationally*, whereas the equality *type* is more general. – Couchy Feb 03 '21 at 15:48
  • I should also point out that `eq` and `=` mean the same thing. – Couchy Feb 03 '21 at 17:19
  • One simple example of semantically equal terms that aren't convertible: if `n : nat` is an atom, then `n + 0 = n` is always true (via a proof which is a recursive function of `n`) but `n + 0` is not synatically convertible to `n`. That proof technically doesn't rely on an `Axiom` but can be reduced to a term of type `(fix E (m : nat) : m + 0 = m := ...) n`. – Daniel Schepler Feb 11 '21 at 00:20