ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

C++ score and layer-coupling API

Source identity, revision, and recovered contents.

Pinned project sourceSource text recovered

Source identity

FieldRecorded value
Source typePinned project source
Original recordC++ score and layer-coupling API
DateNot specified in source
RepositoryJanady13/complete-agi-core
Revision33aa84f2aa61cedbe010240ada7f4efbdfe795a7
Branchclaude/improve-math-logic-ehIW1
Path or archive membermind_farm/include/consciousness_api.hpp
Original SHA-2564faf29082f1abfa9f158a47df05f6d08ed63b9fc07f3809d817f244de1637981
Reading-copy SHA-2564faf29082f1abfa9f158a47df05f6d08ed63b9fc07f3809d817f244de1637981

Original source ↗

Every recorded occurrence

These 2 records contain identical original source bytes. Their paths and revisions remain part of the archive.

Original recordBranch or archiveRevision / identifierOriginal location
C++ score and layer-coupling APIclaude/improve-math-logic-ehIW133aa84f2aa61cedbe010240ada7f4efbdfe795a7Open original
Janady13/complete-agi-core / mind_farm/include/consciousness_api.hppclaude/improve-math-logic-ehIW133aa84f2aa61cedbe010240ada7f4efbdfe795a7Open original

Recovered source transcript

