What is set theory, and how does it provide a foundation for understanding mathematical structures? Discuss the basic concepts of sets, subsets, unions, intersections, and complements, and explain how set theory is used in logic and computer science.