There are a lot of LINQ-based implementations of the Composite Specification Pattern. I have not seen one that used Subsumption.
Are there any such examples that have been documented (blogs, etc.) or published as open source? I have an idea and proof of concept for how this could work by having an ExpressionVisitor translate every specification into a canonical logical form (CNF/DNF), but I am concerned that this is overly complicated. Is there a better way?
The short answer is “No, there isn’t” 1
The long answer: The “overly complicated” captures the essence of the problem: it is NP-hard. Here is a short informal proof relying upon the fact that the satisfiability problem is NP-complete:
AandBAimpliesB, or equivalently¬A | Bfor all assignments of variables upon whichAandBdepend. In other words, you need a proof thatF = ¬A | Bis a tautology.¬F, the inverse ofF.Fis satisfiable if and only if¬Fis not a tautology¬Ffor being a tautologyFsatisfiable” is the inverse of the answer to “is¬Fa tautology”P, and thatP=NP.Of course the fact that the problem is NP-hard does not mean that there would be no solutions for practical cases: in fact, your approach with the conversion to a canonical form may produce OK results in many real-world situations. However, an absence of a known “good” algorithm often discourages active development of practical solutions2.
1 With the obligatory “unless
P=NP” disclaimer.2 Unless a “reasonably good” solution would do, which may very well be the case for your problem, if you allow for “false negatives”.