Spaces:
Runtime error
Runtime error
GitHub Copilot
LOGOS v1.0: MTL Turing Complete, Genesis Kernel, SPCW Transceiver, Harmonizer
6d3aa82
| #!/usr/bin/env python | |
| """ | |
| LOGOS MTL Turing Completeness Validation Script | |
| Run: python logos/tools/validate_mtl.py | |
| """ | |
| import os | |
| import sys | |
| # Ensure we can import from logos | |
| sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) | |
| def main(): | |
| print('=' * 60) | |
| print(' LOGOS MTL TURING COMPLETENESS VALIDATION') | |
| print('=' * 60) | |
| from logos.mtl.interpreter import MTLInterpreter | |
| genesis_path = os.path.join(os.path.dirname(__file__), '..', 'mtl', 'genesis.json') | |
| mtl = MTLInterpreter(genesis_path) | |
| tests = [ | |
| ('Mult [2]*[3]', '(mult [2] [3])', 6), | |
| ('Fractran Adder (72 -> 3125)', '(fractran [[5 2] [5 3]] 72)', 3125), | |
| ('If True (10 % 2 == 0)', '(if (divisible? 10 2) 1 0)', 1), | |
| ('If False (10 % 3 != 0)', '(if (divisible? 10 3) 1 0)', 0), | |
| ('Sub (10 - 3)', '(sub 10 3)', 7), | |
| ('Add (10 + 3)', '(add 10 3)', 13), | |
| ('Genesis Lookup', '(mult [MECHANISM] [RESULT])', 6), | |
| ] | |
| print('\n[1] CORE MTL TESTS') | |
| passed = 0 | |
| for name, expr, expected in tests: | |
| try: | |
| result = mtl.execute(expr) | |
| status = 'β ' if result == expected else 'β' | |
| if result == expected: passed += 1 | |
| print(f' {status} {name}: => {result} (expected {expected})') | |
| except Exception as e: | |
| print(f' β {name}: ERROR - {e}') | |
| print('\n[2] DEFUN/RECURSION TEST') | |
| try: | |
| mtl.execute('(defun triple (x) (mult x 3))') | |
| result = mtl.execute('(triple 7)') | |
| expected = 21 | |
| status = 'β ' if result == expected else 'β' | |
| if result == expected: passed += 1 | |
| print(f' {status} (triple 7) => {result} (expected {expected})') | |
| except Exception as e: | |
| print(f' β Defun Test: ERROR - {e}') | |
| print('\n[3] COND TEST') | |
| try: | |
| result = mtl.execute('(cond ((eq? 1 2) 100) ((eq? 2 2) 200) (1 300))') | |
| expected = 200 | |
| status = 'β ' if result == expected else 'β' | |
| if result == expected: passed += 1 | |
| print(f' {status} cond => {result} (expected {expected})') | |
| except Exception as e: | |
| print(f' β Cond Test: ERROR - {e}') | |
| total = len(tests) + 2 # +2 for defun and cond | |
| print(f'\n[SUMMARY] {passed}/{total} tests passed') | |
| print('=' * 60) | |
| return 0 if passed == total else 1 | |
| if __name__ == '__main__': | |
| sys.exit(main()) | |