@@ -40,6 +40,7 @@ import ap.types.MonoSortedPredicate
4040import ap .types .Sort
4141import IExpression ._
4242import ap .util .Seqs
43+ import ap .theories .ModuloArithmetic
4344
4445import scala .collection .mutable .{HashSet => MHashSet , HashMap => MHashMap ,
4546 LinkedHashSet , ArrayBuffer }
@@ -231,16 +232,30 @@ object SymbolSplitter extends HornPreprocessor {
231232
232233 // ////////////////////////////////////////////////////////////////////////////
233234
235+ import ModuloArithmetic .{mod_cast , evalModCast , ModSort }
236+
234237 protected [preprocessor] def solutionEquation (argNum : Int ,
235238 argSort : Sort ,
236239 t : ITerm ) : IFormula =
237- t match {
240+ (t, argSort) match {
238241 // don't introduce a simple equation in case of
239242 // False, this would be too strong
240- case Sort .MultipleValueBool .False =>
243+ case ( Sort .MultipleValueBool .False , Sort . MultipleValueBool ) =>
241244 (v(argNum, argSort) =/= Sort .MultipleValueBool .True )
242- case arg =>
243- (v(argNum, argSort) === arg)
245+ case (Const (value), ModSort (lower, upper)) =>
246+ (v(argNum, argSort) === mod_cast(lower, upper, value))
247+ case (t, argSort) =>
248+ (v(argNum, argSort) === t)
249+ }
250+
251+ protected [preprocessor] def toCtorTerm (arg : ITerm , sort : Sort ) : ITerm =
252+ (arg, sort) match {
253+ case (IIntLit (value), ModSort (lower, upper)) => {
254+ assert(evalModCast(lower, upper, value) == value)
255+ mod_cast(lower, upper, value)
256+ }
257+ case (t, _) =>
258+ t
244259 }
245260
246261 // ////////////////////////////////////////////////////////////////////////////
@@ -274,6 +289,8 @@ object SymbolSplitter extends HornPreprocessor {
274289 object ConcreteTerm {
275290 def unapply (t : ITerm ) : Option [ITerm ] = t match {
276291 case t : IIntLit => Some (t)
292+ case IFunApp (`mod_cast`, Seq (Const (l), Const (u), Const (v)))
293+ => Some (IIntLit (evalModCast(l, u, v)))
277294 case IConstant (c) => constValue get c
278295 case True | False => Some (t)
279296 case _ => None
0 commit comments