import gradio as gr import json from src.trignum_core.subtractive_filter import SubtractiveFilter # Initialize the zero-model deterministic logic validator sf = SubtractiveFilter() import dataclasses def validate_logic(input_text): if not input_text or len(input_text.strip()) == 0: return "Please input text to validate.", "⚪ N/A", {} # Run the Subtractive Filter result = sf.apply(input_text) # Format the results using the dataclass attributes directly is_valid = result.illogics_removed == 0 state_color = "🔵 BLUE (Logic Stable - Cleared for Takeoff)" if is_valid else "🔴 RED (Illogic Detected - THE FREEZE)" # Format JSON nicely, handling the dataclass serialization details = json.dumps(dataclasses.asdict(result), indent=2) # Generate human readable summary if is_valid: summary = "✅ PASS: The structural integrity of the reasoning is sound. No contradictions, circular logic, or non-sequiturs were detected." else: summary = "❌ FAIL: Structural illogic detected. The reasoning chain is objectively broken prior to any factual verification." return summary, state_color, details # Build the Gradio Interface with gr.Blocks() as demo: gr.Markdown( """ # 🧠 TRIGNUM-300M: The Subtractive Filter ### A Zero-Model Reasoning Integrity Validator TRIGNUM does not use LLMs to check LLMs. It uses a **deterministic logic engine** to catch structural reasoning failures (contradictions, circular logic, non-sequiturs) *before* an AI agent is allowed to act. **Latency:** < 1ms | **Accuracy:** 100% on structural contradictions """ ) with gr.Row(): with gr.Column(): input_box = gr.Textbox( label="Input AI Reasoning or Text", lines=10, placeholder="Paste the output of an LLM here to validate its structural logic..." ) submit_btn = gr.Button("Validate Logic (Subtractive Filter)", variant="primary") gr.Markdown( """ *Try pasting a contradictory statement like:* "The server is completely offline and unreachable. Therefore, we should establish a WebSocket connection to the server to download the logs." """ ) with gr.Column(): state_output = gr.Textbox(label="T-CHIP State", lines=1) summary_output = gr.Textbox(label="Validation Summary", lines=2) json_output = gr.Code(label="Raw Filter Telemetry (JSON)", language="json", lines=15) submit_btn.click( fn=validate_logic, inputs=input_box, outputs=[summary_output, state_output, json_output] ) gr.Markdown( """ --- **Part of the Trignumentality Epistemic Framework** Read the Paper: [10.5281/zenodo.18736774](https://doi.org/10.5281/zenodo.18736774) | GitHub: [Codfski/TRIGNUM-300M-TCHIP](https://github.com/Codfski/TRIGNUM-300M-TCHIP) """ ) if __name__ == "__main__": demo.launch(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="slate"), ssr_mode=False)