Constraints in Krule can all be separate objects, despite having the same resolution patterns. The differences come about because of variable names. For instance, the following two constraints have the same resolution pattern:
($x <rdf:type> $y)
($a <rdf:type> $b)
The variable names cannot be changed, as the distinct names may be needed within each rule. However, the resolutions to these constraints are identical.
Krule needs to:
a. Identify constraints that use the same pattern (see how rlog does this).
b. Map each constraint to a (shared) resolution that matches it.
c. Allow resolutions to be marked as stale by triggering events (see ticket 108).
d. When a constraint needs to use it's resolution in the resolution of the entire rule, then don't let the query engine get the resolution. Instead, provide the common resolution after mapping its variable names to the required names. This may need some internal operations in the query engine.