11package viper .silicon .state
22
33import viper .silicon .rules .functionSupporter
4- import viper .silicon .state .terms .{And , App , HeapDepFun , Implies , Ite , Let , Literal , Not , Or , Quantification , Term , True }
4+ import viper .silicon .state .terms .{And , App , Forall , HeapDepFun , Implies , Ite , Let , Literal , Not , Or , Quantification , Term , True }
55import viper .silver .ast
66
77
@@ -28,13 +28,17 @@ object FunctionPreconditionTransformer {
2828 case Or (ts) => And (transform(ts.head, p), Implies (Not (ts.head), transform(Or (ts.tail), p)))
2929 case Implies (t0, t1) => And (transform(t0, p), Implies (t0, transform(t1, p)))
3030 case Ite (t, t1, t2) => And (transform(t, p), Ite (t, transform(t1, p), transform(t2, p)))
31- case Let (bindings, body) => Let (bindings, transform(body, p))
32- case Quantification (q, vars, body, triggers, name, isGlobal) =>
31+ case Let (bindings, body) =>
32+ And (And (bindings.map(b => transform(b._2, p))), Let (bindings, transform(body, p)))
33+ case Quantification (_, vars, body, triggers, name, isGlobal) =>
3334 val tBody = transform(body, p)
34- if (tBody == True ())
35+ if (tBody == True ()) {
3536 tBody
36- else
37- Quantification (q, vars, tBody, triggers, name, isGlobal)
37+ } else {
38+ // We assume well-definedness for *all* possible values even for existential quantifiers
39+ // (since that is also what we check).
40+ Quantification (Forall , vars, tBody, triggers, name, isGlobal)
41+ }
3842 case App (hdf@ HeapDepFun (_, _, _), args) =>
3943 And (args.map(transform(_, p)) :+ App (functionSupporter.preconditionVersion(hdf), args))
4044 case other => And (other.subterms.map(transform(_, p)))
0 commit comments