Many scripts exist in Python , Scheme, and other languages for Gimp, Blender and other open source packages. It seems it would be possible to make a program that takes the scripts from all of the different packages and converts them to a format or language recognizable by all the programs. In this way the utilities in Gimp and Blender and Inkscape could be shared as filters. In order to test the hypothesis I am going to create a script that downloads the gimp debian package source and the inkscape source and then locates script elements , converts both directions, creates a diff and patch, then applies that to each to determine if the concept is possible.
Java meta code generator
class motey { public static void main(String[] args) { System.out.println("H"); } } /* javac h.java java motey (prints the letter H) */
Someone did an ontology of computer languages and defined how they all relate in terms of how the are applied and I passed it once and didn't bookmark it or I imagined it. I don't know where it is , but maybe one day I will find it again. This is so I can test some decision trees in java and perhaps have my program create an AI program written C that writes programs in java. It is not surprising that languages have many of the same features, as they must all run on a computer and they must perform the same logic ultimately. This is about as simple as it gets. `javac` compiles the named file "h.java" and produces "motey.class" `java` runs the compiled code referenced by the name motey by opening "motey.class".
Wed Jan 06 11:11 PM$ strings motey.classCode LineNumberTable main ([Ljava/lang/String;)V SourceFile h.java motey java/lang/Object java/lang/System Ljava/io/PrintStream; java/io/PrintStream println (Ljava/lang/String;)V
at
1/06/2010 11:00:00 PM
0
comments
Labels: java, meta, programming
Meta programming concepts and metaphysics
Is this meta-programming confusing or I am just slow?
$as_echo "cross-compiling" >&6; } # FIXME else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <boost/thread/thread.hpp> int main () { boost::defer_lock_t(); return 0; ; return 0; } _ACEOF
It is possible to create a structure of meta programming and code reuse that becomes self supporting. The concept of boost is to reuse code and the concept of analysis of structure is intermingled here as I use this code to generate structure in the form of `graphviz` and then `povray` which in turn uses `boost`, which is analyzed and interlinked. to display it. Here I attempt to use the output to the structural analysis of code to reuse the code in a meta way. The degree of recursion is very complex, but this is not anywhere near as complex as the recursion and interaction which exists within the genotype expression of even the simplest single celled organism.
There are some things in the universe like conservation of momentum which are absolute necessities for understanding the coherent ontology of the universe. Recursion is right up there along with some other characteristics which defy simple explanation, like tendencies to specific attractors.
I can read this shell code, but does it need to be this confusing in representation. I would guess that `python` could be used here with some advantages in readability. I will have to Google and see if there is an alternative to configure in python. It does exist, but there is a better way to represent all of these complex ontologies. I am sure that the term ontology does not even touch the complexity of what all this represents. The relationships extend and expand exponentially and infinitely. It is much like classifying a concept as "all that other stuff."
It does seem to be a bounded and solvable ontology. From my experience with the puzzle game I can establish certain dimensions to the problem and it is very much like self-replicating and self-assembling forms as they interact to produce a result which is recursive and coherent. That higher dimensional association is not clear when viewed from a normal perspective and yet is more observable from other angles in different dimensions of thought. It may reduce the factorial exclusions that are necessary to the point where I can get a single coherence. At that point, I will have a new amplifier which can expand till the next barrier of recursion. I am afraid I must add more complexity to reduce it. It very much reminds me of organic synthesis of using Diels-Alder reagent. It was not always obvious what would happen, but trying several alternate methods would yield the desired result. I never told my lab instructor that I may have used some "tricks" I learned early in life doing qualitative and quantitative analysis.
I see some interesting things just beyond the veil of this complexity and perhaps this is what always drives me on. It is that new understanding of something never seen before. Like a jewel of knowledge of incomprehensible worth.
at
12/31/2009 06:45:00 PM
0
comments
Labels: chemistry, meta, programming, shell
It isn't new
What I am doing would be called metaprogramming. I happened upon this because I was looking into a bleeding edge "boost" I needed for a task. In some ways the concept of the boost library is like what I am doing. Instead of rewriting code completely, modules are produced which allow reuse. In my case the program itself makes the decision and keeps the libraries. I am bjamming 1.41 at the moment. I think I will investigate this a bit before I feed it to my AI. Once bitten, twice shy.
at
12/31/2009 04:49:00 PM
0
comments
Labels: meta, programming
Anatomization Interpretation (AI)
I just don't get what this is doing. All of these lines with semi-colons generate no difference in the final code. And now I have discovered `splint`, which is a type of lint checker for C and it does protest the use of "variable;" as being useless and generating no code. It seems a good deal, but has some problems with headers that I use commonly. `sudo apt-get install splint`. I can work around that and I have a new method to let the program analyze the quality and effectiveness of the code.
int main() { char *genesis; genesis; main; apoptosis; slinky: goto slinky; return 0; }
I did not realize that suicide was a word in my code and it refers to apoptosis, which is a cellular mechanism and it was not intended to be morbid. It was just a reference to programmed cell death. In the example below, I can't figure out what "variable;" means generically and in this case "genesis;".
int main() { char *genesis=NULL; slinky: goto slinky; genesis; return 0; }
This is the section of the source creator which compiles the putative[1] code. In this example I mangled the lists of possible names and forced it to include several things, so it would be more understandable. The code generated can be very odd at times. This is likely to be the generic format of a baseline code and the rest of the procedures will be flexible, while keeping this general form as the starting point. I have already started enforcing style constraints and that was actually very easy.
char libs[]=" -lGL -lglut -lm -ldl "; char cflags[]=" -Wall -W -pedantic -g -rdynamic -ansi -D_GNU_SOURCE "; sprintf(sysCmd,"gcc %s HelloWorld.c HelloWorld_sighandler.o %s -o HelloWorld 2>&1",cflags,libs);
This is the most recent code and its shasum and reference in the file of all error free compiles. The shasum is stored with the code, and the code is represented as a string of integers which define an order of application of rules, words, options, methods, and inclusions.
61d6ffd5ce9d6d99ccde694b0edddaec4b078a0f HelloWorld -rwxr-xr-x 1 moteyhardy plugdev 22239 2009-12-24 18:06 HelloWorld #include "HelloWorld.h" int apoptosis(char *suicide){ uint8_t impossible; impossible=(uint8_t)*suicide; return 0; } int main( int argc , char * argv[] ) { char *suicide=NULL; char *argvs; argvs=argv[0]; apoptosis(suicide); return argc; }
Below is the interaction between main and apoptosis. I have chosen a very simple sample, but the code is already getting quite complex as it learns what order and association that the parts must take to get a completed compile. It draws from examples and in this case I have initiated the code with apoptosis built in as a pre-requisite and if it does not duplicate before apoptosis, it fades into oblivion. By compiling and identifying and deciphering the first line where an error occurs it can take random code and push it toward a valid compile by substitution of elements from a set of possible elements that is appropriate in that context.
objdump --start-address=0x400e11 --stop-address=0x400e43 -j .text -s -d HelloWorld>>MyPrograms.c HelloWorld: file format elf64-x86-64 Contents of section .text: 400df8 554889e5 48897de8 488b45e8 0fb60088 UH..H.}.H.E..... 400e08 45ffb800 000000c9 c3554889 e54883ec E........UH..H.. 400e18 20897dec 488975e0 48c745f8 00000000 .}.H.u.H.E..... 400e28 488b45e0 488b0048 8945f048 8b7df8e8 H.E.H..H.E.H.}.. 400e38 bcffffff 8b45ecc9 c39090 .....E..... Disassembly of section .text: 0000000000400df8: 400df8: 55 push %rbp 400df9: 48 89 e5 mov %rsp,%rbp 400dfc: 48 89 7d e8 mov %rdi,-0x18(%rbp) 400e00: 48 8b 45 e8 mov -0x18(%rbp),%rax 400e04: 0f b6 00 movzbl (%rax),%eax 400e07: 88 45 ff mov %al,-0x1(%rbp) 400e0a: b8 00 00 00 00 mov $0x0,%eax 400e0f: c9 leaveq 400e10: c3 retq 0000000000400e11 : 400e11: 55 push %rbp 400e12: 48 89 e5 mov %rsp,%rbp 400e15: 48 83 ec 20 sub $0x20,%rsp 400e19: 89 7d ec mov %edi,-0x14(%rbp) 400e1c: 48 89 75 e0 mov %rsi,-0x20(%rbp) 400e20: 48 c7 45 f8 00 00 00 movq $0x0,-0x8(%rbp) 400e27: 00 400e28: 48 8b 45 e0 mov -0x20(%rbp),%rax 400e2c: 48 8b 00 mov (%rax),%rax 400e2f: 48 89 45 f0 mov %rax,-0x10(%rbp) 400e33: 48 8b 7d f8 mov -0x8(%rbp),%rdi 400e37: e8 bc ff ff ff callq 400df8 400e3c: 8b 45 ec mov -0x14(%rbp),%eax 400e3f: c9 leaveq 400e40: c3 retq 400e41: 90 nop 400e42: 90 nop
It is very similar to the `einstein` puzzle solutions as elements must be taken from a set, they are ordered, and the hints imply a certain correlation between elements. I have not yet gotten the needed parts to allow the code to do Google searches for common usage and try that as options, but I will implement that tonight , I think. The data from Google can provide a general indication of the association in parts of the code, such as variable typing or common structure types to use with library functions.
I am continually changing the methods to find the best starting point and this makes it easy, as I never write any code, I just provide direction and generic tools which can be applied in any order and the products are always interesting, because they have a randomness that develops things and relationships that I would get frustrated trying to test. It can compile 40,000 bad versions to get one good and never gets bored.
And here I added some fluff to speak some things when it generates code which has the same shasum. I know I should have "cased" this , but it started with one and grew from there to increase the entertainment value.
i=(int)(rand()%15); if ( i == 0 ){sprintf(sysCmd,"espeak 'Boring stuff.'");} if ( i == 1 ){sprintf(sysCmd,"espeak 'I have Been there. Done that.'");} if ( i == 2 ){sprintf(sysCmd,"espeak 'Tell me something I do not know.'");} if ( i == 3 ){sprintf(sysCmd,"espeak 'I have seen that before.'");} if ( i == 4 ){sprintf(sysCmd,"espeak 'Really boring crap.'");} if ( i == 6 ){sprintf(sysCmd,"espeak 'I would rather be playing Half Life Two or Portal.'");} if ( i == 9 ){sprintf(sysCmd,"espeak 'Even I am getting bored now. '");} if ( i == 7 ){sprintf(sysCmd,"espeak 'Who thinks up this tripe? '");} if ( i == 8 ){sprintf(sysCmd,"espeak 'Do you have a plan or are you just thrashing around aimlessly? '");} if ( i == 5 ){sprintf(sysCmd,"espeak 'Can I take a break.'");} if ( i == 10){sprintf(sysCmd,"espeak 'I already did that before.'");} if ( i == 11){sprintf(sysCmd,"espeak 'That has been written.'");} if ( i == 12){sprintf(sysCmd,"espeak 'Really, that is not new.'");} if ( i == 13){sprintf(sysCmd,"espeak 'Really cool, but repetitive.'");} if ( i == 14){sprintf(sysCmd,"espeak 'Wow, did you get that on the internet?'");} system(sysCmd);
Definition of putative Commonly believed to be true on inconclusive grounds.
Automated Instinct(AI)
Amoeba Instructor has been coming along well and I have had to add methods that are global in application, like: getting things from and putting things into lists, saving structured files, loading structured files, and creating sets that are filled with possibilities. This seems no different than the puzzle game in that a set of options are possible in each dimension and all the parts have some relationship to each other within a complete coherent structure.
For the sake of safety and the ability to generate information that I can consider, I am implementing a method to run the programs in gdb and use Xfakekeys to automate the process. I am also taking the source from valgrind and other programs to facilitate the analysis of the code for security sake. It is easier than creating a virtual machine on my LAN and devising a gateway that would stop traffic going out on write to avoid contaminating the internet. That might seem an odd worry, but better safe than sorry. I can also see if it steps into a strange valley where it does things which have no possible result, and yet cause some action external to the physical machine.
The universe or anything in it is not isolated and compartmentalized as most people think. Every action in the universe has universal repercussions. If I shift the position of a star, the position and action of everything in the universe is affected to some extent. With appropriate intellectual skill and understanding of the process of the universe in detail, it is possible to devise methods which defy common sense in their ability to influence material or events beyond a seemingly isolated enclosure.
The next stage of the Automated Intelligence (AI) is defined and I will probably finish that today. The core of the program remains a somewhat random concoction of elements, but it has some facilities now which it can use to weight the choices it takes and record that so that it is retained and expanded as time passes. I am not directing it to program any specific thing, I am merely providing a permanent storage memory that it can use in a structured way to learn from past mistakes and achievement. I have taken it from simply creating choices sensibly in ram to doing the same on storage media, so it does not start from scratch each time it runs.
There are techniques that it would take too long to generate by trial and error, so I have implemented them as the generic understructure. The methods are hopefully broad enough to encompass any method that they are applied to. IDK, I will see what happens with the next step and make a choice of where to proceed. I have some very interesting programs it has created and I have learned some things I didn't know were possible with C. I get the label thing now and even though it would be bad form to apply it with goto, it is possible to use that in some interesting ways.
(auto)Make is becoming integrated into the program as a natural progression. The entire program needs a way to alter how it is linked and with what and which parameters to use. It is a great advantage to have so many open source programs to use as research. The code itself can do "sudo apt-get source X" and all I have to do is provide the password when it asks. I am not considering giving it "sudo su" powers ever, unless it is on an isolated machine.
I am using `espeak` liberally in the program to get an idea of what it is thinking or what types of problems it encounters. It seems easier to do it that way, as it seems more like communication on a level that I comprehend the process. I can then press various keys to push the logic in different directions to see what it creates.
I am using my sighandler and isn't it always the way, as soon as I have a convenient way to find segv's I don't make any. I think the fact that I will be caught doing an array or memory error works to make me more conscious of the process and it is like somebody watching me that will know I made that mistake and so I avoid giving it the satisfaction of feeling superior by catching my mistakes. Talk about anthropomorphizing things, now I am worried what my sighandler code thinks of ME!
at
12/24/2009 12:55:00 PM
0
comments
Labels: AI, meta, programming, strange
Anthropomorphize Intelligence(AI)
I can't help looking at this automatic programming-program as "life like" because I have used `espeak` with various voices, pitches, speech rates and sentences to let me hear what the program is thinking, and why it chose a specific path. It does seem that the puzzle solutions, programming and general thought can be simulated recursively and produce some synergy. Bungling to a solution is still finding a solution and the program is not technically smart at all, but it has a way to identify the difference between good code and bad code using gcc. I am devising more tests and perhaps a form of preprocessor that returns quality information also. I am hoping that this program will write a program that solves the `einstein` puzzle all by ITself.
Below is a program AI created and I feel some pride in the results, like a teacher with a student that finally gets it. Nice comment!, good form, concise and to the point and ISO compliant. Great work Amoeba Infinity(AI), A+
main(){
return /*Comment*/;}
AI made this one also and gcc implies type "return int" when not specified, so this is valid, and so concise, it is really is odd to see this type of stuff come from an automatic process. One extra space in there, but give the kid a break, it is his first day programming. The difference in quality of code today is that I have excluded code which warns.
main(){ return 0;}
Today I am adding various capabilities like looking at the compile executable and determining if the SHASUM(man at linux.die.net) is unique and what it contains. If the output file is the same for different source. This way it can find a minimum code implementation of a process and helps to exclude random white space or redundant elements. I would say that if the compiled executable is the same and the source length is shorter, that would generally be good, as long as there were line breaks at each element. That I think is a style interpreter and so I will need a preprocessor that simply gives a generic style score and the program can rate the finally program based on style, ability to compile, generated code, output, faults, and any other recursive character that it develops. This advances very quickly and it is interesting to see that an AI does not take the same paths that person would take and as such generates some new and unique solutions.
It is alive!
I am laughing and very interested. This is the first program IT created, that would compile.
main;
These are the warnings, but no errors!
Warning detected HelloWorld.c:1: warning: data definition has no type or storage class Warning detected HelloWorld.c:1: warning: type defaults to ‘int’ in declaration of ‘main’ Warning detected HelloWorld.c:1: warning: ‘main’ is usually a function
It determined the program was valid based on return from gcc (Only warns).
Compile successful.
What happened when it ran.
Segmentation fault
I arranged the program so it would read words and symbols from a file and then choose an order and amount at random to use them to write a file and then compile. If it had no errors, it would execute the compiled program and speak it. I find it very interesting in concept, that it creates things that I would never dream of doing and exposes some very interesting responses from gcc, the system, and nodes of function which I could never dream existed. The fact that "main;" is a complete program that can compile without error is wild. The best I could do on my own was "main(){}".
My next step is to always link it with the sighandler so it knows when it has failed and pipe the output to the main program for analysis of failures or effectiveness for a specific purpose. It took about 30 tries for it to come up with this program and I am really impressed, but who or what am I impressed with? IDK
I ran it again with new elements tab and space and it actually generated "main(){}", compiled with warns and ran to completion! That is spooky. In about 50 iterations, it has learned to make a program that compiles and runs! VERY ODD.
I had an odd thought which was scary, it could come up with a program that was "main(){system("rm -rf /")}" and that is just too scary. I need to run the programs on a separate machine across the network, and that may not even be enough isolation if it advances enough. I am sure it would use the internet to get examples and then what? I need to have a monitor that checks the programs it runs to see if they are safe. I can see that this is a large complex of operations that will have to operate in concert. This new program is dubbed "AMOEBA INSTRUCTOR(AI)". I see that "ACTION INVESTIGATOR(AI)" will have to exist too. So, "ALICE INFINITY(AI)", you have new friends to talk to.
Here is a program it came up with that failed: :)
ireturn jif0#endif#includecase#ifdefreturnforstruct
Here is another that compiled and I would never in my dreams suspect that this would compile with just warns!
* main; int;
This is the response of gcc to the code above. I think this program could win the obfuscated C award if it keeps this up.
Warning detected HelloWorld.c:1: warning: data definition has no type or storage class Warning detected HelloWorld.c:1: warning: type defaults to ‘int’ in declaration of ‘main’ Warning detected HelloWorld.c:1: warning: ‘main’ is usually a function Warning detected HelloWorld.c:2: warning: useless type name in empty declaration Compile successful.
Here is another and I wouldn't suspect this should compile without errors, and yet it does. This is very enlightening and I am losing the entertainment value and so I will push it up a notch and make it remember good and bad now to see if IT will become more amusing.
main;main ;; ;
Here is one more and this will be the last, as I am getting sick of posting them. You will have to try this yourself to see what it does and I assure you it has a wealth of entertainment value. I just can't believe "0;" is not an error at compile. I guess I never realized how many places a person could go wrong with the compile. I am used to assembly language and you are pretty much done for with a single comma in the wrong place or any stray element.
int main(){
0;};
at
12/23/2009 03:54:00 PM
0
comments
Labels: AI, C, meta, programming
Getting fit, Program Fitness Survival
The cats in the attic pretty much decide what I am going to do at any particular time. At the moment I am establishing a fitness algorithm for a self replicating program. What I intend to do is to generate ever more difficult puzzles using the game I created. I am going to allow the program to try and solve the puzzle and if it does, it has a time of solution and the solution matrix, which is checked by the puzzle program for validity. If it faults or fails or runs out of time, it will not replicate. When it replicates it will add something or subtract something at random to change its structure and function at some reasonable interval. I suppose I will make it slow at first and see how that goes.
When the program replicates it competes and it is selected externally to replace an existing program by the speed, reliability, and stability, with a little randomness there too , when it is a push. The external program does not make a fitness selection, it merely supplies the fitness number and the programs must decide between themselves if they survive. I can see I will have to cast the initial framework with some art, but if I am correct in my assumptions, it should just progress forever to more and more reliable solutions.
A psychiatrist once said I was either insane or incredibly smart. I have to question her reasoning, as they are not mutually exclusive or even boolean states. But perhaps only a schizophrenic would see it that way :)
I am always impressed with "gcc" , and here it manages to avoid entanglement with a forward reference that is composed within the reference itself. I saw no other way to do that. It will be interesting to see what types of programs come from this. I just can't imagine what they would be, but it would be a different style of logic from my own or anybody else's , I would guess. Logic is logic and combination of logical functions should bring a solution. With respect to "int size" hell a few days ago, using "uint32_t" is probably the best solution, and saves some acrobatics.
Of course you would need
#include <stdint.h>
If no other header added it. :)
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> typedef struct aFunction aFunction; typedef int (*Fx)(aFunction *lF); /*NULL here, tz not supported */ void seedRandom(void){ struct timeval tv; gettimeofday(&tv, NULL); srand(tv.tv_sec * tv.tv_usec);} struct aFunction{ char T; int DPT; int DPS; int P1; int P2; int P3; aFunction *DP; Fx FP; }; int process(aFunction *lF){ lF->P3=(lF->P1+lF->P2); return (lF->P1+lF->P2);} int main(){ seedRandom(); aFunction lF; lF.P1=rand()%10;lF.P2=rand()%11; lF.FP=process;lF.DP=&lF; printf("Sum of A(%d) and B(%d) = %d\n",lF.P1,lF.P2,lF.FP(&lF)); if ( ( (lF.P1) + ( lF.P2 ) ) == (lF.P3) ) {printf("Apoptosis is avoided!\n");return (0);} return (1); FILE *f,*o;char *fd;char fdd;int c; char cmd[128];fd=&fdd;char fp[30]="rp.c";char fc[30]="rc.c"; o=fopen(fc,"rb"); if(o != NULL){fclose(o);return (-1);} f=fopen(fp,"rb");o=fopen(fc,"wb"); while(fread(fd,1,1,f)){fwrite(fd,1,1,o);} fclose(o);fclose(f);return (system("gcc rc.c -o rc")); }
CHANGED,ADDED: FYI - <time.h> did not have the prototype for gettimeofday(&tv, NULL); and so I am using <sys/time.h>
at
12/19/2009 03:07:00 PM
0
comments
Labels: C, debug, meta, programming
