Skip to content

Commit

Permalink
Merge pull request #738 from viperproject/meilers_fix_decreases_impor…
Browse files Browse the repository at this point in the history
…t_post

Also checking postconditions for decreases clauses
  • Loading branch information
marcoeilers authored Aug 25, 2023
2 parents 56b74d1 + 7681cd7 commit 65ec341
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ class TerminationPlugin(@unused reporter: viper.silver.reporter.Reporter,
decreasesClauses = decreasesClauses :+ dc
dc
case d => d
}).recurseFunc({ // decreases clauses can only appear in functions/methods pres and methods bodies
}).recurseFunc({ // decreases clauses can only appear in functions/methods pres, posts and methods bodies
case PProgram(_, _, _, _, functions, _, methods, _, _) => Seq(functions, methods)
case PFunction(_, _, _, pres, _, _) => Seq(pres)
case PMethod(_, _, _, pres, _, body) => Seq(pres, body)
case PFunction(_, _, _, pres, posts, _) => Seq(pres, posts)
case PMethod(_, _, _, pres, posts, body) => Seq(pres, posts, body)
}).execute(input)

newProgram
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ predicate list(xs: Ref) {
}

function length(xs: Ref): Int
decreases list(xs)
requires acc(list(xs)) && xs != null // (1)
ensures result > 0
decreases list(xs)
{ unfolding acc(list(xs)) in 1 + (xs.next == null ? 0 : length(xs.next)) } // (1)

function sum(xs: Ref): Int
Expand Down

0 comments on commit 65ec341

Please sign in to comment.