Padlock
Padlock is a thematic, Turing-complete process calculus based on the mathematical model of Ο-calculus, by User:RocketRace.
Syntax
Padlock programs consist of processes (denoted here with P
or Q
) and names (denoted here with x
or y
). Padlock programs are made up of six different characters based on Unicode emoji for locks, using a lisp-style prefix syntax. Alternate ASCII symbols may be used instead, for some text encodings.
Symbol | Alternate Symbol | Usage within programs | Effect |
---|---|---|---|
π |
N |
π |
Nil process. Takes no arguments. |
π |
S |
πPQ |
"Split" instruction. Executes processes P and Q in parallel. |
π |
E |
πxπyπP |
"Send" instruction. Encrypts the name x and sends the encrypted name along channel y, then executes process P. |
π |
R |
πxπyπP |
"Receive" instruction. Receives a name on channel y and binds that name to x, then executes process P. |
π |
K |
πxπyπP |
"Decrypt" instruction. Takes name x, decrypts it once, binds the result to y, then executes process P in parallel with the whole instruction.
That is, |
π |
P |
πxπP |
"Name" instruction. Binds a name x, then executes process P. |
The set of free names in a process P
is defined inductively by the table below. The free names of a process P
are names that are not bound in the process.
Process | Free names |
---|---|
π |
None |
πPQ |
All free names of P and Q
|
πxπyπP |
x ; y ; all free names of P
|
πxπyπP |
x ; all free names of P , except for y
|
πxπyπP |
x ; y ; all free names of P
|
πxπP |
All free names of P , except for x
|
Communication
All communication instructions, that is, π
and π
, will only execute the next process in their chain once they successfully send or receive a name on some channel. This means that any attempt to send to / receive from the channel will pause the process until both a sender and a recipient are on the same channel simultaneously.
Encryption
Encryption and decryption are ideal and reversible. That is, only x_0
can be encrypted into x_1
, and only x_1
can be decrypted into x_0
. If names x
and y
are each encrypted or decrypted, never will x_n
be equal to y_m
, for some integers n
and m
representing the amount of times x
and y
have been encrypted / decrypted. Additionally, a name may be encrypted or decrypted an arbitrary amount of times. An unencrypted name x_0
may also be "decrypted" into x_-1
.
Undefined behavior
Padlock contains necessarily undefined behavior, enumerated below.
- When more than one process attempts to send a name to a channel, only one process will be successful, but the choice of process is undefined.
- When more than one process attempts to receive a name from a channel, only one process will be successful, but the choice of process is undefined.
Computational class
Ο-calculus is capable of universal computation, being able to evaluate lambda calculus. Ο-calculus can be embedded in Padlock, from which follows that Padlock too is Turing-complete. The following table describes the substitutions necessary for this embedding. Here, the naming convention for processes and names presented above is used for both process calculi.
Ο-calculus syntax | Substitution in Padlock |
---|---|
0 |
π
|
P|Q |
πPQ
|
(vx).P |
πxπP
|
x_{y}.P |
πyπxπP
|
x(y).P |
πaπxππbπππbπbπππaπyππbπaπP *
|
!P |
πaππaπaπP **
|
* Here, names a
and b
are disposed, that is, they are bound and cannot be accessed afterwards. This does not impact the result of the program, since the amount of possible names within a program is not finite, and a
and b
can simply be avoided afterwards.
** Here, name a
, as well as every possible decrypted version of name a
, is disposed. Similarly to above, this does not impact the ability to embed Ο-calculus within Padlock.
These substitutions are non-trivial, because unlike in Ο-calculus, sending a name in Padlock sends an encrypted name instead, which can only be decrypted using π
, which in turn replicates the process indefinitely. This replication is avoided by abusing the synchronicity of communication in Padlock; πxπyπP
will only execute P
once it receives a name on channel x
, and thus will hang indefinitely if nothing is ever sent through the channel. Similarly, as π
both decrypts and replicates, if only the replication is needed (like it is for !P
), a disposable name may be provided to the instruction to be "decrypted" indefinitely.