#!/usr/bin/env python """NOT Gate: Structural Steering Test""" from logos.mtl.interpreter import MTLInterpreter mtl = MTLInterpreter() print('=== NOT GATE: STRUCTURAL STEERING TEST ===') # Case 1: N(A)[A,B] -> B (Match first, redirect to second) print('\n[Case 1] N(5)[5, 10] -> Should return 10') result = mtl.execute('(not [5] [5] [10])') print(f' Result: {result}') assert result == 10, f'Expected 10, got {result}' print(' ✅ PASS') # Case 1b: No match returns first print('\n[Case 1b] N(5)[7, 10] -> Should return 7 (no match)') result = mtl.execute('(not [5] [7] [10])') print(f' Result: {result}') assert result == 7, f'Expected 7, got {result}' print(' ✅ PASS') # Case 2: N(A)[B,C,A] -> B(C) (Match last, apply B to C) print('\n[Case 2] N(5)[[2,2,2], [3,3,3], 5] -> Should return [6,6,6]') result = mtl.execute('(not [5] (list 2 2 2) (list 3 3 3) [5])') print(f' Result: {result}') assert result == [6,6,6], f'Expected [6,6,6], got {result}' print(' ✅ PASS') # Case 2b: Integer application print('\n[Case 2b] N(7)[3, 4, 7] -> Should return 12 (3*4)') result = mtl.execute('(not [7] 3 4 [7])') print(f' Result: {result}') assert result == 12, f'Expected 12, got {result}' print(' ✅ PASS') print('\n=== ALL NOT GATE TESTS PASSED ===')