coq

Why must coq mutually inductive types have the same parameters?

十年热恋 提交于 2019-12-10 15:31:32
问题 Following Arthur's suggestion, I changed my Fixpoint relation to a mutual Inductive relation which "builds up" the different comparisons between games rather than "drilling down". But now I am receiving an entirely new error message: Error: Parameters should be syntactically the same for each inductive type. I think the error message is saying that I need the same exact parameters for all of these mutual inductive definitions. I realize there are simple hacks to get around this (unused dummy

OCaml and preprocessor have incompatible versions error when installing tcoq

一曲冷凌霜 提交于 2019-12-10 14:59:34
问题 I was trying to install tcoq and I had the following error: "/Users/pinocchio/.opam/4.05.0/bin/ocamlfind" ocamlc -rectypes -w -3-52-56 -c grammar/compat5.ml OCAMLC -c -pp grammar/gramCompat.mlp >> Fatal error: OCaml and preprocessor have incompatible versions Fatal error: exception Misc.Fatal_error make[1]: *** [grammar/gramCompat.cmo] Error 2 make: *** [submake] Error 2 does someone know: What the error means? How to fix it? I saw related post online: https://coq-club.inria.narkive.com

How to apply a function once during simplification in Coq?

戏子无情 提交于 2019-12-10 14:52:18
问题 From what I understand, function calls in Coq are opaque. Sometimes, I need to use unfold to apply it and then fold to turn the function definition/body back to its name. This is often tedious. My question is, is there an easier way to let apply a specific instance of a function call? As a minimal example, for a list l , to prove right-appending [] does not change l : Theorem nil_right_app: forall {Y} (l: list Y), l ++ [] = l. Proof. induction l. reflexivity. This leaves: 1 subgoals Y : Type

Coq: unfolding class instances

送分小仙女□ 提交于 2019-12-10 13:56:59
问题 How do I unfold class instances in Coq? It seems to be possible only when the instance doesn't include a proof, or something. Consider this: Class C1 (t:Type) := {v1:t}. Class C2 (t:Type) := {v2:t;c2:v2=v2}. Instance C1_nat: C1 nat:= {v1:=4}. Instance C2_nat: C2 nat:= {v2:=4}. trivial. Qed. Theorem thm1 : v1=4. unfold v1. unfold C1_nat. trivial. Qed. Theorem thm2 : v2=4. unfold v2. unfold C2_nat. trivial. Qed. thm1 is proved, but I can't prove thm2 ; it complains at the unfold C2_nat step

Proving that a reversible list is a palindrome in Coq

断了今生、忘了曾经 提交于 2019-12-10 12:55:04
问题 Here is my inductive definition of palindromes: Inductive pal { X : Type } : list X -> Prop := | pal0 : pal [] | pal1 : forall ( x : X ), pal [x] | pal2 : forall ( x : X ) ( l : list X ), pal l -> pal ( x :: l ++ [x] ). And the theorem I want to prove, from Software Foundations : Theorem rev_eq_pal : forall ( X : Type ) ( l : list X ), l = rev l -> pal l. My informal outlines of the proof are as follows: Suppose l0 is an arbitrary list such that l0 = rev l0 . Then one of the following three

How to prove False from obviously contradictory assumptions

廉价感情. 提交于 2019-12-10 12:48:29
问题 Suppose I want to prove following Theorem: Theorem succ_neq_zero : forall n m: nat, S n = m -> 0 = m -> False. This one is trivial since m cannot be both successor and zero, as assumed. However I found it quite tricky to prove it, and I don't know how to make it without an auxiliary lemma: Lemma succ_neq_zero_lemma : forall n : nat, O = S n -> False. Proof. intros. inversion H. Qed. Theorem succ_neq_zero : forall n m: nat, S n = m -> 0 = m -> False. Proof. intros. symmetry in H. apply (succ

Struggling with functional extensionality

时间秒杀一切 提交于 2019-12-10 10:45:10
问题 I've been programming in Coq for a few months now. Particularly, I'm interested in functional programming proofs where functions arise everywhere ( optics , state monad , etc.). In this sense, dealing with functional extensionality has become essential, though extremely annoying. To illustrate the situation, let us assume a simplication of Monad (just one law defined): Class Monad (m : Type -> Type) := { ret : forall {X}, X -> m X ; bind : forall {A B}, m A -> (A -> m B) -> m B }. Notation

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

﹥>﹥吖頭↗ 提交于 2019-12-10 10:28:59
问题 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 inductive proposition work in Coq?

久未见 提交于 2019-12-10 10:15:05
问题 I was going through IndProp in software foundations and Adam Chlipala's chapter 4 book and I was having difficulties understanding inductive propositions. For the sake of a running example, lets use: Inductive ev : nat -> Prop := | ev_0 : ev 0 | ev_SS : forall n : nat, ev n -> ev (S (S n)). I think I do understand "normal" types using Set like: Inductive nat : Set := | O : nat | S : nat -> nat. and things like O just return the single object of type nat and S O is taking an object of type nat

Ltac : optional arguments tactic

感情迁移 提交于 2019-12-10 10:06:58
问题 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. 回答1: We can use the Tactic Notation mechanism to try to solve your issue because it can handle variadic