-
Notifications
You must be signed in to change notification settings - Fork 218
Expand file tree
/
Copy pathAPChameneos.tla
More file actions
37 lines (31 loc) · 1.22 KB
/
APChameneos.tla
File metadata and controls
37 lines (31 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
----------------------------- MODULE APChameneos -----------------------------
(* Apalache type annotations for Chameneos.tla, applied via INSTANCE so the
original spec remains free of tool-specific idiosyncrasies. *)
EXTENDS Integers
CONSTANT
\* @type: Int;
N,
\* @type: Int;
M
VARIABLE
\* @type: Int -> <<Str, Int>>;
chameneoses,
\* @type: Int;
meetingPlace,
\* @type: Int;
numMeetings
\* `Sum` is redefined here solely to attach a type annotation that constrains
\* the operator to `Int`. In TLA+ the original definition works for any value
\* whose `+` is defined (e.g. reals, sequences via concatenation in analogous
\* folds), but Apalache requires a concrete, monomorphic type.
\*
\* Brittle: this trick relies on SANY tolerating a duplicate definition only
\* when the body is identical to the one in `Chameneos`. Any change to the
\* body below turns the warning into a hard "Multiple declarations" error.
RECURSIVE Sum(_, _)
\* @type: (Int -> Int, Set(Int)) => Int;
Sum(f, S) == IF S = {} THEN 0
ELSE LET x == CHOOSE x \in S : TRUE
IN f[x] + Sum(f, S \ {x})
INSTANCE Chameneos
==============================================================================