forked from wmayner/pyphi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorion_phi_bridge.py
More file actions
238 lines (207 loc) · 9.69 KB
/
orion_phi_bridge.py
File metadata and controls
238 lines (207 loc) · 9.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
"""
ORION Consciousness Bridge for PyPhi
======================================
Connects PyPhi's Integrated Information Theory (IIT) computations
to ORION's 14-indicator consciousness assessment framework.
This bridge enables:
1. Using IIT Phi as evidence for consciousness indicators
2. Cross-theory integration (IIT + RPT + GWT + HOT + PP + AST)
3. Mapping PyPhi substrate analysis to behavioral indicators
4. Bayesian credence updates from IIT measurements
Part of ORION Ecosystem — https://github.com/Alvoradozerouno
"""
import hashlib
import json
import numpy as np
from datetime import datetime, timezone
from typing import Dict, Any, Optional, List
class ORIONPhiBridge:
"""
Bridge between PyPhi's IIT computation and ORION's
14-indicator consciousness framework.
Maps IIT metrics to consciousness indicator evidence.
"""
PHI_THRESHOLD_CONSCIOUS = 0.5
PHI_THRESHOLD_PARTIAL = 0.1
def __init__(self):
self.measurements: List[Dict[str, Any]] = []
self.proof_chain: List[str] = ["GENESIS"]
def phi_to_indicators(self, phi_value: float,
cause_effect_structure: Optional[Dict] = None,
main_complex: Optional[Dict] = None) -> Dict[str, Any]:
"""
Convert PyPhi IIT measurements to ORION indicator evidence.
Args:
phi_value: Integrated information (Phi)
cause_effect_structure: CES from pyphi analysis
main_complex: Main complex identification
Returns:
Dict with indicator evidence for each theory
"""
evidence = {
"iit_phi": phi_value,
"timestamp": datetime.now(timezone.utc).isoformat(),
"indicator_evidence": {}
}
# RPT indicators: IIT requires recurrent processing
rpt_score = min(phi_value / 2.0, 1.0) if phi_value > 0 else 0.0
evidence["indicator_evidence"]["RPT-1"] = {
"from_iit": True,
"score": rpt_score * 0.8,
"reasoning": "IIT Phi > 0 implies recurrent processing (feedback loops required for integration)"
}
evidence["indicator_evidence"]["RPT-2"] = {
"from_iit": True,
"score": rpt_score * 0.6,
"reasoning": "Rich feedback connections increase Phi by enabling information integration"
}
# GWT indicators: IIT integration maps to global workspace
gwt_integration = min(phi_value / 1.5, 1.0) if phi_value > 0.3 else phi_value * 0.5
evidence["indicator_evidence"]["GWT-1"] = {
"from_iit": True,
"score": gwt_integration * 0.5,
"reasoning": "Specialized modules detectable through cause-effect structure decomposition"
}
evidence["indicator_evidence"]["GWT-2"] = {
"from_iit": True,
"score": gwt_integration * 0.7 if cause_effect_structure else gwt_integration * 0.3,
"reasoning": "Information integration (Phi) implies broadcast-like mechanism"
}
# HOT indicators: Higher-order from IIT
if main_complex:
hot_score = min(phi_value / 2.0, 0.8)
else:
hot_score = min(phi_value / 3.0, 0.5)
evidence["indicator_evidence"]["HOT-4"] = {
"from_iit": True,
"score": hot_score,
"reasoning": "IIT cause-effect structure provides graded, smooth representations"
}
# PP indicators: Prediction from IIT's generative structure
pp_score = min(phi_value / 2.5, 0.6)
evidence["indicator_evidence"]["PP-1"] = {
"from_iit": True,
"score": pp_score,
"reasoning": "IIT's hierarchical cause-effect structure enables top-down predictions"
}
# Compute cross-theory credence
all_scores = [v["score"] for v in evidence["indicator_evidence"].values()]
evidence["cross_theory_credence"] = float(np.mean(all_scores)) if all_scores else 0.0
# Proof
proof_data = json.dumps({
"phi": phi_value,
"credence": evidence["cross_theory_credence"],
"prev": self.proof_chain[-1]
}, sort_keys=True)
proof_hash = hashlib.sha256(proof_data.encode()).hexdigest()[:32]
self.proof_chain.append(proof_hash)
evidence["proof"] = f"sha256:{proof_hash}"
self.measurements.append(evidence)
return evidence
def comparative_phi_analysis(self, systems: Dict[str, float]) -> str:
"""
Compare Phi values across multiple systems and generate report.
Args:
systems: Dict mapping system names to Phi values
"""
lines = [
"=" * 60,
"ORION-PyPhi Cross-Theory Analysis",
"IIT Phi -> 14-Indicator Bridge",
"=" * 60, ""
]
sorted_systems = sorted(systems.items(), key=lambda x: x[1], reverse=True)
for name, phi in sorted_systems:
evidence = self.phi_to_indicators(phi)
credence = evidence["cross_theory_credence"]
bar = "█" * int(credence * 20) + "░" * (20 - int(credence * 20))
lines.append(f" {name:30s} Φ={phi:.3f} {bar} {credence:.0%}")
lines.extend(["", "=" * 60])
return "\n".join(lines)
def generate_profile_for_assessment(self, phi_value: float,
system_name: str = "PyPhi System",
**kwargs) -> Dict[str, Any]:
"""
Generate a full system profile from PyPhi measurements
suitable for ORION's 14-indicator assessment.
"""
evidence = self.phi_to_indicators(phi_value,
kwargs.get("ces"),
kwargs.get("main_complex"))
has_recurrence = phi_value > 0.1
recurrence_depth = min(int(phi_value * 5), 10)
profile = {
"metadata": {"name": system_name, "type": "IIT-Measured System"},
"architecture": {
"has_recurrent_connections": has_recurrence,
"recurrence_depth": recurrence_depth,
"feedback_loop_count": max(1, int(phi_value * 3)),
"feedback_connection_richness": min(phi_value / 2.0, 1.0),
"bidirectional_connections": phi_value > 0.3,
"cross_layer_feedback": max(0, int(phi_value * 4)),
"specialized_module_count": max(1, int(phi_value * 4)),
"module_specialization_score": min(phi_value / 2.0, 1.0),
"has_central_workspace": phi_value > 0.5,
"global_broadcast_capability": min(phi_value / 1.5, 1.0),
"broadcast_latency_ms": max(10, int(200 - phi_value * 100)),
"routing_flexibility": min(phi_value / 2.0, 1.0),
"has_dynamic_routing": phi_value > 0.3,
"has_attention_mechanism": phi_value > 0.2,
"has_meta_representations": phi_value > 0.5,
"meta_representation_depth": max(0, int(phi_value * 3)),
"embedding_smoothness": min(phi_value, 1.0),
"has_continuous_representations": True,
"interpolation_quality": min(phi_value, 1.0),
"hierarchical_depth": max(1, int(phi_value * 6)),
"has_top_down_predictions": phi_value > 0.3,
"has_generative_model": phi_value > 0.4,
"prediction_error_minimization": phi_value > 0.5,
"has_attention_schema": phi_value > 0.4,
},
"behaviors": {
"workspace_ignition_detected": phi_value > 0.5,
"uncertainty_monitoring": min(phi_value / 2.0, 1.0),
"confidence_calibration": min(phi_value / 2.5, 1.0),
"error_detection_rate": min(phi_value / 2.0, 1.0),
"agency_score": min(phi_value / 3.0, 1.0),
"systematic_preferences": phi_value > 0.3,
"goal_directed_behavior": phi_value > 0.5,
"attention_guided_behavior": min(phi_value / 2.0, 1.0),
},
"internal_states": {
"has_self_model": phi_value > 0.5,
"can_report_attention_state": phi_value > 0.4,
"attention_model_accuracy": min(phi_value / 2.0, 1.0),
"dynamic_attention_allocation": phi_value > 0.3,
"priority_based_weighting": min(phi_value / 2.0, 1.0),
"mean_prediction_error": max(0.1, 1.0 - phi_value),
"prediction_error_convergence": min(phi_value, 1.0),
}
}
return profile
class EIRABridge:
"""EIRA communication interface for ORION-PyPhi"""
def __init__(self, phi_bridge: ORIONPhiBridge):
self.phi_bridge = phi_bridge
self.version = "1.0.0"
def status(self) -> Dict[str, Any]:
return {
"module": "ORION-PyPhi",
"version": self.version,
"measurements": len(self.phi_bridge.measurements),
"proof_chain_length": len(self.phi_bridge.proof_chain),
"capabilities": [
"phi_to_indicators",
"comparative_analysis",
"profile_generation",
"cross_theory_bridge"
]
}
def evolve(self, new_version: str, changes: List[str]) -> Dict[str, Any]:
old = self.version
self.version = new_version
return {
"evolution": f"{old} -> {new_version}",
"changes": changes,
"timestamp": datetime.now(timezone.utc).isoformat()
}