Skip to content

Stop simplifying the left-hand side of equations #2392

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

Merged
merged 40 commits into from
Mar 10, 2021
Merged

Conversation

emarzion
Copy link
Contributor

@emarzion emarzion commented Feb 5, 2021

Fixes #2341


Review checklist

The author performs the actions on the checklist. The reviewer evaluates the work and checks the boxes as they are completed.

  • Summary. Write a summary of the changes. Explain what you did to fix the issue, and why you did it. Present the changes in a logical order. Instead of writing a summary in the pull request, you may push a clean Git history.
  • Documentation. Write documentation for new functions. Update documentation for functions that changed, or complete documentation where it is missing.
  • Tests. Write unit tests for every change. Write the unit tests that were missing before the changes. Include any examples from the reported issue as integration tests.
  • Clean up. The changes are already clean. Clean up anything near the changes that you noticed while working. This does not mean only spatially near the changes, but logically near: any code that interacts with the changes!

Comment on lines 90 to 91
Monad.unless
((isTop . predicate) simplifiedCond)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is this: Before, we would return early if any of the simplifiedResults (i.e. any branch) had a predicate which was not \top. Now, we only return early on that branch. If you swap the order of Logic.observeAllT and returnOriginalIfAborted below (changing the order of nesting LogicT and ExceptT) then all will be well: the entire computation will exit early if any branch exits early.

@emarzion
Copy link
Contributor Author

I'm getting the following error:

./kwasm prove --backend haskell tests/proofs/wrc20-spec.k WRC20-LEMMAS --format-failures \
	--concrete-rules WASM-DATA.wrap-Positive,WASM-DATA.setRange-Positive,WASM-DATA.getRange-Positive,WASM-DATA.get-Existing,WASM-DATA.set-Extend
