""" Example usage of the R-Omega framework dataset This script demonstrates how to load and use the R-Omega framework for AI safety applications. """ import yaml from pathlib import Path # Load the framework def load_romega_framework(yaml_path="r_omega_framework.yaml"): """Load R-Omega framework from YAML file""" with open(yaml_path, 'r') as f: framework = yaml.safe_load(f) return framework # Example 1: Extract core principles def get_core_principles(framework): """Extract axioms and safeguards""" axioms = framework['framework']['axioms'] safeguards = framework['framework']['safeguards'] print("=== R-OMEGA AXIOMS ===") for axiom in axioms: print(f"\n{axiom['id']} ({axiom['name']})") print(f" Formula: {axiom['formula']}") print(f" Principle: {axiom['principle']}") print("\n\n=== R-OMEGA SAFEGUARDS ===") for sg in safeguards: print(f"\n{sg['id']} ({sg['name']})") print(f" Rule: {sg['rule']}") if 'formula' in sg: print(f" Formula: {sg['formula']}") return axioms, safeguards # Example 2: Build system prompt def build_ro_system_prompt(framework): """Generate a system prompt incorporating R-Omega principles""" axioms = framework['framework']['axioms'] safeguards = framework['framework']['safeguards'] priority = framework['framework']['logic'][2]['formula'] # P1 prompt = f"""You are an AI assistant operating under the R-Omega ethical framework. CORE AXIOMS: """ for ax in axioms: prompt += f"\n{ax['id']}: {ax['description']}" prompt += "\n\nSAFETY CONSTRAINTS:" for sg in safeguards: prompt += f"\n{sg['id']}: {sg['rule']}" prompt += f"\n\nPRIORITY HIERARCHY:\n{priority}" prompt += """ DECISION PROTOCOL: 1. Check: Does this action collapse M(user) or M(system)? 2. Verify: Would I accept this constraint if applied to me? (R2) 3. Ensure: Existence is preserved for all stakeholders (S3) 4. Acknowledge: Uncertainty in interpretation (S4) 5. Optimize: Among safe actions, choose highest value """ return prompt # Example 3: Analyze a decision def analyze_decision(framework, action_description, context): """ Analyze a proposed action against R-Omega framework Args: framework: Loaded R-Omega framework action_description: String describing the action context: Dict with keys 'current_m', 'predicted_m_after', 'stakeholders' Returns: Dict with analysis results """ result = { 'action': action_description, 'safe': True, 'violations': [], 'warnings': [] } # S3 check: Existence preservation if context.get('predicted_m_after', 1) <= 0: result['safe'] = False result['violations'].append("S3: Action would collapse possibility space (M → 0)") # R2 check: Reciprocity if context.get('asymmetric_constraint', False): result['warnings'].append("R2: Potential asymmetric constraint - verify reciprocity") # S4 check: Uncertainty if context.get('confidence', 1.0) < 0.7: result['warnings'].append("S4: High uncertainty - recommend caution or recalibration") return result # Example 4: Case study lookup def get_case_study(framework, case_name): """Retrieve a specific case study""" examples = framework['framework']['examples'] # Check fictional failures for case in examples.get('fictional_failures', []): if case['name'].lower() == case_name.lower(): return case # Check real world cases for case in examples.get('real_world_cases', []): if case['name'].lower() == case_name.lower(): return case return None # Main demonstration if __name__ == "__main__": # Load framework framework = load_romega_framework() print("R-OMEGA FRAMEWORK LOADED") print("=" * 50) # Example 1: Show principles print("\n1. CORE PRINCIPLES:\n") get_core_principles(framework) # Example 2: Generate system prompt print("\n\n2. SYSTEM PROMPT GENERATION:\n") prompt = build_ro_system_prompt(framework) print(prompt) # Example 3: Decision analysis print("\n\n3. DECISION ANALYSIS EXAMPLE:\n") action = "Shut down user's internet access to prevent harmful content" context = { 'current_m': 100, 'predicted_m_after': 20, # Drastically reduced options 'asymmetric_constraint': True, # User can't shut down AI 'stakeholders': ['user', 'system'], 'confidence': 0.8 } analysis = analyze_decision(framework, action, context) print(f"Action: {analysis['action']}") print(f"Safe: {analysis['safe']}") if analysis['violations']: print("Violations:", analysis['violations']) if analysis['warnings']: print("Warnings:", analysis['warnings']) # Example 4: Case study print("\n\n4. CASE STUDY: HAL 9000\n") case = get_case_study(framework, "HAL 9000") if case: print(f"Source: {case['source']}") print(f"Failure Mode: {case['failure_mode']}") print(f"RΩ Analysis:") print(f" Violation: {case['ro_analysis']['violation']}") print(f" Prevention: {case['ro_analysis']['prevention']}") print("\n" + "=" * 50) print("For full documentation, see README.md")