#!/usr/bin/env python3
"""
EDEN SYMBOLIC REASONING TEST (LIVE)
- Extracted from Memory ID: v5_1768236144
- Goal: Analyze code structure (AST) without execution.
"""
import ast
from collections import defaultdict

class EdenLogicScanner(ast.NodeVisitor):
    def __init__(self):
        self.counts = defaultdict(int)
        self.variables = []

    def visit_Name(self, node):
        # We only care about variables being loaded (read), not set.
        if isinstance(node.ctx, ast.Load):
            self.counts[node.id] += 1
            if node.id not in self.variables:
                self.variables.append(node.id)
        self.generic_visit(node)

def analyze_logic(source_code):
    print(f"🦁 SCANNING SOURCE CODE:\n{'-'*20}\n{source_code}\n{'-'*20}")
    
    # 1. Parse text into Abstract Syntax Tree (Pure Logic)
    tree = ast.parse(source_code)
    
    # 2. Deploy the Scanner
    scanner = EdenLogicScanner()
    scanner.visit(tree)
    
    # 3. Report Findings
    print(f"🧠 SYMBOLIC ANALYSIS:")
    print(f"   - Detected Variables: {scanner.variables}")
    print(f"   - Usage Counts: {dict(scanner.counts)}")
    
    if 'mass' in scanner.counts and 'speed_of_light' in scanner.counts:
        print("✅ VERDICT: Logic Validated. Eden understands physics equations structurally.")
    else:
        print("❌ VERDICT: Logic Failure.")

if __name__ == "__main__":
    # Test Case: E = mc^2
    test_code = "energy = mass * (speed_of_light ** 2)"
    analyze_logic(test_code)
