Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Question about definitions inside type classes

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Question about definitions inside type classes


Chronological Thread 
  • From: Ben Sherman <sherman AT csail.mit.edu>
  • To: coq-club AT inria.fr, John Wiegley <johnw AT newartisans.com>
  • Subject: Re: [Coq-Club] Question about definitions inside type classes
  • Date: Thu, 27 Apr 2017 09:26:31 -0400
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=sherman AT csail.mit.edu; spf=Pass smtp.mailfrom=sherman AT csail.mit.edu; spf=None smtp.helo=postmaster AT outgoing-stata.csail.mit.edu
  • Ironport-phdr: 9a23:R6jtqxxLVdOx0m7XCy+O+j09IxM/srCxBDY+r6Qd2+8QIJqq85mqBkHD//Il1AaPBtSHraocw8Pt8InYEVQa5piAtH1QOLdtbDQizfssogo7HcSeAlf6JvO5JwYzHcBFSUM3tyrjaRsdF8nxfUDdrWOv5jAOBBr/KRB1JuPoEYLOksi7ze6/9pncbglSmDaxfa55IQmrownWqsQYm5ZpJLwryhvOrHtIeuBWyn1tKFmOgRvy5dq+8YB6/ShItP0v68BPUaPhf6QlVrNYFygpM3o05MLwqxbOSxaE62YGXWUXlhpIBBXF7A3/U5zsvCb2qvZx1S+HNsDtU7s6RSqt4LtqSB/wiScIKTg58H3MisdtiK5XuQ+tqwBjz4LRZoyeKfhwcb7Hfd4CRWROQsVfWCNcDI2yYYsBEegOM+FDoobnu1cOqAGzBQmwCO7tzDJDm3/43bc90+QkCQzLwRIvH9QTu3rJrNX6Kr0SUeWvw6nO0D7OaOhW2Tfj54jSdxAuu/eMUKlsfsrK00YvFgfFgk+VqYzkIzOZzPoCvHWG7+d5U++klmApqwZ0oje1x8csjJHEhoQLxVHK7yp52po1JdyjSEFhZ96kC4FcuD2dN4tzRM4pXmJmuD4ix7Ebp5K2fzIGxZo7yxLFdfCLaZaE7g//WOqJPDt1h2hpdK+8ihu260Stzu3xWtO33VtIqCdOj8PCuWoX1xPJ78iKUvt98Vml2TaIzw3T7fxEIVw7larcKp4hxLEwmoMIsUTfBCD2hF/5gLWKeUU/4Oeo6uDnbq/jpp+dK494kB/xPbkzmsCnAOQ4NBYBX3SD9OihyrHu/lf1TbtWgvEsjKXVqo7WKdkHqqKhBg9ayIcj6xKxDze819QYmGEKLElFeB2ZlYjpPkvBIPbjAPijmFSjijZrx/TcMr3kA5XNMmLPn6n8crZg80Jc0hY8zchD55JIDbEMOO78WkjotNDBEhA5NxG0zP38BdVm1oIeXHqPDbWDPKPTt1+I/OMvLPOWaI8bojauY8QisvXplDoynUIXVaivx5oeLn6iWrxEJEWfKUXtj9gFHHZC6gg5TOr1oFuPTjdJe3epVqQnoDo8DdT1I53EQ9WHjbrJ5ye2BJhfYCgSEVCBC3Lhca2PQP4NbGSXI9MnnzAZA+vyA7Q93A2j4Vepg4FsKfDZr2hB7cru

The issue is not so much that [adj_left] is being unfolded in the statement of [adj_left_nat], but rather that it has not yet even been defined at this point. Remember that [adj_left] must take an [Adjunction] as an argument, yet [adj_left_nat] must be present in the *definition* of an [Adjunction], so it cannot possibly refer to [adj_left]. The best one could do is think of the [adj_left] as defining a [let], but this still wouldn't help in unifying in the situation you're running into.

I have run into this issue before, and one approach that I took was to split up such a type class into two parts, one with the "data" and the other with the "proofs". The "proof" part would depend on the "data" part and live in [Prop] rather than [Type], or at least definitions of the "proof" class instances could be closed off opaquely, which can also be beneficial for performance reasons. Then your [adj_left] definition can come *after* the "data" part but before the "proof" part. You could still later choose to package up the data and proof part into a single object.

From: "John Wiegley" <johnw AT newartisans.com>
Subject: [Coq-Club] Question about definitions inside type classes
Date: April 25, 2017 at 4:59:11 AM EDT


I have a type class with some defined members:

Class Adjunction := {
 adj_iso  {a b} : F a ~{C}~> b ≊ a ~{D}~> U b;
 adj_left  {X Y} := to (@adj_iso X Y);
 adj_left_nat_l {a b c} (f : F b ~> c) (g : a ~> b) :
   adj_left _ _ (f ∘ fmap[F] g) ≈ adj_left _ _ f ∘ g
}.

As you can see, adj_left is defined directly in terms of adj_iso.

My problem is that I cannot rewrite suing adj_left_nat_l when I see a use of
"adj_left" in my goal, because adj_left_nat_l has already unfolded the
definition of adj_left and is actually now in terms of adj_iso. I have to
simplify my goal to unfold adj_left to a use of adj_iso, and then the rewrite
works.

Is there any way to make the member adj_left so that it does not unfold on
simplification, and is not unfolded in the type of adj_left_nat_l?

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2




Archive powered by MHonArc 2.6.18.

Top of Page