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.
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 |
@fact1 Socrates Is Human
@fact2 Humans Are Mortal
@premise fact1 And fact2
@conclusion Socrates Is Mortal
@rule premise Implies conclusion
Macros group statements into named units. Three types are supported:
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
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:
$subject | Input hypervector from the subject position |
$object | Input hypervector from the object position |
@result | Must be declared exactly once; becomes the verb output |
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
Built-in geometric operations:
Add | Element-wise vector addition |
Bind | Element-wise product (role-filler binding) |
Negate | Element-wise negation |
Distance | Similarity/distance metric |
Move | State translation (same as Add) |
Modulate | Element-wise scaling |
HasNumericValue | Wrap a number into NumericValue |
AttachUnit | Attach a unit symbol (kg, m, s) |
AddNumeric | Add with unit compatibility |
SubNumeric | Subtract with unit compatibility |
MulNumeric | Multiply with unit composition |
DivNumeric | Divide with unit composition |
AttachToConcept | Link numeric to a concept |
ProjectNumeric | Extract numeric from concept |
UseTheory | Overlay a theory in the current session |
Remember | Persist facts to a named theory |
BranchTheory | Create an in-memory branch |
MergeTheory | Merge two theory versions |
EvaluateTheory | Score a theory against data |
CompareTheories | Compare two theory versions |
Comments start with # and extend to end of line:
@fact1 Socrates Is Human # This is a comment
# This entire line is a comment
@result valueInside a macro, each @name can only appear once as a declaration. This ensures: