Skip to content

Way to Nondeterministically Sample _Unique_ Values? #1541

Answered by bugarela
zicklag asked this question in Q&A
Discussion options

You must be logged in to vote

The easiest thing is to just use an incremental id. If you need to generate new ids at any point, you can keep a global counter:

var id_counter: int

action create_new_item = all {
  items' = items.append({ uuid: id_counter, other_field: "foo" }),
  id_counter' = id_counter + 1,
}

Of course, in a real distributed implementation, a global counter is not feasible. But, unless you are trying to specifically verify your uuid generation, you can assume it works properly and just use this simplified approach to unique ids in Quint.

For non-incremental ids, if that's a requirement, the most straightforward way is to use powerset, which takes a set and returns all possible sets with elements of t…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@zicklag
Comment options

Answer selected by zicklag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants