Skip to content

Instantly share code, notes, and snippets.

@hwayne
Created March 11, 2017 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hwayne/25cbc07bab057087225d997ffaa3755d to your computer and use it in GitHub Desktop.
Save hwayne/25cbc07bab057087225d997ffaa3755d to your computer and use it in GitHub Desktop.
Formal Methods Example Spec
EXTENDS Integers, TLC, Sequences
CONSTANTS Devices
(* --algorithm BatchInstall
variables
AppScope \in [Devices -> {0, 1}];
Installs \in [Devices -> BOOLEAN];
batch_pool = {};
define
PoolNotEmpty == batch_pool # {}
end define;
procedure ChangeAppScope()
begin
Add:
AppScope := [d \in Devices |->
IF d \in batch_pool THEN AppScope[d] + 1
ELSE AppScope[d]
];
Clean:
batch_pool := {};
return;
end procedure;
fair process SyncDevice \in Devices
begin
Sync:
if Installs[self] then
batch_pool := batch_pool \union {self};
end if;
end process;
fair process TimeLoop = 0
begin
Start:
while TRUE do
await PoolNotEmpty;
call ChangeAppScope();
end while;
end process;
end algorithm; *)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment