@@ -48,20 +48,14 @@ import Booster.Log
48
48
import Booster.Pattern.ApplyEquations qualified as ApplyEquations
49
49
import Booster.Pattern.Base (Pattern (.. ), Sort (SortApp ), Term , Variable )
50
50
import Booster.Pattern.Base qualified as Pattern
51
- import Booster.Pattern.Bool (pattern TrueBool )
52
- import Booster.Pattern.Match (FailReason (.. ), MatchResult (.. ), MatchType (.. ), matchTerms )
53
51
import Booster.Pattern.Rewrite (
54
52
RewriteFailed (.. ),
55
53
RewriteResult (.. ),
56
54
RewriteTrace (.. ),
57
55
performRewrite ,
58
56
)
59
- import Booster.Pattern.Util (
60
- sortOfPattern ,
61
- substituteInPredicate ,
62
- substituteInTerm ,
63
- )
64
- import Booster.Prettyprinter (renderDefault , renderText )
57
+ import Booster.Pattern.Util (sortOfPattern , substituteInPredicate , substituteInTerm )
58
+ import Booster.Prettyprinter (renderText )
65
59
import Booster.SMT.Base qualified as SMT
66
60
import Booster.SMT.Interface qualified as SMT
67
61
import Booster.Syntax.Json (KoreJson (.. ), addHeader , prettyPattern , sortOfJson )
@@ -79,11 +73,7 @@ import Booster.Syntax.Json.Internalise (
79
73
import Booster.Syntax.ParsedKore (parseKoreModule )
80
74
import Booster.Syntax.ParsedKore.Base hiding (ParsedModule )
81
75
import Booster.Syntax.ParsedKore.Base qualified as ParsedModule (ParsedModule (.. ))
82
- import Booster.Syntax.ParsedKore.Internalise (
83
- addToDefinitions ,
84
- definitionErrorToRpcError ,
85
- extractExistentials ,
86
- )
76
+ import Booster.Syntax.ParsedKore.Internalise (addToDefinitions , definitionErrorToRpcError )
87
77
import Booster.Util (Flag (.. ), constructorName )
88
78
import Kore.JsonRpc.Error qualified as RpcError
89
79
import Kore.JsonRpc.Server (ErrorObj (.. ), JsonRpcHandler (.. ), Respond )
@@ -465,87 +455,11 @@ respond stateVar =
465
455
{ satisfiable = RpcTypes. Sat
466
456
, substitution
467
457
}
468
- RpcTypes. Implies req -> withModule req. _module $ \ (def, mLlvmLibrary, mSMTOptions) -> Booster.Log. withContext " implies" $ do
469
- -- internalise given constrained term
470
- let internalised =
471
- runExcept . internalisePattern DisallowAlias CheckSubsorts Nothing def . fst . extractExistentials
472
-
473
- case (internalised req. antecedent. term, internalised req. consequent. term) of
474
- (Left patternError, _) -> do
475
- Log. logDebug $ " Error internalising antecedent" <> Text. pack (show patternError)
476
- pure $
477
- Left $
478
- RpcError. backendError $
479
- RpcError. CouldNotVerifyPattern
480
- [ patternErrorToRpcError patternError
481
- ]
482
- (_, Left patternError) -> do
483
- Log. logDebug $ " Error internalising consequent" <> Text. pack (show patternError)
484
- pure $
485
- Left $
486
- RpcError. backendError $
487
- RpcError. CouldNotVerifyPattern
488
- [ patternErrorToRpcError patternError
489
- ]
490
- (Right (patL, substitutionL, unsupportedL), Right (patR, substitutionR, unsupportedR)) -> do
491
- unless (null unsupportedL && null unsupportedR) $ do
492
- Log. logWarnNS
493
- " booster"
494
- " Implies: aborting due to unsupported predicate parts"
495
- unless (null unsupportedL) $
496
- Log. logOtherNS
497
- " booster"
498
- (Log. LevelOther " ErrorDetails" )
499
- (Text. unlines $ map prettyPattern unsupportedL)
500
- unless (null unsupportedR) $
501
- Log. logOtherNS
502
- " booster"
503
- (Log. LevelOther " ErrorDetails" )
504
- (Text. unlines $ map prettyPattern unsupportedR)
505
- let
506
- -- apply the given substitution before doing anything else
507
- substPatL =
508
- Pattern
509
- { term = substituteInTerm substitutionL patL. term
510
- , constraints = Set. map (substituteInPredicate substitutionL) patL. constraints
511
- , ceilConditions = patL. ceilConditions
512
- }
513
- substPatR =
514
- Pattern
515
- { term = substituteInTerm substitutionR patR. term
516
- , constraints = Set. map (substituteInPredicate substitutionR) patR. constraints
517
- , ceilConditions = patR. ceilConditions
518
- }
519
-
520
- case matchTerms Booster.Pattern.Match. Implies def substPatR. term substPatL. term of
521
- MatchFailed (SubsortingError sortError) ->
522
- pure . Left . RpcError. backendError . RpcError. ImplicationCheckError . RpcError. ErrorOnly . pack $
523
- show sortError
524
- MatchFailed {} ->
525
- doesNotImply (sortOfPattern substPatL) req. antecedent. term req. consequent. term
526
- MatchIndeterminate remainder ->
527
- pure . Left . RpcError. backendError . RpcError. ImplicationCheckError . RpcError. ErrorOnly . pack $
528
- " match remainder: "
529
- <> renderDefault (pretty remainder)
530
- MatchSuccess subst -> do
531
- let filteredConsequentPreds =
532
- Set. map (substituteInPredicate subst) substPatR. constraints `Set.difference` substPatL. constraints
533
- doTracing = Flag False
534
- solver <- traverse (SMT. initSolver def) mSMTOptions
535
-
536
- if null filteredConsequentPreds
537
- then implies (sortOfPattern substPatL) req. antecedent. term req. consequent. term subst
538
- else
539
- ApplyEquations. evaluateConstraints doTracing def mLlvmLibrary solver mempty filteredConsequentPreds >>= \ case
540
- (Right newPreds, _) ->
541
- if all (== Pattern. Predicate TrueBool ) newPreds
542
- then implies (sortOfPattern substPatL) req. antecedent. term req. consequent. term subst
543
- else pure . Left . RpcError. backendError $ RpcError. Aborted " unknown constrains"
544
- (Left other, _) ->
545
- pure . Left . RpcError. backendError $ RpcError. Aborted (Text. pack . constructorName $ other)
546
458
547
459
-- this case is only reachable if the cancel appeared as part of a batch request
548
460
RpcTypes. Cancel -> pure $ Left RpcError. cancelUnsupportedInBatchMode
461
+ -- using "Method does not exist" error code
462
+ _ -> pure $ Left RpcError. notImplemented
549
463
where
550
464
withModule ::
551
465
Maybe Text ->
@@ -560,39 +474,6 @@ respond stateVar =
560
474
Nothing -> pure $ Left $ RpcError. backendError $ RpcError. CouldNotFindModule mainName
561
475
Just d -> action (d, state. mLlvmLibrary, state. mSMTOptions)
562
476
563
- doesNotImply s l r =
564
- pure $
565
- Right $
566
- RpcTypes. Implies
567
- RpcTypes. ImpliesResult
568
- { implication = addHeader $ Syntax. KJImplies (externaliseSort s) l r
569
- , valid = False
570
- , condition = Nothing
571
- , logs = Nothing
572
- }
573
-
574
- implies s' l r subst =
575
- let s = externaliseSort s'
576
- in pure $
577
- Right $
578
- RpcTypes. Implies
579
- RpcTypes. ImpliesResult
580
- { implication = addHeader $ Syntax. KJImplies s l r
581
- , valid = True
582
- , condition =
583
- Just
584
- RpcTypes. Condition
585
- { predicate = addHeader $ Syntax. KJTop s
586
- , substitution =
587
- addHeader
588
- $ (\ xs -> if null xs then Syntax. KJTop s else Syntax. KJAnd s xs)
589
- . map (uncurry $ externaliseSubstitution s)
590
- . Map. toList
591
- $ subst
592
- }
593
- , logs = Nothing
594
- }
595
-
596
477
handleSmtError :: JsonRpcHandler
597
478
handleSmtError = JsonRpcHandler $ \ case
598
479
SMT. GeneralSMTError err -> runtimeError " problem" err
@@ -883,7 +764,7 @@ mkLogRewriteTrace
883
764
| logSuccessfulRewrites ->
884
765
Just $
885
766
singleton $
886
- Kore.JsonRpc.Types.Log. Rewrite
767
+ Rewrite
887
768
{ result =
888
769
Success
889
770
{ rewrittenTerm = Nothing
@@ -897,7 +778,7 @@ mkLogRewriteTrace
897
778
| logFailedRewrites ->
898
779
Just $
899
780
singleton $
900
- Kore.JsonRpc.Types.Log. Rewrite
781
+ Rewrite
901
782
{ result = case reason of
902
783
NoApplicableRules {} -> Failure {reason = " No applicable rules found" , _ruleId = Nothing }
903
784
TermIndexIsNone {} -> Failure {reason = " Term index is None for term" , _ruleId = Nothing }
0 commit comments