coq

Use proof of if expression = true in then part coq

大城市里の小女人 提交于 2019-12-12 20:56:21
问题 Forall 1 <= a and 2 <= b exists k that (b^k) divide a but (b^(k+1)) do not divide a ; And I want to calculate k in coq: Require Import ZArith Znumtheory. Local Open Scope Z_scope. Require Coq.Program.Tactics. Require Coq.Program.Wf. Lemma divgt0 ( a b : Z ) ( agt0 : 0 < a ) ( bgt1 : 1 < b ) (dvd : (b|a) ) : 0<a/b. Proof. apply Zdivide_Zdiv_lt_pos. auto. auto. auto. Qed. Program Fixpoint factor ( a b : Z ) ( agt0 : 0 < a ) ( bgt1 : 1 < b ) {measure (Z.abs_nat a)} := if Zdivide_dec b a then

Proof in COQ that equality is reflexivity

假装没事ソ 提交于 2019-12-12 18:28:34
问题 The HOTT book writes on page 51: ... we can prove by path induction on p: x = y that $(x, y, p) =_{ \sum_{(x,y:A)} (x=y)} (x, x, refl x)$ . Can someone show me how to proof this in COQ? Remarks: Sorry that I do not know how to render latex code here. That is not homework. 回答1: Actually, it is possible to prove this result in Coq: Notation "y ; z" := (existT _ y z) (at level 80, right associativity). Definition hott51 T x y e : (x; y; e) = (x; x; eq_refl) :> {x : T & {y : T & x = y} } := match

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 do I change a concrete variable to an existentially quantified var in a hypothesis?

 ̄綄美尐妖づ 提交于 2019-12-12 12:25:55
问题 Say I have a hypothesis like this: FooProp a b I want to change the hypothesis to this form: exists a, FooProp a b How can I do this? I know I can do assert (exists a, FooProp a b) by eauto but I'm trying to find a solution that doesn't require me to explicitly write down the entire hypothesis; this is bad for automation and is just generally a headache when the hypothesis are nontrivial. Ideally I'd like to specify intro_exists a in H1 or something; it really should be that simple. EDIT :

How does `auto` interract with biconditional (iff)

戏子无情 提交于 2019-12-12 12:15:30
问题 I noticed, that auto is ignoring biconditionals. Here is a simplified example: Parameter A B : Prop. Parameter A_iff_B : A <-> B. Theorem foo1: A -> B. Proof. intros H. apply A_iff_B. assumption. Qed. Theorem bar1: B -> A. Proof. intros H. apply A_iff_B. assumption. Qed. Theorem foo2_failing: A -> B. Proof. intros H. auto using A_iff_B. Abort. Theorem bar2_failing: B -> A. Proof. intros H. auto using A_iff_B. Abort. Now, I know that A <-> B is a syntactic sugar for A -> B /\ B -> A so I wrote

How to deal with really large terms generated by Program Fixpoint in Coq?

家住魔仙堡 提交于 2019-12-12 11:08:09
问题 I'm attempting to define and prove correct in Coq a function that efficiently diffs two sorted lists. As it does not always recurse on a structurally smaller term (either the first or second list is smaller), Fixpoint won't accept it, so I'm attempting to use Program Fixpoint instead. When attempting to prove a property of the function using the tactic simpl or program_simpl , Coq spends minutes computing and then produces a giant term, hundreds of lines long. I was wondering if I'm using

Is there a way to disable a specific notation in Coq?

我们两清 提交于 2019-12-12 11:04:04
问题 I'd like, in Coqide, to have the proof state not use a certain notation (but still use all others). Is this possible? 回答1: From what I understand in the documentation, it is not possible. You might be able to play with opening/closing scopes but I'm not sure it will work, since it is stated explicitly that notations will be used for printing whenever possible. 回答2: Some tricks that might be sufficient are described here: How to disable my custom notation in Coq? I wanted to add pointer to

How can I prove propositional extensionality in Coq?

ⅰ亾dé卋堺 提交于 2019-12-12 10:45:07
问题 I'm trying to prove a substitution theorem about Prop, and I'm failing miserably. Can the following theorem be proven in coq, and if not, why not. Theorem prop_subst: forall (f : Prop -> Prop) (P Q : Prop), (P <-> Q) -> ((f P) <-> (f Q)). The point is that the proof, in logic, would be by induction. Prop isn't defined inductively, as far as I can see. How would such a theorem be proven in Coq? 回答1: Here's the answer: The property I was looking for is called propositional extensionality , and

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

How to define finite set of N elements in Coq?

喜你入骨 提交于 2019-12-12 09:26:53
问题 How to define, for general parameter N:nat , finite set of N elements, $ A_{0},...A_{N-1} $ ? Is there an elegant way to do it by recursive definition? Could someone point me into good example of reasoning about such structures? 回答1: A very convenient solution is to define the n th ordinal, 'I_n as a record: Record ordinal n := { val :> nat; _ : val < n; }. that is to say, a pair of a natural number, plus a proof that such natural number is less than n , where < : nat -> nat -> bool . It is