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

[BUG] Function displayed in the counterexample with multiple indices #962

Closed
andrey-kuprianov opened this issue Aug 25, 2021 · 6 comments · Fixed by #1146
Closed

[BUG] Function displayed in the counterexample with multiple indices #962

andrey-kuprianov opened this issue Aug 25, 2021 · 6 comments · Fixed by #1146
Assignees
Labels
bug help wanted usability UX improvements user-support helping the users

Comments

@andrey-kuprianov
Copy link
Contributor

Description

In the produced TLA+ counterexample a function is displayed with twice the same index

Input specification

See https://github.com/informalsystems/modelator/blob/c9b54c1c4cd753af833ae4a16b626e4d3a5cab94/modelator/tests/integration/tla/IBC_ics02.tla

The command line parameters used to run the tool

apalache-mc check --cinit=CInit --inv=InvTestClientWith3Heights IBC_ics02.tla

Log files

Here are the last few lines of the produced counterexample that contain the erroneous output:

(* Transition 2 to State3 *)
State3 ==
  ChainIds = { "chainA", "chainB" }
    /\ MaxChainHeight = 10
    /\ MaxClientsPerChain = 5
    /\ action
      = [chainId |-> "chainB",
        clientId |-> 0,
        height |-> 3,
        type |-> "UpdateClient"]
    /\ actionOutcome = "OK"
    /\ chains
      = "chainA"
          :> [clientIdCounter |-> 0,
            clients |-> [ x \in {} |-> x ],
            height |-> 1]
        @@ "chainB"
          :> [clientIdCounter |-> 1,
            clients |->
              0 :> [heights |-> { 1, 2, 3 }] @@ 0 :> [heights |-> { 1, 2, 3 }],
            height |-> 4]

(* The following formula holds true in the last state and violates the invariant *)
InvariantViolation ==
  Skolem((\E c$3 \in ChainIds:
    Skolem((\E cl$2 \in DOMAIN (chains[c$3]["clients"]):
      ConstCardinality((Cardinality(chains[c$3]["clients"][cl$2]["heights"])
        >= 3))))))

System information

  • Apalache version: 0.15.11
  • OS: Mac
  • JDK version: OpenJDK Runtime Environment Zulu15.32+15-CA
@andrey-kuprianov andrey-kuprianov changed the title [BUG] [BUG] Function displayed in the counterexample with double index Aug 25, 2021
@andrey-kuprianov
Copy link
Contributor Author

andrey-kuprianov commented Aug 25, 2021

It gets even more interesting than that:

(* Transition 2 to State6 *)
State6 ==
  ChainIds = { "chainA", "chainB" }
    /\ MaxChainHeight = 4
    /\ MaxClientsPerChain = 2
    /\ action
      = [chainId |-> "chainA",
        clientId |-> 1,
        height |-> 4,
        type |-> "UpdateClient"]
    /\ actionOutcome = "OK"
    /\ chains
      = "chainA"
          :> [clientIdCounter |-> 2,
            clients |->
              (((1 :> [heights |-> { 1, 3, 4 }]
                      @@ 1 :> [heights |-> { 1, 3, 4 }])
                    @@ 1 :> [heights |-> { 1, 3, 4 }])
                  @@ 1 :> [heights |-> { 1, 3, 4 }])
                @@ 0 :> [heights |-> { 1, 2, 3 }],
            height |-> 7]
        @@ "chainB"
          :> [clientIdCounter |-> 0,
            clients |-> [ x \in {} |-> x ],
            height |-> 1]

@andrey-kuprianov andrey-kuprianov changed the title [BUG] Function displayed in the counterexample with double index [BUG] Function displayed in the counterexample with multiple indices Aug 25, 2021
@konnov
Copy link
Collaborator

konnov commented Aug 25, 2021

Nice. The important thing is that all copies agree on the value for the key 1.

@konnov konnov added the usability UX improvements label Aug 25, 2021
@konnov konnov added this to the September iteration milestone Aug 25, 2021
@konnov konnov added help wanted user-support helping the users labels Aug 25, 2021
@konnov
Copy link
Collaborator

konnov commented Aug 25, 2021

@shonfeder, do you like to have a look at this one? It should be something in https://github.com/informalsystems/apalache/blob/unstable/tla-bmcmt/src/main/scala/at/forsyte/apalache/tla/bmcmt/SymbStateDecoder.scala

@shonfeder shonfeder self-assigned this Aug 25, 2021
@shonfeder
Copy link
Contributor

I've identified the root cause and am working on a fix.

@shonfeder
Copy link
Contributor

See #962 for a report on my understanding of the underlying problem, and my (blocking) question on how we want to approach it.

@shonfeder
Copy link
Contributor

Here is a MWE

------------------- MODULE Dup -----------------------

VARIABLES
  \* @type: Int -> Int;
  someFun

Init == someFun = [x \in {0, 0} |-> 1]

Next == UNCHANGED someFun

Inv == 0 \notin DOMAIN someFun

============================================================

Run with

apalache-mc check --inv=Inv Dup.tla

Producing the counterexample:

---------------------------- MODULE counterexample ----------------------------

EXTENDS Dup

(* Constant initialization state *)
ConstInit == TRUE

(* Initial state *)
State0 == someFun = 0 :> 1 @@ 0 :> 1

(* The following formula holds true in the last state and violates the invariant *)
InvariantViolation == 0 \in DOMAIN someFun

================================================================================
(* Created by Apalache on Thu Nov 25 14:50:13 EST 2021 *)
(* https://github.com/informalsystems/apalache *)

shonfeder pushed a commit that referenced this issue Nov 26, 2021
shonfeder pushed a commit that referenced this issue Nov 26, 2021
This was referenced Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help wanted usability UX improvements user-support helping the users
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants