OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Rule.h
Go to the documentation of this file.
1 /*
2  * Rule.h
3  *
4  * Copyright (C) 2015 Misgana Bayetta
5  *
6  * Author: Misgana Bayetta <misgana.bayetta@gmail.com> 2015
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Affero General Public License v3 as
10  * published by the Free Software Foundation and including the exceptions
11  * at http://opencog.org/wiki/Licenses
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU Affero General Public License
19  * along with this program; if not, write to:
20  * Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23 
24 #ifndef RULE_H_
25 #define RULE_H_
26 
27 #include <boost/operators.hpp>
30 
31 
32 namespace opencog {
33 
34 using namespace std;
35 
39 class Rule : public boost::less_than_comparable<Rule>,
40  public boost::equality_comparable<Rule>
41 {
42 public:
43  // rule is actually
44  //
45  // MemberLink <TV>
46  // <rule name>
47  // <rbs>
48  Rule(Handle rule);
49 
50  // Comparison
51  bool operator==(const Rule& r) const {
52  return r.rule_handle_ == rule_handle_;
53  }
54  bool operator<(const Rule& r) const {
55  return weight_ < r.weight_;
56  }
57 
58  // Modifiers
59  void set_handle(Handle h) throw (InvalidParamException);
60  void set_name(const string& name);
61  void set_category(const string& name);
62  void set_weight(float p);
63 
64  // Access
65  string& get_name();
66  const string& get_name() const;
67  string& get_category();
68  const string& get_category() const;
69  Handle get_handle();
70  Handle get_vardecl();
71  Handle get_implicant();
72  HandleSeq get_implicant_seq();
73  Handle get_implicand();
74  HandleSeq get_implicand_seq();
75  float get_weight();
76 
77  Rule gen_standardize_apart(AtomSpace* as);
78 
79 private:
80  // Rule handle, typically a BindLink
82 
83  // Rule name, the name of the node referring to the rule body
84  string name_;
85 
86  // Rule base system name
87  string category_;
88 
89  // Rule weight (indicated by the TV strength of the membership of
90  // the rule to the RBS)
91  float weight_;
92 
93  Handle standardize_helper(AtomSpace* as, Handle, std::map<Handle, Handle>&);
94 };
95 
96 } // ~namespace opencog
97 
98 #endif /* RULE_H_ */
std::vector< Handle > HandleSeq
a list of handles
Definition: Handle.h:246
bool operator==(const Rule &r) const
Definition: Rule.h:51
string name_
Definition: Rule.h:84
string category_
Definition: Rule.h:87
float weight_
Definition: Rule.h:91
Handle rule_handle_
Definition: Rule.h:81
bool operator<(const Rule &r) const
Definition: Rule.h:54