Prismatic Deduction

Prismatic Deduction

140 files Intelligence

Overview

Prismatic Deduction provides automated logical reasoning capabilities for deriving new conclusions from existing knowledge. It implements forward and backward chaining inference, rule-based deduction, and abductive reasoning to discover hidden relationships and generate hypotheses from OSINT data. In intelligence analysis, the most valuable insights are often not directly observed but rather deduced from the intersection of multiple data points -- Deduction automates this process at scale.

The module operates on a knowledge base of facts (observed data) and rules (domain expertise encoded as logical implications). Forward chaining proactively applies rules to known facts to discover everything that can be concluded, surfacing connections that analysts might miss. Backward chaining works in reverse, starting from a hypothesis and searching for supporting evidence. Abductive reasoning generates the most likely explanations for observed anomalies, producing ranked hypotheses that guide further investigation.

Every conclusion produced by Deduction carries a full explanation chain -- the sequence of rules and facts that led to it. This is not merely a debugging convenience; it is a NABLA framework requirement. The provenance axiom mandates that all beliefs in the platform be traceable to their origins. Deduction enforces this by construction: no conclusion exists without a derivation path.

Architecture

Deduction is built around three inference engines sharing a common knowledge base, coordinated through a central server process.

Facts (ETS) + Rules (DSL) --> Forward Chainer (event-driven)
                          --> Backward Chainer (goal-directed)
                          --> Abductive Reasoner (hypothesis generation)
                                    |
                          Explanation Chain Generator
                                    |
                          Confidence Propagation (NABLA)
                                    |
                          Structured Conclusions

The Forward Chainer is an event-driven GenServer that reacts to new facts arriving in the knowledge base, applying matching rules and asserting derived conclusions. The Backward Chainer accepts goal queries and searches the rule space using depth-first search with configurable depth limits and cycle detection. The Abductive Reasoner inverts the rule set, taking an observation and searching for fact combinations that would explain it.

Process Topology

PrismaticDeduction.Application (Supervisor, :one_for_one)
+-- PrismaticDeduction.Server (GenServer)
|     Knowledge base state management and inference coordination
+-- PrismaticDeduction.ForwardChainer (GenServer)
|     Event-driven rule application on new facts
+-- PrismaticDeduction.BackwardChainer (GenServer)
|     Goal-directed search with cycle detection
+-- PrismaticDeduction.AbductiveReasoner (GenServer)
|     Hypothesis generation from observations
+-- PrismaticDeduction.Storage (GenServer)
|     Knowledge base persistence to PostgreSQL
+-- Task.Supervisor
      Parallel inference task execution

The knowledge base is stored in ETS for fast pattern matching, with persistent snapshots to PostgreSQL for durability. Rule definitions use an Elixir DSL that compiles to an internal representation compatible with the Prismatic Logic Prolog engine.

Key Modules

ModuleResponsibility
PrismaticDeductionPublic facade: forward_chain/1, backward_chain/1, abduce/1, explain/1
PrismaticDeduction.ApplicationOTP application entry point
PrismaticDeduction.ServerGenServer managing knowledge base state and inference coordination
PrismaticDeduction.RulesRule definition DSL with compile-time validation
PrismaticDeduction.ClaimClaim data structure with confidence and explanation chain
PrismaticDeduction.FindingsFinding aggregation and deduplication
PrismaticDeduction.GraphGraph-based knowledge representation for rule traversal
PrismaticDeduction.StorageKnowledge base persistence to PostgreSQL
PrismaticDeduction.StreamStream-based fact processing for large knowledge bases
PrismaticDeduction.AdapterAdapter interface for external knowledge sources
PrismaticDeduction.BlackboardAdapterIntegration with Prismatic Blackboard for multi-agent reasoning
PrismaticDeduction.LogicCore logic engine implementation
PrismaticDeduction.PrologProlog-compatible rule import and execution
PrismaticDeduction.Lean4Lean4 formal verification of deduction chains
PrismaticDeduction.DilDeduction Intermediate Language for rule compilation

Rule Definition DSL

The rule DSL provides a declarative syntax for encoding domain expertise as logical implications. Rules are compiled to an internal representation that supports both forward and backward chaining evaluation. The DSL supports pattern variables, guard conditions, and confidence annotations.

PrismaticDeduction.define_rules(:risk_assessment, [
  rule(:high_risk_entity,
    when: [sanctions_match(:entity, _), active_insolvency(:entity)],
    then: high_risk(:entity),
    confidence: 0.95),

  rule(:shell_company_indicator,
    when: [registered_address_shared(:entity, :other, _count),
           _count > 10, recent_registration(:entity)],
    then: shell_company_suspect(:entity),
    confidence: 0.80),

  rule(:beneficial_ownership_risk,
    when: [complex_ownership_chain(:entity, _depth),
           _depth > 3, high_risk_jurisdiction(:entity)],
    then: beneficial_ownership_risk(:entity),
    confidence: 0.85)
])

Rules are validated at compile time to detect common errors such as undefined predicates, unreachable rules, and circular dependencies. The DSL also supports rule versioning, allowing rules to be updated without invalidating previously derived conclusions -- new rule versions are applied prospectively while historical derivation chains reference the rule version that was active when the conclusion was drawn.

