@@ -5,11 +5,11 @@ import type { Reasons } from "../reason/index.js"
5
5
import { setIsSubsetOf } from "../utils/set/index.js"
6
6
import { BeliefSystem } from "./BeliefSystem.js"
7
7
8
- // Asking the TMS to deduce all the consequences of all its facts all
9
- // the time is perhaps a bad idea, so when we merge TMSes we
10
- // assimilate the facts from the incoming one into the current one,
11
- // and then deduce only those consequences that are relevant to the
12
- // current worldview.
8
+ // Asking the belief system to deduce all the consequences of all its
9
+ // facts all the time is perhaps a bad idea, so when we merge belief
10
+ // systems we assimilate the facts from the incoming one into the
11
+ // current one, and then deduce only those consequences that are
12
+ // relevant to the current worldview.
13
13
14
14
export function beliefSystemMerge < A , B > (
15
15
content : BeliefSystem < A > ,
@@ -21,7 +21,8 @@ export function beliefSystemMerge<A, B>(
21
21
}
22
22
23
23
// The procedure `assimilate` incorporates all the given items, one by
24
- // one, into the given TMS with no deduction of consequences.
24
+ // one, into the given belief system with no deduction of
25
+ // consequences.
25
26
26
27
function assimilate < A , B > (
27
28
base : BeliefSystem < A > ,
@@ -37,10 +38,6 @@ function assimilate<A, B>(
37
38
)
38
39
}
39
40
40
- function subsumes < A , B > ( x : Belief < A > , y : Belief < B > ) : boolean {
41
- return implies ( x . value , y . value ) && setIsSubsetOf ( x . reasons , y . reasons )
42
- }
43
-
44
41
function assimilateOne < A , B > (
45
42
base : BeliefSystem < A > ,
46
43
belief : Belief < B > | Nothing ,
@@ -49,15 +46,36 @@ function assimilateOne<A, B>(
49
46
return base
50
47
}
51
48
52
- if ( base . beliefs . some ( ( oldBelief ) => subsumes ( oldBelief , belief ) ) ) {
49
+ // When we add a new belief to an existing belief system we check
50
+ // whether the information contained in the new belief is deducible
51
+ // from that in some belief already in the TMS. If so, we can just
52
+ // throw the new one away.
53
+
54
+ if ( base . beliefs . some ( ( oldBelief ) => stronger ( oldBelief , belief ) ) ) {
53
55
return base
54
56
}
55
57
56
- const notSubsumed = base . beliefs . filter (
57
- ( oldBelief ) => ! subsumes ( belief , oldBelief ) ,
58
+ // Conversely, if the information in any existing belief is
59
+ // deducible from the information in the new one, we can throw those
60
+ // existing ones away.
61
+
62
+ const strongerOldBeliefs = base . beliefs . filter (
63
+ ( oldBelief ) => ! stronger ( belief , oldBelief ) ,
58
64
)
59
65
60
- return BeliefSystem < A | B > ( [ ...notSubsumed , belief ] )
66
+ return BeliefSystem < A | B > ( [ ...strongerOldBeliefs , belief ] )
67
+ }
68
+
69
+ // The predicate `stronger` returns true only if the information
70
+ // contained in the second argument is deducible from that contained
71
+ // in the first.
72
+
73
+ // About the ordered set of beliefs:
74
+ // - A belief has stronger value is stronger.
75
+ // - A belief has less reasons is stronger.
76
+
77
+ function stronger < A , B > ( x : Belief < A > , y : Belief < B > ) : boolean {
78
+ return implies ( x . value , y . value ) && setIsSubsetOf ( x . reasons , y . reasons )
61
79
}
62
80
63
81
function strongestConsequence < A > (
0 commit comments