0

If I do something like - From mathcomp Require Import ssreflect. it gives me the following error.

Error: Cannot load mathcomp.ssreflect.ssreflect: no physical path bound to
mathcomp.ssreflect

But if I do this instead - Require Import ssreflect. It compiles just fine. This is probably because I have ssreflect installed but not exactly the way I want.

But the thing is I want the first way to work, because I have a lot of programs written that way, and it doesn't seem logical to change the line in each and every one of them.

This is what I have in my .emacs file - (I think maybe I need to add anything like a path to mathcomp/ssreflect.. I don't know)

(load "~/.emacs.d/lisp/PG/generic/proof-site")

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(coq-prog-name "/usr/local/Cellar/coq/8.10.2_1/bin/coqtop")
 '(package-selected-packages (quote (company-coq)))
 '(proof-three-window-enable t))

;; Load company-coq when opening Coq files
(add-hook 'coq-mode-hook #'company-coq-mode)

It would be really helpful to me if someone can help me to get From mathcomp Require Import ssreflect. working.

  • I tried to make a recipe for the students taking my class on Coq, it looks like it worked for them: https://gist.github.com/anton-trunov/4798b61868e970b5b529951fec9ac3f2 – Anton Trunov Mar 11 '20 at 16:14
  • Thanks Anton. I tried following both methods listed under MacOS, but after trying `From mathcomp Require Import ssreflect` in CoqIDE, it gives me the following error - `Cannot find a physical path bound to logical path matching suffix <> and prefix mathcomp.` – Vedant Chavda Mar 12 '20 at 03:15
  • However if I run coqtop from my terminal, `From mathcomp Require Import ssreflect` works. It also works if I write it in a `.v` file and compile it on terminal using `coqc name.v`. It doesn't work while working with Emacs (along with Proof General) though. Is it possible that the versions of Coq used in terminal and Emacs are different? – Vedant Chavda Mar 12 '20 at 03:27
  • Yes, there is some configuration needed to make Emacs use the system shell settings. I don't remember the details unfortunately (I'm using Spacemacs these days), but that should be searchable. – Anton Trunov Mar 12 '20 at 06:55
  • Hey @VedantChavda you might not have ssreflect installed properly: recent versions of Coq seem to come bundled with the `ssreflect` part of `ssreflect`, but not the whole `mathcomp`. To try it out, try to require another file, like `tuple`, `ssrnat`, etc. – Ptival Mar 12 '20 at 07:18
  • You're right @Ptival. `From mathcomp Require Import ssrnat` and `Require Import ssrnat` both don't work on Emacs. (Although `From mathcomp Require Import ssrnat` works in `coqtop` in terminal). But `Require Import ssreflect` works. What should I do? Also please note that my problem is to not only install ssreflect, but to install it in such a way that `From mathcomp Require Import ssreflect` compiles. – Vedant Chavda Mar 12 '20 at 08:10
  • Are you sure that you only have one version of Coq installed, and that the version that emacs launches is the same as in your terminal? (I wonder whether you have mathcomp installed for one version of Coq, but not the other, for instance) – Ptival Mar 12 '20 at 11:20
  • I think I may have multiple versions installed, but how do I check? And how do I find out which version of `coq` Emacs uses? The command `which coqc` and `which coqtop` in terminal both give `/usr/local/bin/coqtop or coqc` as output. It may be possible that I have mathcomp installed for one version, but I have no idea which. The thing is, since I'm new to this, I've tried searching a lot and trying out various ways of installing things, so in the process I may have installed multiple versions and may have messed up which one Emacs uses, which version has mathcomp etc. – Vedant Chavda Mar 12 '20 at 16:47
  • Also I tried https://gist.github.com/anton-trunov/b55fae56f92c35531fc480232bc74160 this link (by @AntonTrunov), which shows how to switch between versions in Emacs. But I'm not entirely sure how to use this. I did `M-x coq-change-compiler` and then I tried putting `/usr/local/bin` when it asked `Compiler : ` but after that Emacs was still not compiling `From mathcomp Require Import ssrnat`. – Vedant Chavda Mar 12 '20 at 16:49

1 Answers1

0

The recommended way to install non system versions of Coq is through opam cf https://coq.inria.fr/opam-using.html, mainly because it facilitates the installation of packages (such as mathcomp-* packages), and you can focus on a single problem at a time (coq vs emacs)

If you still decide to perform a custom install of Coq, and then of mathcomp, do not forget the make install step which is supposed to copy compiled library files to the subfolder user-contrib/ of your local install.

I noticed that in your original post, your .emacs config file sets "/usr/local/Cellar/coq/8.10.2_1/bin/coqtop" as the coq-prog-name while your terminal seems to use /usr/local/bin/coqtop, which might very well be two distinct versions of Coq. So if you compiled and installed mathcomp using this one, you will not have them for the other one.

Cyril
  • 367
  • 2
  • 7