Overview

SpockDSL is a minimal, uniform domain-specific language for geometric reasoning. Every executable statement follows the same pattern, making it easy to parse, analyze, and explain.

Statement Form

Every statement has exactly four tokens:

@varName subject verb object
@varName Declaration of a new variable in the current scope (SSA discipline)
subject Reference to a previously declared name or literal
verb Binary relation (kernel verb, logical verb, or user-defined)
object Reference to a previously declared name or literal

Examples

@fact1 Socrates Is Human
@fact2 Humans Are Mortal
@premise fact1 And fact2
@conclusion Socrates Is Mortal
@rule premise Implies conclusion

Macro Definitions

Macros group statements into named units. Three types are supported:

Theory Macro

Defines a collection of facts and verb definitions that can be persisted and reused.

@BasicLogic theory begin
    @fact1 a In b
    @fact2 b In c
    @premise fact1 And fact2
    @conclusion a In c
    @rule premise Implies conclusion
end

Verb Macro

Defines a custom binary relation using $subject, $object, and @result.

@Eat verb begin
    @subjectRole subject Bind Calories
    @interaction subjectRole Add object
    @result interaction Move subject
end

Magic Variables:

$subjectInput hypervector from the subject position
$objectInput hypervector from the object position
@resultMust be declared exactly once; becomes the verb output

Session Macro

Defines a temporary reasoning context that overlays theories.

@ReasoningSession session begin
    @useLogic local UseTheory BasicLogic
    @s1 Socrates Is Human
    @s2 Humans Are Mortal
    @query s1 Implies s2
end

Kernel Verbs

Built-in geometric operations:

AddElement-wise vector addition
BindElement-wise product (role-filler binding)
NegateElement-wise negation
DistanceSimilarity/distance metric
MoveState translation (same as Add)
ModulateElement-wise scaling

Numeric Verbs

HasNumericValueWrap a number into NumericValue
AttachUnitAttach a unit symbol (kg, m, s)
AddNumericAdd with unit compatibility
SubNumericSubtract with unit compatibility
MulNumericMultiply with unit composition
DivNumericDivide with unit composition
AttachToConceptLink numeric to a concept
ProjectNumericExtract numeric from concept

Theory Management Verbs

UseTheoryOverlay a theory in the current session
RememberPersist facts to a named theory
BranchTheoryCreate an in-memory branch
MergeTheoryMerge two theory versions
EvaluateTheoryScore a theory against data
CompareTheoriesCompare two theory versions

Comments

Comments start with # and extend to end of line:

@fact1 Socrates Is Human  # This is a comment
# This entire line is a comment

Execution Semantics

  1. Parse script into AST (statements and macros)
  2. For each macro, build dependency graph from references
  3. Compute topological order (textual order as tie-breaker)
  4. Execute statements in topological order
  5. For verb macros, return @result value

SSA Discipline

Inside a macro, each @name can only appear once as a declaration. This ensures:

Related Specifications