Saturday, August 30, 2008

'Teeka' celebrated


This is a nice pic of my chachaji and buaji on the occasion of 'teeka'. Well, that was a great occasion and with chachaji around, its always fun.
Posted by Picasa

Wednesday, August 20, 2008

Realisation of quotidian schedule

Well, as always just a confession - observing that all the movies are done and I really don't want to repeat a certain movie 'n' number of times, I feel that my quotidian routine for the past 2 years since I have bought laptop have gone always for 2-4 movies and little here and little there. Now, I have ample time to do anything but movies, but I am unable to concentrate or even think about doing anything constructive. So, I thought of writing diary just to do something constructive. Well, best of luck to me.

Friday, May 2, 2008

Serious Problem of compromisation

Well, it could be easily seen by my response to the preparation of EEL205. I slept at 1:15 a.m. and woke up at 6 a.m. I started feeling 'morning sickness' . I don't know I just feel nausea tic in the morning and it's not psychological, it's for real. "Muski" was awake at 6 in the morning. I must say he does not compromise in his preparation. He does not sleep till he is fully prepared. Hey and guess what......even after watching such a great effort, I slept from 7 to 10.

I realise that I just prepare in such a way that it's always (20-50)% left. Now my dhd exam is tomorrow and I am listening to songs and writing this diary. I don't know somewhere in the heart of my brain, I am afraid because I feel I am unable to understand these abstract things and I just don't try it. I must confess that I have never made a serious attempt to understand my courses ever. I just take the 'sharan' of Vaneet Dadra, Sumeet Singh, or Rahul Goyal. Just never took things of my own. I take their understanding of the subject and it doesn't help. In examination or any test, things which are your own can help you.

Now, I have loads to do and from the heart of my mind, I do wanna try to understand and improve my performance in my own eyes. (* Note: I got 15/30 in minor1 and 9/30 in minor2 and missed two of its quizzes. and response to it is chill.....which I still think its right/ok. *)

Thursday, May 1, 2008

VMC re-membrance: PHL exam held today

Today was our PHL120 exam and again did many silly mistakes whch made me remember the wording of "physics waale bhaiyya" in vmc: " Jab tak tum poori tayaari nahi kar ke jayoge, tum apne aap ko evaluate nahi kar payoge." thode marks ka kiya nahi tha, thode marks silly mistake ke karan chale gaye, kuch idhar kuch udhar. Something is wrong with the commitment. There is a lot of compromise in my study level, in my expectation of marks. I feel I am doing a lot of compromise which I should not. As said by some great person- " Ek baar compromise karna shuru kar diya, to us dheelepan ki aadat pad jaati hai, aur jo kaam ek baar reh jaye, woh saala waise ka waisa hi reh jaata hai."




Something is wrong somewhere. Don't try to recognise it. Just do your deeds and don't compromise on your level of doing it. [Well... this one is said by me.]

Monday, April 28, 2008

Today was the first exam of major:

I talked to Nikhil after the exams, he suggested that we should study at least one-fourth of the doctors as I had a plan of watching any damn movie today and almost all the aiimsonians seem to study for their final 21 day exams which will be a month after ours. So they don't do anything except study in these so many days. And we, being IITians watch daily cricket T20 matches even in the time of majors. ( Not much of irony ).

Today I also started using Picasa Web Albums, kind of cool, these google products take account of whole of your and seem to become part of my life.

Thursday, April 24, 2008

Wake me up When semester ends.....

hi..... exams going on ....
25th April , 11:55 p.m. - Started watching Hustle, season 2 , episode 1 watched upto 5th episode each being 50 min. ( without cut short editing). just thought I would like to know later in my life.

I would like to share my attendence of the courses which I was supposedly doing in 4th semester.

1. MAL124 : I think I attended 3 or 4 classes but I may be wrong. It could have been less.

2. PHL120 : fighter prof. tha yaar. (50-60 %) attendance khud hi lagayi hai. He is threatening to fail at below 75% attendance.

3. EEL205 : minor 1 ke baad ek class lagayi hai. do quiz miss kiye hain aur ek quiz diya hai: only class I attended after minor 1 or minor 2. (luckily question solve ho gaya.)

4. DHD: CSL316 : bahut hi chill liya hai... agar gaye to suna nahi aur kam hi gaye. Lab tak udaaye hain. Lets see what will be the marks in practical. Minors mein bilkul fight nahi mari.

5. CSL302: PL: Attended almost every class. Assignments se seekhne ko mila. Assignments pooch-pooch ke banayi hain. Vaneet aur muski ko saath mein bitha ke banayi hain. Minor 2 aise hi marwa li.

6.HUL237: Attendance bahut kam hai though there are 10 marks on it. Lets see. Is course se civil waalon ka level pata chal, how much they fraud in a course and how much they tell they can.

All the attendance gap in MAL124 and PHL120 has been filled by Mohit Kataria, a great person always ready to do selfless deeds.

Sunday, April 20, 2008

20th April 2008 : House day of Shivalik Hostel

A great house day : promising touch by the freshers. They did it all without any help from seniors, all the choreo, dance steps, deco and any kind of other stuff. Fourth yearites as usual did a 'masala dance' on various songs in Punjabi, Haryani, English and Hindi. There was a air of success, somewhere inspiration, some frustration(hidden), and a very common feeling of "Do you have a girlfriend?" , "How come you have a girlfriend?" and other common questions about "girls stuff".
Frankly speaking I, myself have a very peculiar perspective for girlfriends. According to me, even if I have a girlfriend(hurray) and she is not interested in meeting your friends, then I won't invite her or say take her to the house day. Especially, if somehow you get to house day or any such party of IIT hostel, NEVER take DINNER there. Don't ruin your night by watching such a pathetic hunger of highly educated and talented young people.
Moreover, I guess there will a lot of awkward feeling when you are roaming with your girlfriend and almost all your friends and other students are staring at her(whatever she is, however she is, We give chance to Every girl). ANd you can't actually blame them because you were in that squad for many many years.
Note: The quality of food is better than normal mess food.

(* Enough for today *) But there is a lot more.

Amitav Ghosh : 'The Shadow Lines' ---- Term paper Tradegy -----

HUL237 - Contemporary Fiction:

17th of April was decided to be 'deadline' for the submission of term paper of any of these books :
1. Arthur C Clarke, Rendezvous with Rama, 1972
2. Yaan Martel, Life of Pi,2001
3. Coetzee, Disgrace,1999
4. Isaac Asimov, Forward the Foundation, 1994
5. Douglas Adams, The Hitchhiker's Guide to the galaxy, 2004
6. Chuck Palaniuk, Fight Club, 1996 : also a great movie on this novel featured by the superb acting of 'Brad Pitt'. No comments on the story - kind of arbit.
7. Khaled Hosseni, The Kiterunner,2003. Most of my friends preferred this because of nice picturisation of the novel in the movie.
8. Dorris Lessing, The Golden Notebook, 1962.
9. Shyam Selvadurai, The Funny boy, 1994.
10. Amitav Ghosh, The Shadow Lines,1998.
11. R.K.Narayan, The Guide, 1958.
12. Arundhati Roy, The God of Small Things,1997.
13. Amitav Ghosh, The Glass Palace, 2000.
14. Kazuo Ishiguro, Never Let Me Go, 2005.

Course Books: KAzuo Ishiguro's 'A Pale View of Hils' and Jhumpa Lahiri's "Interpreter of Maladies"

I would like to confess that most of the content of my term paper on Amitav Ghosh's "The Shadow Lines" is from the intenet inspite of the prior warning of copying from the internet or any other source. Yaar par mein kya karta, kuchch bhi soojhta hi nahi us tarah. An incident which can be normally explained in 10 lines , I do it 2 lines whereas Madame wants it to explain in your own terms in about 100 lines which just seems almost impossible without serious trying and knowledge.
But when I think of myself improving my English skills, I lost a great opportunity and I am wholly responsible for it.
" From now on, I will write book review of any book which I write . I think its more useful than using that time to read another novel.

Let me explian the current state of my term paper of "The Shadow Lines" right now: The narrator has not revealed his identity. He is fond of his second uncle, Tridib who tells him stories and believes passionately that ' a person can't feel the place, if he does not have a picture of his own of that very place" : something like that. The narrator Grandmother is a great character- mixture of many traits - vigilant, passion for freedom , hates Western culture,















Here is my term paper which I submitted:

BOOK REVIEW
Novel : The Shadow Lines
AUTHOR : Amitav Ghosh
Awards : winner of the Sahitya Akademi Award (1989).
Bibliography : The Shadow Lines(novel), Wikipedia(Internet).
Main Characters : Mayadebi, Tridib, Ila, May, Narrator, Nick, grandmother.

POLITICAL SCENERIO :
The novel is set against the backdrop of historical events:
1.Swadeshi movement
2.Second World War
3.Partition of Country
4.Communal riots of 1963-64 in Dhaka and Calcutta


CHARACTERS ANALYSIS :
The characters in this novel – except that of Tridib – are realistically portrayed and are not larger than life. Each one is portrayed with all the weaknesses that make them endearing. Each one is believable . But Tridib does not seem to belong to this world. He comes across as a ‘seer’, someone endowed with extra-sensory and extra-visionary abilities.

1. Narrator : The protagonist is a middle class boy who grows up in a middle class family. He is sexually attaracted to Ila but he never tells her. He is very close to his grandmother and knows about her more than anyone. As a young boy he seldom gets to travel farther than his school. And yet his world spans far beyond, across continents. He paints up this world, rather vividly, borrowing colours from others. He uses Tridib’s eyes to view a certain family in London, their house, the streets, the panic of war. He uses his grandmother’s eyes to see her life in Dhaka as a young girl, her uncle and cousins, the other side of the big house where everything was upside down. He uses his cousin’s eyes to view different parts of the world where she travelled, her aspirations for belonging, her heartaches caused by a reality as different from her dreams as she and her background was from those with whom she lived in those foreign lands.

