Skip to content

[#665] Implement ANDNOT operator in Pattern Matching query engine#1104

Open
andre-senna wants to merge 4 commits into
masterfrom
senna-665-2
Open

[#665] Implement ANDNOT operator in Pattern Matching query engine#1104
andre-senna wants to merge 4 commits into
masterfrom
senna-665-2

Conversation

@andre-senna
Copy link
Copy Markdown
Contributor

Resolves #665

After this PR, ANDNOT can be used as a token in PM queries or andnot in MeTTa queries.
ANDNOT is like an AND but its last clause is taken as if it has a logical NOT before it. So, e.g., in this query:

        "ANDNOT", "2",
            "LINK_TEMPLATE", "Expression", "3",
                "NODE", "Symbol", "Similarity",
                "VARIABLE", "v1", 
                "NODE", "Symbol", "\"human\"",
            "CHAIN", "0", "1", "2",
                "VARIABLE", "v1", 
                "NODE", "Symbol", "\"animal\"",
                "LINK_TEMPLATE", "Expression", "3",
                    "NODE", "Symbol", "Inheritance",
                    "VARIABLE", "vc1",
                    "VARIABLE", "vc2",

Which is equivalent to this MeTTa query:

(andnot (Similarity $v1 \"human\") (chain 0 1 2 $v1 \"animal\" (Inheritance $vc1 $vc2)))

We are searching for entities that are similar to human but which there's not a path between it and animal. In the Animals.metta knowledge base, it means we are looking for ent.

There are more examples in the pattern_matching_query_test.ccfile. See queries q15 and q16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement NOT operator in the query engine

1 participant