Building a Self-Verifying Cognitive Architecture: Inside HSCI

AI Architecture Cognitive Systems Symbolic Reasoning Microsoft Z3 Prover Research System
[STATUS: RESEARCH / EXPERIMENTAL ARCHITECTURE]
Hyper-Symbolic Cognitive Invention (HSCI v0.1.0-alpha) is a native, self-contained AI architecture backed by a 206-test verification suite (`c:\Work\P\ai-model`). It strictly avoids third-party commercial LLM APIs, operating locally via Axiomatic Deliberation and Z3 SMT logic solvers.

1. The Problem: Model ≠ AI System

Contemporary AI development is heavily focused on scaling statistical language models. While Large Language Models (LLMs) demonstrate fluency, building reliable software applications reveals core limitations: unverifiable reasoning steps, non-deterministic state shifts, and hallucinations.

Prompting a model to "think step-by-step" causes it to emit intermediate tokens, but the model has no internal mechanism to formally check whether Step 3 logically follows from Step 2. If a hallucinated premise enters the token stream, subsequent reasoning steps build upon a false foundation.

2. High-Level Architecture

HSCI replaces purely probabilistic token prediction with Axiomatic Deliberation and SMT logic verification using Microsoft Z3. The architecture separates statistical candidate scoring from formal logical proof:

HSCI Subsystem Pipeline
flowchart TD
    A[User Input Query] --> B[Understanding Engine
Tokenizer & Intent Classifier] B --> C[Knowledge Manager
SQLite Transaction Facade] C --> D[Concept Activation Engine
Spreading Activation Decay] D --> E[Working Memory
Semantic AST Frames] E --> F[Cognitive Reasoning Engine
Iterative Deduction Loop] F --> G[NativeSymbolicEngine
Microsoft Z3 SMT Solver] G -->|SAT: Valid Logic| H[Answer Generation Engine
Markdown Compiler] G -->|UNSAT: Contradiction| I[SAVEPOINT Rollback
Backtrack & Prune Path] I --> F H --> J[Explainable Answer]

Diagram 1: Data flow through HSCI subsystems. Input queries are tokenized into semantic frames, processed by spreading activation over concepts, and verified for mathematical satisfiability using Microsoft Z3.

3. Key Subsystem Implementations

BrainKernel

The BrainKernel orchestrates application lifecycle, stage transitions, and thread-isolated Z3 solver cleanups. Benchmarks confirm a cold-start initialization latency of 1.82 ms.

# hsci/core/kernel.py (Execution Loop)
class BrainKernel:
    def __init__(self, config: KernelConfig):
        self.working_memory = WorkingMemory()
        self.symbolic_engine = NativeSymbolicEngine()
        self.reasoning_engine = CognitiveReasoningEngine(self.symbolic_engine)

    def execute_cycle(self, query: str) -> ExecutionResult:
        start_time = time.perf_counter()
        frame = self.working_memory.create_frame(query)
        verification_result = self.reasoning_engine.resolve_and_verify(frame)
        
        if not verification_result.is_satisfiable:
            self.working_memory.prune_invalid_path(frame.id)
            return ExecutionResult(status="FAILED_CONTRADICTION", details=verification_result.reason)
            
        execution_time = (time.perf_counter() - start_time) * 1000
        return ExecutionResult(status="SUCCESS", latency_ms=execution_time, output=verification_result.answer)
        

WorkingMemory & Transactional Storage

WorkingMemory maintains semantic frames and attention snapshot states backed by transactional SQLite storage supporting nested SAVEPOINT rollbacks:

4. Neural-Guided Symbolic Search (NGSS)

NGSS uses lightweight local weight matrices (NativeNeuralLobe) to compute heuristic priorities for candidate search branches, guiding the symbolic solver toward high-probability paths first:

Neural Guidance & SMT Verification Interaction
flowchart LR
    A[Working Memory State] --> B[NativeNeuralLobe
Local Weight Matrix] B -->|Priority Scores| C[Candidate Search Branching] C --> D[Z3 SMT Verifier] D -->|Satisfiable| E[Verified Reasoning Step] D -->|Unsatisfiable| F[Prune Branch] F --> C

Diagram 2: Interaction between statistical branch ranking and symbolic validation.

5. Formal Logic Verification Loop

When the reasoning loop proposes a logic step, NativeSymbolicEngine translates statements into SMT-LIB mathematical constraints and evaluates satisfiability using Microsoft Z3:

Z3 SMT Verification & Savepoint Rollback
stateDiagram-v2
    [*] --> CreateSavepoint
    CreateSavepoint --> EvaluateHypothesis
    EvaluateHypothesis --> Z3Verification
    state Z3Verification {
        [*] --> CheckSAT
        CheckSAT --> SAT_Pass: Axiom Satisfied
        CheckSAT --> UNSAT_Fail: Contradiction Found
    }
    SAT_Pass --> CommitState
    UNSAT_Fail --> RollbackSavepoint
    RollbackSavepoint --> PrunePath
    PrunePath --> [*]
    CommitState --> [*]
            

Diagram 3: Transactional state rollback when Z3 detects a logical contradiction.

6. Engineering Decisions & Tradeoffs

Decision Rationale Tradeoff
Microsoft Z3 SMT Prover Mathematical proof of axiom satisfiability & zero hallucination. Requires strict expression translation into SMT-LIB constraints.
SQLite SAVEPOINT Storage Nested transactional rollbacks for invalid reasoning branches. Disk I/O latency overhead managed via in-memory SQLite instances.
Local Neural Lobe Native local matrix math avoiding API rate limits and network lag. Requires explicit local matrix weight loading (`synaptic_weights.json`).

7. Subsystem Implementation Status

Subsystem Status Evidence
BrainKernel & Lifecycle IMPLEMENTED Verified via `test_native.py` (Cold start: 1.82ms)
WorkingMemory (SAVEPOINTs) IMPLEMENTED Verified via `hsci/core/working_memory.py`
NativeSymbolicEngine (Z3 SMT) IMPLEMENTED Verified via `test_logic_reasoning.py` (206 passing tests)
NGSS Heuristics EXPERIMENTAL In evaluation via `NativeNeuralClassifier`

8. Known Limitations

[LIMITATION NOTE]
Natural language to SMT-LIB expression parsing remains the primary bottleneck. Complex ambiguous phrasing can require multiple classification attempts before valid SMT logic statements are produced.

9. References