makeCart2D[a_,b_,name_]:=Module[{A,B,g,max},

A=Table[{a[[i]]},{i,1,Length@a}];
B=Table[{b[[i]]},{i,1,Length@b}];
max=Max@(Abs/@{Max[a],Max[b]})+3;

g=RegionPlot[RegionProduct[Point[A],Point[B]],BoundaryStyle->Directive[PointSize[Large],Red],AspectRatio->Automatic,Frame->False,Axes->True,PlotRange->{{-(max+1),max+1},{-(max+1),max+1}}];

Show[g, Graphics[{Red,Table[Tooltip[Point@{A[[i]][[1]],B[[j]][[1]]},"("<>ToString[A[[i]][[1]]]<>", "<>ToString[B[[j]][[1]]]<>")"],{i,1,Length@A},{j,1,Length@B}]}],PlotLabel->Style[name[[1]]<>"×"<>name[[2]],FontSize->30]]


]

makeCart3D[a_,b_,c_,name_]:=Module[{A,B,C, g,max},

A=Table[{a[[i]]},{i,1,Length@a}];
B=Table[{b[[i]]},{i,1,Length@b}];
C=Table[{c[[i]]},{i,1,Length@c}];
max=Max@{Max[Abs/@a],Max[Abs/@b],Max[Abs/@c]}+3;

g=RegionPlot3D[DiscretizeRegion@RegionProduct[Point[A],Point[B],Point[C]],BoundaryStyle->Directive[PointSize[Large],Red],AspectRatio->Automatic,Axes->True,PlotRange->{{-(max+1),max+1},{-(max+1),max+1},{-(max+1),max+1}}];

Show[g, Graphics3D[{Red,Table[Tooltip[Point@{A[[i]][[1]],B[[j]][[1]],C[[k]][[1]]},"("<>ToString[A[[i]][[1]]]<>", "<>ToString[B[[j]][[1]]]<>", "<>ToString[C[[k]][[1]]]<>")"],{i,1,Length@A},{j,1,Length@B},{k,1,Length@C}]}],PlotLabel->Style[name[[1]]<>"×"<>name[[2]]<>"×"<>name[[3]],FontSize->30],ImageSize->400]


]

makeCart[a_,b_]:=Module[{data},

data=Table[{b[[j]]}~Join~Table["("<>ToString[a[[i]]]<>", "<>ToString[b[[j]]]<>")",{i,1,Length@a}],{j,1,Length@b}];

Text@Grid[Transpose@Prepend[data,{"×"}~Join~a],Background->{None,{Lighter[Yellow,.9],{White,Lighter[Blend[{Blue,Green}],.8]}}},Dividers->{{Darker[Gray,.6],{Lighter[Gray,.5]},Darker[Gray,.6]},{Darker[Gray,.6],Darker[Gray,.6],{False},Darker[Gray,.6]}},ItemSize->Automatic]
]


makeCart2[a_,b_]:=Module[{data},

data=Table[{b[[j]]}~Join~Table[Row[{"(",a[[i]]," , ",b[[j]],")"}],{i,1,Length@a}],{j,1,Length@b}];

Text@Grid[Transpose@Prepend[data,{"×"}~Join~a],Background->{None,{Lighter[Yellow,.9],{White,Lighter[Blend[{Blue,Green}],.8]}}},Dividers->{{Darker[Gray,.6],{Lighter[Gray,.5]},Darker[Gray,.6]},{Darker[Gray,.6],Darker[Gray,.6],{False},Darker[Gray,.6]}},ItemSize->Automatic]
]

m1[]:=Module[{y3},
Manipulate[

y3=DiscretizeRegion[ImplicitRegion[x^2+y^2==1&&x<t,{x,y}],{{0,2},{0,1}},MaxCellMeasure->0.0001];
Column[{
RegionPlot[y3,PlotLabel->Style["A="<>ToString["{(x,y)|"<>ToString["x"^2,TraditionalForm]<>"+"<>ToString["y"^2,TraditionalForm]<>"=1 ∧ x<"<>ToString[t]<>"}",TraditionalForm],Red],AxesOrigin->{"x","y"}],
RegionPlot3D[RegionProduct[y3,BoundaryMeshRegion[{{0},{1}},Point[{1,2}]]],Axes->True,AxesLabel->{"X","Y","Z"},PlotLabel->"A×[0,1]"]

}],

{{t,1},0.1, 1}

]
]


