@@ -144,13 +144,9 @@ trait VerificationChecker { self =>
144144 * - rewrite the invariant's invocation to be applied to this new variable instead.
145145 * - evaluate the resulting condition under the new model.
146146 */
147- protected def checkAdtInvariantModel (vc : VC , invId : Identifier , model : Model ): VCStatus = {
147+ protected def checkAdtInvariantModel (vc : VC , invId : Identifier , expr : Expr , model : Model ): VCStatus = {
148148 import inox .evaluators .EvaluationResults ._
149149
150- val Seq ((inv, adt, path)) = collectWithPC(vc.condition) {
151- case (inv @ FunctionInvocation (`invId`, _, Seq (adt : ADT )), path) => (inv, adt, path)
152- }
153-
154150 def success : VCStatus = {
155151 reporter.debug(" - Model validated." )
156152 VCStatus .Invalid (VCStatus .CounterExample (model))
@@ -161,6 +157,21 @@ trait VerificationChecker { self =>
161157 VCStatus .Unknown
162158 }
163159
160+ val pcCond = collectWithPC(expr) {
161+ case (inv @ FunctionInvocation (`invId`, _, Seq (adt : ADT )), path) => (inv, adt, path)
162+ }
163+
164+ if (pcCond.isEmpty) {
165+ return evaluator.eval(expr, model) match {
166+ case Successful (BooleanLiteral (false )) => success
167+ case Successful (_) => failure(" - Invalid model." )
168+ case RuntimeError (msg) => failure(s " - Model leads to runtime error: $msg" )
169+ case EvaluatorError (msg) => failure(s " - Model leads to evaluation error: $msg" )
170+ }
171+ }
172+
173+ val Seq ((inv, adt, path)) = pcCond
174+
164175 evaluator.eval(path.toClause, model) match {
165176 case Successful (BooleanLiteral (true )) => // path condition was true, we must evaluate invariant
166177 case Successful (BooleanLiteral (false )) => return success
@@ -184,7 +195,7 @@ trait VerificationChecker { self =>
184195 val adtVar = Variable (FreshIdentifier (" adt" ), adt.getType(symbols), Seq ())
185196 val newInv = FunctionInvocation (invId, inv.tps, Seq (adtVar))
186197 val newModel = inox.Model (program)(model.vars + (adtVar.toVal -> newAdt), model.chooses)
187- val newCondition = exprOps.replace(Map (inv -> newInv), vc.condition )
198+ val newCondition = exprOps.replace(Map (inv -> newInv), expr )
188199
189200 evaluator.eval(newCondition, newModel) match {
190201 case Successful (BooleanLiteral (false )) => success
@@ -252,8 +263,8 @@ trait VerificationChecker { self =>
252263 VCResult (VCStatus .Valid , s.getResultSolver, Some (time))
253264
254265 case SatWithModel (model) if checkModels && vc.kind.isInstanceOf [VCKind .AdtInvariant ] =>
255- val VCKind .AdtInvariant (invId) = vc.kind
256- val status = checkAdtInvariantModel(vc, invId, model)
266+ val VCKind .AdtInvariant (invId, expr ) = vc.kind
267+ val status = checkAdtInvariantModel(vc, invId, expr. asInstanceOf [ Expr ], model)
257268 VCResult (status, s.getResultSolver, Some (time))
258269
259270 case SatWithModel (model) if ! vc.satisfiability =>
0 commit comments