tampe is currently certified at Journeyer level.

Name: Stefan Israelsson Tampe
Member since: 2007-10-09 20:16:39
Last Login: 2014-04-16 16:10:23

FOAF RDF Share This

No personal information is available.

Projects

Recent blog entries by tampe

Syndication: RSS 2.0

guile-log 0.4.1 released

I'm really proud of this release. It sports an implementation of a logic programming environment that's previously had a interface designed by myself and the famous kanren interface that you grok if you read the reasoned schemer. In this release a fairly complete implementation of an iso-prolog have been churn out. That was a huge effort, but the ride was interesting and gave me a lot of new insights in computer programming. This also sports proper namespace handling, proper closures, proper delimited continuation goals. the kanren interleaving constructs, a framework that is enabled by functional data-structures and state handling, vhashes, vlists, and the coolest thing of all you can save state and restore state quite cheaply and seamlessly and with great power if you learn the system. by seamlessly I mean that we do not have proper functional data structures everywhere due to semantic needs in especially accumulators and delimited continuations goals, and the logical variables may also be used in a mutative fashion for two reasons 1. to enable GC of prolog variables. 2 it is maybe 3-4 times faster compared to a vhash based version that is also possible. The vhash version is thread safe (I'm not using guile's internal vhash, but a modded version in C)
Anyhow to seamlessly handle state in all this is really a delicate affair. Cheaply refers to the fact that I tried hard to enable state storage and state retrieval in algorithms meaning that a save is much more intelligent than saving the whole state of the prolog engine. In all I strongly recommend anybody interesting in logic programming to study the features more deeply. I believe there is some good lessons to learn there. And finally by power I mean that the system has designed an internal tool that makes difficult algorithm possible.

Let's play with it


