#Please do not post homework #Ravali Bommanaboina, 9/20/2020, Assignment 4 #Question 1--------------------------------------------------------------------- #CP({a,b,c},{b,c,d}); -> {[a, b], [a, c], [a, d], [b, b], [b, c], [b, d], [c, b], [c, c], [c, d]} #CheckMult({1,2},{3,4}); -> true #CheckAdd({1,2,3},{3,4,5}) -> {1, 2, 3}, {3, 4, 5}, have the following common elements , {3} FAIL #member([d,o,r,o,n],Words({d,o,n,r},5)); -> true #Question 2--------------------------------------------------------------------- #seq(i,i=1..106); #this sequence produces only one search result #Question 3--------------------------------------------------------------------- #U={1,...,15} A1={3,6,9,12,15} A2={5,10,15} #|Comp(U,A1) intersect Comp(U,A2)| = {1,2,4,7,8,11,13,14} #|Comp(U,A1) intersect Comp(U,A2)| = |U| - |A1| - |A2| + |A1 intersect A2| # = 15 - 5 - 3 + 1 = 8 #Question 4--------------------------------------------------------------------- Comp:=proc(U,A1): if not type(U,set) then print(U, `is not a set `): RETURN(FAIL): fi: if not type(A1,set) then print(A1, `is not a set `): RETURN(FAIL): fi: if U intersect A1<>A1 then print(A1, `is not a subset of`,U): RETURN(FAIL): fi: RETURN(U minus A1); end: PIE2:=proc(U,A1,A2) local num1,num2: if not type(U,set) then print(U, `is not a set `): RETURN(FAIL): fi: if not type(A1,set) then print(A1, `is not a set `): RETURN(FAIL): fi: if not type(A2,set) then print(A2, `is not a set `): RETURN(FAIL): fi: if U intersect A1<>A1 then print(A1, `is not a subset of`,U): RETURN(FAIL): fi: if U intersect A2<>A2 then print(A2, `is not a subset of`,U): RETURN(FAIL): fi: num1:=Mynops(Comp(U,A1) intersect Comp(U,A2)): num2:=Mynops(U)-Mynops(A1)-Mynops(A2)+Mynops(A1 intersect A2): RETURN([num1,num2]); end: