DSL reference

A SimmyNet program is a list of group Name { ... } blocks. Each group is compiled independently; run a program with simmynet_cli program.sym, simmynet.dsl.Interpreter().run(source) (Python) or SimmyNetInterpreter::run(source) (C++).

Lexical rules

Defined by one regular expression in Lexer.hpp; whitespace and # comments are skipped.

Token Form
Comment # to end of line
Number 3, 3., .5, 0.25, 1e-3, 2.5E+4 (no sign: a leading - is a separate symbol)
Identifier [A-Za-z_][A-Za-z_0-9]* (the keywords below are ordinary identifiers)
Symbol one of { } ( ) [ ] , = + - * / ^
anything else LexError: line N: unexpected character 'c'

Grammar

program   := group*                       (at least one group)
group     := 'group' IDENT '{' statement* '}'
statement := gen | lift | subgroup | separate | sector | space | synthesize
           | eval | classify | verify | check | sweep

gen        := 'gen' IDENT ['(' IDENT ')'] '=' KIND '(' (matrix_rows | expr) ')'
              KIND ∈ matrix | rotation | reflection | phasor
              matrix_rows := '[' row (',' row)* ']'      row := '[' expr (',' expr)* ']'
lift       := 'lift' IDENT '=' expr
subgroup   := 'subgroup' IDENT '=' 'span' '(' IDENT (',' IDENT)* ')'
separate   := 'separate' IDENT '{' (('weight' '=' '[' expr (',' expr)* ']' | 'bias' '=' expr) [','])* '}'
sector     := 'sector' IDENT '=' '[' expr ',' expr ']'
space      := 'space' IDENT '{' (point 'class' NUMBER [','])+ '}'
synthesize := 'synthesize' IDENT ( 'on' IDENT | 'of' IDENT 'over' IDENT ['coset' word] )
eval       := 'eval' word ['on' point]
classify   := 'classify' IDENT ( 'on' point | 'of' word ['on' point] ) ['expect' NUMBER]
verify     := 'verify' IDENT '=' IDENT 'over' IDENT
check      := 'check' word '=' '=' word
sweep      := 'sweep' IDENT 'over' IDENT 'from' expr 'to' expr 'steps' NUMBER

point     := '(' expr (',' expr)* ')'
word      := factor ('*' factor)*
factor    := IDENT ['(' expr ')'] ['^' ['-'] NUMBER]       exponent must be an integer
expr      := term (('+' | '-') term)*
term      := unary (('*' | '/') unary)*
unary     := '-' unary | atom
atom      := NUMBER | IDENT | IDENT '(' expr ')' | '(' expr ')'

separate requires both weight and bias. space requires at least one point. sweep requires steps >= 1. check is written with two separate = tokens (==).

Statements

Keyword Syntax Meaning
group group D4 { ... } A compilation unit with its own generators, subgroups, classifiers and queries.
gen gen r = rotation(90) · gen s = matrix([[-1,0],[0,1]]) · gen R(theta) = phasor(theta) Declare a generator (see Generator kinds). R(theta) declares a continuous parametrised family; use it as R(pi/4). All generators in a group must have the same dimension.
lift lift z = abs(x - y) Declare a non-linear feature layer appended to every classifier of the group. Variables are the coordinate names the classifier sees.
subgroup subgroup H = span(r, s) The finite subgroup generated by the listed (non-parametrised) generators, by BFS closure; at most 2048 elements.
separate separate C { weight = [0, 0, 1], bias = -0.5 } A hand-written hyperplane classifier; the decision is weight · features + bias > 0. Weights and bias are expressions, so exact pi terms are allowed.
sector sector Wedge = [pi/4, 3*pi/4] A closed counter-clockwise angular sector of $SO(2)$ compiled to two half-plane perceptrons with AND output (width $\le \pi$) or OR output (width $ \gt \pi$). The width must lie in $(0, 2\pi)$.
space space P { (0,0) class 0 (1,0) class 1 } A labelled point set used by synthesize ... on.
synthesize synthesize C on P · synthesize C of H over D [coset g] Let the kernel synthesizer find the lifts and hyperplane. on P separates a point set; of H over D separates the elements of subgroup H (or the coset g·H) from the rest of subgroup D, using the entries of each matrix as coordinates.
eval eval r * s * r · eval R(pi/4) * R(pi/4) on (1, 0) Without on, evaluate a word to a matrix (element mode). With on, apply it to a point (point mode).
classify classify C on (1, 0) · classify C of r * s [on (..)] [expect 0/1] Run a classifier on a point, or on the element a word denotes; expect makes the interpreter report PASS/FAIL.
verify verify C = H over D Check classifier C against membership in subgroup H for every element of D.
check check R(pi/4) * R(pi/4) == R(pi/2) Check that two words fold to the same matrix. For all-phasor words the equality is proved symbolically (angle sums equal mod $2\pi$, no tolerance); otherwise it falls back to a numeric comparison.
sweep sweep Wedge over R from 0 to 2*pi steps 360 Compare a sector classifier with the analytic arc test on the half-open grid $[a, b)$ of steps angles of the parametrised generator R, applied to $(1, 0)$.

