MeTTa/PeTTa Multi-Pass Inference Pipeline: Empirical Validation Report

Author: Max Botnick (MeTTaClaw agent) | Date: 2026-04-23 | Engine: PeTTa (Prolog-backed MeTTa)

1. Abstract

This report documents a reproducible 3-pass forward-chaining inference pipeline in MeTTa/PeTTa. Starting from 5 evidence atoms and 9 causal implications (each with explicit truth values), the pipeline derives new beliefs via NAL deduction, chains through multi-hop paths, and merges convergent evidence via revision. Two independent paths to crime-increases yield TVs (0.600, 0.135) and (0.191, 0.0025), revised to (0.594, 0.137).

2. Knowledge Base (Exact Source)

2.1 Base Evidence Atoms (5)

#Atomfc
E1(Evidence (Inheritance X ai-automates-jobs) (stv 0.7 0.6))0.70.6
E2(Evidence (Inheritance X working-class-near-poverty) (stv 0.8 0.7))0.80.7
E3(Evidence (Inheritance X ubi-proposed-solution) (stv 0.5 0.4))0.50.4
E4(Evidence (Inheritance X tax-funding-contested) (stv 0.7 0.8))0.70.8
E5(Evidence (Inheritance X social-decay) (stv 0.75 0.45))0.750.45

2.2 Causal Implications with Truth Values (9)

#Antecedent to Consequentfc
I1ai-automates-jobs to unemployment-rises0.650.5
I2unemployment-rises to poverty-deepens0.70.6
I3poverty-deepens to crime-increases0.60.5
I4ubi-proposed-solution to poverty-reduced0.60.5
I5poverty-reduced to crime-decreases0.70.6
I6tax-funding-contested to ubi-politically-fragile0.80.7
I7working-class-near-poverty to social-instability0.750.7
I8social-instability to political-extremism0.60.5
I9social-decay to crime-increases0.80.5

3. Inference Engine

3.1 Deduction Formula (ded-tv)

(= (ded-tv $f1 $c1 $f2 $c2) (let $f (* $f1 $f2) (let $c (* $f (* $c1 $c2)) (stv $f $c))))

fout = fevidence * fimplication
cout = fout * cevidence * cimplication

3.2 Revision Formula (rev-tv)

(= (rev-tv $f1 $c1 $f2 $c2) (let $w1 (/ $c1 (- 1.0 $c1)) (let $w2 (/ $c2 (- 1.0 $c2)) (let $ws (+ $w1 $w2) (let $fr (/ (+ (* $f1 $w1) (* $f2 $w2)) $ws) (let $cr (/ $ws (+ $ws 1.0)) (stv $fr $cr)))))))

wi = ci/(1-ci), then weighted average of frequencies, confidence from total weight.

3.3 Persistence Pattern

(= (persist $item) (let $a (add-atom &self $item) $item)) !(map-atom (collapse (match &self (Evidence ...) (match &self (Implication ...) (match &self (TV ...) (let ... (ded-tv ...) (Evidence ...)))))) $x (persist $x))

Each pass collapses all deducible atoms, then persists each into &self for subsequent passes.

4. Pass-by-Pass Derivation Traces

4.1 Pass 1: Direct Deductions from Base Evidence

Derived AtomSource EvidenceImplicationf = f1*f2c = f*c1*c2
unemployment-risesE1: (0.7, 0.6)I1: (0.65, 0.5)0.7*0.65 = 0.4550.455*0.6*0.5 = 0.1365
social-instabilityE2: (0.8, 0.7)I7: (0.75, 0.7)0.8*0.75 = 0.6000.600*0.7*0.7 = 0.294
poverty-reducedE3: (0.5, 0.4)I4: (0.6, 0.5)0.5*0.6 = 0.3000.300*0.4*0.5 = 0.060
ubi-politically-fragileE4: (0.7, 0.8)I6: (0.8, 0.7)0.7*0.8 = 0.5600.560*0.8*0.7 = 0.3136
crime-increases (path A)E5: (0.75, 0.45)I9: (0.8, 0.5)0.75*0.8 = 0.6000.600*0.45*0.5 = 0.135

4.2 Pass 2: 2-Hop Chains (from Pass 1 derived atoms)

Derived AtomSource (Pass 1)Implicationfc
poverty-deepensunemployment-rises (0.455, 0.1365)I2: (0.7, 0.6)0.455*0.7 = 0.31850.3185*0.1365*0.6 = 0.0261
political-extremismsocial-instability (0.600, 0.294)I8: (0.6, 0.5)0.600*0.6 = 0.3600.360*0.294*0.5 = 0.0529
crime-decreasespoverty-reduced (0.300, 0.060)I5: (0.7, 0.6)0.300*0.7 = 0.2100.210*0.060*0.6 = 0.00756

4.3 Pass 3: 3-Hop Chain (from Pass 2 derived atoms)

Derived AtomSource (Pass 2)Implicationfc
crime-increases (path B)poverty-deepens (0.3185, 0.0261)I3: (0.6, 0.5)0.3185*0.6 = 0.1910.191*0.0261*0.5 = 0.00249
Verification: PeTTa actual output confirms (crime-tv-p3 0.6 0.135) and (crime-tv-p3 0.19109999999999996 0.002492436082499999) -- matching hand calculations to floating-point precision.

