viperproject / silver

Definition of the Viper intermediate verification language.
Mozilla Public License 2.0
78 stars 40 forks source link

Perm under inhale-exhale expression handled differently by Silicon vs. Carbon #808

Open mschwerhoff opened 2 months ago

mschwerhoff commented 2 months ago

While playing with a forall-introduction lemma, I noticed that Silicon and Carbon handle perm() nested inside inhale-exhale expressions differently:

field f: Int

function foo(x: Ref, p: Perm): Bool
  requires p > none
  requires acc(x.f, p)

method lemma_forall_intro()
  ensures [forall y: Ref :: perm(y.f) > none ==> foo(y, write), true]
    // Silicon: Rejected as illformed
    // Carbon: Not rejected

method test0() {
  var a: Ref

  inhale acc(a.f, 1/2)
  lemma_forall_intro()
  assert perm(a.f) > none ==> foo(a, write)
    // Silicon: OK
    // Carbon: Fails with insufficient permission
}

method test1() {
  var a: Ref

  inhale acc(a.f, 1/2)
  lemma_forall_intro()
  assert perm(a.f) > none ==> foo(a, 1/2)
    // Silicon: OK
    // Carbon: Fails with "might not hold"
}

method test2() {
  var a: Ref

  inhale acc(a.f, write) 
  lemma_forall_intro()
  assert perm(a.f) > none ==> foo(a, write)
    // Silicon: Fails with "might not hold"
    // Carbon: OK
}