1

I was trying to unfold a Fixpoint definition and obtain the body of the definition. But Coq wouldn't give the body of the definition literally. Instead, it's giving me something starting with (fix ...), which I cannot make use of.

For example, in proving the following from Coq.Init.Wf

Lemma Fix_F_eq :
  forall (x:A) (r:Acc x),
  F x (fun (y:A) (p:R y x) => Fix_F y (Acc_inv x r y p)) = Fix_F x r.
  Proof. intros.

The state is:

...
______________________________________(1/1)
F x
  (fun (y : A) (p : R y x) =>
   Fix_F y (Acc_inv x r y p)) = 
Fix_F x r

Now, Fix_F on the RHS was defined exactly the same as the LHS:

Fixpoint Fix_F (x:A) (r:Acc x) {struct r} : P x :=
  F x (fun (y:A) (p:R y x) => Fix_F y (Acc_inv x r y p)).

I tried to make it a trivial equality by:

unfold Fix_F at 2.

Yet, I got something like (fix Fix_F ... ) on the RHS, and I can't proceed along this line any further:

______________________________________(1/1)
F x
  (fun (y : A) (p : R y x) =>
   Fix_F y (Acc_inv x r y p)) =
(fix
 Fix_F (x0 : A) (r0 : Acc x0) {struct r0} :
   P x0 :=
   F x0
     (fun (y : A) (p : R y x0) =>
      Fix_F y (Acc_inv x0 r0 y p))) x r

The question is:

Is there a way to unfold the above Fixpoint to its function body to the letter?

Note: I know there is a workaround to prove this example.

Proof. intros. destruct r. simpl. trivial. 
  Defined.

But I am more interested in the unfold-ing approach if it is valid.

Elazar
  • 20,415
  • 4
  • 46
  • 67
thor
  • 21,418
  • 31
  • 87
  • 173
  • Can you write your expected goal explicitly? – Elazar Jul 27 '16 at 04:08
  • I don't believe it's possible, since it's not a `Definition` but a `Fixpoint` so the definition is what you get in the `unfold`. I'm not a COQ expert though. – Elazar Jul 27 '16 at 04:37
  • @Elazar, the body of the Fixpoint definition is: `F x (fun (y:A) (p:R y x) => Fix_F y (Acc_inv x r y p))`. I was expecting to get this via unfold, then what's to be proved is a reflexivity. Could you explain the difference between a `Definition` and `Fixpoint` that you mentioned and why it's impossible to expand the Fixpoint definition as-is? – thor Jul 27 '16 at 04:50
  • 2
    As far as I understand, `Fixpoint` is syntactic sugar for a call to a function `fix` (intrinsic to COQ, I guess) that is the [Fixed-point Combinator](https://en.wikipedia.org/wiki/Fixed-point_combinator). The actual definition is exactly what you see after `unfold`. Expanding the fixpoint definiton as is means you remove the syntactic sugar and left with a different definition. – Elazar Jul 27 '16 at 05:41
  • In other words, these definitions are not identical by definition, so your strategy cannot possibly work. Again, everything based on my shallow understanding of the logic and system. – Elazar Jul 27 '16 at 05:47
  • 3
    The comments of @Elazar are correct. Rather than unfolding the definition, what you really want here is to do one step of computation. To do that try `cbv`. – Zimm i48 Jul 27 '16 at 11:55

0 Answers0