[comp.lang.prolog] Help on disassembler/decompilers

Jonathan.Bowen@prg.oxford.ac.uk (Jonathan Bowen) (09/13/90)

Speaking of decompilers, I have recently written a simple compiler in
Prolog based almost directly on a formal compiling specification.
Currently a high-level program can be supplied and object code produced
(non-deterministically, so several (possibly an infinite number of)
versions may be generated) or a high-level program and some object code
may be supplied and checked against one another.  Prolog in principle
can run backwards, so it may be possible to supply some object code and
produce a high-level program or programs as output. The main problem is
running the necessary arithmetic backwards (i.e. avoiding the use of
"is") and I am currently looking into this. Has anyone else done any
similar work or can anyone supply any useful references?

I am cross posting this to comp.lang.prolog as well as comp.compilers
for wider coverage.

--
Jonathan Bowen, Oxford.
-- 
Send compilers articles to compilers@esegue.segue.boston.ma.us
{ima | spdcc | world}!esegue.  Meta-mail to compilers-request@esegue.

kym@bingvaxu.cc.binghamton.edu.cc.binghamton.edu (R. Kym Horsell) (09/14/90)

In article <679@culhua.prg.ox.ac.uk> Jonathan Bowen <Jonathan.Bowen@prg.oxford.ac.uk> writes:
>produce a high-level program or programs as output. The main problem is
>running the necessary arithmetic backwards (i.e. avoiding the use of
>"is") and I am currently looking into this. Has anyone else done any
>similar work or can anyone supply any useful references?

Funny, I didn't _see_ this in comp.lang.prolog...

To answer your query, arithmetic _can_ be run backward.

One simple, but inefficient, technique is to use ``unary'' arithmetic.  (I.e.
zero is 0, 1 is suc(0), 2 is suc(suc(0))). Rewriting the is/2, >/2, etc is a
pain but it _can_ be done.

Quite a lot of interesting work has been done on investigating which Prolog
relations can run backward -- look thru the Int Conf on Logic Prog & similar
things (they only go a few years so why check out the ref for you)?

DHD Warren wrote a nice article in Software Practice and Experience regarding
compiler-writing in Prolog -- check that out too (he writes fairly _neat_
code for one thing, and we're talking about readability here).

-Kym Horsell
-- 
Send compilers articles to compilers@esegue.segue.boston.ma.us
{ima | spdcc | world}!esegue.  Meta-mail to compilers-request@esegue.

hawley@icot32.icot.or.jp (David John Hawley) (09/15/90)

In article <679@culhua.prg.ox.ac.uk> Jonathan Bowen <Jonathan.Bowen@prg.oxford.ac.uk> writes:
>.... The main problem is running the necessary arithmetic backwards (i.e.
>avoiding the use of "is") and I am currently looking into this. Has anyone
>else done any similar work or can anyone supply any useful references?

I'm not confident that that is the major problem, but as far as
"more declarative" realizations of arithmetic (and other non-logical goodies),
check out "constraint logic programming". See the recent pair of articles
in the July/90 CACM - an interpreter and compiler are available for the
CLP(R) language mentioned there (for academic use).

If you are concerned about completeness issues for your "invertible 'is'",
maybe you would be interested in our Grobner-base constraint solver,
the "elephant gun approach" also mentioned in the above articles ;-)

David Hawley,
CAL group, ICOT
-- 
Send compilers articles to compilers@esegue.segue.boston.ma.us
{ima | spdcc | world}!esegue.  Meta-mail to compilers-request@esegue.