Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c460c79

Browse files
committedAug 20, 2024
Add matchTermsWithSubst
1 parent c6e80d0 commit c460c79

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed
 

‎booster/library/Booster/Pattern/Match.hs

+9-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module Booster.Pattern.Match (
1010
FailReason (..),
1111
Substitution,
1212
matchTerms,
13+
matchTermsWithSubst,
1314
checkSubsort,
1415
SortError (..),
1516
) where
@@ -121,6 +122,10 @@ instance FromModifiersT mods => Pretty (PrettyWithModifiers mods FailReason) whe
121122

122123
type Substitution = Map Variable Term
123124

125+
-- | Specialisation of @matchTermsWithSubst@ to an empty initial substitution
126+
matchTerms :: MatchType -> KoreDefinition -> Term -> Term -> MatchResult
127+
matchTerms matchType def = matchTermsWithSubst matchType def mempty
128+
124129
{- | Attempts to find a simple unifying substitution for the given
125130
terms.
126131
@@ -131,8 +136,9 @@ type Substitution = Map Variable Term
131136
to ensure that we always produce a matching substitution without having to check
132137
after running the matcher
133138
-}
134-
matchTerms :: MatchType -> KoreDefinition -> Term -> Term -> MatchResult
135-
matchTerms matchType KoreDefinition{sorts} term1 term2 =
139+
matchTermsWithSubst ::
140+
MatchType -> KoreDefinition -> Substitution -> Term -> Term -> MatchResult
141+
matchTermsWithSubst matchType KoreDefinition{sorts} knownSubst term1 term2 =
136142
let runMatch :: MatchState -> MatchResult
137143
runMatch =
138144
fromEither
@@ -153,7 +159,7 @@ matchTerms matchType KoreDefinition{sorts} term1 term2 =
153159
else
154160
runMatch
155161
State
156-
{ mSubstitution = Map.empty
162+
{ mSubstitution = knownSubst
157163
, mQueue = Seq.singleton (term1, term2) -- PriorityQueue.singleton (term1, term2) RegularTerm ()
158164
, mMapQueue = mempty
159165
, mIndeterminate = []

0 commit comments

Comments
 (0)
Please sign in to comment.