Posts

Showing posts from May, 2006

Got some super power?

You got some super power within you ……. Control it and you gonna get a million dollor… check this out. This entry was posted in Uncategorized . Bookmark the permalink .

Prolog and Definite Clause Grammar

Learning prolog is much more fascinating than what I thought it would be.I just studied how to create a CFG (Context Free Grammar) recognizer in prolog. Even though, you could do it in various methods, the best way is to use DFG(Definite Clause Grammar). DFG can be considered as a simple tool provided by Prolog for encoding CFG. But DFG’s go much beyond that. It is possible to write recognizers for non context free grammars in DFG. In fact DFG’s are syntactic sugar provided by prolog. A recognizer for CFG is a machine (program) which accept all the strings defined by the grammar. Let’s write the grammar for accepting infix expression with operators +,x and numbers 0,1 ie., 1+0, 1*1+0, etc belongs to the language. The grammar can be written as :- E-> T+E|T T-> F*T|F F-> 0,1. So now let us convert this to a DFG. First of all let us define all lexicons ie., +,*,0,1 lex(+,add). lex(*,mul). lex(’0′,f). lex(’1′,f). This means that ...

Prolog programming…

Just  wrote a prolog program to flatten a list. Even though we had done the program in Lisp and Python it was a wonderful experience doing the same in Prolog. Spend about an hour for the program. Really excited at this point… The following is the program. app([], Y, Y). app([H|X], Y, [H|Z]) :- app(X, Y ,Z). flat([], []). flat([H|T],Y) :- flat(H,K), flat(T,L), app(K,L,Y), !. flat(H, [H]) :- not(H = [K]). I am using a gprolog interpreter. The ‘not’ function is not working in my system (any idea why?) and hence wrote my own not function. my_not(X) :- X, !, fail. my_not(_). For those who dont know what flatten is: a = [ 1, [ 2, 3 ], [ [ 4 ], 5 ], 6 ] flat(a) = [1, 2, 3, 4, 5, 6] I am sure that this is not the best solution.  Let me know if you got a much better solutionor any other solution. This entry was posted in Uncategorized . Bookmark the permalink .

Common Sense deviates rreality?

Have you ever felt common sense as an important factor for success. Teachers used to say ‘answer using your common sense.’; does this seem logical. Does our common sense lead to right solutions? In this session let us criticize common sense. Most people have a view of the world derived from the ‘common’ senses ie., they view objects out there in the world by the properties that they appear to us to have. This is known as Naive realism (the world we perceive is the world actually is). Naive realists are the outcome of the resistance of the people to think philosophically. Have you ever thought that the common sense are out there to cheat us? Are these senses misleading us from truth? Are we not perceiving a world which is not the exact one out there? Have you ever felt like all these things out there exist just to make us believe that they exist?. Lets take an example… Have you ever felt the wheel of a fast moving car rotating backwards. Is the wheel reall...