Skip to content

Commit

Permalink
Add RewriteRule "ExistentialSimplifications"
Browse files Browse the repository at this point in the history
  • Loading branch information
geo2a committed Jun 14, 2024
1 parent a96eba0 commit 2a3cbad
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions booster/library/Booster/Definition/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ data KoreDefinition = KoreDefinition
, rewriteTheory :: Theory (RewriteRule "Rewrite")
, functionEquations :: Theory (RewriteRule "Function")
, simplifications :: Theory (RewriteRule "Simplification")
, existentialSimplifications :: Theory (RewriteRule "ExistentialSimplification")
, ceils :: Theory (RewriteRule "Ceil")
}
deriving stock (Eq, Show, GHC.Generic)
Expand All @@ -67,6 +68,7 @@ emptyKoreDefinition attributes =
, rewriteTheory = Map.empty
, functionEquations = Map.empty
, simplifications = Map.empty
, existentialSimplifications = Map.empty
, ceils = Map.empty
}

Expand Down
17 changes: 17 additions & 0 deletions booster/library/Booster/Syntax/ParsedKore/Internalise.hs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ mergeDefs k1 k2
<*> pure (mergeTheories rewriteTheory k1 k2)
<*> pure (mergeTheories functionEquations k1 k2)
<*> pure (mergeTheories simplifications k1 k2)
<*> pure (mergeTheories existentialSimplifications k1 k2)
<*> pure (mergeTheories ceils k1 k2)
where
mergeTheories ::
Expand Down Expand Up @@ -235,6 +236,7 @@ addModule
, rewriteTheory = currentRewriteTheory
, functionEquations = currentFctEqs
, simplifications = currentSimpls
, existentialSimplifications = currentExistentialSimplifications
, ceils = currentCeils
}
)
Expand Down Expand Up @@ -296,6 +298,7 @@ addModule
, rewriteTheory = currentRewriteTheory -- no rules yet
, functionEquations = Map.empty
, simplifications = Map.empty
, existentialSimplifications = Map.empty
, ceils = Map.empty
}

Expand Down Expand Up @@ -352,6 +355,7 @@ addModule
subsortPairs = mapMaybe retractSubsortRule newAxioms
newFunctionEquations = mapMaybe retractFunctionRule newAxioms
newSimplifications = mapMaybe retractSimplificationRule newAxioms
newExistentialSimplifications = mapMaybe retractExistentialSimplificationRule newAxioms
newCeils = mapMaybe retractCeilRule newAxioms
let rewriteIndex =
if null defAttributes.indexCells
Expand All @@ -363,6 +367,11 @@ addModule
addToTheoryWith (Idx.termTopIndex . (.lhs)) newFunctionEquations currentFctEqs
simplifications =
addToTheoryWith (Idx.termTopIndex . (.lhs)) newSimplifications currentSimpls
existentialSimplifications =
addToTheoryWith
(Idx.termTopIndex . (.lhs))
newExistentialSimplifications
currentExistentialSimplifications
ceils =
addToTheoryWith (Idx.termTopIndex . (.lhs)) newCeils currentCeils
sorts =
Expand All @@ -374,6 +383,7 @@ addModule
, rewriteTheory
, functionEquations
, simplifications
, existentialSimplifications
, ceils
}
where
Expand Down Expand Up @@ -534,6 +544,8 @@ data AxiomResult
FunctionAxiom (RewriteRule "Function")
| -- | Simplification
SimplificationAxiom (RewriteRule "Simplification")
| -- | Existential simplification
ExistentialSimplificationAxiom (RewriteRule "ExistentialSimplification")
| -- | Ceil rule
CeilAxiom (RewriteRule "Ceil")

Expand All @@ -554,6 +566,11 @@ retractSimplificationRule :: AxiomResult -> Maybe (RewriteRule "Simplification")
retractSimplificationRule (SimplificationAxiom r) = Just r
retractSimplificationRule _ = Nothing

retractExistentialSimplificationRule ::
AxiomResult -> Maybe (RewriteRule "ExistentialSimplification")
retractExistentialSimplificationRule (ExistentialSimplificationAxiom r) = Just r
retractExistentialSimplificationRule _ = Nothing

retractCeilRule :: AxiomResult -> Maybe (RewriteRule "Ceil")
retractCeilRule (CeilAxiom r) = Just r
retractCeilRule _ = Nothing
Expand Down
1 change: 1 addition & 0 deletions booster/unit-tests/Test/Booster/Fixture.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ testDefinition =
, rewriteTheory = Map.empty
, functionEquations = Map.empty
, simplifications = Map.empty
, existentialSimplifications = Map.empty
, ceils = Map.empty
}
where
Expand Down

0 comments on commit 2a3cbad

Please sign in to comment.