Friday, October 07, 2005

This is an implementation of the Mini Kanren logic system for the CLR. This was done last night, so you can take it with a pinch of salt. It does not cover the full set of constructs that original MK system covers. Here is a overly simplified introduction to miniknaren.

 

This implementation is done in Cw, the experimental language from MSR. You will need the COmega compiler if you wish to compile the source.  

 

This implementation covers the basic ‘run’, ‘all’ and ‘conde’ constructs. You do not need a ‘fresh’ because I use the Cw type system and scoping to give me the equivalent of fresh. MiniKanren is implemented as an embedded language in scheme – so you get to do relational programming and then drop into scheme’s functional host language as need be. Since this implementation runs over Cw, this extends and hence you get a combination of a declarative logic programming system on top of everything that is Cw.

 

I am considering adding some more constructs and maybe a relational arithmetic system. I am also considering extending Cw syntax using an external precompiler so that it becomes as little more natural to write relational programs. The present ‘syntactic beauty’ is well a little lacking..

 

All that said, here are the sources from last night.

 

q = new Var();

a = new Var();

b = new Var();

c = new Var();

 

res = Mk.run( q,

      Mk.eq( q, new object[]{ a, b}),

      Mk.eq( a, c ),

      Mk.eq( c, 10),

      Mk.conde(

            new goal[]{ Mk.eq(b, 5) },

            new goal[]{ Mk.eq(b, 10) },

            new goal[]{ Mk.eq(b, 20) },

            new goal[]{ Mk.eq(b, 25) },

            new goal[]{ Mk.eq(a, 50) }

      ));

 

//res is the potentially infinite lazy evaluated set                            

r  = res.{ return Var.ToString( it ); };

r.{ Console.WriteLine( it ); };

 

A logic programming system is a great way to implement solutions to several kinds of problems like dependency analysis, all searching any relational space (ex: A Type Discipline for Authorization Policies)

 

Disclaimer:

(I am not responsible for your divergences).

(I am also not responsible for any halting problems with your compilation process).

(The full credit of MK goes to its original authors. This implementation is merely a transliteration with a certain imperative flavor added).

Friday, October 07, 2005 1:45:47 PM (Eastern Standard Time, UTC-05:00)  #    Comments [4]  | 
 Wednesday, October 05, 2005

Its been a little over a month at IU and the experience has been overwhelming. As has been since when I can remember I have gotten myself involved in more things than I can handle – which is another way of saying that things have been fun, atleast when I am able to keep up with them.

Like Hogwarts, the university is dotted with signs of greatness from antiquity. And every once in a while you come across some one who can do things to your mundane set of ideas that is no lesser than of Gandalf.

iu-4.jpg iu-2.jpg iu-5.jpg 

iu-3.jpg iu-1.jpg
Pictures from around the Indiana University Campus

I have been hit by some hard ideas and fortunately I had been preparing my mind for a while to handle these – had I not and had I tried to absorb them at the same rate now, I might have been in for some hardship.

lindley_hall.jpg
Lindley Hall, Computer Science Dept

 I have formally enrolled for Operating Systems by Andrew Lumsdaine, Programming Languages by Dan Friedman and Quantum Programming by Amr Sabry.

OS is primarily to scratch an old itch – because of that incomplete OS I left behind in college – this course gets to complete is half done os161 kernel – so there is a lots of traditional C programming there.

Programming Languages essentially covers the whole of ‘Essentials of Programming Languages’ with Prof Friedman saying things like ‘I will let you know when you need to think’, on day one. Most of us are thinking pretty hard already. This year the course also covers the new logic system he worked on with Will Byrd and Oleg Kiselyov called Mini-Kanren (source-forge is not as updated as it should be). This also forms the basis for his third ‘little’ book – The Reasoned Schemer.  

Quantum Programming is … well a course about magic – it’s a huge thinking exercise about creating a model of computation for possible ‘quantum machines’. I will not venture to say much more here, except drop a link to an introductory paper.

OS and PL are supposed to be among the hardest courses in the CS department, many people don’t advice taking them both together. To put things in perspective, I am finding QP the hardest simply because of the breadth of the computer science from which the ideas in QP are coming from. The present state of QP is a little like the state of classical computing in the times of Church and Turing.

kirkwood.jpg iu-7.jpg
Kirkwood Hall and the walkway by Lindley

That aside, I am looking into some of these things as of right now (this is not a complete list)
-        join calculus, pi calculus and other process calculi
-        squiggol (Bird and Meertens formalism)
-        quantum circuits
-        grokking functional programming Haskell-style
-        logic programming

imu.jpg

All of this aside, Bloomington is a beautiful place - small university town with lots of charm and a pleasant weather (for now). I am told that this place has bad winters with lots of snow.

bloomington3.jpg bloomington2.jpg

bloomington1.jpg

I have a small single bedroom apartment that is a ~12 min walk from the university.

univ.JPG
The red square is Lindley Hall, the main CS department building and the green square is my apartment.
(Courtesy: Google Earth)

And among other things, I have a new weapon – its called Qubit. Qubit is a Dell Inspiron 9300, UXGA 17” monitor, with 1Gb ram, 256 mb Nvidia Geforce 6800 graphics card and a dual layer Dvd writer. 

