# Re: [tlaplus] How does this simple Max(set) implementation work?

• From: Hillel Wayne <hwayne@xxxxxxxxx>
• Date: Fri, 16 Apr 2021 14:10:54 -0500
• User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1

Hi Steve,

\A is "for all", so it will choose a value from S that is ≥ all values. If you use \E instead, then it will pick a value that is ≥ at least one value. Note that this includes the value itself, so \E y \in S: y <= x is trivially true for all values in the set.

H

On 4/16/2021 1:59 PM, Steve Ravet wrote:

I'm going through the examples at learntla.com and one asks to write an operator that finds the maximum value in a set. I did it using the SetReduce operator from somewhere else in the tutorial, but the given answer is simpler:

Max(S) == CHOOSE x \in S : \A y \in S : y <= x

I can't quite "read" this. Since CHOOSE picks any value from the set where the condition is true, it seems like this would return a value from S that is larger than at least one other value, not larger than all other values. What makes it keep going to find the largest value?
--
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.