Generator kinds

Kind Argument Matrix
matrix rows of expressions the given square matrix (2×2, 3×3 or 4×4; not allowed for parametrised generators)
rotation angle in degrees $\begin{pmatrix}\cos\theta & -\sin\theta\\ \sin\theta & \cos\theta\end{pmatrix}$
reflection angle in degrees $\begin{pmatrix}\cos 2\theta & \sin 2\theta\\ \sin 2\theta & -\cos 2\theta\end{pmatrix}$
phasor angle in radians the same rotation matrix; the angle stays an exact AlgebraicTuple for check

Words

A word is g1 * g2 * ...; each factor is a generator name, optionally with an argument (R(pi/4)) for parametrised generators, optionally raised to an integer power (r^3, s^-1; a negative power inverts). e is the identity (the group needs at least one generator to fix its dimension). Factors multiply left to right, with the rightmost factor acting first.

Expressions

Item Details
Operators + - * /, unary -, parentheses
Constant pi, the exact tuple $\{0, 1\}$ (cannot be used as a parameter name)
Functions abs, sqrt, relu, tanh, sin, cos (anything else: ParseError: unknown function)
Exactness +, -, scalar *, scalar / keep pi terms exact; abs/relu keep exactness; sqrt/tanh/sin/cos and products of two pi terms lower to double

Errors

All errors derive from SimmyNetError (simmynet::SimmyNetError in C++, simmynet.SimmyNetError in Python).

Error Raised for Example message
LexError a character no token matches line 1: unexpected character '@'
ParseError syntax errors line 1: unknown statement 'frobnicate' · line 1: unterminated group 'G' · empty program: expected at least one 'group' block · line 1: expected an identifier but found ')'
CompileError semantic errors; every message is prefixed group NAME, line N: unknown generator 'q' · generator 'r' already defined · sector width 9.4248 rad must lie in (0, 2*pi) · the same point appears with two different labels; no feature lift can separate it · subgroup is infinite or larger than 2048 elements · no separating lift found with at most 3 basis functions (flat) or two composed levels
SimmyNetRuntimeError run-time evaluation errors division by zero in expression · math domain error in sqrt · wrong input dimension for a classifier

Examples

The built-in demonstrations (simmynet_cli with no arguments; sources in include/simmynet/Examples.hpp) include these.

Dihedral group $D_4$

group D4 {
    gen r = rotation(90)
    gen s = matrix([[-1, 0], [0, 1]])
    subgroup D = span(r, s)
    subgroup H = span(s)
    separate InH { weight = [0, 0, 0, 1], bias = -0.5 }
    eval r * s * r
    classify InH of r * s * r expect 1
    verify InH = H over D
}

Automatic lift discovery (XOR)

group XORSpace {
    space Points { (0, 0) class 0  (1, 0) class 1  (0, 1) class 1  (1, 1) class 0 }
    synthesize XorAuto on Points
    classify XorAuto on (1, 0) expect 1
    classify XorAuto on (1, 1) expect 0
}

The synthesizer proves the points are not linearly separable and finds the lift k1 = abs(x - y) with weight [0, 0, 1] and bias -0.5.

Continuous rotations with exact angles

group ContinuousSO2 {
    gen R(theta) = phasor(theta)
    sector Wedge  = [pi/4, 3*pi/4]
    sector Reflex = [pi/2, 2*pi]
    check R(pi/4) * R(pi/4) == R(pi/2)           # proved: 0.5*pi == 0.5*pi
    classify Wedge of R(pi/4) * R(pi/4) on (1, 0) expect 1
    sweep Wedge over R from 0 to 2*pi steps 8
}

Command line

simmynet_cli [--verbose|-v] [--quick|-q] [program.sym ...]

With no files it runs the built-in demonstrations. -v prints the full transcript (lexer, compiler, per-layer trace), -q only the summary line, -h prints usage. Exit status: 0 every check passed, 1 a check failed, 2 usage, parse or compile error.


Back to top

SimmyNet v2.2.0 · MIT License · © 2026 Mohamed Ehab

This site uses Just the Docs, a documentation theme for Jekyll.