Download Flora-2: User`s Manual
Transcript
19 INSERTION AND DELETION OF RULES
19.3
86
Deletion of Rules
Rules inserted dynamically using insertrule a can be deleted using the primitive deleterule a,
and rules inserted using insertrule z can be deleted using the primitive deleterule z. If the user
wishes to delete a rule that was previously inserted using either insertrule a or insertrule z
then the primitive deleterule can be used. Similarly to rule insertion, several rules can be deleted
in the same command:
delruleop {rulelist }
where delruleop is either deleterule a or deleterule z and rulelist is a comma-separated list of
rules. Rules in the list mast be enclosed in parentheses and should not terminate with a period.
To delete the rules inserted in the second example of Section 19.2, we can use
flora2 ?- deleterule_a{(?X:student :- %enroll(?X,?_T)),
(?X:student :- %enroll(?X,?_T))@mod1}.
or
flora2 ?- deleterule{(?X:student :- %enroll(?X,?_T)),
(?X:student :- %enroll(?X,?_T))@mod1}.
Flora-2 provides a flexible way to express rules to be deleted by allowing variable rule head,
variable rule body, and variable module specification. For example, rule deletions below are all
valid:
flora2 ?- deleterule{(?H:-q(?X))@foo}.
flora2 ?- deleterule{(p(?X):-q(?X))@?M}.
flora2 ?- deleterule{?H:-?B}.
The last query attempts delete every dynamically inserted rule. So, it should be used with great
caution.
We should note that a rule with a composite head, such as
o[b->?V1,c->?V2] :- something(?V1,?V2).
is treated as a pair of separate rules
o[b->?V1] :- something(?V1,?V2).
o[c->?V2] :- something(?V1,?V2).
Therefore