From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: Guillaume Yziquel <guillaume.yziquel@citycable.ch>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Reasoning about categories at compile-time.
Date: Thu, 31 Mar 2011 08:02:30 +0200 [thread overview]
Message-ID: <AANLkTi=KiBAvGbW9i1zXPfkxNtiQxQ-uyNHxnXTUe+pt@mail.gmail.com> (raw)
In-Reply-To: <20110330222702.GF20598@localhost>
[-- Attachment #1: Type: text/plain, Size: 3234 bytes --]
First, one obvious solution : parse the equations, run a solver, then output
"()" if it can deduce the queries from the equations, and "1 = true"
otherwise. Why isn't this solution satisfying ?
With the type system there is one thing that is easy and natural to do : you
could encode your arrows as elements with a specific type (eg. for an arrow
`f` of source `src` and destination `dst` you would write `(src, f, dst)
arrow` with `src, f, dst` abstract types) :
arrow_f : (foo, f, bar) arrow
then write both a composition function
compose : ('a, 'f, 'b) arrow -> ('b, 'g, 'c) arrow -> ('a, ('f, 'g) comp,
'c) arrow
and terms representing your equational theory:
assoc : ('a, (('f, 'g) comp, 'h) comp, 'b) arrow -> ('a, ('f, ('g, 'h)
comp) comp, 'b)
and for each equation f o g = h (not that I use `g` and not `'g`)
witness_fg_h : ('a, (f, g) comp, 'b) arrow -> ('a, h, 'b) arrow
Then, for each deducible relation, there exist a typed term that is a proof
witness of the relation deductibility (you just unify the type of the two
arrows that should be equal). If you have a solver for equation
deductibility, you can ask him to output the proof witness in this format.
This does not use the inference system to solve your problem, which is what
you asked for. But this is a solid design that is going to still work if you
change your language, eg. can still be used on non decidable questions. I
think this is a good first step; feel free to improve it by whatever
advanced type hackery.
On Thu, Mar 31, 2011 at 12:27 AM, Guillaume Yziquel <
guillaume.yziquel@citycable.ch> wrote:
> Hello.
>
> I have a small problem that I would wish to encode in the type system,
> and I would like some advice on how to do that using Camlp4.
>
> You have a finite category (in the sense of a finite number of objects),
> and a finite set of arrows that generates all the arrows. Let's assume
> that you have tokens (Camlp4 a_LIDENT) for all of these.
>
> I want my Camlp4 syntax extension to operate on an .mli interface file
> and an .ml file.
>
> The .mli interface should contain all the relations you want to enforce
> concerning composition of arrows.
>
> The .ml file should contain some relations about composition of arrows.
>
> If I compile the preprocessed .ml file against the preprocessed .mli
> file, I want it to type check if and only if all relations in the .mli
> file can be deduced from relations in the .mli file.
>
> If, for instance the unprocessed .mli file contains
>
> f o g o h = i o j o k
>
> and the unprocessed .ml file contains
>
> f o g = i
> h = j o k
>
> I want it to type check fine. I you ommit h = j o k, I want the type
> checker to fail.
>
> This is purely type-system-ish, and I really do not care how arrows are
> encoded (types, type parameters, fun (type arrow) -> stuff).
>
> Is there a way to use Camlp4 to encode this in the type system?
> Intuitively, I'd say yes, but I currently do not see how.
>
> --
> Guillaume Yziquel
>
> --
> Caml-list mailing list. Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>
[-- Attachment #2: Type: text/html, Size: 4101 bytes --]
next prev parent reply other threads:[~2011-03-31 6:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-30 22:27 Guillaume Yziquel
2011-03-31 6:02 ` Gabriel Scherer [this message]
2011-03-31 23:46 ` Guillaume Yziquel
2011-04-03 7:25 ` Andrej Bauer
2011-04-03 21:03 ` Guillaume Yziquel
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='AANLkTi=KiBAvGbW9i1zXPfkxNtiQxQ-uyNHxnXTUe+pt@mail.gmail.com' \
--to=gabriel.scherer@gmail.com \
--cc=caml-list@inria.fr \
--cc=guillaume.yziquel@citycable.ch \
/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