Imported the union and intersection implementations from the code in the F# distribution, and adapted it to our implementation.