Older blog entries for tampe (starting at number 99)

And so we unify the universes and continues just as before

How cool it is to have fun and do something useful. Well at least on the paper. My main focus for some time is to learn scheme and help out for that community. It's a really nice experience - thanks for that.

Anyhow I just entered a new project on Advogato - guile unify - which is may latest contribution. I've been hacking on it for some months, and feel that it got some interesting twists. so what is it?. Well it's exploring the combination of scheme and prolog.

One of the unique features of scheme that have etched its pattern in my brain is continuations - mainly because it was so hard to grok that call/cc stuff when I first encountered it. And this is a really interesting combination to breed in this marriage between a schemer and a prologur.

prolog is a combination of a variable stack, tree search, and unifying matches. To introduce continuations one probably end up with needing redo trees. A path from the root of the tree out to a leaf is passing variable "set commands" in such a way that the state of variable stack is restored from a blank base setup at the leaf, where a closure is found ready to take a continuation action. By making a tree one can save some on memory and perhaps also on time. Got this working and prompted me give the project some light.

Now, actually I'm lying. Pure continuation will come, but I'm targeted the method for a limited kind of continuation. e.g. a postpone command.

Consider writing a chess solver. Now you build up state information in various structures as you go and would like to use that information to draw strategic conclusions for a certain move. You may want to cut unstrategic moves, right! Well actually this may be prompting the developer to do a lot of tuning to get correct. So an interesting idea is to store the state of the game, save that continuation on a list and continue with that list if resources are available. This approach is more adaptive and probably lead to less tuning for the developer. To note is that storing this state for millions of continuations can put a severe strain on memory and also raise the complexity of the continuation. So that's why compress all the information in a redo tree very much like saving a word lexicon effectively may be interesting - actually, i don't now about this, I just made it work!! and it was great fun and a challenge to do it.

Consider trying to logically prove a statement. Could be cool to try to search for a small and elegant solution before trying those infinite paths. So just monitor stack usage and postpone at the points where stack reaches above a level, and continue to the next level if needed then on. Just write the usual prolog stuff and insert a few commands and you will have it. Nah not implemented but hey look at.

An example in prolog comes here,

prun() :- L = [[[5],2],1,[3,4]],
          X is 0,

f([H|L],N) :- !, postpone, N is N + 1, g(H,L,N). f(H,N) :- pk([H,N]), fail. g(H,L,N) :- f(H,N). g(_,[H|L],N) :- g(H,L,N). g(_,[],_) :- fail.

And entering prun leads to the sequence

(1 1),(2 2),(3 2),(4,2),(5,3)
Yea, trivial, but it shows how simple to code it. Now it's actually trivial to make a stack size criteria that will be a nice hack to try just to see if it improves.

Oh, The speed is not to bad and it is taking advantage of tail calls, prompt logic and CPS. Turns out CPS is not bad for speed - but do affect it.

Now, entering true continuation is just a matter of hard work. I will need to write a special GC for this structure because, the data-structure is tuned to be good at the scenario above and true continuation will be a cool creature, but a second citizen in my view that need some caring.

I will try to find time to talk a little more about the internals of all this. Maybe it's all a nice sand castle, maybe it is severely cool. Time will tell. I will continue to hack on it. If you have any questions or would like to learn or help, join the guile devel community and ask about guile unify.



2 Jan 2010 (updated 16 Jan 2011 at 07:04 UTC) »

I ended the last sequence of blogs about exploring looping, then basically stopped and started to learn about type theory and prolog using Qi.

right now I working with this engine to write a type system that works pretty much like lisp type system e.g. if we can deduce type, then use it! This type-engine will be used to compile Qi to lisp/clojure/scheme/go? or whatever lisp like environment you got.


1 Jan 2010 (updated 16 Jan 2011 at 07:06 UTC) »

A new year.

Well every Christmas I spend some time on thinking about space and some ideas form, it's a fun and entertaining game. maybe not correct thoughts, but entertaining. Now the new year starts and it is back to business with computer quizzes instead of trying to find the dream of Einstein. Anyhow I made a small document describing my (well you never now, people tend to independently walk the same paths) view of how the world is constructed.

I promise, no more of this, until next Christmas.


We have the right to think, correct or not, and if in a world of only correctness, you will simply drown in mathematics and never learn to swim it.


29 Dec 2009 (updated 16 Jan 2011 at 07:17 UTC) »
Christmas days, thinking differently

I spend this Christmas, reading Simon Sings Big Bang. And as Simon pretty much says, I say as well, what a wonderful world.

I'm mentally affected by my education that I constantly ask myself if the things that is presented in a popularizing book is really what is true. Did he mean that. Sure people turn things int a better daylight when asked about it afterwords and so on. There is a constant flow on my mentally left margain. Anyhow I'm now really impressed by the puzzle that scientist made to achieve such a solid ground for the Big Bang theory.

There is always weak spots in an arguments but the core argument is really solid in my view.

