#Also, any set is a subset of itself >>> e=FiniteSet() >>> e.is_subset(t) True >>> e.is_subset(s) True >>> s.is_subset(s) True >>> t.is_subset(t) True #A set t is a superset of another set s, if t contains all of the members contained in s. >>> s.is_superset(t) False >>> t.is_superset(s) True #The power set of a set,s, is the set of all possible subsets of s. Any set has exactly #2^(cardinality) subsets. i.e. The set {1,2,3} has excatcly 8 since 2^3=8 >>> s=FiniteSet(1,2,3) >>> ps=s.powerset() >>> ps {EmptySet(), {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}} >>> len(ps) 8
from sympy import FiniteSet s = FiniteSet(1,2,3) for member in s: print(member) from sympy import FiniteSet s = FiniteSet(3,4,5) t = FiniteSet(5,4,3) s == t s = FiniteSet(1) t = FiniteSet(1,2) s.is_subset(t) t.is_subset(s) t.is_superset(s) s = FiniteSet(1,2,3) ps = s.powerset() ps len(ps) #is 53 prime? for i in range(1,54): if i == 1: print('i = 1') elif i == 53: print('i = 53') elif int(i) != 1 or int(i) != 53: if 53%i == 0:
s = FiniteSet() # EmptySet() # Set Repetition and Order members = [1, 2, 3, 2] FiniteSet(*members) # {1, 2, 3} for member in s: print(member) # 1, 2, 3 # Subsets -> if all the members of s are also a member of t s = FiniteSet(1) t = FiniteSet(1,2) s.is_subset(t) # True t.is_subset(s) # False # Supersets -> if t contains all of the members contained in s s.is_superset(t) # True t.is_superset(s) # True # Powerset -> is the set of all possible subsets of s s = FiniteSet(1, 2, 3) ps = s.powerset() ps # {{1}, {1, 2}, {1, 3}, {1, 2, 3}, {2}, {2, 3}, {3}, EmptySet()} len(ps) # 8 # Proper subset -> if all the members of s are also in t and t has at least one member that is not in s s = FiniteSet(1, 2, 3) t = FiniteSet(1, 2, 3) s.is_proper_subset(t) # False t.is_proper_subset(s) # False