次のエティエンヌの投稿:
これは機能しますが、まだhttps://github.com/epfl-lara/leon/blob/master/library/lang/Set.scalaにセットを実装する必要があります。私はそのようにしました:
package leon.lang
import leon.annotation._
import scala.collection.{ immutable => imm }
object Set {
@library
def empty[T] = Set[T]()
protected[Set] def apply[T](elems: imm.Set[T]): Set[T] = Set(elems.toSeq :_*)
}
@ignore
case class Set[T](elems: T*) {
def +(a: T): Set[T] = Set(elems.toSet + a)
def ++(a: Set[T]): Set[T] = Set(elems.toSet ++ a.elems.toSet) //Set.trim(elems ++ a.elems) //Set((elems.toSeq ++ a.elems.toSeq).toSet.toSeq :_*)
def -(a: T): Set[T] = Set(elems.toSet - a)
def --(a: Set[T]): Set[T] = Set(elems.toSet -- a.elems.toSet)
def contains(a: T): Boolean = elems.toSet.contains(a)
def isEmpty: Boolean = this == Set.empty
def subsetOf(b: Set[T]): Boolean = elems.toSet.forall(e => b.elems.toSet.contains(e))
def &(a: Set[T]): Set[T] = Set(elems.toSet & a.elems.toSet)
}
残念ながら、これを Leon のように直接使用することはできません。
[ Error ] 8:31: Scala's Set API is no longer extracted. Make sure you import leon.lang.Set that defines supported Set operations.
protected[Set] def apply[T](elems: imm.Set[T]): Set[T] = Set(elems.toSeq :_*)
^^^^^^^^^^^^^^^^^
ただし、次を使用してコンパイルscalac
および実行する場合は問題なく動作します。scala
scalac $(find ~/my-path/leon/library/ -name "*.scala" | xargs) Queue.scala
とにかく、--eval
トリックがあれば、それを使用しましょう!
ありがとうございました!