diff --git a/.circleci/config.yml b/.circleci/config.yml index 517e130db3..8260bf6368 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2.0 jobs: ure: docker: - - image: singularitynet/opencog-deps + - image: $CIRCLE_PROJECT_USERNAME/opencog-deps user: root environment: CCACHE_DIR: /ws/ccache @@ -82,7 +82,7 @@ jobs: miner: docker: - - image: singularitynet/opencog-deps + - image: $CIRCLE_PROJECT_USERNAME/opencog-deps user: root environment: CCACHE_DIR: /ws/ccache @@ -134,7 +134,7 @@ jobs: pln: docker: - - image: opencog/opencog-deps + - image: $CIRCLE_PROJECT_USERNAME/opencog-deps user: root environment: CCACHE_DIR: /ws/ccache @@ -186,7 +186,7 @@ jobs: opencog: docker: - - image: singularitynet/opencog-deps + - image: $CIRCLE_PROJECT_USERNAME/opencog-deps user: root environment: CCACHE_DIR: /ws/ccache @@ -241,7 +241,7 @@ jobs: package: #Place holder docker: - - image: singularitynet/opencog-deps + - image: $CIRCLE_PROJECT_USERNAME/opencog-deps user: root working_directory: /ws/ure steps: diff --git a/CMakeLists.txt b/CMakeLists.txt index 5958ce17ba..8b1913c770 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,6 +95,8 @@ ENDIF (ATOMSPACE_FOUND) # add the 'cmake' directory from cogutil to search path list(APPEND CMAKE_MODULE_PATH ${COGUTIL_DATA_DIR}/cmake) include(OpenCogGccOptions) +include(OpenCogLibOptions) +include(OpenCogInstallOptions) include(Summary) # ---------------------------------------------------------- @@ -104,7 +106,7 @@ SET(Boost_USE_MULTITHREADED ON) SET(MIN_BOOST 1.46) # Required boost packages -FIND_PACKAGE(Boost ${MIN_BOOST} REQUIRED COMPONENTS date_time filesystem serialization system thread) +FIND_PACKAGE(Boost ${MIN_BOOST} REQUIRED) IF(Boost_FOUND) SET(Boost_FOUND_SAVE 1) @@ -130,31 +132,9 @@ ELSE (CXXTEST_FOUND) ENDIF (CXXTEST_FOUND) # ---------------------------------------------------------- -# This is required for Guile -FIND_LIBRARY(GMP_LIBRARY gmp) -FIND_PATH(GMP_INCLUDE_DIR gmp.h) - -# Gnu Guile scheme interpreter. Mandatory -# Version 2.2.2 is needed for mrs io ports, compilation, atomics, nlp -FIND_PACKAGE(Guile 2.2.2) -IF (GUILE_FOUND AND GMP_LIBRARY AND GMP_INCLUDE_DIR) - ADD_DEFINITIONS(-DHAVE_GUILE) - SET(HAVE_GUILE 1) - INCLUDE_DIRECTORIES(${GUILE_INCLUDE_DIR}) -ELSE (GUILE_FOUND AND GMP_LIBRARY AND GMP_INCLUDE_DIR) - SET(GUILE_DIR_MESSAGE "Guile was not found; the scheme shell will not be built.\nTo over-ride, make sure GUILE_LIBRARIES and GUILE_INCLUDE_DIRS are set.") - MESSAGE(FATAL_ERROR "${GUILE_DIR_MESSAGE}") -ENDIF (GUILE_FOUND AND GMP_LIBRARY AND GMP_INCLUDE_DIR) - - -# ---------------------------------------------------------- -# secure_getenv -INCLUDE(CheckSymbolExists) -CHECK_SYMBOL_EXISTS(secure_getenv "stdlib.h" HAVE_SECURE_GETENV) -IF (HAVE_SECURE_GETENV) - ADD_DEFINITIONS(-DHAVE_SECURE_GETENV) -ENDIF (HAVE_SECURE_GETENV) +# This is required for Guile, Python +include(OpenCogFindGuile) include(OpenCogFindPython) # ---------------------------------------------------------- @@ -202,54 +182,6 @@ INCLUDE("${ATOMSPACE_DATA_DIR}/cmake/OpenCogMacros.cmake") INCLUDE("${ATOMSPACE_DATA_DIR}/cmake/OpenCogGuile.cmake") INCLUDE("${ATOMSPACE_DATA_DIR}/cmake/OpenCogCython.cmake") -# ------------------------------------------------- -# Library configuration - -# Small hack to handle unixes that use "/usr/lib64" instead of -# "/usr/lib" as the default lib path on 64 bit archs. -# -IF (NOT DEFINED LIB_DIR_SUFFIX) - EXECUTE_PROCESS(COMMAND ${CMAKE_CXX_COMPILER} -print-search-dirs OUTPUT_VARIABLE PRINT_SEARCH_DIRS_OUTPUT) - STRING(REGEX MATCH "\r?\nlibraries:.*\r?\n" COMPILER_LIB_SEARCH_DIRS ${PRINT_SEARCH_DIRS_OUTPUT}) - IF (NOT ${COMPILER_LIB_SEARCH_DIRS} STREQUAL "") - STRING(REGEX MATCH "/lib64/:|/lib64:|/lib64\n" HAS_LIB64 ${COMPILER_LIB_SEARCH_DIRS}) - IF (NOT ${HAS_LIB64} STREQUAL "") - SET(LIB_DIR_SUFFIX "64") - ENDIF (NOT ${HAS_LIB64} STREQUAL "") - ENDIF (NOT ${COMPILER_LIB_SEARCH_DIRS} STREQUAL "") -ENDIF (NOT DEFINED LIB_DIR_SUFFIX) - -# RPATH handling (see https://cmake.org/Wiki/CMake_RPATH_handling) -# Note: RPATH only supported under Linux! -SET(CMAKE_SKIP_BUILD_RPATH FALSE) -SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) -SET(CMAKE_INSTALL_RPATH - "${CMAKE_INSTALL_PREFIX}/lib/opencog" - "${PYTHON_DEST}") - -SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - -# ------------------------------------------------- -# Install configuration - -# Only list install files that have actually changed. -SET(CMAKE_INSTALL_MESSAGE "LAZY") - -# Set confdir and datadir. -IF (NOT DEFINED CONFDIR) - SET (CONFDIR "${CMAKE_INSTALL_PREFIX}/etc") -ENDIF (NOT DEFINED CONFDIR) - -IF (NOT DEFINED DATADIR) - SET (DATADIR "${CMAKE_INSTALL_PREFIX}/share/opencog") -ENDIF (NOT DEFINED DATADIR) - -ADD_DEFINITIONS(-DCONFDIR="${CONFDIR}") -ADD_DEFINITIONS(-DDATADIR="${DATADIR}") - -# (re?)define MAN_INSTALL_DIR -SET (MAN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/man") - # ========================================================== # Decide what to build, based on the packages found. @@ -360,13 +292,6 @@ SET(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local") SET(DEPENDENCY_LIST "guile-2.2-dev (>= 2.2.2)" "python3-dev (>= 3.6.7)" - "libboost-date-time-dev (>= ${MIN_BOOST})" - "libboost-filesystem-dev (>= ${MIN_BOOST})" - "libboost-program-options-dev (>= ${MIN_BOOST})" - "libboost-regex-dev (>= ${MIN_BOOST})" - "libboost-serialization-dev (>= ${MIN_BOOST})" - "libboost-thread-dev (>= ${MIN_BOOST})" - "libboost-system-dev (>= ${MIN_BOOST})" "libboost-random-dev (>= ${MIN_BOOST})" "libstdc++6 (>= 4.7)" "libcogutil-dev (>= 2.0.2)" diff --git a/README.md b/README.md index ea36a6e07d..adc9a7dcf2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Unified Rule Engine -[![CircleCI](https://circleci.com/gh/opencog/ure.svg?style=svg)](https://circleci.com/gh/opencog/ure) +opencog | singnet +------- | ------- +[![CircleCI](https://circleci.com/gh/opencog/ure.svg?style=svg)](https://circleci.com/gh/opencog/ure) | [![CircleCI](https://circleci.com/gh/singnet/ure.svg?style=svg)](https://circleci.com/gh/singnet/ure) The Unified Rule Engine, URE for short, is a term rewriting engine for OpenCog. It can be used to implement any logic. As of today it is used diff --git a/opencog/scm/opencog/ure/ure-utils.scm b/opencog/scm/opencog/ure/ure-utils.scm index df80b3c780..b59765ca39 100644 --- a/opencog/scm/opencog/ure/ure-utils.scm +++ b/opencog/scm/opencog/ure/ure-utils.scm @@ -18,6 +18,7 @@ ;; -- ure-rm-all-rules -- Remove all rules from the given rbs ;; -- ure-rules -- List all rules of a given rule base ;; -- ure-weighted-rules -- List all weighted rules of a given rule base +;; -- ure-search-rules -- Retrieve all potential rules ;; -- ure-set-num-parameter -- Set a numeric parameter of an rbs ;; -- ure-set-fuzzy-bool-parameter -- Set a fuzzy boolean parameter of an rbs ;; -- ure-set-attention-allocation -- Set the URE:attention-allocation parameter @@ -79,6 +80,7 @@ (use-modules (opencog logger)) (use-modules (srfi srfi-1)) (use-modules (ice-9 receive)) +(use-modules (ice-9 optargs)) (define* (cog-fc rbs source #:key @@ -537,6 +539,26 @@ (cog-set-atomspace! current-as) clean-weighted-rules)) +(define*-public (ure-search-rules #:optional (as (cog-atomspace))) +" + Retrieve all potential rules in the given or default atomspace. + https://github.com/singnet/ure/issues/16 +" + (define current-as (cog-atomspace)) + + (define (filter-pot-rules DL-ATOMS-LIST) + (let* ((has-bind (lambda (x) (eq? 'BindLink (cog-type (cog-outgoing-atom x 1)))))) + (filter has-bind DL-ATOMS-LIST))) + + (cog-set-atomspace! as) + + (let* ((dl-atoms-list (cog-get-atoms 'DefineLink)) + (filtered-list (filter-pot-rules dl-atoms-list)) + (rules-list (map (lambda (x) (cog-outgoing-atom x 0)) filtered-list))) + + (cog-set-atomspace! current-as) + rules-list)) + (define (ure-set-num-parameter rbs name value) " Set numerical parameters. Given an rbs, a parameter name and its diff --git a/opencog/unify/Unify.cc b/opencog/unify/Unify.cc index 50c36117dc..7cf2758635 100644 --- a/opencog/unify/Unify.cc +++ b/opencog/unify/Unify.cc @@ -223,10 +223,13 @@ Unify::TypedSubstitution Unify::typed_substitution(const Partition& partition, var2cval = substitution_closure(var2cval); // Remove ill quotations + Variables tmpv(_variables.get_vardecl()); for (auto& vcv : var2cval) { + bool needless_quotation = true; Handle consumed = - RewriteLink::consume_quotations(_variables, vcv.second.handle, - vcv.second.context.quotation, false); + RewriteLink::consume_quotations(tmpv, vcv.second.handle, + vcv.second.context.quotation, + needless_quotation, false); vcv.second = CHandle(consumed, vcv.second.context); } @@ -237,12 +240,21 @@ Unify::TypedSubstitution Unify::typed_substitution(const Partition& partition, return {var2cval, vardecl}; } +static Variables gen_univars(const Handle& h, const Handle& vardecl) +{ + if (vardecl) + return Variables(vardecl); + HandleSet vars = get_free_variables(h); + HandleSeq varli(vars.begin(), vars.end()); + return Variables(varli); +} + void Unify::set_variables(const Handle& lhs, const Handle& rhs, const Handle& lhs_vardecl, const Handle& rhs_vardecl) { // Merge the 2 type declarations - Variables lv = gen_variables(lhs, lhs_vardecl); - Variables rv = gen_variables(rhs, rhs_vardecl); + Variables lv = gen_univars(lhs, lhs_vardecl); + Variables rv = gen_univars(rhs, rhs_vardecl); _variables = merge_variables(lv, rv); } @@ -278,8 +290,9 @@ Unify::HandleCHandleMap Unify::substitution_closure(const HandleCHandleMap& var2 // associated to these variables. HandleCHandleMap result(var2cval); for (auto& el : result) { - VariableListPtr varlist = gen_varlist(el.second); - const Variables& variables = varlist->get_variables(); + HandleSet free_vars = el.second.get_free_variables(); + HandleSeq free_list(free_vars.begin(), free_vars.end()); + Variables variables(free_list); HandleSeq values = variables.make_sequence(var2val); el.second.handle = variables.substitute_nocheck(el.second.handle, values); } @@ -398,6 +411,12 @@ Handle Unify::substitute(BindLinkPtr bl, const TypedSubstitution& ts, return substitute(bl, strip_context(ts.first), ts.second, queried_as); } +static Handle make_vardecl(const Handle& h) +{ + HandleSet vars = get_free_variables(h); + return Handle(createVariableSet(HandleSeq(vars.begin(), vars.end()))); +} + Handle Unify::substitute(BindLinkPtr bl, const HandleMap& var2val, Handle vardecl, const AtomSpace* queried_as) { @@ -407,7 +426,7 @@ Handle Unify::substitute(BindLinkPtr bl, const HandleMap& var2val, // If the bind link has no variable declaration either then // infer one Handle old_vardecl = bl->get_vardecl() ? bl->get_vardecl() - : gen_vardecl(bl->get_body()); + : make_vardecl(bl->get_body()); // Substitute the variables in the old vardecl to obtain the // new one. vardecl = substitute_vardecl(old_vardecl, var2val); @@ -424,7 +443,10 @@ Handle Unify::substitute(BindLinkPtr bl, const HandleMap& var2val, // Perform substitution over the pattern term, then remove // constant clauses Handle clauses = variables.substitute_nocheck(bl->get_body(), values); - clauses = RewriteLink::consume_quotations(vardecl, clauses, true); + Variables tmpv(vardecl); + bool needless_quotation = true; + clauses = RewriteLink::consume_quotations(tmpv, clauses, + Quotation(), needless_quotation, true); if (queried_as) clauses = remove_constant_clauses(vardecl, clauses, queried_as); hs.push_back(clauses); @@ -433,7 +455,10 @@ Handle Unify::substitute(BindLinkPtr bl, const HandleMap& var2val, for (const Handle& himp: bl->get_implicand()) { Handle rewrite = variables.substitute_nocheck(himp, values); - rewrite = RewriteLink::consume_quotations(vardecl, rewrite, false); + Variables tmpv(vardecl); + bool needless_quotation = true; + rewrite = RewriteLink::consume_quotations(tmpv, rewrite, + Quotation(), needless_quotation, false); hs.push_back(rewrite); } @@ -696,8 +721,6 @@ void Unify::ordered_unify_glob(const HandleSeq &lhs, for (size_t i = inter.first; (i <= inter.second and i <= rhs.size()); i++) { const Handle r_h = - i == 1 ? - *rhs.begin() : createLink(HandleSeq(rhs.begin(), rhs.begin() + i), LIST_LINK); auto head_sol = flip ? unify(r_h, lhs[0], rc, lc) : @@ -780,6 +803,27 @@ Unify::SolutionSet Unify::mkvarsol(CHandle lch, CHandle rch) const if (not inter) return SolutionSet(); else { + + // Special case: if the variable is a glob, and it matched + // just one item, then unwrap that item. This seems ... + // kind of perverse to me, but the unit tests expect this + // behavior. Maybe change things in the future? + if (GLOB_NODE == lch.handle->get_type() and + LIST_LINK == rch.handle->get_type() and + 1 == rch.handle->get_arity()) + { + rch.handle = rch.handle->getOutgoingAtom(0); + if (rch.handle == lch.handle) return SolutionSet(true); + inter.handle = rch.handle; + } + if (GLOB_NODE == rch.handle->get_type() and + LIST_LINK == lch.handle->get_type() and + 1 == lch.handle->get_arity()) + { + lch.handle = lch.handle->getOutgoingAtom(0); + if (rch.handle == lch.handle) return SolutionSet(true); + inter.handle = lch.handle; + } Block pblock{lch, rch}; Partitions par{{{pblock, inter}}}; return SolutionSet(par); @@ -1029,16 +1073,6 @@ HandleMap strip_context(const Unify::HandleCHandleMap& hchm) return result; } -/** - * Generate a VariableList of the free variables of a given contextual - * atom ch. - */ -VariableListPtr gen_varlist(const Unify::CHandle& ch) -{ - HandleSet free_vars = ch.get_free_variables(); - return createVariableList(HandleSeq(free_vars.begin(), free_vars.end())); -} - Unify::CHandle Unify::type_intersection(const CHandle& lch, const CHandle& rch) const { if (inherit(lch, rch)) @@ -1055,12 +1089,12 @@ TypeSet Unify::simplify_type_union(TypeSet& type) const TypeSet Unify::get_union_type(const Handle& h) const { - const VariableSimpleTypeMap& vtm = _variables._simple_typemap; + const VariableTypeMap& vtm = _variables._typemap; auto it = vtm.find(h); - if (it == vtm.end() or it->second.empty()) + if (it == vtm.end() or it->second->get_simple_typeset().empty()) return {ATOM}; else { - return it->second; + return it->second->get_simple_typeset(); } } @@ -1181,7 +1215,7 @@ bool Unify::is_node_satisfiable(const CHandle& lch, const CHandle& rch) const Variables merge_variables(const Variables& lhs, const Variables& rhs) { Variables new_vars(lhs); - new_vars.extend(rhs); + new_vars.extend_intersect(rhs); return new_vars; } @@ -1192,12 +1226,11 @@ Handle merge_vardecl(const Handle& lhs_vardecl, const Handle& rhs_vardecl) if (not rhs_vardecl) return lhs_vardecl; - VariableList + Variables lhs_vl(lhs_vardecl), rhs_vl(rhs_vardecl); - Variables new_vars = - merge_variables(lhs_vl.get_variables(), rhs_vl.get_variables()); + Variables new_vars = merge_variables(lhs_vl, rhs_vl); return new_vars.get_vardecl(); } diff --git a/opencog/unify/Unify.h b/opencog/unify/Unify.h index 6204898c91..68ec6c39fc 100644 --- a/opencog/unify/Unify.h +++ b/opencog/unify/Unify.h @@ -33,6 +33,7 @@ #include #include #include +#include #include namespace opencog { @@ -864,12 +865,6 @@ bool tss_content_eq(const Unify::TypedSubstitutions& lhs, */ HandleMap strip_context(const Unify::HandleCHandleMap& hchm); -/** - * Generate a VariableList of the free variables of a given contextual - * atom ch. - */ -VariableListPtr gen_varlist(const Unify::CHandle& ch); - /** * Merge two vardecls into one. If a variable is present in both * vardecls then the more restrictive one replaces the less diff --git a/opencog/ure/backwardchainer/BIT.cc b/opencog/ure/backwardchainer/BIT.cc index b6081f82bc..c037f6415f 100644 --- a/opencog/ure/backwardchainer/BIT.cc +++ b/opencog/ure/backwardchainer/BIT.cc @@ -93,8 +93,14 @@ AndBIT::AndBIT(AtomSpace& bit_as, const Handle& target, Handle vardecl, const BITNodeFitness& fitness, const AtomSpace* qas) : exhausted(false), queried_as(qas) { + // in case it is undefined + if (nullptr == vardecl) + { + HandleSet vars = get_free_variables(target); + vardecl = HandleCast(createVariableSet(HandleSeq(vars.begin(), vars.end()))); + } + // Create initial FCS - vardecl = gen_vardecl(target, vardecl); // in case it is undefined Handle body = Unify::remove_constant_clauses(vardecl, target, queried_as); HandleSeq bl{body, target}; diff --git a/tests/unify/UnifyGlobUTest.cxxtest b/tests/unify/UnifyGlobUTest.cxxtest index 4583c29a21..19a10a567f 100644 --- a/tests/unify/UnifyGlobUTest.cxxtest +++ b/tests/unify/UnifyGlobUTest.cxxtest @@ -116,6 +116,8 @@ void UnifyGlobUTest::setUp(void) void UnifyGlobUTest::test_type_intersection_1() { + logger().info("BEGIN TEST: %s", __FUNCTION__); + Handle lhs = X; Handle rhs = x; Unify unify(lhs, rhs); @@ -123,16 +125,20 @@ void UnifyGlobUTest::test_type_intersection_1() expected = rhs; TS_ASSERT_EQUALS(result, expected) + + logger().info("END TEST: %s", __FUNCTION__); } void UnifyGlobUTest::test_type_intersection_2() { + logger().info("BEGIN TEST: %s", __FUNCTION__); + Handle lhs = X; Handle rhs = Y; Handle l_decl = al(TYPED_VARIABLE_LINK, X, - al(TYPE_SET_LINK, + al(TYPE_INTERSECTION_LINK, al(INTERVAL_LINK, an(NUMBER_NODE, "1"), an(NUMBER_NODE, "4")), @@ -140,7 +146,7 @@ void UnifyGlobUTest::test_type_intersection_2() Handle r_decl = al(TYPED_VARIABLE_LINK, Y, - al(TYPE_SET_LINK, + al(TYPE_INTERSECTION_LINK, al(INTERVAL_LINK, an(NUMBER_NODE, "2"), an(NUMBER_NODE, "3")), @@ -151,17 +157,21 @@ void UnifyGlobUTest::test_type_intersection_2() expected = rhs; TS_ASSERT_EQUALS(result, expected) + + logger().info("END TEST: %s", __FUNCTION__); } void UnifyGlobUTest::test_type_intersection_3() { + logger().info("BEGIN TEST: %s", __FUNCTION__); + Handle lhs = X; Handle rhs = AB; Handle l_decl = al(VARIABLE_LIST, al(TYPED_VARIABLE_LINK, X, - al(TYPE_SET_LINK, + al(TYPE_INTERSECTION_LINK, al(INTERVAL_LINK, an(NUMBER_NODE, "1"), an(NUMBER_NODE, "2")), @@ -172,17 +182,21 @@ void UnifyGlobUTest::test_type_intersection_3() expected = rhs; TS_ASSERT_EQUALS(result, expected) + + logger().info("END TEST: %s", __FUNCTION__); } void UnifyGlobUTest::test_type_intersection_4() { + logger().info("BEGIN TEST: %s", __FUNCTION__); + Handle lhs = X; Handle rhs = AB; Handle l_decl = al(VARIABLE_LIST, al(TYPED_VARIABLE_LINK, X, - al(TYPE_SET_LINK, + al(TYPE_INTERSECTION_LINK, al(INTERVAL_LINK, an(NUMBER_NODE, "1"), an(NUMBER_NODE, "1")), @@ -193,31 +207,39 @@ void UnifyGlobUTest::test_type_intersection_4() expected = Unify::CHandle(Handle::UNDEFINED); TS_ASSERT_EQUALS(result, expected) + + logger().info("END TEST: %s", __FUNCTION__); } void UnifyGlobUTest::test_type_intersection_5() { + logger().info("BEGIN TEST: %s", __FUNCTION__); + Handle lhs = X; Handle rhs = AB; Handle l_decl = al(VARIABLE_LIST, al(TYPED_VARIABLE_LINK, X, - al(TYPE_SET_LINK, + al(TYPE_INTERSECTION_LINK, al(INTERVAL_LINK, an(NUMBER_NODE, "1"), an(NUMBER_NODE, "2")), - an(TYPE_NODE, "ListLink")))); + an(TYPE_NODE, "ConceptNode")))); Unify unify(lhs, rhs, l_decl); Unify::CHandle result = unify.type_intersection(lhs, rhs), expected = rhs; TS_ASSERT_EQUALS(result, expected) + + logger().info("END TEST: %s", __FUNCTION__); } void UnifyGlobUTest::test_unify_basic_1() { + logger().info("BEGIN TEST: %s", __FUNCTION__); + Unify unify(X, A); Unify::SolutionSet result = unify(); Unify::SolutionSet expected = @@ -227,10 +249,14 @@ void UnifyGlobUTest::test_unify_basic_1() std::cout << "expected = " << oc_to_string(expected) << std::endl; TS_ASSERT_EQUALS(result, expected) + + logger().info("END TEST: %s", __FUNCTION__); } void UnifyGlobUTest::test_unify_basic_2() { + logger().info("BEGIN TEST: %s", __FUNCTION__); + Unify unify(X, Y); Unify::SolutionSet result = unify(); @@ -250,10 +276,14 @@ void UnifyGlobUTest::test_unify_basic_2() std::cout << "expected_2 = " << oc_to_string(expected_2) << std::endl; TS_ASSERT((result==expected_1) or (result==expected_2)) + + logger().info("END TEST: %s", __FUNCTION__); } void UnifyGlobUTest::test_unify_basic_3() { + logger().info("BEGIN TEST: %s", __FUNCTION__); + Unify unify(X, x); Unify::SolutionSet result = unify(); @@ -266,10 +296,14 @@ void UnifyGlobUTest::test_unify_basic_3() std::cout << "expected = " << oc_to_string(expected) << std::endl; TS_ASSERT_EQUALS(result, expected) + + logger().info("END TEST: %s", __FUNCTION__); } void UnifyGlobUTest::test_unify_basic_4() { + logger().info("BEGIN TEST: %s", __FUNCTION__); + Unify unify(x, X); Unify::SolutionSet result = unify(); @@ -282,10 +316,14 @@ void UnifyGlobUTest::test_unify_basic_4() std::cout << "expected = " << oc_to_string(expected) << std::endl; TS_ASSERT_EQUALS(result, expected) + + logger().info("END TEST: %s", __FUNCTION__); } void UnifyGlobUTest::test_unify_basic_5() { + logger().info("BEGIN TEST: %s", __FUNCTION__); + Unify unify(X, AB); Unify::SolutionSet result = unify(); @@ -296,10 +334,14 @@ void UnifyGlobUTest::test_unify_basic_5() std::cout << "expected = " << oc_to_string(expected) << std::endl; TS_ASSERT_EQUALS(result, expected) + + logger().info("END TEST: %s", __FUNCTION__); } void UnifyGlobUTest::test_unify_multi_val_1() { + logger().info("BEGIN TEST: %s", __FUNCTION__); + Unify unify(XY, ABC); Unify::SolutionSet result = unify(); @@ -314,10 +356,14 @@ void UnifyGlobUTest::test_unify_multi_val_1() std::cout << "expected = " << oc_to_string(expected) << std::endl; TS_ASSERT_EQUALS(result, expected) + + logger().info("END TEST: %s", __FUNCTION__); } void UnifyGlobUTest::test_unify_multi_val_2() { + logger().info("BEGIN TEST: %s", __FUNCTION__); + Unify unify(al(LIST_LINK, U), al(LIST_LINK, U)); Unify::SolutionSet result = unify(); std::cout << "\n result\n" << oc_to_string(result) << std::endl; @@ -326,10 +372,14 @@ void UnifyGlobUTest::test_unify_multi_val_2() std::cout << "\n expected\n" << oc_to_string(expected) << std::endl; TS_ASSERT_EQUALS(result, expected) + + logger().info("END TEST: %s", __FUNCTION__); } void UnifyGlobUTest::test_unify_multi_val_3() { + logger().info("BEGIN TEST: %s", __FUNCTION__); + Unify unify(XYZ, al(LIST_LINK, U)); Unify::SolutionSet result = unify(); std::cout << "\n result\n" << oc_to_string(result) << std::endl; @@ -340,10 +390,14 @@ void UnifyGlobUTest::test_unify_multi_val_3() std::cout << "\n expected\n" << oc_to_string(expected) << std::endl; TS_ASSERT_EQUALS(result, expected); + + logger().info("END TEST: %s", __FUNCTION__); } void UnifyGlobUTest::test_unify_multi_val_4() { + logger().info("BEGIN TEST: %s", __FUNCTION__); + Unify unify(ABx, YBC); Unify::SolutionSet result = unify(); std::cout << "\n result\n" << oc_to_string(result) << std::endl; @@ -353,10 +407,14 @@ void UnifyGlobUTest::test_unify_multi_val_4() std::cout << "\n expected\n" << oc_to_string(expected) << std::endl; TS_ASSERT_EQUALS(result, expected) + + logger().info("END TEST: %s", __FUNCTION__); } void UnifyGlobUTest::test_unify_typed_1() { + logger().info("BEGIN TEST: %s", __FUNCTION__); + Handle l_decl = al(TYPED_VARIABLE_LINK, Y, an(TYPE_NODE, "ConceptNode")); @@ -371,10 +429,14 @@ void UnifyGlobUTest::test_unify_typed_1() std::cout<< "\n expected\n" << oc_to_string(expected) <