What does the Coq command Require Import Ltac do? - coq

When I am looking at the QuickChick project, I encountered the sentence Require Import Ltac. I don't know what this does and where the Ltac module is. I found a file plugins/ltac/Ltac.v, but this couldn't be the one since this file is empty (by the way, what is the purpose of including an empty file anyway?). I tried Locate Ltac. but I got Error: Syntax error: [constr:global] expected after 'Ltac' (in [locatable])., which is more confusing.
What does the Ltac module do, where is the Ltac.v file, and why doesn't the Loacte command work in this case? Thanks!

Require Import Ltac. is indeed Coq.ltac.Ltac, the empty file you found! I am not sure why there's an empty file there, but it was introduced when Ltac was moved to a plugin. Perhaps it serves as a placeholder for if some of the Ltac implementation were moved into Coq rather than being an OCaml plugin. In any case I think there's little reason for QuickChick to import it, unless they're anticipating some change to Coq I don't know about.
Because of a conflict with the vernacular command Locate Ltac (which is giving you a syntax error), you need to instead use Locate Module explicitly. The same goes for Print Module.
Locate Module Ltac reports Module Coq.ltac.Ltac, which tells you that you're indeed looking at theories/ltac/Ltac.v, and Print Module Ltac shows an empty module. However, that second bit is misleading, since what look like empty modules can still have notations (that's not the case here, but just FYI).

Related

Difference between `uiop/package:define-package` and `defpackage`?

In Common Lisp with ASDF what is the difference between the define-package in uiop/package and the defpackage macro?
UIOP's one has more clauses.
https://common-lisp.net/project/asdf/uiop.html#UIOP_002fPACKAGE
define-package supports the following keywords: use, shadow, shadowing-import-from, import-from, export, intern -- as per cl:defpackage.
those are the same ones. But the rest of the docstring introduces more of them: recycle, mix, reexport…
I have used reexport which makes the following easier: you don't want to fully use package A (for example, Alexandria). You want to import a couple symbols (easy, with import-from), and you also want to export them (easy too, with export). But in doing so, you had to write the symbols twice. reexport saves duplication.
I heard some complains that defpackage would fail to reload a package in some situations, and define-package worked fine, but I didn't encounter this situation.
(edit): another difference: let's say you ":use" a package in your defpackage definition. Now you erase that line and you compile the package definition again. Your Lisp gives you a warning, telling that your package "also uses the following packages" and lists the one you removed from the definition. You removed the line, but the package still "uses" what you wanted to remove. You can check with (describe (find-package :my-package)).
Do the same with UIOP's define-package: you don't have warnings and your package doesn't "use" the one you removed from the definition anymore, as expected.

coqIDE is not properly connecting files in project and is not compiling

I'm new to using coq/coqIDE and I'm not computer savvy either so I don't know whats wrong or what to call the issue. I was trying to go through the Software Foundations book, but coqIDE isn't working right. I'm using the latest windows 10, and coqIDE 8.10.2
The first issue is when I go to the tab compile -> compile buffer in Basics.v, coqIDE doesn't create a .vo file or a .glob. None of the other buttons worked either. Running coqIDE as admin didn't make it work either, but I figured out I can get around this by manually dragging Basics.v into the coqc application file.
I had no issues with coq working during the first lesson, but in the next lesson we're meant to import the definitions from Basics.v into Induction.v, when I run what they say
From LF Require Export Basics.
I get the error The file C:\Users\...\Coq Files\Tutorial\lf\Basics.vo contains library Basics and not library LF.Basics even though the _CoqProject file contains "-Q . LF" as it should.
I can get around this error too by just writing "Require Export Basics."
which properly loads, up until I actually try calling a definition from Basics
Running
Require Export Basics.
Example example: evenb 2 = true.
works until I get to evenb, and then gives the error
The reference evenb was not found in the current environment. even though it's in Basics.v
If I get even more anal and try
Add LoadPath "C:\Users\...\Coq Files\Tutorial\lf".
From LF Require Export Basics.
I get the error
Cannot find a physical path bound to logical path matching suffix <> and prefix LF.
And then finally if I try
Add LoadPath "C:\Users\...\Coq Files\Tutorial\lf".
Require Export Basics.
Example example: evenb 2 = true.
Loads properly.
So I'm wondering how should I fix the load path so that the project works without putting that junk in every file and how do I make the compile tab work.
There were some people talking about "hitting make in the top-level" but I have no idea what that means. I tried it anyway and ran the Makefile as a .bat even though I already downloaded it properly so there shouldn't be any need, but the Makefile didn't change anything anyway.
I don't think I'm forgetting anything, thanks in advance.
Instead of choosing Compile > Compile buffer, try Compile > Make instead (when browsing any one of the vernacular files in Logical Foundations) - I think that is what others meant by "hitting make in the top-level". But first, you may want to remove the workarounds you added in e.g. Induction.v, and save a trivial change in Basics.v such as adding/removing a newline somewhere in order to convince make to recompile it.

How can I find what file a value is defined in?

When I work on a Coq proof I often want to find which file a definition comes from.
E.g. I had a goal which contains list_norepet (map fst (PTree.elements ta)), and I wanted to find the file that defined list_norepet. Doing Print list_norepet. shows lots of helpful information, but not the file name. Is there any way to get Coq to print that?
You can use Locate to get the full module name. Usually this is enough to find the file, but then you can use Locate File to try to find it:
Locate eq_rect.
(* Constant Coq.Init.Logic.eq_rect *)
Locate File "Init/Logic.v".
(* /Users/tchajed/code/sw/coq-master/theories/Init/Logic.v *)
I say "try to find it" because you do need to know the remappings (with -R) to be able to translate module paths to file paths - for example, Coq's standard library is in theories but is mapped to Coq.

Refine and # (at) symbol in Coq 8.5pl1

In the previous version of Coq using symbol # in refine command allows me to create a prove step-by-step. (Each argument was a separate goal.)
I want to avoid implicit arguments like "?Goal0 ?Goal1". And now I can not.
What should I do obtain such possibility?
(It is very uncomfortable to me especially when I trying to deal with recursive functions.)
You are looking for simple refine.
In 8.5, goals that can be solved by unification (what you call implicit) are put in the "shelve" a hidden area, as they are considered trivial. You can unshelve them with Unshelve but it is a bit incovenient as it is a vernacular command.
simple refine behaves as 8.4 and doesn't put anything in the shelve.

Locating definition of a tactic in Coq proofs

In studying Coq proofs of other authors, I often encounter a tactic, lets say "inv eq Heq" or "intro_b". I want to understand such tactics.
How can I find if it is a Coq tactic or a Tactic Notation defined somewhere in my current project?
Second, is there a way to find its definition?
I used SearchAbout, Search, Locate and Print but could not find answers to the above questions.
You should be able to use
Print Ltac <tacticname>.
to print the code of a user-defined tactic (according to the documentation).
To find where it is defined... I guess you're going to need grep unfortunately, Locate does not work for tactics names it seems.
As mentioned before, Print Ltac ... prints the code of a user-defined tactic.
To locate a user-defined tactic (i.e. to know where its defined), use Locate Ltac .... It gives you the fully qualified name. Then use Locate Library to find the corresponding file.