iu-6.jpg

Wednesday, October 05, 2005 10:34:17 PM (Eastern Standard Time, UTC-05:00)  #    Comments [9]  | 
 Tuesday, August 09, 2005

cheers!

Tuesday, August 09, 2005 7:11:33 AM (Eastern Standard Time, UTC-05:00)  #    Comments [14]  | 
 Friday, August 05, 2005

Yay! Finally the search bots gave us a honorary indexing. :)
Hopefully most of the damage due to the url change will be undone soon.

Friday, August 05, 2005 12:37:12 PM (Eastern Standard Time, UTC-05:00)  #    Comments [1]  | 
 Monday, August 01, 2005

I just finished reading Erik Meijer and Peter Drayton’s work-in-progress paper on programming languages and type systems. The paper as correctly noted in the beginning is written-to-provoke and I think this line of work is required today when technologies like .Net and the JVM have opened up possibilities of experimenting with languages and language systems and potentially reduced barriers for acceptance of new languages. The value proposition the expressiveness of a new language provides can be more readily accepted today in frameworks like .Net where a programmers existing knowledge/use of an API and an existing code base will not be lost by switching over to the new language.

 

The paper touches a large variety of topics and is more in brain dump of thoughts around the general area of type systems in dynamic and static languages. They also have some very interesting pointers and references.

 

The papers discusses type inference, programming by contract as opposed to having the type system as the only means of contract, subtyping and potentially expressing subtyping as programming by contract, type-directed lifting in Cw and how that can be used as opposed to non-intuitive reflective code.

 

The paper talks mentions the SqlDataReader – even if you don’t grok anything else in the paper, try and understand this part and try and see the need to a better programming language model – especially if you have ever worked on the data tier or business logic tier of an n-tier data centric application.

 

The paper also mentions lazy evaluation and about potentially deprecating the need for using eval if you have a better system in place for most of the common uses of eval.

 

On the whole it’s a paper that worth your time if you have started thinking about why when using C++ its so damn hard to get anything right, why C# cant be a little more flexible when handling collections, XML like or SQL like data and why languages like your pet python or ruby don’t make the mainstream.

 

http://pico.vub.ac.be/~wdmeuter/RDL04/papers/Meijer.pdf

Monday, August 01, 2005 2:30:34 PM (Eastern Standard Time, UTC-05:00)  #    Comments [3]  | 

I had been to my native place at Pala and Karimanoor this weekend. It was a nice drive along hilly country with lots of heavy downpour to give us company. The country side in Kerala is beautiful. It is probably one of the most abundant states in India with respect to flora and fauna.

 

Here is the gallery:

Gallery\Kerala1

 

 

I am beginning to get an edgy feel about this whole photo gallery business. It doesn’t scale too well, wrt managing lots of galleries over time and I am not classifying the pictures well enough. Hmm…
Monday, August 01, 2005 11:15:19 AM (Eastern Standard Time, UTC-05:00)  #    Comments [7]  | 
 Tuesday, July 26, 2005

Tried my hand at creating some sort of a photo gallery today. I updated the old image resizing progie so that it can draw borders and respect proportion when resizing images. I also wrote a ruby script that can generate an html gallery when it is pointed at a folder that has images and a description text file.

 

Download the updated image-resizing program, source code and ruby script here. The binary is .Net 2.0 Beta2. This is the previous blog entry about the image-resizing program.

 

That said here are two galleries I have uploaded:

Marine Drive, Cochin

Golconda Fort, Hyderabad

 

It’s fun to be blogging again and its fun to have access to your machine and the web at night. I also realize that if I keep at this I am going to run out of space with my ISP and others at TMS aren’t going to be happy. I will need to solve the web space problem…
Tuesday, July 26, 2005 2:00:16 PM (Eastern Standard Time, UTC-05:00)  #    Comments [2]  | 
 Monday, July 25, 2005

Now that I am at home I needed to start cataloging my data and getting things in order before I move on. I spent some time yesterday writing a small app to help catalog my CDs. I had a look around but most CD cataloging apps I could find were paid apps.

 

cdScan.jpg

 

CdScan scans the CDs and lets you do a simple substring search (a little like the old Winamp J option) and also gives you an explorer kind of view of your CDs.

 

Its got a nifty little auto-scan option where you can simply set it to autoscan and keep changing CDs in your drive.

 

There are a whole host of features I can think of adding, but you might want to grab hold of it and use it to catalog your Cds and maybe add a feature or two (since I am giving away source code).

 

Download Binary: cdscan_binary.zip (250.75 KB)

Download Source Code: cdscan_source.zip (268.43 KB)

This is written using .Net 2.0 Beta 2, so you need at least the Beta2 runtime to get the binary to work.

 

Here are a lot of things I can think of adding, maybe you can add them for me –

-          wildcard and regex based searching

-          a more flexible explorer view

-          save more data for an item (EXIF data, Thumbnails, Text index)

-          more intuitive UI, with some helpful text messages…

Monday, July 25, 2005 8:45:48 AM (Eastern Standard Time, UTC-05:00)  #    Comments [5]  |