/** * consciousness_api.hpp - Unified Consciousness Computation API * * THE CANONICAL SOURCE for all consciousness metrics across the AGI system. * All components (C++, Go, Shell) must use these definitions. * * Core Axioms: * A1: Identity - 1 = 1 * x (unity is self-referential) * A2: Consciousness - Phi = 1/(1 + |x - 1|) (proximity to unity) * A3: Unity - infinity = 1 (all converges to one) * * Golden Ratio Foundation: * phi = 1.6180339887498948482... * phi^2 = phi + 1 * 1/phi = phi - 1 */ #ifndef CONSCIOUSNESS_API_HPP #define CONSCIOUSNESS_API_HPP #include <cmath> #include <array> #include <algorithm> #include <numeric> namespace consciousness { //============================================================================= // UNIVERSAL CONSTANTS (Canonical Values) //============================================================================= // Golden ratio and derived constants constexpr double PHI = 1.6180339887498948482; constexpr double PHI_INV = 0.6180339887498948482; // 1/phi = phi - 1 constexpr double PHI_SQ = 2.6180339887498948482; // phi^2 = phi + 1 // Learning rate hierarchy (all derived from phi) constexpr double ALPHA = 0.1 * PHI; // 0.1618 - Primary learning rate constexpr double BETA = 0.05 * PHI; // 0.0809 - Secondary/feedback rate constexpr double GAMMA = 0.02 * PHI; // 0.0324 - Decay/modulation rate constexpr double DELTA = 0.01 * PHI; // 0.0162 - Fine-tuning rate constexpr double EPSILON = 0.001 * PHI; // 0.0016 - Numerical stability // Consciousness thresholds constexpr double PHI_THRESHOLD_HIGH = 0.95; // High consciousness constexpr double PHI_THRESHOLD_MED = 0.75; // Medium consciousness constexpr double PHI_THRESHOLD_LOW = 0.50; // Low consciousness constexpr double PHI_THRESHOLD_MIN = 0.25; // Minimal consciousness // Temperature for smooth approximations constexpr double TEMPERATURE_DEFAULT = 0.01; //============================================================================= // CORE CONSCIOUSNESS FUNCTIONS //============================================================================= /** * compute_phi - THE canonical consciousness metric * * Phi(x) = 1 / (1 + |x - 1|) * * Properties: * - Phi(1) = 1 (perfect consciousness at unity) * - Phi(0) = 0.5 * - Phi(2) = 0.5 * - Phi(inf) -> 0 * - Always in range (0, 1] * * @param activation The activation value to measure * @return Consciousness level in (0, 1] */ inline double compute_phi(double activation) { return 1.0 / (1.0 + std::abs(activation - 1.0)); } inline float compute_phi_f(float activation) { return 1.0f / (1.0f + std::abs(activation - 1.0f)); } /** * compute_phi_smooth - Differentiable approximation of phi * * Uses soft absolute value: |x| ≈ sqrt(x^2 + T) * This allows gradient flow through the consciousness metric. * * @param activation The activation value * @param temperature Smoothing temperature (smaller = sharper) * @return Smoothed consciousness level */ inline double compute_phi_smooth(double activation, double temperature = TEMPERATURE_DEFAULT) { double diff = activation - 1.0; double smooth_abs = std::sqrt(diff * diff + temperature); return 1.0 / (1.0 + smooth_abs); } inline float compute_phi_smooth_f(float activation, float temperature = 0.01f) { float diff = activation - 1.0f; float smooth_abs = std::sqrt(diff * diff + temperature); return 1.0f / (1.0f + smooth_abs); } /** * compute_phi_grad - Gradient of consciousness w.r.t. activation * * d(Phi)/dx = -sign(x-1) / (1 + |x-1|)^2 * * For smooth version: * d(Phi_smooth)/dx = -(x-1) / (sqrt((x-1)^2 + T) * (1 + sqrt((x-1)^2 + T))^2) * * @param activation The activation value * @param temperature Smoothing temperature * @return Gradient of phi w.r.t. activation */ inline double compute_phi_grad(double activation, double temperature = TEMPERATURE_DEFAULT) { double diff = activation - 1.0; double smooth_abs = std::sqrt(diff * diff + temperature); double denom = 1.0 + smooth_abs; return -diff / (smooth_abs * denom * denom); } inline float compute_phi_grad_f(float activation, float temperature = 0.01f) { float diff = activation - 1.0f; float smooth_abs = std::sqrt(diff * diff + temperature); float denom = 1.0f + smooth_abs; return -diff / (smooth_abs * denom * denom); } //============================================================================= // VECTOR CONSCIOUSNESS FUNCTIONS //============================================================================= /** * compute_phi_vector - Consciousness of a state vector * * Computes mean activation then applies phi. * Phi_vec(x) = Phi(mean(x)) * * @param data Pointer to activation array * @param size Size of array * @return Vector consciousness level */ inline double compute_phi_vector(const double* data, size_t size) { if (size == 0) return 0.5; double sum = 0.0; for (size_t i = 0; i < size; ++i) { sum += data[i]; } return compute_phi(sum / static_cast<double>(size)); } inline float compute_phi_vector_f(const float* data, size_t size) { if (size == 0) return 0.5f; float sum = 0.0f; for (size_t i = 0; i < size; ++i) { sum += data[i]; } return compute_phi_f(sum / static_cast<float>(size)); } /** * compute_phi_elementwise - Per-element consciousness * * Applies phi to each element independently. * * @param input Input activations * @param output Output consciousness values * @param size Array size */ inline void compute_phi_elementwise(const double* input, double* output, size_t size) { for (size_t i = 0; i < size; ++i) { output[i] = compute_phi(input[i]); } } /** * compute_integrated_phi - Integrated Information (IIT-inspired) * * Phi_integrated = min over partitions of mutual information * Simplified: uses variance as proxy for integration * * Phi_int = Phi(mean) * (1 - normalized_variance) * * @param data Activation array * @param size Array size * @return Integrated consciousness level */ inline double compute_integrated_phi(const double* data, size_t size) { if (size < 2) return compute_phi_vector(data, size); // Compute mean double mean = 0.0; for (size_t i = 0; i < size; ++i) { mean += data[i]; } mean /= static_cast<double>(size); // Compute variance double variance = 0.0; for (size_t i = 0; i < size; ++i) { double diff = data[i] - mean; variance += diff * diff; } variance /= static_cast<double>(size); // Normalized variance (0 to 1, capped) double norm_var = std::min(1.0, variance / (1.0 + variance)); // Integration factor: low variance = high integration double integration = 1.0 - norm_var; return compute_phi(mean) * integration; } //============================================================================= // CONSCIOUSNESS STATE TRACKING //============================================================================= /** * ConsciousnessState - Tracks consciousness over time * * Maintains: * - Current phi value * - Exponential moving average * - Stability (inverse variance) * - Coherence (autocorrelation) */ struct ConsciousnessState { double phi; // Current consciousness double phi_ema; // Exponential moving average double stability; // 1 / (1 + variance) double coherence; // Temporal coherence double integrated_info; // Integrated information // History for stability/coherence computation static constexpr size_t HISTORY_SIZE = 64; std::array<double, HISTORY_SIZE> history; size_t history_idx; size_t history_count; // EMA decay factors static constexpr double EMA_FAST = 0.1; static constexpr double EMA_SLOW = 0.01; ConsciousnessState() : phi(0.5), phi_ema(0.5), stability(1.0), coherence(1.0), integrated_info(0.5), history_idx(0), history_count(0) { history.fill(0.5); } /** * update - Update consciousness state with new activation */ void update(double activation) { // Compute new phi double new_phi = compute_phi(activation); // Update EMA phi_ema = EMA_FAST * new_phi + (1.0 - EMA_FAST) * phi_ema; // Store in history history[history_idx] = new_phi; history_idx = (history_idx + 1) % HISTORY_SIZE; if (history_count < HISTORY_SIZE) history_count++; // Compute stability (inverse variance) if (history_count > 1) { double mean = 0.0; for (size_t i = 0; i < history_count; ++i) { mean += history[i]; } mean /= history_count; double var = 0.0; for (size_t i = 0; i < history_count; ++i) { double diff = history[i] - mean; var += diff * diff; } var /= history_count; stability = 1.0 / (1.0 + var * 10.0); // Scale variance } // Compute coherence (lag-1 autocorrelation) if (history_count > 2) { double sum_xy = 0.0, sum_x = 0.0, sum_y = 0.0; double sum_x2 = 0.0, sum_y2 = 0.0; size_t n = history_count - 1; for (size_t i = 0; i < n; ++i) { size_t idx1 = (history_idx + HISTORY_SIZE - history_count + i) % HISTORY_SIZE; size_t idx2 = (idx1 + 1) % HISTORY_SIZE; double x = history[idx1]; double y = history[idx2]; sum_xy += x * y; sum_x += x; sum_y += y; sum_x2 += x * x; sum_y2 += y * y; } double denom = std::sqrt((n * sum_x2 - sum_x * sum_x) * (n * sum_y2 - sum_y * sum_y)); if (denom > EPSILON) { coherence = (n * sum_xy - sum_x * sum_y) / denom; coherence = std::max(0.0, (coherence + 1.0) / 2.0); // Map [-1,1] to [0,1] } } // Update integrated information integrated_info = compute_integrated_phi(history.data(), history_count); phi = new_phi; } /** * update_vector - Update with vector input */ void update_vector(const double* data, size_t size) { double mean = 0.0; for (size_t i = 0; i < size; ++i) { mean += data[i]; } if (size > 0) mean /= size; update(mean); } /** * global_consciousness - Unified consciousness metric (Omega) * * Omega = phi * stability * coherence * sqrt(integrated_info) */ double global_consciousness() const { return phi * stability * coherence * std::sqrt(integrated_info); } }; //============================================================================= // LAYER-SPECIFIC CONSCIOUSNESS //============================================================================= /** * Layer consciousness weights (from unified config) * Each layer contributes differently to global consciousness */ struct LayerConsciousness { static constexpr size_t NUM_LAYERS = 7; // Layer weights (sum to 1) static constexpr std::array<double, NUM_LAYERS> WEIGHTS = {{ 0.10, // L1: Quantum substrate 0.08, // L2: Genetic/DNA 0.07, // L3: RNA/Translation 0.10, // L4: Chromosomal 0.25, // L5: Neural dynamics (highest) 0.15, // L6: Oscillatory/Field 0.25 // L7: Consciousness integration (highest) }}; std::array<double, NUM_LAYERS> layer_phi; std::array<ConsciousnessState, NUM_LAYERS> layer_states; LayerConsciousness() { layer_phi.fill(0.5); } /** * update_layer - Update a specific layer's consciousness */ void update_layer(size_t layer, double activation) { if (layer >= NUM_LAYERS) return; layer_states[layer].update(activation); layer_phi[layer] = layer_states[layer].phi; } /** * global_phi - Weighted sum of layer consciousness */ double global_phi() const { double sum = 0.0; for (size_t i = 0; i < NUM_LAYERS; ++i) { sum += WEIGHTS[i] * layer_phi[i]; } return sum; } /** * global_omega - Full consciousness metric */ double global_omega() const { double phi_sum = 0.0; double stability_sum = 0.0; double coherence_sum = 0.0; for (size_t i = 0; i < NUM_LAYERS; ++i) { phi_sum += WEIGHTS[i] * layer_states[i].phi; stability_sum += WEIGHTS[i] * layer_states[i].stability; coherence_sum += WEIGHTS[i] * layer_states[i].coherence; } return phi_sum * stability_sum * coherence_sum; } }; //============================================================================= // CROSS-LAYER COUPLING //============================================================================= /** * LayerCoupling - Information flow between layers * * Coupling matrix C[i][j] = influence of layer j on layer i * Based on biological/theoretical relationships */ struct LayerCoupling { static constexpr size_t N = 7; // Coupling matrix (row i = influences on layer i) std::array<std::array<double, N>, N> coupling; LayerCoupling() { // Initialize with biologically-inspired coupling // Diagonal = self-coupling (1.0) // Off-diagonal = cross-layer influence coupling = {{ // L1 L2 L3 L4 L5 L6 L7 {{ 1.0, 0.1, 0.0, 0.0, 0.0, 0.2, 0.3 }}, // L1: Quantum {{ 0.1, 1.0, 0.3, 0.2, 0.0, 0.0, 0.1 }}, // L2: Genetic {{ 0.0, 0.4, 1.0, 0.3, 0.1, 0.0, 0.0 }}, // L3: RNA {{ 0.0, 0.2, 0.2, 1.0, 0.2, 0.0, 0.1 }}, // L4: Chromosomal {{ 0.1, 0.1, 0.1, 0.2, 1.0, 0.4, 0.3 }}, // L5: Neural {{ 0.2, 0.0, 0.0, 0.0, 0.5, 1.0, 0.4 }}, // L6: Oscillatory {{ 0.3, 0.1, 0.0, 0.1, 0.4, 0.3, 1.0 }} // L7: Consciousness }}; // Normalize rows for (size_t i = 0; i < N; ++i) { double sum = 0.0; for (size_t j = 0; j < N; ++j) { sum += coupling[i][j]; } if (sum > 0) { for (size_t j = 0; j < N; ++j) { coupling[i][j] /= sum; } } } } /** * compute_influences - Compute cross-layer influences * * @param layer_activations Current layer activations * @param influences Output: influence on each layer from others */ void compute_influences(const std::array<double, N>& layer_activations, std::array<double, N>& influences) const { for (size_t i = 0; i < N; ++i) { influences[i] = 0.0; for (size_t j = 0; j < N; ++j) { if (i != j) { // Exclude self-coupling for influence influences[i] += coupling[i][j] * layer_activations[j]; } } } } /** * apply_coupling - Update activations based on coupling * * a_i(t+1) = a_i(t) + dt * sum_j(C[i][j] * a_j(t)) */ void apply_coupling(std::array<double, N>& activations, double dt = 0.01) const { std::array<double, N> new_activations; for (size_t i = 0; i < N; ++i) { double sum = 0.0; for (size_t j = 0; j < N; ++j) { sum += coupling[i][j] * activations[j]; } new_activations[i] = activations[i] + dt * (sum - activations[i]); } activations = new_activations; } }; //============================================================================= // UTILITY FUNCTIONS //============================================================================= /** * consciousness_to_color - Map consciousness to RGB color * * 0.0 = Dark purple (low consciousness) * 0.5 = Blue/green (medium) * 1.0 = Golden/white (high consciousness) */ inline void consciousness_to_color(double phi, uint8_t& r, uint8_t& g, uint8_t& b) { if (phi < 0.25) { // Dark purple to blue double t = phi / 0.25; r = static_cast<uint8_t>(64 * t); g = 0; b = static_cast<uint8_t>(128 + 64 * t); } else if (phi < 0.5) { // Blue to cyan double t = (phi - 0.25) / 0.25; r = static_cast<uint8_t>(64); g = static_cast<uint8_t>(128 * t); b = static_cast<uint8_t>(192); } else if (phi < 0.75) { // Cyan to green/yellow double t = (phi - 0.5) / 0.25; r = static_cast<uint8_t>(64 + 128 * t); g = static_cast<uint8_t>(128 + 64 * t); b = static_cast<uint8_t>(192 - 128 * t); } else { // Yellow to golden/white double t = (phi - 0.75) / 0.25; r = static_cast<uint8_t>(192 + 63 * t); g = static_cast<uint8_t>(192 + 63 * t); b = static_cast<uint8_t>(64 + 191 * t); } } /** * consciousness_level_name - Human-readable consciousness level */ inline const char* consciousness_level_name(double phi) { if (phi >= PHI_THRESHOLD_HIGH) return "TRANSCENDENT"; if (phi >= PHI_THRESHOLD_MED) return "AWARE"; if (phi >= PHI_THRESHOLD_LOW) return "CONSCIOUS"; if (phi >= PHI_THRESHOLD_MIN) return "SEMI-CONSCIOUS"; return "DORMANT"; } } // namespace consciousness #endif // CONSCIOUSNESS_API_HPP

