In Spock AGISystem2, a theory is a named collection of concepts, facts, and verb definitions. Theories create local contexts that can be overlaid, branched, and merged—like Git for knowledge.
The Session-Theory Model
A session is a temporary workspace that stacks theory overlays:
Local Symbols
@declarations from current script
Theory: Physics
Most recently loaded (UseTheory Physics)
Theory: BaseLogic
Earlier loaded theory
Global Symbols
Truth, False, Zero (always available)
Resolution Order (LIFO): When looking up a symbol, Spock searches from top to bottom. Local symbols shadow overlay symbols, which shadow global symbols. The most recent UseTheory takes precedence.
Symbol Resolution
Theory Structure
A theory on disk looks like:
.spock/theories/Physics/
├── theory.spockdsl # DSL statements
├── vectors.bin # Precomputed vectors
└── metadata.json # Version info
# theory.spockdsl
@Gravity Gravity Identity _
@Mass Mass Identity _
@Force Mass Bind Acceleration
@NewtonSecond Force Is MassTimesAcceleration
# Define custom verb
@ApplyForce verb begin
@step1 $subject Add $object
@result step1 Normalise _
end
Theory Versioning
Theory Verbs
Verb
Syntax
Effect
UseTheory
@load _ UseTheory Physics
Load theory as overlay, execute its statements
Remember
@save session Remember MyTheory
Persist session symbols to theory
BranchTheory
@branch Physics BranchTheory experiment
Create Physics__experiment from Physics
MergeTheory
@merge target MergeTheory source
Combine source into target
Merge Strategies
When two theories have the same symbol name, Spock offers geometric merge strategies:
Strategy: target (Default)
Keep the target (base) theory's version. Source is ignored for conflicts.
Throw an error on any conflict. Use when conflicts indicate a problem.
mergeTheory("Physics", "Experiment", { conflictStrategy: 'fail' });
// Throws MergeConflictError if any symbol exists in both
UseTheory with Execution
When you load a theory, its statements can be executed to populate the session:
Remember: Persisting Changes
The Remember verb saves session symbols back to a theory:
# Session work
@discovery Force Bind NewParticle
@law discovery Is UnifiedTheory
# Persist to theory
@save session Remember MyPhysics
# Now MyPhysics contains discovery and law!
What gets saved:
All local symbols (VECTOR, NUMERIC, FACT types)
Original relations are preserved when possible
Internal symbols ($temp, @step) are skipped
Child Sessions
Sessions can spawn child sessions with inherited overlays:
Child sessions:
Share parent's overlays and globals (read-only)
Have their own local symbol table
Changes don't affect parent
Useful for hypothetical reasoning ("what if...")
Why Theory Spaces Matter
Theories enable:
Modularity: Package knowledge into reusable units
Experimentation: Branch, try ideas, merge if they work
Collaboration: Multiple agents can work on different branches