-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weird behaviour with NonDet and Stays modality #47
Comments
I've explored a little and found that the "two separate actions" implementation also fails if I run it with spectacle/src/Language/Spectacle/Model.hs Line 228 in 76f9838
I think this might be excluding some traces where the same action is called twice in a row. It also interacts with the queuedActionsAt list in some way I can't really understand. I think it requires that the same state be achieved through several different paths.Apparently having more labeled actions make this less likely to happen, but it still happens when if the tree gets wide enough. |
Why do you expect them to be equivalent? When you split the actions into |
Hi, thanks for replying! See #47 (comment), I no longer think this is related to NonDet specifically. The two-action model fails when the number of steps is 6, with a similar behaviour in the trace (a branch just hangs where it seems like it should be able to make progress.) Below I discuss the NonDet thing anyway, more as a learning opportunity for myself 😅 I'm not super experienced in formal methods, my mental model might be mistaken here. I expect that the weak fair constraint would require the action to eventually be taken if it's available, and that the action is available as long as it has at least 1 possible result. So in the single-action case I'd expect that weak fairness would require us to eventually attempt I'm not sure if this means "one weak-fair action with two possible results" should always be equivalent to "two weak-fair actions", but in this case it seems to me that the two traces should be equivalent. Again, thanks for taking the time to respond! |
The weak fairness constraint specified on two distinct action formula should imply that both are interleaved fairly (so that one action or stutter-steps cannot be applied infinitely many times) the run here is stuttering infinitely, so we never get to satisfy that position reaches and stays as 0. This is also the case if we set the initial value of I really like this test though, so I've transcribed it in #48 modolo hspec. Thanks for taking the time to write it. I'll be sure to double check the specification later on today to make sure I agree with everything the model checker is asserting. |
Hm, right, but I think I don't understand why this happens here. If we have weak fair actions A and B, and we're in a series of states where B cannot run but A can, we should be able to take multiple A steps, right? I tried to reproduce the specs in TLA, see below. TLC seems to accept both models. Maybe there's some subtle distinction that I'm missing? ---------------------------- MODULE ConvergenceNonDetAction ----------------------------
EXTENDS TLC, Integers
abs(n) == IF n < 0 THEN -n ELSE n
VARIABLES position, stepsLeft
EventuallyAlwaysAtZero == <>[](position = 0 /\ stepsLeft \in {0,1})
vars == << position, stepsLeft >>
Init == (* Global variables *)
/\ position = 0
/\ stepsLeft \in 0..10
TakeStep == /\ stepsLeft > 0
/\ \E newPosition \in {position - 1, position + 1}:
/\ abs(newPosition) < stepsLeft
/\ position' = newPosition
/\ stepsLeft' = stepsLeft - 1
Next == TakeStep
Spec == /\ Init /\ [][Next]_vars
/\ WF_vars(TakeStep)
============================================================================= And here with two weak-fair actions: ---------------------------- MODULE ConvergenceTwoActions ----------------------------
EXTENDS TLC, Integers
abs(n) == IF n < 0 THEN -n ELSE n
VARIABLES position, stepsLeft
EventuallyAlwaysAtZero == <>[](position = 0 /\ stepsLeft \in {0,1})
vars == << position, stepsLeft >>
Init == (* Global variables *)
/\ position = 0
/\ stepsLeft \in 0..10
StepNegative == /\ stepsLeft > 0
/\ \E newPosition \in {position - 1}:
/\ abs(newPosition) < stepsLeft
/\ position' = newPosition
/\ stepsLeft' = stepsLeft - 1
StepPositive == /\ stepsLeft > 0
/\ \E newPosition \in {position + 1}:
/\ abs(newPosition) < stepsLeft
/\ position' = newPosition
/\ stepsLeft' = stepsLeft - 1
Next == StepNegative \/ StepPositive
Spec == /\ Init /\ [][Next]_vars
/\ WF_vars(StepNegative)
/\ WF_vars(StepPositive)
============================================================================= cfg file:
|
I believe it may just be that the implementation of If this were true then I believe something along the lines |
if |
@gusbicalho we've come back around to this issue. Thank you for creating it (and sorry for the almost one-year-long delay). @riz0id and I both agree there's a bug here, we think there might be two. @riz0id wrote a specification that more faithfully matches the TLA+ version you've given us (thanks for that example) and spectacle's I'm taking a stab at fixing it, then we will probably fix the Notably, we haven't written any specifications for Spectacle that exercised the |
Hi, glad to see that you're going back to work on spectacle! |
Smallest reproduction I could build:
The spec models a behaviour where we start at 0, there are a finite number of steps to be taken, and we never take a step away from 0 if it would take us to a distance that is too far to go back. We should be able to move around, but eventually, we should end up stuck at position == 0 (with either 1 or 0 steps left, depending on whether the initial number of steps is odd or even).
In the first test case, we have two possible actions:
stepNegative
tries to decrease the position, stepPositive tries to increase the position. In the second test case, we have a single actiontakeStep
that usesoneOf
to decide whether to decrease or increase the position.I would expect both cases to be equivalent,. However, the first test case passes, while the second fails.
For some reason, I'm only able to reproduce if
initialStepsLeft
is >= 4.The text was updated successfully, but these errors were encountered: