Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An index out of range error when combining oneOf and setOfMaps #1530

Open
ivan-gavran opened this issue Oct 15, 2024 · 0 comments
Open

An index out of range error when combining oneOf and setOfMaps #1530

ivan-gavran opened this issue Oct 15, 2024 · 0 comments
Assignees
Labels
bug Something isn't working simulator Quint simulator

Comments

@ivan-gavran
Copy link
Contributor

Consider the following simple model:

module problem{
    var x: str -> (str -> int)
    val X = Set("A", "B")
    val Y = Set("C", "D")
    val Z = Set(1,2)
    val allPossibleVals = setOfMaps(X, setOfMaps(Y, Z))

    action init =                 
        nondet initVal = allPossibleVals.oneOf()
        x' = initVal

    action step = 
        x' = x

    }   

When running the simulator quint run --max-samples=1 --max-steps=1 problem.qnt, a runtime error occurs:

error: [QNT501] Index out of bounds
[lineNumber]: nondet initVal = allPossibleVals.oneOf()


There are two curious things here:

  1. If we modify Y to be a singleton set, the problem disappears. (Making X or Z singleton has no effect.)
  2. If the set allPossibleVals is evaluated first (in the REPL) and the provided as a constant to the model, the problem disappears.
    Concretely:
module problem{
    var x: str -> (str -> int)
    val allPossibleVals = Set(
        Map("A" -> Map("C" -> 1, "D" -> 1), "B" -> Map("C" -> 1, "D" -> 1)),
        Map("A" -> Map("C" -> 2, "D" -> 1), "B" -> Map("C" -> 1, "D" -> 1)),
        Map("A" -> Map("C" -> 1, "D" -> 2), "B" -> Map("C" -> 1, "D" -> 1)),
        Map("A" -> Map("C" -> 2, "D" -> 2), "B" -> Map("C" -> 1, "D" -> 1)),
        Map("A" -> Map("C" -> 1, "D" -> 1), "B" -> Map("C" -> 2, "D" -> 1)),
        Map("A" -> Map("C" -> 2, "D" -> 1), "B" -> Map("C" -> 2, "D" -> 1)),
        Map("A" -> Map("C" -> 1, "D" -> 2), "B" -> Map("C" -> 2, "D" -> 1)),
        Map("A" -> Map("C" -> 2, "D" -> 2), "B" -> Map("C" -> 2, "D" -> 1)),
        Map("A" -> Map("C" -> 1, "D" -> 1), "B" -> Map("C" -> 1, "D" -> 2)),
        Map("A" -> Map("C" -> 2, "D" -> 1), "B" -> Map("C" -> 1, "D" -> 2)),
        Map("A" -> Map("C" -> 1, "D" -> 2), "B" -> Map("C" -> 1, "D" -> 2)),
        Map("A" -> Map("C" -> 2, "D" -> 2), "B" -> Map("C" -> 1, "D" -> 2)),
        Map("A" -> Map("C" -> 1, "D" -> 1), "B" -> Map("C" -> 2, "D" -> 2)),
        Map("A" -> Map("C" -> 2, "D" -> 1), "B" -> Map("C" -> 2, "D" -> 2)),
        Map("A" -> Map("C" -> 1, "D" -> 2), "B" -> Map("C" -> 2, "D" -> 2)),
        Map("A" -> Map("C" -> 2, "D" -> 2), "B" -> Map("C" -> 2, "D" -> 2))
    )

    action init = 
        nondet initVal = allPossibleVals.oneOf()
        x' = initVal

    action step = 
        x' = x

    }
@ivan-gavran ivan-gavran changed the title An index out of range bug when combining oneOf and setOfMaps An index out of range error when combining oneOf and setOfMaps Oct 15, 2024
@bugarela bugarela added bug Something isn't working simulator Quint simulator labels Oct 16, 2024
@bugarela bugarela self-assigned this Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working simulator Quint simulator
Projects
None yet
Development

No branches or pull requests

2 participants