|
|
|
|
|
Description |
Routines to transform SimpleRules and productions into
Chomsky Normal Form.
SimpleRules such as
f(g(g(X)),X) => c(X) .
are transformed into equivalent FullRules having Term patters of
maximum depth 1 and Variables occurring at most once. For instance, the
Chomsky Normal Form of the above SimpleRule is
| L : f(!2, X!1), !2 : g(!3), !3 : g(X!0), @!Inters : cons(X!0, X!1) => L : c(X!0) .
Similarly, productions such as
@a : f(g(@b)) .
are transformed into
@a : f(%0) .
%0 : g(@b) .
|
|
Synopsis |
|
|
|
|
Basic Operations |
|
data RSt |
State for the normalization of SimpleRules. | Constructors | RSt | | counterR :: !Int | Used to generate fresh variables. | aliases :: !(Map Variable [Variable]) | Stores all the aliases for a variable. |
|
|
|
|
type CNFRSt = State RSt |
|
data GSt |
State for the normalization of productions. | Constructors | GSt | | counterG :: !Int | Used to generate fresh Labels. | cnfProductions :: ![(Label, [Term])] | Productions in CNF |
|
|
|
|
type CNFGSt = State GSt |
|
newId :: CNFRSt Int |
Generate a fresh Int and increment counterR. |
|
newVariable :: CNFRSt Variable |
Generate a fresh for-internal-use-only Variable. |
|
newLabel :: CNFGSt Label |
Generate fresh Label. |
|
writeProduction :: (Label, [Term]) -> CNFGSt () |
Add extra productions to GSt. |
|
newAlias :: Variable -> CNFRSt Variable |
Generte a fresh alias for a Variable, and store the alias in the
aliases map. |
|
Clause Normalization |
|
aliasesIntersections :: CNFRSt [Clause] |
Generate a list of intersection Clauses for each distinct pair of
aliases for a Variable. |
|
flattenClause :: Clause -> CNFRSt [Clause] |
Transform a Clause having an arbitrary Term as pattern into
a list of Clauses where pattern have maximum depth 1. |
|
normalizeClause :: Clause -> CNFRSt [Clause] |
Transform a Clause having an arbitrary Term as pattern into
a Clause list having only patterns with maximum depth 1, and each
Variable occurring at most once in each Clause. |
|
aliasSubst :: CNFRSt Subst |
The Subst associating a Variable with its first alias. |
|
Main Routines |
|
normalizeSimpleRule :: Rule -> Rule |
Transform a SimpleRule into a FullRule. |
|
normalizeSimpleRules :: [Rule] -> [Rule] |
|
flattenProduction :: (Label, [Term]) -> CNFGSt () |
Flatten a production. |
|
normalizeProductions :: [(Label, [Term])] -> [(Label, [Term])] |
Normalize productions. |
|
Produced by Haddock version 0.6 |