Mathematica - Visual Logic

Posted on April 4, 2021
Tags: mathematica

1 Visualizing Logic

AArrow[{p_, q_}, label_:""] := {{Inset[Style[label,Purple],Midpoint[{p,q}]], Arrow[{p,q}]}};
vec2[p_] := Graphics@AArrow[{ConstantArray[0,Length[p]],p}];
vec2[p_,q_] := Which[  ArrayQ[q] == False, Graphics@AArrow[{ConstantArray[0,Length[p]],p},q],
                       ArrayQ[q] == True, Graphics@AArrow[{p,q},""] ]
vec2[p_,q_,label_] := Graphics@AArrow[{p,q},label];

vec[p_] := Which[ Length[p] == 2, vec2[p],
                  Length[p] == 3, vec2[p] /. Graphics -> Graphics3D ];
vec[p_,q_] := Which[ Length[p] == 2, vec2[p,q],
                     Length[p] == 3, vec2[p,q] /. Graphics -> Graphics3D ];
vec[p_,q_,label_] := Which[  Length[p] == 2,vec2[p,q,label],
                             Length[q] == 3,vec2[p,q,label] /. Graphics -> Graphics3D];

matrix[expr_] := expr /. List[p__]-> MatrixForm[List[p]]
cout[x__] := TeXForm[Row[{x}]];
pnt[x_] := Graphics3D@Point[x];

The paradox of \(\bigcap\limits_{i\in I} A_i \qquad \bigwedge\limits_{i\in I} A_i\) Power vs Constraint


Row[{
Show[Graphics3D[{Opacity[0.3],ResourceFunction["Disk3D"][{0,0.5,0},2]}],
Graphics3D[{Opacity[0.3],ResourceFunction["Disk3D"][{1,1,3},2]}],
Graphics3D[{Opacity[0.3],ResourceFunction["Disk3D"][{0,0,2},1]}],
Graphics3D[{Opacity[0.3],ResourceFunction["Disk3D"][{2,0,1.5},2]}],
vec[{0,0,5}],
ImageSize->Small
],

Show[
Graphics[{Opacity[0.3],Disk[{0,0.5},2]}],
Graphics[{Opacity[0.3],Disk[{1,1},2]}],
Graphics[{Opacity[0.3],Disk[{0,1},1]}],
Graphics[{Opacity[0.3],Disk[{2,0},2]}],
Graphics@Text["Intersect",{0.6,0.9}],
ImageSize->Small
]
}]
Output

Vertically, we see the 3d line passing thru 4 stacks giving us more power/evidence for proving.
However in another perspective we see this power is constrained as some subset for any of the other sets.

2 Necessary and Sufficient

2.1 Sufficient

Sufficient can be seen as a type of injectivity.
X is sufficient for Y, we can inject X into Y but that doesnt mean that X is the only injection.

  • Sufficient = Must
  • Red gene is sufficient for sight
  • One can visualize the space of the venn diagram to contain different ways of expressing a certain gene.
  • Taken literally: If one expresses red gene then one must have sight
  • Reality: If one has expresses a collection of genes along with red gene then one must have sight
  • The set of ALL genes is also sufficient for sight (vacuous evidence) An example of Power in \(\bigcap\limits_{i\in I} A_i\)

Biological sufficiency, red gene is sufficient for sight:

  • \((\bigcap\limits_{i\in I} Gene_i \cap red) \rightarrow sight\)
Show[

Graphics[{Opacity[0.3],Disk[{0,0.5},2]}],
Graphics[{Opacity[0.3],Disk[{1,1},2]}],
Graphics[{Opacity[0.3],Disk[{0,1},1]}],
Graphics[{Opacity[0.3],Disk[{2,0},2]}],
Graphics[{Blue,Opacity[0.2],Disk[{1.5,2.5},3]}],
Graphics@Text["Intersect",{0.6,0.9}],
Graphics@Text["Sight",{2.5,4}],

ImageSize->Small
]
Output
Show[

Graphics[{Red,Opacity[0.3],Disk[{1.5,2.5},2.8]}],
Graphics[{Blue,Opacity[0.3],Disk[{2,7},1]}],
Graphics[{Blue,Opacity[0.3],Disk[{6,3},1]}],
Graphics[{Blue,Opacity[0.3],Disk[{10,6},2]}],
Graphics[{Blue,Opacity[0.4],Disk[{1.5,2.5},3]}],
Graphics@Text["Rained",{0.6,0.9}],
Graphics@Text["Wet",{2.5,4}],
Graphics@Text["Wet",{2,7}],
Graphics@Text["NotWet",{6.5,1}],
Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]},
ImageSize->Small
]
Output
  • The red circle aka purple subset of the blue circle represents Rained.
  • The blue circle represents Wet Ground
  • The gray area represents Not Wet Ground
  • The gray area + the thin blue boundary around red Rained circle represents Not Rained

Rain is sufficient for a wet ground.
But there may be many other reasons for a wet ground (the multiple blue circles).
Just because the ground is wet does not mean it must have rained.
But if the ground is not wet then we know it must not have rained. Contrapositive (The grey area is a subset of gray area + thin blue boundary around rained).

Experimenter might induce rain then show that the ground is wet to prove sufficiency.

Row[{
Plot[x,{x,0,1}],
Plot[x=1,{x,0,1}]
}]
Output