Language reference

This page is a compact reference for the current pre-1.0 language. The canonical machine-oriented grammar is Cognia/grammar.cognia; if this page and the grammar disagree, the grammar and validator define accepted syntax. Runtime support is a separate question covered on the Limitations page.

Lexical rules

  • Identifiers are case-sensitive.
  • Strings use double quotes.
  • Numbers may be integer or floating point.
  • Dotted paths address nested instances and endpoints.
  • Statements normally end with ;; declarations and blocks use braces.
  • Keywords are contextual and can be valid identifiers elsewhere.

Top-level declarations

Declaration Purpose
cognia "version"; Language version pragma
seed N; Deterministic topology and random initialization seed
source External sensory source metadata
event Named condition for event-driven behavior
chemistry Global modulators and baselines
neuron Reusable neural unit type
population Homogeneous array of neurons
circuit Reusable composition and connectivity
construct Parameterized structural abstraction with ports
controller Trainable control component with observe/control ports
module Cognitive region with memory, attention, growth or polarization
network Executable graph and its outputs
brain Composition of networks and communication channels

Neuron state

Common runtime-recognized fields are:

Field Meaning
activation Initial continuous state
leak Retained fraction / intrinsic timescale; also used for layer inference
bias Additive input bias
gain Multiplier applied to normalized net drive

Neuron bodies may declare input/output behavior, decay, emitted events and firing probability. Continuous activation and stochastic firing are both introspectable.

Population and composition

population Name {
    neurons {
        endpoint: NeuronType[COUNT];
    }
}

use Type as instance; creates an instance inside a circuit, module, construct, controller, network or brain where allowed. expose and interface blocks provide stable boundaries instead of coupling callers to nested internals.

Construct parameters can be used for dimensions and structural values. Constructs may create and connect structure but do not own learning policy.

Connections

connect source.path -> target.path {
    pattern: full;
    weight: 0.2;
    delay: 0;
    plasticity: none;
}

Supported pattern families:

Pattern Meaning
full Every source connects to every target
one_to_one Matching indices; endpoint sizes must agree
broadcast Broadcast compatible source to target region
random(p) Seeded sparse connectivity with probability/density p
local(...) Neighborhood-limited connectivity
chain Ordered sequential connectivity

delay is an integer number of propagation ticks. Delayed edges read source activity from a ring buffer. A zero delay retains the fast path.

Weights may be constants, seeded distributions or chemistry-affine expressions. Current runtime lowering represents a chemistry-aware weight as a base multiplied/modulated by one declared chemical value.

Plasticity

Recognized rule names include:

Rule Runtime behavior
omitted, none, fixed, frozen No runtime weight update
hebbian, temporal Hebbian-style update
oja Oja normalization update
chl Training-time contrastive Hebbian intent; not a general runtime rule

Rates may be chemistry-modulated. Synaptic homeostasis can cap mean incoming absolute weight after updates. Supervised readout training is invoked by tooling, not automatically by the declaration alone.

Modules

Modules can declare:

  • neuron groups and internal connections;
  • memory behavior and persistence;
  • ignition and workspace participation;
  • focus, settling, preemption and habituation;
  • structural growth and pruning constraints;
  • a two-dimensional polarized state.

A polarized module assigns neurons fixed directions and maintains a module direction vector. Activity is biased by alignment to that vector; activity also updates the vector, producing a continuous context state. See Controllers and polarization for equations and responsible interpretation.

Controllers

A controller declares input observations and control outputs:

controller Steering {
    interface {
        observe observation[4];
        control gate gate_value[1];
        control select choice[3];
        control polarization direction[2];
    }
    // controller substrate and training metadata
}

Network bindings connect observations to the controller and controls to a target. Gate controls scale a path, select controls choose/rank alternatives, and polarization controls steer a polarized module. A polarization control source has width two; its target must be polarized; strength is a compile-time value in [0,1]; one polarization unit can have at most one controller.

Attention and competition

Workspace competition operates over the top layer and its modules. Relevant declarations configure:

  • ignition threshold;
  • winner selection and suppression of rivals;
  • focus settling and maximum steps;
  • stronger-signal preemption;
  • novelty-based release/habituation;
  • growth/pruning constraints.

The runtime also tracks per-module salience, boredom, excitation and refractory state. These are available through snapshots and /_stats.

Outputs

output signal from region.cells as alarm;

output text from words.cells as token {
    vocab: "yes", "no";
}

output classification from classes.cells as intent {
    vocab: "slow", "recover";
    loss: softmax_cross_entropy;
}
  • signal: mean activation interpreted as a boolean with hysteresis in stateful output pumping.
  • text: argmax decoder over a vocabulary.
  • classification: logit-based argmax/softmax output intended for supervised classification.

A vocabulary may be inline or loaded from a declared vocabulary file where supported by the declaration.

Learning, clamp and growth blocks

The grammar can express local plasticity, learning phases, clamping, memory and structural growth policies. Today, command-line trainers implement the reliable supervised paths directly. Do not assume that every declarative training phase is executed merely because it validates.

Growth settings include pruning/activity thresholds, new-edge weight, rate modulation, adjacency constraints, sensory protection and maximum synapse count. Growth changes graph structure during execution and should be bounded for reproducibility.

Expressions

Expressions support numeric and boolean operators, identifiers and selected functions/distributions. Context determines whether an expression must constant-fold during compilation or may be evaluated at runtime. Dimensions, connection density, control strength and similar structural values generally must be compile-time resolvable.

Semantic guarantees

The semantic analyzer checks, among other constraints:

  • duplicate and missing declarations;
  • nested endpoint resolution;
  • endpoint width compatibility;
  • valid competition participants;
  • declared chemistry references;
  • publish/subscribe channel flow compatibility;
  • controller port kinds and control target compatibility;
  • polarization controller uniqueness and range constraints.

Warnings may identify a published channel with no subscriber. Errors stop topology construction.