Generating records like functions

26 views
Skip to first unread message

jwnhy

unread,
Jan 3, 2022, 6:30:04 PM1/3/22
to tlaplus
Hello, I'm new to TLA+ and trying to learn it.

I know that I can generate a set of all possible functions by writing

[{"A", "B"} -> {0, 1}] \* all functions from {"A", "B"} to {0, 1}

I'm wondering if there is a similar way for records?

For example, if I have a record that most of its fields is BOOLEAN, I'm wondering if I can write something like

mstatus \in [{SD, TSR, TW, TVM}: BOOLEAN] \* THIS DOES NOT WORK

Or is there a way to specify a function with different range for different domain?

e.g: f["x"] \in {0,1} f["y"] \in {4, 5}

Thanks,
jwnhy.

Jeremy Wright

unread,
Jan 3, 2022, 6:40:52 PM1/3/22
to tla...@googlegroups.com
Hello jwnhy,

Do you mean something like this?

``tlaplus

f == [x |-> {0, 1}, y |-> {4,5}]

``


image.png


--
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+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tlaplus/9aaa082e-b2ae-4503-a6d8-76ccfe962702n%40googlegroups.com.

Stephan Merz

unread,
Jan 4, 2022, 2:34:21 AM1/4/22
to tla...@googlegroups.com
Sets of records are written like

[foo : BOOLEAN, bar : Nat]

A particular record is constructed as

[foo |-> FALSE, bar |-> 0]

See also section 16.1.8 of Specifying Systems.

Regards,
Stephan

Reply all
Reply to author
Forward
0 new messages