-
Notifications
You must be signed in to change notification settings - Fork 44
SMT.Translate.translatePattern: add fallback for translateApplication #2261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fb8c53c
39ef365
d957204
fab5a42
3dec78a
12d78b1
45f2078
a29c504
3eb2c74
b5aaf5f
affccf1
db68774
a75436b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,9 +210,7 @@ translatePredicateWith translateTerm predicate = | |
return $ SMT.int $ Builtin.Int.extractIntDomainValue | ||
"while translating dv to SMT.int" dv | ||
ApplySymbolF app -> | ||
(<|>) | ||
(translateApplication app) | ||
(translateUninterpreted SMT.tInt pat) | ||
translateApplication (Just SMT.tInt) pat app | ||
DefinedF (Defined child) -> translateInt child | ||
_ -> empty | ||
|
||
|
@@ -230,29 +228,39 @@ translatePredicateWith translateTerm predicate = | |
-- will fail to translate. | ||
SMT.not <$> translateBool notChild | ||
ApplySymbolF app -> | ||
(<|>) | ||
(translateApplication app) | ||
(translateUninterpreted SMT.tBool pat) | ||
translateApplication (Just SMT.tBool) pat app | ||
DefinedF (Defined child) -> translateBool child | ||
_ -> empty | ||
|
||
translateApplication :: Application Symbol p -> Translator m variable SExpr | ||
translateApplication :: Maybe SExpr -> p -> Application Symbol p -> Translator m variable SExpr | ||
translateApplication | ||
maybeSort | ||
original | ||
Application | ||
{ applicationSymbolOrAlias | ||
, applicationChildren | ||
} | ||
= do | ||
let translated = translateSymbol applicationSymbolOrAlias | ||
sexpr <- maybe empty return translated | ||
when (isNothing translated) | ||
$ warnSymbolSMTRepresentation applicationSymbolOrAlias | ||
children <- zipWithM translatePattern | ||
applicationChildrenSorts | ||
applicationChildren | ||
return $ shortenSExpr (applySExpr sexpr children) | ||
| isFunctionalPattern original = | ||
translateInterpretedApplication | ||
<|> translateUninterpreted' | ||
| otherwise = | ||
translateInterpretedApplication | ||
Comment on lines
+243
to
+247
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before, we would fall back to |
||
where | ||
translateInterpretedApplication = do | ||
let translated = translateSymbol applicationSymbolOrAlias | ||
sexpr <- maybe warnAndDiscard return translated | ||
children <- zipWithM translatePattern | ||
applicationChildrenSorts | ||
applicationChildren | ||
return $ shortenSExpr (applySExpr sexpr children) | ||
applicationChildrenSorts = termLikeSort <$> applicationChildren | ||
warnAndDiscard = | ||
warnSymbolSMTRepresentation applicationSymbolOrAlias | ||
>> empty | ||
translateUninterpreted' = do | ||
sort <- hoistMaybe maybeSort | ||
translateUninterpreted sort original | ||
|
||
|
||
translatePredicateExists | ||
:: Exists Sort variable p -> Translator m variable SExpr | ||
|
@@ -300,7 +308,8 @@ translatePredicateWith translateTerm predicate = | |
VariableF _ -> do | ||
smtSort <- hoistMaybe $ translateSort sort | ||
translateUninterpreted smtSort pat | ||
ApplySymbolF app -> translateApplication app | ||
ApplySymbolF app -> | ||
translateApplication (translateSort sort) pat app | ||
DefinedF (Defined child) -> translatePattern sort child | ||
_ -> empty | ||
where | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my understanding, if
translated
isNothing
this gets discarded before logging the warning. My changes should fix this.