Skip to content

Commit 172a8b8

Browse files
committed
ambr subsumes stronger
1 parent 24af62f commit 172a8b8

File tree

1 file changed

+32
-14
lines changed

1 file changed

+32
-14
lines changed

src/belief-system/beliefSystemMerge.ts

+32-14
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import type { Reasons } from "../reason/index.js"
55
import { setIsSubsetOf } from "../utils/set/index.js"
66
import { BeliefSystem } from "./BeliefSystem.js"
77

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.
1313

1414
export function beliefSystemMerge<A, B>(
1515
content: BeliefSystem<A>,
@@ -21,7 +21,8 @@ export function beliefSystemMerge<A, B>(
2121
}
2222

2323
// 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.
2526

2627
function assimilate<A, B>(
2728
base: BeliefSystem<A>,
@@ -37,10 +38,6 @@ function assimilate<A, B>(
3738
)
3839
}
3940

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-
4441
function assimilateOne<A, B>(
4542
base: BeliefSystem<A>,
4643
belief: Belief<B> | Nothing,
@@ -49,15 +46,36 @@ function assimilateOne<A, B>(
4946
return base
5047
}
5148

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))) {
5355
return base
5456
}
5557

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),
5864
)
5965

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)
6179
}
6280

6381
function strongestConsequence<A>(

0 commit comments

Comments
 (0)