Created
June 12, 2025 15:44
-
-
Save patham9/71005e6f3d0cad1d8583f3177c181363 to your computer and use it in GitHub Desktop.
PLN v0.2 for MeTTa-Morph
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;PLN for MeTTa-Morph, based on PLN 0f2e0008f82cefdf53585d0bc103489e00b77de7 of June 12, 2025. | |
| ;What made it work: | |
| ;1. mettamorph extension for (empty) | |
| ;2. removal of functions that are already in the stdlib of mettamorph | |
| ;3. Replaced if occurrences with If of Mettamorph | |
| ;4. Represented implication sentences with functions to avoid floating vars | |
| ;mettamorph extension: | |
| (= (empty) ()) ;todo make it call amb-failure-continuation | |
| ; MeTTa standard lib extension (already in MeTTa-Morph) | |
| ;(: (max (-> Number Number Number))) | |
| ;(= (max $1 $2) | |
| ; (If (> $1 $2) $1 $2)) | |
| ;(: (min (-> Number Number Number))) | |
| ;(= (min $1 $2) | |
| ; (If (< $1 $2) $1 $2)) | |
| ;(: (clamp (-> Number Number Number Number))) (3-ary input typing pattern not supported by MeTTa-Morph) | |
| (= (clamp $v $min $max) | |
| (min $max (max $v $min))) | |
| (= (TupleConcat $Ev1 $Ev2) | |
| (collapse (superpose ((superpose $Ev1) (superpose $Ev2))))) | |
| (= (and5 $0 $1 $2 $3 $4) (and $0 (and $1 (and $2 (and $3 $4))))) | |
| (= (min5 $0 $1 $2 $3 $4) (min $0 (min $1 (min $2 (min $3 $4))))) | |
| (= (/safe $A $B) | |
| (If (> $B 0.0) | |
| (/ $A $B) | |
| (empty))) | |
| (= (negate $arg) (- 1.0 $arg)) | |
| (= (invert $arg) (/ 1.0 $arg)) | |
| ; Consistency Conditions: PLN book "5.2.2.2 PLN Deduction and Second-Order Probability", page 74: | |
| ; borrowed from https://github.com/trueagi-io/hyperon-pln/blob/main/metta/pln/dependent-types/DeductionDTL.metta | |
| (: smallest-intersection-probability (-> Number Number Number)) | |
| (= (smallest-intersection-probability $As $Bs) | |
| (clamp (/ (- (+ $As $Bs) 1) $As) 0 1)) | |
| (: largest-intersection-probability (-> Number Number Number)) | |
| (= (largest-intersection-probability $As $Bs) | |
| (clamp (/ $Bs $As) 0 1)) | |
| (: conditional-probability-consistency (-> Number Number Number Bool)) | |
| (= (conditional-probability-consistency $As $Bs $ABs) | |
| (and (< 0 $As) | |
| (and (<= (smallest-intersection-probability $As $Bs) $ABs) | |
| (<= $ABs (largest-intersection-probability $As $Bs))))) | |
| (= (Consistency_ImplicationImplicantConjunction $As $Bs $Cs $ACs $BCs) | |
| ; Conditional probability consistency checks: | |
| ; P(C|A) <= P(C)/P(A) => $sAC <= $sC / $sA | |
| ; P(C|B) <= P(C)/P(B) => $sBC <= $sC / $sB | |
| ; Also ensure denominators are not zero for the checks. | |
| (and5 (> $As 0) (> $Bs 0) (> $Cs 0) ; Avoid division by zero and ensure meaningful probabilities | |
| (<= $ACs (/ $Cs $As)) | |
| (<= $BCs (/ $Cs $Bs)))) | |
| ;; TRUTH FORMULAS | |
| ; Deduction formula: PLN book "1.4 Truth-value Formulas", page 15: | |
| ; borrowed from https://github.com/trueagi-io/hyperon-pln/blob/main/metta/pln/dependent-types/DeductionDTL.metta | |
| (= (Truth_Deduction (stv $Ps $Pc) | |
| (stv $Qs $Qc) | |
| (stv $Rs $Rc) | |
| (stv $PQs $PQc) | |
| (stv $QRs $QRc)) | |
| (If (and (conditional-probability-consistency $Ps $Qs $PQs) | |
| (conditional-probability-consistency $Qs $Rs $QRs)) | |
| ;; Preconditions are met | |
| (stv (If (< 0.9999 $Qs) ; avoid division by 0 | |
| ;; Qs tends to 1 | |
| $Rs | |
| ;; Otherwise | |
| (+ (* $PQs $QRs) (/safe (* (- 1 $PQs) (- $Rs (* $Qs $QRs))) (- 1 $Qs)))) | |
| (min $Pc (min $Qc (min $Rc (min $PQc $QRc))))) | |
| ;; Preconditions are not met | |
| (stv 1 0))) | |
| ; Induction formula: PLN book "Appendix A: Comparison of PLN Rules with NARS Rules", page 307 | |
| (= (Truth_Induction (stv $sA $cA) | |
| (stv $sB $cB) | |
| (stv $sC $cC) | |
| (stv $sBA $cBA) | |
| (stv $sBC $cBC)) | |
| (stv (+ (/safe (* (* $sBA $sBC) $sB) $sA) | |
| (* (- 1 (/safe (* $sBA $sB) $sA)) | |
| (/safe (- $sC (* $sB $sBC)) (- 1 $sB)))) | |
| (Truth_w2c (min $cBA $cBC)))) ;confidence TODO check | |
| ; Abduction formula: PLN book "Appendix A: Comparison of PLN Rules with NARS Rules", page 307 | |
| (= (Truth_Abduction (stv $sA $cA) | |
| (stv $sB $cB) | |
| (stv $sC $cC) | |
| (stv $sAB $cAB) | |
| (stv $sCB $cCB)) | |
| (stv (+ (/safe (* (* $sAB $sCB) $sC) | |
| $sB) | |
| (/safe (* $sC (* (- 1 $sAB) (- 1 $sCB))) | |
| (- 1 $sB))) | |
| (Truth_w2c (min $cAB $cCB)))) ;confidence TODO check | |
| ;Modus Ponens: PLN book "5.7.1 Modus Ponens", page 111: | |
| (= (Truth_ModusPonens (stv $f1 $c1) (stv $f2 $c2)) | |
| (stv (+ (* $f1 $f2) (* 0.02 (- 1 $f1))) | |
| (min $c1 $c2))) | |
| ; SymmetricModusPonens rule see https://github.com/opencog/pln/blob/master/opencog/pln/rules/wip/symmetric-modus-ponens.scm | |
| (= (Truth_SymmetricModusPonens (stv $sA $cA) (stv $sAB $cAB)) | |
| (let* | |
| (($snotAB 0.2) | |
| ($cnotAB 1.0)) | |
| (stv | |
| (+ (* $sA $sAB) (* (* $snotAB (negate $sA)) (+ 1.0 $sAB))) | |
| (min (min $cAB $cnotAB) $cA)))) | |
| ;Revision: PLN Book "5.10.2 A Heuristic Revision Rule for Simple Truth-values", page 116: | |
| (: Truth_c2w (-> Number Number)) | |
| (= (Truth_c2w $c) | |
| (/safe $c (- 1 $c))) | |
| (: Truth_w2c (-> Number Number)) | |
| (= (Truth_w2c $w) | |
| (/safe $w (+ $w 1))) | |
| (= (Truth_Revision (stv $f1 $c1) (stv $f2 $c2)) | |
| (let* (($w1 (Truth_c2w $c1)) ($w2 (Truth_c2w $c2)) ($w (+ $w1 $w2)) | |
| ($f (/safe (+ (* $w1 $f1) (* $w2 $f2)) $w)) ($c (Truth_w2c $w))) | |
| (stv (min 1.00 $f) | |
| (min 1.0 (max (max $c $c1) $c2))))) | |
| ; negation, see https://github.com/opencog/pln/blob/master/opencog/pln/rules/wip/negation-introduction.scm#L41 | |
| ; negation elimination, see https://github.com/opencog/pln/blob/master/opencog/pln/rules/wip/not-elimination.scm#L34 | |
| (= (Truth_negation (stv $s $c)) | |
| (stv (- 1.0 $s) $c)) | |
| (= (Truth_inversion (stv $Bs $Bc) (stv $ABs $ABc)) | |
| ; confidence depends on Truth of (target) B node, which is not according to OpenCOG classic. | |
| ; confidence penality not according to OpenCOG classic PLN. Is weaker in this implementation. | |
| (stv $ABs (* $Bc (* $ABc 0.6)))) | |
| ; see https://github.com/opencog/pln/blob/master/opencog/pln/rules/wip/equivalence-to-implication.scm | |
| (= (Truth_equivalenceToImplication (stv $As $Ac) (stv $Bs $Bc) (stv $ABs $ABc)) | |
| (let* (($ConclS (If (< 0.99 (* $ABs $ABc)) ; Hack to work around the lack of distributional | |
| ; TV. If ABs is high enough, we just set $ConclS as $ABs | |
| $ABs | |
| ;; Formula based on PLN book formula for sim2inh | |
| (/safe (* (+ 1.0 (/safe $Bs $As)) $ABs) (+ 1.0 $ABs))))) | |
| (stv $ConclS $ABc))) | |
| (= (ImplicationImplicantConjunctionStrength $sC $sAC $sBC) | |
| (min (/safe (* $sAC $sBC) $sC) 1.0)) | |
| (= (ImplicationImplicantConjunctionConfidence $cAC $cBC) | |
| (min $cAC $cBC)) | |
| ; Implication Implicant Conjunction Rule, see https://github.com/opencog/pln/blob/75815f9f21ad899f44eccba1921fa253a7c6216f/opencog/pln/rules/wip/implication-implicant-conjunction.scm | |
| (= (Truth_ImplicationImplicantConjunction (stv $As $Ac) (stv $Bs $Bc) (stv $Cs $Cc) (stv $ACs $ACc) (stv $BCs $BCc)) | |
| (If (Consistency_ImplicationImplicantConjunction $As $Bs $Cs $ACs $BCs) | |
| (stv (ImplicationImplicantConjunctionStrength $Cs $ACs $BCs) | |
| (ImplicationImplicantConjunctionConfidence $ACc $BCc)) | |
| ; Preconditions are not met | |
| (stv 1 0))) | |
| ; Implication Implicant Disjunction Strength Formula | |
| (= (ImplicationImplicantDisjunctionStrength $sA $sB $sAC $sBC) | |
| (let* (($CinterA (* $sAC $sA)) | |
| ($CinterB (* $sBC $sB)) | |
| ($Numerator (+ $CinterA (+ $CinterB (* $CinterA (* $CinterB (* $sA (* $sB -1.0))))))) ; As per Scheme code | |
| ($Denominator (+ (+ $sA $sB) (* $sA (* $sB -1.0))))) | |
| (/safe $Numerator $Denominator))) | |
| ; Implication Implicant Disjunction Rule, see https://github.com/opencog/pln/blob/master/opencog/pln/rules/wip/implication-implicant-disjunction.scm | |
| (= (Truth_ImplicationImplicantDisjunction (stv $sA $cA) (stv $sB $cB) (stv $sC $cC) (stv $sAC $cAC) (stv $sBC $cBC)) | |
| (stv (ImplicationImplicantDisjunctionStrength $sA $sB $sAC $sBC) | |
| (min $cAC $cBC))) | |
| ; see https://github.com/opencog/pln/blob/master/opencog/pln/rules/wip/inheritance-to-member.scm | |
| (= (Truth_inheritanceToMember (stv $s $c)) | |
| (stv $s (* $c 0.9))) | |
| ; see https://github.com/opencog/pln/blob/master/opencog/pln/rules/wip/formulas.scm#L160-L173 | |
| (= (TransitiveSimilarityStrength $sA $sB $sC $sAB $sBC) | |
| (let* (($T1 (/ (* (+ 1.0 (/ $sB $sA)) $sAB) (+ 1.0 $sAB))) | |
| ($T2 (/ (* (+ 1.0 (/ $sC $sB)) $sBC) (+ 1.0 $sBC))) | |
| ($T3 (/ (* (+ 1.0 (/ $sB $sC)) $sBC) (+ 1.0 $sBC))) | |
| ($T4 (/ (* (+ 1.0 (/ $sA $sB)) $sAB) (+ 1.0 $sAB)))) | |
| (invert (- (+ (invert (+ (* $T1 $T2) (* (negate $T1) (/safe (- $sC (* $sB $T2)) (negate $sB))))) | |
| (invert (+ (* $T3 $T4) (* (negate $T3) (/safe (- $sC (* $sB $T4)) (negate $sB)))))) 1.0)))) | |
| ; see https://github.com/opencog/pln/blob/master/opencog/pln/rules/wip/transitive-similarity.scm | |
| (= (Truth_transitiveSimilarity (stv $As $Ac) | |
| (stv $Bs $Bc) | |
| (stv $Cs $Cc) | |
| (stv $ABs $ABc) | |
| (stv $BCs $BCc)) | |
| (let* (($ConclS (TransitiveSimilarityStrength $As $Bs $Cs $ABs $BCs)) | |
| ($ConclC (min $ABc $BCc))) | |
| (stv $ConclS $ConclC))) | |
| ; see https://github.com/opencog/pln/blob/master/opencog/pln/rules/wip/formulas.scm | |
| (= (simpleDeductionStrength $sA $sB $sC $sAB $sBC) | |
| (If (and (conditional-probability-consistency $sA $sB $sAB) | |
| (conditional-probability-consistency $sB $sC $sBC)) | |
| ;; Preconditions are met | |
| (If (< 0.99 $sB) | |
| ;; sB tends to 1 | |
| $sC | |
| ;; otherwise | |
| (+ (* $sAB $sBC) (/safe (* (- 1.0 $sAB) (- $sC (* $sB $sBC))) (- 1.0 $sB)))) | |
| ;; Preconditions are not met | |
| (empty))) | |
| ; see https://github.com/opencog/pln/blob/master/opencog/pln/rules/wip/evaluation-implication.scm | |
| (= (Truth_evaluationImplication (stv $As $Ac) | |
| (stv $Bs $Bc) | |
| (stv $Cs $Cc) | |
| (stv $ABs $ABc) | |
| (stv $ACs $ACc)) | |
| (let* (($ConclS (simpleDeductionStrength $Bs $As $Cs $ABs $ACs)) | |
| ($ConclC (* (* 0.9 0.9) | |
| (min5 $Bc $Ac $Cc $ACc (* 0.9 $ABc))))) | |
| (stv $ConclS $ConclC))) | |
| ;; INFERENCE RULES | |
| ;Revision | |
| (= (|- ($T $T1) | |
| ($T $T2)) | |
| ($T (Truth_Revision $T1 $T2))) | |
| ;Modus Ponens | |
| (= (|- ($A $T1) | |
| ((Implication $A $B) $T2)) | |
| ($B (Truth_ModusPonens $T1 $T2))) | |
| ; guard to only allow inference for certain link types | |
| (= (SymmetricModusPonensRuleGuard Similarity) True) | |
| (= (SymmetricModusPonensRuleGuard IntentionalSimilarity) True) | |
| (= (SymmetricModusPonensRuleGuard ExtensionalSimilarity) True) | |
| ; SymmetricModusPonens rule, see https://github.com/opencog/pln/blob/master/opencog/pln/rules/wip/symmetric-modus-ponens.scm | |
| (= (|- ($A $TruthA) | |
| (($LinkType $A $B) $TruthAB)) | |
| (If (SymmetricModusPonensRuleGuard $LinkType) | |
| ($B (Truth_SymmetricModusPonens $TruthA $TruthAB)) (empty))) | |
| ; guard to only allow inference for certain link types | |
| (= (SyllogisticRuleGuard Inheritance) True) | |
| (= (SyllogisticRuleGuard Implication) True) | |
| ; Deduction rule, see https://github.com/opencog/pln/blob/master/opencog/pln/rules/term/deduction.scm | |
| (= (|- (($LinkType $A $B) $T1) | |
| (($LinkType $B $C) $T2)) | |
| (If (SyllogisticRuleGuard $LinkType) | |
| (($LinkType $A $C) | |
| (Truth_Deduction (STV $A) | |
| (STV $B) | |
| (STV $C) $T1 $T2)) (empty))) | |
| ; Induction rule, see https://github.com/opencog/pln/blob/master/opencog/pln/rules/wip/induction.scm | |
| (= (|- (($LinkType $C $A) $T1) | |
| (($LinkType $C $B) $T2)) | |
| (If (SyllogisticRuleGuard $LinkType) | |
| (($LinkType $A $B) (Truth_Induction (STV $A) | |
| (STV $B) | |
| (STV $C) $T1 $T2)) (empty))) | |
| ; Abduction rule, see https://github.com/opencog/pln/blob/master/opencog/pln/rules/wip/abduction.scm | |
| (= (|- (($LinkType $A $C) $T1) | |
| (($LinkType $B $C) $T2)) | |
| (If (SyllogisticRuleGuard $LinkType) | |
| (($LinkType $A $B) (Truth_Abduction (STV $A) | |
| (STV $B) | |
| (STV $C) $T1 $T2)) (empty))) | |
| ;Usage of inheritance for predicates | |
| ;unary arg | |
| (= (|- ((Evaluation (Predicate $x) | |
| (List (Concept $C))) $T1) | |
| ((Inheritance (Concept $S) (Concept $C)) $T2)) | |
| ((Evaluation (Predicate $x) | |
| (List (Concept $S))) (Truth_ModusPonens $T1 $T2))) | |
| ;binary arg1 | |
| (= (|- ((Evaluation (Predicate $x) | |
| (List (Concept $C1) (Concept $C2))) $T1) | |
| ((Inheritance (Concept $S) (Concept $C1)) $T2)) | |
| ((Evaluation (Predicate $x) | |
| (List (Concept $S) (Concept $C2))) (Truth_ModusPonens $T1 $T2))) | |
| ;binary arg2 | |
| (= (|- ((Evaluation (Predicate $x) | |
| (List (Concept $C1) (Concept $C2))) $T1) | |
| ((Inheritance (Concept $S) (Concept $C2)) $T2)) | |
| ((Evaluation (Predicate $x) | |
| (List (Concept $C1) (Concept $S))) (Truth_ModusPonens $T1 $T2))) | |
| ; negation introduction, takes only one premise (is unary) | |
| (= (|- ($x $t)) | |
| (If (not (== $x (Not $_))) ;don't derive if it is already a NotLink | |
| ((Not $x) (Truth_negation $t)) (empty))) | |
| ; not elimination rule, see https://github.com/opencog/pln/blob/master/opencog/pln/rules/wip/not-elimination.scm#L1-L8 | |
| (= (|- ((Not $x) $t)) | |
| ($x (Truth_negation $t))) | |
| ; Inheritance Inversion Rule, see https://github.com/opencog/pln/blob/master/opencog/pln/rules/wip/inversion.scm | |
| (= (|- ((Inheritance $A $B) $Truth)) | |
| ((Inheritance $B $A) (Truth_inversion (STV $B) $Truth))) | |
| ; Implication Inversion Rule (same) | |
| (= (|- ((Implication $A $B) $Truth)) | |
| ((Implication $B $A) (Truth_inversion (STV $B) $Truth))) | |
| ; Equivalence to Implication Rule, see https://github.com/opencog/pln/blob/master/opencog/pln/rules/wip/equivalence-to-implication.scm | |
| (= (|- ((Equivalence $A $B) $Truth)) | |
| ((Implication $A $B) (Truth_equivalenceToImplication (STV $A) | |
| (STV $B) $Truth))) | |
| (= (|- ((Equivalence $A $B) $Truth)) | |
| ((Implication $B $A) (Truth_equivalenceToImplication (STV $A) | |
| (STV $B) $Truth))) | |
| ; Implication Implicant Conjunction Rule, see https://github.com/opencog/pln/blob/75815f9f21ad899f44eccba1921fa253a7c6216f/opencog/pln/rules/wip/implication-implicant-conjunction.scm | |
| (= (|- ((Implication $A $C) $tvAC) | |
| ((Implication $B $C) $tvBC)) | |
| (If (not (== $A $B)) ; GuardCondition: A is not identical to B | |
| ((Implication (And $A $B) $C) | |
| (Truth_ImplicationImplicantConjunction (STV $A) | |
| (STV $B) | |
| (STV $C) $tvAC $tvBC)) (empty))) | |
| ; Implication Implicant Disjunction Rule, see https://github.com/opencog/pln/blob/master/opencog/pln/rules/wip/implication-implicant-disjunction.scm | |
| (= (|- ((Implication $A $C) $tvAC) | |
| ((Implication $B $C) $tvBC)) | |
| (If (not (== $A $B)) ; GuardCondition: A is not identical to B | |
| ((Implication (Or $A $B) $C) | |
| (Truth_ImplicationImplicantDisjunction (STV $A) | |
| (STV $B) | |
| (STV $C) $tvAC $tvBC)) (empty))) | |
| ; Inheritance To Member Rule, see https://github.com/opencog/pln/blob/master/opencog/pln/rules/wip/inheritance-to-member.scm | |
| (= (|- ((Inheritance $B $C) $Truth)) | |
| ((Member $B $C) (Truth_inheritanceToMember $Truth))) | |
| ; transitive similarity Rule, see https://github.com/opencog/pln/blob/master/opencog/pln/rules/wip/transitive-similarity.scm | |
| (= (|- ((Similarity $A $B) $T1) | |
| ((Similarity $B $C) $T2)) | |
| ((Similarity $A $C) (Truth_transitiveSimilarity (STV $A) | |
| (STV $B) | |
| (STV $C) $T1 $T2))) | |
| ; Evaluation Implication Rule, see https://github.com/opencog/pln/blob/master/opencog/pln/rules/wip/evaluation-implication.scm | |
| (= (|- ((Evaluation $A $B) $TruthAB) | |
| ((Implication $A $C) $TruthAC)) | |
| ((Evaluation $C $B) (Truth_evaluationImplication (STV $A) | |
| (STV $B) | |
| (STV $C) $TruthAB $TruthAC))) | |
| ; extensional - Member deduction rule, see https://github.com/opencog/pln/blob/master/opencog/pln/rules/extensional/member-deduction.scm | |
| ; we are using the truth of deduction here | |
| (= (|- ((Member $A $B) $T1) | |
| ((Inheritance $B $C) $T2)) | |
| ((Member $A $C) (Truth_Deduction (STV $A) | |
| (STV $B) | |
| (STV $C) $T1 $T2))) | |
| ;Whether evidence was just counted once | |
| (= (StampDisjoint $Ev1 $Ev2) | |
| (== () (collapse (let* (($x (superpose $Ev1)) | |
| ($y (superpose $Ev2))) | |
| (case (== $x $y) ((True True))))))) | |
| ;; Exhaustive-until-depth deriver | |
| (= (Derive $beliefs $depth $maxdepth) | |
| (If (> $depth $maxdepth) | |
| $beliefs | |
| (let $derivations | |
| (collapse (superpose ((let* (((Sentence $x $Ev1) (superpose $beliefs)) | |
| ((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 (TupleConcat $beliefs $derivations) (+ $depth 1) $maxdepth)))) | |
| ;(= (Derive $beliefs $depth $maxdepth) | |
| ; (If (> $depth $maxdepth) | |
| ; $beliefs | |
| ; (let $derivations | |
| ; (collapse (let* (((Sentence $x $Ev1) (superpose $beliefs)) | |
| ; ((Sentence $y $Ev2) (superpose $beliefs)) | |
| ; ($stamp (TupleConcat $Ev1 $Ev2))) | |
| ; (If (StampDisjoint $Ev1 $Ev2) | |
| ; (case (|- $x $y) ((($T $TV) (Sentence ($T $TV) $stamp))))))) | |
| ; (Derive (TupleConcat $beliefs $derivations) (+ $depth 1) $maxdepth)))) | |
| ;retrieve the best candidate | |
| (= (BestCandidate $evaluateCandidateFunction $bestCandidate $tuple) | |
| (If (== $tuple ()) | |
| $bestCandidate | |
| (let* (($head (car-atom $tuple)) | |
| ($tail (cdr-atom $tuple))) | |
| (If (> ($evaluateCandidateFunction $head) | |
| ($evaluateCandidateFunction $bestCandidate)) | |
| (BestCandidate $evaluateCandidateFunction $head $tail) | |
| (BestCandidate $evaluateCandidateFunction $bestCandidate $tail))))) | |
| ;candidate evaluation based on confidence | |
| (= (ConfidenceRank ((stv $f $c) $Ev)) $c) | |
| (= (ConfidenceRank ()) 0) | |
| ;pose a question of a certain term to the system on some knowledge base | |
| (= (Question $kb $term $steps) | |
| (BestCandidate ConfidenceRank () (collapse (let $x (Derive $kb 1 $steps) | |
| (case (superpose $x) | |
| (((Sentence ($T $TV) $Ev) (case (== $T $term) | |
| ((True ($TV $Ev))))))))))) | |
| (= (STV (Concept Sam)) | |
| (stv 0.2 0.9)) | |
| (= (STV (Concept Pingu)) | |
| (stv 0.2 0.9)) | |
| (= (STV (Concept Penguin)) | |
| (stv 0.2 0.9)) | |
| (= (STV (Concept Raven)) | |
| (stv 0.2 0.9)) | |
| (= (STV (Concept Bird)) | |
| (stv 0.2 0.9)) | |
| (= (kb) | |
| ( | |
| (Sentence ((Inheritance (Concept Sam) | |
| (Concept Raven)) | |
| (stv 0.99 0.9)) (1)) | |
| (Sentence ((Inheritance (Concept Pingu) | |
| (Concept Penguin)) | |
| (stv 0.99 0.9)) (2)) | |
| (Sentence ((Evaluation (Predicate flies) | |
| (List (Concept Penguin))) | |
| (stv 0.01 0.9)) (3)) | |
| (Sentence ((Inheritance (Concept Raven) | |
| (Concept Bird)) | |
| (stv 0.99 0.9)) (4)) | |
| (Sentence ((Inheritance (Concept Penguin) | |
| (Concept Bird)) | |
| (stv 0.99 0.9)) (5)) | |
| (Sentence ((Evaluation (Predicate flies) | |
| (List (Concept Bird))) | |
| (stv 0.99 0.9)) (6)) | |
| )) | |
| ;FlyingRaven: | |
| !(Question (kb) | |
| (Evaluation (Predicate flies) | |
| (List (Concept Pingu))) | |
| 2) | |
| !(Question (kb) | |
| (Evaluation (Predicate flies) | |
| (List (Concept Sam))) | |
| 2) | |
| ;Smokes: | |
| ;Implication (1) | |
| (= (|- ((Evaluation (Predicate friend) | |
| (List $1 $2)) $T1) | |
| ((Evaluation (Predicate smokes) | |
| (List $1)) $T2)) | |
| ((Evaluation (Predicate smokes) | |
| (List $2)) | |
| (Truth_ModusPonens (Truth_ModusPonens $T1 $T2) | |
| (stv 0.4 0.9)))) | |
| ;Implication (2) | |
| (= (|- ((Evaluation (Predicate smokes) | |
| (List $1)) $T1)) | |
| ((Evaluation (Predicate cancerous) | |
| (List $1)) | |
| (Truth_ModusPonens $T1 (stv 0.6 0.9)))) | |
| !(Question ( | |
| (Sentence ((Evaluation (Predicate friend) | |
| (List (Concept Anna) | |
| (Concept Bob))) | |
| (stv 1.0 0.9)) (3)) | |
| (Sentence ((Evaluation (Predicate friend) | |
| (List (Concept Anna) | |
| (Concept Edward))) | |
| (stv 1.0 0.9)) (4)) | |
| (Sentence ((Evaluation (Predicate friend) | |
| (List (Concept Anna) | |
| (Concept Frank))) | |
| (stv 1.0 0.9)) (5)) | |
| (Sentence ((Evaluation (Predicate friend) | |
| (List (Concept Edward) | |
| (Concept Frank))) | |
| (stv 1.0 0.9)) (6)) | |
| (Sentence ((Evaluation (Predicate friend) | |
| (List (Concept Gary) | |
| (Concept Helen))) | |
| (stv 1.0 0.9)) (7)) | |
| (Sentence ((Evaluation (Predicate friend) | |
| (List (Concept Gary) | |
| (Concept Frank))) | |
| (stv 0.0 0.9)) (8)) | |
| (Sentence ((Evaluation (Predicate smokes) | |
| (List (Concept Anna))) | |
| (stv 1.0 0.9)) (9)) | |
| (Sentence ((Evaluation (Predicate smokes) | |
| (List (Concept Edward))) | |
| (stv 1.0 0.9)) (10)) | |
| ) | |
| (Evaluation (Predicate cancerous) | |
| (List (Concept Edward))) | |
| 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment