Unlike Agda, Coq tends to separate proofs from functions. The tactics Coq gives are great for writing proofs, but I'm wondering if there is a way to replicate some Agda-mode functionality.
Specifically, I'd like:
- Some equivalent of Agda's
?
or Haskell's_
, where I can omit part of a function while I'm writing it, and (hopefully) have Coq tell me the type I need to put there - An equivalent of C-c C-r in Agda mode (reify), where you fill a
?
block with a function, and it will make new?
blocks for the needed arguments - When I'm doing a
match
in a function, having Coq automatically write expand out the possible branches (like C-c C-a in Agda-mode)
Is this possible, in CoqIde or Proof General?
As was suggested by ejgallego in the comments, you can (almost) do it. There is company-coq tool, which works on top of ProofGeneral.
Let me demonstrate how the
map
function could be implemented using company-coq and therefine
tactic. Start withType in
refine ().
, then put the cursor inside the parens and type C-c C-a RET list RET -- it inserts amatch
expression on lists with holes you fill in manually (let's fill in the list name and the base case).To finish it off we rename
x0
intotl
and provide the recursive caseexact (map A B f tl).
:There is also a useful keyboard shortcut C-c C-a C-x which helps with extracting the current goal into a separate lemma/helper function.