<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1296081044595245207</id><updated>2012-02-16T03:29:56.554-08:00</updated><title type='text'>Rocket Scientist's log</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://rocketscientistlog.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://rocketscientistlog.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Bimal</name><uri>http://www.blogger.com/profile/04593105510379142308</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_HTO3ZItlYwA/SRzJfngdo-I/AAAAAAAAABQ/0EkwIhr-VOk/S220/avatar12243_2.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>16</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1296081044595245207.post-1821959718749591735</id><published>2008-12-05T19:48:00.000-08:00</published><updated>2008-12-05T20:03:20.911-08:00</updated><title type='text'>Final Words</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_HTO3ZItlYwA/STn3kYGTtwI/AAAAAAAAAD4/aP1eqvtW_is/s1600-h/CMS_Higgs-event.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 367px; height: 337px;" src="http://4.bp.blogspot.com/_HTO3ZItlYwA/STn3kYGTtwI/AAAAAAAAAD4/aP1eqvtW_is/s320/CMS_Higgs-event.jpg" alt="" id="BLOGGER_PHOTO_ID_5276520642757506818" border="0" /&gt;&lt;/a&gt;Contrary to CSC165, I actually enjoyed this course. It laid more emphasis on applications rather than theoretical proofs. The problem solving techniques helped me tackle problems in different ways (specially in physics) and upgraded my problem solving abilities. I learnt that all problems do not need to be solved mathematically but a bit of logic can help a lot; example the binary arithmetic trick for the 4th question for A3.&lt;br /&gt;&lt;br /&gt;Although I did run into some medical issues during the semester, I am a bit worried about my marks but I was able to catch up most of the work I missed and Danny was very helpful throughout the term. I am very thankful to him for all his help in CSC165 and CSC236 and to the TA's at the CS Help Center. This course makes me feel more confident that I will actually be able to do the AI specialist without glitches and inspires me to continue in this field.&lt;br /&gt;&lt;br /&gt;Happy holidays to everyone!&lt;br /&gt;&lt;br /&gt;Bimal&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1296081044595245207-1821959718749591735?l=rocketscientistlog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rocketscientistlog.blogspot.com/feeds/1821959718749591735/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1296081044595245207&amp;postID=1821959718749591735' title='39 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/1821959718749591735'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/1821959718749591735'/><link rel='alternate' type='text/html' href='http://rocketscientistlog.blogspot.com/2008/12/final-words.html' title='Final Words'/><author><name>Bimal</name><uri>http://www.blogger.com/profile/04593105510379142308</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_HTO3ZItlYwA/SRzJfngdo-I/AAAAAAAAABQ/0EkwIhr-VOk/S220/avatar12243_2.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_HTO3ZItlYwA/STn3kYGTtwI/AAAAAAAAAD4/aP1eqvtW_is/s72-c/CMS_Higgs-event.jpg' height='72' width='72'/><thr:total>39</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1296081044595245207.post-6933949040385791384</id><published>2008-12-05T14:09:00.000-08:00</published><updated>2008-12-05T14:39:11.684-08:00</updated><title type='text'>Test 3</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_HTO3ZItlYwA/STmoDZ2-iKI/AAAAAAAAADY/xCFSMyTiwEI/s1600-h/sick_image.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 289px; height: 320px;" src="http://3.bp.blogspot.com/_HTO3ZItlYwA/STmoDZ2-iKI/AAAAAAAAADY/xCFSMyTiwEI/s320/sick_image.jpg" alt="" id="BLOGGER_PHOTO_ID_5276433214875797666" border="0" /&gt;&lt;/a&gt;Today we had test 3 but I did not do so well in it (I dont know, maybe I did). I have a bad fever and a flu since 5 days and its been bugging me a lot... I cant even study properly... I thought of going to the hospital but the fear of having to take a blood test forced me to take the test no matter what; because last time I took a blood test, the syringe needle broke in my arm and getting that thing out was the most painful experience in my life and since then, has become my greatest fear...&lt;br /&gt;&lt;br /&gt;About the test, the first question about the DFSA seemed familiar to Q4 from the third assignment. I think I got all the state declarations right and I think the way to tackle part b of the first question was to count the odd/even number of 1's and their sums and match them to the declaration that suits it.&lt;br /&gt;&lt;br /&gt;I think I bombed the second question, I thought about it on my way home and I think I got the wrong answer for it. I proved that if there is a regex for R1 and R2 then there is a subset that can be denoted for L(R1 + R2)  and since R1+R2 belongs to R, then the subset (0,1,epsilon) exists...&lt;br /&gt;&lt;br /&gt;The third question was easy but I think I used the wrong technique... I made a DFSA that represents L2 and by using minimisation techniques, I got a regular expression that takes from state epsilon to a final accepting state and that regular expression was eqivalent to the L( ... ) expression. I wanted to make a formal proof but my head hurt too much and I couldnt concentrate anymore.&lt;br /&gt;&lt;br /&gt;I hope I will get better soon because my finals start next week and I need to study for them.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1296081044595245207-6933949040385791384?l=rocketscientistlog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rocketscientistlog.blogspot.com/feeds/6933949040385791384/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1296081044595245207&amp;postID=6933949040385791384' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/6933949040385791384'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/6933949040385791384'/><link rel='alternate' type='text/html' href='http://rocketscientistlog.blogspot.com/2008/12/test-3.html' title='Test 3'/><author><name>Bimal</name><uri>http://www.blogger.com/profile/04593105510379142308</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_HTO3ZItlYwA/SRzJfngdo-I/AAAAAAAAABQ/0EkwIhr-VOk/S220/avatar12243_2.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_HTO3ZItlYwA/STmoDZ2-iKI/AAAAAAAAADY/xCFSMyTiwEI/s72-c/sick_image.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1296081044595245207.post-1428260949765784060</id><published>2008-12-04T19:36:00.000-08:00</published><updated>2008-12-05T21:09:46.131-08:00</updated><title type='text'>An interesting example on the Pumping Lemma</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_HTO3ZItlYwA/STn7Qjr8_DI/AAAAAAAAAEA/71QDTgVEUlE/s1600-h/Jet_pump.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 302px; height: 320px;" src="http://2.bp.blogspot.com/_HTO3ZItlYwA/STn7Qjr8_DI/AAAAAAAAAEA/71QDTgVEUlE/s320/Jet_pump.jpg" alt="" id="BLOGGER_PHOTO_ID_5276524700317318194" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I had some problems understanding the Pumping Lemma and while reading a book (Introduction to Automata Theory Languages and Computation 2nd edition page 128) I came across an interesting example of how they described the Pumping Lemma as a game:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;The Pumping Lemma as an Adversarial Game&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;... &lt;/span&gt;&lt;/span&gt;The pumping lemma is an important example in a theorem that involves several alternations of 'for-all'  and 'there-exists' quantifiers that can be thought of as a game between two players, since it in effect involves four different quantifiers: "for all regular languages L there exists n such that for all w in L with /w/ &gt;= n there exists xyz equal to w such that ..." We can see the application of the pumping lemma as a game, in which:&lt;br /&gt;&lt;br /&gt;1. Player 1 picks the language L to be proved nonregular.&lt;br /&gt;&lt;br /&gt;2. Player 2 picks n, but doesn't reveal to player 1 what n is; player 1 must devise a play for all possible n's.&lt;br /&gt;&lt;br /&gt;3. Player 1 picks w, which may depend on n and which must be of length at least n.&lt;br /&gt;&lt;br /&gt;4. Player 2 divides w into x, y, and z, obeying the constraints that are stipulated in the pumping lemma; y != epsilon and /xy/ &lt;= n. Again player 2 does not have to tell player 1 what x,y, and z are, although they must obey the constraints. &lt;br /&gt;&lt;br /&gt;5. Player 1 "wins" by picking k, which may be a function of n,x,y, and z, such that x(y^k)z is not in L. &lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1296081044595245207-1428260949765784060?l=rocketscientistlog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rocketscientistlog.blogspot.com/feeds/1428260949765784060/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1296081044595245207&amp;postID=1428260949765784060' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/1428260949765784060'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/1428260949765784060'/><link rel='alternate' type='text/html' href='http://rocketscientistlog.blogspot.com/2008/12/interesting-example-on-pumping-lemma.html' title='An interesting example on the Pumping Lemma'/><author><name>Bimal</name><uri>http://www.blogger.com/profile/04593105510379142308</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_HTO3ZItlYwA/SRzJfngdo-I/AAAAAAAAABQ/0EkwIhr-VOk/S220/avatar12243_2.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_HTO3ZItlYwA/STn7Qjr8_DI/AAAAAAAAAEA/71QDTgVEUlE/s72-c/Jet_pump.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1296081044595245207.post-1801507723002686802</id><published>2008-12-04T18:11:00.000-08:00</published><updated>2008-12-05T19:34:16.551-08:00</updated><title type='text'>Building a DFSA from an NFSA</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_HTO3ZItlYwA/STnykK4vSMI/AAAAAAAAADw/-ZgD6Cx5N4w/s1600-h/Untitled.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 369px; height: 170px;" src="http://3.bp.blogspot.com/_HTO3ZItlYwA/STnykK4vSMI/AAAAAAAAADw/-ZgD6Cx5N4w/s320/Untitled.jpg" alt="" id="BLOGGER_PHOTO_ID_5276515141652793538" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Suppose we have a Non-Deterministic Finite State Automaton (NFSA) and we want to derive a DFSA from it. Lets take for example, a NFSA that accepts strings containing at least '00' or '11' and can be of even or odd length:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_HTO3ZItlYwA/STnoOzjRwoI/AAAAAAAAADg/8o9TWN6gw5Q/s1600-h/1.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 438px; height: 275px;" src="http://4.bp.blogspot.com/_HTO3ZItlYwA/STnoOzjRwoI/AAAAAAAAADg/8o9TWN6gw5Q/s320/1.JPG" alt="" id="BLOGGER_PHOTO_ID_5276503779495232130" border="0" /&gt;&lt;/a&gt;We can see that if we input strings containing at least two zeroes or two ones, those strings are accepted by this machine. To derive a DFSA from this machine, we need to draw the state transition table.&lt;br /&gt;&lt;br /&gt;First lets observe the transitions when we input 0's and 1's:&lt;br /&gt;&lt;br /&gt;If we input a 0, we remain in &lt;span style="color: rgb(0, 0, 153);"&gt;q0&lt;/span&gt; and at the same time we go to q1 therefore &lt;span style="color: rgb(0, 0, 153);"&gt;q0q1&lt;/span&gt;&lt;br /&gt;If we input a 1 we remain in&lt;span style="color: rgb(0, 0, 153);"&gt; q0&lt;/span&gt; and go to &lt;span style="color: rgb(0, 0, 153);"&gt;q3&lt;/span&gt; therefore &lt;span style="color: rgb(0, 0, 153);"&gt;q0q3&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now that we have the transitions for &lt;span style="color: rgb(0, 0, 153);"&gt;q0&lt;/span&gt;, we now have new states &lt;span style="color: rgb(0, 0, 153);"&gt;q0q1&lt;/span&gt; and &lt;span style="color: rgb(0, 0, 153);"&gt;q0q3&lt;/span&gt; and we now have to deal with them.&lt;br /&gt;&lt;br /&gt;if we are in &lt;span style="color: rgb(0, 0, 153);"&gt;q0q1&lt;/span&gt; and we input a 1, if 0 enters q0 it transits to q1 and if 0 enters q1 it transits to &lt;span style="color: rgb(0, 0, 153);"&gt;q2&lt;/span&gt;. We then get a new state &lt;span style="color: rgb(0, 0, 153);"&gt;q0q1q2&lt;/span&gt;. And when we are in &lt;span style="color: rgb(0, 0, 153);"&gt;q0q1&lt;/span&gt; and we get a 1, we remain in &lt;span style="color: rgb(0, 0, 153);"&gt;q0&lt;/span&gt; and it transits to &lt;span style="color: rgb(0, 0, 153);"&gt;q3&lt;/span&gt; as well. When we get a 1 for&lt;span style="color: rgb(0, 0, 153);"&gt; q1&lt;/span&gt;, there is no state transition for 1 so we don't move anywhere. Then we get state &lt;span style="color: rgb(0, 0, 153);"&gt;q0q3&lt;/span&gt; which we already found for the transitions for &lt;span style="color: rgb(0, 0, 153);"&gt;q0&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Now, we have to take care of &lt;span style="color: rgb(0, 0, 153);"&gt;q0q3&lt;/span&gt;. If we get a 0 we remain in &lt;span style="color: rgb(0, 0, 153);"&gt;q0&lt;/span&gt; and branch to &lt;span style="color: rgb(0, 0, 153);"&gt;q1 &lt;/span&gt;and when we get a zero for &lt;span style="color: rgb(0, 0, 153);"&gt;q3&lt;/span&gt;, we don't move anywhere since there are no state transitions described for a 0 input. Then we get state &lt;span style="color: rgb(0, 0, 153);"&gt;q0q1&lt;/span&gt;. Now when we get a 1 in &lt;span style="color: rgb(0, 0, 153);"&gt;q0&lt;/span&gt;, we remain in &lt;span style="color: rgb(0, 0, 153);"&gt;q0 &lt;/span&gt;and branch to &lt;span style="color: rgb(0, 0, 153);"&gt;q3&lt;/span&gt;. When we get a 1 for &lt;span style="color: rgb(0, 0, 153);"&gt;q3&lt;/span&gt;, we branch to &lt;span style="color: rgb(0, 0, 153);"&gt;q4&lt;/span&gt;. So we geta  new trsnaition state &lt;span style="color: rgb(0, 0, 153);"&gt;q0q3q4 &lt;/span&gt;and we have to take care, as always for every new state derived, of it and observe its transitions. If we get a 0 for &lt;span style="color: rgb(0, 0, 153);"&gt;q0q1q2 &lt;/span&gt;we get the same state transition: &lt;span style="color: rgb(0, 0, 153);"&gt;q0q1q2 &lt;/span&gt;and if we get a 1, we get &lt;span style="color: rgb(0, 0, 153);"&gt;q0q3&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Similarly if we get a 0 for &lt;span style="color: rgb(0, 0, 153);"&gt;q0q3q4 &lt;/span&gt;we get &lt;span style="color: rgb(0, 0, 153);"&gt;q0q1 &lt;/span&gt;and if we get a 1 we get &lt;span style="color: rgb(0, 0, 153);"&gt;q0q3q4 &lt;/span&gt;again. In our NFSA, &lt;span style="color: rgb(0, 0, 153);"&gt;q2 &lt;/span&gt;and &lt;span style="color: rgb(0, 0, 153);"&gt;q4 &lt;/span&gt;were final accepting states so in our DFSA, any state containing &lt;span style="color: rgb(0, 0, 153);"&gt;q2 &lt;/span&gt;or &lt;span style="color: rgb(0, 0, 153);"&gt;q4 &lt;/span&gt;will be accepting states as well. We will highlight them in red and all others in blue. So now we dont have anymore new states and we can start building our DFSA but lets build the transition table first so that we get a clearer picture of what's happening:&lt;br /&gt;&lt;br /&gt;-------------------Inputs--------------|&lt;br /&gt;---------------0-------------1---------&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;q0-----------&lt;span style="color: rgb(0, 102, 0);"&gt;q0q1---------q0q3&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;q0q1--------&lt;span style="color: rgb(0, 102, 0);"&gt;q0q1q2-------q0q3&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;q0q3--------&lt;span style="color: rgb(0, 102, 0);"&gt;q0q1---------q0q3q4&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;q0q1q2------&lt;span style="color: rgb(0, 102, 0);"&gt;q0q1q2------q0q3&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;q0q3q4------&lt;span style="color: rgb(0, 102, 0);"&gt;q0q1--------q0q3q4&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;And our DFSA looks like this:&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_HTO3ZItlYwA/STnv0DJURHI/AAAAAAAAADo/H_LBlXNN9uE/s1600-h/2.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 439px; height: 288px;" src="http://4.bp.blogspot.com/_HTO3ZItlYwA/STnv0DJURHI/AAAAAAAAADo/H_LBlXNN9uE/s320/2.JPG" alt="" id="BLOGGER_PHOTO_ID_5276512115917866098" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1296081044595245207-1801507723002686802?l=rocketscientistlog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rocketscientistlog.blogspot.com/feeds/1801507723002686802/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1296081044595245207&amp;postID=1801507723002686802' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/1801507723002686802'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/1801507723002686802'/><link rel='alternate' type='text/html' href='http://rocketscientistlog.blogspot.com/2008/12/building-dfsa-from-nfsa.html' title='Building a DFSA from an NFSA'/><author><name>Bimal</name><uri>http://www.blogger.com/profile/04593105510379142308</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_HTO3ZItlYwA/SRzJfngdo-I/AAAAAAAAABQ/0EkwIhr-VOk/S220/avatar12243_2.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_HTO3ZItlYwA/STnykK4vSMI/AAAAAAAAADw/-ZgD6Cx5N4w/s72-c/Untitled.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1296081044595245207.post-5059507810008613994</id><published>2008-12-01T20:37:00.000-08:00</published><updated>2008-12-05T20:44:25.322-08:00</updated><title type='text'>Problem 4 Assignment 3</title><content type='html'>&lt;span style="color: rgb(153, 0, 0); font-weight: bold;"&gt;Use the Cartesian Product technique from Section 7.5 of the Course Notes to construct a DFSA that accepts binary strings of odd length, and that are multiples of 5 when interpreted as base two numbers. For example, your machine should accept 101 (5 in base two), but not 1111 (15 in base two). State, without proof, the appropriate state invariants (see Section 7.3).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;My teammate and I worked on a solutiona nd came up with the following:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;The following is the state invariants of a DFSA that accepts binary strings of&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;odd length, and that are multiples of 5 when interpreted as base two numbers.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;Note: In the expression x%5 = n, n denotes the remainder of x divided by 5.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;State invariants of a DFSA that accepts binary strings of odd length.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;Q_1 = {q'_0, q'_1}.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;Sigma_1 = {0, 1}.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;s_1 = {q'_0)}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;F_1 = {q'_1}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;                       q'_0 if the length of x is even&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;P_1(x): delta*(s_1, x) = q'_1 if the length of x is odd&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;State invariants of a DFSA that accepts binary strings that are multiples &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;of 5 when interpreted as base two numbers:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;Q_2 = {q_(epsilon), q_0, q_1, q_2, q_3, q_4}.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;Sigma_2 = {0, 1}.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;s_2 = {q_(epsilon)}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;F_2 = {q_0}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;&lt;br /&gt;--------------q_(epsilon)  if x is an exmpty string&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;--------------q_0  if x%5 = 0 when interpreted as a base two number&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;--------------q_1  if x%5 = 1 when interpreted as a base two number&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;P_2(x): delta*(s_2, x) = q_2  if x%5 = 2 when interpreted as a base two number&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;--------------q_3  if x%5 = 3 when interpreted as a base two number&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;--------------q_4  if x%5 = 4 when interpreted as a base two number&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;State invariants of a DFSA that accepts binary strings of odd length, and &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;that are multiples of 5 when interpreted as base two numbers.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;Q = {q_(epsilon), q_0, q_1, q_2, q_3, q_4, q'_0, q'_1}.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;Sigma = {0, 1}.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;s = {(q_(epsilon), q'_0)}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;F = {(q_0, q'_1)}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;------------(q_(epsilon), q'_0) if x is an empty string&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;------------(q_0, q'_0) if length of x is even and x%5 = 0&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;------------(q_0, q'_1) if length of x is odd and x%5 = 0&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;------------(q_1, q'_0) if length of x is even and x%5 = 1&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;------------(q_1, q'_1) if length of x is odd and x%5 = 1&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;P(x): delta*(s, x) = (q_2, q'_0) if length of x is even and x%5 = 2&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;------------(q_2, q'_1) if length of x is odd and x%5 = 2&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;------------(q_3, q'_0) if length of x is even and x%5 = 3&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;------------(q_3, q'_1) if length of x is odd and x%5 = 3&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;------------(q_4, q'_0) if length of x is even and x%5 = 4&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 51, 51);"&gt;------------(q_4, q'_1) if length of x is odd and x%5 = 4&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1296081044595245207-5059507810008613994?l=rocketscientistlog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rocketscientistlog.blogspot.com/feeds/5059507810008613994/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1296081044595245207&amp;postID=5059507810008613994' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/5059507810008613994'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/5059507810008613994'/><link rel='alternate' type='text/html' href='http://rocketscientistlog.blogspot.com/2008/12/problem-4-assignment-3.html' title='Problem 4 Assignment 3'/><author><name>Bimal</name><uri>http://www.blogger.com/profile/04593105510379142308</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_HTO3ZItlYwA/SRzJfngdo-I/AAAAAAAAABQ/0EkwIhr-VOk/S220/avatar12243_2.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1296081044595245207.post-7425324351683866926</id><published>2008-11-26T23:27:00.000-08:00</published><updated>2008-11-26T23:50:02.940-08:00</updated><title type='text'>How to nail an assignment</title><content type='html'>&lt;a href="http://4.bp.blogspot.com/_HTO3ZItlYwA/SS5Mn1wgf6I/AAAAAAAAADQ/Sex2nfQ8ZgY/s1600-h/NAILED.jpg"&gt;&lt;img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 240px; DISPLAY: block; HEIGHT: 320px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5273236461026574242" border="0" alt="" src="http://4.bp.blogspot.com/_HTO3ZItlYwA/SS5Mn1wgf6I/AAAAAAAAADQ/Sex2nfQ8ZgY/s320/NAILED.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;span style="color:#663300;"&gt;&lt;em&gt;Image Courtesy: Jared&lt;/em&gt; &lt;em&gt;- MAT237 Assignment 2&lt;/em&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="left"&gt;I just discovered one of the major problems I had when doing assignments (Whether it was for CSC165 or CSc236 or any other subject) while working on Assignment 3. I found that I was thinking too hard and most of the time, I misread the question. While working on A3, the first thing I noticed about question 1 was a proof on an iterative program. Immediately I put in some values and calculated the output and I noticed that q returned the number of times the while loop executed and r would give the GCD() of the two numbers n,m. I wrote a 1.5 page proof on it...&lt;/div&gt;&lt;div align="left"&gt; &lt;/div&gt;&lt;div align="left"&gt;Well it sure was ugly and when I showed it to my assignment partner, he was surprised and he simply asked me: &lt;/div&gt;&lt;div align="left"&gt; &lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#006600;"&gt;"Why?"&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt; &lt;/div&gt;&lt;div align="left"&gt;I was surprised and when he told me what the function exactly does and the fact that it was already described, I felt stupid and I felt that I wasted a lot of time writing the unnecessary proof. It was so simple that after sometime I asked myself: &lt;/div&gt;&lt;div align="left"&gt; &lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#006600;"&gt;"Why didn't I think of that in the first place? and what made me think of GCD()?!!"&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#006600;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#000000;"&gt;The second mistake I made was on question 4. I actually thought we had to hand in a complete DFSA. Well it turned out that we simply had to submit the state invariants and that would give the TA's a clear idea of how the machine worked. It shows that I didnt even read the question properly and thought too much on it when it was simple. Maybe I panicked and tried designing a DFSA and used a series of inputs to test it. But when I did so, I found that I was going round and round and that trial-and-error may not be effective in solving this kind of problem.&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#000000;"&gt;I did have some problems understanding how to develop a technique to count multiples of 5. Thats when I went to Danny and he explained to me how to tackle this sort of problem. Well everything went well after that but the only thing bothering me is that I feel being careless can be very dangerous and can account for most mistakes. Simple misinterpretations can lead to disaster and working with a partner really helped me find my faults.&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt; &lt;/div&gt;&lt;div align="left"&gt;I hope any student that reads this post will learn something about my experiences and will be careful when tackling assignments. Anyways I have made it a habit now that for any subject, if I dont understand something in the assignment, I would go and ask the TA's at the help center or the instructor.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1296081044595245207-7425324351683866926?l=rocketscientistlog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rocketscientistlog.blogspot.com/feeds/7425324351683866926/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1296081044595245207&amp;postID=7425324351683866926' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/7425324351683866926'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/7425324351683866926'/><link rel='alternate' type='text/html' href='http://rocketscientistlog.blogspot.com/2008/11/how-to-nail-assignment.html' title='How to nail an assignment'/><author><name>Bimal</name><uri>http://www.blogger.com/profile/04593105510379142308</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_HTO3ZItlYwA/SRzJfngdo-I/AAAAAAAAABQ/0EkwIhr-VOk/S220/avatar12243_2.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_HTO3ZItlYwA/SS5Mn1wgf6I/AAAAAAAAADQ/Sex2nfQ8ZgY/s72-c/NAILED.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1296081044595245207.post-7673724822131689456</id><published>2008-11-25T21:48:00.000-08:00</published><updated>2008-11-25T22:23:33.361-08:00</updated><title type='text'>The Koch Curve</title><content type='html'>I know its slightly off topic but still, there is some connection to CSC236 -- Paterns. The Koch Curve is sort of a fractal, we can use the equations and change it to make interesting shapes. Here is the&lt;span style="color:#000099;"&gt; python code &lt;/span&gt;for a Koch Curve (got it from wikipedia) that will model a snowflake:&lt;br /&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#000099;"&gt;import turtle&lt;br /&gt;set="F"&lt;br /&gt;for i in range(5): set=set.replace("F","FLFRFLF")&lt;br /&gt;set=set+"R"+set+"R"+set&lt;br /&gt;turtle.down()&lt;br /&gt;for move in set:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;#Get rid of the underscores, replace by a sinlge tab as blogspot doesn't like leading blank spaces.&lt;br /&gt;____if move is "F": turtle.forward(100.0/3**i)&lt;br /&gt;____if move is "L": turtle.left(60)&lt;br /&gt;____if move is "R": turtle.right(120)&lt;br /&gt;input ()&lt;/span&gt; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;And we get this image:&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://1.bp.blogspot.com/_HTO3ZItlYwA/SSzkfH4SH1I/AAAAAAAAACY/X-wT3DypQdY/s1600-h/flake.JPG"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 310px; FLOAT: left; HEIGHT: 320px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5272840487086202706" border="0" alt="" src="http://1.bp.blogspot.com/_HTO3ZItlYwA/SSzkfH4SH1I/AAAAAAAAACY/X-wT3DypQdY/s320/flake.JPG" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Now what if we try and modify the equations?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets try:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;import turtle&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;import math&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;set="F"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;c = 2f&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;for i in range(5): set=set.replace("F","FLFRFLF")&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;set=set+"R"+set+"R"+set&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;turtle.down()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;for move in set: &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;____if move is "F": turtle.forward((100/c**i)) &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;____if move is "L": turtle.left(60/c**(c-i*i)) &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;____if move is "R": turtle.right(math.cos(45*(i/i**2))*i**4) &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;input ()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;And we get a more interesting pattern:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://4.bp.blogspot.com/_HTO3ZItlYwA/SSzlf5-eDCI/AAAAAAAAACg/LIzE2tqlMOM/s1600-h/flake2.JPG"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 318px; FLOAT: left; HEIGHT: 320px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5272841600045550626" border="0" alt="" src="http://4.bp.blogspot.com/_HTO3ZItlYwA/SSzlf5-eDCI/AAAAAAAAACg/LIzE2tqlMOM/s320/flake2.JPG" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Looks fun, now lets terribly screw it over and see what happens :)&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets try:&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;import turtle&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;import math&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;set="F"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;c = 2&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;for i in range(5): set=set.replace("F","FLFRFLF")&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;set=set+"R"+set+"R"+set&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;turtle.down()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;for move in set: &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;____if move is "F": turtle.forward((100/c**i)) &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;____if move is "L": turtle.left(60/c**(c-i*i)) &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;____if move is "R": turtle.right(math.cos(45*(i/i**2))*i**4) &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;____set=set+"L"+set+"L"+set &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;____for move in set: &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;________if move is "F": turtle.forward((100/c**i)) &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;________if move is "L": turtle.left(60/c**(c-i*i)) &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;________if move is "R": turtle.right(math.cos(45*(i/i**2))*i**4) #set=set+"R"+set+"R"+set&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#000099;"&gt;input ()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After a couple of minutes of computation, we get this:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://2.bp.blogspot.com/_HTO3ZItlYwA/SSzmM3zwepI/AAAAAAAAACo/CF959jka1l4/s1600-h/flake3.JPG"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 320px; FLOAT: left; HEIGHT: 306px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5272842372557863570" border="0" alt="" src="http://2.bp.blogspot.com/_HTO3ZItlYwA/SSzmM3zwepI/AAAAAAAAACo/CF959jka1l4/s320/flake3.JPG" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Now if we let the computation continue for a while (7mins) we get this:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://3.bp.blogspot.com/_HTO3ZItlYwA/SSzmh3pJiLI/AAAAAAAAACw/dZjmtg5ziRM/s1600-h/flake3_2.JPG"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 320px; FLOAT: left; HEIGHT: 311px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5272842733290621106" border="0" alt="" src="http://3.bp.blogspot.com/_HTO3ZItlYwA/SSzmh3pJiLI/AAAAAAAAACw/dZjmtg5ziRM/s320/flake3_2.JPG" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;And finally after 21 minutes, we get this beautiful image:&lt;/div&gt;&lt;div&gt;&lt;a href="http://1.bp.blogspot.com/_HTO3ZItlYwA/SSzqnC6OJ9I/AAAAAAAAADA/73-3W2aXuYM/s1600-h/flake3_3.JPG"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 320px; FLOAT: left; HEIGHT: 304px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5272847220260874194" border="0" alt="" src="http://1.bp.blogspot.com/_HTO3ZItlYwA/SSzqnC6OJ9I/AAAAAAAAADA/73-3W2aXuYM/s320/flake3_3.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://4.bp.blogspot.com/_HTO3ZItlYwA/SSzpTQ_kOkI/AAAAAAAAAC4/UfW07Y_S5Xw/s1600-h/flake3_3.JPG"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;God knows what it is but I like it. Now there's something worrying me a bit, its still drawing! I dont know when it will stop drawing but i think i'll let it draw till tomorrow morning and see what the final image is like.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1296081044595245207-7673724822131689456?l=rocketscientistlog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rocketscientistlog.blogspot.com/feeds/7673724822131689456/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1296081044595245207&amp;postID=7673724822131689456' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/7673724822131689456'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/7673724822131689456'/><link rel='alternate' type='text/html' href='http://rocketscientistlog.blogspot.com/2008/11/koch-curve.html' title='The Koch Curve'/><author><name>Bimal</name><uri>http://www.blogger.com/profile/04593105510379142308</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_HTO3ZItlYwA/SRzJfngdo-I/AAAAAAAAABQ/0EkwIhr-VOk/S220/avatar12243_2.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_HTO3ZItlYwA/SSzkfH4SH1I/AAAAAAAAACY/X-wT3DypQdY/s72-c/flake.JPG' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1296081044595245207.post-295943982208666040</id><published>2008-11-19T11:11:00.000-08:00</published><updated>2008-11-19T12:41:17.003-08:00</updated><title type='text'>DFSA</title><content type='html'>I had some problems understanding how to create the state transition table for a given DFSA. I knew how to form transition tables using circuits but this one is a bit different. I read this great book: "&lt;em&gt;Introduction to automata theory languages and computation 2nd edition by John E. Hopcroft, Rajeev Motwani, Jeffrey D. Ullman"&lt;/em&gt; and the bank-store-customer example they used made it clear to me.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;I used an example from the book and tried to solve it.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="color:#ff0000;"&gt;Problem 1: Design a DFSA that accepts a string that has the sequence "01" somewhere in the string&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="color:#003333;"&gt;Solution: Let L be the language where:&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="color:#003333;"&gt;{x01y where x and y are any strings of 0's and 1's}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="color:#003333;"&gt;So that means "01", "11010", "100011" ε L&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;but "100", 110000", "000", "111" is not contained in L.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="color:#003333;"&gt;Let q0 be the starting state. Now since we need to find string "01" we need a 'variable' to store the previous character so that we can compare. Let q1 be the state when we see a zero. So when we are in q1 and we see a "1", we can move to a final state q2 which is the accepting state. Now, if we are in q1 and we still encounter a "0" character, we shall stay in the same state. Similarly if we are in q0 and find a "1", its useless since the string desired should start with "01".&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="color:#003333;"&gt;Finally once we step into q2, we dont have to worry if we encounter a "0" or "1" anymore since we will remain in q2 no matter what. (By the way, if i remember, in a JK flip-flop system, this is denoted by capital X which means 'dont care' state).&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="color:#003333;"&gt;So our transition table looks as follows:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span style="color:#663300;"&gt;∂(q0, 1) = q0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color:#663300;"&gt;∂(q0, 0) = q1&lt;br /&gt;∂(q1, 0) = q1&lt;br /&gt;∂(q1, 1) = q2&lt;br /&gt;∂(q2, 0) = q2&lt;br /&gt;∂(q2, 1) = q2&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;and our state diagram looks like:&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;a href="http://1.bp.blogspot.com/_HTO3ZItlYwA/SSRway77ryI/AAAAAAAAAB4/I3potPw0tPs/s1600-h/accept_01.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5270461069582380834" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; WIDTH: 320px; CURSOR: hand; HEIGHT: 206px" alt="" src="http://1.bp.blogspot.com/_HTO3ZItlYwA/SSRway77ryI/AAAAAAAAAB4/I3potPw0tPs/s320/accept_01.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Now what if we try and modify it and say we want it to accept any string containing the string "0101"&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;Problem 2: Design a DFSA that accepts a string that has the sequence "0101" somewhere in the string&lt;/span&gt;&lt;/p&gt;&lt;p&gt;So our state transition table will change and we have to introduce new states q3 and a final accepting state q4. So if we start at q0 and find a "1", its pretty useless and we remain in the same state q0. but if we find a "0" means that it is the start of the substring we are looking for. So we jump to state q1. Now from q1, if we find a "0" as the next character, we are back to square 1 so we jump back to q0. But if we find a 1, we jump to q2. Similarly, if we get a "0" while being in state q3, its useless since its not forming the substring we are looking for and we jump back to q0. But if we find a "1", then we jump to the final accepting state q4. Once we are in state q4, we 'dont care' about the incoming characters since we have already found our substring and we remain in state q4.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;So our transition table becomes:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="color:#663300;"&gt;∂(q0, 1) = q0 ---------- ∂(q0, 0) = q1&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="color:#663300;"&gt;∂(q1, 0) = q0 ---------- ∂(q1, 1) = q2&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="color:#663300;"&gt;∂(q2, 0) = q3 ---------- ∂(q2, 1) = q0&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="color:#663300;"&gt;∂(q3, 0) = q0 ---------- ∂(q3, 1) = q4&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="color:#663300;"&gt;∂(q4, 0) = q4 ---------- ∂(q4, 1) = q4&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;And our state diagram would look like this:&lt;/p&gt;&lt;a href="http://4.bp.blogspot.com/_HTO3ZItlYwA/SSR2l9m6_YI/AAAAAAAAACA/SwJq1F70AgQ/s1600-h/accept_0101.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5270467858495372674" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; WIDTH: 320px; CURSOR: hand; HEIGHT: 258px" alt="" src="http://4.bp.blogspot.com/_HTO3ZItlYwA/SSR2l9m6_YI/AAAAAAAAACA/SwJq1F70AgQ/s320/accept_0101.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;I must thank Danny for showing us jFlap. Its a great tool to analyse state diagrams and find flaws.&lt;/p&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1296081044595245207-295943982208666040?l=rocketscientistlog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rocketscientistlog.blogspot.com/feeds/295943982208666040/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1296081044595245207&amp;postID=295943982208666040' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/295943982208666040'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/295943982208666040'/><link rel='alternate' type='text/html' href='http://rocketscientistlog.blogspot.com/2008/11/dfsa.html' title='DFSA'/><author><name>Bimal</name><uri>http://www.blogger.com/profile/04593105510379142308</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_HTO3ZItlYwA/SRzJfngdo-I/AAAAAAAAABQ/0EkwIhr-VOk/S220/avatar12243_2.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_HTO3ZItlYwA/SSRway77ryI/AAAAAAAAAB4/I3potPw0tPs/s72-c/accept_01.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1296081044595245207.post-2733381425220489479</id><published>2008-11-15T23:36:00.000-08:00</published><updated>2008-11-15T20:43:00.471-08:00</updated><title type='text'>Problem Set 5</title><content type='html'>&lt;span style="color:#cc0000;"&gt;Problem: Prove that if language L has a finite number of strings, then there is is some regular expression that denotes L.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;The first thing i noticed is that since L has a finite number of strings, there exists a Regular Expression (RE) that denotes L.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#663366;"&gt;//This roof resembles a proof we did in linear algebra (MAT223) where we had to prove that &lt;/span&gt;&lt;span style="color:#663366;"&gt;a vector v = (v1,v2,v3,..,vm) belongs to a vector space.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;Let L = {L1, L2, L3, ... ,Lm} over Ʃ&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Any substring from L can be denoted as L_a where a should at least be 1 and at most be m. Given that strings are a concatenation of characters, we can define a string:&lt;br /&gt;&lt;br /&gt;L_a = (L_a1, L_a2, L_a3, ... ,L_an), since L_a belongs to L and L_a belongs to Ʃ&lt;br /&gt;&lt;br /&gt;Then L_a1 is a regex for Ʃ ==&gt; L_a1L_a2 is also a regex;&lt;br /&gt;Then L_a1L_a2...L_an is a regex for Ʃ&lt;br /&gt;&lt;br /&gt;RE(L_a1L_a2...L_an) is a regex for Ʃ and given that L_a = (L_a1, L_a2, ... L_an), L_a defines the string.&lt;br /&gt;&lt;br /&gt;Then RE(L_a1L_a2...L_an) is the String L_a.&lt;br /&gt;&lt;br /&gt;All substrings in L have regular expressions RE_1, RE_2, RE_3, ... ,RE_n&lt;br /&gt;RE_1 is a regex for Ʃ&lt;br /&gt;(RE_1 + RE_2) is also a regex for Ʃ&lt;br /&gt;.&lt;br /&gt;. Concatenating the regexes&lt;br /&gt;.&lt;br /&gt;(RE_1 + RE_2 + RE_3 + ... + RE_n) is also a regex for Ʃ&lt;br /&gt;&lt;br /&gt;The sum of all regexes is equivalent to the language L.&lt;br /&gt;&lt;br /&gt;n&lt;br /&gt;Ʃ RE _i &lt;=&gt; (RE_1 + RE_2 + RE_3 + ... + RE_n) &lt;=&gt; L&lt;br /&gt;i=0&lt;br /&gt;&lt;br /&gt;Then if L has a finite number of strings, there exists a regular expression RE that denotes L;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1296081044595245207-2733381425220489479?l=rocketscientistlog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rocketscientistlog.blogspot.com/feeds/2733381425220489479/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1296081044595245207&amp;postID=2733381425220489479' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/2733381425220489479'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/2733381425220489479'/><link rel='alternate' type='text/html' href='http://rocketscientistlog.blogspot.com/2008/11/problem-set-5.html' title='Problem Set 5'/><author><name>Bimal</name><uri>http://www.blogger.com/profile/04593105510379142308</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_HTO3ZItlYwA/SRzJfngdo-I/AAAAAAAAABQ/0EkwIhr-VOk/S220/avatar12243_2.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1296081044595245207.post-7848385807006355902</id><published>2008-11-14T12:08:00.001-08:00</published><updated>2008-11-15T20:34:30.369-08:00</updated><title type='text'>Problem set 4</title><content type='html'>&lt;span style="color:#000000;"&gt;Problem set 4 was OK, i missed a perfect score because I did not use the induction hypothesis but here is my solution: &lt;em&gt;(Please note that blogspot does not like spaces so indentation is a problem; sorry about that)&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#cc0000;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#cc0000;"&gt;def revString(s):&lt;br /&gt;if len(s) &lt;&gt;&lt;br /&gt;&lt;span style="color:#cc0000;"&gt;else: return revString(s[1:]+s[0])&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#333300;"&gt;(1) Define our P(n)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333300;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333300;"&gt;____P(n) = /forall s /in Strings+ { if len(s) == 1: revString(s) &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333300;"&gt;____else if len(s) &gt; 1: revString(s[1:]+s[0])&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;Lets assume that the program does not take empty strings (strings with length 0) and lets denot all strings with positive lengths but Strings+. i.e: /forall x /in Strings+, len(x) &gt; 0.&lt;br /&gt;&lt;br /&gt;Proof: &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;&lt;strong&gt;&lt;em&gt;&lt;u&gt;Base case:&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;len(s) = 1 &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;&lt;br /&gt;Assume s /in Strings+ &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;{&lt;br /&gt;&lt;br /&gt;__Then s is a string with at least 1 element&lt;br /&gt;__Then len(s) = 1 and 'if' condition is satisfied&lt;br /&gt;__Then revString() executes line: 'if len(s) is less than 2: return s&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;__Then revString() is correct. &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;Then /forall s /in Strings+, len(s) &lt; 2 =""&gt; revString() is correct and our base case passes=&gt; Post condition is true.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#333300;"&gt;&lt;em&gt;&lt;strong&gt;&lt;u&gt;Inductive case:&lt;/u&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333300;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333300;"&gt;Assume n /in N #Generic natural number&lt;br /&gt;_Assume s /in Strings+&lt;br /&gt;__Assume i=0_V^n P(i) (*) &lt;em&gt;(Want to prove P(n+1))&lt;/em&gt;&lt;br /&gt;___Assume len(s) &gt;= 2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;____Then 'if' condition is false and line 'if len(s) &lt;&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;____Then line 'else: return revString(s[1:] + s[0])' is executed.&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;____Then len(s[0])=1 &amp;amp;&amp;amp; (len(s[0]) &lt;= len(s[1:]).&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;____Since len(s[0]) = 1, from our base case we know that len(s) == 1 ==&gt; return s.&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;____So return revString(s[1:]) + s[0] # *1 = s[0] part is then  true.&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;____Then revString(s[1:]) is called.&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;____Case 1: len(s[1:]) == 1:&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;_____by base case, if len(s) == 1: then return s&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;_____Then s[1:] is returned and revString() is correct. &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;_____s[1:] + s[0] means string returned is reversed ==&gt; Post condition is true.&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;____Case 2: len(s[1:]) &gt;= 2:&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;_____Then line 'else: return revString(s[1:] + s[0])' is called. &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;_____# s[0] by *1 is true&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;_____Then by (*), revString() is correct.&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;_____==&gt; Post condition is true&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#003333;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#333300;"&gt;___Then revString() is correct # &lt;em&gt;proof by cases&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333300;"&gt;__Then P(n+1)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333300;"&gt;_Then i=0_V^n P(i) =&gt; P(n+1) # intro =&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333300;"&gt;Then /forall s /in Strings+, i=0_V^n P(i) =&gt; P(n+1) #intro&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333300;"&gt;/forallThen /forall n /in N, /forall s /in Strings+, i=0_V^n P(i) =&gt; P(n+1) #intro /forall&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#333300;"&gt;&lt;br /&gt;Then Post condition holds and revString() is correct&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1296081044595245207-7848385807006355902?l=rocketscientistlog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rocketscientistlog.blogspot.com/feeds/7848385807006355902/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1296081044595245207&amp;postID=7848385807006355902' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/7848385807006355902'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/7848385807006355902'/><link rel='alternate' type='text/html' href='http://rocketscientistlog.blogspot.com/2008/11/problem-set-4.html' title='Problem set 4'/><author><name>Bimal</name><uri>http://www.blogger.com/profile/04593105510379142308</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_HTO3ZItlYwA/SRzJfngdo-I/AAAAAAAAABQ/0EkwIhr-VOk/S220/avatar12243_2.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1296081044595245207.post-772537989073932512</id><published>2008-11-13T14:49:00.002-08:00</published><updated>2008-11-13T16:32:44.005-08:00</updated><title type='text'>Test 2</title><content type='html'>&lt;a href="http://1.bp.blogspot.com/_HTO3ZItlYwA/SRzFxlUEdQI/AAAAAAAAABI/y-iFXVs_vbM/s1600-h/grave.jpg"&gt;&lt;img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 449px; DISPLAY: block; HEIGHT: 335px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5268303119737189634" border="0" alt="" src="http://1.bp.blogspot.com/_HTO3ZItlYwA/SRzFxlUEdQI/AAAAAAAAABI/y-iFXVs_vbM/s320/grave.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;Unfortunately, I had a lot of problems to look after (some related to school and some not) and I did not have enough time to study for any subject... :( As a result I did find test 2 difficult but i still gave it a shot from what I followed in lectures.&lt;br /&gt;&lt;br /&gt;The first question was a bit confusing, I think I got the wrong idea... I stated unwinding G(n) and tried to prove that T(n) can be derived and exists in G(n). I used the same unwinding technique from problem set 3 but I dont know if that was the solution to it...&lt;br /&gt;&lt;br /&gt;The second question was fine, we had done something similar in lecture and in CSC165 during summer. The third question was a bit tricky, i had trouble finding an appropriate invariant but I knew that we had to show that the loop terminates. We know that n keeps on getting smaller after each iteration and at some point, the condition would be false and the loop would terminate.&lt;br /&gt;&lt;br /&gt;To summarize, i knew part of the solutions but i'm not sure whether they are correct... I will have to catch up on the forthcoming problem sets/assignemnts and tests.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1296081044595245207-772537989073932512?l=rocketscientistlog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rocketscientistlog.blogspot.com/feeds/772537989073932512/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1296081044595245207&amp;postID=772537989073932512' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/772537989073932512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/772537989073932512'/><link rel='alternate' type='text/html' href='http://rocketscientistlog.blogspot.com/2008/11/test-2.html' title='Test 2'/><author><name>Bimal</name><uri>http://www.blogger.com/profile/04593105510379142308</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_HTO3ZItlYwA/SRzJfngdo-I/AAAAAAAAABQ/0EkwIhr-VOk/S220/avatar12243_2.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_HTO3ZItlYwA/SRzFxlUEdQI/AAAAAAAAABI/y-iFXVs_vbM/s72-c/grave.jpg' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1296081044595245207.post-1633881302449174671</id><published>2008-11-13T14:49:00.000-08:00</published><updated>2008-11-13T15:58:37.822-08:00</updated><title type='text'>State machines... we meet again</title><content type='html'>On Wednesday, we were introduced to state diagrams and how to draw a circuit from given states and state transitions... I did FSMs back home when I was studying electronics... They are very useful for designing sequential circuits using JK flip-flops. I was surprised and happy to learn that we are learning how to use state machines in CSC236 but this time, we are not lighting leds or making a vending machine... instead we are building "circuits" to analyse strings.&lt;br /&gt;&lt;br /&gt;Professor Danny used a very interesting software called jKFLAP (? not sure) where he made the circuit simply by drag-and-drop. I was also amazed that it can even test the circuit.. Now, how I wished I knew back then that there was such a software...&lt;br /&gt;&lt;br /&gt;Unfortunately because of some personal problems, I missed two lectures (the ones dealing with formal languages) but it was pretty easy to catch up on the slides. I found that the laws for the equivalent REs on the slides were similar to the laws whether a vector belongs to a vector space from linear algebra (MAT223).&lt;br /&gt;&lt;br /&gt;For example, there has to be the zero element or empty string such that:&lt;br /&gt;&lt;br /&gt;( R + Ø ) = R # Ø is the empty string.&lt;br /&gt;&lt;br /&gt;Theres only one thing I'm not too sure about and that is the "Idempotence of Kleene start" where:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;( R** = R* )&lt;br /&gt;&lt;br /&gt;I missed that lecture, unfortunately, but i'm wondering whether there is a typo and if it should have been: Kleen star (thats what google says)&lt;br /&gt;&lt;br /&gt;Wikipedia states that: &lt;a href="http://en.wikipedia.org/wiki/Kleene_star"&gt;http://en.wikipedia.org/wiki/Kleene_star&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#336666;"&gt;1) If V is a set of strings then V* is defined as the smallest &lt;/span&gt;&lt;/em&gt;&lt;a class="mw-redirect" title="Superset" href="http://en.wikipedia.org/wiki/Superset"&gt;&lt;em&gt;&lt;span style="color:#336666;"&gt;superset&lt;/span&gt;&lt;/em&gt;&lt;/a&gt;&lt;em&gt;&lt;span style="color:#336666;"&gt; of V that contains λ (the empty string) and is &lt;/span&gt;&lt;/em&gt;&lt;a title="Closure (mathematics)" href="http://en.wikipedia.org/wiki/Closure_(mathematics)"&gt;&lt;em&gt;&lt;span style="color:#336666;"&gt;closed&lt;/span&gt;&lt;/em&gt;&lt;/a&gt;&lt;em&gt;&lt;span style="color:#336666;"&gt; under the &lt;/span&gt;&lt;/em&gt;&lt;a title="Concatenation" href="http://en.wikipedia.org/wiki/Concatenation"&gt;&lt;em&gt;&lt;span style="color:#336666;"&gt;string concatenation operation&lt;/span&gt;&lt;/em&gt;&lt;/a&gt;&lt;em&gt;&lt;span style="color:#336666;"&gt;. This set can also be described as the set of strings that can be made by concatenating zero or more strings from V. &lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#336666;"&gt;2) If V is a set of symbols or characters then V* is the set of all strings over symbols in V, including the &lt;/span&gt;&lt;/em&gt;&lt;a title="Empty string" href="http://en.wikipedia.org/wiki/Empty_string"&gt;&lt;em&gt;&lt;span style="color:#336666;"&gt;empty string&lt;/span&gt;&lt;/em&gt;&lt;/a&gt;&lt;em&gt;&lt;span style="color:#336666;"&gt;.&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;So for example:&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#336666;"&gt;{'a', 'b', 'c'}* = {λ, "a", "b", "c", "aa", "ab", "ac", "ba", "bb", "bc", "ca", "cb", "cc", ...}&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Applying the Kleene star would mean it contains the zero element&lt;span style="color:#336666;"&gt; λ &lt;/span&gt;&lt;span style="color:#000000;"&gt;and all the elements &lt;/span&gt;&lt;span style="color:#336666;"&gt;'a', 'b', 'c'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;And then it would looke like:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_HTO3ZItlYwA/SRy8RJxxu6I/AAAAAAAAAA4/GFaWbWLLXe4/s1600-h/Image010.jpg"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 366px; FLOAT: left; HEIGHT: 365px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5268292666985135010" border="0" alt="" src="http://4.bp.blogspot.com/_HTO3ZItlYwA/SRy8RJxxu6I/AAAAAAAAAA4/GFaWbWLLXe4/s320/Image010.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;We can notice a pattern in the number of elements that form after every "step" as shown in the image below:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_HTO3ZItlYwA/SRy8yh6VNUI/AAAAAAAAABA/qs2tMoQRFkM/s1600-h/Image009.jpg"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 363px; FLOAT: left; HEIGHT: 307px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5268293240399148354" border="0" alt="" src="http://2.bp.blogspot.com/_HTO3ZItlYwA/SRy8yh6VNUI/AAAAAAAAABA/qs2tMoQRFkM/s320/Image009.jpg" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1296081044595245207-1633881302449174671?l=rocketscientistlog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rocketscientistlog.blogspot.com/feeds/1633881302449174671/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1296081044595245207&amp;postID=1633881302449174671' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/1633881302449174671'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/1633881302449174671'/><link rel='alternate' type='text/html' href='http://rocketscientistlog.blogspot.com/2008/11/state-machines-we-meet-again.html' title='State machines... we meet again'/><author><name>Bimal</name><uri>http://www.blogger.com/profile/04593105510379142308</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_HTO3ZItlYwA/SRzJfngdo-I/AAAAAAAAABQ/0EkwIhr-VOk/S220/avatar12243_2.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_HTO3ZItlYwA/SRy8RJxxu6I/AAAAAAAAAA4/GFaWbWLLXe4/s72-c/Image010.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1296081044595245207.post-1738697891234981226</id><published>2008-10-22T22:09:00.001-07:00</published><updated>2008-10-22T22:22:20.640-07:00</updated><title type='text'>Problem Set 3</title><content type='html'>One thing I noticed with CSC236 is that you cannot sit down and try and get the answer in a  couple of hours... I was actually confused by the notion of a closed form. I wondered how to use repeated substitution, I thought hard about it but couldn't get a hint. Then I said to myself, "lets take a break!"&lt;br /&gt;&lt;br /&gt;So I played a bit of unreal tournament 3 online with my friends while a small part of my brain was concentrating on the problem set. Suddenly out of the blue, I shouted "AHA!". All of a sudden, at random, a clue came to my head. I immediately exited the game and went back to the problem set.&lt;br /&gt;&lt;br /&gt;After playing around with the numbers and continuosly re substituting onto itself, I came up with a sequence which could be easily written with summation symbols etc. The sequence was :&lt;br /&gt;&lt;br /&gt;3^3 + 3^2 + 3^1 + ... I played around with the summation and found that it actually converged to P(n+1). That was the clue! After re arranging and some factorisation, I spent about half an hour trial-and-error and found the final equation that would be a closed form for the problem!&lt;br /&gt;&lt;br /&gt;Then I said to myself, frequent breaks are really useful! Random hints might fall in when the brain is not fully concentrating on the subject. The human brain surprises us all the time...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1296081044595245207-1738697891234981226?l=rocketscientistlog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rocketscientistlog.blogspot.com/feeds/1738697891234981226/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1296081044595245207&amp;postID=1738697891234981226' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/1738697891234981226'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/1738697891234981226'/><link rel='alternate' type='text/html' href='http://rocketscientistlog.blogspot.com/2008/10/problem-set-3.html' title='Problem Set 3'/><author><name>Bimal</name><uri>http://www.blogger.com/profile/04593105510379142308</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_HTO3ZItlYwA/SRzJfngdo-I/AAAAAAAAABQ/0EkwIhr-VOk/S220/avatar12243_2.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1296081044595245207.post-5751037052653867197</id><published>2008-09-30T20:49:00.000-07:00</published><updated>2008-10-01T21:30:45.681-07:00</updated><title type='text'>A mathematical problem</title><content type='html'>As a scientist, although I got a transfer credit for the first year calculus, I dont know much about real world calculus! And i am happy that I dont know anything much about it because thats the best result you can get: Know Nothing! This proves that there still much to learn ahead and excitement to come!&lt;br /&gt;&lt;br /&gt;Here's the problem that got me stuck for ages:&lt;br /&gt;&lt;br /&gt;My friend owns a roller shade company and he need to make boxes for them. He makes the barrels himself and they come in various diameters. Now he has to roll a shade of length L onto in and after each turn, the total diameter increases exponentially (because it is a spiral and spirals grow exponentially, not linearly). Then we can obtain the total diameter of the barrel and the shade rolled onto. Once we have that, we can order boxes of correct dimensions.&lt;br /&gt;&lt;br /&gt;Here is a picture of the situation:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5252038042136504770" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_LJK82NPcoe4/SOL8xdhiacI/AAAAAAAAAN0/g9hO2zBIEfA/s400/barrel_problem.jpg" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now, the only way i tried to solve this problem is by rolling and counting the number of turns made first.&lt;/p&gt;&lt;p&gt;&lt;u&gt;So lets denote:&lt;/u&gt;&lt;/p&gt;&lt;p&gt;Length of shade: L&lt;/p&gt;&lt;p&gt;Width of shade: W&lt;/p&gt;&lt;p&gt;Thickness of shade: h&lt;/p&gt;&lt;p&gt;diameter of barrel : D&lt;/p&gt;&lt;p&gt;3.1412 : pi&lt;/p&gt;&lt;p&gt;n = number of rolls&lt;/p&gt;&lt;p&gt;&lt;u&gt;&lt;/u&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Now lets roll the first turn: we can do that by subtracting the circumference of the diameter++ from the sheet of shade.&lt;/p&gt;&lt;p&gt;n = 1 =&gt; So 1st turn: [L - pi(D)] cm left to roll onto&lt;/p&gt;&lt;p&gt;n = 2 =&gt; 2nd turn: [(L - pi(D)) - pi(D+h)] &lt;/p&gt;&lt;p&gt;&lt;=&gt; [(L - pi(2D + h)] cm left to roll onto. pi(D+h) means that the new circumference has increased by the thickness of the shade, which also varies in size.&lt;/p&gt;&lt;p&gt;n = 3 =&gt; 3rd turn: [(L - pi(D)) - pi(D+h) - pi(D+2h)] &lt;/p&gt;&lt;p&gt;&lt;=&gt; [(L - pi(D)) - pi((D+h) + (D+2h))]&lt;/p&gt;&lt;p&gt;&lt;=&gt; [(L - pi(D)) - pi(2D + 3h)] &lt;/p&gt;&lt;p&gt;&lt;=&gt; [(L - pi(3D + 3h)] cm left to roll onto.&lt;/p&gt;&lt;p&gt;n = 4 =&gt; 4th turn yields: [L - pi(4D + 6h)] cm left to roll onto&lt;/p&gt;&lt;p&gt;n = 5 =&gt; 5th roll yields: [L - pi(5D+10h)] cm left to roll onto&lt;/p&gt;&lt;p&gt;n = 6 =&gt; 6th roll yields: [L - pi(6D + 15h)] cm left to roll onto&lt;/p&gt;&lt;p&gt;... nth roll&lt;/p&gt;&lt;p&gt;So for n&gt;1 rolls:&lt;/p&gt;&lt;p&gt;We can observe a pattern. If we look at the last digit in each equation, we see 1, 3, 6, 10, 15, ...&lt;/p&gt;&lt;p&gt;And this pattern is best described as triangular numbers: &lt;a href="http://en.wikipedia.org/wiki/Triangular_numbers"&gt;http://en.wikipedia.org/wiki/Triangular_numbers&lt;/a&gt;&lt;/p&gt;&lt;p&gt;So we can actually write a program that can generate a list/range of numbers from&lt;/p&gt;&lt;p&gt;2 -&gt; m # {2,3,4,5,......,(m-1)}, lets call this list m&lt;/p&gt;&lt;p&gt;then we create a regular list starting from 1 -&gt; p # {1,2,3,4,.........,p}, lets call this list p&lt;/p&gt;&lt;p&gt;Assume m and p are natural numbers. Then we add each number in a specific way:&lt;/p&gt;&lt;p&gt;&lt;em&gt;&lt;strong&gt;for i in range(0,m):&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&lt;strong&gt;p[i+1] = p[i] + m[i]&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;Then list p will have elements: {1,3,6,10,15,...}&lt;/p&gt;&lt;p&gt;and save it in an ordered list named Q. Then, if we can start with our base case, n = 1, we can substitute each number from this ordered list to the last digit in our n+1 equation corresponding to the proper index. So we will have an ordered list Q of triangular numbers. That would solve the problem creating the pattern.&lt;/p&gt;&lt;p&gt;Now for the coefficient of D, we can see a similar pattern but it seems to be related to the number of rolls. So for every new equation for (n+1) turns, we can form a formula:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Assume that n &gt; 0:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Length remaining to roll = &lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;if n = 1, [ ( L - pi( (n)D ) ] &lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;else if n &gt; 1, [ ( L - pi( (n)D + Q[n-2]*h ) ) ]&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Q[n-2]&lt;/em&gt;&lt;/strong&gt; indicates the index of the element in Q&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;So now we have a general formula to calculate the number of turns possible given a length of a shade and the diameter of the barrel. We dont care much about the width of the barrel and shade as it does not affect our calculations.&lt;/p&gt;&lt;p&gt;Now since we can predict the length of any nth roll, we can write some code to check if the length remaining is smaller than the length required for the next (n+1) roll and if it is smaller, we can stop there and return '&lt;strong&gt;N&lt;/strong&gt;', the number of rolls possible.&lt;/p&gt;&lt;p&gt;We now have the number of turns possible but I still cannot find a way to find the diameter at that Nth point. I am still working on it but if anyone has any hints, please let me know, that would be great!&lt;/p&gt;&lt;p&gt;I hope you enjoyed this problem as much as I did.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1296081044595245207-5751037052653867197?l=rocketscientistlog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rocketscientistlog.blogspot.com/feeds/5751037052653867197/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1296081044595245207&amp;postID=5751037052653867197' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/5751037052653867197'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/5751037052653867197'/><link rel='alternate' type='text/html' href='http://rocketscientistlog.blogspot.com/2008/09/mathematical-problem.html' title='A mathematical problem'/><author><name>Bimal</name><uri>http://www.blogger.com/profile/04593105510379142308</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_HTO3ZItlYwA/SRzJfngdo-I/AAAAAAAAABQ/0EkwIhr-VOk/S220/avatar12243_2.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_LJK82NPcoe4/SOL8xdhiacI/AAAAAAAAAN0/g9hO2zBIEfA/s72-c/barrel_problem.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1296081044595245207.post-601383414016544969</id><published>2008-09-30T19:49:00.000-07:00</published><updated>2008-09-30T20:40:50.933-07:00</updated><title type='text'>Assignment 1 and the symmetric pattern</title><content type='html'>For assignment 1, problem 2, i noticed something fishy... Something playing around with my mind..&lt;br /&gt;&lt;br /&gt;I could sense a pattern going on but couldn't trace it down. The problem is that we are given 2 meals, L and S. A suitable cycle for the meals in which the meal for the next day differs by exactly one would be: {}, {S}, [L,S}, {L},&lt;br /&gt;&lt;br /&gt;So when we add a new meal and manually compute the set, we get this:&lt;br /&gt;&lt;br /&gt;{}, {S}, [L,S}, {L}, {L,P}, [L,S,P}, {S,P}, {P} which is correct.&lt;br /&gt;&lt;br /&gt;But I noticed something interesting. Starting from the first element {}, lets make a copy of this list. If we take the region after the last element and before the "," [i.e: {}, {S}, [L,S}, {L} (THIS REGION HERE) ,] and use it as a vertical symmetry axis, we can rotate the list by 180 degrees and we would obtain an image of our original list.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5252017182984011650" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_HTO3ZItlYwA/SOLpzTICf4I/AAAAAAAAAAo/UDVRefcLHmA/s320/pic_1+copy.jpg" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;Then if we add the new meal 'P' in each set in our newly rotated list, we get this:&lt;br /&gt;{}, {S}, [L,S}, {L}, {L,P}, [L,S,P}, {S,P}, {P}&lt;br /&gt;&lt;br /&gt;And this corresponds to what we would get by manually verifying it:&lt;br /&gt;{}, {S}, [L,S}, {L}, {L,P}, [L,S,P}, {S,P}, {P}&lt;br /&gt;&lt;br /&gt;So, could there be a pattern? Lets check by adding a new meal 'Q'. We repeat the same stesp. Lets create an imaginary vertical symmetry axis at the point labelled 'here': ...{P} (HERE) ,&lt;br /&gt;&lt;br /&gt;Lets make a copy of the list and rotate it. We would get this:&lt;br /&gt;{}, {S}, {L,S}, {L}, {L,P}, {L,S,P}, {S,P}, {P} ( Symmetry Axis here) , {P}, {S,P}, {L,S,P}, {L,P}, {L}, {L,S}, {S}, {}&lt;br /&gt;&lt;br /&gt;So if we add the new meal 'Q' in each set of our newly rotated list, we would get:&lt;br /&gt;{}, {S}, {L,S}, {L}, {L,P}, {L,S,P}, {S,P}, {P}, {P,Q}, {S,P,Q}, {L,S,P,Q}, {L,P,Q}, {L,Q}, {L,S,Q}, {S,Q}, {Q}&lt;br /&gt;&lt;br /&gt;And if we verify manually, we would get the same! So there exists a pattern to solve this question! In a programming language, we can achieve this by copying the list, reversing the elements, add the new element in each array, appending the modified copy to our original list and voila!&lt;br /&gt;&lt;br /&gt;Maybe the law of supersymmetry in physics (which states that for any object, there exists its symmetric twin somewhere else in the universe) could explain this but this technique works for any length of the list!&lt;br /&gt;&lt;br /&gt;Now we can also observe that the length of the list is equal to 2 ^ (number of meals)&lt;br /&gt;Inductively we can prove that when new meal is added, the length of the new list of meals is double that of the original list.&lt;br /&gt;&lt;br /&gt;n&gt;2&lt;br /&gt;&lt;br /&gt;We need to rpove P(n) =&gt; P(n+1)&lt;br /&gt;&lt;br /&gt;&lt;=&gt; 2^(n+1) = 2^n x 2^1&lt;br /&gt;&lt;=&gt; P(n) x 2 # Which means P(n) was actually 2^n&lt;br /&gt;&lt;br /&gt;So inductively we can show that the length of the new list is double the size of the original list.&lt;br /&gt;&lt;br /&gt;Hope it helped!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1296081044595245207-601383414016544969?l=rocketscientistlog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rocketscientistlog.blogspot.com/feeds/601383414016544969/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1296081044595245207&amp;postID=601383414016544969' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/601383414016544969'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/601383414016544969'/><link rel='alternate' type='text/html' href='http://rocketscientistlog.blogspot.com/2008/09/assignment-1-and-symmetric-pattern.html' title='Assignment 1 and the symmetric pattern'/><author><name>Bimal</name><uri>http://www.blogger.com/profile/04593105510379142308</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_HTO3ZItlYwA/SRzJfngdo-I/AAAAAAAAABQ/0EkwIhr-VOk/S220/avatar12243_2.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_HTO3ZItlYwA/SOLpzTICf4I/AAAAAAAAAAo/UDVRefcLHmA/s72-c/pic_1+copy.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1296081044595245207.post-6042211818878742210</id><published>2008-09-30T19:26:00.000-07:00</published><updated>2008-09-30T19:38:21.075-07:00</updated><title type='text'>First</title><content type='html'>Welcome everybody to my blog! This is my first post and I will be posting very frequently about my experience with CSc236. Just as a short recap, I had a nightmarish time with CSC165 - Maths reasoning for computer scientists. I cannot understand why but i feel that I like CSC236! Its more like applying the proof techniques in CSC165 to real world problems. Well, we will see how it goes... Stay tuned for more posts.&lt;br /&gt;&lt;br /&gt;-Bimal&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1296081044595245207-6042211818878742210?l=rocketscientistlog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rocketscientistlog.blogspot.com/feeds/6042211818878742210/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1296081044595245207&amp;postID=6042211818878742210' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/6042211818878742210'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1296081044595245207/posts/default/6042211818878742210'/><link rel='alternate' type='text/html' href='http://rocketscientistlog.blogspot.com/2008/09/first.html' title='First'/><author><name>Bimal</name><uri>http://www.blogger.com/profile/04593105510379142308</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_HTO3ZItlYwA/SRzJfngdo-I/AAAAAAAAABQ/0EkwIhr-VOk/S220/avatar12243_2.gif'/></author><thr:total>0</thr:total></entry></feed>
