forked from regb/scala-smtlib
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInts.scala
57 lines (48 loc) · 1.67 KB
/
Ints.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package smtlib
package theories
import trees.Terms._
import Operations._
object Ints {
object IntSort {
def apply(): Sort = {
Sort(Identifier(SSymbol("Int")))
}
def unapply(sort: Sort): Boolean = sort match {
case Sort(Identifier(SSymbol("Int"), Seq()), Seq()) => true
case _ => false
}
}
object NumeralLit {
def apply(value: BigInt): Term = SNumeral(value)
def unapply(term: Term): Option[BigInt] = term match {
case SNumeral(value) => Some(value)
case _ => None
}
}
object Divisible {
def apply(n: BigInt, t: Term): Term =
FunctionApplication(
QualifiedIdentifier(Identifier(SSymbol("divisible"), Seq(SNumeral(n)))),
Seq(t)
)
def unapply(term: Term): Option[(BigInt, Term)] = term match {
case FunctionApplication(
QualifiedIdentifier(
Identifier(SSymbol("divisible"), Seq(SNumeral(n))),
None
), Seq(t)) => Some((n, t))
case _ => None
}
}
object Neg extends Operation1 { override val name = "-" }
object Add extends OperationN1 { override val name = "+" }
object Sub extends OperationN1 { override val name = "-" }
object Mul extends OperationN1 { override val name = "*" }
object Div extends OperationN1 { override val name = "div" }
object Mod extends Operation2 { override val name = "mod" }
object Abs extends Operation1 { override val name = "abs" }
object LessThan extends Operation2 { override val name = "<" }
object LessEquals extends Operation2 { override val name = "<=" }
object GreaterThan extends Operation2 { override val name = ">" }
object GreaterEquals extends Operation2 { override val name = ">=" }
}