-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
55 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{-# LANGUAGE FlexibleContexts #-} | ||
|
||
{- | | ||
Copyright : (c) Runtime Verification, 2023 | ||
License : BSD-3-Clause | ||
-} | ||
module Booster.Pattern.Implication ( | ||
checkImplication, | ||
ImplicationCheckResult (..), | ||
) where | ||
|
||
import Booster.Definition.Base (KoreDefinition) | ||
import Booster.Pattern.Base (Pattern (..), Predicate) | ||
import Booster.Pattern.Unify qualified as Unify | ||
|
||
data ImplicationCheckResult | ||
= ImplicationValid Unify.Substitution | ||
| ImplicationUnknown (Maybe Unify.FailReason) [Predicate] | ||
| ImplicationSortError Unify.SortError | ||
|
||
-- | Attempt to check the implication between two patterns using matching and simplification rules | ||
checkImplication :: KoreDefinition -> Pattern -> Pattern -> ImplicationCheckResult | ||
checkImplication def antecedent consequent = | ||
case Unify.unifyTerms def consequent.term antecedent.term of | ||
Unify.UnificationSuccess subst -> | ||
-- got substitution, let's now look at constraints | ||
case (antecedent.constraints, consequent.constraints) of | ||
([], []) -> ImplicationValid subst | ||
(_, _) -> ImplicationUnknown Nothing (antecedent.constraints <> consequent.constraints) | ||
Unify.UnificationFailed reason -> ImplicationUnknown (Just reason) [] | ||
Unify.UnificationSortError sortError -> ImplicationSortError sortError | ||
Unify.UnificationRemainder pairs -> error (show pairs) |