scheme@(guile-user)> ,L prolog
Happy hacking with Prolog! To switch back, type `,L scheme'.
prolog@(guile-user)> .[use-modules (logic guile-log iso-prolog)]
prolog@(guile-user)> .[use-modules (logic guile-log guile-prolog interpreter)]
prolog@(guile-user)> user_set(1,1),stall,user_set(1,2),stall.
stalled
/* We are at the first stall */
prolog@(guile-user)> .h

HELP FOR PROLOG COMMANDS
---------------------------------------------------------------------
(.n ) try to find n solutions
(.all | .* ) try to find all solutions
(.once | .1 ) try to find one solution
(.mute | .m ) no value output is written.
---------------------------------------------------------------------
(.save | .s ) associate current state with name ref
(.load | .l ) restore associate state with name ref
(.cont | .c ) continue the execution from last stall point
(.lold | .lo) restore the last state at a stall
(.clear ) clear the prolog stack and state
---------------------------------------------------------------------
(.ref ) get value of reference user variable ref
(.set ) set user variable ref to value val
---------------------------------------------------------------------
prolog@(guile-user)> .ref 1
$1 = 1
prolog@(guile-user)> .s 1
prolog@(guile-user)> .c
$2 = stalled
/* we are at the second stall */
prolog@(guile-user)> .ref 1
$3 = 2
prolog@(guile-user)> .s 2
prolog@(guile-user)> .c
yesmore (y/n/a) > n
$4 = ()
prolog@(guile-user)> .l 1
prolog@(guile-user)> .ref 1
$5 = 1
prolog@(guile-user)> .l 2
prolog@(guile-user)> .ref 1
$6 = 2
prolog@(guile-user)> .c
yesmore (y/n/a) > n
$7 = ()
prolog@(guile-user)>

To play with it checkout the v0.4.1 tag at guile-log and read the manual at manual

Have fun

Proluguroschlispymindy


I'm soon about to do a new release of guile-log - logic programming in guile scheme. This release sports delimeted continution goals, an iso-prolog interface (it already sports a kanren interface) and much more.

Why guile-log's prolog? Well, for one thing, if you want to program future emacs in prolog, the base is now there. But it do sports a few interesting ideoms of it's own. But also it's possible to treat a prolog module as a scheme module and reuse already written prolog in e.g. a kanren program and of cause vice versa. It has been really tough to match an iso prolog at a reasonable level, but we will probably not have a stable solution until quite a few releases ahead of us. Also there is not much of a community so if you are interested in any of these aspects above please try contact me at the guile-user mailing list.



Anyway this is all for your fun, so have fun!! Cheers!

We know everything, so why are you thinking mooron!

I have blogged a few times about fundamental physic insights, but there is possibly a better source, there is a free thinker regarding how the world is working, he is a heretic, he say that we all got our models backwards, that QM is a huge joke and that the world is much simpler than proclaimed in science shows and Universities throughout the world, or is he just a person that got tricked by a mathematical play, read on for the story.

The background is that for circa 20 years ago Randi Mills, the founder of BlackLightPower published his theory and has refined it ever since. I spend time reading his books and is really intrigued of how badly treated this material is both by himself and the scientific community as a whole. I know that many of you have read about BlackLightPower and the hydrino power they have so often claimed to produce. To be frank I find the hydrinos fishy and after I read his book I can actually point to weaknesses in Mill's proofs of their existence. But folks, hydrinos and antigravity is just a few sidetracks of the theory, that may be false, not because the theory is bad, but because the theory is missing parts and need to be complemented.

So what is the possible mistake of the assumption of a hydrino state. Well What Mills do is taking plain ol elecromagnetism, he set up a foton trapped by varying charge density in a sphere around the photon and than say that the system is a stable state if it does not radiate and deduces mathematically how this charge distribution look like. In Itself manage to do this is a great theoretical task and he should get a golden star for doing that, no one claims his been mathematically wrong in his solution(s). He then calculate the properties of these atoms and find out that it produces the same energy states and levels as normal quantum electrodynamics say. But not only this, he produces extremely accurate results for many body problems for basically all kinds of atoms and many molecules. Of cause Mills has great confidence in the theory after that feat. But now comes the sorrow part that probably shot down the whole effort and maybe have tricked Mills to haunt a gost for 20 years. He finds out states, hydrino states that is
less energetic states below the normal ground state in e.g. hydrogen. We should be able to produce these hydrino states and be able to harvest the energy from normal water basically for ever, welcome new free energy world. Is it so?, well as a mathematician I am picky with 'if' and 'if and only if'

Mills theory is interesting because it can give a very natural explanation how the world is working. Maxwell's equations for electromagnetism is what we call in mathematics linear, this means that we can superpose different solutions on top of each other and produce new solutions. It is also typical solution when disturbances from a steady state is small. So one would expect the Maxwell equations to be invalid for extreme cases where the disturbances are large. So what can happen when the equation breaks?, well one thing is that waves may start reflecting. It is interesting to note that in Mills solution the information flowing part of the solution at the surface is flowing tangential to the surface which is natural because the solution does not radiate. If we assume that it is the information flowing part that get mirrored at the surface we can imagine that the solution is stable if we deform it slightly. The actual dynamics of what happens if we disturb the system slightly is a key part to really say that a system is non radiating. And this analysis is missing in Mills theory of hydrinos. It can happen that these hydrinos will start radiate if it is disturbed a little and then because of this move even further away and then brake, if this is the case then these hydrino states will not be long lived and not represent a physical solution. So a physical solution does not radiate, but all states that does not radiate is not necessary a physical attainable state. So in
order to accept hydrinos I would need an 'if and only if' proof by Mills.

If you read about Mills theory and try to find critics of his theory, you may find:,

Hydrinos cannot exists because bla bla bla. Correct, but that does not invalidate the theory, it must be complemented.

It challanges QM, QM predicts everything quite well, it cannot work. - Well Mills theory is easier to work with and produces impressive results for especially atom physics, So QM and Mills theory are just two mathematical models of the same physics they are dual. Nowone have shown how this can be so, so why aren't bright theoreticians taking the task to explain it.

Mills talk about antigravity as a fifth force, sure it must be a fake. - Well he produces, is it 1500 pages of dense theory sure if you cherry pick, you can find strange things, but most of it seams to be correct.

Andreas Ratke says' his theory is not Lorenz invariant. Well
Andreas is trying to show this by showing that the charge density does not follow the wave equation. Well here is an issue with 'if and only if'. Solutions to the wave equation follows special relativity, but not all solutions to special relativity follows the wave equation, this critique is a really poor work and you can find quite many issues with it in Mills rebuttal to that paper.

In all I would ask any critique to concretely show how the hell Mill's fake all the calculations that is spot on, and not just mumble some abstract critic, that is really missing the point, Mills has by far not finished his work, that task is up to the physics community. Because reading his book all his amazing formulas seams to be based on just his basic assumption and than plain ol electromagnetism, am I right, or did I miss something, read it for yourself, have fun!

References:

wikipedia

the art of memorization


I read a book about human memory and memory techniques. Quite interesting and as an association of that memory I will in this post try to describe a nifty memory trick you can do in stack based prolog like engines.

The task is to make a kind of variable that behaves just like a variable but at a memorization of the current state these are automatically stored. We should try to not store too much information so we will need to have some mechanism that free memory in gc and selectively store stuff according to some intelligent scheme.

So let's start with a basic building block.


(define-syntax with-guarded-states
(lambda (x)
(syntax-case x ()
((_ guard ((s v) ...) code ...)
#'(let ((s v) ... (fr #t) (done #f))
(letrec ((guard (mk-guard *current-stack* fr done guard s ...)))
(dyn
(lambda ()
(set! fr #t)
(set! done #t)
(push-setup
*current-stack*
(lambda ()
(set! done #f))))
(lambda (x) (set! fr #f))
*current-stack*)
(let () code ...)))))))


with-guarded-states take a name for a guard and associate that with a set of variables s ... with initial values v .... The guard is active in the code section and it is a function that is used to set the variable s ... in the wanted manner. in the code we first initiate the variables with the initial value and initiate to flags fr, and done. we then define a guard function with the helper macro mk-guard which semantic will be described later. Then the function put's a dynwind dyn on the prolog stack. a dynwind has essentially two functions, one that is executed when the stack is reinstated and one where the stack is unwinded. Here at unwinding the fr flag is set to #f and at rewinding e.g. recalling a state, fr is set to #t and done is set to #t and we push a setup hook that set done to #f. The setup hook is called after the winding have been finished. the code is then executed in a let environment meaning that we are allowed to start the code with a set of defines. Anyway done is used to make sure we will update just ones if there is a sequence of guards evaluated and fr will mark that we are in the frame of the guarded variables and done will mark that we are hitting the first guarded set! in a wind/unwind.

the mk-guard is essentially the following


(lambda (ss ...)
(let ((so s) ...)
(set! s ss) ...
(dyn
rewind-code
unwind-code)))

So the generated guard will take the new data ss ... and then store the old state in so ..., then set the variables with the new data in (set! s ss) ... and push a dynwind on the stack that represents the memorization of the setting of the variables.
essentially when passing the dynwind in a unwind we will restore the old value, and when passing in a rewind we will restore the new value.

The rewind code and the unwind will be described next, we use,


(begin
(if (and (gp-wind-ref p) (not done))
(begin
(set! done #t)
(push-setup p
(let ((ss s) ...)
(lambda ()
(set! done #f)
(if fr
(guard ss ...)
(begin (set! s ss) ...)))))))
(set! s so) ...))

So here we see the done flag in action, if done is false e.g. it hits the variable for the first time then it will try execute the if, also we need gp-wind-ref to be true, e.g. we are saving the variable values, the if just marks done as #t so we will not do this again if we enters a new guarded set for the same variables. Again we push-setup e.g. put a hook to be executed at the finishing of the wind/unwind. so we store the current variables in ss, the lambda then will undo done and put it to #f, ready to be used at the next wind/unwind, it will then check if we are in the frame of the variable, if so we will make a new guard setting the s to the stored ss. If we have left the frame we will set the s, the net effect is that we have kept the initial value of the guarded variables intact but been able to correctly add, if needed, a guarded to do the correct transformations of the variable if we unwind or rewind over the new guard, in case of leaving the frame of the variables we have still kept the variable value, in case the there are no references to the variables all data will be reclaimed at perhaps the next gc. After the if part is done we simple restore to the old value so.


The code for the wind is very similar, again we will make sure to just execute the first encountered guard. The difference is that fr will always be true here. Also gp-wind-ref will flag if we shall keep the value of the special variable, or if we shall restore the old value. There is a problem with the previous code though one need to make sure not to grow the number of guards as one reinstate the new value, this is an optimization not solved yet, but the wanted semantic should be correct. A solution would be to at re-instation overwrite the last guard/wind refering to the variables to the new one or add a new one. Another optimization is to make sure that we do not add a null guard e.g. one that does not change anything. The deficiencies shown at winding back the stack does not look that good, but in practice the rewind is followed by a unwind what essentially keep the number of guard to say 1 or 2.

So this works pretty well it is not perfected but still a quite cool feature if one does not restore data to the same state to often without backtracking over the guard constructs.

Have fun!

One year of imagination and coding

This year I have accomplish much more than any year before, Maybe not so much is seen in the space of Openly sourced code, but quite a lot have been achieved under the hood. For example I have been studying the guile sources extensively by experimenting compiling guile scheme to native code, and making an rtl compiler. I'm pretty new here and actually not trusted to make such a pillar of a component of guile. I'm pretty fine with that. I really enjoy the programming effort and will of cause use this experience in the open discussions how to churn out these things in the end when the trusted hackers starts hacking. Another reason I do not want to promote my code is because it's learning code, e.g. I'm not that good and experienced programmer to churn these things out to the best degree. The native code works, can be 2-3 times faster then rtl that maybe is 50% than guile-2.0 and it can be made working. But it's not the best you can do!

My approach is simple. Just take a byte code and inline a C-stub that represents that code. Many operations would be just inlining essentially a function call out to a C - stub that does the meaty work. The rest, could be efficiently coded with a few cpu instructions. The fear with this approach is that we will end up with a bloated code that blows the instruction cache. I'm not sure about this, I just observed the number of bytes to encode a simple function was less that encoding it in actual byte code so I do not buy this yet.


Nah the main problem is that I don't take advantage of cpu registers. For example there are JIT engines out there that does register handling so it is important in order to get up in speed. But I wan't the engine to be coded in scheme - which maybe is stupid, but after coding quite a lot of assembler in scheme I'm convinced that getting that functionality into scheme is a boon.

Another big task I have been taken is to make sure guile can compile scheme down to the rtl VM that wingo has coded. It was impossible for me to do that on a clean piece of paper so I took the old compiler to the old VM and molded it into produce RTL VM code instead. Cool, but remember we need to make use of registers! And the rtl vm representation as the old guile VM representation is not optimal to use for finding out the allocations for the registers. We need something new and Noha has been starting coding on such a compilation scheme. But Now I now all the details needed to produce nice rtl vm code - so I can be a good help in his quest.

Happy Hacking :-)

116 older entries...

 

Others have certified tampe as follows:

  • Akira certified tampe as Apprentice
  • zanee certified tampe as Apprentice
  • fzort certified tampe as Apprentice
  • mutek certified tampe as Master
  • ittner certified tampe as Journeyer
  • dangermaus certified tampe as Master

[ Certification disabled because you're not logged in. ]

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!

X
Share this page