-
-
Save JoshOrndorff/f251e75e44232326052c75fa41deca70 to your computer and use it in GitHub Desktop.
My work-in-progress pi-calculus in k framework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PI-SYNTAX | |
imports DOMAINS | |
// Processes | |
syntax Proc ::= Norm // Normal processes are still processes | |
| Proc "|" Proc // Parallel | |
| "!" Proc // Replication | |
| "(" "v" Id ")" Proc // New name | |
| "(" Proc ")" // Allow parens for grouping | |
// Normal Processes | |
syntax Norm ::= Pi "." Proc // Prefixing | |
| "@" // Trivial Process. Looks kinda like empty set. | |
| Norm "+" Norm // Summation | |
// | Pi // Could allow Milner shorthand for Pi.0 | |
// Atomic Actions | |
syntax Pi ::= Id "(" Id ")" // Receive | |
| Id "~" Id // Send. Looks kinda like overbar | |
endmodule | |
module PI | |
imports PI-SYNTAX | |
endmodule | |
// Questions: | |
// Why can I just refer to a name like "x"? Is that what DOMAINS gets me? (reference below) | |
// Since the shorthand is commented, x~y shouldn't be a thing. How do I tell kompile that the top level entity should be a Proc? | |
// How do we teach kframework the actual reduction rules? Maybe involves importing SUBSTITUTION ? | |
// Helpful references: | |
// Our zoom sesssion: https://youtu.be/iX5L8lGynNo?t=32m23s | |
// Official lambda example: https://github.com/kframework/k5/blob/master/k-distribution/tutorial/1_k/1_lambda/lesson_1/lambda.k | |
// DOMAINS package: https://github.com/kframework/k5/blob/master/k-distribution/include/builtin/domains.k |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
joshy@MicrosoftSurface:~/ProgrammingProjects/k-framework/piCalc.k$ cat test1 | |
(@) | |
joshy@MicrosoftSurface:~/ProgrammingProjects/k-framework/piCalc.k$ krun test1 | |
<k> | |
( @ ) | |
</k> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
joshy@MicrosoftSurface:~/ProgrammingProjects/k-framework/piCalc.k$ cat test2 | |
x~y | |
joshy@MicrosoftSurface:~/ProgrammingProjects/k-framework/piCalc.k$ krun test2 | |
<k> | |
x ~ y | |
</k> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This example taken from Milner tutorial. Be careful not to use v as a name. v mean nu! | |
joshy@MicrosoftSurface:~/ProgrammingProjects/k-framework/piCalc.k$ cat test3 | |
(v x)(x~y.@ | x(u).u~w.@) | x~z.@ | |
joshy@MicrosoftSurface:~/ProgrammingProjects/k-framework/piCalc.k$ krun test3 | |
<k> | |
( ( v x ) ( x ~ y . ( @ | x ( u ) . u ~ w . @ ) ) ) | x ~ z . @ | |
</k> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This example taken from Milner tutorial. Be careful not to use v as a name. v mean nu! | |
joshy@MicrosoftSurface:~/ProgrammingProjects/k-framework/piCalc.k$ cat test4 | |
x~y.@ | !x(u).u~w.@ | x~z.@ | |
joshy@MicrosoftSurface:~/ProgrammingProjects/k-framework/piCalc.k$ krun test4 | |
<k> | |
( x ~ y . @ ) | ( ( ! x ( u ) . u ~ w . @ ) | x ~ z . @ ) | |
</k> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yup, more specifically the
ID
module withindomains.k
, which you can import instead ofDOMAINS
(since you aren't using Int or anything else in that package for now) withimports ID
. See the regex that your "x" matches to become anId
hereGreat question! Check out the
kast --sort
option. We will also find a fun way to define the default top level entity when we get into defining configurations.That would be a start. The full answer is I'm not totally sure yet. If you want to cheat and look ahead, I know that there is an implementation of the semantics for pi in this paper and in the rchain repo.
Other hints for improvement: there are still ambiguities in your grammar. To see the ambiguities in say, test3, run
kast -w all test3.pi
(and you might want to add a-s
option to that command as well...). To resolve these ambiguities, you will need to figure out how to define rule precedence and associativity (hint, hint, hint)