coq-tactic

Are Coq tacticals right associative or left associative?

你离开我真会死。 提交于 2019-12-11 07:21:14
问题 I was going through software foundations and got the example: repeat (try (left; reflexivity); right). and was confused what this meant. For example do we get: try [ (left; reflexivity); right ] or [try (left; reflexivity);] right second or first? in particular I was trying to understand: Theorem In10 : In 10 [1;2;3;4;5;6;7;8;9;10]. Proof. repeat (try (left; reflexivity); right). Qed. 回答1: A good way of solving those problems on your own is to use tactics like idtac (always succeeds) and fail

Can destruct used in implication in Coq?

痞子三分冷 提交于 2019-12-10 23:26:09
问题 destruct can be used to split and , or in Coq. But it seems can also be used in implication? For example, I want to prove ~~(~~P -> P) Lemma test P : ~~(~~P -> P). Proof. unfold not. intro pffpf. apply pffpf. intro pff. destruct pff. intro p. apply pffpf. intro pff. exact p. Qed. when destruct pff. it works fine, but I don't know why? Can anyone explain it for me? 回答1: The destruct tactic works on implications if the conclusion of the implication is of inductive (or co-inductive) type. Hence

How can I rewrite “+ 1” (plus one) to “S” (succ) in Coq?

南笙酒味 提交于 2019-12-10 17:13:11
问题 I have the following Lemma with an incomplete proof: Lemma (s_is_plus_one : forall n:nat, S n = n + 1). Proof. intros. reflexivity. Qed. This proof fails with Unable to unify "n + 1" with "S n". It seems like eq_S would be the way to prove this, but I can't apply it (it doesn't recognize n + 1 as S n : Error: Unable to find an instance for the variable y. ). I've also tried ring , but it can't find a relation. When I use rewrite , it just reduces to the same final goal. How can I finish this

coq: elimination of forall quantifier

浪尽此生 提交于 2019-12-10 15:54:02
问题 I want to prove the following theorem: Theorem Frobenius (A: Set) (q: Prop) (p: A -> Prop) : (q \/ forall x : A, p x) -> (forall x : A, q \/ p x). I already got the following piece of the proof: Proof. intro. intro. destruct H. left. assumption. But now I am in a situation I don't know what to do. The following things are at my disposal: A : Set q : Prop p : A -> Prop H : forall x : A, p x x : A And I would like to prove the following subgoal: q \/ p x How can I eliminate the forall

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

rewrite works for = but not for <-> (iff) in Coq

我怕爱的太早我们不能终老 提交于 2019-12-10 10:02:53
问题 I have the following during a proof, in which I need to replace normal_form step t with value t as there is a proven theorem that there are equivalent. H1 : t1 ==>* t1' /\ normal_form step t1' t2' : tm H2 : t2 ==>* t2' /\ normal_form step t2' ______________________________________(1/1) exists t' : tm, P t1 t2 ==>* t' /\ normal_form step t' The equivalence theorem is: Theorem nf_same_as_value : forall t : tm, normal_form step t <-> value t Now, I can use this theorem to rewrite normal_form

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

南笙酒味 提交于 2019-12-10 10:02: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". 回答1: Ltac is now provided as a plugin, which you’ll need to load to use: Declare ML Module "ltac_plugin".

Modus Ponens and Modus Tollens in Coq

情到浓时终转凉″ 提交于 2019-12-07 14:53:00
问题 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

How do you selectively simplify arguments to each time a function is called, without evaluating the function itself?

这一生的挚爱 提交于 2019-12-06 08:44:46
问题 I'm using Coq 8.5pl1. To make a contrived but illustrative example, (* fix so simpl will automatically unfold. *) Definition double := fix f n := 2*n. Theorem contrived n : double (2 + n) = 2 + double (1 + n). Now, I only want to simplify the arguments to double, and not any part outside of it. (For example, because the rest has already carefully been put into the correct form.) simpl. S (S (n + S (S (n + 0)))) = S (S (S (n + S (n + 0)))) This converted the outside (2 + ...) to (S (S ...)) as

Defining different equality types as inductive types in Coq

与世无争的帅哥 提交于 2019-12-06 05:50:24
问题 I am trying to define in Coq different types of equalities. During an university course my professor gave us the rules of four different types, as follows (I provide just the links to the rules): Gentzen : https://ibb.co/imQOCF Leibniz : https://ibb.co/n0uBzv Martin-Lof : https://ibb.co/fALZKv Path Induction : https://ibb.co/esZuKv The difference among these four types relies on the type C. I am trying to prove the isomorphism among them. Unfortunately I have some troubles in declaring as