I like the formulation that uses the potential formulation under the Lorenz gauge if I remember everything correctly. Then all components follow a wave equation and there is one linear first order constraints that look close to a simple continuity equations. Now I wanted to understand what this actually meant and searched for some example that would reveal that to me. And there is one telling partial solution. You could have a solution where you make the constraint a continuity equation. You will have a sort of "magnitude of disturbance field" in the scalar potential and the vector potential will be a sort of momentum potential e.g. the scalar potential times a velocity field of constant velocity c. It's a really trivial and very particular solution. But you can modify it. You can assume that if along a direction you have the same disturbance, then you can choose any velocity you like.

Now, in my view this captures some essential features of electromagnetism. A constant stream of light is not dependent of the speed of the stream and it is information that is constrained to the speed of light. Not necessary the actual physical or disturbance transport.

Note that if we have just one stream the transversal direction has to be transported with the speed of light and indicate plane waves.

Even if this is a simple particular solution. One would probably be able to deduce Maxwell's equations after closing the space using Lorenz transforms

Ok this is just a mathematical play, but it poses from my position of knowledge very interesting question. It's just some speculation from a guy that is not an expert. But I still hope that I've teased your imagination so please have fun, play with the mathematics, enjoy the stars and have a very happy hacking new year.

22 Nov 2009 (updated 16 Jan 2011 at 07:20 UTC) »

Exploring,Fighting and Enjoying

I'm coding on a library called BoopCore right now. The reason is that I was thinking about how to make the code for the new version of Qi, called Shen.

Oh, I did a small test with the Einstein riddle. Got basically the same speed as gprolog so the "prolog" compiling part is not too bad.

My idea though is that it should be used by designers of PL tools and for people with specific needs. As an example backtracking and unification can be really customized and fast.

The program itself is pure magic, e.g. has some really poor design. But this is ok for a first version. That version has to have all the features, which is not decided from the beginning, but grows as bugs are found and new features has to be implemented. This means I am Exploring ideas, Fighting the beast to get them implemented but throughout the whole process, enjoy it as if it was the best wine in the world.


Type Type and Type And this is what I get

I have been quite for some time here, work is calling, family is calling and a new version of Qi ready to be explored was released. Now in the mean time I have been studying the sequent calculus and the Qi source code to learn how to mod it to my taste.

So perhaps my coolest hack is a type driven macro framework. So a little code,

(def-tp-macro ex1
   X                  : A  -> (? Usage number) 
   where (ask? Usage)

[X : num Y : num] : A -> (simple-num-num X Y) where (element? simple Usage)

[X : num Y : str] : A -> (simple-num-str X Y) where (element? simple Usage)

[X : num Y : num] : A -> (complex-num-num X Y) where (element? complex Usage)

[X : num Y : str] : A -> (complex-num-str X Y) where (element? complex Usage))

The first line says that at any kind of arguments and type of evaluation context first ask for it usage and the return values will be stored in Usage. This will send out the type-system to track usages according to some mechanism, this is done the first time. The next time if not inhibited (ask? Usage) will be negative and the system goes down to expand according to function signature and the properties of the The Value of Usage. In (? Usage T), T is the type that is returned from the function in the non ask context, e.g. (+ (ex1 X1 Y1) (ex1 X2 Y2)) should type-check!!

It works stupidly by type-checking repeatedly and whenever something is asked for a retry is done. A process that can be made much more effective by remembering the type deduction and use this memory at nonvolatile sites in the deduction tree a property that somehow has to be passed up the deduction tree. Anyway (ask? Usage) will be true if someone later in the deduction have inhibited it. Such if a ex1 value is used in the argument of ex2 that also asks for information in this case ex2 inhibits ex1 when it asks for information. (To speed up this deduction process ex1 should be marked as nonvolatile)

Actually macros can work on code fragments like this

