Sys2DSL is the textual language used to describe all reasoning logic in an AGISystem2 session or theory file. There is no separate concept of “macro”: a theory is simply a multi‑line Sys2DSL programme.
Every Sys2DSL instruction is a line (or a fragment of a line) of the form:
@varName ACTION arg1 arg2 ...
@varName defines a variable name in the script environment (for example @f1, @q1, @mask).ACTION is an uppercase keyword (for example ASSERT, ASK, CF, FACTS_MATCHING, ALL_REQUIREMENTS_SATISFIED, MASK_DIMS).arg1 arg2 ... are the action parameters: simple words or quoted strings, optionally with variable references.Comments are lines starting with # and are ignored. Extra spaces between tokens are allowed.
Conventions for tokens in arguments:
dog, water, export_data) – concept names;Alice, CityX) – individuals or concrete instances;$ ($reqs, $list) – references to variables defined earlier (via @reqs, @list);?, = etc.Variables are bound at the time the instruction that defines them is executed. Any instruction that uses $name depends on the instruction that defined @name.
A Sys2DSL script is a list of instructions. Statements are delimited as follows:
@ that starts a word marks the beginning of a new statement;@:@f1 ASSERT Dog IS_A Animal
@f2 ASSERT Water BOILS_AT Celsius100
@f3 ASSERT Celsius100 IS_A temperature
@q1 ASK "Is Dog an Animal?"
@q2 ASK "Water BOILS_AT Celsius100?"
@f1 ASSERT Dog IS_A Animal @q1 ASK "Is Dog an Animal?"
Instead of executing lines strictly in textual order, the interpreter first builds a dependency graph between variables (based on $name occurrences) and evaluates instructions in a topological order. This allows you to write:
@b BOOL_AND $a $a
@a NONEMPTY $list
@list FACTS_MATCHING "Dog IS_A Animal"
even though @b appears first textually; the engine will evaluate @list first, then @a, then @b. Cyclic dependencies (for example @a depending on $b and @b on $a) are detected and reported as errors.
Sys2DSL commands are organized into functional categories. See DS(/theory/Sys2DSL_commands) for the complete reference with 40+ commands.
@q1 ASK Dog IS_A Animal # Query truth value
@q2 ASK "Is Dog an Animal?" # Natural question form
@masked ASK_MASKED $ontologyMask Dog IS_A Animal # Masked query
@facts FACTS_MATCHING Dog ? ? # Pattern search
@f1 ASSERT Dog IS_A Animal
@f2 ASSERT Water BOILS_AT Celsius100
@r1 RETRACT Dog IS_A Fish # Remove fact
@proof PROVE Dog IS_A LivingThing # Prove with chain
@valid VALIDATE # Check consistency
@hyp HYPOTHESIZE Smoke # Generate hypotheses
@cf CF "Water IS_A gas?" | Water TEMPERATURE_AT Celsius150
@abd ABDUCT Smoke CAUSED_BY # Abductive reasoning
@_ THEORY_PUSH name="exploration" # Push new layer
@_ THEORY_POP # Pop and discard
@stack LIST_THEORIES # Show layer stack
@load LOAD_THEORY physics_basics # Load from file
@save SAVE_THEORY my_domain # Save to file
@stats GET_USAGE Water # Usage statistics
@_ PROTECT ImportantConcept # Protect from forgetting
@_ UNPROTECT TempConcept # Remove protection
@clean FORGET threshold=5 # Remove low-usage
@_ BOOST Water 50 # Increase priority
@m1 MASK_PARTITIONS ontology # By partition
@m2 MASK_DIMS temperature pressure # By dimensions
@m3 MASK_CONCEPT $waterRef # By concept relevance
@and BOOL_AND $q1 $q2 # Boolean AND
@or BOOL_OR $q1 $q2 # Boolean OR
@not BOOL_NOT $q1 # Boolean NOT
@merged MERGE_LISTS $list1 $list2 # Combine lists
@first PICK_FIRST $list # First element
@n COUNT $list # List size
@nonEmpty NONEMPTY $list # Check if non-empty
@text TO_NATURAL $result # Human-readable
@json TO_JSON $result # JSON export
@exp EXPLAIN $result # Detailed explanation
A compliance check programme demonstrating multiple command types:
# Fetch procedure requirements
@reqs FACTS_MATCHING "$procId REQUIRES ?"
@satGiven FACTS_MATCHING "? GIVEN yes"
@satPresent FACTS_MATCHING "? PRESENT yes"
@allSat MERGE_LISTS $satGiven $satPresent
@result ALL_REQUIREMENTS_SATISFIED $reqs $allSat
# Check and report
@check ASK ProcedureX COMPLIANT yes
@explanation EXPLAIN $check
The same language is used in two contexts:
*.sys2dsl) versioned in Git, containing reusable Sys2DSL programmes for a domain (health rules, export rules, narratives, etc.).System2Session to add facts, run checks or explore counterfactuals.There is no syntax difference between the two; only the loading method differs (persistent files vs. commands sent via API/CLI).
Sys2DSL is the only textual‑level language used to talk to AGISystem2. Facts, questions and verification programmes are all expressed as sequences of @var ACTION … instructions, evaluated in a deterministic and easily auditable way.
For implementation details, see the relevant design specifications (referenced by ID):