Coq error: The reference evenb was not found in the current environment - coq

I'm trying to go through the Software Foundations Coq book (http://www.cis.upenn.edu/~bcpierce/sf/current/toc.html), but when I compile Induction.v (which looks like http://www.cs.uml.edu/~rhenniga/coq/sf_induction.html), I get the error message "Error: The reference evenb was not found in the current environment." -- even after compilation of Basics.v. Any ideas why?

I can confirm that opening CoqIDE from the same directory works on macOS: cd <sf-dir>; /Applications/CoqIDE_8.5.app/Contents/MacOS/coqide
from: The reference "X" was not found in the current environment

Try to erase every blank character in the address related to Coq or software-foundation book.
In my case, when I struggled with the file
C:\Users\XxX\Documents\software foundation\lf\Induction.v
, CoqIDE failed to execute From LF Require Export Basics and to define evenb_S theorem. Also, I couldn't see any files like Basics.vo or Basics.glob created when Basics.v with [Compile] - [Compile buffer] function in CoqIDE.
Everything works fine when I change my folder name to
C:\Users\XxX\Documents\softwarefoundation\lf\Basic.v
The Coq installer had already informed this >>
Link to the screenshot image of Coq setup

Compiling Basic.v with coqc Basics.v command should produce Basic.vo and Basic.glob files in the same directory. Then you should be fine with compiling Induction.v in the same directory as well; coqc Induction.v.

Related

there is no package with name "QL". while installing clisp

I'm trying to install lisp in my laptop by following the instruction command and steps that is suggested this site : https://grishagin.com/lisp/windows10/2017/01/26/install-lisp-Windows10.html.
I have done following steps :
I've extract emacs in my specified directory and add it's bin path to the system variable
PATH
I've created a another new directory named C:\HOME and add it system variable with variable HOME and
value C:\HOME
Clisp 2.48 is installed in my lisp directory and To fix some problem, copied svm.dll out of clisp-
2.48/libsvm directory into clisp-2.48/full.
Place quicklisp.lisp into lisp directory and run following code in clisp
(load "C:/lisp/quicklisp.lisp"),
(quicklisp-quickstart:install :path "C:/lisp/quicklisp/")
this two command worked but when i go from next command : (ql:add-to-init-file)
It shows this error :- READ from #<INPUT CONCATENATED-STREAM # #>: there is no package
with name "QL".
Can anyone please help to solve this error and explain how does this all help for lisp to keep working?
So, in the QuickLisp installation instructions, it says:
(quicklisp-quickstart:install)
But you include an optional parameter :path "C:/lisp/quicklisp/"
Try it again, without the optional parameter, and see if that works better.

Unable to set up Certified Programming with Dependent Types

