Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] [NEWBIE] Applying Nat.eq_dec

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] [NEWBIE] Applying Nat.eq_dec


Chronological Thread 
  • From: Yao Li <liyao AT seas.upenn.edu>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] [NEWBIE] Applying Nat.eq_dec
  • Date: Fri, 5 Jan 2018 16:59:44 -0500
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=liyao AT seas.upenn.edu; spf=Pass smtp.mailfrom=liyao AT seas.upenn.edu; spf=None smtp.helo=postmaster AT hound.seas.upenn.edu
  • Ironport-phdr: 9a23:zPNm5x1VCB6bdXNOsmDT+DRfVm0co7zxezQtwd8Zse0WL/ad9pjvdHbS+e9qxAeQG9mDsrQc06L/iOPJYSQ4+5GPsXQPItRndiQuroEopTEmG9OPEkbhLfTnPGQQFcVGU0J5rTngaRAGUMnxaEfPrXKs8DUcBgvwNRZvJuTyB4Xek9m72/q99pHPfglEniaxba9vJxiqsAvdsdUbj5F/Iagr0BvJpXVIe+VSxWx2IF+Yggjx6MSt8pN96ipco/0u+dJOXqX8ZKQ4UKdXDC86PGAv5c3krgfMQA2S7XYBSGoWkx5IAw/Y7BHmW5r6ryX3uvZh1CScIMb7S60/Vza/4KdxUBLmiDsIODEk/m/ZhMx+kqBUrhGmqRFk2YHYfISVOeB+fq/Bf94XQ3dKUMZLVyxGB4Oxd4kAAPAGPe1FqYf9pkYFoBy6BQmtBOLg0DhIi2Tt3aIkyeshChvK3BE4H90QtnTUqs/5O7kPXuCo1aTFyyjIYfBO2Trl9YTFchMsreuRUb9+bcbd00siGx7fglmNp4HpIyuZ2vkNvmWY9eZsSOyih3I9pw1vvjSj290ghpTUio8T11vK7z92wJwvKt29UEN7YcCrEJ9XtyyCN4t2Rd4iQ2d1tyog0b0Jp4S0fDMQxJQ63x7QdfqHc46S7h39SemRPC90hHNjeL2hmxa/6VWsx+3/W8WuzVpHoDZJnsPOu3wQzRDf98aKRudl8kekwzmP1gTT6u9eIUAzkKrWM5ohwr8wl5UJtkTOBTT2l1vsg6+NbEkk5/Co5PrhYrXgvJOTKZJ7ihzmPqQ0hsO/Gfg4MhQJX2WD5eu806Tj8VTlT7VOk/05ibLUsIvaJMQevq62GRVZ0ocl6xalDjepys4UnXcdLAENRBXShI/wflrKPfrQDPGlgl3qni046erBO+jQC5KFCnmLxLPgbL96w1VRwRF10MhS4ZQSB70cdqGgEnTtvcDVW0dqeze/xPzqXY1w

In your first proof: your goal is falsehood, but you also have a contradiction in your hypothesis. The “contradiction” tactic should be able to solve the goal.

Your second proof seems to be on the wrong track. I guess what you are trying to say is that [a] always equals to [a], but that is not what [trivialEq] is actually saying...

A general lemma that may be useful to you is:

Lemma eq_dec_refl_branch {A} : forall a (b c : A),
    (if Nat.eq_dec a a then b else c) = b.
Proof. intros. destruct (Nat.eq_dec a a); auto; contradiction. Qed.

Best,
Yao

On 5 Jan 2018, at 4:12 PM, Ramkumar Ramachandra <artagnon AT gmail.com> wrote:

Now I have an additional Lemma which I'm not able to apply, due to "Cannot change D, it is used in conclusion". 

Lemma trivialEq : forall a : M.key, {a = a} + {a <> a} -> True.
Proof.
trivial.
Qed.

Lemma keyInMap : forall a b, M.find (elt := nat) a [a |-> b] = Some b.
Proof.
intros.
unfold update. unfold fst. unfold snd.
rewrite F.add_o.
unfold Nat_as_OT.eq_dec.
remember (Nat.eq_dec a a) as D.
apply trivialEq in D.

My hypothesis and goals window looks like this in the last step:
  • a: M.key
  • b: nat
  • D: {a = a} + {a <> a}
  • HeqD: D = Nat.eq_dec a a
  • 1/1(if D then Some b else M.find (elt:=nat) a [ ]) = Some b
Why do I get the error? I have all the right types for unification.

Thanks.

Ram

On Thu, Jan 4, 2018 at 6:47 PM, Ramkumar Ramachandra <artagnon AT gmail.com> wrote:
Hi folks,

I'm trying to use Coq to prove that M.find (referring to FMapAVL) finds an element that exists in the map. Here's my progress so far:

Lemma keyInMap : forall a b, M.find (elt := nat) a [a |-> b] = Some b.
Proof.
intros.
unfold update. unfold fst. unfold snd.
rewrite F.add_o.
unfold Nat_as_OT.eq_dec.
remember (Nat.eq_dec a a) as D.
induction D.
reflexivity.
rewrite F.empty_o.
Qed.


Somehow, I get stuck with this to prove:
  • a: M.key
  • b: nat
  • b0: a <> a
  • HeqD: right b0 = Nat.eq_dec a a
  • 1/1None = Some b
Which is a falsehood, so I think I did the wrong thing by using "induction D". To eliminate one of the cases of the `if`, I will need to apply `Nat.eq_dec`, and I'm unable to apply it for some strange reason.

Some pointers would be appreciated.

Thanks.

Ram





Archive powered by MHonArc 2.6.18.

Top of Page