caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Jean-Baptiste Rouquier" <jean-baptiste.rouquier@ens-lyon.org>
To: <skaller@ozemail.com.au>, "caml-list" <caml-list@inria.fr>
Subject: Re: [Caml-list] flow optimisation q
Date: Fri, 2 Jan 2004 22:42:26 +0100	[thread overview]
Message-ID: <002b01c3d179$520149d0$e228f9c1@zyfo> (raw)
In-Reply-To: <1072936720.4626.18.camel@pelican>

> Suppose there is a set of
> primitive procedures pr1 pr2 and a procedure constructor:
>
> proc = proc list
>
> which defines a new procedure to be a list of calls
> to other procedures, with mutual recursion allowed.
>
> A special procedure is the empty
> procedure whose call list is empty.
>
> Problem: remove all empty procedures
> (and of course calls to them).

This is a graph problem : draw a vertice for each proc and a vertice from a
to b when b calls a (so a -> b mean "a is called by b").
First suppose that there are no cycle. You just have to start from primitive
procs, mark recursively all their callers, and delete all non marked
vertices.
O(n).

If there are cycle and if you want to keep a structure like
a calls b
b calls a
where neither a nor b is a primitive proc, you can calculate strongly
connected components of your graph. Then draw the graph of this strongly
connected components (vertices are the strongly connected components, and
there is an edge A -> B iff there exists a in A and b in B such that there
is an edge a -> b in the first graph). Finnally apply the first algorithm
using components with two or more procs as primitives procs, plus the
initial primitives procs.


> My current algorithm is functional:
> make a new set of procedures which
> (a) excludes empty procedures
> (b) has calls to empty procedures elided
>
> To make this solve the problem requires
> repeated application until there are no
> empty procedures left.
 Seems O(n^2).

Jean-Baptiste Rouquier.


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2004-01-02 21:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-03  2:54 skaller
2004-01-02 21:42 ` Jean-Baptiste Rouquier [this message]
2004-01-03 18:02 ` Damien Doligez
2004-01-03 18:16   ` skaller

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='002b01c3d179$520149d0$e228f9c1@zyfo' \
    --to=jean-baptiste.rouquier@ens-lyon.org \
    --cc=caml-list@inria.fr \
    --cc=skaller@ozemail.com.au \
    /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;
as well as URLs for NNTP newsgroup(s).