mirror of
https://github.com/achlipala/frap.git
synced 2024-11-10 00:07:51 +00:00
MessagesAndRefinement: base syntax and semantics
This commit is contained in:
parent
1cb930d8d1
commit
c3935ce842
1 changed files with 41 additions and 0 deletions
41
MessagesAndRefinement.v
Normal file
41
MessagesAndRefinement.v
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
(** Formal Reasoning About Programs <http://adam.chlipala.net/frap/>
|
||||||
|
* Chapter 15: Pi-Calculus and Behavioral Refinement
|
||||||
|
* Author: Adam Chlipala
|
||||||
|
* License: https://creativecommons.org/licenses/by-nc-nd/4.0/ *)
|
||||||
|
|
||||||
|
Require Import Frap.
|
||||||
|
|
||||||
|
Set Implicit Arguments.
|
||||||
|
Set Asymmetric Patterns.
|
||||||
|
|
||||||
|
|
||||||
|
Notation channel := nat.
|
||||||
|
|
||||||
|
Inductive proc :=
|
||||||
|
| NewChannel (k : channel -> proc)
|
||||||
|
| Send (ch : channel) {A : Set} (v : A) (k : proc)
|
||||||
|
| Recv (ch : channel) {A : Set} (k : A -> proc)
|
||||||
|
| Par (pr1 pr2 : proc)
|
||||||
|
| Dup (pr : proc).
|
||||||
|
|
||||||
|
Notation pid := nat.
|
||||||
|
Notation procs := (fmap pid proc).
|
||||||
|
Notation channels := (set channel).
|
||||||
|
|
||||||
|
Inductive step : channels * procs -> channels * procs -> Prop :=
|
||||||
|
| StepNew : forall chs ps i k ch,
|
||||||
|
ps $? i = Some (NewChannel k)
|
||||||
|
-> ~ch \in chs
|
||||||
|
-> step (chs, ps) (chs \cup {ch}, ps $+ (i, k ch))
|
||||||
|
| StepSendRecv : forall chs ps i ch {A : Set} (v : A) k1 j k2,
|
||||||
|
ps $? i = Some (Send ch v k1)
|
||||||
|
-> ps $? j = Some (Recv ch k2)
|
||||||
|
-> step (chs, ps) (chs, ps $+ (i, k1) $+ (j, k2 v))
|
||||||
|
| StepPar : forall chs ps i pr1 pr2 j,
|
||||||
|
ps $? i = Some (Par pr1 pr2)
|
||||||
|
-> ps $? j = None
|
||||||
|
-> step (chs, ps) (chs, ps $+ (i, pr1) $+ (j, pr2))
|
||||||
|
| StepDup : forall chs ps i pr j,
|
||||||
|
ps $? i = Some (Dup pr)
|
||||||
|
-> ps $? j = None
|
||||||
|
-> step (chs, ps) (chs, ps $+ (i, Dup pr) $+ (j, pr)).
|
Loading…
Reference in a new issue