Skip to content

"wildcard could be negative" #508

@ArmborstL

Description

@ArmborstL

In the following code, I get the error that "Assert might fail. Fraction wildcard might be negative.".
Changing the program (e.g. removing the trigger on the assert, and using the function call right before it, which is currently commented out) causes viper to verify it successfully.
While playing around with triggers can circumvent the problem, I do not see how wildcard permissions could ever be negative. So I think there might be a deeper issue than just triggers...

Since this is an excerpt from a bigger example, where I stumbled upon negative wildcards quite a few times, I would be interested to hear if this is some underlying bug, or if it can actually be possible that wildcards are negative in certain cases.

domain VCTArray[CT] {
  
  function loc(a: VCTArray[CT], i: Int): CT
  
}

field bool_prop: Bool

field item: Ref

function alwaysTrue(v: Ref): Bool
  ensures result == true

method some_method(trees: VCTArray[Ref], g: Int) 
  requires 0 < g
  requires (forall i: Int :: {loc(trees, i).item} 0 <= i && i < g ==> acc(loc(trees, i).item, wildcard))
  requires (forall i: Int :: {loc(trees, i).item.bool_prop} 0 <= i && i < g ==> acc(loc(trees, i).item.bool_prop, wildcard))
{
  // assert alwaysTrue(loc(trees, 0).item)
  assert forall j: Int :: {loc(trees, j).item.bool_prop} 0 <= j && j < g ==> acc(loc(trees, j).item.bool_prop, wildcard)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions