@@ -144,13 +144,9 @@ trait VerificationChecker { self =>
144
144
* - rewrite the invariant's invocation to be applied to this new variable instead.
145
145
* - evaluate the resulting condition under the new model.
146
146
*/
147
- protected def checkAdtInvariantModel (vc : VC , invId : Identifier , model : Model ): VCStatus = {
147
+ protected def checkAdtInvariantModel (vc : VC , invId : Identifier , expr : Expr , model : Model ): VCStatus = {
148
148
import inox .evaluators .EvaluationResults ._
149
149
150
- val Seq ((inv, adt, path)) = collectWithPC(vc.condition) {
151
- case (inv @ FunctionInvocation (`invId`, _, Seq (adt : ADT )), path) => (inv, adt, path)
152
- }
153
-
154
150
def success : VCStatus = {
155
151
reporter.debug(" - Model validated." )
156
152
VCStatus .Invalid (VCStatus .CounterExample (model))
@@ -161,6 +157,21 @@ trait VerificationChecker { self =>
161
157
VCStatus .Unknown
162
158
}
163
159
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
+
164
175
evaluator.eval(path.toClause, model) match {
165
176
case Successful (BooleanLiteral (true )) => // path condition was true, we must evaluate invariant
166
177
case Successful (BooleanLiteral (false )) => return success
@@ -184,7 +195,7 @@ trait VerificationChecker { self =>
184
195
val adtVar = Variable (FreshIdentifier (" adt" ), adt.getType(symbols), Seq ())
185
196
val newInv = FunctionInvocation (invId, inv.tps, Seq (adtVar))
186
197
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 )
188
199
189
200
evaluator.eval(newCondition, newModel) match {
190
201
case Successful (BooleanLiteral (false )) => success
@@ -252,8 +263,8 @@ trait VerificationChecker { self =>
252
263
VCResult (VCStatus .Valid , s.getResultSolver, Some (time))
253
264
254
265
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)
257
268
VCResult (status, s.getResultSolver, Some (time))
258
269
259
270
case SatWithModel (model) if ! vc.satisfiability =>
0 commit comments