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
| Concept | Description |
|---|---|
| Pole | One extreme of a dialectic — a thesis or antithesis position |
| Thesis | The initial proposition or affirmative stance |
| Antithesis | The opposing or negating stance |
| Tension | The dynamic friction between poles that drives reasoning forward |
| Resonance | The constructive synthesis that emerges from sustained tension |
| Observe / Evolve | A 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")
}| Pattern | Poles | Use Case |
|---|---|---|
decide(A, B) | option_a / option_b | Binary decision making |
assess_risk(system) | safe / danger | Risk analysis |
creative_tension(c, f) | form / flow | Design tradeoffs |
ethical_diameter(action) | utilitarian / deontological | Moral reasoning |
adversarial(a, d) | red / blue | Security 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);| Function | Description |
|---|---|
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:
| Function | Description |
|---|---|
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
| Pattern | Type | Description |
|---|---|---|
| Deductive | Top-down | General rule → specific conclusion |
| Inductive | Bottom-up | Specific observations → general rule |
| Abductive | Inference to best explanation | Observation → most likely cause |
| Analogical | Comparative | Known domain → unknown domain |
| Dialectical | Oppositional | Thesis ↔ 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 patternsbraid-lang/include/dts_neural.h— NeuralDiameter type and C APIbraid-lang/include/diameter_train.h— DiameterTrainState training APIbraid-lang/src/runtime/dts_neural_bridge.c— Neural bridge implementation