grammar
Current grammar
This is a reference for the executable today, not a permanent language specification. Start with the examples if the answer model is new to you.
Concepts and composition
| Form | Meaning |
|---|---|
[] | No Concept |
[name] | Named Concept |
["escaped text"] | Named Concept containing escaped UTF-8 text |
{memory} | Percept reference; the computed global Percept {*} is read-only |
{"escaped text"} | Percept reference containing escaped UTF-8 text |
[A]->[B]->[C] | Ordered Concept |
[A][B] | Unordered Concept containing A and B |
(expression) | Keep the complete expression as one surrounding member |
[A]*[B] | Merge direct unordered members |
[A]/[B] | Merge with an inverted right side |
![A] | Inverted member |
x2[A] | Two copies of the next complete member; x1 is omitted |
Use [name] for names made from ASCII letters, digits, spaces, _, and -. Use ["escaped text"] for other UTF-8 text. Escapes include \", \\, \0, \b, \t, \n, \f, \r, and \u{...}. Both forms create opaque named Concepts; ["cat"] formats as [cat].
[] is no Concept. [""] is a normal named Concept whose name is the empty string. The same escaped text form works for Percepts, including {""}. Represent an absent optional relationship by leaving that relationship out.
Memory, questions, and choice
| Form | Meaning |
|---|---|
{memory} = expression | Replace a Percept value |
{memory} += expression | Add to its current value |
{memory} -= expression | Subtract from its current value |
{memory} *= expression | Merge direct members into its current value |
{memory} /= expression | Inverse-merge from its current value |
{memory} ~= expression | Capture assigned inputs and remember one complete experience |
subject @ question | Fill blanks from a Concept or one or more Percepts |
{target} @+= {evidence} | Add matching sources from another linked answer |
{target} @-= {evidence} | Subtract matching sources from another linked answer |
&operand | Return the shared answer shape behind linked Percepts |
$operand | Read Percepts without changing their shared answer |
^operand | Choose one result and update every linked output |
${*} | Inspect the ordinary Concepts currently live in the engine |
Questions
The left side of @ may be one structural Concept, one Percept, or an unordered default-coefficient set of Percepts. A selected Percept supplies the complete Concepts retained under it. The read-only global Percept {*} supplies the live ordinary Concepts in the engine. In a structural subject, embedded Percepts remain represented references; use $ to evaluate them. In the question, Percepts are blanks.
Fixed structure participates in matching, but the current unordered matcher can keep extra context from either side. A completed row can therefore contain a detail supplied only by the question. Its presence in the result does not by itself establish that it was observed. The Rust Answer API retains these remainders; their direct language interface remains open.
An unordered collection of ordered relationships forms a question graph. Repeating one Percept connects the relationships through a shared blank. A flat ordered question can also match a contiguous part of a longer ordered Concept. Equal values at different positions remain distinct while matching.
Question parts without a shared blank stay within one complete source. Repeating a Percept can connect relationships across separate sources.
Shared answers
@ returns complete rows and writes its output Percepts. Rows may retain Percept references supplied by the subject. Every output from that question remains linked to one correlated answer. &{output} reveals the shared question shape, and $(&{output}) reads the complete rows. An unlinked Percept has no shared answer.
Every selected source Percept on the left of @ can add support to matching results. When a current value should only restrict the question, read it with $ inside the question instead.
Materialized results obey ordinary coefficient composition. The current wildcard question x2[A] @ {part}finds both x2[A] and its inner [A], producing x3[A]. The linked Answer retains both complete possibilities. Inverted members can cancel in a materialized result without erasing that Answer.
A question shape can itself be questioned, for example (&{animal}) @ {left}->{right}. Reading these linked outputs substitutes their bindings once, keeping any captured Percept references. Another $ can then read those references. Ordinary detached values are followed recursively. These evaluation boundaries remain prototype behavior.
^ chooses the greatest positive current weight, with canonical order as the tie break. It keeps only complete rows compatible with that result and recalculates every linked output. Any linked subset can be chosen together. Separate choices may differ because the first changes what remains for the second.
Reusing linked outputs as blanks in a later question joins compatible old and new rows. An incompatible extension changes nothing. Asking again with every output from one answer starts a new cycle. Assignment detaches an output; copying a $ read makes an independent branch.
@+= and @-= compare the written part of one linked target answer with the written part of another linked answer. Matching sources are added or subtracted, and every target output moves to the new answer revision. Only the target is published, so a separate source answer stays unchanged. Either side can be one Percept or a larger shape. A mixed, detached, or unlinked operand is an error; ordinary += and -= remain ordinary Percept value operations.
Experience and inputs
Repeating the same ~= experience raises that remembered item's integer weight. Output reads combine the source support reaching each result. These integers are not defined as probabilities, logits, confidence, or truth.
= provides a replaceable current input. When ~= sees an assigned Percept, it captures the value held at that moment. Later changes do not rewrite old experience, and an empty required input records no partial observation. A Percept populated through experience remains a reference; use $ to follow it explicitly.
Boundaries and coefficients
Parentheses make one complete surrounding member, while * opens its operands and merges their direct members. Canonical output preserves that distinction. Arrow chains are flat unless parentheses explicitly nest one ordered Concept.
A coefficient is signed 64-bit structure on the next complete member. It can be matched exactly, but x2 does not automatically mean two events or twice the confidence. Inversion also remains structure unless an explicit program uses it in a calculation.
Scripts
- Separate statements with semicolons.
- Use
//for a line comment and/* ... */for a block comment. - Canonical output adds parentheses only when they are needed to preserve grouping or ordered nesting.
- The console's
helpcommand is the shortest parser reference. - The CLI console's
inspect operandcommand shows linked strengths, row counts, signed source contributions, and top ties. It is a console diagnostic, not.paesyntax or a workbench operator.