m2[]:=DynamicModule[{x,y=0},

(*Dynamic@*)Column[{
y=0;
x=RectangleHoleMesh[{20,10}];
RegionPlot[RectangleHoleMesh[{20,10}],PlotStyle->Directive[Yellow,Opacity[0.5]],Mesh->None,ImageSize->500,Frame->False],

RegionPlot3D[RegionProduct[x,BoundaryMeshRegion[{{0},{1}},Point[{1,2}]]],PlotStyle->Directive[Yellow,Opacity[0.5]],Mesh->None,ImageSize->500,Boxed->False]}
],

Initialization:>((*rectangleCoords[{i_,j_}]:=rectangleCoords[{i,j},{0.5,0.5}];
rectangleCoords[{i_,j_},{α_,β_}]:={{i-α/2,j-β/2},{i+α/2,j-β/2},{i+α/2,j+β/2},{i-α/2,j+β/2}};

rectangleIndexes[i_]:=Line[i-1+{1,2,3,4,1}];

RectangleHoleMesh[{m_,n_}]:=Module[{oc,hc},
hc=Flatten[Table[rectangleCoords[{i,j}],{j,n},{i,m}],2];
oc={{0,0},{m+1,0},{m+1,n+1},{0,n+1}};
BoundaryMeshRegion[Join[hc,oc],
rectangleIndexes[4 m n+1],
Sequence@@Table[rectangleIndexes[i],{i,1,4 m n,4}]
]
];*)

y=1;)
]

m3[]:=DynamicModule[{A,B},


Panel@Dynamic@Column[{
Button["Again",

A=Range[1,RandomInteger[{2,5}]]+RandomInteger[{-3,3}];
B={RandomInteger[{-3,3}]}],


"A="<>(ToString@A),
"B="<>(ToString@B),
makeCart2D[A,B,{"A","B"}]
}
]

,
Initialization:>(

makeCart2D[a_,b_,name_]:=Module[{A,B,g,max},

A=Table[{a[[i]]},{i,1,Length@a}];
B=Table[{b[[i]]},{i,1,Length@b}];
max=Max@(Abs/@{Max[a],Max[b]})+3;

g=RegionPlot[RegionProduct[Point[A],Point[B]],BoundaryStyle->Directive[PointSize[Large],Red],AspectRatio->Automatic,Frame->False,Axes->True,PlotRange->{{-(max+1),max+1},{-(max+1),max+1}}];

Show[g, Graphics[{Red,Table[Tooltip[Point@{A[[i]][[1]],B[[j]][[1]]},"("<>ToString[A[[i]][[1]]]<>", "<>ToString[B[[j]][[1]]]<>")"],{i,1,Length@A},{j,1,Length@B}]}],PlotLabel->Style[name[[1]]<>"×"<>name[[2]],FontSize->30]]


];






A=Range[1,RandomInteger[{2,5}]]+RandomInteger[{-3,3}];
B={RandomInteger[{-3,3}]};)
]




m4[]:=DynamicModule[{A,B,CC},


Panel@Dynamic@Column[{
Button["Again",

A=Range[1,RandomInteger[{2,5}]]+RandomInteger[{-3,3}];
B=RandomChoice@{RandomInteger[{-3,3},2],{RandomInteger[{-3,3}]}};
CC=RandomChoice@{RandomInteger[{-3,3},2],{RandomInteger[{-3,3}]}};],


"A="<>(ToString@A),
"B="<>(ToString@B),
"C="<>(ToString@CC),
makeCart3D[A,B,CC, {"A","B","C"}]
}
]

,
Initialization:>(


makeCart3D[a_,b_,c_,name_]:=Module[{A,B,C, g,max},

A=Table[{a[[i]]},{i,1,Length@a}];
B=Table[{b[[i]]},{i,1,Length@b}];
C=Table[{c[[i]]},{i,1,Length@c}];
max=Max@{Max[Abs/@a],Max[Abs/@b],Max[Abs/@c]}+3;

g=RegionPlot3D[DiscretizeRegion@RegionProduct[Point[A],Point[B],Point[C]],BoundaryStyle->Directive[PointSize[Large],Red],AspectRatio->Automatic,Axes->True,PlotRange->{{-(max+1),max+1},{-(max+1),max+1},{-(max+1),max+1}}];

Show[g, Graphics3D[{Red,Table[Tooltip[Point@{A[[i]][[1]],B[[j]][[1]],C[[k]][[1]]},"("<>ToString[A[[i]][[1]]]<>", "<>ToString[B[[j]][[1]]]<>", "<>ToString[C[[k]][[1]]]<>")"],{i,1,Length@A},{j,1,Length@B},{k,1,Length@C}]}],PlotLabel->Style[name[[1]]<>"×"<>name[[2]]<>"×"<>name[[3]],FontSize->30],ImageSize->400]


];


A=Range[1,RandomInteger[{2,5}]]+RandomInteger[{-3,3}];
B=RandomInteger[{-3,3},2];
CC=RandomInteger[{-3,3},2];)
]

