Skip to content

Commit

Permalink
Recognize rewrite rules using intEq and intModEq relations.
Browse files Browse the repository at this point in the history
This is a band-aid pending a proper solution for #1261.
  • Loading branch information
Brian Huffman committed May 17, 2021
1 parent 7063225 commit 2a6c24b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion saw-core/src/Verifier/SAW/Rewriter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,12 @@ vecEqIdent = mkIdent (mkModuleName ["Prelude"]) "vecEq"
equalNatIdent :: Ident
equalNatIdent = mkIdent (mkModuleName ["Prelude"]) "equalNat"

intEqIdent :: Ident
intEqIdent = mkIdent (mkModuleName ["Prelude"]) "intEq"

intModEqIdent :: Ident
intModEqIdent = mkIdent (mkModuleName ["Prelude"]) "intModEq"

-- | Converts a universally quantified equality proposition from a
-- Term representation to a RewriteRule.
ruleOfTerm :: Term -> RewriteRule
Expand All @@ -307,7 +313,7 @@ rulePermutes lhs rhs =

mkRewriteRule :: [Term] -> Term -> Term -> RewriteRule
mkRewriteRule c l r =
RewriteRule {ctxt = c, lhs = l, rhs = r , permutative = rulePermutes l r}
RewriteRule {ctxt = c, lhs = l, rhs = r , permutative = rulePermutes l r}

-- | Converts a universally quantified equality proposition between the
-- two given terms to a RewriteRule.
Expand All @@ -333,6 +339,10 @@ ruleOfProp (R.asApplyAll -> (R.isGlobalDef boolEqIdent -> Just (), [x, y])) =
Just $ mkRewriteRule [] x y
ruleOfProp (R.asApplyAll -> (R.isGlobalDef vecEqIdent -> Just (), [_, _, _, x, y])) =
Just $ mkRewriteRule [] x y
ruleOfProp (R.asApplyAll -> (R.isGlobalDef intEqIdent -> Just (), [x, y])) =
Just $ mkRewriteRule [] x y
ruleOfProp (R.asApplyAll -> (R.isGlobalDef intModEqIdent -> Just (), [_, x, y])) =
Just $ mkRewriteRule [] x y
ruleOfProp (unwrapTermF -> Constant _ body) = ruleOfProp body
ruleOfProp (R.asEq -> Just (_, x, y)) =
Just $ mkRewriteRule [] x y
Expand Down

0 comments on commit 2a6c24b

Please sign in to comment.