File tree 3 files changed +36
-14
lines changed
3 files changed +36
-14
lines changed Original file line number Diff line number Diff line change 1
1
import { Belief } from "../belief/index.js"
2
2
import { isNothing , nothing , type Nothing } from "../cell/index.js"
3
- import { merge , moreInformative , type MergeConflict } from "../merge/index.js"
3
+ import { implies , merge , type MergeConflict } from "../merge/index.js"
4
4
import type { Reasons } from "../reason/index.js"
5
5
import { setIsSubsetOf } from "../utils/set/index.js"
6
6
import { BeliefSystem } from "./BeliefSystem.js"
@@ -75,9 +75,7 @@ function assimilateOne<A, B>(
75
75
// - A belief has less reasons is stronger.
76
76
77
77
function stronger < A , B > ( x : Belief < A > , y : Belief < B > ) : boolean {
78
- return (
79
- moreInformative ( x . value , y . value ) && setIsSubsetOf ( x . reasons , y . reasons )
80
- )
78
+ return implies ( x . value , y . value ) && setIsSubsetOf ( x . reasons , y . reasons )
81
79
}
82
80
83
81
function strongestConsequence < A > (
Original file line number Diff line number Diff line change 1
- import { merge , moreInformative , type MergeConflict } from "../merge/index.js"
1
+ import { implies , merge , type MergeConflict } from "../merge/index.js"
2
2
import { setIsSubsetOf , setUnion } from "../utils/set/index.js"
3
3
import { Belief } from "./Belief.js"
4
4
@@ -13,8 +13,8 @@ export function beliefMerge<A, B>(
13
13
// 写的不是那么对称了。
14
14
15
15
if ( mergedValue === content . value ) {
16
- // 正向和反向的 moreInformative 代表等价。
17
- if ( moreInformative ( increment . value , mergedValue ) ) {
16
+ // 正向和反向的 implies 代表等价。
17
+ if ( implies ( increment . value , mergedValue ) ) {
18
18
// 倾向于 content,除非 increment 真的有更多信息。
19
19
// 更小的 reason 集合,代表拥有更多的信息(更精确的依赖关系)。
20
20
if ( setIsSubsetOf ( content . reasons , increment . reasons ) ) {
Original file line number Diff line number Diff line change @@ -54,13 +54,37 @@ export const merge = defineGeneric({
54
54
} ,
55
55
} )
56
56
57
- // 第二个参数对于 merge 来说是多余的。
58
- // 这个实现就是用 lattice 的 meet (merge)
59
- // 来实现 ordered set 中的序关系(小于等于关系)。
60
- // 也就是说,信息越多就越具体,
61
- // 在 lattice 的中位置就更低,
62
- // 所以 merge 是 meet。
63
- export function moreInformative < A , B > ( x : A , y : B ) : boolean {
57
+ // merge 的效果是让 partial information 变得 more informative。
58
+ //
59
+ // - merge 是 lattice 的 meet。
60
+ // - implies 是 ordered set 中的 "less or equal to"。
61
+ // 虽然 "more informative" 一词中有一个 "more",
62
+ // 但是其实就序集而言它是更小。
63
+ //
64
+ // 注意术语所在的领域:
65
+ //
66
+ // - merge 是就 partial information 而言的术语。
67
+ // - implies 是就命题之间的蕴含而言的术语。
68
+ //
69
+ // 最好用例子来理解 "more informative":
70
+ //
71
+ // - 对集合来说,越小的集合越具体,包含的信息更多。
72
+ // 比如考虑 CLP(FD) -- Constraint Logic Programming over Finite Domains,
73
+ // 在求解 constraint 问题的过程中,domain 作为一个集合会变小。
74
+ //
75
+ // - 对于命题来说,蕴含式前项的命题比后项的命题包含更多信息。
76
+ // 因此 more informative 就是 implies。
77
+ // 集合之间的「包含于」关系,就对应于命题之间「蕴含关系」。
78
+ //
79
+ // - 对区间来说,越小的区间就更精确,就包含更多信息。
80
+ // 毕竟,区间是特殊的集合。
81
+ //
82
+ // - 对于 Belief 来说,「包含更多信息」可以被理解为
83
+ // (某个 cell 拥有)更强的信念。
84
+ // 更强的信念,代表在更少的条件下相信更多的信息,
85
+ /// 「更少的条件下」被实现为更小的 reasons 集合。
86
+
87
+ export function implies < A , B > ( x : A , y : B ) : boolean {
64
88
return merge ( x , y ) === x
65
89
}
66
90
You can’t perform that action at this time.
0 commit comments