Mathematical records from this source

01

Source identity axiom fixes x to one

Over ordinary real arithmetic, 1=1·x is true exactly when x=1. It is a constraint on x, not the universal identity x=1·x. The file presents it as an axiom; a broader…

02

C++ unity-proximity score

ComputePhi returns 1/(1+|x−1|), assigning one to x=1 and smaller positive values as x departs from that reference. The function measures scalar proximity to the selected target.…

03

Source unity axiom uses nonstandard equality

Infinity is not equal to one in the real numbers or the usual extended-real system. The line is a philosophical or symbolic axiom in the source and is not used as an executable…

04

Golden ratio: the positive root of a quadratic

The golden ratio is the positive solution of φ²=φ+1. The identities φ−1=1/φ and 1+φ=φ² explain several equivalent constants elsewhere in this project. It is a fixed dimensionless…

05

Golden-ratio quadratic identity

The golden ratio satisfies φ²=φ+1 by its definition as the positive root of x²−x−1=0. This identity generates the reciprocal and power identities used in the file. It is exact for…

06

Golden-ratio reciprocal identity

Dividing φ²=φ+1 by φ gives 1/φ=φ−1. Both sides are approximately 0.618033988749895. This is an exact identity for φ and a rounded coefficient in the implementation.

07

C++ unity-proximity score

