Closed lemmy closed 3 years ago
Hi Markus!
Actually, I cannot parse the pasted file with SANY 1.7.0:
$ java -jar ~/.m2/repository/org/lamport/tla2tools/1.7.0-SNAPSHOT/tla2tools-1.7.0-SNAPSHOT.jar -config swim_stats.cfg swim_stats2.tla
TLC2 Version 2.15 of Day Month 20?? (rev: eb3ff99)
Running breadth-first search Model-Checking with fp 87 and seed 8212768720453189801 with 1 worker on 8 cores with 3641MB heap and 64MB offheap memory (Mac OS X 10.15.7 x86_64, Oracle Corporation 1.8.0_172 x86_64, MSBDiskFPSet, DiskStateQueue).
Parsing file /Users/igor/Downloads/swim_stats2.tla
Parsing file /private/var/folders/42/77j16l715bd5k68fffptzgvw0000gn/T/Naturals.tla
Parsing file /private/var/folders/42/77j16l715bd5k68fffptzgvw0000gn/T/FiniteSets.tla
Parsing file /Users/igor/Downloads/FiniteSetsExt.tla
Fatal errors while parsing TLA+ spec in file swim_stats2
java.lang.NullPointerException
Starting... (2020-10-16 08:58:19)
Error: Parsing or semantic analysis failed. Module-Table lookup failure for module name swim_stats2 derived from swim_stats2 file name.
Finished in 00s at (2020-10-16 08:58:19)
We just recently switched to 1.7.0, so you most likely used apalache with tla2tools 1.6.0. I suspect that the problems that we encounter both in Apalache and 1.7.0 are of similar nature.
Hi Igor,
can you pull FiniteSetsExt
and the other modules in the EXTENDS
from the CommunityModules?
Now I have the reported behavior. Thanks!
Our importer fails at the following expression (line 575):
peer_states' = [peer_states EXCEPT ![member][peer] =
[@ EXCEPT !.state = new_state,
!.disseminations = 0,
!.round = round[member]]]
It looks like the problem is in using @
inside the nested EXCEPT
expression. The notation @
works on simple expressions. I will have another look later.
I am staring at a MWE for this bug:
---- MODULE Updates ----
VARIABLE f
E4 == [ f EXCEPT ![0] = [@ EXCEPT !.state = 4] ]
================================
@lemmy, the node explorer is showing me quite a strange structure (see Updates.pdf). Could you clarify how to interpret that structure at the level of SemanticNode
?
Do line numbers (-Dtla2sany.explorer.DotExplorerVisitor.includeLineNumbers=true
) and each node's type help to answer your questions?
strict digraph DiskGraph {
1146 [label="Updates",style = filled];
1209 [shape=square,color="yellow",label="f
line 2, col 10 to line 2, col 10
Updates
OpDeclNode"];
1146 -> 1209
1283 [style=filled,shape=diamond,fillcolor="red",label="E4
line 3, col 1 to line 3, col 48
Updates
OpDefNode"];
1146 -> 1283
1397 [color="green",label="[fEXCEPT![0]=[@EXCEPT!.state=4]]
line 3, col 7 to line 3, col 48
Updates
OpApplNode"];
1283 -> 1397
1396 [color="green",label="f
line 3, col 9 to line 3, col 9
Updates
OpApplNode"];
1397 -> 1396
1209 [shape=square,color="yellow",label="f
line 2, col 10 to line 2, col 10
Updates
OpDeclNode"];
1396 -> 1209
1400 [color="green",label="![0]=[@EXCEPT!.state=4]
line 3, col 18 to line 3, col 46
Updates
OpApplNode"];
1397 -> 1400
1399 [color="green",label="![0]=[@EXCEPT!.state=4]
line 3, col 18 to line 3, col 46
Updates
OpApplNode"];
1400 -> 1399
1615 [label="0
line 3, col 20 to line 3, col 20
Updates
NumeralNode"];
1399 -> 1615
1402 [color="green",label="[@EXCEPT!.state=4]
line 3, col 25 to line 3, col 46
Updates
OpApplNode"];
1400 -> 1402
1405 [color="green",label="!.state=4
line 3, col 35 to line 3, col 45
Updates
OpApplNode"];
1402 -> 1405
1404 [color="green",label="!.state=4
line 3, col 35 to line 3, col 45
Updates
OpApplNode"];
1405 -> 1404
1682 [label="state
line 3, col 37 to line 3, col 41
Updates
StringNode"];
1404 -> 1682
1623 [label="4
line 3, col 45 to line 3, col 45
Updates
NumeralNode"];
1405 -> 1623
}
That makes sense. Thanks!
What is strange here. The debugger shows AtNode
as the first argument to the $Except
node (when using OpApplNode.getArgs
). But it is not shown in the graph. I am trying to figure out exactly how the expression [@ EXCEPT !.state = 4]
is translated.
This is an issue of DotExplorerVisitor
. AtNode
doesn't show up because AtNode#walkGraph
is a no-op.
You can use the interactive Explorer java -cp tla2tools.jar tla2sany.SANY -d Updates.tla
:
****** SANY2 Version 2.2 created 08 July 2020
Parsing file /tmp/Updates.tla
Semantic processing of module Updates
*** TLA+ semantic graph exploration tool v 1.0 (DRJ)
>>mt
External Module Table:
| Module: *ModuleNode: Updates uid: 154 kind: ModuleKind errors: none
| | Context Entry: f 155
| | Context Entry: E4 167
>>167
*OpDefNode: E4
uid: 167 kind: UserDefinedOpKind arity: 0 orgDefInModule: Updates
local: false
letInLevel: 0
inRecursive: false
inRecursiveSection: false
recursiveSection: -1
local: false
source: this
originallyDefinedInModule: Updates (uid: 154)
Formal params: 0
SymbolTable: non-null
| Body:
| | *OpApplNode: $Except uid: 157 kind: OpApplKind errors: non-null
| | | Operator: $Except 85
| | | Operands: 2
| | | | *OpApplNode: f uid: 156 kind: OpApplKind errors: non-null
| | | | | Operator: f 155
| | | | *OpApplNode: $Pair uid: 160 kind: OpApplKind errors: non-null
| | | | | Operator: $Pair 96
| | | | | Operands: 2
| | | | | | *OpApplNode: $Seq uid: 159 kind: OpApplKind errors: non-null
| | | | | | *OpApplNode: $Except uid: 162 kind: OpApplKind errors: non-null
Labels: null
Arity: 0
Level: 1
LevelParams: [line 2, col 10 to line 2, col 10 of module Updates]
LevelConstraints: { f -> 2}
ArgLevelConstraints: { }
ArgLevelParams: {}
MaxLevel:
opLevelCond: []
AllParams: {f}
NonLeibnizParams: {}
IsLeibniz: true
isLeibnizArg:
>>157
*OpApplNode: $Except uid: 157 kind: OpApplKind errors: non-null
| Operator: $Except 85
| Operands: 2
| | *OpApplNode: f uid: 156 kind: OpApplKind errors: non-null
| | | Operator: f 155
| | *OpApplNode: $Pair uid: 160 kind: OpApplKind errors: non-null
| | | Operator: $Pair 96
| | | Operands: 2
| | | | *OpApplNode: $Seq uid: 159 kind: OpApplKind errors: non-null
| | | | | Operator: $Seq 105
| | | | | Operands: 1
| | | | | | *NumeralNode: uid: 158 kind: NumeralKind Value: 0; image: 0
| | | | *OpApplNode: $Except uid: 162 kind: OpApplKind errors: non-null
| | | | | Operator: $Except 85
| | | | | Operands: 2
| | | | | | *AtNode: uid: 161 kind: AtNodeKind
| | | | | | | ExceptRef: 157
| | | | | | | ExceptComponent: 160
| | | | | | *OpApplNode: $Pair uid: 165 kind: OpApplKind errors: non-null
Level:1
LevelParams: [line 2, col 10 to line 2, col 10 of module Updates]
LevelConstraints: { f -> 2}
ArgLevelConstraints: { }
ArgLevelParams: {}
AllParams: {f}
NonLeibnizParams: {}
>>
Wow. Those is the details I always wanted to see! Thanks!
IMO the dot graph is better to understand the hierarchy. What parts of the textual explorer would you want to see in the graph?
I expected to see the whole syntax tree, but the printer happens to be selective about what it shows.
In the end, it is a one-line fix, see #302. Though it took me several hours to understand the problem :)
As always with such bugs, another unexpected behavior popped up
PR #305 implements better error reporting for the language predicates. Now apalache complains about TLCSet
:
swim_stats.tla:296:12-296:39: unexpected expression: TLC!TLCSet(r$1 * 100, 0) E@12:11:50.192
swim_stats.tla:297:12-297:43: unexpected expression: TLC!TLCSet((r$1 * 100) + 1, 0) E@12:11:50.214
swim_stats.tla:299:20-299:74: unexpected expression: TLC!TLCSet((r$1 * 100) + 6, initial_state_stats'["alive_members"]) E@12:11:50.236
swim_stats.tla:300:20-300:80: unexpected expression: TLC!TLCSet((r$1 * 100) + 7, initial_state_stats'["alive_states"]) E@12:11:50.257
swim_stats.tla:301:20-301:42: unexpected expression: TLC!TLCSet((r$1 * 100) + 6, 0) E@12:11:50.279
swim_stats.tla:302:20-302:49: unexpected expression: TLC!TLCSet((r$1 * 100) + 7, 0) E@12:11:50.301
swim_stats.tla:303:12-303:36: unexpected expression: TLC!TLCSet((r$1 * 100) + 2, 0) E@12:11:50.323
swim_stats.tla:304:12-304:43: unexpected expression: TLC!TLCSet((r$1 * 100) + 3, 0) E@12:11:50.344
swim_stats.tla:305:12-305:33: unexpected expression: TLC!TLCSet((r$1 * 100) + 4, 0) E@12:11:50.365
swim_stats.tla:306:12-306:40: unexpected expression: TLC!TLCSet((r$1 * 100) + 5, 0) E@12:11:50.386
I think we should stop here. The parser goes through. Now the model checker complains about unsupported operators, which we don't know how to support. If you like to make further progress on this spec, let's open another issue. But I would wait till the new type checker is integrated.
Also see https://github.com/Vanlightly/formal-methods-playground/tree/master/tla/swim