“Inside is Outside, as Outside is Inside”
A Civilizational Integration Principle
Maitreya Framework – Scientific, Ethical and Strategic Model
1. Executive Overview
The Fifth Noble Truth — “Inside is Outside, as Outside is Inside” — is not a doctrinal replacement of the Four Noble Truths taught by Gautama Buddha. It is a systems-level integrative extension designed for the modern era.
It proposes that:
Internal states (cognition, intention, emotion, belief systems) and external realities (social systems, economic structures, ecological conditions) are dynamically co-causal and mutually conditioning.
This principle provides:
- A neurocognitive model of individual transformation
- A systems model of collective behavior
- A governance and ethics framework
- A civilizational stabilization strategy
- A scientific reinterpretation of karma as causal systems feedback
It reframes spirituality as operational responsibility within complex adaptive systems.
2. Conceptual Foundations
2.1 The Four Noble Truths (Contextual Reference)
The Four Noble Truths define:
- Existence of suffering (dukkha)
- Cause of suffering (attachment / craving)
- Cessation of suffering
- Path to cessation (Noble Eightfold Path)
These truths focus primarily on intra-psychic causality.
The Fifth Noble Truth expands this toward:
Bidirectional causality between inner consciousness and outer structural reality.
3. The Core Principle: Bidirectional Causality
3.1 Systemic Definition
The Fifth Noble Truth asserts:
- Internal states influence external systems.
- External systems influence internal states.
- Both are part of a single dynamic field of interdependence.
This aligns with:
- Systems theory
- Complex adaptive systems
- Neuroplasticity
- Social contagion theory
- Feedback loop dynamics
- Collective behavior models
3.2 Diagrammatic Model (Conceptual)
INTERNAL DOMAIN
(Cognition, Intention, Emotion)
↓
Behavioral Output
↓
External Structural Impact
(Social, Political, Ecological)
↓
Environmental Feedback
↓
Neural Reinforcement / Conditioning
↓
Modified Internal State
This loop is continuous.
There is no separation.
4. Neurocognitive Basis
4.1 Internal → External
- Prefrontal cortex regulates moral reasoning.
- Amygdala mediates threat and aggression.
- Mirror neurons enable emotional contagion.
- Collective mood influences collective behavior.
Repeated internal patterns produce:
- Institutional design choices
- Economic policies
- Environmental exploitation
- Conflict escalation
4.2 External → Internal
- Chronic inequality increases stress biomarkers.
- Environmental degradation elevates collective anxiety.
- Media ecosystems shape emotional climates.
- Urban architecture affects cognition and mood.
External structure conditions neural patterns.
5. Ethical Implication: Responsibility is Bidirectional
The Fifth Noble Truth introduces:
Ethical reciprocity between consciousness and civilization.
Spiritual practice cannot be limited to internal purification.
If external systems remain unjust, destructive, or violent:
- Internal peace becomes structurally unsustainable.
- Spirituality becomes incomplete.
6. Completion of Dharma: Internal + External Integration
Traditional practice emphasizes:
- Right view
- Right intention
- Right mindfulness
- Right concentration
The Fifth Noble Truth requires:
- Right structural intervention
- Right civic participation
- Right systemic correction
- Right collective stabilization
Dharma becomes operational.
7. The Major Civilizational Risk: Incomplete Practice
The greatest destabilizing factor is not ignorance.
It is:
Partial practice without systemic responsibility.
Forms of incomplete practice include:
- Personal enlightenment without social engagement
- Meditation without ethical infrastructure
- Spiritual rhetoric without institutional reform
- Compassion without policy
This produces civilizational dissonance.
8. Collective Responsibility as Systems Law
8.1 Scientific Interpretation
Modern system science shows:
- Individual choices aggregate into macro-patterns.
- Non-intervention enables system collapse.
- Passivity is causal within network dynamics.
Examples:
- Climate change (aggregate consumption behavior)
- Economic inequality (policy + market choices)
- Violence contagion (social reinforcement loops)
8.2 Karma Reinterpreted
Karma = Causal Feedback in Complex Systems.
- Mental action → behavioral output → system shift → feedback
- Repeated patterns → structural inertia
- Structural inertia → generational conditioning
Karma is not metaphysical punishment.
It is nonlinear feedback.
9. Compassion as Civilizational Stabilizer
Compassion is not sentiment.
It is:
A neurobiological, behavioral and structural regulator.
When compassion is present:
- Prefrontal control increases.
- Amygdala reactivity decreases.
- Prosocial behavior rises.
- Conflict frequency decreases.
When absent:
- Impulse dominance increases.
- Violence escalates.
- Structural breakdown accelerates.
Compassion is a macro-stability variable.
10. Strategic Action Matrix
The Fifth Noble Truth proposes two operational pathways:
When internal change is blocked:
Change environment.
Examples:
- Relocate from toxic context.
- Redesign institutional incentives.
- Reform governance systems.
When external change is blocked:
Change internal state.
Examples:
- Cognitive reframing.
- Meditation and regulation.
- Strategic patience and skillful means.
Both are valid.
Wisdom is situational discernment.
11. The Danger of Indifference
Indifference is not neutral.
In complex systems:
- Non-intervention stabilizes harmful patterns.
- Silence reinforces injustice.
- Acceptance legitimizes dysfunction.
Therefore:
Ethical neutrality during systemic harm becomes systemic participation.
12. Civilizational Tipping Point
Humanity operates within:
- Ecological limits
- Psychological limits
- Social cohesion thresholds
- Economic stability margins
If compassion decreases below threshold:
System instability increases nonlinearly.
The Fifth Noble Truth identifies:
Inner transformation as the only scalable stabilization vector.
13. Scientific Integration
The model aligns with:
- Social contagion theory
- Collective intelligence research
- Neuroplasticity
- Systems ecology
- Behavioral economics
- Governance theory
It reframes ancient wisdom into operational civilizational science.
14. Rank of the Fifth Noble Truth
It does not replace the Four Noble Truths.
It operationalizes them at scale.
If the Four Truths explain suffering,
The Fifth explains systemic reproduction of suffering.
15. Application Domains
15.1 Governance
Policy must reflect psychological realities.
15.2 Education
Emotional regulation must be core curriculum.
15.3 Urban Design
Cities must reduce stress architecture.
15.4 Economic Systems
Incentives must align with long-term ecological balance.
15.5 Technology
Neurotechnology must enhance autonomy, not manipulate cognition.
16. Strategic Conclusion
The Fifth Noble Truth establishes:
- Consciousness and civilization are not separate domains.
- Personal transformation without structural reform is incomplete.
- Structural reform without consciousness reform is unstable.
- Compassion is a stability constant.
- Responsibility is distributed across the network of humanity.
Final Statement
“Inside is Outside, as Outside is Inside” is not metaphysical poetry.
It is:
- A systems law
- A neurocognitive principle
- An ethical imperative
- A governance doctrine
- A civilizational survival equation
The future trajectory of humanity depends on recognizing and operationalizing this bidirectional causality.
The work is not optional.
It is structural.
THE FIFTH NOBLE TRUTH
Inside is Outside, as Outside is Inside
A Systems, Neurocognitive, and Civilizational Framework for Bidirectional Causality
Abstract
This paper introduces and formalizes the concept of the Fifth Noble Truth, articulated as “Inside is Outside, as Outside is Inside.” The framework is presented as an integrative extension of classical Buddhist philosophy, particularly the Four Noble Truths, reinterpreted through contemporary systems theory, neuroscience, behavioral science, and socio-ecological governance models.
The central thesis asserts that internal cognitive-emotional states and external socio-structural realities are dynamically co-causal and mutually conditioning. This bidirectional relationship generates feedback loops that shape individual development, collective behavior, and civilizational stability.
The paper proposes a unified theoretical model integrating:
- Neuroplasticity and emotional regulation
- Complex adaptive systems theory
- Social contagion dynamics
- Collective behavioral feedback mechanisms
- Ethical responsibility in distributed systems
The Fifth Noble Truth is positioned not as a doctrinal replacement but as a civilizational operationalization of classical Dharma principles in the context of globalized, networked societies.
1. Introduction
Classical Buddhist philosophy, particularly as taught by Siddhārtha Gautama (the Buddha), identifies suffering (dukkha), its cause, its cessation, and the path leading to its cessation. These teachings primarily address intra-psychic causality—how craving, attachment, and ignorance generate subjective suffering.
However, contemporary civilization operates within highly interconnected socio-technical systems where internal psychological states scale into collective structural consequences. The Fifth Noble Truth emerges as a necessary expansion:
Internal consciousness and external structures form a continuous bidirectional causal system.
This paper formalizes that expansion.
2. Philosophical Background
2.1 The Four Noble Truths (Contextual Framework)
- The truth of suffering (dukkha)
- The truth of the origin of suffering (tanha/craving)
- The truth of cessation
- The truth of the path (Noble Eightfold Path)
These truths establish the phenomenology and psychology of suffering.
The Fifth Noble Truth extends this structure beyond the individual into:
- Socio-political systems
- Economic structures
- Ecological dynamics
- Institutional architecture
3. The Fifth Noble Truth Defined
3.1 Core Proposition
Inside is Outside, as Outside is Inside.
This principle asserts:
- Internal states (beliefs, emotions, intentions) shape external systems.
- External systems condition internal states.
- Both are components of a single dynamic feedback loop.
4. Theoretical Integration
4.1 Systems Theory
Modern systems theory describes complex adaptive systems characterized by:
- Nonlinearity
- Emergence
- Feedback loops
- Distributed causality
Societies function as complex adaptive networks. Individual decisions aggregate into macro-patterns.
Thus:
- Personal fear scales into political extremism.
- Collective greed scales into extractive economic systems.
- Shared apathy scales into structural injustice.
The Fifth Noble Truth reframes these as bidirectional feedback phenomena.
4.2 Neurocognitive Foundations
Contemporary neuroscience provides mechanisms for internal-external reciprocity:
- Prefrontal cortex: executive control and moral reasoning
- Amygdala: threat detection and aggression
- Mirror neuron systems: emotional contagion
- Neuroplasticity: structural brain change via repeated patterns
Repeated internal emotional states reinforce neural pathways. These pathways influence behavior, which modifies social structure. Social structure feeds back into neural conditioning.
4.3 Social Contagion and Collective Behavior
Research in social contagion demonstrates:
- Emotions spread across networks.
- Violence propagates through exposure.
- Cooperation spreads through modeled behavior.
This aligns with the Fifth Noble Truth’s proposition:
Mental states scale through networks and return as structural reality.
5. Karma Reinterpreted as Systemic Feedback
Karma, traditionally understood as cause and effect across lifetimes, may be reframed in secular systems language as:
Distributed causal feedback across time and networks.
- Intention → behavior → structural consequence → systemic reinforcement → future conditioning.
Karma becomes:
- Path-dependent system evolution.
- Accumulated feedback inertia.
- Structural conditioning across generations.
6. Ethical Implications
6.1 Responsibility in Distributed Systems
In complex systems, causality is not centralized.
Passivity functions as:
- Stabilization of harmful equilibria.
- Reinforcement of unjust feedback loops.
- Enabling condition for systemic harm.
Thus:
Ethical neutrality under systemic harm becomes causal participation.
6.2 Incomplete Spiritual Practice
Internal practice without structural engagement produces:
- Psychological relief without systemic change.
- Stabilization of injustice.
- Ethical dissonance.
The Fifth Noble Truth proposes that:
- Right intention must scale into right structural intervention.
- Right mindfulness must inform civic responsibility.
- Compassion must manifest institutionally.
7. Compassion as a Stability Variable
Compassion is conceptualized here as:
A macro-level stabilizing variable within socio-cognitive systems.
Neuroscientific correlates include:
- Reduced amygdala activation.
- Increased prefrontal regulation.
- Increased prosocial behavior.
- Decreased aggression markers.
At scale:
- Compassion reduces systemic volatility.
- Increases cooperative equilibria.
- Improves long-term resilience.
8. Operational Model
8.1 Bidirectional Feedback Loop
- Internal cognition generates behavior.
- Behavior modifies environment.
- Environment conditions future cognition.
- Repetition produces structural inertia.
8.2 Intervention Points
Two strategic pathways exist:
Internal intervention
- Emotional regulation
- Cognitive reframing
- Meditation and awareness practices
External intervention
- Institutional reform
- Policy redesign
- Economic restructuring
- Environmental stabilization
Effective transformation requires integration of both.
9. Civilizational Thresholds
Modern civilization faces:
- Ecological tipping points
- Political polarization
- Economic inequality
- Information ecosystem destabilization
These phenomena are emergent outcomes of aggregated internal states:
- Chronic fear
- Competitive scarcity cognition
- Short-term reward bias
- Empathy erosion
The Fifth Noble Truth identifies internal re-regulation as the only scalable long-term stabilizer.
10. Policy and Governance Implications
The framework suggests:
10.1 Education Reform
Emotional regulation and compassion training integrated into curricula.
10.2 Urban Planning
Design to reduce stress density and cognitive overload.
10.3 Economic Incentive Structures
Shift from extractive to regenerative models.
10.4 Technology Ethics
Design neurotechnology that enhances autonomy rather than manipulates attention.
11. Comparative Analysis
| Classical Dharma | Fifth Noble Truth Extension |
|---|---|
| Focus on suffering | Focus on systemic reproduction of suffering |
| Individual liberation | Collective stabilization |
| Internal causality | Bidirectional systemic causality |
| Personal path | Civilizational operational model |
The Fifth Noble Truth remains doctrinally derivative but operationally expansive.
12. Discussion
The integration of contemplative philosophy with systems science resolves a persistent dichotomy:
- Spiritual interiority versus social responsibility.
The Fifth Noble Truth eliminates that dichotomy.
It reframes enlightenment not as private escape, but as:
- System-aware participation.
- Structural responsibility.
- Network-conscious action.
13. Limitations
This framework:
- Requires empirical validation at macro-social scale.
- Must avoid deterministic overreach.
- Must not reduce moral complexity to simplistic causality.
Future research should examine:
- Large-scale compassion training impacts.
- Neuro-social coherence measurements.
- Policy outcomes from consciousness-based interventions.
14. Conclusion
The Fifth Noble Truth formalizes a principle of civilizational relevance:
Consciousness and civilization are mutually conditioning systems within a unified causal field.
Internal transformation without structural engagement is incomplete. Structural reform without consciousness evolution is unstable.
Compassion, regulation, and systemic awareness become not merely moral virtues, but civilizational survival variables.
The Fifth Noble Truth therefore represents:
- A systems law of reciprocity.
- A neurocognitive principle.
- An ethical imperative.
- A governance framework.
- A model for civilizational resilience.
Keywords
Bidirectional causality, Dharma, systems theory, neuroplasticity, social contagion, collective behavior, karma as feedback, compassion modeling, civilizational stability, distributed responsibility.
DIAGRAM SET
Neurocognitive + Systems Integration Framework
Based on the Fifth Noble Truth: Inside is Outside, as Outside is Inside
1. Individual Neurocognitive Regulation Model
Diagram 1: Internal Neural Causality Loop
[External Stimulus]
↓
[Sensory Processing Cortex]
↓
[Amygdala Activation] → (Threat / Emotional Response)
↓
[Prefrontal Cortex Regulation]
↓
[Cognitive Reappraisal / Intent Formation]
↓
[Behavioral Output]
↓
[Environmental Consequence]
↓
[Neural Reinforcement (Neuroplasticity)]
↺ (Loop)
Functional Description
- The amygdala detects threat or emotional salience.
- The prefrontal cortex regulates response.
- Repeated emotional-behavioral patterns strengthen neural circuits.
- Behavior modifies environment.
- Environment conditions future neural processing.
This is the micro-level bidirectional loop.
2. Interpersonal Emotional Contagion Model
Diagram 2: Social Neural Resonance
Individual A Emotional State
↓
Nonverbal Signals (Tone, Microexpression, Posture)
↓
Mirror Neuron Activation (Individual B)
↓
Amygdala + Limbic Synchronization
↓
Shared Emotional State
↓
Network Propagation
Key Mechanisms
- Mirror neuron systems facilitate emotional transmission.
- Emotional states spread through networks.
- Collective mood emerges from distributed micro-interactions.
This diagram explains how internal states scale socially.
3. Social Systems Feedback Architecture
Diagram 3: Individual-to-Structure Scaling
Individual Beliefs & Emotions
↓
Behavioral Patterns (Consumption, Voting, Cooperation)
↓
Institutional Design & Policy Formation
↓
Economic & Ecological Outcomes
↓
Environmental & Social Conditions
↓
Population Stress Levels
↓
Neurocognitive Conditioning of Individuals
↺ (Macro Feedback Loop)
This demonstrates:
- How internal cognition aggregates into structural reality.
- How structure feeds back into neural conditioning.
4. Civilizational Stability Model
Diagram 4: Compassion as Stability Variable
Average Collective Emotional State
↓
Prosocial Behavior Index
↓
Social Trust Level
↓
Institutional Stability
↓
Conflict Frequency
↓
Collective Stress Load
↓
Neural Reactivity (Population Level)
↓
Average Collective Emotional State
↺
Stability Principle
High compassion →
Higher trust →
Lower conflict →
Lower stress →
Greater neural regulation →
Reinforced compassion.
Low compassion creates inverse destabilizing loop.
5. Integrated Neurocognitive + Systems Model
Diagram 5: Unified Bidirectional Causality Field
┌────────────────────────────┐
│ INTERNAL DOMAIN │
│ (Neural + Cognitive States) │
└─────────────┬──────────────┘
↓
Individual Behavior
↓
┌────────────────────────────┐
│ INTERPERSONAL NETWORKS │
│ (Emotional Contagion) │
└─────────────┬──────────────┘
↓
┌────────────────────────────┐
│ SOCIAL STRUCTURES │
│ (Policy, Economy, Design) │
└─────────────┬──────────────┘
↓
┌────────────────────────────┐
│ ECOLOGICAL & MATERIAL │
│ REALITY CONDITIONS │
└─────────────┬──────────────┘
↓
Environmental Feedback
↓
Neurocognitive Conditioning
↺
This is the complete expression of:
Inside → Outside → Inside
6. Intervention Points Overlay
Diagram 6: Strategic Intervention Map
Level 1: Neural Regulation
- Meditation
- Cognitive Training
- Emotional LiteracyLevel 2: Social Field Modulation
- Group Synchronization
- Communication Norms
- Media EthicsLevel 3: Structural Reform
- Economic Incentives
- Governance Models
- Urban DesignLevel 4: Ecological Correction
- Sustainability Policy
- Resource Redistribution
Intervention must occur at multiple simultaneous levels for system stability.
7. Mathematical Abstraction (Conceptual)
Let:
I(t) = Internal state
B(t) = Behavior
S(t) = Structural environment
E(t) = External conditions
Then:
B(t) = f(I(t))
S(t+1) = g(B(t))
I(t+1) = h(S(t+1), E(t+1))
Full system:
I(t+1) = h(g(f(I(t))))
This represents recursive bidirectional causality.
8. Interpretation Summary
The Neurocognitive + Systems Integration Model demonstrates:
- Neural regulation scales into social outcomes.
- Social outcomes scale into structural reality.
- Structural reality feeds back into neural conditioning.
- Compassion functions as a macro-regulatory stabilizer.
- Responsibility is distributed across network nodes (individuals).
9. Research Implications
Future empirical validation can examine:
- Compassion training impact on social trust indices.
- Neural coherence and reduced crime rates.
- Emotional contagion network modeling.
- Policy outcomes from population-level regulation training.
10. Strategic Use Cases
This diagram set can be used for:
- Academic publication
- Policy white papers
- Neurotechnology development
- Ethical AI design
- Civilizational stability frameworks
- Educational reform models
Model A — Macro System Dynamics (Discrete-Time)
State variables (all normalized to 0…1)
- Cₜ: collective compassion / prosocial orientation
- Sₜ: collective stress load
- Tₜ: social trust
- Vₜ: violence/conflict rate
- Rₜ: resource strain / ecological pressure (optional, can stand for “external conditions”)
Core update equations
Use a discrete step (e.g., weekly or monthly). Clamp outputs to [0,1].Tt+1Vt+1St+1Ct+1Rt+1=clip(Tt+α1Ct−α2Vt−α3St)=clip(Vt+β1St+β2(1−Tt)+β3Rt−β4Ct)=clip(St+γ1Vt+γ2Rt−γ3Tt−γ4Ct)=clip(Ct+δ1Tt−δ2St−δ3Vt+δ4It)=clip(Rt+ρ1Vt+ρ2(1−Tt)−ρ3Ut)
Where:
- Iₜ = internal training/introspection intensity (policy lever: meditation programs, education, etc.)
- Uₜ = external reform intensity (policy lever: governance, redistribution, ecological correction)
Interpretation
- Compassion raises trust; stress and violence reduce trust.
- Stress increases violence; compassion counteracts violence.
- Violence and resource strain raise stress; compassion + trust reduce stress.
- Compassion grows when trust is high and stress/violence are low; plus an intervention term (Iₜ).
- Resource strain worsens via conflict and low trust; improves via reforms (Uₜ).
Model B — Agent-Based Network (Micro → Macro Emergence)
Agents i=1..N
Each agent has:
- si(t) stress in [0,1]
- ci(t) compassion in [0,1]
- ai(t) aggression propensity in [0,1]
- xi(t) exposure field from neighbors (contagion)
Network contagion field
Let A be adjacency matrix and N(i) neighbors.xi(t)=∣N(i)∣1j∈N(i)∑(λaaj(t)−λccj(t))
Agent updates
si(t+1)ai(t+1)ci(t+1)=clip(si(t)+η1xi(t)+η2R(t)−η3ci(t))=σ(θ0+θ1si(t+1)+θ2xi(t)−θ3ci(t))=clip(ci(t)+κ1cN(i)(t)−κ2si(t+1)+κ3I(t))
Where:
- σ(⋅) is logistic to keep aggression bounded.
- R(t) is macro resource strain (can be exogenous or coupled from macro model).
- I(t) is training intervention applied globally or targeted.
Macro observables from agents
C(t)S(t)V(t)=N1i∑ci(t)=N1i∑si(t)=N1i∑1[ai(t)>τ]
Trust can be modeled as:T(t)=clip(ω1C(t)−ω2V(t)−ω3S(t))
Coupled Model (Recommended)
- Run Model B to compute C(t),S(t),V(t).
- Feed those into Model A as the macro state, or use Model A for R(t) and feed R(t) back into agents.
This gives inside → outside → inside in a measurable loop.
Reference Implementation (Pure Python, No External Dependencies)
1) Macro simulator (Model A)
from dataclasses import dataclass
from typing import Callable, List, Tupledef clip01(x: float) -> float:
return 0.0 if x < 0.0 else 1.0 if x > 1.0 else x@dataclass
class MacroParams:
a1: float = 0.08
a2: float = 0.06
a3: float = 0.05 b1: float = 0.09
b2: float = 0.08
b3: float = 0.05
b4: float = 0.10 g1: float = 0.08
g2: float = 0.07
g3: float = 0.06
g4: float = 0.07 d1: float = 0.06
d2: float = 0.06
d3: float = 0.04
d4: float = 0.08 r1: float = 0.05
r2: float = 0.04
r3: float = 0.08@dataclass
class MacroState:
C: float # compassion
S: float # stress
T: float # trust
V: float # violence
R: float # resource straindef simulate_macro(
steps: int,
init: MacroState,
p: MacroParams,
I: Callable[[int], float], # internal intervention schedule
U: Callable[[int], float], # external reform schedule
) -> List[MacroState]:
states = [init]
st = init
for t in range(steps):
It = clip01(I(t))
Ut = clip01(U(t)) T_next = clip01(st.T + p.a1*st.C - p.a2*st.V - p.a3*st.S)
V_next = clip01(st.V + p.b1*st.S + p.b2*(1-st.T) + p.b3*st.R - p.b4*st.C)
S_next = clip01(st.S + p.g1*st.V + p.g2*st.R - p.g3*st.T - p.g4*st.C)
C_next = clip01(st.C + p.d1*st.T - p.d2*st.S - p.d3*st.V + p.d4*It)
R_next = clip01(st.R + p.r1*st.V + p.r2*(1-st.T) - p.r3*Ut) st = MacroState(C=C_next, S=S_next, T=T_next, V=V_next, R=R_next)
states.append(st)
return states# Example schedules:
def I_schedule(t: int) -> float:
# ramp up training after step 20
return 0.0 if t < 20 else 0.6def U_schedule(t: int) -> float:
# reforms start later
return 0.0 if t < 40 else 0.5if __name__ == "__main__":
init = MacroState(C=0.40, S=0.50, T=0.45, V=0.35, R=0.55)
states = simulate_macro(steps=120, init=init, p=MacroParams(), I=I_schedule, U=U_schedule)
# Print last state
print(states[-1])
2) Agent-based simulator (Model B)
import random
import math
from typing import List, Dictdef clip01(x: float) -> float:
return 0.0 if x < 0.0 else 1.0 if x > 1.0 else xdef sigmoid(x: float) -> float:
return 1.0 / (1.0 + math.exp(-x))def make_random_graph(n: int, p_edge: float, seed: int = 0) -> List[List[int]]:
random.seed(seed)
nbrs = [[] for _ in range(n)]
for i in range(n):
for j in range(i+1, n):
if random.random() < p_edge:
nbrs[i].append(j)
nbrs[j].append(i)
# Ensure no isolates (optional)
for i in range(n):
if not nbrs[i]:
j = (i+1) % n
nbrs[i].append(j)
nbrs[j].append(i)
return nbrsdef simulate_agents(
steps: int,
n: int = 500,
p_edge: float = 0.02,
seed: int = 0,
R_schedule=lambda t: 0.5, # external strain
I_schedule=lambda t: 0.0, # training
tau: float = 0.7 # violence threshold
) -> Dict[str, List[float]]:
random.seed(seed)
nbrs = make_random_graph(n, p_edge, seed) # Initialize agent states
s = [random.random()*0.6 for _ in range(n)] # stress
c = [0.3 + random.random()*0.4 for _ in range(n)] # compassion
a = [random.random()*0.5 for _ in range(n)] # aggression # Parameters (tune)
lam_a, lam_c = 0.8, 0.8
eta1, eta2, eta3 = 0.10, 0.06, 0.08
th0, th1, th2, th3 = -0.4, 1.2, 0.8, 1.1
kap1, kap2, kap3 = 0.06, 0.07, 0.08 C_hist, S_hist, V_hist, T_hist = [], [], [], [] for t in range(steps):
R = clip01(R_schedule(t))
I = clip01(I_schedule(t)) # Precompute neighborhood averages for c and aggression field
x = [0.0]*n
cN = [0.0]*n
for i in range(n):
neigh = nbrs[i]
inv = 1.0 / len(neigh)
sum_field = 0.0
sum_c = 0.0
for j in neigh:
sum_field += (lam_a * a[j] - lam_c * c[j])
sum_c += c[j]
x[i] = sum_field * inv
cN[i] = sum_c * inv # Update stress
s_next = [0.0]*n
for i in range(n):
s_next[i] = clip01(s[i] + eta1*x[i] + eta2*R - eta3*c[i]) # Update aggression
a_next = [0.0]*n
for i in range(n):
a_next[i] = sigmoid(th0 + th1*s_next[i] + th2*x[i] - th3*c[i]) # Update compassion
c_next = [0.0]*n
for i in range(n):
c_next[i] = clip01(c[i] + kap1*(cN[i] - c[i]) - kap2*s_next[i] + kap3*I) s, a, c = s_next, a_next, c_next # Macro observables
C = sum(c)/n
S = sum(s)/n
V = sum(1 for i in range(n) if a[i] > tau)/n
T = clip01(0.9*C - 0.6*V - 0.5*S) C_hist.append(C); S_hist.append(S); V_hist.append(V); T_hist.append(T) return {"C": C_hist, "S": S_hist, "V": V_hist, "T": T_hist}if __name__ == "__main__":
# Example: turn on training at step 30
out = simulate_agents(
steps=120,
R_schedule=lambda t: 0.55,
I_schedule=lambda t: 0.0 if t < 30 else 0.6,
seed=1
)
print("Final:", {k: v[-1] for k,v in out.items()})
What to simulate (standard experiment suite)
- Baseline drift: no interventions I(t)=U(t)=0.
- Internal-only: training ramps I(t)↑, U(t)=0.
- External-only: reforms ramp U(t)↑, I(t)=0.
- Combined: both ramp; measure synergy thresholds.
- Shock test: sudden resource strain spike R(t) and measure recovery time.
Key outputs:
- Time-to-stability (when V falls below target)
- Resilience (recovery after shock)
- Critical thresholds (minimum I,U needed to avoid runaway conflict)
