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 |
subject @~ question | Ask the same question, also composing parts and generalizing from similar cases |
{target} @+= {evidence} | Add the evidence of matching rows from another linked answer |
{target} @-= {evidence} | Subtract the evidence of matching rows 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 |
^~operand | Draw one result by probability 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.
@~ asks the same question and also lets parts without a shared blank come from separate experiences. Those composed rows are labeled, and a graded answer's probabilities interpolate from the rows seen whole toward the composed ones with the Witten-Bell rule, so whole observations keep priority. Reading one output of a graded answer adds the complete rows that give each value, so it agrees with reading them all. A graded $ shows each probability as a share of a common denominator. With only exact rows, @~ answers exactly like @.
@~ also compares the question with each remembered experience as one complete case whose names may differ. The distance counts each name occurrence that differs, plus one for each extra value that a name the question repeats would take, and each distance forms one more level below the composed answers. A case counts only if it shares a name with the question and supplies each part of the question from a different part of itself. An answer that sits where a changed question name sits maps back to that name. Only names inside ordered relationships can change.
Probabilities stay exact fractions while their arithmetic fits in 128 bits. When a graded $ would need shares too large for its 64-bit evidence counts, it shows millionths that add up to one million, and past 128 bits the interpolation continues in fixed point. The arithmetic is integer throughout, so the console and this site compute the same values.
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 most probable current value, 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.
^~ draws a value with probability equal to its share instead, using the interpolated probabilities of a graded answer, and collapses the answer the same way. When no value has positive evidence, it returns []. Each engine draws from its own generator, which starts at seed 0, so the same commands draw the same values in every run.
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. The evidence of matching rows is added or subtracted, and every target output moves to the updated answer. Only the target changes, 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.
Evidence imported from a graded answer keeps its grade, so a case that only resembles the target counts below the target's own evidence. A graded answer cannot itself be adjusted, because one value can sit in rows of several grades.
Experience and inputs
Repeating the same ~= experience adds one to that remembered item's evidence count. Output reads combine the source support reaching each result. An answer reads the counts as probabilities: each value's share of the positive evidence among the alternatives. A value whose evidence is zero or negative has probability zero. The probability is the relative frequency of remembered experience, not a calibrated confidence or truth. A row joined from separate experiences weighs the product of their counts, while one experience that proves several parts of a row counts once.
= 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 console's
inspect operandcommand lists linked values from most to least probable, with their evidence counts, probabilities, row counts, signed source contributions, and top ties. - The console's
seed ncommand restarts the generator that^~draws from at seedn. A new console or workbench session starts at seed 0. - The console's
partitions ncommand divides remembered experience amongnpartition engines, andpartitionslists what each one holds.drop partition kloses one partition and the experience in it. Answers do not depend on how experience is divided. help,inspect,seed,partitions, anddrop partitionwork the same in the CLI console and the workbench. They are console commands, not.paesyntax.