(def-tr-macro ex3
  [adv [X : number Y : str] Z : symbol] : A -> [Z X]
This is a quite general construct and of cause the process of macro-expansion, usage information exchange and so on can be repeated recursively.

So the macro can use information how the result of the form is used later on in the code and under what signature the type-system thinks that this form will be evaluated under. So there is a message system that works in both directions in the code graph (what signals do I get from the arguments and what context or what features of what I provide is used.

There are weak points to this construct but I think now have one big chunk that can be put to use when I go deep into optimizations of loop macros. At least I now have a powerful tool to do optimizations by using the computer as much as possible and my coding fingers as little as possibly

1 Jan 2009 (updated 16 Jan 2011 at 07:36 UTC) »

The number of dimensions are, well infinite

I have a standard prediction of a science breakthrough that comes after having studied the standard model.

In the standard model of physics they combine all natural forces but gravity in one formulation. The basic building block there seems to be fields that have properties that comes from the Yang Mills and Pauli theory. To understand the standard model it is good to think about what Yang Mills and Pauli try to describe. I played around with it a little got an understanding. It feels like these fields describe disturbances in a kind of ray fluid.

Lets move some atoms

11 Dec 2008 (updated 16 Jan 2011 at 07:39 UTC) »

Lets type unit tests

Maybe this is plain stupidity, but hey it's different from the usual path.

If you have full control of the type system, what can we do?

Well type is a flow of information so basically here you have the possibility to do meta tracking.

But lets consider another idea. Assume that we make an abstract class, with no implementation.

(class stack A         Abstract
       (clear )->NIL
       (push A)->NIL
       (pop   )-> A)

This follow sort of the standard specification used in Java C++ C# etc.

Now consider another "concrete" class

(class mycl  A         Impl
       (clear )->NIL
       (push A)->NIL
       (pop   )-> A))

Then typically you subclass mycl from stack and you go. The idea now is that in order to be able to subclass mycl from the abstract class you would have to pass a unit test e.g.

(class mycl) => (class stack) if (stack-unit-test mycl)
Customizing the type theory adding these tests with cashing would be .... different.

As a side note, this is how I view object orientation abstractly. You have a set of code snippets in the form of different function implementations and object orientations just put names on subsets and makes arrows between the snippets, now the process of making subclasses is just rules that makes arrows and rules how to select which code to evaluate or the context to evaluate a function when using one or several name references.

If we all looked nice and same, the ugliest person would become attractive


Words can dance

My day work is calling for serious attention and I had the usual period of being tired. This is sort of strange, but From time to time I need to sleep more. (This public effort of mine is done usually after 21:00 when the rest of the family relax before the TV or is sleeping)

Anyway this means that I do not pay attention on detail right now but spend my spare time gathering inputs, Reading and just think.

I have been playing around with texmacs, mainly trying to see how code look like when you allow for a little more typesetting then your favorite editor. I concluded from this effort how badly needed monospace is. The reason is that I tend to align stuff because things is easier on the brain when you have alignment. This means that the brain will learn to use the difference between two rows in it's visual parsing. Letters not being aligned will just make this activity a pain (to do this make sure your tired, you then notice bad style). On the other hand one feature that makes for better reading is subscript and superscript under monospace. The thing is that it's ok to change the space in a few blocks. Personally I would also like to have a few extra symbols too use while programming then what's common. But this is old stuff, emacs has ok support for this and I've used it for some of my LISP or Qi programming. I don't think that Big Integral and sum operators, square root constructs and fractions is so badly needed for programming that I would like to suggest implementing that in a programming editor. On the other hand the ability to use different decorators of your symbols is attractive if they don't disturb the spaces too much.

So I concluded that decorators, sub/super script that disturb the spaces as little as possible together with unicode symbols would be my favorite typesetting extensions to the common craft of programming.

Let's sleep on it

16 Nov 2008 (updated 16 Nov 2008 at 21:24 UTC) »

You can do everything in assembler

I first want to say that layout manager and such really is something that is old technology and already included in all modern gui's, but it is always good to just focus on a thing and think a little to see if things can be improved.

When drawing diagrams in powerpoint I always get very frustrated. the reason is that I believe that something like a well implementation of the tools found in the TeX community to draw diagrams, would be so much easier (for me). It would be so cool to be able to use the TeX tools to layout stuff in diagramming and gui construction. If you are like me I suggest to read and play with those TeX tools like xy-pic, great fun.

Let me also point out that QP is probably not used because simpler solutions then what I described is probably already implemented. The point using QP is that you can specify that not only X is close to Y, but allow the distance is allowed to vary if there is conflicting constraint(s). It is also a quite general framework if you stick to linear constructs. What I miss is a framework and tools, to handle and develop layout managers. There should simply be a tool for me and others who now the math (perhaps do it using scipy) to develop some great markup framework to do layout of different things. I could imagine it being based of QP and also of cause, as a special case Linear programming. One could think of including other mathematical tools as well like convex programming.

As an example let's discuss about implementing a tool to make sure that the layout has straight left and right margins. We stack a sequence of objects X1,X2,X3..., with a smallest distance d1,d2,d3,.. between X1,X2;X2,X3;..., And we also say that we punish a deviation from di by a coupling constants C1,C2,... basically you could automatically select Ci,di according to the sizes of objects (xy-pic in the TeX world has such ideas in it's layout strategy of diagrams.) Now to specify a conflicting constraint to let the total distance of the sequence to be constant in order to achieve a right margin. You never get an exact right margin, but by adjusting the spaces between words or objects you may make it happen. The good thing using this is that you will always get an answer and depending on measures how well every constraints is satisfied you can decide to remove objects to the next line or include new objects. Also you could fire up guis and let users who want to tweak the coupling constants, do it to adjust the layout.

Finally here is a trick I use to deduce the components in a quadratic criteria x'S'x + v'x + d from other representations without thinking. When I first tried to do this I went for the white board and started to deduce things by hand. well that is not needed. just define a function f(x) that is your definition of the criteria, that is most easy to define. Then use your computer to evaluate f(0), f(ei),i=1,..,n, f(ei+ej) i,j=1,..,n. Using this information you will be able to deduce S and v. I find this a very neat tool. It is written once and will save you ton's of time.

What I fear is that we mostly develop to make things simple for the less advanced users because most users are on that level which means that this is ok. Beeing an advanced user means that you don't get the benefit of most development and that means that you are not 10 times as effective but perhaps only 2 times and you loose.


90 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!