loading

Failed Experimentation : AI : My new creature is alive !

.
It's alive !

Alive, yes, but not as much intelligent than expected ..........

Instead of watching a stupid movie at TV, I decided to write a tiny AI programme all in PHP.
My goal was to get some functionalities comparable to logic programming languages like Prolog.

In simpler words : I wanted to create a programme that could learn facts, and find the solutions to some logical problems.

For instance :

> blue is colour.Okay.> carrot is vegetable.Okay.> blue is colour ?Yes.> blue is vegetable ?No.> carrot is colour ?No.
etc.

So far, I can teach it facts in the form of 3-words-affirmations, and I can ask it questions and definitions, and the creature is able to find some connections between facts.

Experimentation #1 :
> red is colour.Okay> black is colour.Okay> orange is colour.Okay> orange is fruit.Okay
(Here, we have a trap : orange is both a color and a fruit.)
> red is colour ?Yes> black is fruit ?No> orange is colour ?Yes> orange is fruit ?Yes
(Good. The beast did not fall in the trap.)

> translate :  red- "colour"> translate : orange- "colour"- "fruit"> translate : colour- "red"- "black"- "orange"
Good ! The beast can give a sense to the words it learned.

Experimentation #2 :
> Paul is human.Okay> human eat fruit.Okay> apple is fruit.Okay> human is animal.Okay> animal eat meat.Okay> animal is mortal.Okay

Now, let's see if it can "chain" the facts in a logical manner :
> translate : Paul- "human"
Here it should have replied : "human", "animal" and "mortal", since human are animals, and animals are mortal ...
Let's see how it defines "Paul" :
> define : Paul- Paul is human
My creature seems obviously narrow minded ...

Let's quiz it now :
> Paul is apple ?No> Paul is fruit ?No> Paul is human ?Yes> human is Paul ?Yes> Paul is Paul ?Yes> Paul eat fruit ?Yes> Paul eat apple ?Yes> Paul is animal ?Yes> Paul eat meat ?No> Paul is mortal ?Yes

As we can see, it successfully (and surprisingly) replied correctly to each question by connecting facts together, excepted for "Paul eat meat ?".
At this question, it should have replied "yes", since it knows that "Paul is human", "human is animal" and "animal eat meat". But it did not ...

... and it's bizarre since it can reply correctly to "Paul is mortal ?", from "Paul is human", "human is animal" and "animal is mortal", or to "Paul eat apple ?" from "Paul is human", " human eat fruit" and "apple is fruit" ...

Interesting, isn't it ? =o)

If you want, you can submit your facts and questions to my experimental creature (which has no name yet) =o)

What would be interesting also, is to confront it to a "paradox" just to see how it behaves ! =o)


20080625 : For those of you who would like to have a look at the guts of the beast, here is available the source code.

However, keep it mind it's a spaghetti-code and many function names are in french (as well as comments).

Also, this version relies on MySQL to store and query facts (I'm planning to replace it with simple arrays though), which make the code slightly more complicated than required ...

The main code makes less than 250 lines =o)

There is no direct input interface : instead, it use scripts (exp_*.php) that call functions. For example :
declarer("red","is","colour"); // <---- declarationsdeclarer("black","is","colour");declarer("orange","is","colour");declarer("orange","is","fruit");verifier("red","is","colour"); // <---- questionsverifier("black","is","fruit");verifier("orange","is","colour");verifier("orange","is","fruit");
... which is slightly more complicated than what I showed above for the sake of comprehension and simplification !

sort by: active | newest | oldest
1-10 of 83Next »
wizerd 7458 years ago
anyway you could do something like this with batch (easily)?
PKM wizerd 7458 years ago
To put it simply, no. Batch is a very simple language that doesn't have the data storage capabilities to do this type of task. I would guess that it is somehow possible, but it would be difficult even for a seasoned programmer, and strange almost to the point of perversity. I don't have a clue how I'd write this in batch, but I can see how I would do it in a more complete language like C.
Goodhart PKM8 years ago
To be very practical, the language has to be able to alter it's own functionality to learn, and as you wrote, it would be difficult if not impossible to do this in Batch, even with some of the more advanced Batch functions.
Ok thanks
kelseymh PKM8 years ago
You could do it in Perl trivially, or even in kshell. Use hash arrays to store each predicate, in particular use two inverse hash arrays so you can do queries in both directions. This still isn't going to solve your syllogism problem, which requires implementing an algorithm to either accumulate the full trees of relations at creation, or to figure them out on demand.
Perl perhaps?
Labot20018 years ago
Would Mr. Choose teach Labot how to copy AI onto his computer to use?
chooseausername (author)  Labot20018 years ago
You need a HTML server with PHP and MySQL servers, etc ...

If you're under windows, you could try : http://www.easyphp.org/

Once you'll have understood how EasyPHP works, you copy the source code in the appropriate folder, and you'll rename their .txt extension to .php5

=o)
>Once you'll have understood how EasyPHP works, you copy the source code in the appropriate folder, and you'll rename their .txt extension to .php5

Hmm, can you point me in a direction where I can learn about EasyPHP? For know, I'll start at Wikipedia, do some Google'ing, etc...
chooseausername (author)  Labot20018 years ago
The site EasyPHP.org gives you all the required help related to how to install and setup the web servers (that's what EasyPHP is), and more.

About the PHP language itself, you could learn the basis at : www.w3schools.org

I'd recommend that you start learning HTML first ...

However, keep in mind that PHP is not really a "general purpose" programming language ...
The main purpose of PHP is to generate web-pages dynamically ...

If I used it for my experimentation, it was for the sake of laziness. =o)
(I already had all the servers installed on my system, and I was too lazy to code in C++ ...)

If you want to learn programming without having to install many tools, you're not forced to do that with PHP ...
You could begins with HTML and JavaScript for instance (You'd only need notepad and a web browser ( www.w3schools.org )).

And if you want to learn are serious programming language, you could pick C++, Pascal or Visual-Basic ...
1-10 of 83Next »