Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Opaque module typing with exposing function defs

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Opaque module typing with exposing function defs


Chronological Thread 
  • From: Julia Belyakova <julbinb AT gmail.com>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] Opaque module typing with exposing function defs
  • Date: Thu, 27 Apr 2017 01:03:24 +0000
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=julbinb AT gmail.com; spf=Pass smtp.mailfrom=julbinb AT gmail.com; spf=None smtp.helo=postmaster AT mail-ua0-f174.google.com
  • Ironport-phdr: 9a23:UwQbPh/6nB6qzf9uRHKM819IXTAuvvDOBiVQ1KB52ukcTK2v8tzYMVDF4r011RmSDNmds6oMotGVmpioYXYH75eFvSJKW713fDhBt/8rmRc9CtWOE0zxIa2iRSU7GMNfSA0tpCnjYgBaF8nkelLdvGC54yIMFRXjLwp1Ifn+FpLPg8it2e2//5Lebx9UiDahfLh/MAi4oQLNu8cMnIBsMLwxyhzHontJf+RZ22ZlLk+Nkhj/+8m94odt/zxftPw9+cFAV776f7kjQrxDEDsmKWE169b1uhTFUACC+2ETUmQSkhpPHgjF8BT3VYr/vyfmquZw3jSRMMvrRr42RDui9b9mRxDmiCgFNzA3/mLZhNFugq1Hux+uvQBzzpTObY2JKPZzfKXQds4aS2pbWcZRUjRMDIehb4sLDuoOJ/tTopTjqFsKrRqxHwqsBOTxyjBSm3T72q860/klEQ7d3QwgGckBvW/brNXwLqgSUOS1wLPUwjXEavNbwDHw45XLfBA5ufyAQ658fM7LxUQsFw7JlEucpZHnMj+Py+gAsWeW4ux9Xuy1kWEnsRt+oj23y8cslIbJgoUVx0jB9SpjwYY1IcS0SFNhbtK4CZdQuTyWOol5T884TGFovyE6yrICuZGlZiQF1JMnxxvHZ/yGdYiH/A7jWf6PLTtkgH9pYrGyihao/US+1+HxVNO43EtIoydKitXMs2oC1x3X6siJUPt9+UKh1C6N1wDO7uFLOkE0lazAJJM6zb4wk4AcsUXHHiPshEr2i6qWel0++ue08+TnfqnmppiEOoBojQH+K70ildC7AeQlKQcDRHOb+OS51L3750L1WrRKjvsskqnYqp/WP8obprTqSzNSh40k8lO0Cyqs+NUeh3gOalxfKzydiI28GUzKIfmwJ/q7kl2vlylij6TEI7nrA5PHBnfGmbblO7167hgPm0II0dlD6scMWfk6K/XpVxqpuQ==

Thank you for reply!

Are there other ways to hide some parts of a module except for opaque typing? I am primarily interested in hiding auxiliary lemmas.

It seems to me strange though that one cannot actually _use_ functions from the opaque-typed module. 

--
Kind regards,
Julia


ср, 26 апр. 2017 г., 17:10 ikdc <ikdc AT mit.edu>:
On 04/26/2017 04:57 PM, Julia Belyakova wrote:
> Dear Coq users,
>
> I guess it's a stupid question, but...
>
> I want to define a module with certain parts being hidden. For this I
> define a module type and then use opaque typing for the module. And the
> problem is that now I cannot compute functions of the module, their
> definitions are not accessible.
>
> Please, find a simple example below.
>
> Module Type Addition.
>   Parameter t : Type.
>   Parameter add : t -> t -> t.
> End Addition.
>
> Module MAddition : Addition with Definition t := nat.
>   Definition t := nat.
>   Definition add x y := x + y.     (* I want this to be available *)
>   Definition priv_id (x : t) := x. (* This must be hidden *)
> End MAddition.
>
> (* priv_id is not available as desired *)
> (* Compute (MAddition.priv_id 4). *)
> (* add is available, but the call does not reduce to 7 *)
> Compute (MAddition.add 3 4).
>


If I understand correctly, I don't think you can do this.  The fact that
the module type is opaque means that any program which uses a module
with that type must behave the same way; in particular it may not unfold
the definitions hidden by the module type.  You could of course do this:


Module MAddition : Addition
     with Definition t := nat
     with Definition add := fun x y => x + y.
   Definition t := nat.
   Definition add x y := x + y.
   Definition priv_id (x : t) := x.
End MAddition.


But if you want to be able to compute through [add], then perhaps the
module type "Addition" isn't actually the interface you want to be using
in the first place.

I don't know very much about the module system, so someone please
correct me if this is wrong.

--
Istvan Chung




Archive powered by MHonArc 2.6.18.

Top of Page