A simple monovariant Binding-Time Analyzer (BTA)

The sources of the BTA can be found here. Once you download this file, you can uncompress it with

  tar xvfz btaAbst.tgz
The btaAbst.tgz contains three files:

btaAbst.curry

monovariant BTA implementation

ack.curry

ackermann function

power.curry

power function

 

ack.curry

power.curry

data Nat = Z | S Nat

-- main call
s ackermann for a static the first argument (3) and

-- dynamic the second (x):

main x = ack (S (S (S Z)))  x

ack Z     n    = S n
ack (S m) Z    = ack m  (S Z)
ack (S m) (S n)= ack m  (ack (S m) n)
 

 data Nat = Z | S Nat

 

-- main calls power function with dynamic the first argument (x)

-- and static the second (4):

 

 main x = pow x (S (S (S (S Z))))

 

pow _ Z     = S Z

pow x (S n) = mult x (pow x n)

 

mult Z     _  = Z

mult (S v) n  = sum n (mult v n)

 

sum Z     n = n

sum (S v) n = S (sum v n)

In order to use the BTA, first you need to install the PAKCS (version 1.7.3) environment for Curry. Then, start PAKCS and load the file btaAbst.curry as follows:

[gustavo@cmm2 ]$ cd btamono
[gustavo@cmm2 btamono]$ pakcs
% restoring /usr/local/pakcs/curry2prolog/c2p.state...
  ______      __       _    _    ______   _______
 |  __  |    /  \     | |  / /  |  ____| |  _____|   Portland Aachen Kiel
 | |  | |   / /\ \    | |_/ /   | |      | |_____    Curry System
 | |__| |  / /__\ \   |  _  |   | |      |_____  |
 |  ____| / ______ \  | | \ \   | |____   _____| |   Version 1.7.3 (10)
 |_|     /_/      \_\ |_|  \_\  |______| |_______|   September 2006

Curry2Prolog(sicstus) Compiler Environment (Version of 15/09/06)
(RWTH Aachen, CAU Kiel, Portland State University)

Bug reports: mh@informatik.uni-kiel.de

Type ":h" for help

Prelude> :l btaAbst
Parsing 'btaAbst.curry'...
generating btaAbst.fcy ...
Compiling './btaAbst.fcy' into './btaAbst.pl'...done
btaAbst> bta "power" [D]

---- calculating BTA ----
generating power.acy ...
... Computing Division

[[D],[S,S],[S,S],[S,S]]
[[D],[D,S],[S,S],[S,S]]
[[D],[D,S],[D,D],[S,S]]
[[D],[D,S],[D,D],[D,D]]
[("main",1,[D]),("pow",2,[D,S]),("mult",2,[D,D]),("sum",2,[D,D])]
btaAbst> bta "ack" [D]

---- calculating BTA ----
generating ack.acy ...
... Computing Division

[[D],[S,S]]
[[D],[S,D]]
[("main",1,[D]),("ack",2,[S,D])]
btaAbst> :quit
[gustavo@cmm2 btamono]$ 

     Last update 03/20/2007  /  garroyo (at) dsic.upv.es