learning_tla/lamport_video/docs/lecture07.md
2025-02-12 18:19:37 +01:00

873 B

7. Paxos

CHOOSE

CHOOSE x \in S: P selects one particular value in S such that P holds.

Example: how to write a maximum function:

Maximum(S) == 
    IF S = {} 
    THEN -1
    ELSE CHOOSE n \in S: \A m \in S: n >= m

maximum.png

Elements of a SYMMETRY set can not appear in a CHOOSE expression.

Set constructors

  • { v \in S: P } the set of all v in S for which P holds
  • {e: v \in S} the set of e for all v in S
    • Example: { n^2: n \in Nat }: the set of squares of all natural numbers

EXCEPT drilling

[aState EXCEPT ![m.ins][acc].mbal = m.bal]
\* means
[aState EXCEPT ![m.ins] =
    [aState[m.int] EXCEPT ![acc] =
        [aState[m.ins][acc] EXCEPT !.mbal = m.bal]
    ]
]
\* just like this programming statement:
\* aState[m.ins][acc].mbal = mbal