Algorithm for removing redundant generic constraints?

when lib/SymbolGraphGen emits constraints for protocol conformances, it also generates all the implied conformances to protocols inherited by the original protocol.

for example, for Dictionary, we get

Dictionary<Key, Value>:Equatable where Value:Equatable
Dictionary<Key, Value>:Equatable where Value:Hashable

with the latter originating from Dictionary’s Hashable conformance.

what is the easiest way to remove these redundant constraints in the general case?