Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Apply without TC inference

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Apply without TC inference


Chronological Thread 
  • From: Robbert Krebbers <mail AT robbertkrebbers.nl>
  • To: coq-club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Apply without TC inference
  • Date: Wed, 27 Jul 2016 01:27:12 +0200
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=mail AT robbertkrebbers.nl; spf=None smtp.mailfrom=mail AT robbertkrebbers.nl; spf=None smtp.helo=postmaster AT smtp1.science.ru.nl
  • Ironport-phdr: 9a23:zuEMZRfbkLFV05j7yx0wpSEGlGMj4u6mDksu8pMizoh2WeGdxc6+bB7h7PlgxGXEQZ/co6odzbGH6+a+BSdaud6oizMrSNR0TRgLiMEbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpQAbFhi3DwdpPOO9QteU1JXvkb7usMeLKyxzxxOFKYtoKxu3qQiD/uI3uqBFbpgL9x3Sv3FTcP5Xz247bXianhL7+9vitMU7q3cY6Lod8JtLVry/dKAlR/QMBzM/dmsx+cfDtB/ZTALJ6GFKAUsMlR8dOQ/P5hzgQt/SqCbwvOdnw2HOOMT3SZguXj6o4r13SwXlgi0KLSV/9mWB2Z84t75SvB/0/083+IXTeozAbPc=

Something fishy seems to be going on. When writing:

class_apply @silly; [reflexivity|]

with:

Lemma silly {A} `{C A} : 0 = 0 -> c = c -> True.

Then reflexivity invokes TC inference on the shelved goal while its own goal 0 = 0 does not even involve the type class.

See below for an example.

============================

Require Import Classes.Init.

Class C A := c : A.
Instance nat_C : C nat := 0.
Instance bool_C : C bool := true.
Lemma silly {A} `{C A} : 0 = 0 -> c = c -> True.
Proof. auto. Qed.

Goal True.
class_apply @silly; [reflexivity|].
(* BAD: @eq bool (@c bool bool_C) (@c bool bool_C) *)
(* Why does reflexivity invoke TC inference? *)
Restart.
class_apply @silly. reflexivity.
(* @eq ?A (@c ?A ?H) (@c ?A ?H) *)
(* Now it no longer happens, why is class_apply @silly. reflexivity. *)
(* any different from class_apply @silly; [reflexivity|]. *)

On 07/27/2016 12:41 AM, Robbert Krebbers wrote:
Hi,

is there a variant of apply that does not invoke type class inference on
the arguments of the applied lemma, but instead turns type class
constraints into shelved subgoals so that these can be solved later.

The (undocumented) tactic "class_apply" seems to be doing somewhat what
I like, but not entirely: it only turns type class constraints into
shelved subgoals when the applied lemma is prefixed with an @. This is
insufficient when used as part of the implementation of some Ltac tactic
because I do not want the users of my tactic having to prefix their
lemmas with an @.

I have included an example below.

Robbert

=========

Require Import Classes.Init.

Class C A := c : A.
Instance nat_C : C nat := 0.
Instance bool_C : C bool := true.
Lemma silly {A} `{C A} : c = c -> True.
Proof. auto. Qed.

Goal True.
apply silly. (* BAD: @eq bool (@c bool bool_C) (@c bool bool_C) *)
(* I only want TC inference to be invoked later,
for example when doing: *)
Fail apply (@eq_refl nat).
Restart.
eapply silly. (* BAD: @eq bool (@c bool bool_C) (@c bool bool_C) *)
Restart.
eapply @silly. (* BAD: @eq bool (@c bool bool_C) (@c bool bool_C) *)
Restart.
class_apply silly. (* BAD: @eq bool (@c bool bool_C) (@c bool bool_C) *)
Restart.
class_apply @silly. (* GOOD: @eq ?A (@c ?A ?H) (@c ?A ?H) *)
apply (@eq_refl nat). (* works *)

(* But can we also do it without the @ ? *)





Archive powered by MHonArc 2.6.18.

Top of Page