tlaplus: Evaluate alias expression on pair of states s and t in error-trace and printed in place of s

TLC now allows the cfg file to contain the statement ALIAS R where R is the definition of a record in the spec or the model. R’s component expressions can be formed from constant-, state-, and action-level expressions. When printing an error-trace, TLC evaluates the record R on every step (pair or states s -> t) on the behavior that violated the property for every state of the error-trace. TLC prints the result r of the evaluation of R in place of s by formatting each component hi of r as a conjunct s.t. "hi" = r["hi"]. If the evaluation of R for a step fails, TLC falls back to printing s.

---- CONFIG Alias ----
SPECIFICATION FairSpec
INVARIANT Inv
PROPERTY Prop
ALIAS Alias
======================

---- MODULE Alias ----
EXTENDS Integers, TLC, Sequences

VARIABLES x, y
vars == <<x,y>>

Next == /\ y' = ~y
        /\ \/ /\ x < 4
              /\ x' = x + 1
           \/ /\ x = 4
              /\ x' = 1

Spec == x = 1 /\ y = FALSE /\ [][Next]_vars

FairSpec == Spec /\ WF_vars(Next)

Inv == x < 4

Prop == <>(x > 4)

Animation(e1,e2) == "e1: " \o ToString(e1) \o " e2: " \o ToString(e2)

\* An expression that is evaluated on the pair of states
\* s and t and printed in place of s in an error trace.
\* Useful to:
\* - filter out variables (not shown below)
\* - rename variables
\* - map variables (e.g. animation)
\* - additional trace expressions
\* TLC shows the original state if the evaluation of
\* Alias fails.
Alias == [y |-> y, \* x and y reordered.
          x |-> x, 
          a |-> x' - x, 
          b |-> x' = x,
          anim |-> Animation(x, y), \* Animation
          te |-> ENABLED Next]      \* Trace Expression

\* Syntactic variant for those that prefer this notation.
AliasEq ==
     "y" :> y @@
     "x" :> x @@
     "a" :> x' - x @@
     "b" :> (x' = x) @@
     "anim" :> Animation(x, y) @@
     "te" :> ENABLED Next
=======================
\* FairSpec => []Inv
Error: Invariant Inv is violated.
Error: The behavior up to this point is:
State 1: <Initial predicate>
/\ y = FALSE
/\ x = 1
/\ a = 1
/\ b = FALSE
/\ anim = "e1: 1 e2: FALSE"
/\ te = TRUE

State 2: <Next line 7, col 9 to line 11, col 23 of module Alias>
/\ y = TRUE
/\ x = 2
/\ a = 1
/\ b = FALSE
/\ anim = "e1: 2 e2: TRUE"
/\ te = TRUE

State 3: <Next line 7, col 9 to line 11, col 23 of module Alias>
/\ y = FALSE
/\ x = 3
/\ a = 1
/\ b = FALSE
/\ anim = "e1: 3 e2: FALSE"
/\ te = TRUE

State 4: <Next line 7, col 9 to line 11, col 23 of module Alias>
/\ y = TRUE
/\ x = 4
/\ a = 0         \* Stuttering
/\ b = TRUE \* Stuttering
/\ anim = "e1: 4 e2: TRUE"
/\ te = TRUE

-------------------------------
\* Spec => Prop
Error: Temporal properties were violated.
Error: The following behavior constitutes a counter-example:
State 1: <Initial predicate>
/\ y = FALSE
/\ x = 1
/\ a = 0         \* Stuttering
/\ b = TRUE \* Stuttering
/\ anim = "e1: 1 e2: FALSE"
/\ te = TRUE

State 2: Stuttering

-------------------------------
\* FairSpec => Prop
Error: Temporal properties were violated.
Error: The following behavior constitutes a counter-example:
State 1: <Initial predicate>
/\ y = FALSE
/\ x = 1
/\ a = 1
/\ b = FALSE
/\ anim = "e1: 1 e2: FALSE"
/\ te = TRUE

State 2: <Next line 7, col 9 to line 11, col 23 of module Alias>
/\ y = TRUE
/\ x = 2
/\ a = 1
/\ b = FALSE
/\ anim = "e1: 2 e2: TRUE"
/\ te = TRUE

State 3: <Next line 7, col 9 to line 11, col 23 of module Alias>
/\ y = FALSE
/\ x = 3
/\ a = 1
/\ b = FALSE
/\ anim = "e1: 3 e2: FALSE"
/\ te = TRUE

State 4: <Next line 7, col 9 to line 11, col 23 of module Alias>
/\ y = TRUE
/\ x = 4
/\ a = -3           \* State 1 is successor
/\ b = FALSE   \* State 1 is successor
/\ anim = "e1: 4 e2: TRUE"
/\ te = TRUE

Back to state 1: <Next line 7, col 9 to line 11, col 23 of module Alias>

-------------------------------

(The Alias feature would perhaps have helped with https://github.com/dgpv/bip32_template_parse_tplaplus_spec/issues/1)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 16 (14 by maintainers)

Commits related to this issue

Most upvoted comments

FYI this feature is wonderful for debugging refinement mappings.

Quickly generate animations:

java -cp /opt/toolbox/tla2tools.jar:CommunityModules.jar tlc2.TLC -simulate num=1 -depth 32001 -config AsyncGameOfLife.cfg AsyncGameOfLifeAnim.tla | grep anim | sed 's;anim = ;anim |-> ;g' | xclip

Peek 2020-07-09 17-55