horse/prob: first pass on P(A xor B)
This commit is contained in:
@@ -101,8 +101,8 @@ pub fun (+)(a: kfl, b: kfl): e kfl
|
|||||||
// Cases with _ on the left simplify later cases that all absorb to the right.
|
// Cases with _ on the left simplify later cases that all absorb to the right.
|
||||||
(Guaranteed, _) -> Guaranteed
|
(Guaranteed, _) -> Guaranteed
|
||||||
(_, Guaranteed) -> Guaranteed
|
(_, Guaranteed) -> Guaranteed
|
||||||
(Cry-If-Not, _) -> Cry-If-Not
|
(Cry-If-Not, _) -> Guaranteed
|
||||||
(Most-Likely, Cry-If-Not) -> Guaranteed
|
(Most-Likely, Cry-If-Not) -> Cry-If-Not
|
||||||
(Most-Likely, _) -> Cry-If-Not
|
(Most-Likely, _) -> Cry-If-Not
|
||||||
(_, Cry-If-Not) -> Cry-If-Not
|
(_, Cry-If-Not) -> Cry-If-Not
|
||||||
(Probably, Most-Likely) -> Cry-If-Not
|
(Probably, Most-Likely) -> Cry-If-Not
|
||||||
@@ -124,3 +124,35 @@ pub fun (+)(a: kfl, b: kfl): e kfl
|
|||||||
(_, Doubtful) -> Doubtful
|
(_, Doubtful) -> Doubtful
|
||||||
(_, Probably-Not) -> Probably-Not
|
(_, Probably-Not) -> Probably-Not
|
||||||
(_, Impossible) -> Impossible
|
(_, Impossible) -> Impossible
|
||||||
|
|
||||||
|
// KFL union, or the probability of occurrence of exactly one of two independent events.
|
||||||
|
pub fun either(a: kfl, b: kfl): e kfl
|
||||||
|
val (l, h) = match a.cmp(b) // this operation is commutative
|
||||||
|
Gt -> (b, a)
|
||||||
|
_ -> (a, b)
|
||||||
|
match (l, h)
|
||||||
|
(Impossible, r) -> r
|
||||||
|
(Probably-Not, Guaranteed) -> Cry-If-Not
|
||||||
|
(Probably-Not, r) -> r
|
||||||
|
(Doubtful, Guaranteed) -> Most-Likely
|
||||||
|
(Doubtful, Cry-If-Not) -> Most-Likely
|
||||||
|
(Doubtful, Most-Likely) -> Probably
|
||||||
|
(Doubtful, Probably) -> Mayhapsibly
|
||||||
|
(Doubtful, Mayhapsibly) -> Mayhapsibly
|
||||||
|
(Doubtful, Unlikely) -> Mayhapsibly
|
||||||
|
(Doubtful, _) -> Unlikely
|
||||||
|
(Unlikely, Guaranteed) -> Probably
|
||||||
|
(Unlikely, Cry-If-Not) -> Mayhapsibly
|
||||||
|
(Unlikely, Most-Likely) -> Mayhapsibly
|
||||||
|
(Unlikely, _) -> Probably
|
||||||
|
(Mayhapsibly, Guaranteed) -> Mayhapsibly
|
||||||
|
(Mayhapsibly, Cry-If-Not) -> Mayhapsibly
|
||||||
|
(Mayhapsibly, Most-Likely) -> Mayhapsibly
|
||||||
|
(Mayhapsibly, _) -> Probably
|
||||||
|
(Probably, Guaranteed) -> Unlikely
|
||||||
|
(Probably, Cry-If-Not) -> Unlikely
|
||||||
|
(Probably, Most-Likely) -> Unlikely
|
||||||
|
(Probably, _) -> Mayhapsibly
|
||||||
|
(Most-Likely, _) -> Doubtful
|
||||||
|
(Cry-If-Not, _) -> Probably-Not
|
||||||
|
(Guaranteed, _) -> Impossible
|
||||||
|
|||||||
Reference in New Issue
Block a user