/** * symbolic-neural-bridge.ts - AIQL v2.2.0 Symbolic-Neural Bridge * * Validates and grounds neural network (LLM) outputs in symbolic AIQL structures. * Detects hallucinations, ensures semantic coherence, and validates relation semantics. * * Design Philosophy: * - Neural outputs must ground in symbolic knowledge graph * - Hallucinations detected through semantic inconsistency * - Relation validation preserves graph coherence * - Bridge enables safe LLM-to-AIQL translation */ import { InferenceEngine } from '@aiql-org/inference'; import * as AST from '@aiql-org/core'; /** * Grounding result: How well neural output maps to symbolic KB */ export interface GroundingResult { grounded: boolean; confidence: number; validStatements: AST.Statement[]; invalidStatements: AST.Statement[]; reasons: string[]; } /** * Semantic coherence check result */ export interface CoherenceResult { coherent: boolean; coherenceScore: number; violations: Array<{ statement: AST.Statement; violationType: 'type-mismatch' | 'relation-invalid' | 'concept-unknown' | 'confidence-low'; reason: string; }>; } /** * Hallucination detection result */ export interface HallucinationResult { hasHallucinations: boolean; hallucinatedStatements: Array<{ statement: AST.Statement; reason: string; confidence: number; }>; validStatements: AST.Statement[]; } /** * Relation validation result */ export interface RelationValidationResult { valid: boolean; reason?: string; suggestedAlternatives?: string[]; } /** * SymbolicNeuralBridge - Safe LLM-to-AIQL translation * * Grounds neural network outputs in symbolic knowledge structures, * ensuring semantic correctness and detecting hallucinations. */ export declare class SymbolicNeuralBridge { /** * Ground neural output (LLM response) in symbolic knowledge base * * Validates that LLM-generated AIQL code: * 1. Parses correctly (syntactic validity) * 2. References known concepts (semantic grounding) * 3. Uses valid relations (relation grounding) * 4. Maintains graph coherence (structural validity) * * @param llmResponse - Raw AIQL code from LLM * @param context - Context concepts that should appear * @param kb - InferenceEngine with background knowledge * @returns Grounding result with validated statements */ groundNeuralOutput(llmResponse: string, context: string[], kb: InferenceEngine): GroundingResult; /** * Check semantic coherence of statement with KB context * * Validates: * - Type consistency (meta-concept categories) * - Relation domain/range constraints * - Confidence thresholds * - Concept existence * * @param statement - Statement to validate * @param context - Contextual concepts * @param kb - InferenceEngine with background knowledge * @returns Coherence result with violations */ checkSemanticCoherence(statement: AST.Statement, context: string[], kb: InferenceEngine): CoherenceResult; /** * Validate relation semantics: Does this relation make sense? * * Checks: * - Known relations in KB * - Meta-relation constraints * - Common-sense relation patterns * - Type compatibility * * @param subject - Subject concept name * @param relation - Relation name * @param object - Object concept name * @param kb - InferenceEngine with background knowledge * @returns Validation result with alternatives */ validateRelationSemantics(subject: string, relation: string, object: string, kb: InferenceEngine): RelationValidationResult; /** * Detect hallucinations in statements * * Hallucination indicators: * - Statements contradicting KB * - Impossible relations (semantic violations) * - Unknown concepts with high confidence * - Circular reasoning * * @param statements - Statements to check * @param kb - InferenceEngine with background knowledge * @returns Hallucination detection result */ detectHallucinations(statements: AST.Statement[], kb: InferenceEngine): HallucinationResult; /** * Extract all statements from program */ private extractStatements; /** * Get all known concepts from KB */ private getKnownConcepts; /** * Get all known relations from KB */ private getKnownRelations; /** * Validate statement grounding */ private validateStatementGrounding; /** * Suggest similar relations */ private suggestSimilarRelations; /** * Check common-sense relation patterns */ private checkRelationPatterns; /** * Check if statement contradicts KB */ private checkContradiction; } //# sourceMappingURL=symbolic-neural-bridge.d.ts.map