Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Elegant way to show Equivalence (fun m n => Nat.eqb m n = true) from standard library lemmas?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Elegant way to show Equivalence (fun m n => Nat.eqb m n = true) from standard library lemmas?


Chronological Thread 
  • From: Jonathan Leivent <jonikelee AT gmail.com>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] Elegant way to show Equivalence (fun m n => Nat.eqb m n = true) from standard library lemmas?
  • Date: Thu, 2 Jun 2016 13:16:31 -0400
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=jonikelee AT gmail.com; spf=Pass smtp.mailfrom=jonikelee AT gmail.com; spf=None smtp.helo=postmaster AT mail-qk0-f182.google.com
  • Ironport-phdr: 9a23:bB4MWRK1bHGPk0kfc9mcpTZWNBhigK39O0sv0rFitYgULv3xwZ3uMQTl6Ol3ixeRBMOAu6MC1rud6vixEUU7or+/81k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i760zceF13FOBZvIaytQ8iJ35XxirH5osWCKyxzxxODIppKZC2sqgvQssREyaBDEY0WjiXzn31TZu5NznlpL1/A1zz158O34YIxu38I46FppIZ8VvDxeL19RrhFBhwnNXo07Yvlr0rtVwyKs1kbVGwKkhNOSyzI7Q/3WIu55in9sOt+1S2XMOX5SLk1XXKp6KI9G0ygszsOKzNsqDKfscd3lq8O+B8=


Require Export Relations Morphisms Setoid Equalities.
Require Import Arith.

Search Nat.eqb.

Lemma eqb_equiv : Equivalence (fun m n => Nat.eqb m n = true).
Proof.
constructor; hnf; intros; rewrite Nat.eqb_eq in *; congruence.
Qed.

On 06/02/2016 12:40 PM, Soegtrop, Michael wrote:
Dear Coq Users,

sometimes I am struggling a bit with type classes. I wonder if there is an
elegant way to show:

Lemma eqb_equiv : Equivalence (fun m n => Nat.eqb m n = true).

This would follow easily from Nat.eq_equiv and Nat.eqb_eq, if I could rewrite
with Nat.eqb_eq under the lambda. I tried setoid_rewrite like this:

Require Export Relations Morphisms Setoid Equalities.
Require Import Arith.
Lemma eqb_equiv : Equivalence (fun m n => Nat.eqb m n = true).
Proof.
setoid_rewrite Nat.eqb_eq.

But I don't quite understand what to supply to get rid of the resulting error
message:

Error: setoid rewrite failed: Unable to satisfy the following constraints:
In environment:
do_subrelation := Morphisms.do_subrelation : apply_subrelation

?p : "@Proper (forall _ : relation nat, Prop)
(@respectful (relation nat) Prop
(@pointwise_relation nat (forall _ : nat, Prop)
(@pointwise_relation nat Prop iff)) (@Basics.flip Prop Prop
Prop Basics.impl))
(@Equivalence nat)"

The description in the manual is a bit too short for me to understand it.

Or is there a more elegant way to prove this without a rewrite under the
binder?

Or is there already an instance for this in the library?

Thanks & best regards,

Michael

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928





Archive powered by MHonArc 2.6.18.

Top of Page