Pangine

examples

Learn Pangine through examples

These are literal transcripts from the current console. Text after command> is the input; indented text is the exact output.

Each section starts with a fresh console unless its transcript includes the earlier setup. Names such as cat, is-a, and gave have no built-in meaning.

1. Make a Concept

command> []
  []
command> [cat]
  [cat]
command> [cat]->[purrs]
  {[cat]->[purrs]}
command> [cat][dog]
  [cat]
  [dog]

[] is no Concept. Square brackets make a named Concept. An arrow makes one ordered Concept, and writing Concepts beside one another makes an unordered Concept. The braces around arrow output are Pangine's canonical spelling.

2. Remember statements and ask for their shape

command> ['memory'] ~= [cat]->[purrs]
  {[cat]->[purrs]}
command> ['memory'] ~= [dog]->[barks]
  {[cat]->[purrs]}
  {[dog]->[barks]}
command> ['memory'] @ ['animal']->['sound']
  {[cat]->[purrs]}
  {[dog]->[barks]}
command> $['animal']
  [cat]
  [dog]
command> $['sound']
  [barks]
  [purrs]

A quoted name is a Percept, Pangine's mutable reference. ~= remembers one complete statement under ['memory']. In a question, quoted Percepts are blanks. @ returns every complete answer, while $ lets us inspect one blank afterward.

The complete answer is more informative than either column alone because it keeps cat with purrs and dog with barks.

3. Capture current input values as experience

command> ['context-input'] = [opal]
  [opal]
command> ['reading-input'] = [cedar]
  [cedar]
command> ['observations'] ~= [observation]->[context]->['context-input']->[reading]->['reading-input']
  {[observation]->[context]->[opal]->[reading]->[cedar]}
command> ['reading-input'] = [violet]
  [violet]
command> ['observations'] ~= [observation]->[context]->['context-input']->[reading]->['reading-input']
  {[observation]->[context]->[opal]->[reading]->[cedar]}
  {[observation]->[context]->[opal]->[reading]->[violet]}

= gives each input Percept its current value. When ~= remembers the observation, Pangine replaces those assigned Percepts with the values they hold at that moment. Changing the reading creates a second observation and leaves the first one unchanged.

If an assigned input has no value, Pangine remembers no partial observation. A Percept that was itself filled with ~= remains a reference inside another experience; use $ when you explicitly want to follow it.

4. Ask for two connected relationships

command> ['knowledge'] ~= [Socrates]->[is-a]->[human]
  {[Socrates]->[is-a]->[human]}
command> ['knowledge'] ~= [human]->[is-a]->[mortal]
  {[Socrates]->[is-a]->[human]}
  {[human]->[is-a]->[mortal]}
command> ['knowledge'] @ ([Socrates]->[is-a]->['kind'])(['kind']->[is-a]->['conclusion'])
  {[Socrates]->[is-a]->[human]}
  {[human]->[is-a]->[mortal]}
command> $['conclusion']
  [mortal]

The question contains two ordered relationships. The same ['kind'] blank appears at the end of the first and the beginning of the second, so both parts must agree on [human].

Pangine has no special syllogism rule and gives [is-a] no built-in meaning. The question supplies the connection.

5. Keep equal values at different positions separate

command> [Alice]->[gave]->[book]->[to]->[Bob]->[gap]->[Carol]->[gave]->[book]->[to]->[Dave] @ (['giver']->[gave]->['thing'])(['thing']->[to]->['receiver'])
  {[Alice]->[gave]->[book]}{[book]->[to]->[Bob]}
  {[Carol]->[gave]->[book]}{[book]->[to]->[Dave]}
command> $['receiver']
  [Bob]
  [Dave]

The same [book] Concept occurs twice in the long ordered value. The shared ['thing'] blank asks for two overlapping pieces around one represented occurrence. Pangine keeps the local pairings and does not invent Alice with Dave or Carol with Bob.

