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

# Re: [tlaplus] State sequences

 You cannot nest primes in TLA+ formulas, for good reasons related to stuttering invariance. You want to specify a state machine that monitors the progress of unlocking. Perhaps something along the following lines:Digit == 0 .. 9CONSTANT Code  \* can be instantiated to <<3,2,1>>, for exampleASSUME Code \in Seq(Digit)VARIABLES   locked,   \* status of the lock  idx       \* monitor progression in input of the codeInit ==  /\ locked = TRUE  /\ idx = 1Input(x) ==  \/ \* user input correct digit     /\ idx <= Len(Code) /\ x = Code[idx]     /\ idx' = idx+1     /\ locked' = (idx < Len(Code))  \* unlock when last digit has been input  \/ \* user input incorrect digit     /\ idx <= Len(Code) /\ x # Code[idx]     /\ idx' = Len(Code)+1  \* make further inputs useless     /\ locked' = locked  \/ \* ignore input when beyond the length of the code     /\ idx > Len(Code)     /\ UNCHANGED <>Spec == Init /\ [][\E x \in Digit : Input(x)]_<>The last disjunct of the Input action is in fact useless here, since stuttering is always allowed, but it may be useful when interaction with the user is modeled through an explicit interface. Also, you may choose to have a different strategy of handling input errors such as tolerating a certain number of wrong inputs before blocking.StephanOn 16 Nov 2019, at 03:29, ns wrote:hello, I was wondering if there was a convenient way to specify a required sequence of states in TLA+. As an example, suppose the code 3 2 1 unlocks something, we would like to say Next ==       ...\/    num = 3 /\ num'=2 /\ num''=1 /\ unlock'''      ...and the usual [] [Next]_{vars}. I would like for this to mean  [] (Next \/ (num'=num /\ unlock'=unlock) \/ (num''=num' /\ unlock''=unlock') \/ (num'''=num'' /\ unlock'''=unlock'') but I don't know if there's a way to write this easily in TLA"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/c9a1dbdf-33f5-4b1e-a3cf-4c42202ce33d%40googlegroups.com. -- 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/CD13E81E-F1E1-46EF-AFE2-07D7452CB8A9%40gmail.com.