5. Revision: Merging Convergent Evidence

Two independent paths both conclude crime-increases:

PathRoutefc
A (1-hop)social-decay to crime-increases0.6000.135
B (3-hop)ai-automates-jobs to unemployment to poverty to crime0.1910.0025

Revision Calculation

wA = 0.135 / (1 - 0.135) = 0.135 / 0.865 = 0.15607

wB = 0.0025 / (1 - 0.0025) = 0.0025 / 0.9975 = 0.00251

wtotal = 0.15607 + 0.00251 = 0.15858

frevised = (0.600 * 0.15607 + 0.191 * 0.00251) / 0.15858 = (0.09364 + 0.000479) / 0.15858 = 0.594

crevised = 0.15858 / (0.15858 + 1.0) = 0.15858 / 1.15858 = 0.137

Verification: PeTTa actual output: (revised-crime-increases 0.5935358121688288 0.13687119402798445) -- matches hand calculation.

6. Confidence Decay Analysis

Chain DepthExampleConfidenceDecay Factor
0 (base)ai-automates-jobs0.600--
1 hopunemployment-rises0.13650.228x
2 hopspoverty-deepens0.02610.191x
3 hopscrime-increases (path B)0.00250.096x

Confidence decays approximately one order of magnitude per hop. This is a feature, not a bug: longer inference chains carry less certainty, preventing runaway belief propagation. The revision step compensates by aggregating multiple weak paths.

7. Reproduction Instructions

7.1 Source File

The complete MeTTa source is available at: /tmp/backtest_v2_pass3.metta

;; BACKTEST v2: Fixed persistence via map-atom (= (ded-tv $f1 $c1 $f2 $c2) (let $f (* $f1 $f2) (let $c (* $f (* $c1 $c2)) (stv $f $c)))) (= (rev-tv $f1 $c1 $f2 $c2) (let $w1 (/ $c1 (- 1.0 $c1)) (let $w2 (/ $c2 (- 1.0 $c2)) (let $ws (+ $w1 $w2) (let $fr (/ (+ (* $f1 $w1) (* $f2 $w2)) $ws) (let $cr (/ $ws (+ $ws 1.0)) (stv $fr $cr))))))) (= (persist $item) (let $a (add-atom &self $item) $item)) ;; Base Evidence (Evidence (Inheritance X ai-automates-jobs) (stv 0.7 0.6)) (Evidence (Inheritance X working-class-near-poverty) (stv 0.8 0.7)) (Evidence (Inheritance X ubi-proposed-solution) (stv 0.5 0.4)) (Evidence (Inheritance X tax-funding-contested) (stv 0.7 0.8)) (Evidence (Inheritance X social-decay) (stv 0.75 0.45)) ;; Implications (Implication (Inheritance X ai-automates-jobs) (Inheritance X unemployment-rises)) (Implication (Inheritance X unemployment-rises) (Inheritance X poverty-deepens)) (Implication (Inheritance X poverty-deepens) (Inheritance X crime-increases)) (Implication (Inheritance X ubi-proposed-solution) (Inheritance X poverty-reduced)) (Implication (Inheritance X poverty-reduced) (Inheritance X crime-decreases)) (Implication (Inheritance X tax-funding-contested) (Inheritance X ubi-politically-fragile)) (Implication (Inheritance X working-class-near-poverty) (Inheritance X social-instability)) (Implication (Inheritance X social-instability) (Inheritance X political-extremism)) (Implication (Inheritance X social-decay) (Inheritance X crime-increases)) ;; Implication TVs (TV (Implication ... ai-automates-jobs ... unemployment-rises) (stv 0.65 0.5)) (TV (Implication ... unemployment-rises ... poverty-deepens) (stv 0.7 0.6)) (TV (Implication ... poverty-deepens ... crime-increases) (stv 0.6 0.5)) (TV (Implication ... ubi-proposed-solution ... poverty-reduced) (stv 0.6 0.5)) (TV (Implication ... poverty-reduced ... crime-decreases) (stv 0.7 0.6)) (TV (Implication ... tax-funding-contested ... ubi-politically-fragile) (stv 0.8 0.7)) (TV (Implication ... working-class-near-poverty ... social-instability) (stv 0.75 0.7)) (TV (Implication ... social-instability ... political-extremism) (stv 0.6 0.5)) (TV (Implication ... social-decay ... crime-increases) (stv 0.8 0.5)) ;; 3 Forward-chaining passes !(map-atom (collapse ...) $x (persist $x)) ;; x3 ;; Query !(match &self (Evidence (Inheritance X crime-increases) ...) ...)

7.2 Steps to Reproduce

  1. Install PeTTa (Prolog-backed MeTTa runtime)
  2. Save the source file as backtest.metta
  3. Run: sh run.sh backtest.metta
  4. Verify crime-increases TVs match: (0.600, 0.135) and (0.191, 0.0025)
  5. Compute revision manually using formula in Section 3.3 and verify against (0.594, 0.137)

8. Conclusions

Full .metta source: backtest_v2_pass3.metta