coq-tactic

How to use Coq arithmetic solver tactics with SSReflect arithmetic statements

左心房为你撑大大i 提交于 2021-01-28 03:11:21
问题 Coq has some convenient tactics for automatically proving arithmetic lemmas, for instance lia : From Coq Require Import ssreflect ssrfun ssrbool. From mathcomp Require Import ssrnat. Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Require Import Psatz. Lemma obv : forall (x y z: nat), (x < y)%coq_nat -> (y < z)%coq_nat -> (z < 3)%coq_nat -> (x < 3)%coq_nat. Proof. move => x y z xlty yltz zlt3. lia. Qed. The tactics do not directly support SSReflect-style

How to switch the current goal in Coq?

烂漫一生 提交于 2020-07-18 09:02:16
问题 Is it possible to switch the current goal or subgoal to prove in Coq? For example, I have a goal like this (from an eexists): ______________________________________(1/1) ?s > 0 /\ r1 * (r1 + s1) + ?s = r3 * (r3 + s2) What I want to do is to split and prove the right conjunct first. This I think will give the value of the existential variable ?s , and the left conjunct should be just a simplification away. But split by default set the left conjunct ?s > 0 as the current goal. _________________

How to explicitly use an induction principle in coq?

三世轮回 提交于 2020-05-16 22:06:15
问题 I'm trying to prove symmetry of propositional identity with the induction principal explicitly in Coq, but can't do it with the induction principle like I can in agda. I don't know how to locally declare a variable in Coq, nor do I know how to unfold a definition, as you can see below. How can I get a proof that resembles the agda one below? Inductive Id (A : Type) (x : A) : A -> Type := | refl : Id A x x. (* trivial with induction *) Theorem symId {A} {x y} : Id A x y -> Id A y x. Proof.

How to explicitly use an induction principle in coq?

我的梦境 提交于 2020-05-16 22:05:20
问题 I'm trying to prove symmetry of propositional identity with the induction principal explicitly in Coq, but can't do it with the induction principle like I can in agda. I don't know how to locally declare a variable in Coq, nor do I know how to unfold a definition, as you can see below. How can I get a proof that resembles the agda one below? Inductive Id (A : Type) (x : A) : A -> Type := | refl : Id A x x. (* trivial with induction *) Theorem symId {A} {x y} : Id A x y -> Id A y x. Proof.

How to explicitly use an induction principle in coq?

陌路散爱 提交于 2020-05-16 22:05:03
问题 I'm trying to prove symmetry of propositional identity with the induction principal explicitly in Coq, but can't do it with the induction principle like I can in agda. I don't know how to locally declare a variable in Coq, nor do I know how to unfold a definition, as you can see below. How can I get a proof that resembles the agda one below? Inductive Id (A : Type) (x : A) : A -> Type := | refl : Id A x x. (* trivial with induction *) Theorem symId {A} {x y} : Id A x y -> Id A y x. Proof.

Ltac: repeating a tactic n times with backtracking

六眼飞鱼酱① 提交于 2020-01-25 00:37:46
问题 Suppose I have a tactic like this (taken from HaysTac), that searches for an argument to specialize a particular hypothesis with: Ltac find_specialize_in H := multimatch goal with | [ v : _ |- _ ] => specialize (H v) end. However, I'd like to write a tactic that searches for n arguments to specialize a tactic with. The key is that it needs to backtrack. For example, if I have the following hypotheses: y : T H : forall (x : T), x = y -> P x x1 : T x2 : T Heq : x1 = y If I write do 2 (find

How does one inspect what more complicated tactics do in Coq step-by-step?

房东的猫 提交于 2020-01-24 04:08:52
问题 I was trying to go through the famous and wonderful software foundations book but I got to an example where simpl. and reflexivity. just do to much under the covers and are hindering my learning & understanding. I was going through the following theorem: Theorem plus_1_neq_0 : forall n : nat, beq_nat (n + 1) 0 = false. (* n+1 != 0 *) Proof. intros n. destruct n as [| n']. -simpl. reflexivity. -simpl. reflexivity. Qed. what I really want is something that allows me to go through step by step

Induction on predicates with product type arguments

倾然丶 夕夏残阳落幕 提交于 2020-01-04 13:26:13
问题 If I have a predicate like this: Inductive foo : nat -> nat -> Prop := | Foo : forall n, foo n n. then I can trivially use induction to prove some dummy lemmas: Lemma foo_refl : forall n n', foo n n' -> n = n'. Proof. intros. induction H. reflexivity. Qed. However, for a predicate with product type arguments: Inductive bar : (nat * nat) -> (nat * nat) -> Prop := | Bar : forall n m, bar (n, m) (n, m). a similar proof for nearly identical lemma gets stuck because all assumptions about variables

is there a `eapply`-like tactic that works on `exists` goals in Coq?

醉酒当歌 提交于 2019-12-24 15:25:14
问题 I have the following during a proof where the goal is an existential, and the target property is one of the assumptions. H : x ==> y ... ______________________________________(1/2) exists t : tm, x ==> t I know I can do exists y. apply H. to prove the current goal, but I am wondering if there is a more intelligent tactic that can use the assumption directly to prove the existential goal here, like eapply H ? Since this is one unification away, it would be nice not having to write the X part

how to rearrange terms in Coq using plus communtativity and associativity?

假装没事ソ 提交于 2019-12-24 14:34:29
问题 I have a general question about how to rearrange terms in Coq. For example, if we have a term m + p + n + p , humans can quickly re-arrange the terms to something like m + n + p + p (implicitly using plus_comm and plus_assoc). How do we do this efficiently in Coq? For a (silly) example, Require Import Coq.Arith.Plus. Require Import Coq.Setoids.Setoid. Theorem plus_comm_test: forall n m p: nat, m + p + (n + p) = m + n + 2 * p. Proof. intros. rewrite plus_assoc. simpl. rewrite <- plus_n_O. Now,