From: "Yefim Dinitz" <dinitz@cs.bgu.ac.il>
To: "dinitz@cs.bgu.ac.il"
Subject: activities
Date: Thu, 26 Feb 2009 16:06:32 +0200
MIME-Version: 1.0
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_07D9_01C9982C.30DF66E0"
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579

This is a multi-part message in MIME format.

------=_NextPart_000_07D9_01C9982C.30DF66E0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Correctness proof for the Activities algorithm Greedy:

<formal definition of the problem>
<algorithm Greedy>
<auxiliary statements A and B with proofs>

Correctness proof :

Invariant INV :=20
   S is a prefix of some optimal solution T.

1) At the beginning, INV holds for any optimal solution, since the empty =
set is a prefix of any ordered set.

2) Statement:
       If S was a prefix of an optimal solution T, and Greedy added a to =
S, then S U {a} is a prefix of some optimal solution T'.

Proof:
   <Drawing>: T: (S=3D) _____   _________  ______ < a' > (RPT=3D) ____  =
________ ___ =20

where RPT means "Right Part of T"

Observe that the case shown at Drawing is representative (that is the =
single possible). Indeed, all activities in T - S should be righter than =
those in S, since S is a prefix of T.

Case 1: a' =3D a.
    Then, we set T'=3DT, and the new S =3D S U {a} is indeed a prefix of =
T'.

Case 2" a' is not a.
    Then, we set T' =3D T - {a'} U {a}.=20
    Let us prove that T' is legal. Of course, T - {a'} is legal as a =
part of T. It remains to show that a does not intersect with T - {a'} =
=3D S U RPT.

    1. a does not intersect S by the algorithm.
    2. Since a' precedes RPT in T, for any activity a''=3D(s",t") in RPT =
holds: f' =3D< s" .=20
        By the choice of a in Greedy, holds: f =3D< f', since both of a =
and a' participated in the choice, and a has the earliest finishing =
time.
        Hence, for any activity a''=3D(s",t") in RPT holds: f =3D< f' =
=3D< s" , as required.

    Let us check that T' is optimal. Indeed, |T'| =3D |T| -1 + 1 =3D =
|T|. Since T is optimal, also T' is optimal.=20
    Besides, S is a prefix of T', since a precedes RPT.

3) At the end of Greedy, by INV, S is a prefix of an optimal solution T. =
Assume to the contrary, that T - S is non-empty. Then, any activity in T =
- S could be added to S, a contradiction to the finishing condition of =
Greedy.

<end-of-proof>

Comments:=20

1) It is a dangerous source of errors to use a drawing that shows only =
one of the possible cases!!

2) Seemingly, when INV incudes the requirement "prefix", Auxiliary =
Statement C is extra. It could be useful, if we would remove the =
requirement "prefix" from INV, but both of them are not needed. =
Nevertheless, I add the proof of that statement:

Auxiliary Statement C:
   Greedy produces activities from the left to the right.

Proof:
   Assume to the contrary that there is a problem instance such that =
Greedy violates this property. Let us consider the *first* time during =
the executon when activity a=3D(s,f) added to S satisfies the wrong =
inequality f < s', where a'=3D(s',f') is the rightmost activity in S.=20

Notice that the previous choice was S <-- S U {a'} (since our case is =
the first wrong one). However, at the time of that choice, also activity =
a was available, and its finishing time was earlier. Why a was not =
chosen? -- a contradiction to the algorithm.
<end-of-proof>

------=_NextPart_000_07D9_01C9982C.30DF66E0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.6000.16809" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Correctness proof for the Activities =
algorithm=20
Greedy:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;formal definition of the=20
problem&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&lt;algorithm Greedy&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&lt;auxiliary statements A and B with=20
proofs&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Correctness proof :</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Invariant INV : </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; S is a prefix of some =
optimal solution=20
T.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>1) At the beginning, INV holds for any =
optimal=20
solution, since the empty set is a prefix of any ordered =
set.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>2) Statement:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If =
S was a=20
prefix of an optimal solution T, and Greedy added a to S, then S U {a} =
is a=20
prefix of some optimal solution T'.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Proof:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; &lt;Drawing&gt;:&nbsp;T: =
(S=3D)=20
_____&nbsp;&nbsp; _________&nbsp; ______&nbsp;&lt; a' &gt; (RPT=3D) =
____&nbsp;=20
________ ___&nbsp; </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>where RPT means "Right Part of =
T"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Observe that the case shown at Drawing =
is=20
representative (that is the single possible). Indeed, all activities in =
T -=20
S&nbsp;should be&nbsp;righter than those in S, since S is a prefix of=20
T.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Case 1: a' =3D a.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; &nbsp;Then, we set T'=3DT, =
and the new S=20
=3D S U {a} is indeed a prefix of T'.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Case 2" a' is not a.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Then, we set T' =3D =
T - {a'} U=20
{a}. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Let us prove that T' =
is legal.=20
Of course, T - {a'} is legal as a part of T. It remains to show that a =
does not=20
intersect with T - {a'} =3D S U RPT.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; 1. a does not =
intersect S by the=20
algorithm.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; 2. Since a' precedes =
RPT in T,=20
for any activity a''=3D(s",t") in RPT holds: f' =3D&lt; s" . =
</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; By the=20
choice of a in Greedy, holds: f =3D&lt; f', since both of a and a' =
participated in=20
the choice, and a has&nbsp;the earliest finishing time.</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hence,=20
for any activity a''=3D(s",t") in RPT holds: f =3D&lt; f' =3D&lt; s" , =
as=20
required.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Let us check that T' =
is optimal.=20
Indeed, |T'| =3D |T| -1 + 1 =3D |T|. Since T is optimal, also T' is =
optimal.=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Besides, S is a =
prefix of T',=20
since a precedes RPT.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>3) At the end of Greedy, by INV, S is a =
prefix of=20
an optimal solution T. Assume to the contrary, that T - S is non-empty. =
Then,=20
any activity in T - S could be added to S, a contradiction to the =
finishing=20
condition of Greedy.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;end-of-proof&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Comments: </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>1) It is a dangerous source of errors =
to use a=20
drawing that shows only one of the possible cases!!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>2) Seemingly, when INV incudes the =
requirement=20
"prefix", Auxiliary Statement C is extra. It could be useful, if we =
would remove=20
the requirement "prefix" from INV, but both of them are not=20
needed.&nbsp;Nevertheless, I add the proof of that =
statement:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>Auxiliary Statement C:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; Greedy produces activities =
from the=20
left to the right.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Proof:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; Assume to the contrary =
that there is a=20
problem instance such that Greedy violates this property. Let us =
consider the=20
*first* time during the executon when activity a=3D(s,f) added to S =
satisfies the=20
wrong inequality f&nbsp;&lt; s', where a'=3D(s',f') is =
the&nbsp;rightmost activity=20
in S. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Notice that the previous choice was S =
&lt;-- S U=20
{a'} (since our case is the first wrong one). However, at the time of =
that=20
choice, also activity a was available, and its finishing time was =
earlier. Why a=20
was not chosen? --&nbsp;a&nbsp;contradiction to the =
algorithm.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&lt;end-of-proof&gt;</FONT></DIV>
<DIV></FONT><FONT face=3DArial =
size=3D2></FONT>&nbsp;</DIV></DIV></BODY></HTML>

------=_NextPart_000_07D9_01C9982C.30DF66E0--
