01: /*
02: * Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18: package org.mandarax.kernel;
19:
20: /**
21: * Rules are prerequisite / conclusion associations. Note that this class represents
22: * only simple rules having only one fact in the head. Prerequisites can be connected
23: * by AND or OR.<br>
24: * For generalized rules with a disjunction of facts in the head use <code>Clause</code> or <code>ClauseSet</code>.
25: * Note that instances are usually created using a factory.
26: * @see org.mandarax.kernel.LogicFactory
27: * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
28: * @version 3.4 <7 March 05>
29: * @since 1.0
30: */
31: public interface Rule extends Clause {
32:
33: /**
34: * Apply a set of replacements to a rule. Returns a new rule!
35: * @return the rule that is the result of applying the replacements
36: * @param r a collection of replacements
37: */
38: public Rule applyToRule(java.util.Collection r);
39:
40: /**
41: * Apply a single replacement to a rule. Return a new rule!
42: * @return the rule that is the result of applying the replacement
43: * @param r a replacement
44: */
45: public Rule applyToRule(Replacement r);
46:
47: /**
48: * Get the body of the rule.
49: * @return the body (a list of facts)
50: */
51: public java.util.List getBody();
52:
53: /**
54: * Get the head fact.
55: * @return the head (conclusion) of the rule
56: */
57: public Fact getHead();
58:
59: /**
60: * Indicates whether the premisses in the body are connected by OR.
61: * @return a boolean
62: */
63: boolean isBodyOrConnected();
64:
65: /**
66: * Set the body.
67: * @param b the new body
68: */
69: public void setBody(java.util.List b);
70:
71: /**
72: * Set a new value. A value true means that the prerequisistes are connected by OR,
73: * a value false means that the prerequistes are connected by AND.
74: * @param value a boolean
75: */
76: public void setBodyOrConnected(boolean value);
77:
78: /**
79: * Set the head.
80: * @param f the new head
81: */
82: public void setHead(Fact f);
83: }
|