Skip to content

Can ensure false as the post-condition of a function #668

@BenjaminFrei

Description

@BenjaminFrei

We are able to prove false in the function lenght below. This should not be possible.

adt List[T] {
  Nil()
  Cons(value : T, tail : List[T])
} 

function lenght(xs : List[Int]) : Int
  ensures lenght(xs) >= 0
  ensures xs.isNil ==> lenght(xs) == 0
  ensures (xs.isCons ==> lenght(xs) == lenght(xs.tail) + 2)
  ensures false
{
  (xs.isNil ? 0 : (1 + lenght(xs.tail)))
}

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