BRAIDGROUP
RESEARCH & DEV
71. Library Docs

Diameter Reasoning

Overview

Diameter Logic is Braid's native dialectical reasoning framework. It models decision-making and inference as a dynamic tension between two opposing poles (thesis and antithesis), from which a synthesis emerges through resonance. This is inspired by Hegelian dialectics and reframed as a computational pattern: any proposition can be reasoned about by holding two opposing views in tension and letting a higher-order resolution crystallize.

Core Concepts

ConceptDescription
PoleOne extreme of a dialectic — a thesis or antithesis position
ThesisThe initial proposition or affirmative stance
AntithesisThe opposing or negating stance
TensionThe dynamic friction between poles that drives reasoning forward
ResonanceThe constructive synthesis that emerges from sustained tension
Observe / EvolveA cycle: observe the current state of tension, evolve toward synthesis

std.diameter_patterns

The std.diameter_patterns module provides predefined dialectical patterns as reusable Braid functions. Each pattern creates a diameter block with named poles.

import std.diameter_patterns

fn main() {
    # Decision making: weigh two options
    let decision = decide("invest", "save")
    io.println(decision)

    # Risk assessment
    let risk = assess_risk(system_state)
    io.println(risk)

    # Creative tension: constraint vs freedom
    let art = creative_tension("budget limit", "maximum creativity")

    # Ethical reasoning: utilitarian vs deontological
    let ethics = ethical_diameter("autonomous vehicle choice")

    # Adversarial reasoning
    let war = adversarial("attack vector", "defense mechanism")
}
PatternPolesUse Case
decide(A, B)option_a / option_bBinary decision making
assess_risk(system)safe / dangerRisk analysis
creative_tension(c, f)form / flowDesign tradeoffs
ethical_diameter(action)utilitarian / deontologicalMoral reasoning
adversarial(a, d)red / blueSecurity analysis

NeuralDiameter — DTS + Dialectics

The NeuralDiameter type (declared in dts_neural.h) bridges DTS knowledge graphs with dialectical reasoning. A NeuralDiameter holds tensor representations of the thesis and antithesis, plus a computed tension magnitude.

# C API — accessible via native bindings
NeuralDiameter* nd = neural_diameter_create(thesis_tensor, antithesis_tensor);
ObjTensor* synthesis = neural_diameter_synthesize(nd, context_tensor);
double tension = nd->tension_magnitude;
neural_diameter_free(nd);
FunctionDescription
neural_diameter_create(thesis, antithesis)Create a NeuralDiameter from two opposing tensor viewpoints
neural_diameter_synthesize(nd, context)Merge DTS knowledge context with dialectical reasoning to produce a synthesis tensor
neural_diameter_free(nd)Free the NeuralDiameter and its tensors

The DiameterTrainState (from diameter_train.h) provides training infrastructure for dialectical reasoning in transformer models:

FunctionDescription
diameter_train_init(d_model, window, alpha)Initialize a diameter training state
diameter_train_step(state, hidden, context)Run one dialectical training step
diameter_train_get_target(state)Get the current synthesis target tensor
diameter_train_update_critics(state, ...)Update block critics with diameter feedback

Example: Simple Logic Gate (Dialectical AND)

import std.diameter_patterns
import std.math

fn dialectical_and(a: int, b: int) -> int {
    let decision = decide(a, b)
    # Synthesize: both poles must agree for true AND
    if a == 1 && b == 1 {
        return 1
    }
    return 0
}

fn main() {
    io.print_int(dialectical_and(1, 1))  # 1
    io.print_int(dialectical_and(1, 0))  # 0
    io.print_int(dialectical_and(0, 0))  # 0
}

Example: Contradiction Resolution

import std.diameter_patterns

fn resolve_contradiction(claim_a: string, claim_b: string) -> string {
    let diameter = creative_tension(claim_a, claim_b)
    # The tension between form and flow produces a synthesis
    if claim_a == claim_b {
        return claim_a
    }
    # Synthesize by finding common ground
    return "Synthesis: " + claim_a + " and " + claim_b
}

fn main() {
    let result = resolve_contradiction(
        "The system should be fast",
        "The system should be secure"
    )
    io.println(result)
    # Output: "Synthesis: The system should be fast and The system should be secure"
}

Example: DTS-Augmented Dialectical Reasoning

import std.dts
import std.diameter_patterns

fn reason_with_knowledge(topic: string, context: string) {
    # Load knowledge into DTS
    let knowledge = dts.analyze(context)
    dts.train(knowledge, context)
    dts.bind_axiom(knowledge, "ground_truth", 1)

    # Form dialectic from knowledge base
    let thesis = dts.predict(knowledge, topic)
    let antithesis = dts.predict(knowledge, "not " + topic)

    # Resolve through diameter pattern
    let decision = decide(thesis, antithesis)
    dts.store(decision, "reasoning")

    io.print("Thesis: ")
    io.println(thesis)
    io.print("Antithesis: ")
    io.println(antithesis)
    io.print("Synthesis: ")
    io.println(decision)
}

fn main() {
    reason_with_knowledge("quantum computing",
        "Quantum computing uses qubits. Quantum computers can solve certain problems faster than classical computers. Quantum computing is still an emerging technology.")
}

Decision-Making with Diameter

Diameter reasoning is especially powerful for complex decisions with tradeoffs. The pros/cons, contradictions, and opposing viewpoints are each modeled as poles in a diameter block.

import std.diameter_patterns

fn weigh_pros_cons(proposals: [string]) -> string {
    if len(proposals) == 0 {
        return "No options"
    }
    if len(proposals) == 1 {
        return proposals[0]
    }
    let result = proposals[0]
    let i = 1
    while i < len(proposals) {
        let d = decide(result, proposals[i])
        # Synthesis emerges from each pairwise dialectic
        result = d
        i = i + 1
    }
    return result
}

fn main() {
    let best = weigh_pros_cons([
        "Option A: low cost, medium quality",
        "Option B: medium cost, high quality",
        "Option C: high cost, highest quality"
    ])
    io.println(best)
}

Pattern Library

PatternTypeDescription
DeductiveTop-downGeneral rule → specific conclusion
InductiveBottom-upSpecific observations → general rule
AbductiveInference to best explanationObservation → most likely cause
AnalogicalComparativeKnown domain → unknown domain
DialecticalOppositionalThesis ↔ Antithesis → Synthesis

Each pattern can be implemented as a diameter block. The dialectical pattern is the foundational meta-pattern — all other reasoning modes can be modeled as a tension between complementary approaches.

Source Files

  • braid-lang/lib/std/diameter_patterns.bd — Braid-language diameter patterns
  • braid-lang/include/dts_neural.h — NeuralDiameter type and C API
  • braid-lang/include/diameter_train.h — DiameterTrainState training API
  • braid-lang/src/runtime/dts_neural_bridge.c — Neural bridge implementation