@@ -359,37 +359,32 @@ ruleOfTerms l r = mkRewriteRule [] l r False Nothing
359
359
-- | Converts a parameterized equality predicate to a RewriteRule,
360
360
-- returning 'Nothing' if the predicate is not an equation.
361
361
ruleOfProp :: SharedContext -> Term -> Maybe a -> IO (Maybe (RewriteRule a ))
362
- ruleOfProp sc term ann
363
- | Just (_, ty, body) <- R. asPi term =
364
- do rule <- ruleOfProp sc body ann
365
- pure $ (\ r -> r { ctxt = ty : ctxt r }) <$> rule
366
- | Just (_, ty, body) <- R. asLambda term =
367
- do rule <- ruleOfProp sc body ann
368
- pure $ (\ r -> r { ctxt = ty : ctxt r }) <$> rule
369
- | (R. isGlobalDef ecEqIdent -> Just () , [_, _, x, y]) <- R. asApplyAll term =
370
- pure $ Just $ mkRewriteRule [] x y False ann
371
- | (R. isGlobalDef bvEqIdent -> Just () , [_, x, y]) <- R. asApplyAll term =
372
- pure $ Just $ mkRewriteRule [] x y False ann
373
- | (R. isGlobalDef equalNatIdent -> Just () , [x, y]) <- R. asApplyAll term =
374
- pure $ Just $ mkRewriteRule [] x y False ann
375
- | (R. isGlobalDef boolEqIdent -> Just () , [x, y]) <- R. asApplyAll term =
376
- pure $ Just $ mkRewriteRule [] x y False ann
377
- | (R. isGlobalDef vecEqIdent -> Just () , [_, _, _, x, y]) <- R. asApplyAll term =
378
- pure $ Just $ mkRewriteRule [] x y False ann
379
- | (R. isGlobalDef arrayEqIdent -> Just () , [_, _, x, y]) <- R. asApplyAll term =
380
- pure $ Just $ mkRewriteRule [] x y False ann
381
- | (R. isGlobalDef intEqIdent -> Just () , [x, y]) <- R. asApplyAll term =
382
- pure $ Just $ mkRewriteRule [] x y False ann
383
- | (R. isGlobalDef intModEqIdent -> Just () , [_, x, y]) <- R. asApplyAll term =
384
- pure $ Just $ mkRewriteRule [] x y False ann
385
- | Constant _ (Just body) <- unwrapTermF term = ruleOfProp sc body ann
386
- | Just (_, x, y) <- R. asEq term =
387
- pure $ Just $ mkRewriteRule [] x y False ann
388
- | Just body <- R. asEqTrue term = ruleOfProp sc body ann
389
- | (R. asConstant -> Just (_, Just body), as) <- R. asApplyAll term =
390
- do app <- scApplyAllBeta sc body as
391
- ruleOfProp sc app ann
392
- | otherwise = pure Nothing
362
+ ruleOfProp sc term ann =
363
+ case term of
364
+ (R. asPi -> Just (_, ty, body)) ->
365
+ do rule <- ruleOfProp sc body ann
366
+ pure $ (\ r -> r { ctxt = ty : ctxt r }) <$> rule
367
+ (R. asLambda -> Just (_, ty, body)) ->
368
+ do rule <- ruleOfProp sc body ann
369
+ pure $ (\ r -> r { ctxt = ty : ctxt r }) <$> rule
370
+ (R. asApplyAll -> (R. isGlobalDef ecEqIdent -> Just () , [_, _, x, y])) -> eqRule x y
371
+ (R. asApplyAll -> (R. isGlobalDef bvEqIdent -> Just () , [_, x, y])) -> eqRule x y
372
+ (R. asApplyAll -> (R. isGlobalDef equalNatIdent -> Just () , [x, y])) -> eqRule x y
373
+ (R. asApplyAll -> (R. isGlobalDef boolEqIdent -> Just () , [x, y])) -> eqRule x y
374
+ (R. asApplyAll -> (R. isGlobalDef vecEqIdent -> Just () , [_, _, _, x, y])) -> eqRule x y
375
+ (R. asApplyAll -> (R. isGlobalDef arrayEqIdent -> Just () , [_, _, x, y])) -> eqRule x y
376
+ (R. asApplyAll -> (R. isGlobalDef intEqIdent -> Just () , [x, y])) -> eqRule x y
377
+ (R. asApplyAll -> (R. isGlobalDef intModEqIdent -> Just () , [_, x, y])) -> eqRule x y
378
+ (unwrapTermF -> Constant _ (Just body)) -> ruleOfProp sc body ann
379
+ (R. asEq -> Just (_, x, y)) -> eqRule x y
380
+ (R. asEqTrue -> Just body) -> ruleOfProp sc body ann
381
+ (R. asApplyAll -> (R. asConstant -> Just (_, Just body), args)) ->
382
+ do app <- scApplyAllBeta sc body args
383
+ ruleOfProp sc app ann
384
+ _ -> pure Nothing
385
+
386
+ where
387
+ eqRule x y = pure $ Just $ mkRewriteRule [] x y False ann
393
388
394
389
-- | Generate a rewrite rule from the type of an identifier, using 'ruleOfTerm'
395
390
scEqRewriteRule :: SharedContext -> Ident -> IO (RewriteRule a )
0 commit comments