diff --git a/prototype/Doubt/Interpreter.swift b/prototype/Doubt/Interpreter.swift index c60cc8b53..128d9c373 100644 --- a/prototype/Doubt/Interpreter.swift +++ b/prototype/Doubt/Interpreter.swift @@ -16,6 +16,14 @@ public struct Interpreter { self.cost = cost } + + /// Computes a term comparable function from a categorizing function. + public static func comparable(categorize: Term -> Set)(_ a: Term, _ b: Term) -> Bool { + let c0 = categorize(a) + let c1 = categorize(b) + return c0 == c1 || !categorize(a).intersect(categorize(b)).isEmpty + } + /// Computes a diff cost function from a patch cost function. public static func cost(cost: Patch -> Int)(_ diff: Diff) -> Int { return diff.map(cost).reduce(0, combine: +)