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

Re: [tlaplus] Understanding CHOOSE



Hi Alex,

Thank you for your message.

1 - Is  CHOOSE sub \in ClaimsData : TRUE   the correct way to say that I want TLA+ to pick a value from ClaimsData and label it sub ? How would you have expressed it ?

2 - In my module, I'm trying to represent the bahviour of an external API (which may respond with a 200 HTTP status or a 4XX or 5XX HTTP status : 2 states => Success OR Failure). Briefly put, how would you describe an external API that your system consumes and needs to react predictably according to the API's response (success or failure) ? (the "randomness" part is how often do you get a Successful/Failed response. The difficulty is how do I describe this beahviour ?

Thank you!

On Wednesday, January 20, 2021 at 2:47:51 PM UTC+1 alex.we...@xxxxxxx wrote:
CHOOSE is definitely a confusing operator, many people have problems with it including myself. The idea is that CHOOSE always picks the same value, it does not represent arbitrary values.

If you're trying to say "sub can be any element of ClaimsData", then the "there exists" operator (existential quantification) is what you're looking for, i.e.

\E sub \in ClaimsData: SomePredicate(sub)

or something thereabout. If we are thinking in terms of predicates on the state space, this returns true for _every_ next state where sub is an element of ClaimsData and SomePredicate(sub) is true. Which path the algorithm takes during a single algorithm execution is the "random" part, but the specification should describe all possible paths with no randomness. 



On Wed, Jan 20, 2021 at 4:38 AM Park Lay <younesagma@xxxxxxxxx> wrote:
Hello,

I am new to TLA+ and I'm trying to understand the how does the keyword CHOOSE work in TLA+. I have already read the available documentation but I don't think I fully grasp how it works.

I have this in my module :

CHOOSE sub \in ClaimsData : TRUE such that ClaimsData <- {0..10}

Can you please help me understand what really is happening here ? What I'm trying to achieve is to pick a "random" value... but I know that this is not non-deterministic.. I'm really confused..

Thank you!

--
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@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tlaplus/efa2ccc2-0fe0-49ad-b893-d7fd286193f0n%40googlegroups.com.


--
- Alex Weisberger, Senior Software Engineer: House Manage

--
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/8fdf54e6-a773-44e1-8035-5b19fb66f29dn%40googlegroups.com.