1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
// Ackermann Function
//
// fun ack(0,n) = n+1
// | ack(m,0) = ack(m-1,1)
// | ack(m,n) = ack(m-1,ack(m,n-1));
// The following rule is wrong because there is no gurantee that
// the 'cnt' is connected to an integer agent
// when ack(r)~(m-1,cnt) is evaluated.
//
// ack(r) >< (int m, int n)
// | m==0 => r~(n+1)
// | n==0 => ack(r) ~ (m-1,1)
// | _ => ack(cnt)~(m,n-1), ack(r)~(m-1,cnt);
//
// So, the `cnt' should be connected as an element of connections.
ack(ret, int m) >< (int n)
| m==0 => ret~(n+1)
| n==0 => ack(ret, m-1)~1
| _ => ack(cnt, m)~(n-1), ack(ret, m-1)~cnt;
ackMain(ret)><(int m, int n) => ack(ret,n)~m;
ackMain(ret)~(3,5);
ret;
free ret;
|