Skip to main content

Ethical Riemann Hypothesis (ERH) Simulation SDK

Project description

# Ethical Riemann Hypothesis (ERH)

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python](https://img.shields.io/badge/python-3.10%2B-blue)](https://www.python.org/)
[![Status](https://img.shields.io/badge/Status-Research_Preview-orange)](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 |
| :---: | :---: |
| ![Zeta Function Visualization](https://github.com/user-attachments/assets/86b7e910-dc49-4d9c-ab6e-bb8dd9dceb2a) | ![Error Distribution Plot](https://github.com/user-attachments/assets/f883510f-b0e5-479c-a792-a93b554618be) |

| Prime Counting Function $\Pi(x)$ | Critical Line Analysis |
| :---: | :---: |
| ![Prime Counting Function](https://github.com/user-attachments/assets/421f952c-a732-43fe-8049-6da2dba27e51) | ![Critical Line Analysis](https://github.com/user-attachments/assets/b1543552-036f-43b9-a35e-f058d8641683) |

---

## ๐Ÿ“‚ 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

  1. Preprocessing: Ingest GitLab API data (MRs, security reports) and calculate $c(a)$, $V(a)$, $w(a)$, $J(a)$, and prime marking for all actions.
  2. 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)
  1. 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:

  1. Quantitative Criterion: AI systems should satisfy $|E(x)| = O(\sqrt{x})$.
  2. Bias Detection: Violations of ERH indicate systematic failures.
  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

erh-0.1.0.tar.gz (83.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

erh-0.1.0-py3-none-any.whl (88.6 kB view details)

Uploaded Python 3

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

Hashes for erh-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ca7f01516b653f651dd7f9b14e5a335872d0437b8a1a5b6c3d69a5127074054b
MD5 2947d035ed6dc5cc48369ed18a0bf362
BLAKE2b-256 8067354037fa47d289f113c0f29259bad8f70947663774b03b994743ba3ea302

See more details on using hashes here.

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

Hashes for erh-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 56e03a56a8dff2f0f306abbe79d46083bc399bcafb660586fcb47c49572ca07c
MD5 b968ae535d1df7d0fb2508f84ef084f8
BLAKE2b-256 2d31ec802cd0721521bb9caacb0129ebd268da2f9c44aa5c7ae4e3cbf1a6dbbe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page