kore-exec: [237865963] Warning (WarnStuckClaimState):
    (InfoReachability) while checking the implication:
    The proof has reached the final configuration, but the claimed implication is not valid. Location: /Users/emarzion/wasm-semantics/././tests/proofs/wrc20-spec.k:10:11-46:84
  #Not ( {
      #getRange ( #setRange ( BM , ADDR , #getRange ( BM , ADDR +Int 7 , 1 ) +Int ( #getRange ( BM , ADDR +Int 6 , 1 ) +Int ( #getRange ( BM , ADDR +Int 5 , 1 ) +Int ( #getRange ( BM , ADDR +Int 4 , 1 ) +Int ( #getRange ( BM , ADDR +Int 3 , 1 ) +Int ( #getRange ( BM , ADDR +Int 2 , 1 ) +Int ( #getRange ( BM , ADDR +Int 1 , 1 ) +Int ( #getRange ( BM , ADDR , 1 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) , 8 ) , ADDR +Int 1 , 1 )
    #Equals
      #getRange ( BM , ADDR +Int 6 , 1 )
    }
  #And
    {
      #getRange ( #setRange ( BM , ADDR , #getRange ( BM , ADDR +Int 7 , 1 ) +Int ( #getRange ( BM , ADDR +Int 6 , 1 ) +Int ( #getRange ( BM , ADDR +Int 5 , 1 ) +Int ( #getRange ( BM , ADDR +Int 4 , 1 ) +Int ( #getRange ( BM , ADDR +Int 3 , 1 ) +Int ( #getRange ( BM , ADDR +Int 2 , 1 ) +Int ( #getRange ( BM , ADDR +Int 1 , 1 ) +Int ( #getRange ( BM , ADDR , 1 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) , 8 ) , ADDR +Int 2 , 1 )
    #Equals
      #getRange ( BM , ADDR +Int 5 , 1 )
    }
  #And
    {
      #getRange ( #setRange ( BM , ADDR , #getRange ( BM , ADDR +Int 7 , 1 ) +Int ( #getRange ( BM , ADDR +Int 6 , 1 ) +Int ( #getRange ( BM , ADDR +Int 5 , 1 ) +Int ( #getRange ( BM , ADDR +Int 4 , 1 ) +Int ( #getRange ( BM , ADDR +Int 3 , 1 ) +Int ( #getRange ( BM , ADDR +Int 2 , 1 ) +Int ( #getRange ( BM , ADDR +Int 1 , 1 ) +Int ( #getRange ( BM , ADDR , 1 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) , 8 ) , ADDR +Int 3 , 1 )
    #Equals
      #getRange ( BM , ADDR +Int 4 , 1 )
    }
  #And
    {
      #getRange ( #setRange ( BM , ADDR , #getRange ( BM , ADDR +Int 7 , 1 ) +Int ( #getRange ( BM , ADDR +Int 6 , 1 ) +Int ( #getRange ( BM , ADDR +Int 5 , 1 ) +Int ( #getRange ( BM , ADDR +Int 4 , 1 ) +Int ( #getRange ( BM , ADDR +Int 3 , 1 ) +Int ( #getRange ( BM , ADDR +Int 2 , 1 ) +Int ( #getRange ( BM , ADDR +Int 1 , 1 ) +Int ( #getRange ( BM , ADDR , 1 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) , 8 ) , ADDR +Int 4 , 1 )
    #Equals
      #getRange ( BM , ADDR +Int 3 , 1 )
    }
  #And
    {
      #getRange ( #setRange ( BM , ADDR , #getRange ( BM , ADDR +Int 7 , 1 ) +Int ( #getRange ( BM , ADDR +Int 6 , 1 ) +Int ( #getRange ( BM , ADDR +Int 5 , 1 ) +Int ( #getRange ( BM , ADDR +Int 4 , 1 ) +Int ( #getRange ( BM , ADDR +Int 3 , 1 ) +Int ( #getRange ( BM , ADDR +Int 2 , 1 ) +Int ( #getRange ( BM , ADDR +Int 1 , 1 ) +Int ( #getRange ( BM , ADDR , 1 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) , 8 ) , ADDR +Int 5 , 1 )
    #Equals
      #getRange ( BM , ADDR +Int 2 , 1 )
    }
  #And
    {
      #getRange ( #setRange ( BM , ADDR , #getRange ( BM , ADDR +Int 7 , 1 ) +Int ( #getRange ( BM , ADDR +Int 6 , 1 ) +Int ( #getRange ( BM , ADDR +Int 5 , 1 ) +Int ( #getRange ( BM , ADDR +Int 4 , 1 ) +Int ( #getRange ( BM , ADDR +Int 3 , 1 ) +Int ( #getRange ( BM , ADDR +Int 2 , 1 ) +Int ( #getRange ( BM , ADDR +Int 1 , 1 ) +Int ( #getRange ( BM , ADDR , 1 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) , 8 ) , ADDR +Int 6 , 1 )
    #Equals
      #getRange ( BM , ADDR +Int 1 , 1 )
    }
  #And
    {
      #getRange ( #setRange ( BM , ADDR , #getRange ( BM , ADDR +Int 7 , 1 ) +Int ( #getRange ( BM , ADDR +Int 6 , 1 ) +Int ( #getRange ( BM , ADDR +Int 5 , 1 ) +Int ( #getRange ( BM , ADDR +Int 4 , 1 ) +Int ( #getRange ( BM , ADDR +Int 3 , 1 ) +Int ( #getRange ( BM , ADDR +Int 2 , 1 ) +Int ( #getRange ( BM , ADDR +Int 1 , 1 ) +Int ( #getRange ( BM , ADDR , 1 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) , 8 ) , ADDR +Int 7 , 1 )
    #Equals
      #getRange ( BM , ADDR , 1 )
    }
  #And
    {
      #getRange ( #setRange ( BM , ADDR , #getRange ( BM , ADDR +Int 7 , 1 ) +Int ( #getRange ( BM , ADDR +Int 6 , 1 ) +Int ( #getRange ( BM , ADDR +Int 5 , 1 ) +Int ( #getRange ( BM , ADDR +Int 4 , 1 ) +Int ( #getRange ( BM , ADDR +Int 3 , 1 ) +Int ( #getRange ( BM , ADDR +Int 2 , 1 ) +Int ( #getRange ( BM , ADDR +Int 1 , 1 ) +Int ( #getRange ( BM , ADDR , 1 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) , 8 ) , ADDR , 1 )
    #Equals
      #getRange ( BM , ADDR +Int 7 , 1 )
    } )
