views:

235

answers:

7

What concepts are important to learn when considering writing a program that can "think" about itself?

By "think", I mean software that can look at itself and improve over time.

How easy is it to write a program that can introspect at a basic level?

+4  A: 

Fairly easily. If you consider a configuration as part of a program, then you can simply change it, and thus it has changed itself.

Really, your questions is completely vague and arguably useless. I suggest you consider a real goal; something you actually want to do, and then do that. To implement some AI you don't want to modify the program itself (i.e. change lines of code). You only want to add new behaviours, and so on. It's a conceptual thing.

Noon Silk
based on the statistic data collected over time, your software can tune itself by changing its runtime parameters. e.g. google page rank, and oracle's claim of self tuned database, etc. and i think this is the pragmatic approach.
Dyno Fu
+4  A: 

There are languages that expose the program to itself as a data structure, such as Lisp, and allow you to write code that manipulates this data structure, to dynamically modify the program. This is why Lisp is sometimes used for AI programming.

You can do similar things, maybe not as straightforward though, using C#'s emit and reflection capabilities.

AaronLS
+1  A: 

Thinking is a very abstract term and something that we still haven't understood properly. That said, the problem you may be trying to crack encompasses recreating human intelligence and there is plenty of research work and materials you can find on the current state of the art.

If, however, you have a specific goal that you're trying to achieve and you can objectively define and measure "improvement", then you could use some of the some AI techniques to make progress. For example, it could be code that runs faster, or is shorter in size, etc. You can find related work in the field over here.

Many languages offer Reflection capabilities that should allow you to modify the program's structure from within.

Anurag
A: 

You're basically talking about the hypothetical point in future when we reach Technological Singularity. A software that can improve itself will mark a turning point in history, because that feature will create a feedback loop, and artificial intelligence will start to outsmart everyone of us very fast, rendering us plain human beings dumb and useless.

So do you really want to be the guy who does that break through and are you going to take all the burden of responsibility for that?

;-)

herzmeister der welten
That was funny lol.
Alix Axel
-1: "Software that can improve itself" has been around for at least thirty years. Probably longer. A very popular book for 1992 was John Koza's *Genetic Algorithms*... but there were many techniques before him. And the feedback loop? Not nearly so useful as we had hoped.
Chip Uni
I certainly don't want to be that guy because things can get really horrible. Proof - http://www.dailymotion.com/video/x7mxwm_family-guy-malfunctioning-robot_shortfilms
Anurag
A: 

If "if" and "else" were commands rather than keywords, then something a program could do to improve itself would be to log which branches of a conditional got executed most frequently, and then make sure that the most frequent conditions got evaluated first. For this you might need a command language, such as Tcl.

George Jempty
Sun's "HotSpot" JIT compiler does something very much like that with adaptive_optimization, but it's clearly not thinking.
Wayne Conrad
+1  A: 

The ability of the software to improve itself will be dependent on two things:

  • introspection and reflection, the ability to examine its own operation and change it dynamically
  • a criteria for analysis, the much harder task of deciding what is being measured by the program to judge itself, and how to effectively improve those factors.

In practice, profiling libraries and genetic algorithms would probably be good starting places for programs where people are doing these kinds of tasks.

A language like lisp that is designed to read and write the structures which make up its own executable code makes this sort of thing much easier, and much more robust, though you can emulate this behavior in other languages with liberal use of arrays of function pointers and conditionals.

Justin Smith
+1  A: 

The most important thing to consider is what problem you're trying to solve. The second is how you represent knowledge. The third is how you choose to find improvements. Let's take these steps one at a time:

What you're trying to solve
Running these simulations usually requires a purpose. This purpose something to judge against: an evaluation function that says how close you are to your goal. Without a goal, a simulation can manipulate itself... but it would just put out random material.

How you represent knowledge
If you're trying to reach a goal, then the code needs two parts: the goal-oriented material, which doesn't change, and the learning material, which does change. Some use a language like LISP, where data and code are of the same format. I created a simple virtual machine with the functions that I needed, putting knowledge in an assembly language. There are myriads of correct answers, but you need to choose.

How you find improvements The most common way to examine and upgrade code is through a genetic algorithm strategy. But other hill-climbing algorithms and optimization algorithms work well too. I've used genetic algorithms, simulated annealing, and neural networks in metaprogramming experiments.

Chip Uni