coq

Terms as types in Coq

拟墨画扇 提交于 2019-12-12 05:49:55
问题 Parameter R: Type. Parameter P: R. Parameter O: P. (*Error: The term "P" has type "R" which should be Set, Prop or Type.*) doesn't work because terms can't have terms in Coq. How can we bypass this restriction? One would imagine several possibilities: parametrization, subset types, classes, records, ensembles, explicit universe levels... My question is about the recommended and easiest way(s) of implementing terms as types in Coq (along w/ MWEs). PS. I don't assume the "recommended" and

Rewriting hypothesis with a more concrete expression

狂风中的少年 提交于 2019-12-12 04:30:53
问题 Let's say these are my current premises and goals: IHl' : forall l' : list A, In a l'' \/ In a l' -> In a (l'' ++ l') l' : list A ============================ .... Now, I want the hypothesis to get transformed like this: IHl' : In a l'' \/ In a l' -> In a (l'' ++ l') l' : list A ============================ .... So, basically I instantiate IHl' with l' . Is there any tactic which does this ? Rewriting or even introducing a new specialized hypothesis should do. 回答1: Just to leave the shortest

Declaring a well colored digraph in coq

亡梦爱人 提交于 2019-12-12 03:17:02
问题 I would like to declare a structure in coq which represents a digraph which is well colored. I declared a Register which is accepted by coq if I don't have a condition. However I tried many ways of writing the condition wellColored in coq without exit. Each time I get a new error message: The condition wellColored is the following: for every pair of vertices $v1$, $v2$ and every edge $e$, if the source of $e$ is $v1$, the target of $e$ is $v2$ and the color of $v1$ is $a$ then there is a

How to give a counterxample in Coq?

可紊 提交于 2019-12-12 02:44:21
问题 Is it possible to give a counterexample for a statement which doesn't hold in general? Like, for example that the all quantor does not distribute over the connective "or". How would you state that to begin with? Parameter X : Set. Parameter P : X -> Prop. Parameter Q : X -> Prop. (* This holds in general *) Theorem forall_distributes_over_and : (forall x:X, P x /\ Q x) -> ((forall x:X, P x) /\ (forall x:X, Q x)). Proof. intro H. split. apply H. apply H. Qed. (* This doesn't hold in general *)

Why does Coq use unnamed parameters in Inductive Types of Propositions?

浪子不回头ぞ 提交于 2019-12-11 21:52:21
问题 I was looking at IndProp and I saw: Fail Inductive wrong_ev (n : nat) : Prop := | wrong_ev_0 : wrong_ev 0 | wrong_ev_SS : ∀ n, wrong_ev n → wrong_ev (S (S n)). (* ===> Error: A parameter of an inductive type n is not allowed to be used as a bound variable in the type of its constructor. *) except that it seems to behave exactly as if it was taking an argument but it seems to throw an error. Why is this? The text provides some explanation but I don't understand it: what I don't understand

Unprovable theorem forall A : Prop, ~~A -> A

左心房为你撑大大i 提交于 2019-12-11 17:52:26
问题 I am stuck with a theorem and I think that it's unprovable. Theorem double_negation : forall A : Prop, ~~A -> A. Can you prove it or explain why it is unprovable? Is it due to Gödel's incompleteness theorems? 回答1: Double negation elimination is not provable in constructive logic which underpins Coq. Attempting to prove it we quickly get stuck: Theorem double_negation_elim : forall A : Prop, ~~A -> A. Proof. unfold not. intros A H. (* stuck because no way to reach A with H : (A -> False) ->

Coq Import problems

做~自己de王妃 提交于 2019-12-11 17:38:46
问题 I'm trying to import Library Coq.Structures.OrdersFacts as usual with: Require Import Coq.Structures.OrdersFacts Then I try to use of the lemmas there with either: apply CompareFacts.compare_nlt_iff. or apply compare_nlt_iff. But none work ... what am I missing? 回答1: CompareFacts is a Module Type , not a Module . You can see that if you do Require Import Coq.Structures.OrdersFacts. Print OrdersFacts.CompareFacts. Find a Module of this type and apply its Lemmas instead. EDIT: I meant that to

A different way to do induction on lists that needs a proof

余生长醉 提交于 2019-12-11 16:36:39
问题 I have defined an inductive definition of lists (called listkind ) in order make it easy for me to prove a specific theorem by induction on listkind rather than on list. Inductive listkind {X}: list X -> Prop := | l_nil : listkind [] | l_one : forall a:X, listkind [a] | l_app : forall l, listkind l -> forall a b, listkind ([a]++l++[b]). (With this property, to prove things about lists, I have to prove the cases where a list is [], [a], or [a]++l++[b], rather than the cases where a list is []

How can I prove following lemma in Coq?

社会主义新天地 提交于 2019-12-11 16:02:38
问题 I am trying to write a Coq poof for the following lemma: Require Export Coq.Structures.OrderedTypeEx. Require Import FMapAVL. Module M := FMapAVL.Make(Nat_as_OT). Fixpoint cc (n: nat) (c: M.t nat):bool := match M.find n c with | None => false | _ => true end. Lemma l: forall (n: nat) (k:nat) (m: M.t nat), cc n m = true -> cc n (M.add k k m) = true. I'm unable to simplify (M.add k k m) part. 回答1: First, there is no recursive call in cc , so you should make this definition a plain definition

Searching a list by List.filter

这一生的挚爱 提交于 2019-12-11 15:28:36
问题 In my program, I use List.filter to search a list for finding specific elements. I am proving if List.filter finds some elements in a list, then by appenindg another list we still get those elements that were in the first list before appending. I am a bit stuck in proving filterKeepSameElementsAfterAppending . To make my program shorter, I changed my program's data to customType and mydata . Require Import List Nat. Inductive customType : Type := |Const1: nat -> customType |Const2: list nat -