Skip to content

Instantly share code, notes, and snippets.

@patham9
Created July 31, 2025 22:07
Show Gist options
  • Select an option

  • Save patham9/56ccaf963266406c33d27826ee6a6f4b to your computer and use it in GitHub Desktop.

Select an option

Save patham9/56ccaf963266406c33d27826ee6a6f4b to your computer and use it in GitHub Desktop.
PLN deriver efficiency: use derivations only for inference in each recursion.
;; Exhaustive-until-depth deriver
(= (Derive $derivationsLast $beliefs $depth $maxdepth)
(if (> $depth $maxdepth)
$beliefs
(let $derivations
(collapse (superpose ((let* (((Sentence $x $Ev1) (superpose $derivationsLast))
((Sentence $y $Ev2) (superpose $beliefs))
($stamp (TupleConcat $Ev1 $Ev2)))
(if (StampDisjoint $Ev1 $Ev2)
(case (|- $x $y) ((($T $TV) (Sentence ($T $TV) $stamp)))) (empty)))
(let (Sentence $z $Ev3) (superpose $beliefs)
(case (|- $z) ((($T3 $TV3) (Sentence ($T3 $TV3) $Ev3))))))))
(Derive $derivations (TupleConcat $beliefs $derivations) (+ $depth 1) $maxdepth))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment