<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>I think we are in agreement now on this.<BR>
My original assertions were indeed wrong for <= and >=.<BR>
I'm not even sure they were correct for < and >.<BR>
<BR>
- Jay<BR><BR><BR>
<HR id=stopSpelling>
<BR>
> To: jayk123@hotmail.com<BR>> CC: m3devel@elegosoft.com<BR>> Subject: Re: [M3devel] small set comparisons understood, now just to understand the front end code.. <BR>> Date: Mon, 14 Apr 2008 13:10:05 -0700<BR>> From: mika@async.caltech.edu<BR>> <BR>> Sorry, I think the Green Book is completely unambiguous about this.<BR>> <BR>> a < b is the same as a <= b AND a # b for all a and b, no matter<BR>> the type (set, integer, or floating). That's what 2.6.11 says, and<BR>> it seems correct, because it implies that for sets, <= is the subset<BR>> relation, and < is the proper subset relation.<BR>> <BR>> Mika<BR>> <BR>> Jay writes:<BR>> >--_a67e670a-e4c4-4f68-a1a3-4f4661e52338_<BR>> >Content-Type: text/plain; charset="iso-8859-1"<BR>> >Content-Transfer-Encoding: quoted-printable<BR>> ><BR>> > a < b "should be implemented as" (a & b) =3D=3D a=20<BR>> >=20<BR>> > I believe, and so on.=20<BR>> >I could be wrong. I only thought about it a few minutes.=20<BR>> >=20<BR>> > The current incorrect code is:=20<BR>> >PROCEDURE Set_compare (s: Size; op: Cmp) =3D BEGIN IF Force_pair (comm=<BR>> >ute :=3D TRUE) THEN op :=3D M3CG.SwappedCompare [op]; END; IF (s=<BR>> > <=3D Target.Integer.size) THEN cg.compare (Target.Word.cg_type, Targe=<BR>> >t.Integer.cg_type, op); ELSE cg.set_compare (AsBytes (s), op, Target.I=<BR>> >nteger.cg_type); END; SPop (2, "Set_eq"); SPush (Type.Int32); END=<BR>> > Set_compare;<BR>> >=20<BR>> >which generates simply, I think this was <=3D (jbe -- jump if below or equa=<BR>> >l):<BR>> >=20<BR>> >=20<BR>> > 0040119C: 56 push esi 0040119D: E8 AE FE FF FF =<BR>> > call _Main__m 004011A2: 83 C4 04 add esp,4<BR>> >=20<BR>> > ... end of previous line that just called m("foo")=20<BR>> >=20<BR>> > ; push a string to print=20<BR>> > 004011A5: 8D 35 2C 12 40 00 lea esi,ds:[40122Ch] 004011AB: 56 =<BR>> > push esi<BR>> >=20<BR>> > ; compare two sets=20<BR>> > ; one is constant 0x15; one is a global=20<BR>> > 004011AC: 83 3D 44 90 45 00 cmp dword ptr ds:[459044h],15h =<BR>> > 15<BR>> >=20<BR>> > ; spend a while converting the compare result to a boolean 004011B3: 0F =<BR>> >96 45 FC setbe byte ptr [ebp-4] 004011B7: 33 DB =<BR>> >xor ebx,ebx 004011B9: 8A 5D FC mov bl,byte ptr [=<BR>> ebp-4] 004011BC: 83 FB 00 cmp ebx,0 004011BF: 0F 94 45 =<BR>> >F8 sete byte ptr [ebp-8] 004011C3: 33 D2 xor =<BR>> > edx,edx 004011C5: 8A 55 F8 mov dl,byte ptr [ebp-8]<BR>> > ; and then push that boolean=20<BR>> > 004011C8: 52 push edx<BR>> > 004011C9: E8 6C FF FF FF call _Main__checkM<BR>> >oh, you are right, < needs to also be !=3D.<BR>> >I thought it was suspicious to have only two implementations of four operat=<BR>> >ions, but I did like the resulting efficiency. :)<BR>> >Hey, I was at least sure the current code was wrong.<BR>> >=20<BR>> > - Jay<BR>> ><BR>> ><BR>> ><BR>> >> To: jayk123@hotmail.com> Subject: Re: [M3devel] small set comparisons und=<BR>> >erstood, now just to understand the front end code.. > Date: Mon, 14 Apr 20=<BR>> >08 10:16:01 -0700> From: mika@async.caltech.edu> > Jay writes:> >--_6435b74=<BR>> >a-d943-44c2-9091-ab0408dc7ed0_> >Content-Type: text/plain; charset=3D"iso-8=<BR>> >859-1"> >Content-Transfer-Encoding: quoted-printable> >> >> >currently set =<BR>> ><,>,<=3D3D,>=3D3D are implemented merely as> >integer <,>,<=3D3D,>=3D3D> >=<BR>> >=3D20> >This is wrong.> >=3D20> >I believe it should be:> >=3D20> >a < b =<BR>> >=3D3D> (a & b) =3D3D=3D3D a> >a <=3D3D b =3D3D> (a & b) =3D3D=3D3D a (same =<BR>> >as <=3D3D)> >a > b =3D3D> (a & b) =3D3D=3D3D b> >a >=3D3D b =3D3D> (a & b) =<BR>> >=3D3D=3D3D b (same as >)> > You don't actually mean logical implication by =<BR>> >your arrows do you,> but equivalence, where the objects to the left of the =<BR>> >arrow refer> to the abstract sets a and b and the objects to the right of t=<BR>> >he> arrow refer to bit-vector implementations (in C) of the same?> > Green =<BR>> >Book, page 57, section 2.6.1:> > "In all cases, x < y means (x <=3D y) AND =<BR>> >(x # y), and x > y means y < x."> > So in your syntax a > b would be ((a & =<BR>> >b) =3D=3D a) && (a !=3D b).> > Also, just above it, > > "The expression x >=<BR>> >=3D y is equivalent to y <=3D x."> > Why not define the operation "x >=3D y=<BR>> >" and then use the two statements> from the Green Book to generate the rest=<BR>> >?> > Mika=<BR>> ><BR>> >--_a67e670a-e4c4-4f68-a1a3-4f4661e52338_<BR>> >Content-Type: text/html; charset="iso-8859-1"<BR>> >Content-Transfer-Encoding: quoted-printable<BR>> ><BR>> ><html><BR>> ><head><BR>> ><style><BR>> >.hmmessage P<BR>> >{<BR>> >margin:0px;<BR>> >padding:0px<BR>> >}<BR>> >body.hmmessage<BR>> >{<BR>> >FONT-SIZE: 10pt;<BR>> >FONT-FAMILY:Tahoma<BR>> >}<BR>> ></style><BR>> ></head><BR>> ><body class=3D'hmmessage'> a < b "should be implemented as" (a &=<BR>> >; b) =3D=3D a <BR><BR>> > <BR><BR>> > I believe, and so on. <BR><BR>> >I could be wrong. I only thought about it a few minutes. <BR><BR>> > <BR><BR>> > The current incorrect code is: <BR><BR>> ><BR>PROCEDURE Set_compare (s: Size; op: Cmp) =3D<BR> BEGIN<BR>&=<BR>> >nbsp; IF Force_pair (commute :=3D TRUE) THEN<BR> &nb=<BR>> >sp; op :=3D M3CG.SwappedCompare [op];<BR> END=<BR>> >;<BR> IF (s <=3D Target.Integer.size)<BR> &=<BR>> >nbsp; THEN cg.compare (Target.Word.cg_type, Target.Integer.cg_t=<BR>> >ype, op);<BR> ELSE cg.set_compare (AsBytes (s=<BR>> >), op, Target.Integer.cg_type);<BR> END;<BR> &=<BR>> >nbsp; SPop (2, "Set_eq");<BR> SPush (Type.Int32);<BR>&nbs=<BR>> >p; END Set_compare;<BR><BR><BR>> > <BR><BR>> >which generates simply, I think this was <=3D (jbe -- jump if below or e=<BR>> >qual):<BR><BR>> > <BR><BR>> > <BR><BR>> > 0040119C: 56 &n=<BR>> >bsp; push =<BR>> > esi<BR> 0040119D: E8 AE FE FF FF =<BR>> > call _Main__m<BR> 004011A2=<BR>> >: 83 C4 04 add&=<BR>> >nbsp; esp,4<BR><BR>> > <BR><BR>> > ... end of previous line that just called m("foo") <BR><BR>> > <BR><BR>> > ; push a string to print <BR><BR>> > 004011A5: 8D 35 2C 12 40 00 lea &=<BR>> >nbsp; esi,ds:[40122Ch]<BR> 004011AB: 56 =<BR>> > &nb=<BR>> >sp; push esi<BR><BR>> > <BR><BR>> > ; compare two sets <BR><BR>> > ; one is constant 0x15; one is a global <BR><BR>> > 004011AC: 83 3D 44 90 45 00 cmp &=<BR>> >nbsp; dword ptr ds:[459044h],15h<BR> &nb=<BR>> >sp; 15<BR><BR>> > <BR><BR>> > ; spend a while converting the compare result to a boolean <BR> =<BR>> > 004011B3: 0F 96 45 FC setbe =<BR>> >; byte ptr [ebp-4]<BR> 004011B7: 33 DB&=<BR>> >nbsp; &nbs=<BR>> >p; xor ebx,ebx<BR> 00=<BR>> >4011B9: 8A 5D FC  =<BR>> >; mov bl,byte ptr [ebp-4]<B=<BR>> >R> 004011BC: 83 FB 00 =<BR>> > cmp ebx,0<BR>&=<BR>> >nbsp; 004011BF: 0F 94 45 F8 sete&=<BR>> >nbsp; byte ptr [ebp-8]<BR> 004011=<BR>> >C3: 33 D2 =<BR>> > xor edx,edx<BR=<BR>> >> 004011C5: 8A 55 F8 &=<BR>> >nbsp; mov dl,byte ptr=<BR>> > [ebp-8]<BR><BR><BR>> > ; and then push that boolean <BR><BR>> > 004011C8: 52 &n=<BR>> >bsp; push =<BR>> > edx<BR><BR>> > 004011C9: E8 6C FF FF FF call &nb=<BR>> >sp; _Main__checkM<BR><BR><BR><BR>> >oh, you are right, < needs to also be !=3D.<BR><BR>> >I thought it was suspicious to have only two implementations of four operat=<BR>> >ions, but I did like the resulting efficiency. :)<BR><BR>> Hey, I was at least sure the current code was wrong.<BR><BR>> > <BR><BR>> > - Jay<BR><BR><BR><BR><BR>> ><BR>> ><HR id=3DstopSpelling><BR>> ><BR><BR>> >> To: jayk123@hotmail.com<BR>> Subject: Re: [M3devel] small set compa=<BR>> >risons understood, now just to understand the front end code.. <BR>> Dat=<BR>> >e: Mon, 14 Apr 2008 10:16:01 -0700<BR>> From: mika@async.caltech.edu<BR>=<BR>> >> <BR>> Jay writes:<BR>> >--_6435b74a-d943-44c2-9091-ab0408dc7e=<BR>> >d0_<BR>> >Content-Type: text/plain; charset=3D"iso-8859-1"<BR>> &g=<BR>> >t;Content-Transfer-Encoding: quoted-printable<BR>> ><BR>> ><BR>=<BR>> >> >currently set <,>,<=3D3D,>=3D3D are implemented merely=<BR>> > as<BR>> >integer <,>,<=3D3D,>=3D3D<BR>> >=3D20<BR>=<BR>> >> >This is wrong.<BR>> >=3D20<BR>> >I believe it should b=<BR>> >e:<BR>> >=3D20<BR>> >a < b =3D3D> (a & b) =3D3D=3D3D =<BR>> >a<BR>> >a <=3D3D b =3D3D> (a & b) =3D3D=3D3D a (same as <=<BR>> >;=3D3D)<BR>> >a > b =3D3D> (a & b) =3D3D=3D3D b<BR>> >=<BR>> >;a >=3D3D b =3D3D> (a & b) =3D3D=3D3D b (same as >)<BR>> <B=<BR>> >R>> You don't actually mean logical implication by your arrows do you,<B=<BR>> >R>> but equivalence, where the objects to the left of the arrow refer<BR=<BR>> >>> to the abstract sets a and b and the objects to the right of the<BR>&=<BR>> >gt; arrow refer to bit-vector implementations (in C) of the same?<BR>> <=<BR>> >BR>> Green Book, page 57, section 2.6.1:<BR>> <BR>> "In all cases,=<BR>> > x < y means (x <=3D y) AND (x # y), and x > y means y < x."<BR=<BR>> >>> <BR>> So in your syntax a > b would be ((a & b) =3D=3D a) &=<BR>> >amp;& (a !=3D b).<BR>> <BR>> Also, just above it, <BR>> <BR>&g=<BR>> >t; "The expression x >=3D y is equivalent to y <=3D x."<BR>> <BR>&=<BR>> >gt; Why not define the operation "x >=3D y" and then use the two stateme=<BR>> >nts<BR>> from the Green Book to generate the rest?<BR>> <BR>> Mika=<BR>> ><BR><BR></body><BR>> ></html>=<BR>> ><BR>> >--_a67e670a-e4c4-4f68-a1a3-4f4661e52338_--<BR><BR></body>
</html>