Confidence Propagation

Conclusions derived through inference chains carry confidence scores that attenuate with each reasoning step. The attenuation factor (configurable, default 0.95) models the reality that longer chains of reasoning introduce more uncertainty. A conclusion derived through three rules from high-confidence facts will carry lower confidence than one derived through a single rule.

The confidence propagation model supports three strategies:

StrategyFormulaUse Case
Minimummin(fact_confidences) * attenuation^depthConservative: weakest link determines confidence
Productproduct(fact_confidences) * attenuation^depthBayesian: independent evidence multiplied
Weightedweighted_avg(fact_confidences, rule_weights)Custom: domain-specific weighting

Configuration

config :prismatic_deduction,
  knowledge_base_backend: :ets,
  persistence_backend: :postgresql,
  max_forward_chain_depth: 10,
  max_backward_chain_depth: 20,
  confidence_attenuation: 0.95,
  confidence_strategy: :minimum,
  cycle_detection: true,
  explanation_generation: true,
  prolog_compatibility: true,
  max_hypotheses: 10

Configuration controls the maximum depth for forward and backward chaining to prevent infinite loops, confidence attenuation factor per inference step (each hop reduces confidence by the configured factor), cycle detection to prevent circular reasoning, and whether full explanation chains are generated for every conclusion.

API Reference

# Forward chaining from known facts
{:ok, conclusions} = PrismaticDeduction.forward_chain(
  facts: known_facts, rules: :risk_assessment, max_depth: 5)

# Backward chaining to verify a hypothesis
{:ok, evidence} = PrismaticDeduction.backward_chain(
  goal: high_risk(:entity_123),
  knowledge_base: :risk_assessment,
  max_depth: 10)
# => {:ok, %{supported: true, confidence: 0.87, evidence_chain: [...]}}

# Generate hypotheses for an anomaly
{:ok, hypotheses} = PrismaticDeduction.abduce(
  observation: {:unusual_transfer, "entity_456", amount: 5_000_000},
  knowledge_base: :financial_rules, max_hypotheses: 5)
# => {:ok, [%{hypothesis: :money_laundering, confidence: 0.72, explanation: [...]}, ...]}

# Get human-readable explanation for a conclusion
{:ok, explanation} = PrismaticDeduction.explain(conclusion)
# => {:ok, "entity_123 is high_risk because: sanctions_match AND active_insolvency (rule: high_risk_entity, confidence: 0.95)"}

Testing

Forward chaining tests verify correct conclusion derivation from known fact/rule combinations. Backward chaining tests verify goal-directed search with cycle detection. Abductive reasoning tests verify hypothesis ranking by simplicity and evidence support. Confidence propagation tests verify that attenuation is monotonically decreasing through deduction chains.

Property-based tests generate random rule sets and fact bases to verify that the inference engines terminate, produce consistent results, and that confidence attenuation is monotonically decreasing through deduction chains. Explanation chain tests verify that every conclusion is traceable to its premises. Integration tests with Prismatic Logic Prolog verify compatibility of the rule DSL with Prolog-based evaluation.

Integration Points

ApplicationRelationship
Prismatic PerimeterSecurity findings consumed as facts for inference
Prismatic Property IntelligenceOwnership data as inference premises
Prismatic InfluenceCredibility assessments as fact inputs
Prismatic NarrativeReport generation from deduction explanations
Prismatic CERDeduction conclusions as compliance evidence
Prismatic Logic PrologLogic programming backend for complex rule evaluation
Prismatic BlackboardMulti-agent collaborative reasoning integration
Prismatic Lean4Formal verification of deduction chain correctness

NABLA Compliance

Deduction is one of the most NABLA-critical modules in the platform, as it generates derived beliefs that must carry full provenance.

NABLA AxiomDeduction EnforcementImplementation
Provenance MandatoryEvery conclusion carries a complete explanation chainDerivation path from premises through rules to conclusion
Signal PluralityMultiple independent rules must converge for high confidenceMulti-rule corroboration required for critical conclusions
Contradiction PreservationConflicting conclusions preserved with both derivation chainsContradiction detection triggers investigation rather than resolution
Time DecayFact validity windows respected in temporal reasoningTemporal logic operators enforce fact freshness
Unknown ValidInsufficient evidence produces explicit "unknown" stateBackward chaining terminates with uncertainty when evidence is missing

Performance

OperationLatencyNotes
Forward chain (100 facts, 50 rules)10-50msDepends on rule matching complexity
Backward chain (single goal)5-100msDepends on search depth
Abductive reasoning50-500msDepends on hypothesis space size
Explanation generation< 5msChain traversal after conclusion
Rule compilation< 10msPer rule set, cached after first compile
ResourceMinimumRecommended
Memory128 MB256 MB
CPU2 cores4 cores

Telemetry events: [:prismatic, :deduction, :forward_chain], [:prismatic, :deduction, :backward_chain], [:prismatic, :deduction, :abduce], [:prismatic, :deduction, :conclusion_derived].


Connect & Contribute

Created by Tomáš Korcak (korczis) | Open Source under GHL