Skip to Content.
Sympa Menu

coq-club - [Coq-Club] About filling holes automatically

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] About filling holes automatically


Chronological Thread 
  • From: Jonathan Leivent <jonikelee AT gmail.com>
  • To: Coq Club <coq-club AT inria.fr>
  • Subject: [Coq-Club] About filling holes automatically
  • Date: Fri, 1 Jul 2016 19:36:33 -0400
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=jonikelee AT gmail.com; spf=Pass smtp.mailfrom=jonikelee AT gmail.com; spf=None smtp.helo=postmaster AT mail-qk0-f170.google.com
  • Ironport-phdr: 9a23:I1SuVhRvqGDPg4H7p67vDBx7/Npsv+yvbD5Q0YIujvd0So/mwa64YhyN2/xhgRfzUJnB7Loc0qyN4vimAD1LuMbZ+Fk5M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aJBzzOEJPK/jvHcaK1oLshrj0osyYOlUQzBOGIppKZC2sqgvQssREyaBDEY0WjiXzn31TZu5NznlpL1/A1zz158O34YIxu38I46Fp34d6XK77Z6U1S6BDRHRjajhtpZ6jiR6WZgyWrlAYT29exhFPGk3O6Azwdpb3qCrz8ORnjnq0J8rzGJIzXz2+765tADvliTkKMSJxpGPQjM1zgaZWrTquohV+x8jfZ4TDZ6k2Rb/UYd5PHTkJZc1WTSEUR9rkN4Y=

I am trying to understand the various ways there are in Coq to get a hole (implicit arg subgoal, or "_" in a term) to have a proof attempted on it automatically, without the need to explicitly supply a term or call a tactic.

AFAICT, there are 4 varieties of ways:

- typeclasses

- canonical structures

- Declare Implicit Tactic

- Program with Obligation Tactic

Are there any I left out?

Below is my attempt at rough descriptions of what these do - but not being an expert, I would greatly appreciate any corrections:

I think the most restrictive is Program/Obligation Tactic - which requires that one starts the definition in Program mode, and only solves holes generated from that top-level Program definition - hence it cannot be used in the middle of a proof or non-Program definition. But, it has no restriction on the type (conclusion) of the holes it can try to solve.

Typeclasses automatically attempt to solve holes generated at any point, but only if the initial hole is an exact match (modulo intros) for a type declared in the appropriate way as a class. Once typeclass resolution is started in the initial hole, any subsequent subgoal holes generated from there can be solved using hints or classes (the search done by typeclasses eauto). The Existing Class command can extend the initial hole types to previously defined non-class types. However, the match for the initial hole still has to be exact.

I am not as familiar with canonical structures as typeclasses. I think with canonical structures there is a further restriction that the hole be a hole in a projection term - not a hole in an arbitrary term. However, canonical structures will do reduction on the type of the hole to find a match - which among other things makes overlapping matches possible. But, AFAIK, unlike typeclasses, there is no way to declare matches for some pre-existing type (for example, eq) because there is no way to declare post-hoc projections for pre-existing types. In other words, there is nothing like the typeclass Existing Class declaration. Is that right?

Declare Implicit Tactic is a bit of a backwater in Coq - apparently little used since its introduction in 8.1, and it seems to have suffered some amount of bit-rot since then. However, it apparently would have the least restrictions - any hole of any type produced at any time would fire the tactic so declared. But, I think the tactic must solve all goals it attempts, unless this can be subverted via the shelve tactic (as in Declare Implicit Tactic (try mytac; shelve).)


Suppose one were to describe what happens starting with the formation of an arbitrary hole. How do these competing hole-fillers interact?

-- Jonathan




  • [Coq-Club] About filling holes automatically, Jonathan Leivent, 07/02/2016

Archive powered by MHonArc 2.6.18.

Top of Page