Locy Language Guide¶
Rule Definition¶
CREATE RULE rule_name [PRIORITY n] AS
MATCH ...
[WHERE ...]
[ALONG ...]
[FOLD ...]
[BEST BY ...]
YIELD ...
Rule References¶
Unary¶
Binary/Tuple¶
Expression Functions in Rules¶
Cypher expression functions work inside WHERE, ALONG, FOLD, BEST BY, and YIELD. The similar_to() function is particularly useful for semantic scoring in rules:
-- Filter by semantic similarity in WHERE
CREATE RULE relevant_docs AS
MATCH (q:Query)-[:ABOUT]->(topic:Topic)<-[:TAGGED]-(d:Document)
WHERE similar_to(d.embedding, q.text) > 0.7
YIELD KEY q, KEY d, similar_to(d.embedding, q.text) AS score
-- Use as PROB value for probabilistic derivation
CREATE RULE related AS
MATCH (a:Paper)-[:CITES]->(b:Paper)
YIELD KEY a, KEY b, PROB similar_to(b.embedding, a.embedding)
similar_to() supports vector similarity, FTS scoring, and multi-source hybrid fusion. See the Vector Search guide for full documentation.
Rule vs command expressions
In rule bodies (WHERE, YIELD, ALONG, FOLD), similar_to() runs inside DataFusion with full capability — vector cosine, auto-embedding, FTS, and multi-source fusion. In command WHERE clauses (DERIVE ... WHERE, ABDUCE ... WHERE), only vector cosine is available because commands execute on materialized rows after strata converge.
Goal Query¶
Derivation Commands¶
Hypothetical Reasoning¶
Abductive Reasoning¶
Explainability¶
Modules¶
For advanced semantics of ALONG, FOLD, BEST BY, and mutation reasoning, continue to the advanced pages.