SI-6582 Use Tseitin's algorithm for CNF conversion in pattern matching analysis.

This chops #2724 into smaller commits.

I made Lit into a value class and encapsulated a bit more.
Please double check my refactorings were correctness-preserving.

review by @gbasler