Skip to content
Archee Docs

Sets, views and rules

Combine queries with set operations, name a pattern with DEFINE, and keep a check as a RULE.

Set operations

UNION, INTERSECT and EXCEPT combine queries that return the same columns, left to right, with set semantics. EXCEPT keeps the rows of the left query that the right one lacks.

Bearings and seals:
MATCH (p:bearing) RETURN p.id UNION MATCH (p:seal) RETURN p.id

Both coaxial and touching:
MATCH (p)-[:coaxial]-("shaft.II") RETURN p.id INTERSECT MATCH (p)-[:touches]-("shaft.II") RETURN p.id

Shafts with no dimension:
MATCH (p:shaft) RETURN p.id EXCEPT MATCH (:dim)-[:dimensions]->(p:shaft) RETURN p.id

Optional match

OPTIONAL MATCH keeps a row when its pattern finds nothing:

MATCH (s:shaft) OPTIONAL MATCH (d:dim)-[:dimensions]->(s) RETURN s.id, count(d) AS dims

Shafts without dimensions appear with dims = 0.

DEFINE

DEFINE names a pattern you reuse in the same program:

DEFINE mounted_on(p, s) AS MATCH (p)-[:coaxial]-(s:shaft), (p)-[:touches]-(s) RETURN p, s;
MATCH mounted_on(p, s) RETURN s.id, count(p) AS carried

Recursion is a monotone closure over relations, capped in depth, with no aggregate or negation inside. A capped result says truncated: true.

RULE

RULE name AS query is a check. Each returned row is a violation, and an empty result passes.

RULE seal_on_thread AS MATCH (s:seal)-[:touches]-(t:thread) RETURN s.id, t.id

Keep the rules that matter to your design. The same rule runs after every edit, and a policy is a rule over the result.

Rule packs

A rule pack is a set of .arql rules evaluated together. The packs compat, departures, map and impact ship with the engine. In impact, touching is the one-hop set [:touches|coaxial] and impacted is the two-hop set [:touches|coaxial*1..2]. List them with:

agentcad search 'rule pack'

Use ARQL in a review

  1. Export the drawing, or open the .dxf.
  2. Run the ten common queries, or your own, against it.
  3. Turn the query that matters into a RULE.
  4. After each revision, run the rules again and read the rows.

See Query reference for the grammar.