plunder.tech ( News | Git | Docs )

Docs/Plan

Here is the current version of the formal PLAN spec:
Every PLAN vaue is either a pin x:<i>, a law x:{n a b}, an app x:(f g),
a nat x:@, or a black hole x:<>.

(o <- x) mutates o in place, updating it's value to equal x.

Unmatched patterns diverge.

Run F[x] to normalize a value, to "evaluate".

F[o] =                                  | N[o] = E[o]; if o:@ then o else 0
    E[o]                                |
    when o:(f x)                        | C[z,p,n] = if n=0 then z else (p(n-1))
         F[f]; F[x]                     |
    o                                   | S[o:(f x y)]       = (S[(f x)] y)
                                        | S[o:(<{n a b}> y)] = o
                                        | S[o:(<@> y)]       = o
E[o] =                                  | S[o:(<f> x)]       = S[(f x)]
    when o:(f x)                        | S[o]               = o
        E[f]                            |
        when A[f]=1                     | I[f, (e x), 0] = x
            o <- S[o]                   | I[f, e,     0] = e
            o <- X[o,o]                 | I[f, (e x), n] = I[f, e, n-1]
            E[o]                        | I[f, e,     n] = f
    o                                   |
                                        | A[(f x)]     = A[f]-1
X[(f x), e]         = X[f,e]            | A[<n:@>]     = I[1, (5 3 1 3 1), n]
X[0, (_ x)]         = <F[x]>            | A[<p>]       = A[p]
X[1, (_ n a b)]     = W[N[n],N[a],F[b]] | A[{n a b}]   = a
X[2, (_ x)]         = N[x]+1            | A[n:@]       = 0
X[3, (_ z p x)]     = C[z,p,N[x]]       |
X[4, (_ p l a n x)] = P[p,l,a,n,E[x]]   | R[n,e,b:@] | b≤n = I[_,e,(n-b)]
X[{n a b}, e]       = B[a,a,e,b,b]      | R[n,e,(0 f x)]   = (R[n,e,f] R[n,e,x])
X[<p>, e]           = X[p,e]            | R[n,e,(2 x)]     = x
                                        | R[n,e,x]         = x
L[i,n,e,(1 v b)] = I[_,e,i] <- R[n,e,v] |
                   L[i+1,n,e,b]         | P[p,l,a,n,(f x)]   = (a f x)
L[_,n,e,x]       = R[n,e,x]             | P[p,l,a,n,<x>]     = (p x)
                                        | P[p,l,a,n,{n a b}] = (l n a b)
B[a,n,e,b,(1 _ k)] = B[a,n+1,(e <>),b,k]| P[p,l,a,n,x:@]     = (n x)
B[a,n,e,b,x]       = L[a,n,e,b]         |