6. Keep complete experiences from mixing

command> ['pairs'] ~= (([person]->[Alice])([pet]->[cat]))
  {[person]->[Alice]}
  {[pet]->[cat]}
command> ['pairs'] ~= (([person]->[Bob])([pet]->[dog]))
  {[person]->[Alice]}{[pet]->[cat]}
  {[person]->[Bob]}{[pet]->[dog]}
command> ['pairs'] @ ([person]->['who'])([pet]->['animal'])
  {[person]->[Alice]}{[pet]->[cat]}
  {[person]->[Bob]}{[pet]->[dog]}

Each ~= operation remembers one complete person-and-pet experience. The question searches each selected experience and all of its parts recursively. Because its two parts do not share a Percept, their matches stay connected through a complete source: Alice stays with cat and Bob stays with dog. Repeating an equal experience would add support to its complete answer without mixing the pairs.

7. Keep possibilities, then choose one

command> ['world'] ~= [morning]->[birds]
  {[morning]->[birds]}
command> ['world'] ~= [morning]->[birds]
  x2 {[morning]->[birds]}
command> ['world'] ~= [morning]->[traffic]
  x2 {[morning]->[birds]}
  {[morning]->[traffic]}
command> ['world'] @ [morning]->['answer']
  {[morning]->[birds]}
  {[morning]->[traffic]}
command> $['answer']
  x2 [birds]
  [traffic]
command> ^['answer']
  [birds]
command> $['answer']
  x2 [birds]

Repeating an equal experience raises its current integer weight. Pangine prints two copies as x2 and leaves the ordinary x1 invisible. @ still returns both complete possibilities.

The current ^ rule chooses the greatest positive weight and uses canonical order to break a tie. It is a deterministic placeholder, not a learned sampler or probability calculation. The final read shows that collapse also updates the chosen output Percept.

8. Keep several outputs in one answer

command> ['memory'] ~= [cat]->[purrs]
  {[cat]->[purrs]}
command> ['memory'] ~= [cat]->[purrs]
  x2 {[cat]->[purrs]}
command> ['memory'] ~= [dog]->[barks]
  x2 {[cat]->[purrs]}
  {[dog]->[barks]}
command> ['memory'] @ ['animal']->['sound']
  {[cat]->[purrs]}
  {[dog]->[barks]}
command> &['animal']
  {['animal']->['sound']}
command> $(&['animal'])
  x2 {[cat]->[purrs]}
  {[dog]->[barks]}
command> ^['animal']
  [cat]
command> $['sound']
  x2 [purrs]

The two output Percepts still refer to one shared set of possible rows after @. &['animal'] reveals the question shape linking them. Passing that shape to $ reads the complete possibilities without changing anything, keeping cat with purrs and dog with barks.

Choosing animal collapses the complete answer to the cat row. Sound is then read again from what remains, so barks is gone. You can choose several linked outputs at once with ^(['animal']->['sound']). If a question has more outputs, that operand can name any subset. Separate choices can produce a different result when the first choice changes the weights seen by the second.

9. Extend an answer through a shared Percept

command> ([cat]->[eats]->[fish])([dog]->[eats]->[bone]) @ ['animal']->[eats]->['food']
  {[cat]->[eats]->[fish]}
  {[dog]->[eats]->[bone]}
command> ([cat]->[lives-in]->[house])([dog]->[lives-in]->[yard]) @ ['animal']->[lives-in]->['home']
  {[cat]->[eats]->[fish]}{[cat]->[lives-in]->[house]}
  {[dog]->[eats]->[bone]}{[dog]->[lives-in]->[yard]}
command> &['animal']
  {['animal']->[eats]->['food']}
  {['animal']->[lives-in]->['home']}
command> $(&['animal'])
  x2({[cat]->[eats]->[fish]}{[cat]->[lives-in]->[house]})
  x2({[dog]->[eats]->[bone]}{[dog]->[lives-in]->[yard]})

