Calculation to determine which of 16 binary functions satisfy the associative law of SEMIGROUPOID and which ones don't
Download
View Source (print view)
Rating : 4.7
Views : 379
<?php
$functions = array(
"0"=>"0000",
"&"=>"0001",
"x & ~y"=>"0010",
"x"=>"0011",
"~x & y"=>"0100",
"y"=>"0101",
"xor"=>"0110",
"or"=>"0111",
"nor"=>"1000",
"~nor"=>"1001",
"~y"=>"1010",
"x | ~y"=>"1011",
"~x"=>"1100",
"~x | y"=>"1101",
"nand"=>"1110",
"1"=>"1111");
foreach ($functions as $key=>$function)
{
echo "<br><table border=1 cellpadding=3 cellspacing=0>";
echo "<tr><td colspan=8 align=center bgcolor=silver><font color=blue><b>$key</b></font></b></td></tr>";
echo "<tr><td align=center>x</td><td align=center>y</td><td align=center>z</td><td align=center>(y+z)</td><td align=center>x+(y+z)</td><td align=center>(x+y)</td><td align=center>(x+y)+z</td><td>x+(y+z)=(x+y)+z</td>";
foreach($xarr=array(false,true) as $x)
{
foreach($yarr=array(false,true) as $y)
{
foreach($zarr=array(false,true) as $z)
{
if($x){$displayX = "T";}
else {$displayX = "F";}
if($y){$displayY = "T";}
else {$displayY = "F";}
if($z){$displayZ = "T";}
else {$displayZ = "F";}
echo "<tr>";
echo "<td>   $displayX   </td><td>   $displayY   </td><td>   $displayZ   </td>";
$leftside = operation($x,operation ($y,$z,$function),$function);
$rightside = operation(operation($x,$y,$function),$z,$function);
echo "<td align=center>".operation ($y,$z,$function)."</td>";
echo "<td align=center>".$leftside."</td>";
echo "<td align=center>".operation($x,$y,$function)."</td>";
echo "<td align=center>".$rightside."</td>";
if($leftside == $rightside)
{
echo "<td align=center>";
echo "<font color=green>";
}
else
{
echo "<td bgcolor=silver align=center>";
echo "<font color=red>";
}
echo "$leftside = $rightside";
echo "</font></b>";
echo "</td>";
echo "</tr>";
}
}
}
echo "</table>";
}
echo "<br><br>";
echo"<table bgcolor=silver width=80%>";
echo "<tr><td>";
$source = 'semigroupoid.php';
highlight_file($source);
echo "</td></tr>";
echo "<table>";
function operation($firstValue,$secondValue,$functionID)
{
#$functionResults = array ($functionID[0],$functionID[1],$functionID[2],$functionID[3]);
if( (!$firstValue) && (!$secondValue) )
{
return $functionID[0];
}
if( (!$firstValue) && ($secondValue) )
{
return $functionID[1];
}
if( ($firstValue) && (!$secondValue) )
{
return $functionID[2];
}
if( ($firstValue) && ($secondValue) )
{
return $functionID[3];
}
}
?>
download, regirstration form, php_snips, fedex, call php', userstatusinonline, php_script"_class="neww"_target="_blank"_title="im_neuen, best ide, php script" class="neww" target="_b..., forum, p t test paired, guest, php_tools, href php function, utfraw, php jobs, php script and char(124) (select cast(count(1) as varchar(8000)) char(124) from [sysobjects] where 1=1)>0 and =, commit, gonzo_florin, yahoo status check, rss