> On 12 Nov 2015, at 10:00, Jaak Ristioja <
jaak.r...@cyber.ee> wrote:
>
> So, TLC also optimizes sets and record?
That's correct. In fact, TLA+ does not specify how functions (and thus records) are represented as sets. That's different from standard Zermelo-Fraenkel set theory where functions are sets of ordered pairs (argument, result).
> Because one cannot take the
> element of a record, e.g. \E e \in record: Print(e, TRUE) yields in
> "java.lang.RuntimeException: TLC encountered a non-enumerable quantifier
> bound [answer |-> 42]."
What would you expect as a result? Your formula looks strange to me. If you want to print the entire record, you'd write Print(record, TRUE). If you want to print some record from a set of records, you might write \E e \in records : Print(e, TRUE). If you want to print some record field, you might write \E fld \in DOMAIN record : Print(record[fld], TRUE).
(But in fact, in both these cases, writing a CHOOSE expression would be clearer, although you have to handle the case of the empty set separately.)
> So I guess the question is really whether it is possible in TLC to check
> whether something is a record or a set, e.g.:
>
> IF isRecord(r) THEN (* handle record *) ELSE (* handle set *)
Again, you could use the IsRecord predicate that I defined in my previous message. To my knowledge, there is no built-in function, and I confess I've never missed it because I know the type of the objects that appear in the specification. I might want to write
IF r \in BusinessRecords THEN ... ELSE IF r \in PrivateRecords THEN ... ELSE ...
to handle different kinds of records that are stored in some set. Storing different types of values (such as numbers, functions or sets) in one data structure is legal in TLA+ but usually a bad idea because TLC will give you error messages such as the one above.
Stephan