From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id B40F3E0128 for ; Wed, 31 Aug 2022 03:21:29 +0200 (CEST) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=garrigue@math.nagoya-u.ac.jp; spf=None smtp.mailfrom=garrigue@math.nagoya-u.ac.jp; spf=None smtp.helo=postmaster@ms.math.nagoya-u.ac.jp Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of garrigue@math.nagoya-u.ac.jp) identity=pra; client-ip=133.6.130.11; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="garrigue@math.nagoya-u.ac.jp"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of garrigue@math.nagoya-u.ac.jp) identity=mailfrom; client-ip=133.6.130.11; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="garrigue@math.nagoya-u.ac.jp"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@ms.math.nagoya-u.ac.jp) identity=helo; client-ip=133.6.130.11; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="postmaster@ms.math.nagoya-u.ac.jp"; x-conformance=sidf_compatible IronPort-SDR: KBeniEQES8XQDPoIzHmPoAsI8+piqHohEKtvLp2LgF2F14oBiznM6i3ZkaASzuXQxHhn1NfO36 QLpLbMP1bMQPQDloy3RGZ2Igj133jihO/Z2/4sHGaKNZAj5ulCKcKeIO5Epw7y/3e8lO87D31E qRJO8/z0ldsZv355E4ewUit7nEVpzLGSTlAiWByMz+Ys7QayzJgwkh0YACzbkrrVCgEKANLPUK Dr8rQNtSCgHIIxqtfkVKJHhLxvThu4PPSGCDVGzKBePCJUKeZHilVyfJmiSov4EmbWY0Ztw0IL AYssJ3sJ+9xJpHnBtY90b9jQ X-IPAS-Result: =?us-ascii?q?A0BWAQD1tg5jlwuCBoVaFgcBAQEBCQESAQUFAYIPgSGBA?= =?us-ascii?q?4EBVysDBAtFhE6IfogPA4skk1YFAgkBAwENLAEGDQIEAQGCE4J0AoRlHgYGN?= =?us-ascii?q?BMBAgQBAQEBAwIDAQEBAQEBAwEBBQEBAQIBAQIEBAETAQEBAQEBAQE2BRBOZ?= =?us-ascii?q?GiBT4F6BgQwDYI1KQGDYwEBAQECAQEiBBkBATcBBAsJAgwMHAQBBgMCAiEHH?= =?us-ascii?q?hEGE4J9AYJtAw0lAhGNDJscen8ygQGCCAEBBoJggjkNKyZOgSQJgT2GewMbU?= =?us-ascii?q?VIBgTiGH0OCDYE8HIJnPoIgQgECgTZWgyk3gi6EGpMTBzcDCQQHBSweQgMLH?= =?us-ascii?q?w4WNRwDFAMFGAwHAxkPIw0NBBYHDAMDBSUDAgIbBwICAwIGFQUCAjUYOQgEC?= =?us-ascii?q?AQrGwkPBQIHLwUELwIeBAUGEQgCFgIGBAQEBBUCEAgCCCYXBxMzGQEFWRAJI?= =?us-ascii?q?RwOGg0FBhMDIG0FBz4PKDM1OSsdGwqBEiooFQMEBAMCBhMDAyACECwxAxQGK?= =?us-ascii?q?RMSLQcrdQkCAyJoBQMDBCgsAwk+BygmPAUFWToBBAMDECI9BgMJAwInX36UV?= =?us-ascii?q?4FBghCBMQYBAU9CB3aORQeEOREFkDKLOZIuboNchAcdhSk8gSKNA4F0hgQEL?= =?us-ascii?q?oN2gVCLAJgwHZZqjTmDY5EHLz4BhE81gRkqI4FbTTg7KgGCPAk1EAECAQIBD?= =?us-ascii?q?AECAgECAQIBAgEIAQECAY4cGYUXgUiCDoVZMjQCOQIGAQoBAQMJhUaCRIJIA?= =?us-ascii?q?QE?= IronPort-PHdr: A9a23:ozveiBJVcHSbpcF0Y9mcuDh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JdmycSMqyXMbEDt7ec3OChKadb/DCYytHSuQ4A9QYVcem6A5sQlztENg== X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="5.93,276,1654552800"; d="scan'208,217";a="50606243" X-MGA-submission: =?us-ascii?q?MDFeqlOqlkGSbla8EDC9Uz/QR4eJas6GnlaSN7?= =?us-ascii?q?zdAtZMzCMzxk9jwHtDcmtXh08MdY6e0Pqtsb6+uS1Bs7psFx5miyTxTh?= =?us-ascii?q?OLAXXvxw1RfTyKiNCiBcGRl1goBlzs1l/0GI3HRWwu+8+MTpr/QRWzv9?= =?us-ascii?q?MTK5ccAs2OBvzMcAztdjuoFA=3D=3D?= Received: from bsd20.math.nagoya-u.ac.jp (HELO ms.math.nagoya-u.ac.jp) ([133.6.130.11]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2022 03:21:25 +0200 Received: from smtpclient.apple (unknown [210.137.33.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ms.math.nagoya-u.ac.jp (Postfix) with ESMTPSA id 4306015EC016; Wed, 31 Aug 2022 10:21:21 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=math.nagoya-u.ac.jp; s=20160220; t=1661908881; bh=ySyeyagEkmrREI/bCNgaP2hVZtt4Rze+dFj2IXwUkfc=; h=From:Subject:Date:In-Reply-To:Cc:To:References; b=Y9cbz6aSNxIwORk0tBxNdPybPQBXAxuSOYx4FPSz1bjB2Xf9T1FpTFVvbL+thxuRW wC1uQdZWBkLpUKJHDofs6G7vfwZiCSAekNBv/JUE3oix9cdFfipoIqd+ZaQkqCmjmn IWZbPIr4hyTskzvtK5fGklbIoAM0XS+9/DTFlVFQ= From: Jacques Garrigue Message-Id: <1C6AD961-EBAA-4DB8-89C6-D89536366411@math.nagoya-u.ac.jp> Content-Type: multipart/alternative; boundary="Apple-Mail=_3123FD76-AE42-495E-87F5-55005DC02A4D" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Date: Wed, 31 Aug 2022 10:21:20 +0900 In-Reply-To: Cc: Mailing List OCaml To: Aaron Gray References: <25e68e2c-04d2-7764-e189-00812c08a34a@inria.fr> X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (ms.math.nagoya-u.ac.jp [0.0.0.0]); Wed, 31 Aug 2022 10:21:21 +0900 (JST) X-Virus-Scanned: clamav-milter 0.99.2 at bsdserver20 X-Virus-Status: Clean X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on bsdserver20.math.nagoya-u.ac.jp Subject: Re: [Caml-list] coinductive data types --Apple-Mail=_3123FD76-AE42-495E-87F5-55005DC02A4D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hello Aaron, If you are interested in the subtyping already available inside OCaml, it provides width subtyping for both objects and polymorphic variants. Polymorphic variants are algebraic datatypes, but their equality is structural rather than nominal, and they are limited to regular type definitions. For instance, the following subtyping on two variants of potentially = infinite streams is available: type 'a seq =3D 'a seqc lazy_t and 'a seqc =3D [`Nil | `Cons of 'a * 'a = seq] type 'a aseq =3D 'a aseqc lazy_t and 'a aseqc =3D ['a seqc | `App of 'a aseq * 'a aseq] let sub x =3D (x : 'a seq :> 'a aseq) (* val sub : 'a seq -> 'a aseq *) Jacques Garrigue > 2022/08/30 21:33=E3=80=81Aaron Gray >=E3=81=AE=E3=83=A1=E3=83=BC=E3=83=AB: >=20 > On Tue, 30 Aug 2022 at 12:12, Xavier Leroy > > wrote: >>=20 >> On Tue, Aug 30, 2022 at 9:24 AM Fran=C3=A7ois Pottier = > wrote: >>>=20 >>>=20 >>> Hello, >>>=20 >>> Le 29/08/2022 =C3=A0 17:43, Aaron Gray a =C3=A9crit : >>>> Does either ML or OCaML have coinductive data types ? And if so = could >>>> you please point me at the/some appropriate documentation on them. >>>=20 >>> ML and OCaml have algebraic data types, which are recursive (that = is, >>> more general than inductive and co-inductive types). Algebraic data >>> type definitions are not subject to a positivity restriction, and >>> algebraic data types can be constructed and deconstructed by = recursive >>> functions, which are not subject to a termination check. >=20 > Hello Xavier, >=20 > Thanks for putting me straight on that. >=20 > My original path of inquiry which I should have actually stated was > regarding how to go about implementing subtyping of mutually recursive > algebraic data types. >=20 > I am looking on how to go about this and using coinduction and > bisimulation seemed like the best fit or correct way to go about this. >=20 > Does OCaML use/handle subtyping of mutually recursive algebraic data > types ? And if so, is its implementation easily accessible ? >=20 >>> If you want to see a typical example of a "co-inductive" data = structure >>> encoded in OCaml, I suggest to have a look at "sequences", which can = be >>> described as potentially infinite lists: >>>=20 >>> https://v2.ocaml.org/api/Seq.html = >>>=20 >> Lazy evaluation (type Lazy.t) can also be used to define coinductive = data structures. >>=20 >> For concreteness, here are two definitions of the type of streams = (infinite lists) : >>=20 >> type 'a stream =3D unit -> 'a streamcell and 'a streamcell =3D { = head: 'a; tail: 'a stream } >> type 'a stream =3D 'a streamcell Lazy.t and 'a streamcell =3D { head: = 'a; tail: 'a stream } >>=20 >> and of the stream of integers starting from n : >>=20 >> let rec ints n =3D fun () -> { head =3D n; tail =3D ints (n + 1) } >> let rec ints n =3D lazy { head =3D n; tail =3D ints (n + 1) } >=20 > Thank you, yes I am familiar with this type of usage. >=20 > Regards, >=20 > Aaron >=20 >>>=20 >>=20 >> Hope this helps, >>=20 >> - Xavier Leroy >>=20 >>=20 >>>=20 >>> -- >>> Fran=C3=A7ois Pottier >>> francois.pottier@inria.fr >>> http://cambium.inria.fr/~fpottier/ >=20 >=20 >=20 > --=20 > Aaron Gray >=20 > Independent Open Source Software Engineer, Computer Language > Researcher, Information Theorist, and amateur computer scientist. --Apple-Mail=_3123FD76-AE42-495E-87F5-55005DC02A4D Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
Hello Aaron,

If you are interested in = the subtyping already available inside OCaml,
it = provides width subtyping for both objects and polymorphic = variants.
Polymorphic variants are algebraic = datatypes, but their equality is
structural rather = than nominal, and they are limited to regular type
definitions.

For instance, the following subtyping on two variants of = potentially infinite
streams is = available:

type 'a seq =3D 'a seqc lazy_t and 'a seqc =3D [`Nil | `Cons = of 'a * 'a seq]
type 'a aseq =3D 'a aseqc = lazy_t
 and 'a aseqc =3D ['a seqc | `App of 'a = aseq * 'a aseq]
let sub x =3D (x : 'a seq :> 'a = aseq)
(* val sub : 'a seq -> 'a aseq = *)

Jacques = Garrigue

2022/08/30 21:33=E3=80=81Aaron Gray <aaronngray.lists@gmail.com>=E3=81=AE=E3=83=A1=E3=83=BC=E3= =83=AB:

On Tue, 30 Aug 2022 at 12:12, Xavier Leroy
<xavier.leroy@college-de-france.fr> wrote:

On Tue, Aug 30, 2022 at 9:24 AM Fran=C3=A7ois Pottier <francois.pottier@inria.fr> wrote:


Hello,

Le 29/08/2022 =C3=A0 = 17:43, Aaron Gray a =C3=A9crit :
Does either ML or OCaML have coinductive data types ? And if = so could
you please point me at the/some appropriate = documentation on them.

ML and = OCaml have algebraic data types, which are recursive (that is,
more general than inductive and co-inductive types). = Algebraic data
type definitions are not subject to a = positivity restriction, and
algebraic data types can be = constructed and deconstructed by recursive
functions, = which are not subject to a termination check.

Hello Xavier,

Thanks for putting me straight on that.

My original path of inquiry = which I should have actually stated was
regarding how to go about implementing subtyping of mutually = recursive
algebraic = data types.

I am looking = on how to go about this and using coinduction and
bisimulation seemed like the = best fit or correct way to go about this.

Does OCaML use/handle subtyping of mutually recursive = algebraic data
types ? And if so, is its implementation easily accessible = ?

If you want to see a = typical example of a "co-inductive" data structure
encoded = in OCaml, I suggest to have a look at "sequences", which can be
described as potentially infinite lists:

  https://v2.ocaml.org/api/Seq.html

Lazy evaluation (type Lazy.t) can also be used = to define coinductive data structures.

For = concreteness, here are two definitions of the type of streams (infinite = lists) :

type 'a stream =3D unit -> 'a = streamcell and 'a streamcell =3D { head: 'a; tail: 'a stream }
type 'a stream =3D 'a streamcell Lazy.t and 'a streamcell =3D = { head: 'a; tail: 'a stream }

and of the = stream of integers starting from n :

let = rec ints n =3D fun () -> { head =3D n; tail =3D ints (n + 1) }
let rec ints n =3D lazy { head =3D n; tail =3D ints (n + 1) = }

Thank you, yes I am familiar with this type of = usage.

Regards,

Aaron



Hope this = helps,

- Xavier Leroy



--
Fran=C3=A7ois Pottier
francois.pottier@inria.fr
http://cambium.inria.fr/~fpottier/



-- Aaron Gray

Independent Open Source Software = Engineer, Computer Language
Researcher, Information Theorist, and amateur computer = scientist.

= --Apple-Mail=_3123FD76-AE42-495E-87F5-55005DC02A4D--