leon icon indicating copy to clipboard operation
leon copied to clipboard

Missing import statement in documentation example

Open nunomota opened this issue 8 years ago • 2 comments

In the Induction section of Proving Theorems, the below example does not make a reference to leon.proof:

import leon.collection._ // for List
import leon.lang._       // for holds

object Example {
  def reverseReverse[T](l: List[T]): Boolean = {
    l.reverse.reverse == l
  }.holds
}

Which is then needed in the following steps (for because, check and trivial calls):

def reverseReverse[T](l: List[T]): Boolean = {
  l.reverse.reverse == l because {
    l match {
      case Nil()       => check {  Nil[T]().reverse.reverse == Nil[T]()  }
      case Cons(x, xs) => check { (x :: xs).reverse.reverse == (x :: xs) }
    }
  }
}.holds
def reverseReverse[T](l: List[T]): Boolean = {
  l.reverse.reverse == l because {
    l match {
      case Nil()       => trivial
      case Cons(x, xs) => check { (xs.reverse :+ x).reverse == (x :: xs) }
    }
  }
}.holds

nunomota avatar Apr 20 '16 18:04 nunomota

@mantognini Maybe you want to look into this?

manoskouk avatar Apr 21 '16 10:04 manoskouk

While because and check were already introduced before, we could add import leon.proof._ // for check, trivial and because as well to make things more obvious and simplify copy-pasting the examples. It would also be a bit more consistent with other snippets.

mantognini avatar Apr 21 '16 17:04 mantognini