OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
BackwardChainer.h
Go to the documentation of this file.
1 /*
2  * BackwardChainer.h
3  *
4  * Copyright (C) 2014 Misgana Bayetta
5  * Copyright (C) 2015 OpenCog Foundation
6  *
7  * Author: Misgana Bayetta <misgana.bayetta@gmail.com> October 2014
8  * William Ma <https://github.com/williampma>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU Affero General Public License v3 as
12  * published by the Free Software Foundation and including the exceptions
13  * at http://opencog.org/wiki/Licenses
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU Affero General Public License
21  * along with this program; if not, write to:
22  * Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25 #ifndef BACKWARDCHAINER_H_
26 #define BACKWARDCHAINER_H_
27 
30 
31 #include "Target.h"
32 
33 class BackwardChainerUTest;
34 
35 namespace opencog
36 {
37 
38 typedef std::map<Handle, UnorderedHandleSet> VarMultimap;
39 typedef std::map<Handle, Handle> VarMap;
40 
92 {
93  friend class ::BackwardChainerUTest;
94 
95 public:
97 
98  void set_target(Handle init_target);
100  const UREConfigReader& get_config() const;
101 
102  void do_chain();
103  void do_step();
104 
106 
107 private:
108 
109  void process_target(Target& target);
110 
111  std::vector<Rule> filter_rules(const Target& target);
112  Rule select_rule(Target& target, const std::vector<Rule>& rules);
113 
114  HandleSeq match_knowledge_base(const Handle& htarget,
115  Handle htarget_vardecl,
116  std::vector<VarMap>& vmap);
117  HandleSeq ground_premises(const Handle& htarget, const VarMap& vmap,
118  std::vector<VarMap>& vmap_list);
119  bool unify(const Handle& hsource, const Handle& hmatch,
120  Handle hsource_vardecl, Handle hmatch_vardecl, VarMap& result);
121 
122  Handle gen_sub_varlist(const Handle& parent, const Handle& parent_varlist,
123  std::set<Handle> additional_free_varset);
124 
129 
131 
132  // XXX any additional link should be reflected
133  unordered_set<Type> _logical_link_types = { AND_LINK, OR_LINK, NOT_LINK };
134 };
135 
136 
137 } // namespace opencog
138 
139 #endif /* BACKWARDCHAINER_H_ */
std::vector< Rule > filter_rules(const Target &target)
void set_target(Handle init_target)
std::vector< Handle > HandleSeq
a list of handles
Definition: Handle.h:246
Rule select_rule(Target &target, const std::vector< Rule > &rules)
const VarMultimap & get_chaining_result()
UREConfigReader _configReader
HandleSeq match_knowledge_base(const Handle &htarget, Handle htarget_vardecl, std::vector< VarMap > &vmap)
HandleSeq ground_premises(const Handle &htarget, const VarMap &vmap, std::vector< VarMap > &vmap_list)
std::map< Handle, UnorderedHandleSet > VarMultimap
bool unify(const Handle &hsource, const Handle &hmatch, Handle hsource_vardecl, Handle hmatch_vardecl, VarMap &result)
UREConfigReader & get_config()
unordered_set< Type > _logical_link_types
std::map< Handle, Handle > VarMap
Handle gen_sub_varlist(const Handle &parent, const Handle &parent_varlist, std::set< Handle > additional_free_varset)
void process_target(Target &target)
BackwardChainer(AtomSpace &as, Handle rbs)