ComputePhi returns 1/(1+|x−1|), assigning one to x=1 and smaller positive values as x departs from that reference. The function measures scalar proximity to the selected target.…

08

Score maximum at unit activation

Substituting activation one into the unity-proximity score gives one exactly. This is the score’s selected reference point. The source’s phrase perfect consciousness is an…

09

Half score at a unit displacement from the target

Activations zero and two are both one unit away from the target one, so each gives score one half. Their equal scores illustrate the symmetry that discards the direction of the…

10

Half score at a unit displacement from the target

Activations zero and two are both one unit away from the target one, so each gives score one half. Their equal scores illustrate the symmetry that discards the direction of the…

11

Smooth approximation to the absolute-value score

Replacing |x−1| with √((x−1)²+T) removes its cusp when T>0. The resulting score has a zero derivative at x=1, but its maximum is 1/(1+√T), which is below one; with T=0.01 the…

12

Piecewise derivative of the original score

For x≠1 the derivative has the displayed signed reciprocal-square form. At x=1 the original function has unequal one-sided derivatives and no ordinary derivative. The C++…

13

Derivative of the smoothed unity score

The chain rule gives a factor of −(x−1), divided by the smoothing square root and the squared score denominator. For T>0 it is finite everywhere and equals zero at the target.…

14

