Skip to content

Commit 79b5d4d

Browse files
committed
Extend Unknown type, abort on unsafe unknown ensures
1 parent 33d2642 commit 79b5d4d

File tree

2 files changed

+17
-45
lines changed

2 files changed

+17
-45
lines changed

booster/library/Booster/Pattern/Rewrite.hs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ applyRule pat@Pattern{ceilConditions} rule =
307307
MatchSuccess matchingSubstitution -> do
308308
-- existential variables may be present in rule.rhs and rule.ensures,
309309
-- need to strip prefixes and freshen their names with respect to variables already
310-
-- present in the input pattern and in the unification substitution
310+
-- present in the input pattern and in the matching substitution
311311
varsFromInput <- lift . RewriteT $ asks (.varsToAvoid)
312312
let varsFromPattern = freeVariables pat.term <> (Set.unions $ Set.map (freeVariables . coerce) pat.constraints)
313313
varsFromSubst = Set.unions . map freeVariables . Map.elems $ matchingSubstitution
@@ -499,8 +499,10 @@ applyRule pat@Pattern{ceilConditions} rule =
499499
-- check unclear requires-clauses in the context of known constraints (priorKnowledge)
500500
solver <- lift $ RewriteT $ (.smtSolver) <$> ask
501501
SMT.checkPredicates solver pat.constraints pat.substitution (Set.fromList stillUnclear) >>= \case
502-
SMT.IsUnknown{} ->
503-
smtUnclear stillUnclear -- abort rewrite if a solver result was Unknown
502+
SMT.IsUnknown reason -> do
503+
-- abort rewrite if a solver result was Unknown
504+
withContext CtxAbort $ logMessage reason
505+
smtUnclear stillUnclear
504506
SMT.IsInvalid -> do
505507
-- requires is actually false given the prior
506508
withContext CtxFailure $ logMessage ("Required clauses evaluated to #Bottom." :: Text)
@@ -528,6 +530,11 @@ applyRule pat@Pattern{ceilConditions} rule =
528530
-- TODO it is probably enough to establish satisfiablity (rather than validity) of the ensured conditions.
529531
-- For now, we check validity to be safe and admit indeterminate result (i.e. (P, not P) is (Sat, Sat)).
530532
(lift $ SMT.checkPredicates solver pat.constraints pat.substitution (Set.fromList newConstraints)) >>= \case
533+
SMT.IsUnknown SMT.ImplicationIndeterminate -> do
534+
pure ()
535+
SMT.IsUnknown SMT.InconsistentGroundTruth -> do
536+
withContext CtxWarn $ logMessage ("Ground truth is #Bottom." :: Text)
537+
RewriteRuleAppT $ pure Trivial
531538
SMT.IsInvalid -> do
532539
withContext CtxSuccess $ logMessage ("New constraints evaluated to #Bottom." :: Text)
533540
RewriteRuleAppT $ pure Trivial

booster/test/rpc-integration/test-substitutions/response-symbolic-bottom-predicate.json

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"args": [
6868
{
6969
"tag": "EVar",
70-
"name": "Y",
70+
"name": "X",
7171
"sort": {
7272
"tag": "SortApp",
7373
"name": "SortInt",
@@ -111,41 +111,6 @@
111111
]
112112
}
113113
},
114-
"substitution": {
115-
"format": "KORE",
116-
"version": 1,
117-
"term": {
118-
"tag": "Equals",
119-
"argSort": {
120-
"tag": "SortApp",
121-
"name": "SortInt",
122-
"args": []
123-
},
124-
"sort": {
125-
"tag": "SortApp",
126-
"name": "SortGeneratedTopCell",
127-
"args": []
128-
},
129-
"first": {
130-
"tag": "EVar",
131-
"name": "X",
132-
"sort": {
133-
"tag": "SortApp",
134-
"name": "SortInt",
135-
"args": []
136-
}
137-
},
138-
"second": {
139-
"tag": "EVar",
140-
"name": "Y",
141-
"sort": {
142-
"tag": "SortApp",
143-
"name": "SortInt",
144-
"args": []
145-
}
146-
}
147-
}
148-
},
149114
"predicate": {
150115
"format": "KORE",
151116
"version": 1,
@@ -190,22 +155,22 @@
190155
"sorts": [],
191156
"args": [
192157
{
193-
"tag": "EVar",
194-
"name": "X",
158+
"tag": "DV",
195159
"sort": {
196160
"tag": "SortApp",
197161
"name": "SortInt",
198162
"args": []
199-
}
163+
},
164+
"value": "1"
200165
},
201166
{
202-
"tag": "DV",
167+
"tag": "EVar",
168+
"name": "X",
203169
"sort": {
204170
"tag": "SortApp",
205171
"name": "SortInt",
206172
"args": []
207-
},
208-
"value": "1"
173+
}
209174
}
210175
]
211176
}

0 commit comments

Comments
 (0)