In lecture 6 of the DeepSpec 2018, the lecturer Checks the definition of
string_dec
obtaining:
string_dec
: forall s1 s2 : string, {s1 = s2} + {s1 <> s2}
Then he goes on to see the definition of +, but before, he disables in CoqIde the printing of notation. So that sumbool is printed. This last symbol can be checked.
How can I do the same thing with Proof General?
You can use the menu, Coq > OPTIONS > Set Printing All.
You can also issue the command directly, typing Set Printing All. and evaluating it in your buffer before running the Check command. This also gives you access to Unset Printing Notations to only disable printing notations (which is something you can do with the menu in CoqIDE). When you're done you can just delete this command, which will undo its effect.
Finally, you can also directly use Coq > OTHER QUERIES > Check (show all) on string_dec.
Related
So I am playing with Coq using Emacs as the IDE. Both proof-general and company-coq are installed and load correctly.
Then I open dummy whatever_name.v file and define recursive function using the Fixpoint keyword.
Then I run coq-Check on it and get:
> Check addnm .
Error: The reference addnm was not found in the current environment.
However, for example, Inductive unit : Set := tt. works perfectly well.
What am I doing wrong?
I have the impression you did not ask Coq to read the addnm definition. Try pressing C-c C-n on your Coq buffer. This should instruct Proof General to send in the next command to Coq for processing. You should see your buffer progressively turning a different color as the commands are sent. Once the definition of addnm is highlighted, you should be able to check it (C-c C-a C-c).
(The reason unit still works is that its definition is automatically loaded when you start Coq in Emacs.)
I'm working on a colleague's embedding of modal logic in Coq and I'm trying to define a custom notation for formulas of said logic, like presented here and also on Volume 2 of the book Software Foundations. So far I have this:
Declare Custom Entry modal.
Declare Scope modal_scope.
Notation "[! m !]" := m (at level 0, m custom modal at level 99) : modal_scope.
Notation " p -> q " := (Implies p q) (in custom modal at level 13, right associativity).
Open Scope modal_scope.
Definition test:
[! p -> q !].
However, the Definition gives this error:
Syntax error: [constr:modal level 99] expected after '[!' (in [constr:operconstr]).
And I can't figure out why. I found some questions on SO where the suggested solution is to change the precedence of the first symbol, p in this case, however that just throws another error. The Coq manual wasn't very helpful either.
What is causing this error and why do the other notations work ?
You declared your own syntactic category for your logic: The parser, after [!, expects only things that are in the entry modal. p is an identifier, and the parser does not expect arbitrary identifiers.
In the documentation on custom entries, you can find a hint on how to add identifiers to your entry:
Declare Custom Entry modal.
Declare Scope modal_scope.
Print Grammar constr.
Axiom Implies : Prop -> Prop -> Prop.
Notation "x" := x (in custom modal at level 0, x ident).
Notation "[! m !]" := m (at level 0, m custom modal at level 99) : modal_scope.
Notation "p '->' q" := (Implies p q) (in custom modal at level 13, right associativity).
Open Scope modal_scope.
Definition testp p q:
[! p -> q !] .
I found some questions on SO where the suggested solution is to change the precedence of the first symbol, p in this case, however that just throws another error. The Coq manual wasn't very helpful either.
This can be a solution if the left-most symbol of your notation is a terminal, not a variable.
sometimes I find coq gets into a state where when I apply a tactic, the new goal and hypotheses don't automatically get printed out. How do I set it to print these out after each tactic invocation.
This is coq 8.7.2, using coqtop
I believe when this happens it's a bug in Proof General, which is supposed to display the proof context whenever you're in the middle of a proof. Li-yao Xia's solution of hitting C-c C-p should work.
I am working on an example given here:
Notation step_normal_form := (normal_form step).
Definition stuck (t:tm) : Prop :=
step_normal_form t /\ ~ value t.
Example some_term_is_stuck :
exists t, stuck t.
and I am having trouble unfold-ing the definition step_normal_form at step 1 (Coq 8.4pl6). I can Check its contents in CoqIDE:
normal_form
: relation ?23 -> ?23 -> Prop
value
: tm -> Prop
But when I unfold step_normal_form:
Example some_term_is_stuck :
exists t, stuck t.
Proof.
unfold stuck. unfold step_normal_form.
I get an error:
Error: step_normal_form is bound to a notation that does not denote a reference.
Does anyone know why this happens and how to fix it?
BTW, I tried to work around this by doing the unfold manually and redefining:
Definition stuck' (t:tm) : Prop :=
normal_form step t /\ ~ value t.
and use stuck' instead. But Coq seems to automatically fold the content of stuck' into step_normal_form and then refuse to unfold it, giving the same error.
Since step_normal_form is just notation for (normal_form step) you could just do unfold normal_form.
Sometimes notations and pretty-printing hides what's really there. Use Set Printing All. to make Coq print the term in clear.
I'm using ProofGeneral with Coq. When I do C-c C-return, Emacs highlights the area Coq has processed. This is nice. However, it inserts a '=>' on the next line, which overwrites the first two characters of your input. For example, currently I'm looking at
Inductive Seq : Set :=
| MkSeq : Ants -> Form -> Seq.
=>ductive Prf : Set :=
| Init :
How can I get rid of that arrow?
Update:
I learned that if I turn fringe-mode on, the arrow is in the fringe and I can see all my typing. I still want to kill it though. Thanks!
Aha, just found it. This is an Emacs configuration, not a Proof General one, given in the overlay-arrow-string variable. To turn it off, just set the variable to "" in your Emacs configuration puttng this in your .emacs:
(setq overlay-arrow-string "")