Skip to content

Commit b6be971

Browse files
committed
Add Apalache wrapper for DieHardest
Add APADieHardest.tla, an Apalache-compatible configuration that checks DieHardest's interleaved composition (Section 4) with --cinit for constant initialization and [s \in S |-> ...] in place of :> and @@. Note the Apalache incompatibility of NextParallelGlobalFreeze in DieHardest.tla (TLCGet takes both Str and Int arguments). Signed-off-by: Markus Alexander Kuppe <github.com@lemmster.de>
1 parent 93dc4c8 commit b6be971

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
Apalache configuration for DieHardest (Section 4, interleaved composition).
2+
3+
$ apalache-mc check \
4+
--cinit=ConstInit --next=NextInterleaved \
5+
--inv=NotSolved --length=13 \
6+
APADieHardest.tla
7+
8+
Apalache finds the expected 12-state counterexample in about four hours
9+
on a 2021 MacBook Pro (Apalache 0.52.2).
10+
11+
----------------------------- MODULE APADieHardest ------------------------------
12+
(***************************************************************************)
13+
(* Apalache-compatible model-checking wrapper for DieHardest. *)
14+
(* *)
15+
(* DieHardest's Sections 1-3 use TLC-specific operators (TLCGet, TLCSet) *)
16+
(* that Apalache does not support. This module checks only Section 4 *)
17+
(* (interleaved composition) by selecting NextInterleaved via --next. *)
18+
(* *)
19+
(* Adaptations for Apalache: *)
20+
(* - Constants are initialized via ConstInit (--cinit) rather than a *)
21+
(* TLC .cfg file. *)
22+
(* - Capacity functions use [s \in S |-> ...] instead of the TLC-module *)
23+
(* operators :> and @@. *)
24+
(***************************************************************************)
25+
26+
CONSTANT
27+
\* @type: Seq(Str -> Int);
28+
Capacities,
29+
\* @type: Int;
30+
Goal
31+
32+
VARIABLE
33+
\* @type: Str -> Int;
34+
c1,
35+
\* @type: Str -> Int;
36+
c2,
37+
\* @type: Int;
38+
s1,
39+
\* @type: Int;
40+
s2
41+
42+
INSTANCE DieHardest
43+
44+
MCGoal == 4
45+
46+
MCCapacity1 ==
47+
[ s \in {"j1", "j2"} |-> IF s = "j1" THEN 5 ELSE 3 ]
48+
49+
MCCapacity2 ==
50+
[ s \in {"j1", "j2", "j3"} |-> IF s = "j1" THEN 5 ELSE 3 ]
51+
52+
ConstInit ==
53+
/\ Capacities = <<MCCapacity1, MCCapacity2>>
54+
/\ Goal = MCGoal
55+
56+
=============================================================================

specifications/DieHard/DieHardest.tla

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ NextParallelFreeze ==
160160
ASSUME TLCSet(2, 999) /\ TLCSet(3, 999)
161161

162162
NextParallelGlobalFreeze ==
163+
\* TLCGet is called with both Str and Int arguments (TLCGet("level")
164+
\* vs. TLCGet(2)), so Apalache's type checker cannot assign a single
165+
\* type to its parameter. This operator is therefore incompatible
166+
\* with Apalache. See APADieHardest.tla, which checks Section 4 only.
163167
/\ IF TLCGet("level") >= TLCGet(2) THEN UNCHANGED c1 ELSE D1!Next
164168
/\ IF TLCGet("level") >= TLCGet(3) THEN UNCHANGED c2 ELSE D2!Next
165169
/\ Goal \in Range(c1') /\ TLCGet(2) = 999 => TLCSet(2, TLCGet("level") + 1)

0 commit comments

Comments
 (0)