[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlaplus] Re: TLC error about a variable that was changed while it is specified as UNCHANGED



Let me just clarify my question a bit: I understand that its possible that ButtonInterface can change r even as e_r goes to FALSE. I think what I was (perhaps sloppily) hoping for was that TLC would somehow interpret my spec as requiring that ButtonInterface must stutter in order that r and g can remain unchanged

On Tuesday, November 26, 2019 at 4:53:36 PM UTC-8, ns wrote:
Hello, could someone let me know what I'm doing wrong here
I have a button interface that is responsible for 

-------------------------- MODULE ButtonInterface --------------------------
VARIABLES r,g
TypeInv == r \in BOOLEAN /\ g \in BOOLEAN

ButtonInit == r=TRUE /\ g=FALSE
Idle == r=FALSE /\ g=FALSE

ButtonNext == 
        (Idle /\ ((r'=TRUE /\ g'=FALSE) \/ (g'=TRUE /\ r'=FALSE)))
    \/  (r=TRUE /\ r'=FALSE /\ UNCHANGED g)
    \/  (g=TRUE /\ g'=FALSE /\ UNCHANGED r)
    \/  UNCHANGED <<r,g>>

=============================================================================

Then an event generator that relies on signals r and g from the button interface:

------------------------------ MODULE Problem1 ------------------------------
VARIABLES r, g, e_r, e_g, e_clr

TypeInv == r \in BOOLEAN /\ g \in BOOLEAN /\ e_r \in BOOLEAN /\ e_g \in BOOLEAN /\ e_clr \in BOOLEAN

BI == INSTANCE ButtonInterface \* my g and r are substituting for ButtonIfce's g and r

\* can't just write r /\ ~g /\ etc
M_Init == e_r=FALSE /\ e_g=FALSE  /\ e_clr=FALSE /\ TypeInv

all_vars == <<r,g, e_r, e_g, e_clr>>
M_Next ==   (r /\ ~g     /\ e_r'=TRUE /\ UNCHANGED <<e_g, e_clr>>)
         \/ (g /\ ~r     /\ e_g'=TRUE /\ UNCHANGED <<e_r, e_clr>>)
         \/ (e_r         /\ e_r'=FALSE /\ UNCHANGED <<r, g, e_g, e_clr>>)
         \/ (e_g         /\ ~e_g'=TRUE /\ UNCHANGED <<r, g, e_r, e_clr>>)

CombinedInit == BI!ButtonInit /\ M_Init
CombinedNext == BI!ButtonNext /\ M_Next
Spec ==  CombinedInit /\ [][CombinedNext]_all_vars
=============================================================================

Now when I run this in TLC I get the error message 

The variable r was changed while it is specified as UNCHANGED at line 16, col 55 to line 16, col 55 of module Problem1
The variable g was changed while it is specified as UNCHANGED at line 16, col 57 to line 16, col 57 of module Problem1
Deadlock reached.

I've allowed ButtonInterface to stutter, so what's the problem?

Also, somewhat tangential, if I replace the _expression_ (r'=TRUE /\ g'=FALSE) with Only_r' where I define
_Only_r_ == r=TRUE /\ g=FALSE
I get an unexpected exception, I was under the impression that if e was an _expression_, e' was the same _expression_ with all variables replaced by their primed forms?

thanks


--
You received this message because you are subscribed to the Google Groups "tlaplus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tlaplus+unsubscribe@xxxxxxxxxxxxxxxx.
To view this discussion on the web visit https://groups.google.com/d/msgid/tlaplus/9756a9c7-2f10-48cc-b6b6-be6ac548ea56%40googlegroups.com.