Skip to content

Commit

Permalink
Revert "Merge pull request opencog#2500 from linas/anchor-link"
Browse files Browse the repository at this point in the history
Linking results to the AnchorNode idea now seems like a bad idea,
in retrospect.  The ideas in opencog#2911 seem superior. So trash the
AnchorNode support in the query subsystem.

FWIW, if this kind of thing was wanted, a better solution would
be a new kind of Value, that dequeued from a QueueValue, and
plopped the results onto an AnchorNode. ***This*** is the real
reason for stripping away this code: its not generic enough.

This reverts commit 46dea8e, reversing
changes made to 5ec84bb.
  • Loading branch information
linas committed Dec 16, 2022
1 parent 47d30c0 commit 9a3d2c7
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 289 deletions.
1 change: 0 additions & 1 deletion examples/pattern-matcher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ Basic Examples
The first five examples provide a basic introduction to basic
pattern matching.

* `anchor.scm` -- Obtaining results incrementally.
* `satisfaction.scm` -- Determining satisfiability of a query.
* `unify.scm` -- Basic term unification.
* `glob.scm` -- Matching multiple atoms at once.
Expand Down
66 changes: 0 additions & 66 deletions examples/pattern-matcher/anchor.scm

This file was deleted.

28 changes: 26 additions & 2 deletions opencog/atoms/core/Variables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ static const GlobInterval& default_interval(Type t)
var_def_interval;
}

const GlobInterval Variables::get_interval(const Handle& var) const
const GlobInterval& Variables::get_interval(const Handle& var) const
{
const auto& decl = _typemap.find(var);

Expand Down Expand Up @@ -668,10 +668,34 @@ Handle Variables::get_vardecl() const

if (_ordered)
return HandleCast(createVariableList(std::move(vardecls)));

return HandleCast(createVariableSet(std::move(vardecls)));
}

void Variables::validate_vardecl(const HandleSeq& oset)
{
for (const Handle& h: oset)
{
Type t = h->get_type();
if (VARIABLE_NODE == t or GLOB_NODE == t)
{
varset.insert(h);
varseq.emplace_back(h);
}
else if (TYPED_VARIABLE_LINK == t)
{
get_vartype(h);
}
else
{
throw InvalidParamException(TRACE_INFO,
"Expected a VariableNode or a TypedVariableLink, got: %s"
"\nVariableList is %s",
nameserver().getTypeName(t).c_str(),
to_string().c_str());
}
}
}

/* ================================================================= */

std::string Variables::to_string(const std::string& indent) const
Expand Down
5 changes: 5 additions & 0 deletions opencog/atoms/core/Variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,13 @@ struct Variables : public FreeVariables
/// _typemap holds back-ponters to TypedVariableLinkPtrs
VariableTypeMap _typemap;

<<<<<<< HEAD
/// Anchor, if present, else undefined.
Handle _anchor;
=======
// See VariableList.cc for comments
void get_vartype(const Handle&);
>>>>>>> parent of 46dea8ea1 (Merge pull request #2500 from linas/anchor-link)

// Validate the variable decls
void validate_vardecl(const Handle&);
Expand Down
10 changes: 0 additions & 10 deletions opencog/atoms/pattern/BindLink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,6 @@ ValuePtr BindLink::execute(AtomSpace* as, bool silent)
OC_ASSERT(qv->is_closed(), "Unexpected queue state!");
HandleSeq rslt(qv->to_handle_seq());

// If there is an anchor, then attach results to the anchor.
// Otherwise, create a SetLink and return that.
if (_variables._anchor and as)
{
for (const Handle& h: rslt)
as->add_link(MEMBER_LINK, h, _variables._anchor);

return _variables._anchor;
}

// The result_set contains a list of the grounded expressions.
// (The order of the list has no significance, so it's really a set.)
// Put the set into a SetLink, cache it, and return that.
Expand Down
15 changes: 0 additions & 15 deletions opencog/atoms/pattern/DualLink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,6 @@ ValuePtr DualLink::execute(AtomSpace* as, bool silent)
if (nullptr == as) as = _atom_space;
Recognizer reco(as);
reco.satisfy(PatternLinkCast(get_handle()));

// If there is an anchor, then attach results to the anchor.
// Otherwise, create a SetLink and return that.
// XXX FIXME ... at this time, there is no documented way of
// squeezing an AnchorLink into a DualLink. So the below
// if-statement is never taken. Some additional design work
// is needed.
if (_variables._anchor and as)
{
for (const Handle& h : reco._rules)
as->add_link(MEMBER_LINK, h, _variables._anchor);

return _variables._anchor;
}

return as->add_atom(createUnorderedLink(reco._rules, SET_LINK));
}

Expand Down
10 changes: 0 additions & 10 deletions opencog/atoms/pattern/GetLink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,6 @@ ValuePtr GetLink::execute(AtomSpace* as, bool silent)
OC_ASSERT(qv->is_closed(), "Unexpected queue state!");
HandleSet hs(qv->to_handle_set());

// If there is an anchor, then attach results to the anchor.
// Otherwise, create a SetLink and return that.
if (_variables._anchor and as)
{
for (const Handle& h : hs)
as->add_link(MEMBER_LINK, h, _variables._anchor);

return _variables._anchor;
}

// Create the satisfying set, and cache it.
Handle satset(createUnorderedLink(std::move(hs), SET_LINK));

Expand Down
6 changes: 0 additions & 6 deletions opencog/atoms/pattern/SatisfactionLink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ TruthValuePtr SatisfactionLink::evaluate(AtomSpace* as, bool silent)
Satisfier sater(as);
sater.satisfy(PatternLinkCast(get_handle()));

// If there is an anchor, then attach results to the anchor.
if (_variables._anchor and as)
{
as->add_link(MEMBER_LINK, sater._ground, _variables._anchor);
}

return sater._result;
}

Expand Down
138 changes: 0 additions & 138 deletions tests/query/AnchorUTest.cxxtest

This file was deleted.

2 changes: 0 additions & 2 deletions tests/query/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ ADD_CXXTEST(RecognizerUTest)
ADD_CXXTEST(ArcanaUTest)
ADD_CXXTEST(SubstitutionUTest)
ADD_CXXTEST(GetLinkUTest)
ADD_CXXTEST(AnchorUTest)
ADD_CXXTEST(NotLinkUTest)
ADD_CXXTEST(GetStateUTest)
ADD_CXXTEST(ClassicalBooleanUTest)
Expand Down Expand Up @@ -150,7 +149,6 @@ TARGET_LINK_LIBRARIES(SparseUTest
)

# -------------------------------------------------------------

# Run only the tests in this subdirectory
ADD_CUSTOM_TARGET (qtest
DEPENDS tests
Expand Down
39 changes: 0 additions & 39 deletions tests/query/anchor.scm

This file was deleted.

0 comments on commit 9a3d2c7

Please sign in to comment.