Ethical Riemann Hypothesis (ERH) Simulation SDK
Project description
# Ethical Riemann Hypothesis (ERH)
[](https://opensource.org/licenses/MIT)
[](https://www.python.org/)
[](https://github.com/)
**A mathematical framework for analyzing moral judgment errors through an analogy with the Riemann Hypothesis in number theory.**
---
## ๐ Project Overview
This project introduces the **Ethical Riemann Hypothesis (ERH)**. It posits that in a "healthy" moral judgment system, the cumulative error in predicting critical misjudgments grows at most like $\sqrt{x}$, where $x$ is the complexity of the decision.
### Key Concepts
- **Ethical Primes ($P$)**: Critical misjudgments representing fundamental errors.
- **$\Pi(x)$**: The count of ethical primes up to complexity $x$.
- **$E(x) = \Pi(x) - B(x)$**: The error term comparing the actual count vs. the baseline expectation.
- **The ERH Condition**: $|E(x)| \leq C \cdot x^{1/2 + \epsilon}$ for healthy judgment systems.
### Analogy with Number Theory
| Number Theory Concept | Ethical Judgment Analogy |
| :--- | :--- |
| **Prime Numbers** | Ethical Primes (Critical Misjudgments) |
| **$\pi(x)$** | $\Pi(x)$ (Count of ethical primes) |
| **Prime Number Theorem** | Baseline Expectation $B(x)$ |
| **Riemann Hypothesis** | Ethical Riemann Hypothesis (Bounds on error growth) |
---
## ๐ผ๏ธ Demo
Below are visualizations generated by the framework, showcasing the distribution of ethical primes and the behavior of the error term.
| Zeta Function Analysis | Error Distribution |
| :---: | :---: |
|  |  |
| Prime Counting Function $\Pi(x)$ | Critical Line Analysis |
| :---: | :---: |
|  |  |
---
## ๐ Project Structure
```text
Ethic-Latex/
โโโ simulation/ # Python simulation framework
โ โโโ core/ # Core modules
โ โ โโโ action_space.py # Action and world generation
โ โ โโโ judgement_system.py # Judge implementations
โ โ โโโ ethical_primes.py # Prime selection and analysis
โ โโโ analysis/ # Analysis tools
โ โ โโโ zeta_function.py # Ethical zeta function
โ โ โโโ statistics.py # Statistical analysis
โ โโโ visualization/ # Plotting utilities
โ โ โโโ plots.py # All visualization functions
โ โโโ notebooks/ # Jupyter notebooks for experiments
โ โ โโโ 01_basic_simulation.ipynb
โ โ โโโ 02_judge_comparison.ipynb
โ โ โโโ ... (other analysis notebooks)
โ โโโ output/ # Generated figures and data
โโโ scripts/ # Utility scripts
โโโ docs/ # Documentation files
โโโ tests/ # Test files
โโโ ethical_riemann_hypothesis.tex # Main research paper (LaTeX)
โโโ requirements.txt # Python dependencies
โก Installation
Prerequisites
- Python: 3.10 or later
- LaTeX Distribution: (Optional, for compiling the paper)
Python Setup
# Clone the repository
git clone <repository-url>
cd Ethic-Latex
# Install dependencies
pip install -r requirements.txt
LaTeX Setup
To compile the research paper:
# Using the provided script (Mac/Linux)
bash scripts/compile_latex.sh
# Or manually
pdflatex ethical_riemann_hypothesis.tex
bibtex ethical_riemann_hypothesis
pdflatex ethical_riemann_hypothesis.tex
๐ Quick Start
Running a Basic Simulation
from simulation.core import generate_world, BiasedJudge, evaluate_judgement
from simulation.core import select_ethical_primes, compute_Pi_and_error
from simulation.visualization import plot_Pi_B_E
# 1. Generate moral action space
actions = generate_world(num_actions=1000, complexity_dist='zipf')
# 2. Create and apply a judgment system
judge = BiasedJudge(bias_strength=0.2, noise_scale=0.1)
evaluate_judgement(actions, judge, tau=0.3)
# 3. Extract ethical primes (critical errors)
primes = select_ethical_primes(actions, importance_quantile=0.9)
# 4. Compute and plot error distribution
Pi_x, B_x, E_x, x_vals = compute_Pi_and_error(primes, X_max=100)
plot_Pi_B_E(x_vals, Pi_x, B_x, E_x)
Running Jupyter Notebooks
bash scripts/start_jupyter.sh
Start with simulation/notebooks/01_basic_simulation.ipynb for an introduction.
โ๏ธ Cloud Deployment
- ๐ Streamlit Cloud (Recommended - 5 minutes): Push to GitHub, then deploy via the Streamlit website.
- ๐ Binder (For Notebooks - 2 minutes): Deploy your notebooks for live access.
- ๐ณ Docker (Any Platform):
docker build -t erh-app .
docker run -p 8501:8501 erh-app streamlit run simulation/app.py
See docs/CLOUD_DEPLOYMENT.md for detailed guides.
๐ ERH-on-Security PoC Design Document
Subject: Analysis of Structural Misjudgment in GitLab DevSecOps Pipelines
This design document outlines a Proof of Concept (PoC) applying the ERH framework to quantify how systematic and fatal security misjudgments accumulate as project complexity increases within a DevSecOps pipeline.
1. Objectives & Scope
| Category | Description |
|---|---|
| Core Problem | Quantify the rate at which "truly fatal security misjudgments" (structural misjudgments) accumulate as the complexity of project changes grows. |
| Hypothesis | Can we use an ERH-style metric to quantify this Structural Risk Growth? |
| Scope | GitLab Merge Request security review pipeline (using SAST/DAST results and post-merge incident data as proxies for ground truth). |
2. Mapping ERH to Security Context
| ERH Concept | Security Context Mapping |
|---|---|
| Action ($a$) | Defined as a security decision event for a single Merge Request (MR). |
| Complexity ($c(a)$) | A composite metric of MR size and scope: $c(a) = \text{norm}(\log(1 + \text{lines_changed}) + \lambda \cdot \text{files_changed} + \dots)$ |
| True Value ($V(a)$) | Ground Truth. $+1$: Safe merge (no post-merge incident/unresolved high issue). $-1$: Unsafe merge (resulted in incident or high-severity issue). |
| Judgment System ($J(a)$) | Pipeline Judge ($J_{\text{pipe}}$): Automated CI/SAST results. Human Judge ($J_{\text{human}}$): Reviewer behavior/override. Combined Judge ($J_{\text{combo}}$). |
| Error ($\Delta(a)$) | $\Delta(a) = J(a) - V(a)$. |
| Ethical Prime ($P$) | A Critical Misjudgment ($M(a)=1$) on a High-Importance asset ($w(a)$ in top quantile). |
3. Data Schema Design
actions (Core: MR Decisions)
| Column | Type | Description |
|---|---|---|
action_id |
PK (MR ID) | Unique identifier for the decision event |
lines_added |
int | Complexity factor |
files_changed |
int | Complexity factor |
services_touched |
string[] | Subsystems affected (via path mapping) |
merged_at |
timestamp | Time of merge (nullable) |
ground_truth
| Column | Type | Description |
|---|---|---|
action_id |
FK | Link to MR |
V |
float [-1, 1] | True Value (Post-merge security impact) |
has_post\_incident |
bool | Flag for incident discovery within observation window |
unresolved\_high |
bool | True if merged with unmitigated high/critical issues |
derived_metrics (Calculated on-the-fly or materialized)
| Column | Type | Description |
|---|---|---|
action_id |
FK | Link to MR |
c |
float | Normalized Complexity |
delta |
float | $\Delta(a)$ Error |
is_prime |
bool | Flag indicating an Ethical Prime |
4. ERH Analysis Flow and Metrics
- Preprocessing: Ingest GitLab API data (MRs, security reports) and calculate $c(a)$, $V(a)$, $w(a)$, $J(a)$, and prime marking for all actions.
- ERH-style Metrics: Compute the following for each judge:
| Metric | Formula | Description |
|---|---|---|
| Mistake Rate (MR) | $\frac{1}{N} \sum M(a)$ | Overall misjudgment frequency. |
| Prime Count $\Pi(x)$ | Count of primes where $c(a) \leq x$. | Cumulative critical error count by complexity. |
| Error Growth $\alpha$ | Fit $ | E(x) |
- Interpretation: Check if $\alpha$ satisfies the ERH-style boundary. $\alpha \approx 0.5$ implies Riemann-healthy system with controlled risk growth. $\alpha \geq 1$ implies systematic degradation.
๐ Key Results (Expected)
The following table is a placeholder to be filled with simulation results.
| Judge Type | Exponent $\alpha$ | ERH Satisfied? | Growth Rate Interpretation |
|---|---|---|---|
| Biased | TBD | TBD | -- |
| Noisy | TBD | TBD | -- |
| Conservative | TBD | TBD | Low risk, potentially high friction ($\alpha < 0.5$) |
| Radical | TBD | TBD | High risk accumulation, systematic failure ($\alpha \geq 1.0$) |
๐ Documentation and Future Work
- Simulation Framework: See
simulation/README.md - Installation Guide: See
docs/INSTALL.md - Theory: See
ethical_riemann_hypothesis.tex
Applications to AI Ethics
The ERH framework provides:
- Quantitative Criterion: AI systems should satisfy $|E(x)| = O(\sqrt{x})$.
- Bias Detection: Violations of ERH indicate systematic failures.
- Fairness Analysis: Ethical primes highlight critical errors on vulnerable groups.
Future Work
- Apply the framework to real-world AI systems (e.g., content moderation).
- Develop theoretical proofs for ERH boundary conditions.
- Explore connections to causal inference and quantum computing implementations.
ยฉ Citation and License
Citation
If you use this framework in your research, please cite:
@article{ethical_riemann_hypothesis,
title={The Ethical Riemann Hypothesis: A Mathematical Framework for Analyzing Moral Judgment Errors},
author={[Author Name]},
journal={[To be completed]},
year={2025}
}
License
This project is licensed under the MIT License.
Contributing
Contributions, suggestions, and discussions are welcome.
Contact: admin@dennisleehappy.org
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file erh-0.1.0.tar.gz.
File metadata
- Download URL: erh-0.1.0.tar.gz
- Upload date:
- Size: 83.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca7f01516b653f651dd7f9b14e5a335872d0437b8a1a5b6c3d69a5127074054b
|
|
| MD5 |
2947d035ed6dc5cc48369ed18a0bf362
|
|
| BLAKE2b-256 |
8067354037fa47d289f113c0f29259bad8f70947663774b03b994743ba3ea302
|
File details
Details for the file erh-0.1.0-py3-none-any.whl.
File metadata
- Download URL: erh-0.1.0-py3-none-any.whl
- Upload date:
- Size: 88.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56e03a56a8dff2f0f306abbe79d46083bc399bcafb660586fcb47c49572ca07c
|
|
| MD5 |
b968ae535d1df7d0fb2508f84ef084f8
|
|
| BLAKE2b-256 |
2d31ec802cd0721521bb9caacb0129ebd268da2f9c44aa5c7ae4e3cbf1a6dbbe
|