Sys2DSL (System 2 Domain-Specific Language) is the structured command language used by AGISystem2. It provides a deterministic, testable, and auditable way to express knowledge and queries. This page explains the role of Sys2DSL and shows how natural language maps to structured commands.

Why a DSL?

AGISystem2 uses a constrained DSL rather than free-form natural language for several important reasons:

Natural Language to Sys2DSL

The Chat Interface uses an LLM to translate natural language into Sys2DSL commands. Here are examples of how common statements translate:

Teaching Facts

Natural LanguageSys2DSL Command
"Dogs are animals" ASSERT Dog IS_A Animal
"Fire causes smoke" ASSERT Fire CAUSES Smoke
"Paris is located in France" ASSERT Paris LOCATED_IN France
"A car has wheels" ASSERT Car HAS_PART Wheel
"Driving requires a license" ASSERT Driving REQUIRES License
"Speeding is prohibited by law" ASSERT Speeding PROHIBITED_BY Law

Asking Questions

Natural LanguageSys2DSL Command
"Is a dog an animal?" ASK "Dog IS_A Animal?"
"What causes smoke?" ASK "? CAUSES Smoke"
"Where is Paris located?" ASK "Paris LOCATED_IN ?"
"What if water were a gas?" CF "Water IS_A Gas?" | Water TEMPERATURE_AT Celsius200

Command Structure

Every Sys2DSL command follows a consistent pattern:

@variable COMMAND arguments

The @variable captures the result. The COMMAND specifies the operation. Arguments provide the data.

Core Commands

CommandPurposeExample
ASSERT Add a fact @f ASSERT Dog IS_A Animal
ASK Query truth value @q ASK "Dog IS_A Animal?"
RETRACT Remove a fact @r RETRACT Dog IS_A Fish
FACTS_MATCHING Find matching facts @m FACTS_MATCHING ? IS_A Animal

Theory Management

CommandPurposeExample
THEORY_PUSH Create new context layer @_ THEORY_PUSH name="experiment"
THEORY_POP Discard top layer @_ THEORY_POP
LOAD_THEORY Load theory file @_ LOAD_THEORY medical
SAVE_THEORY Save current state @_ SAVE_THEORY session_1

Benefits for Testing and Validation

Automated Testing

Sys2DSL commands can be stored in test files and executed automatically:

# test_taxonomy.sys2dsl
@f1 ASSERT Dog IS_A Mammal
@f2 ASSERT Mammal IS_A Animal
@q ASK "Dog IS_A Animal?"
# Expected: TRUE_CERTAIN (transitive)

CI/CD Integration

# In GitHub Actions or similar
./bin/AGISystem2Raw.sh --batch tests/knowledge_base.sys2dsl
./bin/AGISystem2Raw.sh --exec "ask Is system consistent?" --json

Audit Logs

Every command execution is logged with timestamp and result:

2024-01-15 10:23:45 ASSERT Dog IS_A Animal → OK
2024-01-15 10:23:46 ASK "Dog IS_A Animal?" → TRUE_CERTAIN (0.95)
2024-01-15 10:23:47 THEORY_PUSH name="experiment" → depth=1

The Two Interfaces

AGISystem2 provides two ways to work with Sys2DSL:

InterfaceInputBest For
Raw CLI Direct Sys2DSL commands Testing, automation, scripting
Chat Interface Natural language (translated by LLM) Exploration, demos, learning

Both interfaces execute the same underlying Sys2DSL commands. The Chat Interface adds an LLM translation layer for convenience, while the Raw CLI provides direct control for precision work.

Related Documentation