coq-tactic

Rewriting at the type level

天涯浪子 提交于 2019-12-24 05:45:05
问题 I have the following proof state: 1 subgoals U : Type X : Ensemble U Y : Ensemble U f : U -> U g : U -> U pF : proof_dom_cod U X Y f pG : proof_dom_cod U X Y g fg : f = g H : proof_dom_cod U X Y g = proof_dom_cod U X Y f ______________________________________(1/1) createarrow U X Y f pF = createarrow U X Y g pG So I want to assert (pF = pG) and then use proof irrelevance to prove that. Unfortunately, pF = pG is not valid because they have different types, even though I know the types to be

Rewrite hypothesis in Coq, keeping implication

给你一囗甜甜゛ 提交于 2019-12-24 02:16:31
问题 I'm doing a Coq proof. I have P -> Q as a hypothesis, and (P -> Q) -> (~Q -> ~P) as a lemma. How can I transform the hypothesis into ~Q -> ~P ? When I try to apply it, I just spawn new subgoals, which isn't helpful. Put another way, I wish to start with: P : Prop Q : Prop H : P -> Q and end up with P : Prop Q : Prop H : ~Q -> ~P given the lemma above - i.e. (P -> Q) -> (~Q -> ~P) . 回答1: This is not as elegant as just an apply , but you can use pose proof (lemma _ _ H) as H0 , where lemma is

How to prove excluded middle is irrefutable in Coq?

淺唱寂寞╮ 提交于 2019-12-20 10:44:57
问题 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 ,

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

匆匆过客 提交于 2019-12-19 10:32:50
问题 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 .

Coq: How to prove if statements involving strings?

寵の児 提交于 2019-12-13 08:09:53
问题 I have a string a and on comparison with string b , if equals has an string c , else has string x . I know in the hypothesis that fun x <= fun c . How do I prove this below statement? fun is some function which takes in string and returns nat . fun (if a == b then c else x) <= S (fun c) The logic seems obvious but I am unable to split the if statements in coq. Any help would be appreciated. Thanks! 回答1: If you can write an if-then-else statement, it means that the test expression a == b is in

How to automatically introduce symmetries into Coq hypotheses?

[亡魂溺海] 提交于 2019-12-13 07:04:49
问题 I have some equalities ( = ) and unequalities ( <> ) in the hypotheses such as: e : x2 = x1 n : x3 <> x1 I want to use tactics like assumption , but sometimes the expected (un)equality in the goal is in the other direction like: x1 = x2 x1 <> x3 My question is: Is it possible to automatically introduce the symmetric forms of (un)equality above into the hypotheses? If not, is it possible to use Notation to write a tactical to do this. So far, I can do this manually like this: assert (x1 = x2)

Decomposing equality of constructors with match expressions in Coq

China☆狼群 提交于 2019-12-13 05:38:58
问题 I have a question similar to Decomposing equality of constructors coq, however, my equality contains a match expression. Consider the example (which is nonsensical, but just used for clarification): Fixpoint positive (n : nat) := match n with | O => Some O | S n => match positive n with | Some n => Some (S n) | None => None (* Note that this never happens *) end end. Lemma positiveness : forall n : nat, Some (S n) = positive (S n). Proof. intro. simpl. At this point, with n : nat in the

How to add to both sides of an equality in Coq

佐手、 提交于 2019-12-12 12:56:47
问题 This seems like a really simple question, but I wasn't able to find anything useful. I have the statement n - x = n and would like to prove (n - x) + x = n + x I haven't been able to find what theorem allows for this. 回答1: You should have a look at the rewrite tactic (and then maybe reflexivity ). EDIT: more info about rewrite: You can rewrite H rewrite -> H to rewrite from left to right You can rewrite <- H to rewrite from right to left You can use the pattern tactic to only select specific

How to leverage auto's searching and hint databases in custom tactics?

心已入冬 提交于 2019-12-12 09:46:09
问题 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

Substitute argument of `fix` in proof

拜拜、爱过 提交于 2019-12-11 15:15:48
问题 This question is probably trivial, but I'm stuck on it since yesterday and I couldn't find the relevant keyword to search for. Consider the following: Fixpoint mfp (t: nat*nat) := fst t. Lemma ml: forall (t: nat*nat), mfp t = fst t. Proof. intros. unfold mfp. (* substitute t0 with t in lhs *) reflexivity. Qed. After unfolding mfp , I have to prove (fix mfp (t0 : nat * nat) : nat := fst t0) t = fst t which trivially holds, yet I don't know how to tell Coq "Do the substitution of t0 by t ". Do