Skip to content

Commit ca9c022

Browse files
mario-bucevvkuncak
authored andcommitted
Making some arithmetic ops n-ary
1 parent 351cad5 commit ca9c022

File tree

4 files changed

+44
-12
lines changed

4 files changed

+44
-12
lines changed

src/it/scala/smtlib/it/TheoriesBuilderTests.scala

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class TheoriesBuilderTests extends AnyFunSuite with TestHelpers {
5151

5252

5353
{
54+
import theories.Core.Equals
5455
import theories.Ints._
5556
val theoryString = "Theory of Ints"
5657
var counter = 0
@@ -84,9 +85,22 @@ class TheoriesBuilderTests extends AnyFunSuite with TestHelpers {
8485

8586
val f8 = LessEquals(Sub(NumeralLit(5), NumeralLit(3)), NumeralLit(1))
8687
mkTest(f8, UnsatStatus, uniqueName())
88+
89+
val f9 = Equals(Add(NumeralLit(1), NumeralLit(2), NumeralLit(3), NumeralLit(4)), NumeralLit(10))
90+
mkTest(f9, SatStatus, uniqueName())
91+
92+
val f10 = Equals(Sub(NumeralLit(1), NumeralLit(2), NumeralLit(3), NumeralLit(4)), NumeralLit(-8))
93+
mkTest(f10, SatStatus, uniqueName())
94+
95+
val f11 = Equals(Mul(NumeralLit(1), NumeralLit(2), NumeralLit(3), NumeralLit(4)), NumeralLit(24))
96+
mkTest(f11, SatStatus, uniqueName())
97+
98+
val f12 = Equals(Div(NumeralLit(80), NumeralLit(4), NumeralLit(2)), NumeralLit(10))
99+
mkTest(f12, SatStatus, uniqueName())
87100
}
88101

89102
{
103+
import theories.Core.Equals
90104
import theories.Reals._
91105
val theoryString = "Theory of Reals"
92106
var counter = 0
@@ -116,6 +130,18 @@ class TheoriesBuilderTests extends AnyFunSuite with TestHelpers {
116130

117131
val f8 = LessEquals(Sub(NumeralLit(5), NumeralLit(3)), NumeralLit(1))
118132
mkTest(f8, UnsatStatus, uniqueName())
133+
134+
val f9 = Equals(Add(NumeralLit(1), NumeralLit(2), NumeralLit(3), NumeralLit(4)), NumeralLit(10))
135+
mkTest(f9, SatStatus, uniqueName())
136+
137+
val f10 = Equals(Sub(NumeralLit(1), NumeralLit(2), NumeralLit(3), NumeralLit(4)), NumeralLit(-8))
138+
mkTest(f10, SatStatus, uniqueName())
139+
140+
val f11 = Equals(Mul(NumeralLit(1), NumeralLit(2), NumeralLit(3), NumeralLit(4)), NumeralLit(24))
141+
mkTest(f11, SatStatus, uniqueName())
142+
143+
val f12 = Equals(Div(NumeralLit(80), NumeralLit(4), NumeralLit(2)), NumeralLit(10))
144+
mkTest(f12, SatStatus, uniqueName())
119145
}
120146

121147
{
@@ -181,5 +207,11 @@ class TheoriesBuilderTests extends AnyFunSuite with TestHelpers {
181207
// Int2BV does not care about the sign
182208
val f17 = Equals(Int2BV(8, NumeralLit(-214)), BitVectorConstant(42, 8))
183209
mkTest(f17, SatStatus, uniqueName())
210+
211+
val f18 = Equals(Add(BitVectorConstant(1, 32), BitVectorConstant(2, 32), BitVectorConstant(3, 32), BitVectorConstant(4, 32)), BitVectorConstant(10, 32))
212+
mkTest(f18, SatStatus, uniqueName())
213+
214+
val f20 = Equals(Mul(BitVectorConstant(1, 32), BitVectorConstant(2, 32), BitVectorConstant(3, 32), BitVectorConstant(4, 32)), BitVectorConstant(24, 32))
215+
mkTest(f20, SatStatus, uniqueName())
184216
}
185217
}

src/main/scala/smtlib/theories/FixedSizeBitVectors.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ object FixedSizeBitVectors {
5656
}
5757

5858

59-
object Concat extends Operation2 { override val name = "concat" }
59+
object Concat extends OperationN1 { override val name = "concat" }
6060

6161
object Not extends Operation1 { override val name = "bvnot" }
6262
object Neg extends Operation1 { override val name = "bvneg" }
@@ -68,9 +68,9 @@ object FixedSizeBitVectors {
6868
object XNOr extends Operation2 { override val name = "bvxnor" }
6969

7070
object Comp extends Operation2 { override val name = "bvcomp" }
71-
object Add extends Operation2 { override val name = "bvadd" }
71+
object Add extends OperationN1 { override val name = "bvadd" }
7272
object Sub extends Operation2 { override val name = "bvsub" }
73-
object Mul extends Operation2 { override val name = "bvmul" }
73+
object Mul extends OperationN1 { override val name = "bvmul" }
7474
object UDiv extends Operation2 { override val name = "bvudiv" }
7575
object SDiv extends Operation2 { override val name = "bvsdiv" }
7676
object URem extends Operation2 { override val name = "bvurem" }

src/main/scala/smtlib/theories/Ints.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ object Ints {
4242
}
4343

4444
object Neg extends Operation1 { override val name = "-" }
45-
object Add extends Operation2 { override val name = "+" }
46-
object Sub extends Operation2 { override val name = "-" }
47-
object Mul extends Operation2 { override val name = "*" }
48-
object Div extends Operation2 { override val name = "div" }
45+
object Add extends OperationN1 { override val name = "+" }
46+
object Sub extends OperationN1 { override val name = "-" }
47+
object Mul extends OperationN1 { override val name = "*" }
48+
object Div extends OperationN1 { override val name = "div" }
4949
object Mod extends Operation2 { override val name = "mod" }
5050
object Abs extends Operation1 { override val name = "abs" }
5151

src/main/scala/smtlib/theories/Reals.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object Reals {
2828
case _ => None
2929
}
3030
}
31-
31+
3232
object DecimalLit {
3333
def apply(value: BigDecimal): Term = SDecimal(value)
3434
def unapply(term: Term): Option[BigDecimal] = term match {
@@ -38,10 +38,10 @@ object Reals {
3838
}
3939

4040
object Neg extends Operation1 { override val name = "-" }
41-
object Add extends Operation2 { override val name = "+" }
42-
object Sub extends Operation2 { override val name = "-" }
43-
object Mul extends Operation2 { override val name = "*" }
44-
object Div extends Operation2 { override val name = "/" }
41+
object Add extends OperationN1 { override val name = "+" }
42+
object Sub extends OperationN1 { override val name = "-" }
43+
object Mul extends OperationN1 { override val name = "*" }
44+
object Div extends OperationN1 { override val name = "/" }
4545

4646
object LessThan extends Operation2 { override val name = "<" }
4747
object LessEquals extends Operation2 { override val name = "<=" }

0 commit comments

Comments
 (0)