expr=Column[{

Pane@1. Cartesian Product,
Spacer[100],
Pane@Definition 1.1. The Cartesian product (or cross product) of A and B, denoted by A × B, is the set: ,
Spacer[100],
Pane@A × B = {( a , b )| a ∈ A  , b ∈ B }.
 ,
Pane@1.  the elements (a, b) of A × B are ordered pairs
2. for pairs (a, b),(c, d) we have
,
Spacer[100],
Pane@(a, b) = (c, d) ⟺ a = c and b = d
,
Spacer[100],
Pane@3. The Cartesian product A × B is not commutative,,
Pane@A × B ≠ B × A,,
Spacer[100],
Pane@because the ordered pairs are reversed except if at least one of the following conditions is satisfied:

	• A is equal to B, or
	• A or B is the empty set.
	,


Spacer[100],
Pane@Example 1.1. Let A = {1,2, 3, 4, 5} and B = {4}
,
makeCart2D[{1,2,3,4},{4},{"{1,2,3,4}","{4}"}],
Spacer[100],
makeCart2D[{4},{1,2,3,4},{"{4}","{1,2,3,4}"}],
Spacer[100],
m3[],
Spacer[100],
Pane@Example 1.2. Let A = {1,2, 3, 4} and B = {4, 5}
,
Spacer[100],
makeCart2D[{2,3,4},{4,5},{"A","B"}],
Spacer[100],
makeCart2D[{4,5},{1,2,3,4,5},{"B","A"}],
Spacer[100],
makeCart2D[{1,2,3,4,5},{1,2,3,4,5},{"A","A"}],
Spacer[100],
makeCart2D[{4,5},{4,5},{"B","B"}],
Spacer[100],
Pane@Example 1.3. Let A = {a, b, c, d, e} and B = {1, 2, 3}
,
Spacer[100],
Pane@makeCart[CharacterRange["a","e"],Range[1,3]],
Spacer[100],
Pane@Example 1.4. Let A = {a, b, c, d, e} and B = {f, g, h, i, j, k}
,
Spacer[100],
Pane@makeCart[CharacterRange["a","e"],CharacterRange["f","k"]],
Spacer[100],
Pane@Example 1.4. Let A = {4, 5} 
,
Spacer[100],
Pane@makeCart3D[{4,5},{4,5},{4,5},{"A","A","A"}],
Spacer[100],
Pane@Example 1.5. Let A = {1, 2, 3, 4}, B= {5}, C={6} 
,
Spacer[100],
Pane@makeCart3D[{1,2,3,4},{5},{6},{"{1,2,3,4}","{5}","{6}"}],

Spacer[100],
m4[],

Spacer[100],
Pane@Example 1.5. Cartesian Product could apply to any sets 
,
Spacer[100],
Pane@makeCart2[RandomSample[{,,"∫(x^x)\[DifferentialD]x","(ω^(1/∅))"},4],RandomSample[{,,},3]],
Spacer[100],

Pane@Visual Definition 
,
Spacer[100],
Pane@{{p,q}|p∈(Subscript[reg, 1])∧q∈(Subscript[reg, 2])}
,
Spacer[100],
Pane@Row[{,"×",,,}],

Spacer[100],
Pane@Example 1.6. [0, 1]×[0, 1]
,
Spacer[100],
Pane@Row[{,"×",,,BoundaryDiscretizeRegion@RegionProduct[Line[{{0},{1}}],Line[{{0},{1}}]]}],

Spacer[100],
Pane@Example 1.7. C×[0, 1], where C is the circle's arc in first quadrant
,
Spacer[100],
m1[],
Spacer[100],
Pane@Example 1.8. C×[0, 1], where C is the punctured disk
,
x=BoundaryMeshRegion[{{0,0},{3,0},{3,3},{0,3},{1,1},{2,1},{2,2},{1,2}},Line[{1,2,3,4,1}],Line[{5,6,7,8,5}]],
Spacer[100],


Pane@Row[{x,"×",,,RegionPlot3D[RegionProduct[x,BoundaryMeshRegion[{{0},{1}},Point[{1,2}]]],PlotStyle->Directive[Yellow,Opacity[0.5]],Mesh->None,Boxed->False,ImageSize->300]}],
Spacer[100],
Pane@Example 1.9. C×[0, 1], where C is the grid-punctured disk
,
Spacer[100],
rectangleCoords[{i_,j_}]:=rectangleCoords[{i,j},{0.5,0.5}];
rectangleCoords[{i_,j_},{α_,β_}]:={{i-α/2,j-β/2},{i+α/2,j-β/2},{i+α/2,j+β/2},{i-α/2,j+β/2}};

rectangleIndexes[i_]:=Line[i-1+{1,2,3,4,1}];

RectangleHoleMesh[{m_,n_}]:=Module[{oc,hc},
hc=Flatten[Table[rectangleCoords[{i,j}],{j,n},{i,m}],2];
oc={{0,0},{m+1,0},{m+1,n+1},{0,n+1}};
BoundaryMeshRegion[Join[hc,oc],
rectangleIndexes[4 m n+1],
Sequence@@Table[rectangleIndexes[i],{i,1,4 m n,4}]
]
];m2[]

}]

CDFDeploy[ToFileName[{$UserDocumentsDirectory},"Cartesian_Product.cdf"],expr,"Method"->"Standalone"];