File tree 1 file changed +9
-3
lines changed
booster/library/Booster/Pattern
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ module Booster.Pattern.Match (
10
10
FailReason (.. ),
11
11
Substitution ,
12
12
matchTerms ,
13
+ matchTermsWithSubst ,
13
14
checkSubsort ,
14
15
SortError (.. ),
15
16
) where
@@ -121,6 +122,10 @@ instance FromModifiersT mods => Pretty (PrettyWithModifiers mods FailReason) whe
121
122
122
123
type Substitution = Map Variable Term
123
124
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
+
124
129
{- | Attempts to find a simple unifying substitution for the given
125
130
terms.
126
131
@@ -131,8 +136,9 @@ type Substitution = Map Variable Term
131
136
to ensure that we always produce a matching substitution without having to check
132
137
after running the matcher
133
138
-}
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 =
136
142
let runMatch :: MatchState -> MatchResult
137
143
runMatch =
138
144
fromEither
@@ -153,7 +159,7 @@ matchTerms matchType KoreDefinition{sorts} term1 term2 =
153
159
else
154
160
runMatch
155
161
State
156
- { mSubstitution = Map. empty
162
+ { mSubstitution = knownSubst
157
163
, mQueue = Seq. singleton (term1, term2) -- PriorityQueue.singleton (term1, term2) RegularTerm ()
158
164
, mMapQueue = mempty
159
165
, mIndeterminate = []
You can’t perform that action at this time.
0 commit comments