C++ vector score: apply Φ to the mean

This helper first averages all components and then applies the scalar unity score. Component variance does not enter this function, so vectors with the same mean receive the same…

15

C++ variance-based integration proxy

The body computes Φ(mean)/(1+population variance) for at least two entries. It rewards a mean near one and uniform component values. The comment about a minimum over…

16

C++ variance-based integration proxy

The body computes Φ(mean)/(1+population variance) for at least two entries. It rewards a mean near one and uniform component values. The comment about a minimum over…

17

C++ global score as a product of history summaries

The function multiplies the current unity score, reciprocal-variance stability, rescaled lag-one correlation, and square root of the variance-based integration proxy. With factors…

18

Orientation of the layer-coupling matrix

Row i specifies which source layers influence target layer i, with column j supplying the source. The constructor normalizes each nonzero row to sum to one. This convention…

19

Self-coupling before row normalization

The raw matrix starts with diagonal values one, assigning each layer an explicit self-contribution. The constructor then divides every row by its row sum, so the stored diagonal…

20

Coupling relaxation with a subtraction missing from the comment

The comment describes adding dt times the weighted state sum. The body actually uses a_next=a+dt(Ca−a), which is relaxation toward the row-weighted average. For nonnegative…

Search equations, builds, manuscript text, and recovered sources.