I am working with the book Certified Programming with Dependent Types but each time I'm finding a different error. It seems to me that the error comes from a mismatch between the compilation process from Proof General and through the makefile of the sources of the book.
If I compile the sources with make and try to run for instance Subset.v in Proof-General I get:
Error: File /home/usuario/Desktop/Coq/cpdt/src/CpdtTactics.vo has
bad magic number 81100 (expected 8600). It is corrupted or was
compiled with another version of Coq.
If I clean the makefile compiled files with make clean and try to proceed with the option Coq -> Auto Compilation -> Compile before require then it is the line:
Require Extraction.
that fails. Originally it failed with the error:
Error: Unable to locate library Extraction.
but with the above option enables it gives something like:
echo "Require Extraction." > /tmp/ProofGeneral-coqQPJTf0.v coqdep -Q /home/usuario/Desktop/Coq/cpdt/src/ -R /home/usuario/Desktop/Coq/cpdt/src Cpdt /tmp/ProofGeneral-coqQPJTf0.v
* Warning: in file /tmp/ProofGeneral-coqQPJTf0.v, library Extraction is required and has not been found in the loadpath!
* Warning: in file /tmp/ProofGeneral-coqQPJTf0.v, library Extraction is required and has not been found in the loadpath!
/tmp/ProofGeneral-coqQPJTf0.vo /tmp/ProofGeneral-coqQPJTf0.glob /tmp/ProofGeneral-coqQPJTf0.v.beautified: /tmp/ProofGeneral-coqQPJTf0.v
/tmp/ProofGeneral-coqQPJTf0.vio: /tmp/ProofGeneral-coqQPJTf0.v
How can I solve this?
Side-questions: which OS are you using? do you rely on opam?
Regarding the first error you get, it certainly comes from the following fact:
outside proofgeneral, the coqc binary corresponds to Coq 8.11, while in ProofGeneral, the coqtop binary correspond to Coq 8.6. Maybe because the PATH variable is not the same in the two contexts.
To figure out which binary is found, you can do in the terminal which coqtop, and within Emacs, M-! which coqtop RET and you should thus get different paths.
Sometimes, opening emacs directly from the terminal (emacs &) can help for this kind of issue.
But if you want to change the coqtop binary that is used in ProofGeneral, you can set the coq-prog-name option, by using one of the following steps:
Interactively, type C-u C-c C-x (to kill Coq), M-: (setq coq-prog-name "…/coqtop"), and C-c C-n
Or create a .dir-locals.el file (Emacs' standard conf-file) in the project root containing:
((coq-mode . ((coq-prog-name . "…/coqtop"))))
and close/reopen the ….v file at stake (or just do M-x normal-mode RET or C-x C-v RET in the already-opened ….v buffer)
Regarding the second error you get, I'm a bit puzzled that Require Extraction triggers this error, as this library does exist in Coq 8.6 and 8.11.
At first sight, I'd suggest to re-test the auto-compilation with Coq 8.11, asserting From Coq Require Extraction. (instead of just Require Extraction.)
But maybe there is a bug in PG's Auto Compilation -> Compile before require feature; anyway feel free to open a related issue in the PG tracker if need be, bug reports and feature requests are very welcome: https://github.com/ProofGeneral/PG/issues

QuickChick "Error: Could not compile mli file"

I successfully installed coq 8.9.1 and coq-quickchick 1.1.0 with opam 2.0.4 and I'm programming on emacs 26.1.
However, when running a QuickChick command I received the following error:
Error: Could not compile mli file
Any ideas of what I can do?
Also, I have tried to include the following command before the QuickChick command:
"QuickChickDebug Debug On."
Still, no success and no instructive message was provided.
You can try to manually extract and compile.
A first idea is to replace QuickChick my_prop. with Extraction TestCompile my_prop., which will also try to compile.
There is also Separate Extraction my_prop. (assuming my_prop is an identifier), which just outputs .ml files so you can compile them by hand and see what is wrong.
There are other variants of extraction worth knowing about:
https://coq.inria.fr/distrib/current/refman/addendum/extraction.html#generating-ml-code
Can you compile the file from command line? If you can, you can open emacs from the command line and re-run and see.
BTW, what's your OS? I have the same problem on OS X Catalina and the problem comes from the privacy policy of Catalina I guess.

Coq file generated by WP does not compile

I have installed frama-c (18.0) and coqide (8.9) through opam (plus other needed dependencies of course, but that may not be the matter here). Well the point is I simply installed it through opam, not done anything else strange (and I didn't see any particular instruction that I should do otherwise).
Frama-c works as expected when I use Alt-ergo with WP, but if I try to use coq or coqide instead of Alt-ergo, then I get the following error for each goal that Qed does not manage to prove immediately:
[wp] 13 goals scheduled
[wp] [Coq] 'Qed.v' compilation failed.
------------------------------------------------------------
--- Coqc (stderr) :
------------------------------------------------------------
File "/tmp/wp7fe5dc.dir/coqwp/Qed.v", line 27, characters 8-17:
Error:
Cannot find a physical path bound to logical path matching suffix bool.
------------------------------------------------------------
[wp] [Coq] Goal typed_nondet_loop_inv_preserved : Failed
Compilation of 'Qed.v' failed.
As a note, before displaying the error, it manages to compile some other .v files. I have tried to open manually the files in coqide, and I get the same result. For the record, here are the lines coq complains about:
Require bool.Bool.
Require int.Int.
Require int.Abs.
Require int.ComputerDivision.
Require real.Real.
Require real.RealInfix.
Require real.FromInt.
I have also tried to downgrade coq a bit, but not lower than 8.7 (as otherwise opam complains of incompatible base installation package and I don't really want to screw up my installation), and got the same result.
If someone would have an idea of what is causing that and how I can get to set it up that correctly, that'd be nice. Even if for what I'm doing with it for now, Alt-ergo is sufficient, I would have liked to play a bit with coq to see how it can be used.
Regards,
--
Vincent Penelle.
First, indeed you need coq < 8.8 (e.g. 8.7.2) if you want to use it with Frama-C/WP, as newer versions are not supported for the moment.
Second, the order in which you have installed your packages is relevant. In particular, if the appropriate version of coq has been installed after frama-c, WP did not compile and install its coq libraries, which are the ones that are missing here. Thus, you may want to do opam reinstall frama-c to compile the package against a compatible coq version.

Merlin complains about a missing module in the same project

I am new to Ocaml and just setting up my dev environment with emacs, merlin and flycheck. Everything works more or less expected except one thing : merlin doesn't seem to be able recognise the dependencies between the modules in the same project.
e.g. I have a test project with two modules: main.ml and awesome.ml.
here is my main.ml which references the second module awesome.ml
(* main.ml *)
open Core
module A = Awesome
let _ =
Printf.printf "hello \n Converted to string we get: %s\n"
(A.str_of_t (A.succ A.one_t));
here is awesome.ml:
(* awesome.ml *)
type t = int
let one_t = 1
let succ i = i + 1
let str_of_t = string_of_int
when I send main.ml buffer to evaluate into utop with utop-eval-buffer function, I am getting an error: "Error: Unbound module Awesome"
I have .merlin in the root of the project which has S instruction.
I know it is found by merlin as it doesn't complain about "open Core"
S src
PKG core lwt ounit
B _build/src
B +threads
here is my _tags:
<src/**>: include
<src/**>: package(oUnit), package(core)
true:thread
the regular project compilation with ocamlbuild works fine, no errors.
here is Makefile
## Makefile
default: main
main: main.native
test: test.native
%.native:
ocamlbuild -use-ocamlfind $#
mv $# $*
.PHONY: test default
any ideas why Awesome module is not recognised in utop or this is expected behaviour?
Merlin will see other modules once you have compiled them (in fact, once you have compiled its interfaces). So given your .merlin is correct it will see everything after you run compilation. Your files should indeed be in a src folder, i.e., your project layout, based on your .merlin file should look like this:
Makefile
.merlin
src/
awesome.ml
main.ml
This is not a required layout, but this is the one, that you described to Merlin. The reason, why I suspect that it is not the same, is your Makefile.
P.S. Just as a side note, there is a small issue in your code: you should open Core.Std not Core.
As Ivan's answer pointed out, Merlin can only recognize a module in your project after you compile it. If Merlin is giving you an unbound module Foo error, one solution is to run
ocamlbuild foo.cmi
I had the same problem. I tried installing merlin through opam or sources, but I couldn't solve this problem until I put the ".merlin" file in to the \src directory--not at the root-- with a "REC" tag in it.