2. Tridib : He was the son of Mayadebi, and so by relation he was the second uncle of Narrator. He is well-travelled but he prefers to live his life in Calcutta, where he works at a Ph.D. in archaeology. For Tha'mma, he is very irresponsible person who wastes his life wandering across the streets but narrator loves to listen to Trideb. He passionately believes that 'a place does not merely exist, that it has to be invented in one's imagination' . He was killed by Muslim mobs in communal riots of 1963-64 in Dhaka.

3. Grandmother of Narrator (Tha'mma) : She is the headmistress of girls school in Calcutta. She is very strict, disciplined, hardworking, mentally strong and patient lady. Time is very precious for her. According to her, time is a toothbrush; it goes mouldy if it isn’t used. She had been awarded a Bachelor’s degree in history by Dhaka University. She has a dreadful past. She was married to an engineer with the railways, in Burma. In 1935, her husband passed away.

4. Ila : She is the cousin of narrator. She lives in Stockwell, London. She is very good looking, and broad minded. She wants to be free. According to her, the constraints on women in India made their life horrible. That’s why she lived in London, so that she could do whatever she wants. She marries Nick, an Englishman, buys a home, finds a job, tries to settle down but without success.

5. May : She is the daughter of Prices family, who are relatives of Tridib’s family. Tridib was in love with her. She is committed to a purposeful and principled social life. She is kind-hearted and works for society by collecting funds for famine relief in Africa, and other social services.

6. Nick : He is a good looking blonde having long hairs and wants to become a Chartered Accountant. As May says to narrator: 'He is different, he is not like us'. He lacks the sensibility and moral values of a normal human being. He marries Ila and is cheating on her as he admits sleeping with other women.

Apart from all these characters, there is a fantasized character "Magda", Ila's fantasy child whom she acknoledges when she was playing 'houses' with the narrator. Magda is blue-eyed and blonde and has very bright and beautiful hairs. This shows that Ila fantasized to marry an Englishman from her childhood.

TITLE OF THE BOOK - "The Shadow lines" :
The shadow lines that the title proclaims to be the theme of the novel are very shadowy themselves. We never get to see them as they are and there is never a mention of these lines anywhere in the novel. The interpretation of the meaning of the shadow lines is left to the reader. Now that points to an interpretation itself as the shadow lines could mean something that is insubstantial and therefore, its existence is doubtful. Another interpretation of the shadow lines could be that they are lines that change positions with the gaze or perspective. Yet another interpretation of the shadow lines could be that they are just a pale imitation of reality.
What are lines associated with? Lines could be boundaries or they could just signify the linearity of relationships. Lines are also used to measuring and dividing length. They are also constructs created by humans and are thus, unreal. Shadow could be referring to the physical shadow that light casts when obstructed by objects. It could also mean protection or security. It could also mean an inseparable companion as a shadow always follows some object or a pale representation of the object. Together, ’shadow lines’ could mean insubstantial boundaries or boundaries that provide a sense of false security or shifting boundaries or boundaries that humans carry everywhere .
The lines are just human constructs that have no real significance. Grandmother asking whether she would be able to see lines on the land separating India and East Pakistan, and the narrator’s father saying that the boundaries start at the airports itself and grandmother trying to find the boundaries in the Dhaka airport. Even though boundaries separate them, grandmother reveals that Dhaka and Calcutta are very similar to each other.
These boundaries are shown to be very flimsy and perspective oriented. The categorisation is based on the perspective of an individual. The best example from the book of this perspective-oriented classification is the way many people look at the riots that killed Tridib. For the narrator’s father, it was an accident, for May it was a sacrifice, for Robi it was a nightmare. An event has been shown as categorised in several ways by different people. They are correct in some way or another but for the people who classify them so, they are experienced in so varied ways and hence, the difference in the classification.
Boundaries demarcate and classify. Man is inherently programmed to classify and form groups of all that he samples by his senses. These classification are generally based on adjectives that are dependent like good, bad, warm, cold, etc. Shadows are known to change shape and size with changing light positions. The light positions could be considered as the perspective of a person and the shadows as the lines that classify. Hence, the perspective determines the classification and as shadow lines demarcate them, they are unreliable.

Author’s way of Presenting Story :

The narrator, Indian born and English educated, traces events back and forth in time, from the outbreak of World War II to the late twentieth century, through years of Bengali partition and violence, observing the ways in which political events invade private lives. Amitav Ghosh refrains from giving him a name. The novel brings into perpestive the fact that one cannot attribute absolute identities to things or events that can’t be 'absolutely' good or bad. The knack of the narrator to go to places hitherto unseen in a manner as if he had visited them before surprises us just as it surprises Nick and Ila. The narrative is simple. It flows smoothly, back and forth between times, places and characters. The use of the first person and therefore a reflective style is very effectively used by Ghosh to say much more than the written word.


PLOT SUMMARY :

It is a rather straightforward story, which follows the life of a young boy growing up in Calcutta and later on in Delhi and London. His family – the Datta Chaudharis - and the Prices in London are linked by the friendship between their respective patriarchs – Justice Dattachaudhari and Alan Tresawsen. The narrator adores Tridib because of his tremendous knowledge and his perspective of the incidents and places. Tha'mma thinks that Tridib is type of person who seems 'determined to waste his life in idle self-indulgence', one who refuses to use his family connections to establish a career. Unlike his grandmother, the narrator loves listening to Tridib. For the narrator, Tridib's lore is very different from the collection of facts and figures. The narrator is sexually attaracted to Ila but his feelings are passive. He never expresses his feelings to her afraid to lose the relation that exist between them. But one day he expresses his feelings when she was changing clothes in front of him being unaware of his feelings. She feels sorry for him. Tha'mma does not like Ila. 'Why do you always speak for that whore' - She doesn't like her grandson to support her. Tha'mma has a dreadful past and wants to reunite her family and goes to Dhaka to bring back her uncle. Tridib is in love with May and sacrificed his life to rescue her from Muslim mobs in the communal riots of 1963-64 in Dhaka.


CRITICAL ANALYSIS :
The Shadow lines, a novel written by Amitav Ghosh. It was the second novel of him. Language, structure and spirit have coalesced to produce a work of lyrical beauty.
Ghosh’s prose is evocative and realist. The Shadow Lines is written effortlessly and without the baggage of ‘magical realism’.This novel is enigmatically written with a blend of fiction and non-fiction events.Ghosh completely outstands in his language, way of writing, in different moves he took while the story was proceeding. The most difficult part of a book is to show flashback without explicitly taking off reader’s interest and attention from his reading flow. And narrator completely showed his supremacy in this regard. His resonant use of language completely spell bound the readers. Girish Karnad rightly said about him, “Ghosh uses to great effect a matrix of multiple points of view in which memory, mythology and history freely interpenetrate…A delight to read”.
Amitav Ghosh refrains from giving him a name. The novel brings into perpestive the fact that one cannot attribute absolute identities to things or events that can’t be 'absolutely' good or bad.The narrator is a young boy growing up in Calcutta and later on in Delhi and London. As a young boy, he seldom gets to travel farther than his school. And yet his world spans far beyond, across continents. He paints up this world, rather vividly, borrowing colours from others. He uses Tridib’s eyes to view a certain family in London, their house, the streets, the panic of war. He uses his grandmother’s eyes to see her life in Dhaka as a young girl, her uncle and cousins, the other side of the big house where everything was upside down. He uses his cousin’s eyes to view different parts of the world where she travelled, her aspirations for belonging, her heartaches caused by a reality as different from her dreams as she and her background was from those with whom she lived in those foreign lands.
There are two parts in the novel- 'Gong Away' and 'Coming Home'. 'Going away' shows the narrator who has heard about England from a cousin who lived there for sometime and his own discovery of the country when he visits it later in life. 'Coming Home' shows his grandmother visiting her old home in Dhaka, her nostalgia and the discovery of alienation from what she had remembered before Dhaka became part of Pakistan.
His grandmother is passionate for freedom. When she was young during the Swadeshi movement, she wanted to join it and could do anything for her country. She says- 'I would have killed him. It was for our freedom' . She doesn't like western culture at all and never liked Ila. When narrator argues with her about Ila, telling her that Ila lives in London not because of the lure of money or commodities, but for freedom. Ila believes that there are lot of constraints on women in Indian culture. There are lot of decisions which women have to take because of the pressure of the society and culture. Grandmother's response to this is- 'It is not freedom she wants, she wants to be let alone to do as she pleases; that's all any whore would want.' . She doesn't even hasitate to call her a whore.

The narrator grandmother's nationalist faiths fail her because she comes to realize that borders have a tenuous existence, and that not even a history of bloodshed can make them real nad impermeable. Lines on the map are the handiwork of administrators and cartographers. In 1964, as she plans to fly to Dhaka, she wonders if she would be able to see the border between India and East-Pakistan from the plane. When her son laughs at her, she replies- 'Where's the difference then? And if there is no difference, both sides will be the same; it will be just like it used to be before' . The grandmother has a typical state dominated view about nationalism,what she is unable to realize that one can be unsafe even in one’s own country.

May's humanitarianism forces Tridib to stop the car and help the dog lying half-dead on the highway. That same instinct of May led Tridib to lose his life when they were caught in the communal riots of 1964 in Dhaka. She went out of the car trying to save her uncle but Tridib stops her and sacrifices his own life. Torn by her memories, May believes for a long time that she killed Tridib, only at the end, she seems to calm herself and get rid of her torturing guilt when she says- ' He gave himself up, it was a sacrifice. I know I can't understand, I know I mustn't try, for any real sacrifice is a mystery.' .
The title "The Shadow lines" is itself peculiar and mysterious. There is no mention of it even a single time. The shadow lines could be boundaries that humans create and which are insubstantial. The mental boundaries present in the minds of people that limit their vision to what is visible is transcended by Tridib and the narrator by their imaginations. These mental boundaries are shown to be immaterial, as they cannot limit the sights and scenes of the world. Transcending these boundaries is shown to be a human task that broadens the horizons that one sees. This can be interpreted as a philosophical message that humans can broaden their minds just by broadening their scope of view. It can be done by seeing things beyond the visible and the obvious, and by seeing things that are subtle and those that are hidden for various reasons. The shadow lines that mark our horizons are merely shadows of the real boundaries and humans should cross it like Sita crossed the Laxman-rekha.
This is one novel that can be interpreted in so many different ways in so many different perspectives. This is something that the novel seems to be emphasising. The interpretations vary form person to person, as they are dependent on the person. This is the message I see from the novel from my perspective. Of course, someone else may differ on this. This is the beauty of this novel, again from my perspective.












Saturday, April 19, 2008

Today is my French exam:19th April,2008. Aujourd hui est mon exam de francais.

Hi got to study for it.....But note there is a cool site for its grammer on "geocities". ----
http://www.geocities.com/sohlhaut/FGHOnline.html

Au revoir.

Tuesday, April 15, 2008

14th April: My Birthday..

Hey... nothing new, all the same sunlight, same schedule, but some speciality in the date. its 14th and that too of april. So , its an important day, its my janamdin.
As always, my brother takes me to some cool or some really posh place (expensive too at least through my lens), but I wondered what it would be this time. *Some of earlier are which I liked the most mainly because of taste of "chicken tikka" - Khan chacha, Karim(near Jama Masjid), Rajendra dhaba, hotel taj(just posh but poor cuisines), Narula poutpouri(not good....) * This time we went to Parikrama hotel: The revolving hotel.
We had to wait for at least half an hour for a table of two. Then eventually we got in after making some comments on maddu's and their hero icons. First, we got the feeling as if we were traveling in a smooth train. But as the building is very tall, restaurant at 24th floor, it was a nice view of all the buildings and the lights. The quality of food was nice but it was expensive and service was poor. Well, I must cut short my writings as my exams are coming near and I got to know the details of the syllabus to start studying.
On the whole, must visit "Parikrama" with your girlfriend as there is lot of waiting, nice view, good quality food and expensive (* might be a good point sometime *).
Well, Happy birthday to me....

Thursday, April 3, 2008

Library

* Fine : for late submission and stealing of library items.
* Collection of magazines.
* Collection of books, especially from seniors
*

Prolog tutorials

Abridgment from the site:http://www.cs.nuim.ie/~jpower/Courses/PROLOG/

In particular, we want to emphasise that Prolog deals with relations and not functions.

Thursday, March 27, 2008

Coolest email by my professor ever

It's a mail by some professor of foreign university to our HoD. (Must read)

Dear sir,

The email attached is typical of many that I receive. They all seem to
come from IIT students. The students all claim to have reviewed my web
pages and to be particularly interested in working with me. I have yet
to receive one that shows any evidence that this is true, or indeed that
the writer has any idea whatsoever what research I do. Invariably their
stated interests do not coincide with any of mine. The fact that these
emails all appear to originate from IIT students, they all have similar
format and none of them show any sign that students have actually done
any research (it really looks as if they have written generic emails and
spammed them to every email address they could harvest) suggests that
they might be being instructed to behave this way. I find that hard to
believe, so I imagine it is more likely that they have misunderstood
something, but please could your staff who are responsible for your
internship programme encourage students to apply more selectively? I
fear that this deluge of spam emails from your students is not enhancing
the reputation of your institution, which I understand to be very high.

I've deleted all the identifiers from this email, it doesn't matter who
the student is, I've had many similar emails.

Jim Miles

-------- Original Message --------

Date: Thu, 14 Feb 2008 03:04:00 +0530
Subject: IIT Delhi Student - Application for Internship
MIME-Version: 1.0
Content-Type: multipart/mixed;

Respected Professor

I am a second year Computer Science student at Indian Institute of
Technology (IIT) Delhi ( http://www.iitd.ac.in/ ), which is a world
class institute with state of the art facilities and highly qualified
faculty imparting high quality teaching and training in technical
streams. IIT Delhi lays strong focus on practical knowledge apart from
imparting strong theoretical background which places it amongst the
top technical universities of the world.

Starting from 10th May 2008, I have about 10 weeks summer break during
which I would like to enhance my theoretical knowledge and practical
skills under excellent guidance. I am looking for high growth and
challenging opportunity to exploit my inner talent in the best working
environment and I am confident that I can do very good and meaningful
work in the area of Computer Science. By that time I would have
completed 4 (91 credits) semesters which include courses and projects
that have provided me with adequate fundamental knowledge of Computer
Science, both theoretical as well as practical. I have honed my
programming and technical skills with many projects and assignments
done in various courses related to a wide range of fields in Computer
Science.

I have been through the website and am impressed by the level of
innovative research at your institute.I have gone through the research
pursued by you and I am interested to work with you. I am highly
motivated to pursue research involving application of my knowledge and
more than willing to learn new concepts before working on a project.
An internship under your guidance would be an ideal addition to my
Bachelor's Degree in engineering. I am proficient in English and quick
to learn new languages also.

I am appending my Resume to this email, for your kind consideration.
Hoping for a wonderful learning experience under your guidance.

Looking forward to a favourable response and thanking you for your time.

Yours Sincerely

2nd Yr Computer Science
Indian Institute of Technology, Delhi

Official Information of DE's of CS in IITD

Here is a list of courses and their pre-requirements--------


DEPARTMENT CORE (DC) :

CSL356 Analysis and Design of Algorithms : (3-1-0)
Pre-req : CSL201 & CSL105.

CSL373 : Operating Systems : (3-0-4) :
Pre-req : CSL201 & CSL211 & CSL302 .

CSL374 - - - Computer Networks - - - - (3-0-3) ----- (4.5)
pre-req: CSL201 & CSL 211 & EEL205

DEPARTMENT ELECTIVES (DE) :

Mini project : CSD310 : (0-0-6)
Pre-req : EC = 80 .

CSL303 : Logic for Computer Science : (3-0-2)
Pre-req : CSL201 .

CSL332 : Introduction to Database Systems (3-0-3) :
Pre-req : CSL201 .

CSL333 : Artificial Intelligence (3-0-2)
Pre-req : CSL201 .

CSL361 : Numerical And Scientific Computating : (3-1-2)
Pre-req : CSL101 / CSL102 & EC = 60 .

CSL362 : Simualtion and modelling : (3-0-2) :
Pre-req : CSL201 & MAL250 .

CSL705 : Theory of computation (3-1-0) :
Pre-req : CSL105 & EC = 90 .

CSL719 : Synthesis of Digital Systems :(3-0-2)
Pre-req : CSL316

CSL728 : Compiler Design : (3-0-3)
Pre-req : CSL302 & CSL705 .

CSL740 : Software Engineering : ( 3-0-2)
Pre-req : CSL201 & CSL302 .

CSL781 : Computer Graphics : (3-0-3)
Pre-req : CSL201 & EC =90 .

CSL783 : Digital Image Analysis : (3-0-3)
Pre-req : EEL205 & CSL201 & EC = 90 .

CSP315 : Embedded System Design Laboratory : (0-1-6) :
Pre-req : CSL211 .

CSR310 : Professional Practice : (0-1-2) :
Pre-req : EC = 60 .

CSS310 : Independent Study : (0-3-0) :
Pre-req : EC =60 .

small POLTU of IITD : Lost my convener elections for 3rd year

NOTE: When it comes to politics then nobody is your friend, everybody is a subject "which" has to be manipulated appropriately to need your ends.
Do business then mean business.(except for your relatives where you may win by losing)

Well, I saw many intelligent people vote on any basis other than their brain. But I don't think that they did so much wrong because if I would have been there, I would also have allowed that happen. But I still remember the faces of ignorant intelligent students, they were thrilled, happy and unconcerned of the actual results. Many of those were men of principles.

Result: Even good men do wrong things but they think those things are good in their domain. History gives us many proofs of this. Well, according to me, slavery of India and Indians was due to this reason. Its not that there were no good men in India but they did right things in their own domain by serving obediently to British rule. After 1857, there were only 10,000 (on an average) British troops to rule the whole nation and army was in millions.

ONE more important thing: At least ask your friend a favor when you need. Don't be shy. So that you know, upto which level is your friendship.

Wednesday, March 26, 2008

Got selected for Library secy

Hi. There is a news when I joined the session for meeting of our batch that mahesh gattani has slipped back for his post and I was next to him
for the post.
Well, as I was unanimously selected for the post, I did not have to present my statement of purpose. But lets see what have I got in my bag:

1. Collection of minor and major exam papers along with professor's name.

2. Bring new books e.g. fiction, CAT preparation psychology, IAS preparation and psychology.

3. Make a committee, if possible officially, and ask for representing common demands of books, exam papers, or any other help which is accessible from seniors or other source.

4. Make sure that the database of the library is properly maintained.

5. General check on the type of newspapers or magazines purchased.

6. Even the lighting of library needs to be improved.( Basic point but important )

Monday, March 17, 2008

Results of Conversations leading to truth

Well, I just had a conversation with my sister and it emerged as a good talk that i wanted myself to know and understand. Actually she was asking something that I always wanted to ask myself- "What are you doing nowadays in IITD?". She knows it that I am not a maggu type guy who always studies or likes to study. She put me through various options- " Lawn tennis, dance, table tennis, jogging, anything that is something worth mentioning or considering " but my response is- "I dedicate my time to all the downloaded stuff our "ODC" has . I watch movies-which I don't like now much , So I watch english t.v. shows-"heroes, the lost room , sherlock holmes, Friends, The Class, Desperate housewives, Roadies,.........and many more".So, the answer is -"You may do that stuff but you must do something that is something." So, she advises me to join dance classes, or learn swimming, or play chess on internet at international level. Though some of her ideas are vague and some are good but my response is direct-"If I have to choose something in my life, I will choose improvement of my life." like 'I will wake up early in the day, do yoga , go for walk, later concentrate on my subjects, improve my english speaking skills, vocabulary..... do something that I always wanted to do.'
This is the question that I always wnated to ask myself-"When will I start living life of my own style, the way I want to live, talk, behave , laugh or may be sleep."
The answer is " 'When I will' decide that from now on, no more lethargicness, just do whatever you decide to, live the way you feel."

Well, in the core of my heart, I know I won't be able to survive with this soundness function of mine.

Friday, March 14, 2008

Crippled without a stick

There are times when you feel crippled even without a stick, and there are times when you act like crippled and these are not physically but mentally. You are doing an assignment and you know can get the code from some xyz.com website, then you tend to act like crippled. and even though you pass the first test of ignoring the site, you may lose when you are stuck in the program. and its worst if you seek the help of your friend even without fully trying it.
As a matter of fact, I am hit by the latter one.

Terrible news

I was having my lunch when my chachiji called me and asked me if my brother, Nikhil has called me or any other family member has called me. I was enjoying my food and I hung up the phone saying "I will call u later". I call ed after having my lunch, I asked 'whats the matter?' and she gave me the terrible news that my mamaji expired today of heart - attack . I could not speak or talk more, I did not understand what to say or do? I was not in trauma at once but a sudden shock. I hung up the phone and just stood there. My friends came by and waving happily , screaming not knowing what a thunderstorm has just struck the ground. I tried to call my brother because I feel (safe) with him or there is something that says 'I am there for you' . I did not know how to talk to my mother. I was afraid and also feeling guilty in hesitating to call her. I just don't know why I haven't call her yet......I just really don't know.

Wednesday, March 12, 2008

Cycles of life

Well, in exams time, the most important thing is whether you study or not. In the time of playing sports or games in the field, the most important thing is whether you perform well or not along with no injuries.

Spiritual lectures

Unification is God. And the process to reach it is through implementation of logic and physics.

Friday, March 7, 2008

Prolog Assignment : Useful Links

Hey guys, I have been given a Prolog assignment and I really surfed a lot to get my assignment from net. In doing so, I came across many useful sites which help in better understanding of the language and its implementations.

Here are some useful links:
http://www.doc.gold.ac.uk/~mas02gw/prolog_tutorial/prologpages/lists.html
http://www.anselm.edu/homepage/mmalita/culpro/index.html
http://www.anselm.edu/homepage/mmalita/culpro/index.html
http://kti.mff.cuni.cz/~bartak/prolog/genealogy.html
http://www.engin.umd.umich.edu/CIS/course.des/cis479/prolog/matrix.pro
To execute any prolog program (test.pl) -- first install "xsb" for linux which is free or any other version of it.

Then on the command line --------
? ['test'] ------- will compile the program.

Here is a lecture series from one of these links:

Lecture 1

Program 1.1

likes(max, julia).

Program 1.2

likes(max, julia).
likes(max, amabel).

Program 1.3 - a definition of jealousy

likes(max, julia).
likes(max, amabel).

jealous(Jealous, Victim) :-
likes(Person, Jealous),
likes(Person, Victim).

Lecture 2

Program 2.1

lives_in(max, london).
likes(max, amabel).
child(charles, amy, brian).
price(template, 3, 4.75).
assembly(arm, joint(ball, 3)).

Program 2.2

lives_at(brian, boxgrave_rd).
lives_at(mandy, boxgrave_rd).

neighbours(Pers1, Pers2) :-
lives_at(Pers1, Road),
lives_at(Pers2, Road).

Program 2.3

pass(Pass_Mark) :-
module_pass(Mod_Pass),
module_no(Mod_No),
Pass_Mark is Mod_Pass * Mod_No.

% number of modules to be completed
module_no(6).

% individual module pass mark
module_pass(40).

friend_of(max, julia).
friend_of(max, amabel).
friend_of(amabel, richard).
% etc

% 1
friend(Pers, Friend) :-
friend_of(Pers, Friend).
% 2
friend(Pers, Friend) :-
friend_of(Pers, Inter),
friend(Inter, Friend).

Lecture 3

Program 3.1 - inefficient factorial

% 1 - "Input" number is 0
factorial(0, _, 1).

% 2 - base when all args unify
factorial(Numb, Numb, Numb).

% 3 - singly recursive
factorial(Numb, Count, Answ) :-
% don't count past Numb
Count < Numb,
% increment Count
Count1 is Count + 1,
% calculate Count1!
factorial(Numb, Count1, Answ1),
% calculate Count!
Answ is Answ1 * Count.

% factorial/2 calls factorial/3
factorial(Numb, Result) :-
factorial(Numb, 1, Result).

Program 3.2 - fibonacci numbers - not used in 2002/03

% 1 - terminating
fibonacci(1, 1).

% 2 - terminating
fibonacci(2, 1).

% 3 - doubly recursive
fibonacci(Numb, Fib) :-
Numb > 2,
Numb1 is Numb - 1,
Numb2 is Numb - 2,
fibonacci(Numb1, Fib1),
fibonacci(Numb2, Fib2),
Fib is Fib1 + Fib2.

Program 3.3 - displaying a binary tree

display_label(Label, Offset) :-
tab(Offset),
write(Label),
nl.

% 1 - boundary
display_tree(nil, _Offset).
% 2 - recursive
display_tree(bt(Left, Label, Right), Offset) :-
Offset1 is Offset + 5,
display_tree(Left, Offset1),
display_label(Label, Offset),
display_tree(Right, Offset1).

Program 3.4 - efficient factorial

factorial(Numb, Answ) :-
factorial(Numb, 1, 1, Answ).

% 1 - Number is 0
factorial(0, _, _, 1).
% 2 - Number is 2
factorial(Numb, Numb, Answ, Answ).
% 3 - recursive
factorial(Numb, Count, Answ0, Answ) :-
Numb > Count,
Count1 is Count + 1,
Answ1 is Answ0 * Count1,
factorial(Numb, Count1, Answ1, Answ).

Lecture 4

Program 4.1 - graph search

path(a,1).
path(a,3).

path(1,2).
path(1,4).

path(2,5).

path(3,4).

path(4,5).

% 1 - boundary
route(Start, End) :-
path(Start, End).
% 2 - recursive
route(Start, End) :-
path(Start, Via),
route(Via, End).

Program 4.2 - finding the length of a list


% 1 - terminating
len_of_list([], Length, Length).
% 2 - recursive
len_of_list([_Head|Tail], Length1, Length) :-
Length2 is Length1 + 1,
len_of_list(Tail, Length2, Length).

Program 4.3 - is an element a member of a list?


% 1 - terminating
memb(Elem, [Elem|_]).
% 2 - recursive
memb(Elem, [_|Tail]) :-
memb(Elem, Tail).

Program 4.4 - finding the element at the nth position in a list


% 1 - recursive
nth(Count, Item, [_|Tail]) :-
Count > 1,
Count0 is Count - 1,
nth(Count0, Item, Tail).
% 2 - terminating
nth(1, Head, [Head|_]).

Program 4.5 - appending two lists to make a third - or splitting a list into two lists


% 1 - terminating
app([], List, List).
% 2 - recursive
app([Head|L1], L2, [Head|L3]) :-
app(L1, L2, L3).

Program 4.6 - deleting an element from a list - an extension of memb/2 that also inserts an item into a list


% 1 - terminating
delete(Head, [Head|Tail], Tail).
% 2 - recursive
delete(Item, [Head|Tail], [Head|New_Tail]) :-
delete(Item, Tail, New_Tail).


Lecture 5

Program 5.1 - pairing items from two lists

/* ************************************************ */
/* */
/* pair/3 */
/* Summary: List 3 is pairs of items from */
/* Lists 1 & 2. */
/* Arg 1: List. */
/* Arg 2: List. */
/* Arg 3: List. */
/* Author: P J Hancox */
/* Date: 29 October 1998 */
/* */
/* ************************************************ */

% 1 - terminating 1
pair([], [Head|Tail], [Head|Tail]).
% 2 - terminating 2
pair(List, [], List).
% 3 - recursive
pair([Head1|Tail1], [Head2|Tail2],
['<', Head1, Head2, '>'|Tail3]) :-
pair(Tail1, Tail2, Tail3).

Program 5.2 - deleting an element from a list - an extension of memb/2 that also inserts an item into a list. Also used in Lecture 4


/* ************************************************ */
/* */
/* delete/3 */
/* Summary: Arg 3 is Arg 2 with an instance of */
/* Arg 1 deleted. */
/* Arg 1: Term. */
/* Arg 2: List. */
/* Arg 3: List. */
/* Author: P J Hancox */
/* Date: 22 October 1999 */
/* */
/* ************************************************ */

% 1 - terminating
delete(Head, [Head|Tail], Tail).
% 2 - recursive
delete(Item, [Head|Tail], [Head|New_Tail]) :-
delete(Item, Tail, New_Tail).

Program 5.3 - flattens a list


/* ************************************************ */
/* */
/* flatten/2 */
/* Summary: Arg 2 is Arg 1 with all items */
/* extracted from sublists: eg */
/* | ?-flatten([[a,b],e,[[f]]],R). */
/* R = [a,b,e,f] ? ; */
/* no */
/* Arg 1: List. */
/* Arg 2: List. */
/* Author: P J Hancox */
/* Date: 29 October 1999 */
/* */
/* ************************************************ */

% 1 - terminating
flatten([], []).
% 2 - recursive
flatten([Item|Tail1], [Item|Tail2]) :-
\+ is_a_list(Item),
flatten(Tail1, Tail2).
% 3 - recursive
flatten([Item|Tail1], List2) :-
is_a_list(Item),
flatten(Item, List1),
flatten(Tail1, Tail2),
app(List1, Tail2, List2).


/* ************************************************ */
/* */
/* app/3 */
/* Summary: True if Arg 3 is Arg 2 appended to */
/* Arg 1. */
/* Arg 1: List. */
/* Arg 2: List. */
/* Arg 3: List. */
/* Author: P J Hancox */
/* Date: 29 October 1999 */
/* */
/* ************************************************ */

% 1 - terminating
app([], List, List).
% 2 - recursive
app([Head|List1], List2, [Head|List3]) :-
app(List1, List2, List3).


/* ************************************************ */
/* */
/* is_a_list/1 */
/* Summary: True if Arg1 is instantiated and a */
/* list. */
/* Arg 1: List. */
/* Author: P J Hancox */
/* Date: 29 October 1999 */
/* */
/* ************************************************ */

is_a_list(List) :-
nonvar(List),
is_a_list1(List).


/* ************************************************ */
/* */
/* is_a_list1/1 */
/* Summary: True if Arg1 unifies with an empty */
/* list or a list with a head and tail. */
/* Arg 1: List. */
/* Author: P J Hancox */
/* Date: 29 October 1999 */
/* */
/* ************************************************ */

% 1 - list is empty
is_a_list1([]).
% 2 - list has > 0 members
is_a_list1([_|_]).

Program 5.4 - reversing a list - inefficiently


/* ************************************************ */
/* */
/* reverse_naive/2 */
/* Summary: True if Arg2 is Arg 1 in reverse */
/* order. */
/* Arg 1: List. */
/* Arg 2: List. */
/* Author: P J Hancox */
/* Date: 29 October 1999 */
/* */
/* ************************************************ */

% 1 terminating
reverse_naive([], []).
% 2 recursive
reverse_naive([Head|Tail1], Reversed) :-
reverse_naive(Tail1, Tail2),
app(Tail2, [Head], Reversed).

Program 5.5 - reversing a list - efficiently


/* ************************************************ */
/* */
/* reverse_acc/2 */
/* Summary: True if Arg2 is Arg 1 in reverse */
/* order. */
/* Arg 1: List. */
/* Arg 2: List. */
/* Author: P J Hancox */
/* Date: 29 October 1999 */
/* */
/* ************************************************ */

% 1
reverse_acc(List, Tsil) :-
reverse_acc(List, [], Tsil).
/* ************************************************ */
/* */
/* reverse_acc/3 */
/* Summary: True if Arg3 is Arg 1 in reverse */
/* order. */
/* Arg 1: List. */
/* Arg 2: List. */
/* Arg 3: List. */
/* Author: P J Hancox */
/* Date: 29 October 1999 */
/* */
/* ************************************************ */

% 1 terminating condition
reverse_acc([], Reversed, Reversed).
% 2 recursive
reverse_acc([Head|Tail], Rest, Reversed) :-
reverse_acc(Tail, [Head|Rest], Reversed).


Lecture 6

Program 6.1 - classifying a list into vowels and consonants.

/* ************************************************ */
/* */
/* vowel/1 */
/* Summary: True if Arg1 is a vowel. */
/* Arg 1: Letter. */
/* Author: P J Hancox */
/* Date: 30 October 2002 */
/* */
/* ************************************************ */

vowel(a).
vowel(e).
vowel(i).
vowel(o).
vowel(u).


/* ************************************************ */
/* */
/* classify/3 */
/* Summary: Classifies a list of letters into two */
/* lists: vowels and consonants. */
/* Arg 1: List of letters. */
/* Arg 2: List of vowels. */
/* Arg 3: List of consonants. */
/* Author: P J Hancox */
/* Date: 30 October 2002 */
/* */
/* ************************************************ */

% 1 - terminating
classify([], [], []).
% 2 - recursive: letter is a vowel
classify([Vowel|Tail], [Vowel|Vowel_Tail], Non_Vowels) :-
vowel(Vowel),
classify(Tail, Vowel_Tail, Non_Vowels).
% 3 - recursive: letter is a consonant
classify([Non_Vowel|Tail], Vowels, [Non_Vowel|Non_Vowel_Tail]) :-
classify(Tail, Vowels, Non_Vowel_Tail).

Program 6.2 - buggy version of member/2 to show singleton variables

/* ************************************************ */
/* */
/* member/2 */
/* Summary: True if Arg1 occurs in Arg2. */
/* Arg 1: Term. */
/* Arg 2: List. */
/* Author: P J Hancox */
/* Date: 30 October 2002 */
/* */
/* ************************************************ */

% 1 - terminating
member(Head, [Heda|_]).
% 2 - recursive
member(Elem, [_|Tail]) :-
member(Elem, Tail).


Lecture 7

Program 7.1 - a simple course database program


semester2_1 -->
mod, mod, mod, mod,
prog_option,
options2_1.

options2_1 -->
option.
options2_1 -->
elective.

mod --> [sem222].
mod --> [sem236].
mod --> [sem240].
mod --> [sem232a].

prog_option --> [sem241].
prog_option --> [sem242].

elective --> [comm271].

option --> [sem227].
option --> [sem2a2].

Program 7.2 - a simple course database program that checks the name of the student


semester2_1(Student) -->
mod(Student),
mod(Student),
mod(Student),
mod(Student),
prog_option(Student),
options2_1(Student).

options2_1(Student) -->
option(Student).
options2_1(Student) -->
elective(Student).

mod(james) --> [sem222].
mod(james) --> [sem236].
mod(james) --> [sem240].
mod(james) --> [sem232a].

prog_option(james) --> [sem242].

elective(james) --> [comm271].

option(ben) --> [sem227].

Program 7.3 - a simple course database program that checks the name of the student and calculates a total mark


semester2_1(Student, Total_Mark) -->
mod(Student, Mark1),
mod(Student, Mark2),
mod(Student, Mark3),
mod(Student, Mark4),
prog_option(Student, Mark5),
options2_1(Student, Mark6),
{ Total_Mark is Mark1 + Mark2 + Mark3 +
Mark4 + Mark5 + Mark6 }.

options2_1(Student, Mark) -->
option(Student, Mark).
options2_1(Student, Mark) -->
elective(Student, Mark).

mod(james, 57) --> [sem222].
mod(james, 53) --> [sem236].
mod(james, 62) --> [sem240].
mod(james, 55) --> [sem232a].

prog_option(james, 95) --> [sem242].

elective(james, 68) --> [comm271].

option(ben, 54) --> [sem227].

Program 7.4 - a demonstration of how to build a structure representiong an object.

This technique is often used to represent syntactic structure in grammar but can equally well work for other things. This example is the structure of a door.

doors(door(Panel, Hinges, Lock)) -->
hinges(Hinges),
door_panel(Panel),
lock(Lock).


hinges(hinge(brass, 3)) -->
[hinge].
hinges(hinge(steel, 2)) -->
[hinge].

door_panel(panel(white)) -->
[panel].
door_panel(panel(wood_effect)) -->
[panel].

lock(lock(yale)) -->
[lock].

Program 7.5 - a DCG for a Noun Phrase that will not terminate


np(np(NP1, NP2)) -->
np(NP1),
noun(NP2).
np(np(Det)) -->
det(Det).

det(det(the)) --> [the].

noun(noun(car)) --> [car].

Program 7.6 - a DCG for a Noun Phrase that will terminate because of the use of modified functors


np(np(NP1, NP2)) -->
np1(NP1),
noun(NP2).

np1(np(Det)) -->
det(Det).

det(det(the)) --> [the].

noun(noun(car)) --> [car].

Program 7.7 - a DCG for a Noun Phrase that will terminate because of the use of an history list


np(np(NP1, NP2), History0, History, S0, S) :-
\+ memb(entry(np, S0), History0),
np(NP1, [entry(np, S0)|History0], History1, S0, S1),
noun(NP2, [entry(noun, S1)|History1], History, S1, S).

np(np(Det), History0, History) -->
det(Det, History0, History).

det(det(the), History, History) --> [the].

noun(noun(car), History, History) --> [car].

% 1 - terminating
memb(Elem, [Elem|_]).
% 2 - recursive
memb(Elem, [Head|Tail]) :-
\+ (Elem = Head),
memb(Elem, Tail).

Program 7.8 - a DCG for a Noun Phrase that will terminate because of the use of a limited history list


np(np(NP1, NP2), History0, History, S0, S) :-
\+ memb(entry(np, S0), History0),
np(NP1, [entry(np, S0)|History0], History1, S0, S1),
noun(NP2, [entry(noun, S1)|History1], History, S1, S).

np(np(Det), History0, History) -->
det(Det, History0, History).

det(det(the), _History, []) --> [the].

noun(noun(car), _History, []) --> [car].

Program 7.9 - a DCG version of sum_sublist/3


sum_sublist(Elem, List, Sum) :-
find_sublist(Elem, List, Sublist),
sum(Elem, 0, Sum, Sublist, _).

% 1 - terminating
find_sublist(Elem) -->
[Elem].
% 2 - recursive
find_sublist(Elem) -->
[Head],
{ \+ (Head = Elem)},
find_sublist(Elem).

% 1 - terminating
sum(0, Sum, Sum) --> [].
% 2 - recursive
sum(Count, Sum, Sum2) -->
[Head],
{ Sum1 is Sum + Head,
Count1 is Count - 1},
sum(Count1, Sum1, Sum2).


Lecture 8

Program 8.1 - appending two lists to make a third - or splitting a list into two lists


/* ************************************************ */
/* */
/* app/3 */
/* Summary: True if Arg 3 is Arg 2 appended to */
/* Arg 1. */
/* Arg 1: List. */
/* Arg 2: List. */
/* Arg 3: List. */
/* Author: P J Hancox */
/* Date: 29 October 1999 */
/* */
/* ************************************************ */

% 1 - terminating
app([], List, List).
% 2 - recursive
app([Hd|L1],L2,[Hd|L3]) :-
app(L1, L2, L3).

Program 8.2 - is an element a member of a list?


/* ************************************************ */
/* */
/* memb/2 */
/* Summary: True if Arg1 is in Arg2. */
/* Arg 1: Term. */
/* Arg 2: List. */
/* Author: P J Hancox */
/* Date: 22 October 1999 */
/* */
/* ************************************************ */

% 1 - terminating
memb(Elem, [Elem|_]).
% 2 - recursive
memb(Elem, [_|Tail]) :-
memb(Elem, Tail).

Program 8.3 - updating a count of a letter

/* ************************************************ */
/* */
/* update_count/3 */
/* Summary: Increments Arg3 is Arg1 is "a". */
/* Arg 1: Vowel. */
/* Arg 2: Number (accumulator). */
/* Arg 3: Number. */
/* Author: P J Hancox */
/* Date: 22 October 1999 */
/* */
/* ************************************************ */

% 1 - a
update_count(a, A, A1) :-
A1 is A + 1.
% 2 - not "a"
update_count(Letter, A, A) :-
Letter \== a.

Program 8.4 - inefficient factorial

/* ************************************************ */
/* */
/* fac1/2 */
/* Summary: True if Arg2 is the factorial of */
/* Arg1. */
/* Arg 1: Number. */
/* Arg 2: Number. */
/* Author: P J Hancox */
/* Date: 22 October 1999 */
/* */
/* ************************************************ */

% 1 - terminating
fac1(0, 1).
% 2 - recursive - but goes into infinite recursion
% on backtracking
fac1(N, Factorial) :-
N1 is N - 1,
fac1(N1, Factorial1),
Factorial is N * Factorial1.

Program 8.5 - more efficient factorial - using accumulator

/* ************************************************ */
/* */
/* fac2/2 */
/* Summary: True if Arg2 is the factorial of */
/* Arg1. Calls fac2/3. */
/* Arg 1: Number. */
/* Arg 2: Number. */
/* Author: P J Hancox */
/* Date: 22 October 1999 */
/* */
/* ************************************************ */

fac2(Numb, Fact) :-
fac2(Numb, 1, Fact).


/* ************************************************ */
/* */
/* fac2/3 */
/* Summary: True if Arg3 is the factorial of */
/* Arg1. */
/* Arg 1: Number. */
/* Arg 2: Number (accumulator). */
/* Arg 2: Number. */
/* Author: P J Hancox */
/* Date: 22 October 1999 */
/* */
/* ************************************************ */

% 1 - terminating
fac2(0, Fact, Fact).
% 2 - recursive - but goes into infinite recursion
% on backtracking
fac2(N, Accum, Fact) :-
N1 is N - 1,
tab(N1), write(Accum), nl, % we can output this
Accum1 is N * Accum,
fac2(N1, Accum1, Fact).

Program 8.6 - efficient factorial - using accumulator and if...then...else

/* ************************************************ */
/* */
/* fac3/2 */
/* Summary: True if Arg2 is the factorial of */
/* Arg1. Calls fac3/3. */
/* Arg 1: Number. */
/* Arg 2: Number. */
/* Author: P J Hancox */
/* Date: 22 October 1999 */
/* */
/* ************************************************ */

fac3(Numb, Fact) :-
fac3(Numb, 1, Fact).


/* ************************************************ */
/* */
/* fac3/3 */
/* Summary: True if Arg3 is the factorial of */
/* Arg1. Uses if...then...else. */
/* Arg 1: Number. */
/* Arg 2: Number (accumulator). */
/* Arg 2: Number. */
/* Author: P J Hancox */
/* Date: 22 October 1999 */
/* */
/* ************************************************ */

fac3(N, Accum, Fact) :-
( N > 0 ->
N1 is N - 1,
Accum1 is N * Accum,
fac3(N1, Accum1, Fact)
; N =:= 0 ->
Accum = Fact
).

Program 8.7 - maximum of two numbers with a green cut

/* ************************************************ */
/* */
/* max1/3 */
/* Summary: True if Arg3 is the maximum of Arg1 */
/* or Arg2. Works correctly. */
/* Arg 1: Number. */
/* Arg 2: Number. */
/* Arg 2: Number. */
/* Author: P J Hancox */
/* Date: 22 October 1999 */
/* */
/* ************************************************ */

max1(X, Y, X) :-
X >= Y, !. % green cut
max1(X, Y, Y) :-
X < Y.

Program 8.8 - maximum of two numbers with a red cut - gives incorrect results

/* ************************************************ */
/* */
/* max2/3 */
/* Summary: True if Arg3 is the maximum of Arg1 */
/* or Arg2. Works incorrectly because */
/* it allows max2(2,1,1). */
/* Arg 1: Number. */
/* Arg 2: Number. */
/* Arg 2: Number. */
/* Author: P J Hancox */
/* Date: 22 October 1999 */
/* */
/* ************************************************ */

max2(X, Y, X) :-
X >= Y, !.
max2(_X, Y, Y).

Program 8.9 - maximum of two numbers using if...then...else

/* ************************************************ */
/* */
/* max3/3 */
/* Summary: True if Arg3 is the maximum of Arg1 */
/* or Arg2. Works correctly. Uses */
/* if...then...else. Not used in */
/* lecture. */
/* Arg 1: Number. */
/* Arg 2: Number. */
/* Arg 2: Number. */
/* Author: P J Hancox */
/* Date: 22 October 1999 */
/* */
/* ************************************************ */

max3(X, Y, Z) :-
( X >= Y ->
X = Z
; X <>
Y = Z
).


Lecture 9

Program 9.1 - a rule base for defining relationships between parents, children and siblings

The logical inference maker requires rules to work.


% The following must be present - but they are better
% placed in the inference engine.

:- op(400, xfx, if).
:- op(300, xfy, and).

/* ************************************************ */
/* */
/* Rules of inference */
/* */
/* ************************************************ */

father(Father, Child) if
parent(Father, Child) and
male(Father).

mother(Mother, Child) if
parent(Mother, Child) and
female(Mother).

child(Child, Parent) if
parent(Parent, Child).

sibling(Sibling1, Sibling2) if
father(Father, Sibling1) and
father(Father, Sibling2) and
mother(Mother, Sibling1) and
mother(Mother, Sibling2) and
not_equals(Sibling1, Sibling2).

brother(Brother, Sibling) if
sibling(Brother, Sibling) and
male(Brother).

sister(Sister, Sibling) if
sibling(Sister, Sibling) and
female(Sister).

step_sibling(Sibling1, Sibling2) if
father(Father1, Sibling1) and
father(Father2, Sibling2) and
mother(Mother, Sibling1) and
mother(Mother, Sibling2) and
not_equals(Sibling1, Sibling2) and
not_equals(Father1, Father2).

step_sibling(Sibling1, Sibling2) if
father(Father, Sibling1) and
father(Father, Sibling2) and
mother(Mother1, Sibling1) and
mother(Mother2, Sibling2) and
not_equals(Sibling1, Sibling2) and
not_equals(Mother1, Mother2).

step_brother(Brother, Sibling) if
step_sibling(Brother, Sibling) and
male(Brother).

step_sister(Sister, Sibling) if
step_sibling(Sister, Sibling) and
female(Sister).

married(Husband, Wife) if
father(Husband, Child) and
mother(Wife, Child).

Program 9.2 - logical inference by forward chaining

The top-level predicate is go. It then needs to be fed facts, eg:

To stop the program, type stop.


/* ************************************************ */
/* */
/* Logical inference by forward chaining */
/* Taken from: Gazdar, G. and Mellish, C. */
/* Natural Language Processing in Prolog. */
/* Addison-Wesley, 1989. pp 333-339. */
/* */
/* ************************************************ */

:- op(400, xfx, if).
:- op(300, xfy, and).

:- dynamic(fact/1).


/* ************************************************ */
/* */
/* go/0 */
/* Summary: Runs inference engine. Slightly */
/* adapted from Gazdar & Mellish, p 337. */
/* Author: P J Hancox */
/* Date: 3 December 1999 */
/* */
/* ************************************************ */

go :-
write('Input something: '),
read(Fact),
nl,
add(Fact, 'user input'),
go.


/* ************************************************ */
/* */
/* find_new_consequences/1 */
/* Summary: Finds all new facts inferable from */
/* Arg 1. Based on Gazdar & Mellish's */
/* predicate of the same name, but */
/* doesn't rely of fail/0. */
/* Arg 1: Fact, eg mother(ann, elizabeth). */
/* Author: P J Hancox */
/* Date: 3 December 1999 */
/* */
/* ************************************************ */

find_new_consequences(Fact) :-
findall(new_facts(Theorem, Premises),
(Theorem if Premises,
select(Fact, Premises, Remainder),
all_facts(Remainder)),
New_Facts),
add_new_facts(New_Facts).


/* ************************************************ */
/* */
/* add_new_facts/1 */
/* Summary: Add each new fact to the database. */
/* Arg 1: List of facts. */
/* Author: P J Hancox */
/* Date: 3 December 1999 */
/* */
/* ************************************************ */

% 1- terminating
add_new_facts([]).
% 2 - recursive
add_new_facts([new_facts(Theorem, Premises)|New_Facts]) :-
add(Theorem, Premises),
add_new_facts(New_Facts).


/* ************************************************ */
/* */
/* all_facts/1 */
/* Summary: True is a conjunction of facts is in */
/* the database. Slightly adapted from */
/* Gazdar & Mellish. */
/* Arg 1: Facts (in form F't or (F't and F'ts)) */
/* Author: P J Hancox */
/* Date: 3 December 1999 */
/* */
/* ************************************************ */

% 1 - terminating
all_facts(Fact) :-
\+ (Fact = (_ and _)),
!, % green cut
fact(Fact).
% 2 - recursive
all_facts(Fact and Facts) :-
fact(Fact),
all_facts(Facts).

/* ************************************************ */
/* */
/* select/3 */
/* Summary: True if Arg1 is contained in Arg2. */
/* Arg3 is Arg2 minus Arg1. */
/* Arg 1: Fact */
/* Arg 2: Facts (in form F't or (F't and F'ts)) */
/* Arg 3: Facts (in form true or (F't and F'ts))*/
/* Author: Gazdar & Mellish, p 336. */
/* */
/* ************************************************ */

% 1 - Arg1 and Arg2 match exactly - return "true"
select(Fact, Fact, true).
% 2 - Arg1 matches head of Arg2 exactly - return
% remainder of Arg2
select(Fact, Fact and Facts, Facts).
% 3 - Arg1 isn't the same as head of Arg2, so
% search in remainder of Arg2
select(Fact1, Fact2 and Facts1, Fact2 and Facts2) :-
select(Fact1, Facts1, Facts2).


/* ************************************************ */
/* */
/* add/2 */
/* Summary: Adds new facts to the database and */
/* makes new inferences and outputs new */
/* inferences. Adapted from Gazdar & */
/* Mellish, p 335. */
/* Arg 1: Fact */
/* Arg 2: Premises */
/* Author: P J Hancox */
/* Date: 3 December 1999 */
/* */
/* ************************************************ */

% 1 - stops program - added by PJH
add(stop, _) :-
abort.
% 2 - fact already exists in the database
add(Fact, _) :-
fact(Fact),
!. % green cut
% 3 - fact doesn't exist in the database
% add to db and make new inferences
add(Fact, Premise) :-
\+ fact(Fact),
assert(fact(Fact)),
tab(5),
write('Adding: '),
write(Fact),
nl,
tab(14),
write('from '),
display_premise(Premise, 14),
find_new_consequences(Fact).


/* ************************************************ */
/* */
/* fact/1 */
/* Summary: Base facts. Adapted from Gazdar & */
/* Mellish, p 336. */
/* Arg 1: true */
/* Author: P J Hancox */
/* Date: 3 December 1999 */
/* */
/* ************************************************ */

fact(true).

fact(equals(X, Y)) :-
nonvar(X),
X == Y. % assumes it never sees a variable.

fact(not_equals(X, Y)) :-
nonvar(X),
X \== Y. % assumes it never sees a variable.



/* ************************************************ */
/* */
/* display_premise/2 */
/* Summary: Displays the facts from which the */
/* inference was made. */
/* Arg 1: Premises */
/* Arg 2: Offset (tab width) */
/* Author: P J Hancox */
/* Date: 3 December 1999 */
/* */
/* ************************************************ */

% 1 - terminating
display_premise(Premise, _Offset) :-
\+ (Premise = (_ and _)),
!, % green cut
display_premise(Premise).
% 2 - recursive
display_premise(Premise and Premises, Offset) :-
display_premise(Premise),
tab(Offset),
write('and '),
display_premise(Premises, Offset).


/* ************************************************ */
/* */
/* display_premise/1 */
/* Summary: Displays a fact from which the */
/* inference was made. */
/* Arg 1: Premise */
/* Author: P J Hancox */
/* Date: 3 December 1999 */
/* */
/* ************************************************ */

display_premise(Premise) :-
write(Premise),
nl.

Program 9.3 - a DCG and associated code to interface with the inference maker.

Grammar and dictionary describe some family relations of the Tudor kings and queens of England.

The top-level predicate is run.. Valid sentences include:

To stop the program, enter [stop].


s(_, _) -->
[stop],
{ abort }.

s(s(NP, VP), VP_Sem) -->
np(NP, NP_Sem),
vp(VP, VP_Sem, NP_Sem).

np(propn('Henry VII'), 'Henry VII') -->
[henry7].
np(propn('Henry VIII'), 'Henry VIII') -->
[henry8].
np(propn('Elizabeth of York'), 'Elizabeth of York') -->
[elizabeth_of_york].
np(propn('Catherine of Aragon'), 'Catherine of Aragon') -->
[catherine_of_aragon].
np(propn('Ann Boleyn'), 'Ann Boleyn') -->
[ann_boleyn].
np(propn('Jane Seymour'), 'Jane Seymour') -->
[jane].
np(propn('Anne of Cleeves'), 'Anne of Cleves') -->
[ann_of_cleeves].
np(propn('Catherine Howard'), 'Catherine Howard') -->
[catherine_howard].
np(propn('Catherine Parr'), 'Catherine Parr') -->
[catherine_parr].
np(propn('Edward VI'), 'Edward VI') -->
[edward].
np(propn('Mary Tudor'), 'Mary') -->
[mary].
np(propn('Elizabeth I'), 'Elizabeth I') -->
[elizabeth].

np(np(Det, Noun), Sem) -->
det(Det),
noun(Noun, Sem).

pp(pp(Prep, NP), Sem) -->
prep(Prep),
np(NP, Sem).

vp(vp(is, Adj_P), Sem, Agent) -->
[is],
adj_phrase(Adj_P, Sem),
{ functor(Sem, _, 1),
arg(1, Sem, Agent) }.

vp(vp(is, NP, PP), Sem, Agent) -->
[is],
np(NP, Sem),
pp(PP, Patient),
{ functor(Sem, _, 2),
arg(1, Sem, Agent),
arg(2, Sem, Patient) }.

adj_phrase(adj_p(NP), Sem) -->
np(NP, Sem).
adj_phrase(adj_p(Adj), Sem) -->
adj(Adj, Sem).

adj(adj(female), female(_)) -->
[female].
adj(adj(male), male(_)) -->
[male].

det(det(a)) -->
[a].
det(det(the)) -->
[the].

noun(noun(parent), parent(_, _)) -->
[parent].

prep(prep(of)) -->
[of].

run :-
write('Input text: '),
read(Text),
nl,
s(Tree, Sem, Text, []),
write('Syntax: '),
write(Tree),
nl,
write('Semantics: '),
write(Sem),
nl,
add(Sem, 'user input'),
nl,
run.

Program 9.4 - code for running pre-prepared examples and two examples.

The examples are based on the family relations of the Tudor kings and queens of England. No guarantee is given of accuracy as the examples have been devised from memory - in the absence of a suitable family tree.

The top-level predicate is run/1.where the argument is the identifier of a group of queries, eg:

run(Text) :-
write('Input text: '),
write(Text),
nl,
s(Tree, Sem, Text, []),
tab(5),
write('Syntax: '),
write(Tree),
nl,
tab(5),
write('Semantics: '),
write(Sem),
nl,
add(Sem, 'user input'),
nl.

example(Corpus) :-
findall(Text, text(Corpus, Text), Texts),
process_texts(Texts).

process_texts([]).
process_texts([Head|Tail]) :-
run(Head),
process_texts(Tail).

text(1, [henry8, is, male]).
text(1, [henry8, is, a, parent, of, mary]).

text(2, [henry8, is, male]).
text(2, [catherine_of_aragon, is, female]).
text(2, [ann_boleyn, is, female]).
text(2, [catherine_parr, is, female]).
text(2, [elizabeth, is, female]).
text(2, [mary, is, female]).
text(2, [edward, is, male]).
text(2, [henry8, is, a, parent, of, mary]).
text(2, [henry8, is, a, parent, of, elizabeth]).
text(2, [henry8, is, a, parent, of, edward]).
text(2, [catherine_of_aragon, is, a, parent, of, mary]).
text(2, [ann_boleyn, is, a, parent, of, elizabeth]).
text(2, [catherine_parr, is, a, parent, of, edward]).


Lecture 10

Program 10.1 - a Prolog program for solving a puzzle


/* ************************************************ */
/* */
/* board/3 */
/* Arg 1: board as a structured object */
/* Arg 2: board as a list */
/* Arg 3: board as a list of rows, columns */
/* and groups of squares */
/* Summary: Represents the board in several ways */
/* to aid processing. Note the use of */
/* shared variables to ensure that the */
/* instantiation of a variable in one */
/* argument of board/3 instantiates the */
/* all instances of the variable. */
/* Author: P J Hancox */
/* Date: 27 November 2004 */
/* */
/* ************************************************ */

board(square(A1, A2, A3, A4, A5, A6,
B1, B2, B3, B4, B5, B6,
C1, C2, C3, C4, C5, C6,
D1, D2, D3, D4, D5, D6,
E1, E2, E3, E4, E5, E6,
F1, F2, F3, F4, F5, F6),
square([A1, A2, A3, A4, A5, A6,
B1, B2, B3, B4, B5, B6,
C1, C2, C3, C4, C5, C6,
D1, D2, D3, D4, D5, D6,
E1, E2, E3, E4, E5, E6,
F1, F2, F3, F4, F5, F6]),
sizes([ % rows
six(A1, A2, A3, A4, A5, A6),
six(B1, B2, B3, B4, B5, B6),
six(C1, C2, C3, C4, C5, C6),
six(D1, D2, D3, D4, D5, D6),
six(E1, E2, E3, E4, E5, E6),
six(F1, F2, F3, F4, F5, F6),

% columns
six(A1, B1, C1, D1, E1, F1),
six(A2, B2, C2, D2, E2, F2),
six(A3, B3, C3, D3, E3, F3),
six(A4, B4, C4, D4, E4, F4),
six(A5, B5, C5, D5, E5, F5),
six(A6, B6, C6, D6, E6, F6d),

% groups
six(A1, A2, A3, A4, B2, C2),
six(A5, A6, B3, B4, B5, C3),
six(B1, C1, D1, D2, D3, E2),
six(B6, C4, C5, C6, D6, E6),
six(D4, D5, E5, F4, F5, F6),
six(E1, E3, E4, F1, F2, F3)])).


/* ************************************************ */
/* */
/* candidates/1 */
/* Arg 1: list of candidates */
/* Summary: Candidates may be used to fill */
/* squares. */
/* Author: P J Hancox */
/* Date: 27 November 2004 */
/* */
/* ************************************************ */

candidates([1,2,3,4,5,6]).


/* ************************************************ */
/* */
/* solve/0 */
/* Summary: Generates and tests solutions to the */
/* puzzle, outputing successful */
/* solutions. */
/* Author: P J Hancox */
/* Date: 27 November 2004 */
/* */
/* ************************************************ */

solve :-
board(Display_Square, square(Square), sizes(Sixes)),
candidates(Candidates),
generate(Square, Candidates),
display_board(Display_Square),

test(Sixes),
display_board(Display_Square).


/* ************************************************ */
/* */
/* generate/2 */
/* Arg 1: list of squares on the board */
/* Arg 2: list of candidates */
/* Summary: Fills squares on the board to */
/* generate possible solutions. */
/* Author: P J Hancox */
/* Date: 27 November 2004 */
/* */
/* ************************************************ */

% 1 - terminating
generate([], _Candiates).
% 2 - recursive
generate([Square|Squares], Candiates) :-
member(Square, Candiates),
generate(Squares, Candiates).


/* ************************************************ */
/* */
/* test/1 */
/* Arg 1: list of rows, columns and groups of */
/* squares on the board */
/* Summary: Tests lines of six squares to ensure */
/* the squares are unique. */
/* Author: P J Hancox */
/* Date: 27 November 2004 */
/* */
/* ************************************************ */

% 1 - terminating
test([]).
% 2 - recursive
test([Six|Sixes]) :-
test_six(Six),
test(Sixes).


/* ************************************************ */
/* */
/* test/1 */
/* Arg 1: a row, column or group of squares */
/* Summary: Tests line of six squares to ensure */
/* the squares are unique. */
/* Author: P J Hancox */
/* Date: 27 November 2004 */
/* */
/* ************************************************ */

test_six(six(Sq1, Sq2, Sq3, Sq4, Sq5, Sq6)) :-
Sq1 =\= Sq2,
Sq1 =\= Sq3,
Sq1 =\= Sq4,
Sq1 =\= Sq5,
Sq1 =\= Sq6,
Sq2 =\= Sq3,
Sq2 =\= Sq4,
Sq2 =\= Sq5,
Sq2 =\= Sq6,
Sq3 =\= Sq4,
Sq3 =\= Sq5,
Sq3 =\= Sq6,
Sq4 =\= Sq5,
Sq4 =\= Sq6,
Sq5 =\= Sq6.


/* ************************************************ */
/* */
/* display_board/1 */
/* Arg 1: board as a structured object */
/* Summary: Displays the board. */
/* Author: P J Hancox */
/* Date: 27 November 2004 */
/* */
/* ************************************************ */

display_board(Board) :-
display_board(0, Board).


/* ************************************************ */
/* */
/* display_board/1 */
/* Arg 1: counter */
/* Arg 2: board as a structured object */
/* Summary: Displays the board. */
/* Author: P J Hancox */
/* Date: 27 November 2004 */
/* */
/* ************************************************ */

% 1 - terminating
display_board(36, _Board) :-
nl, nl.
% 2 - recursive
display_board(Index, Board) :-
Index < 36,
Index1 is Index + 1,
arg(Index1, Board, Cell),
display_square(Index1, Cell),
display_board(Index1, Board).


/* ************************************************ */
/* */
/* display_square/1 */
/* Arg 1: counter */
/* Arg 2: individual square of the board */
/* Summary: Displays an individual square and, if */
/* it is the 6th square of a row, moves */
/* to a new line. */
/* Author: P J Hancox */
/* Date: 27 November 2004 */
/* */
/* ************************************************ */

display_square(Index, Square) :-
( nonvar(Square) ->
write(' '), write(Square), write(' ')
;
write(' ')
),
( (Index) // 6 =:= (Index)/6 ->
nl
;
true
).


/* ************************************************ */
/* */
/* member/2 */
/* */
/* ************************************************ */

% 1 - terminating
member(Term, [Term|_]).
% 2 - recursive
member(Term, [_|Tail]) :-
member(Term, Tail).


/* ************************************************ */
/* */
/* End of program */
/* */
/* ************************************************ */

Program 10.2 - CLP(R) and Prolog programs for converting Celsius and Fahrenheit

:- ensure_loaded(library(clpr)).


/* ************************************************ */
/* */
/* convert_clpr/2 */
/* Arg 1: temperature in degrees Celsius */
/* Arg 2: temperature in degrees Fahrenheit */
/* Summary: Converts between Celsius and */
/* Fahrenheit. */
/* Author: P J Hancox */
/* Date: 27 November 2004 */
/* */
/* ************************************************ */

convert_clpr(Celsius, Fahrenheit) :-
{ Celsius = (Fahrenheit - 32) * 5 / 9 }.


/* ************************************************ */
/* */
/* convert_pl/2 */
/* Arg 1: temperature in degrees Celsius */
/* Arg 2: temperature in degrees Fahrenheit */
/* Summary: Converts Fahrenheit into Celsius. */
/* Author: P J Hancox */
/* Date: 27 November 2004 */
/* */
/* ************************************************ */

convert_pl(Celsius, Fahrenheit) :-
Celsius is (Fahrenheit - 32) * 5 / 9.


/* ************************************************ */
/* */
/* End of program */
/* */
/* ************************************************ */

Program 10.3 - CLP(FD) program for solving a puzzle

:- ensure_loaded(library(clpfd)).


/* ************************************************ */
/* */
/* board/1 */
/* Arg 1: board as a structured object */
/* Summary: Define the domains of the variables */
/* representing the board; imposes */
/* constraints on these variables; */
/* generates the solutions by */
/* "labelling". */
/* Author: P J Hancox */
/* Date: 27 November 2004 */
/* */
/* ************************************************ */

board(square(A1, A2, A3, A4, A5, A6,
B1, B2, B3, B4, B5, B6,
C1, C2, C3, C4, C5, C6,
D1, D2, D3, D4, D5, D6,
E1, E2, E3, E4, E5, E6,
F1, F2, F3, F4, F5, F6)) :-

A1 #= 1,
B3 #= 1,
B6 #= 3,
C3 #= 2,
D6 #= 2,
E1 #= 3,
E2 #= 6,
F3 #= 4,
F5 #= 5,

% define the domain - ordered by rows
domain([A1, A2, A3, A4, A5, A6,
B1, B2, B3, B4, B5, B6,
C1, C2, C3, C4, C5, C6,
D1, D2, D3, D4, D5, D6,
E1, E2, E3, E4, E5, E6,
F1, F2, F3, F4, F5, F6], 1, 6),

% impose constraints on rows
all_different([A1, A2, A3, A4, A5, A6]),
all_different([B1, B2, B3, B4, B5, B6]),
all_different([C1, C2, C3, C4, C5, C6]),
all_different([D1, D2, D3, D4, D5, D6]),
all_different([E1, E2, E3, E4, E5, E6]),
all_different([F1, F2, F3, F4, F5, F6]),

% impose constraints on columns
all_different([A1, B1, C1, D1, E1, F1]),
all_different([A2, B2, C2, D2, E2, F2]),
all_different([A3, B3, C3, D3, E3, F3]),
all_different([A4, B4, C4, D4, E4, F4]),
all_different([A5, B5, C5, D5, E5, F5]),
all_different([A6, B6, C6, D6, E6, F6]),

% impose constraints on groups
% groups could be constrained as with rows and columns,
% but this is an alternative (longer) way of imposing constraints
A1 #\= A2, A1 #\= A3, A1 #\= A4, A1 #\= B2, A1 #\= C2,
A2 #\= A3, A2 #\= A4, A2 #\= B2, A2 #\= C2,
A3 #\= A4, A3 #\= B2, A3 #\= C2,
A4 #\= B2, A4 #\= C2,
B2 #\= C2,

A5 #\= A6, A5 #\= B3, A5 #\= B4, A5 #\= B5, A5 #\= C3,
A6 #\= B3, A6 #\= B4, A6 #\= B5, A6 #\= C3,
B3 #\= B4, B3 #\= B5, B3 #\= C3,
B4 #\= B5, B4 #\= C3,
B5 #\= C3,

B1 #\= C1, B1 #\= D1, B1 #\= D2, B1 #\= D3, B1 #\= E2,
C1 #\= D1, C1 #\= D2, C1 #\= D3, C1 #\= E2,
D1 #\= D2, D1 #\= D3, D1 #\= E2,
D2 #\= D3, D2 #\= E2,
D3 #\= E2,

B6 #\= C4, B6 #\= C5, B6 #\= C6, B6 #\= D6, B6 #\= E6,
C4 #\= C5, C4 #\= C6, C4 #\= D6, C4 #\= E6,
C5 #\= C6, C5 #\= D6, C5 #\= E6,
C6 #\= D6, C6 #\= E6,
D6 #\= E6,

D4 #\= D5, D4 #\= E5, D4 #\= F4, D4 #\= F5, D4 #\= F6,
D5 #\= E5, D5 #\= F4, D5 #\= F5, D5 #\= F6,
E5 #\= F4, E5 #\= F5, E5 #\= F6,
F4 #\= F5, F4 #\= F6,
F5 #\= F6,

E1 #\= E3, E1 #\= E4, E1 #\= F1, E1 #\= F2, E1 #\= F3,
E3 #\= E4, E3 #\= F1, E3 #\= F2, E3 #\= F3,
E4 #\= F1, E4 #\= F2, E4 #\= F3,
F1 #\= F2, F1 #\= F3,
F2 #\= F3,

% generate the solution by labelling
labeling([], [A1, A2, A3, A4, A5, A6]),
labeling([], [B1, B2, B3, B4, B5, B6]),
labeling([], [C1, C2, C3, C4, C5, C6]),
labeling([], [D1, D2, D3, D4, D5, D6]),
labeling([], [E1, E2, E3, E4, E5, E6]),
labeling([], [F1, F2, F3, F4, F5, F6]).


/* ************************************************ */
/* */
/* solve/0 */
/* Summary: Constrains and generates solutions to */
/* the puzzle, outputing successful */
/* solutions. */
/* Author: P J Hancox */
/* Date: 27 November 2004 */
/* */
/* ************************************************ */

solve :-
board(Square),
display_board(Square).


/* ************************************************ */
/* */
/* display_board/1 */
/* Arg 1: board as a structured object */
/* Summary: Displays the board. */
/* Author: P J Hancox */
/* Date: 27 November 2004 */
/* */
/* ************************************************ */

display_board(Board) :-
display_board(0, Board).


/* ************************************************ */
/* */
/* display_board/1 */
/* Arg 1: counter */
/* Arg 2: board as a structured object */
/* Summary: Displays the board. */
/* Author: P J Hancox */
/* Date: 27 November 2004 */
/* */
/* ************************************************ */

% 1 - terminating
display_board(36, _Board) :-
nl, nl.
% 2 - recursive
display_board(Index, Board) :-
Index < 36,
Index1 is Index + 1,
arg(Index1, Board, Cell),
display_square(Index1, Cell),
display_board(Index1, Board).


/* ************************************************ */
/* */
/* display_square/1 */
/* Arg 1: counter */
/* Arg 2: individual square of the board */
/* Summary: Displays an individual square and, if */
/* it is the 6th square of a row, moves */
/* to a new line. */
/* Author: P J Hancox */
/* Date: 27 November 2004 */
/* */
/* ************************************************ */

display_square(Index, Square) :-
( nonvar(Square) ->
write(' '), write(Square), write(' ')
;
write(' ')
),
( (Index) // 6 =:= (Index)/6 ->
nl
;
true
).


/* ************************************************ */
/* */
/* End of program */
/* */
/* ************************************************ */