coq

A simple case of universe inconsistency

有些话、适合烂在心里 提交于 2019-12-01 07:30:02
问题 I can define the following inductive type: Inductive T : Type -> Type := | c1 : forall (A : Type), A -> T A | c2 : T unit. But then the command Check (c1 (T nat)) fails with the message: The term T nat has type Type@{max(Set, Top.3+1)} while it is expected to have type Type@{Top.3} (universe inconsistency). How can I tweak the above inductive definition so that c1 (T nat) does not cause a universe inconsistency, and without setting universe polymorphism on? The following works, but I would

How to indicate decreasing in size of two Coq inductive types

馋奶兔 提交于 2019-12-01 07:28:15
问题 I'm trying to define the game inductive type for combinatorial games. I want a comparison method which tells if two games are lessOrEq , greatOrEq , lessOrConf or greatOrConf . Then I can check if two games are equal if they are both lessOrEq and greatOrEq . But when I try defining the mutually recursive methods for making this check, I get: Error: Cannot guess decreasing argument of fix . I think this is because only one game or the other decreases in size with each recursive call (but not

Which vector library to use in coq?

若如初见. 提交于 2019-12-01 06:13:20
I'm wondering, is there a commonly used library for vectors in coq, I.e. lists indexed by their length in their type. Some tutorials reference Bvector, but it's not found when I try to import it. There's Coq.Vectors.Vectordef, but the type defined there is just named t which makes me think it's intended for internal use. What is the best or most common practice for someone who doesn't want to roll their own library? Am I wrong about the vectors in the standard library? Or is there another Lib I'm missing? Or do people just use lists, paired with proofs of their length? There are generally

Why is it impossible to perform induction on a term that is used in conclusion?

杀马特。学长 韩版系。学妹 提交于 2019-12-01 05:47:27
问题 Suppose the following particular scenario. We have a definition of equality: Inductive eqwal {A : Type} (x : A) : A -> Prop := eqw_refl : eqwal x x. And peano nats: Inductive nawt : Prop := | zewro : nawt | sawc : nawt -> nawt. We define addition on nats: Fixpoint plaws (m n : nawt) : nawt := match m with | zewro => n | sawc m' => sawc (plaws m' n) end. And now we want to prove that zero is neutral from right wrt. summing: Theorem neutral_r : forall n : nawt, eqwal (plaws n zewro) n. Sadly

Which vector library to use in coq?

好久不见. 提交于 2019-12-01 05:12:07
问题 I'm wondering, is there a commonly used library for vectors in coq, I.e. lists indexed by their length in their type. Some tutorials reference Bvector, but it's not found when I try to import it. There's Coq.Vectors.Vectordef, but the type defined there is just named t which makes me think it's intended for internal use. What is the best or most common practice for someone who doesn't want to roll their own library? Am I wrong about the vectors in the standard library? Or is there another Lib

How to forbid simpl tactic to unfold arithmetic expressions?

不羁的心 提交于 2019-12-01 04:40:28
The simpl tactic unfolds expressions like 2 + a to "match trees" which doesn't seem simple at all. For example: Goal forall i:Z, ((fun x => x + i) 3 = i + 3). simpl. Leads to: forall i : Z, match i with | 0 => 3 | Z.pos y' => Z.pos match y' with | q~1 => match q with | q0~1 => (Pos.succ q0)~1 | q0~0 => (Pos.succ q0)~0 | 1 => 3 end~0 | q~0 => match q with | q0~1 => (Pos.succ q0)~0 | q0~0 => q0~1 | 1 => 2 end~1 | 1 => 4 end | Z.neg y' => Z.pos_sub 3 y' end = i + 3 How to avoid such complications with simpl tactic? This particular goal can be solved with omega , but if it is a bit more

The reference “X” was not found in the current environment

人盡茶涼 提交于 2019-12-01 04:22:44
I'm using CoqIDE to complete the exercises in the Software Foundations book about Coq. I can successfully compile Basics.v, resulting in Basics.vo and Basics.glob in my directory. When I try to run Induction.v, it works. When I try to compile it, it complains about tons of missing references, such as evenb and negb_involutive . If I copy Basics.v contents into Induction.v it compiles, but obviously this is not the way to go. This is not a duplicate of question Coq error: The reference evenb was not found in the current environment , as I have already done those things: Compile Basics.v. Check

Coq simpl for Program Fixpoint

我与影子孤独终老i 提交于 2019-12-01 03:57:27
is there anything like the tactic simpl for Program Fixpoint s? In particular, how can one proof the following trivial statement? Program Fixpoint bla (n:nat) {measure n} := match n with | 0 => 0 | S n' => S (bla n') end. Lemma obvious: forall n, bla n = n. induction n. reflexivity. (* I'm stuck here. For a normal fixpoint, I could for instance use simpl. rewrite IHn. reflexivity. But here, I couldn't find a tactic transforming bla (S n) to S (bla n).*) Obviously, there is no Program Fixpoint necessary for this toy example, but I'm facing the same problem in a more complicated setting where I

Error in defining Ackermann in Coq

牧云@^-^@ 提交于 2019-12-01 03:50:56
I am trying to define the Ackermann-Peters function in Coq, and I'm getting an error message that I don't understand. As you can see, I'm packaging the arguments a, b of Ackermann in a pair ab ; I provide an ordering defining an ordering function for the arguments. Then I use the Function form to define Ackermann itself, providing it with the ordering function for the ab argument. Require Import Recdef. Definition ack_ordering (ab1 ab2 : nat * nat) := match (ab1, ab2) with |((a1, b1), (a2, b2)) => (a1 > a2) \/ ((a1 = a2) /\ (b1 > b2)) end. Function ack (ab : nat * nat) {wf ack_ordering} : nat

Coq: how to apply one hypothesis to another

可紊 提交于 2019-12-01 03:22:41
Assume I have two hypotheses in the context, a_b : A -> B and a : A . I should be able to apply a_b to a to gain a further hypothesis, b : B . That is, given the following state: 1 subgoal A : Prop B : Prop C : Prop a_b : A -> B a : A ______________________________________(1/1) C There should be some tactic, foo (a_b a) , to transform this into the following state: 1 subgoal A : Prop B : Prop C : Prop a_b : A -> B a : A b : B ______________________________________(1/1) C But I don't know what foo is. One thing I can do is this: assert B as b. apply a_b. exact a. but this is rather long-winded,