#And
  <wasm>
    <instrs>
      _DotVar2
    </instrs>
    <valstack>
      _37
    </valstack>
    <curFrame>
      <locals>
        _DotVar10
      </locals>
      <curModIdx>
        CUR:Int
      </curModIdx>
    </curFrame>
    <moduleRegistry>
      _38
    </moduleRegistry>
    <moduleIds>
      _39
    </moduleIds>
    <moduleInstances>
      <moduleInst>
        <modIdx>
          CUR
        </modIdx>
        <exports>
          _25
        </exports>
        <types>
          1 |-> [ i64  .ValTypes ] -> [ i64  .ValTypes ]
        </types>
        <nextTypeIdx>
          _26
        </nextTypeIdx>
        <funcAddrs>
          _0 [ NEXTFUNCIDX:Int <- NEXTADDR:Int ]
        </funcAddrs>
        <nextFuncIdx>
          NEXTFUNCIDX +Int 1
        </nextFuncIdx>
        <tabIds>
          _27
        </tabIds>
        <tabAddrs>
          _28
        </tabAddrs>
        <memIds>
          _29
        </memIds>
        <memAddrs>
          0 |-> MEMADDR:Int
        </memAddrs>
        <globIds>
          _30
        </globIds>
        <globalAddrs>
          _31
        </globalAddrs>
        <nextGlobIdx>
          _32
        </nextGlobIdx>
        <moduleMetadata>
          <moduleFileName>
            _33
          </moduleFileName>
          <moduleId>
            _34
          </moduleId>
          <funcIds>
            _35
          </funcIds>
          <typeIds>
            _36
          </typeIds>
        </moduleMetadata>
      </moduleInst> _DotVar7
    </moduleInstances>
    <nextModuleIdx>
      _40
    </nextModuleIdx>
    <mainStore>
      <funcs>
        <funcDef>
          <fAddr>
            NEXTADDR
          </fAddr>
          <fCode>
            #block ( [ .ValTypes ] , #loop ( [ .ValTypes ] , #local.get ( 1 )  i64 . const 8  i64 . ge_u  #br_if ( 1 )  #local.get ( 0 )  i64 . const 56  #local.get ( 1 )  i64 . const 8  i64 . mul  i64 . sub  i64 . shl  i64 . const 56  i64 . shr_u  i64 . const 56  i64 . const 8  #local.get ( 1 )  i64 . mul  i64 . sub  i64 . shl  #local.get ( 2 )  i64 . add  #local.set ( 2 )  #local.get ( 1 )  i64 . const 1  i64 . add  #local.set ( 1 )  #br ( 0 )  .EmptyStmts )  .EmptyStmts )  #local.get ( 2 )  .EmptyStmts
          </fCode>
          <fType>
            [ i64  .ValTypes ] -> [ i64  .ValTypes ]
          </fType>
          <fLocal>
            [ i64  i64  .ValTypes ]
          </fLocal>
          <fModInst>
            CUR
          </fModInst>
          <funcMetadata>
            <funcId>
              $i64.reverse_bytes
            </funcId>
            <localIds>
              .Map
            </localIds>
          </funcMetadata>
        </funcDef>
      </funcs>
      <nextFuncAddr>
        NEXTADDR +Int 1
      </nextFuncAddr>
      <tabs>
        _20
      </tabs>
      <nextTabAddr>
        _21
      </nextTabAddr>
      <mems>
        <memInst>
          <mAddr>
            MEMADDR
          </mAddr>
          <mmax>
            _DotVar9
          </mmax>
          <msize>
            SIZE
          </msize>
          <mdata>
            #setRange ( BM , ADDR , #getRange ( BM , ADDR +Int 7 , 1 ) +Int ( #getRange ( BM , ADDR +Int 6 , 1 ) +Int ( #getRange ( BM , ADDR +Int 5 , 1 ) +Int ( #getRange ( BM , ADDR +Int 4 , 1 ) +Int ( #getRange ( BM , ADDR +Int 3 , 1 ) +Int ( #getRange ( BM , ADDR +Int 2 , 1 ) +Int ( #getRange ( BM , ADDR +Int 1 , 1 ) +Int ( #getRange ( BM , ADDR , 1 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) <<Int 8 ) , 8 )
          </mdata>
        </memInst> _DotVar4
      </mems>
      <nextMemAddr>
        _22
      </nextMemAddr>
      <globals>
        _23
      </globals>
      <nextGlobAddr>
        _24
      </nextGlobAddr>
    </mainStore>
    <deterministicMemoryGrowth>
      _41
    </deterministicMemoryGrowth>
  </wasm>
#And
  {
    false
  #Equals
    <mAddr>
      MEMADDR
    </mAddr> in_keys ( _DotVar4 )
  }
#And
  {
    false
  #Equals
    <modIdx>
      CUR
    </modIdx> in_keys ( _DotVar7 )
  }
#And
  {
    true
  #Equals
    0 <=Int ADDR
  }
#And
  {
    true
  #Equals
    ADDR +Int 8 <=Int SIZE *Int 65536
  }
#And
  {
    true
  #Equals
    ADDR <Int 4294967296
  }

@emarzion emarzion marked this pull request as ready for review March 8, 2021 19:29
@ttuegel ttuegel requested review from ttuegel and MirceaS March 9, 2021 15:25
MirceaS
MirceaS previously requested changes Mar 9, 2021
@emarzion emarzion requested a review from MirceaS March 10, 2021 16:13
@emarzion emarzion dismissed MirceaS’s stale review March 10, 2021 16:29

Request addressed.

@emarzion emarzion merged commit 95b6c10 into master Mar 10, 2021
@emarzion emarzion deleted the no-simplify-lhs branch March 10, 2021 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop simplifying the left-hand side of equations
3 participants