The second question reuses ['animal'] and adds ['home']. Pangine treats the repeated Percept as the same blank, joins compatible complete answers, and links animal, food, and home to the larger result. The value returned by the second @ grounds both question shapes at once.

A question can also connect two existing answers. An incompatible extension returns [] and leaves the old answers unchanged. Asking again with every output from one answer starts a new cycle. Assignment or a copied $ read remains the explicit way to make a detached branch.

10. Adjust one answer with another

command> ['candidates'] ~= [inspect]->[dumpbin]
  {[inspect]->[dumpbin]}
command> ['candidates'] ~= [reconfigure]->[cmake]
  {[inspect]->[dumpbin]}
  {[reconfigure]->[cmake]}
command> ['helpful'] ~= [inspect]->[dumpbin]
  {[inspect]->[dumpbin]}
command> ['failed'] ~= [inspect]->[dumpbin]
  {[inspect]->[dumpbin]}
command> ['failed'] ~= [inspect]->[dumpbin]
  x2 {[inspect]->[dumpbin]}
command> ['candidates'] @ ['action']->['tool']
  {[inspect]->[dumpbin]}
  {[reconfigure]->[cmake]}
command> ['helpful'] @ ['helpful-action']->['helpful-tool']
  {[inspect]->[dumpbin]}
command> ['action']->['tool'] @+= ['helpful-action']->['helpful-tool']
  x2 {[inspect]->[dumpbin]}
  {[reconfigure]->[cmake]}
command> ['failed'] @ ['failed-action']->['failed-tool']
  {[inspect]->[dumpbin]}
command> ['action']->['tool'] @-= ['failed-action']->['failed-tool']
  {[reconfigure]->[cmake]}
command> inspect ['action']->['tool']
    +0, 1 row: {[inspect]->[dumpbin]}
      +1 from ['candidates']: {[inspect]->[dumpbin]}
      -2 from ['failed']: {[inspect]->[dumpbin]}
      +1 from ['helpful']: {[inspect]->[dumpbin]}
  * +1, 1 row: {[reconfigure]->[cmake]}
      +1 from ['candidates']: {[reconfigure]->[cmake]}
command> &['action']
  {['action']->['tool']}
command> ^(['action']->['tool'])
  {[reconfigure]->[cmake]}

The first three questions form separate linked answers for candidates, helpful results, and failed results. The written pair on each side tells Pangine to compare complete action-tool values. @+= adds the helpful source to the matching candidate. @-= then subtracts two failed observations, bringing inspect-dumpbin to zero and leaving reconfigure-cmake as the positive choice.

The CLI console's inspect command shows the complete sources behind both strengths. The * marks the current top result. This is diagnostic output rather than a Pangine operator, so it does not add source metadata to the answer.

&['action'] shows that action and tool are still one linked answer after both updates. The source answers are unchanged. A one-Percept operand would update every candidate row sharing that one value; the larger shape used here matches the complete pair.

What these examples demonstrate

The same grammar handles current input capture, lookup, multi-link questions, grouped alternatives, ordered paths, repeated experience, reusable grounded rows, shared answers, answer adjustment, and collapse. Learned scoring, sampling, persistence, and a settled theory of Relevance remain open. Continue to the grammar page for the compact reference.

Run the console or a complete program

git clone https://github.com/caustik/pangine.git
cd pangine
cargo run --bin pangine-console

The checked-in route cycle builds three complete routes, uses current result values to filter recorded episodes, records two failures, changes its choice, then strengthens the new route after a success. Run every command from the file with:

cargo run --bin pangine-console -- examples/route-cycle.pae

The settings program uses the same engine behavior for a different shape. It keeps three outputs linked, chooses them at once, returns one complete setting Concept, and remembers the supplied result:

cargo run --bin pangine-console -- examples/settings-choice.pae