From: skaller <skaller@users.sourceforge.net>
To: Andrej.Bauer@andrej.com
Cc: Caml list <caml-list@inria.fr>
Subject: Re: [Caml-list] Coinductive semantics
Date: Mon, 23 Jan 2006 02:35:48 +1100 [thread overview]
Message-ID: <1137944149.8961.103.camel@rosella> (raw)
In-Reply-To: <43D37955.90408@andrej.com>
On Sun, 2006-01-22 at 13:23 +0100, Andrej Bauer wrote:
> skaller wrote:
> If everyone believed in type theory, compilers would be easy to write.
LOL!
> Every time a programmer wanted to address an element of an array, he
> would provide not just the index k but also the proof p that k is a
> valid index. Compiler would just have to check that p is a valid proof
> (easy when p is a formal proof). But programmers don't want to do that.
Actually some of us would like to do it .. however this is moving
past my real problem.
I'm willing to accept that the typing may end up being unsound
in the sense the compiler cannot prove what it needs to:
this is actually easy to fix, by simply inserting a runtime
check.
Also, in this particular case (arrays) the run time representation
is already known (literally it is the same as a variant,
where the discriminant tag is the array length). This is very
nice, since you can actually match on it against particular
constant lengths.
My problem is more categorical: given your explanation that
this is a dependent typing thing, how do I represent
such typing in the compiler?
If the type of the *value* of the array bound is a unitsum,
what is the type of the store containing that value?
In particular if I have a match:
match somearray_of_float with
| (case 1 of NAT) data => ... // 0 elements
| (case 2 of NAT) data => ... // 1 elements
| (case ?n of NAT) data => // n-1 elements
what is NAT? At present my type system only has terms like:
type t = [
| `tuple of t list
| `sum of t list
| `unitsum of int
...
so they're all just constants. How do I modify the type system
to allow for a variable? Do I have to actually put executable
terms into the type terms? That would account for construction,
what about destructors (pattern matches)?
Clearly the match has to get out a run time representation
of the length .. but it isn't an integer: I mean, the encoding
at run time is certainly an integer .. but what is the
type ascribed to this value? I called it NAT above ..
what, categorically, is NAT?
BTW: I think all this analysis could apply to Ocaml too.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
next prev parent reply other threads:[~2006-01-22 15:36 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-05 18:23 Alessandro Baretta
2006-01-05 19:48 ` [Caml-list] " David Baelde
2006-01-06 13:12 ` Andrej Bauer
2006-01-10 11:10 ` Francisco J. Valverde Albacete
2006-01-11 8:34 ` Hendrik Tews
2006-01-11 12:19 ` skaller
2006-01-11 14:54 ` Andrej Bauer
2006-01-12 2:10 ` skaller
2006-01-12 14:03 ` Andrej Bauer
2006-01-12 21:54 ` skaller
2006-01-13 10:23 ` Hendrik Tews
2006-01-13 14:42 ` skaller
2006-01-18 12:58 ` Hendrik Tews
2006-01-18 14:22 ` skaller
2006-01-20 0:49 ` William Lovas
2006-01-20 9:57 ` Andrej Bauer
2006-01-20 18:59 ` William Lovas
2006-01-20 20:59 ` skaller
2006-01-21 18:36 ` Andrej Bauer
2006-01-22 3:16 ` skaller
2006-01-22 12:23 ` Andrej Bauer
2006-01-22 15:35 ` skaller [this message]
2006-01-22 17:26 ` Kenn Knowles
2006-01-22 21:52 ` Andrej Bauer
2006-01-21 19:06 ` Andrej Bauer
2006-01-13 10:40 ` Andrej Bauer
[not found] ` <43C7B17A.1070503@barettadeit.com>
2006-01-14 16:53 ` Andrej Bauer
2006-01-05 20:38 Don Syme
2006-01-06 15:33 ` Alessandro Baretta
2006-01-08 10:02 ` Andrej Bauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1137944149.8961.103.camel@rosella \
--to=skaller@users.sourceforge.net \
--cc=Andrej.Bauer@andrej.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox