coq

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

断了今生、忘了曾经 提交于 2019-12-06 00:30:22
问题 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? 回答1: I can confirm that opening CoqIDE from the same directory works on macOS: cd <sf-dir>; /Applications/CoqIDE_8.5.app

How do we know all Coq constructors are injective and disjoint?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 22:16:54
According to this course , all constructors (for inductive types) are injective and disjoint: ...Similar principles apply to all inductively defined types: all constructors are injective, and the values built from distinct constructors are never equal. For lists, the cons constructor is injective and nil is different from every non-empty list. For booleans, true and false are unequal. (And the inversion tactic based on this assumption) I am just wondering how do we know this assumption holds? How do we know that, e.g., we cannot define natural numbers based on 1) a Successor and maybe a

Modus Ponens and Modus Tollens in Coq

柔情痞子 提交于 2019-12-05 22:06:55
I would like to have Ltac tactics for these simple inference rules. In Modus Ponens, if I have H:P->Q and H1:P , Ltac mp H H1 will add Q to the context as H2 : Q . In Modus Tollens, if I have H:P->Q and H1:~Q , then Ltac mt H H1 will add H2:~P to the context. I have written one for the modus ponens, but it does not work in the complicated cases where the precedent is also an implication. Ltac mp H0 H1 := let H := fresh "H" in apply H0 in H1 as H. Edit : I have found the answer to Modus Ponens in another seemingly unrelated question ( Rewrite hypothesis in Coq, keeping implication ), where a

Ltac : optional arguments tactic

早过忘川 提交于 2019-12-05 21:47:07
I want to make a Ltac tactic in coq which would take either 1 or 3 arguments. I have read about ltac_No_arg in the LibTactics module but if I understood it correctly I would have to invoke my tactic with : Coq < mytactic arg_1 ltac_no_arg ltac_no_arg. which is not very convenient. Is there any way to get a result like this ? : Coq < mytactic arg_1. Coq < mytactic arg_1 arg_2 arg_3. We can use the Tactic Notation mechanism to try to solve your issue because it can handle variadic arguments. Let's reuse ltac_No_arg and define a dummy tactic mytactic for the purposes of demonstration Inductive

Can I define a tactic under “coqtop - nois”?

醉酒当歌 提交于 2019-12-05 21:38:17
$ coqtop -nois Welcome to Coq 8.7.0 (October 2017) Coq < Ltac i := idtac. Toplevel input, characters 0-4: > Ltac i := idtac. > ^^^^ Error: Syntax error: illegal begin of vernac. I am redeveloping "Coq.Init.Prelude" and "HoTT.Basics.Overture" under "coqtop -nois" for pratice. I find it hard to write expressions directly. That's why I want to use tactics. I wonder why I can not use "Ltac". Ltac is now provided as a plugin, which you’ll need to load to use: Declare ML Module "ltac_plugin". 来源: https://stackoverflow.com/questions/48837345/can-i-define-a-tactic-under-coqtop-nois

How to extract the second element of Sigma on the Calculus of Constructions?

老子叫甜甜 提交于 2019-12-05 20:48:36
问题 I'm attempting to do that as follows: λ (A : *) -> λ (B : (A -> *)) -> λ (t : (∀ (r : *) -> (∀ (x : a) -> (B x) -> r)) -> r) -> (t (B (t A (λ (x : A) -> λ (y : (B x)) -> x))) (λ (x : A) -> λ (y : (B x)) -> y)) Notice that, since the value returned by that function depends on a value inside the sigma itself, I need to extract that value. This code doesn't check, because, I believe, it fails to unify the type extracted from Sigma with the type inside it. Is there any workaround? 来源: https:/

Well founded recursion in Coq

*爱你&永不变心* 提交于 2019-12-05 20:03:45
I am trying to write a function for computing natural division in Coq and I am having some trouble defining it since it is not structural recursion. My code is: Inductive N : Set := | O : N | S : N -> N. Inductive Bool : Set := | True : Bool | False : Bool. Fixpoint sum (m :N) (n : N) : N := match m with | O => n | S x => S ( sum x n) end. Notation "m + n" := (sum m n) (at level 50, left associativity). Fixpoint mult (m :N) (n : N) : N := match m with | O => O | S x => n + (mult x n) end. Notation "m * n" := (mult m n) (at level 40, left associativity). Fixpoint pred (m : N) : N := match m

Coq case analysis and rewrite with function returning subset types

只愿长相守 提交于 2019-12-05 19:25:04
I was working is this simple exercise about writing certified function using subset types. The idea is to first write a predecessor function pred : forall (n : {n : nat | n > 0}), {m : nat | S m = n.1}. and then using this definition give a funtion pred2 : forall (n : {n : nat | n > 1}), {m : nat | S (S m) = n.1}. I have no problem with the first one. Here is my code Program Definition pred (n : {n : nat | n > 0}) : {m : nat | S m = n.1} := match n with | O => _ | S n' => n' end. Next Obligation. elimtype False. compute in H. inversion H. Qed. But I cannot workout the second definition. I

How to leverage auto's searching and hint databases in custom tactics?

99封情书 提交于 2019-12-05 19:20:32
In my coq development I am learning how to create new tactics tailored to my problem domain, a la Prof. Adam Chlipala . On that page he describes how to create powerful custom tactics by e.g. combining repeat with match . Now, I already have a powerful one-shot tactic in use, auto . It strings together chains of steps found from hint databases. I have invested some effort in curating those hint databases, so I'd like to continue using it as well. However this presents a problem. It isn't clear what the "right" way is to incorporate auto 's functionality into customized tactics. For example,

Coq - Induction over functions without losing information

丶灬走出姿态 提交于 2019-12-05 18:12:24
I'm having some troubles in Coq when trying to perform case analysis on the result of a function (which returns an inductive type). When using the usual tactics, like elim , induction , destroy , etc, the information gets lost. I'll put an example: We first have a function like so: Definition f(n:nat): bool := (* definition *) Now, imagine we are at this step in the proof of a specific theorem: n: nat H: f n = other_stuff ------ P (f n ) When I apply a tactic, like let's say, induction (f n) , this happens: Subgoal 1 n:nat H: true = other_stuff ------ P true Subgoal 2 n:nat H: false = other