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.

Basic Line Form

Every Sys2DSL instruction is a line (or a fragment of a line) of the form:

@varName ACTION arg1 arg2 ...

Comments are lines starting with # and are ignored. Extra spaces between tokens are allowed.

Tokens and Variables

Conventions for tokens in arguments:

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.

Statements and Topological Evaluation

A Sys2DSL script is a list of instructions. Statements are delimited as follows:

@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.

Command Categories

Sys2DSL commands are organized into functional categories. See DS(/theory/Sys2DSL_commands) for the complete reference with 40+ commands.

Query 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

Assertion Commands

@f1 ASSERT Dog IS_A Animal
@f2 ASSERT Water BOILS_AT Celsius100
@r1 RETRACT Dog IS_A Fish                  # Remove fact

Reasoning Commands

@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 Layer Commands

@_ 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

Memory Management Commands

@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

Mask Commands

@m1 MASK_PARTITIONS ontology               # By partition
@m2 MASK_DIMS temperature pressure         # By dimensions
@m3 MASK_CONCEPT $waterRef                 # By concept relevance

Utility Commands

@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

Output Commands

@text TO_NATURAL $result                   # Human-readable
@json TO_JSON $result                      # JSON export
@exp EXPLAIN $result                       # Detailed explanation

Complete Example

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

Sys2DSL in Theory Files vs. Sessions

The same language is used in two contexts:

There is no syntax difference between the two; only the loading method differs (persistent files vs. commands sent via API/CLI).

Summary

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.

References

For implementation details, see the relevant design specifications (referenced by ID):