File size: 3,257 Bytes
71d3d49
 
 
 
 
2ee1a1f
71d3d49
401069d
 
71d3d49
 
 
 
 
 
 
401069d
 
71d3d49
 
401069d
 
71d3d49
 
 
 
 
 
 
 
 
 
c0184a4
71d3d49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c0184a4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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)