coq-tactic

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

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 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,

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

笑着哭i 提交于 2019-12-04 12:32:06
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 well as unfolding double. I can match one of them by doing: match goal with | |- (double ?A) = _ =>

Coq execution difference between semicolon “;” and period “.”

邮差的信 提交于 2019-12-04 12:13:53
问题 Given a valid Coq proof using the ; tactical, is there a general formula for converting it to a valid equivalent proof with . substituted for ; ? Many Coq proofs use the ; or tactic sequencing tactical. As a beginner, I want to watch the individual steps execute, so I want to substitute . for ; , but to my surprise I find that this may break the proof. Documentation on ; is sparse, and I haven't found an explicit discussion of . anywhere. I did see a paper that says informal meaning of t1; t2

Defining different equality types as inductive types in Coq

穿精又带淫゛_ 提交于 2019-12-04 10:41:38
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 inductive types the first and the second, because I cannot find a way to specify the type C. I have a

Decomposing equality of constructors coq

大兔子大兔子 提交于 2019-12-04 03:20:56
问题 Often in Coq I find myself doing the following: I have the proof goal, for example: some_constructor a c d = some_constructor b c d And I really only need to prove a = b because everything else is identical anyway, so I do: assert (a = b). Then prove that subgoal, then rewrite H. reflexivity. finishes the proof. But it seems to just be unnecessary clutter to have those hanging around at the bottom of my proof. Is there a general strategy in Coq for taking an equality of constructors and

Coq execution difference between semicolon “;” and period “.”

早过忘川 提交于 2019-12-03 08:33:36
Given a valid Coq proof using the ; tactical, is there a general formula for converting it to a valid equivalent proof with . substituted for ; ? Many Coq proofs use the ; or tactic sequencing tactical. As a beginner, I want to watch the individual steps execute, so I want to substitute . for ; , but to my surprise I find that this may break the proof. Documentation on ; is sparse, and I haven't found an explicit discussion of . anywhere. I did see a paper that says informal meaning of t1; t2 is apply t2 to every subgoal produced by the execution of t1 in the current proof context, and I

How to prove excluded middle is irrefutable in Coq?

烈酒焚心 提交于 2019-12-03 00:20:54
I was trying to prove the following simple theorem from an online course that excluded middle is irrefutable, but got stuck pretty much at step 1: Theorem excluded_middle_irrefutable: forall (P:Prop), ~~(P \/ ~ P). Proof. intros P. unfold not. intros H. Now I get: 1 subgoals P : Prop H : P \/ (P -> False) -> False ______________________________________(1/1) False If I apply H , then the goal would be P \/ ~P , which is excluded middle and can't be proven constructively. But other than apply , I don't know what can be done about the hypothesis P \/ (P -> False) -> False : implication -> is

How to automatically prove simple equality of real numbers in Coq?

女生的网名这么多〃 提交于 2019-12-01 10:45:21
What I am looking for is an auto -like tactic that can prove simple equalities like: 1/2 = 2/4 So far, what I've tried manually is to use ring_simplify and field_simplify to prove equalities. Even this doesn't work out well (Coq 8.5b3). The example below works: Require Export Coq.Reals.RIneq. Local Open Scope Z_scope. Local Open Scope R_scope. Example test2: 1 = 1 / 1. Proof. field_simplify. field_simplify. reflexivity. Qed. But it was necessary to use field_simplfy twice before reflexivity . The first field_simplfiy gives me: 1 subgoal ______________________________________(1/1) 1 / 1 = 1 / 1