398Views83Replies

Author Options:

Failed Experimentation : AI : My new creature is alive ! Answered

.
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 !

Discussions

The forums are retiring in 2021 and are now closed for new topics and comments.
0
wizerd 745
wizerd 745

11 years ago

anyway you could do something like this with batch (easily)?

0
PKM
PKM

Reply 11 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.

0
Goodhart
Goodhart

Reply 11 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.

0
kelseymh
kelseymh

Reply 11 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.

0
purduecer
purduecer

Reply 11 years ago

Perl perhaps?

0
Labot2001
Labot2001

12 years ago

Would Mr. Choose teach Labot how to copy AI onto his computer to use?

0
chooseausername
chooseausername

Reply 12 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)

0
Labot2001
Labot2001

Reply 12 years ago

>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...

0
chooseausername
chooseausername

Reply 12 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 ...

0
Lithium Rain
Lithium Rain

Reply 12 years ago

Visual basic?? What century do you program in? :D

0
chooseausername
chooseausername

Reply 12 years ago

lol Actually, even Pascal is slightly out of fashion Xo)

0
Goodhart
Goodhart

Reply 11 years ago

Pascal is much older then VB for sure. As for C, I like C # myself ;-)

0
PKM
PKM

Reply 12 years ago

I have to code with VBA at work ;_;

0
Lithium Rain
Lithium Rain

Reply 12 years ago

Do you work in the eighteenth century?

0
Labot2001
Labot2001

Reply 12 years ago

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

I can do intermediate HTML. What I'm really interested in is programming, not web design.

>And if you want to learn are serious programming language, you could pick C++, Pascal or Visual-Basic ...

I heard that if you want to learn programming, start with Python. What would your recommendation be, ups and downs of each of them, etc?

0
chooseausername
chooseausername

Reply 12 years ago

> I can do intermediate HTML. What I'm really interested in is programming, not web design.

I understand. However, HTML is the entry door for JavaScript and PHP (they all work together). That's why I told you to start with HTML (just in case ...)

But if you want to learn programming, then, you can start with Python if you want.

I tried many languages, but I don't remember I ever tried Python ... so I can't tell you anything about it, excepted that Whatsisface once said : «Or Python ! Python rocks!»

I tried various languages : many BASIC dialects, some Assembly languages, Pascal, C and C++, Euphoria, some Perl, some Erlang, LUA, C# and some D ... I even tried a language called "microbe" ... all of that, plus HMTL, XML, JavaScript and PHP indeed ...

The most used programming language around the world is probably C++.
That's also my main language when I want to code something serious.

Honestly, I think that whichever you choose to begin with, you'll always end-up trying a new one till you've found your "holy grail".
So, just pick up one of them and start with it : Why not Python ??

=o)

0
Labot2001
Labot2001

Reply 12 years ago

Aha! Thanks for all the wisdom.

And, um... n00b question... Is "C++" pronounced "See-Plus-Plus"?

0
Lithium Rain
Lithium Rain

Reply 12 years ago

Yeah. And "C #" is pronounced "see-sharp".

0
Labot2001
Labot2001

Reply 12 years ago

Really, now? Thanks, smart aleck.

0
Lithium Rain
Lithium Rain

Reply 12 years ago

I'm not being a smart aleck! THAT'S HOW YOU SAY IT!!

0
chooseausername
chooseausername

Reply 12 years ago

And by the way, have you noticed my formidable pun ??? =o)

"holy grail" ... Python ...

Python ... and the "holy grail" ??

No ? nothing ? .........

Never mind ...

0
Labot2001
Labot2001

Reply 12 years ago

No, I didn't catch it at first. I've never seen the whole movie ~~and I didn't care for it~~ but I'll get to it one day.

0
whatsisface
whatsisface

Reply 12 years ago

I got it at least :-)

0
zachninme
zachninme

Reply 12 years ago

"And if you want to learn are serious programming language, you could pick C++, Pascal or Visual-Basic ..."

Sorry chooseausername, but I wholeheartedly disagree. I would never start with VB, as it does not teach good programming practices. Pascal, maybe, but I wouldn't personally recommend it.

I'd also not recommend either Python or Java as a first language. This article makes a convincing point. (it applies equally to python, even though they do not mention it)

0
chooseausername
chooseausername

Reply 12 years ago

Oh, you know, that's not a subject I will argue about ... =o)

Honestly, if I told him C++, Pascal (or Delphi) and VB, it's mainly because (at my knowledge) they are 3 of the top most popular ones (many tutorials, many resources and many tools available) ...

Anyway, if I ruled the world, the only programming language would be C.
=o)

0
whatsisface
whatsisface

Reply 12 years ago

Or Python! Python rocks!

0
Labot2001
Labot2001

Reply 12 years ago

Can you tell me enough about Python to get me on my feet?

Or at least crawling?

0
whatsisface
whatsisface

Reply 12 years ago

I'm learning it from this site :http://www.freenetpages.co.uk/hp/alan.gauld/

It's a very good piece of text, well written and easy to understand. MAke sure you start at the start and don't skip anything.

0
Labot2001
Labot2001

Reply 12 years ago

Ah, gracias, Sir Face. I shall "bookmark" it, yes?

0
NachoMahma
NachoMahma

Reply 12 years ago

. You might want to investigate [http://en.wikipedia.org/wiki/LAMP_(software_bundle) LAMP] or WAMP.

0
kelseymh
kelseymh

11 years ago

What I think you're looking for is called "predicate calculus" in English.

I'm sorry that I don't know the technical term in French. Doing a Google Scholar search for research articles on predicate calculus might (or might not :-( ) lead to you to some useful algorithms for how to have your software make deductions and follow syllogistic chains.

0
Keith-Kid
Keith-Kid

12 years ago

The comments in this thread are interesting, they seem to answer a lot of my questions. I'll keep an eye on this thread.

0
chooseausername
chooseausername

Reply 12 years ago

Are you planning to make a report ? =o)

0
Keith-Kid
Keith-Kid

Reply 12 years ago

I'd really like to learn about programming languages......

0
chooseausername
chooseausername

Reply 12 years ago

What would you like to programme for instance ?

0
Keith-Kid
Keith-Kid

Reply 12 years ago

Yeah....I'm not even sure what I wanna learn.......

0
chooseausername
chooseausername

Reply 12 years ago

Then, what are you sure about ??

0
Keith-Kid
Keith-Kid

Reply 12 years ago

I'm pretty sure I have internet connection........

0
NachoMahma
NachoMahma

12 years ago

> If you want, you can submit your facts and questions . Why not setup a web interface? If it's already in PHP, it shouldn't be too difficult. Then we (and the rest of the World, if you like) could "test" it at our leisure.

0
chooseausername
chooseausername

Reply 12 years ago

> Why not setup a web interface? If it's already in PHP, it shouldn't be too difficult. Then we (and the rest of the World, if you like) could "test" it at our leisure.

I was thinking about that too. =o)
But I wanted to be able to detect bugs and to analyse it's behaviours thanks to submissions.

Anyway (and as you could see through the source code), I'm afraid this version is not yet ready for a public exhibition ;o)

0
Labot2001
Labot2001

Reply 12 years ago

So the Instructables community gets to be the beta testers? ;-)

0
chooseausername
chooseausername

Reply 12 years ago

In a certain way =o)

That could have been fun though =o)

0
PKM
PKM

Reply 12 years ago

Because the /b/-tards found a chatterbot online that you could "instruct", so basically they had stuffed its knowledge base full of nonsensical rubbish. It pretty much just insulted you and spouted racial/sexual epithets and non sequiturs.

0
Aar000n3y
Aar000n3y

Reply 12 years ago

Haha Can you post a link to that chatterbot here?

0
skunkbait
skunkbait

12 years ago

Impressive! I can barely turn on the computer.

0
PKM
PKM

12 years ago

Does your machine neglect to add "eats" relations to the transitive closure? That's all I can think of, if it can apply transitivity to "is". I'm quite interested in computer knowledge representation and low-level AI, and have been charged with helping my brother write a semi-generic AI doober for a web interface he's writing- how 'bout a group or a collaboration? We could actually create the Instructables Robot!

0
chooseausername
chooseausername

Reply 12 years ago

> Does your machine neglect to add "eats" relations to the transitive closure? That's all I can think of, if it can apply transitivity to "is".

Actually, I'm not really sure how it work (LOL !), because I wrote the code without really planning anything ........ It's an improvised coding ... and I was tired too ;o)

However, the difference between "is" and "eat" (or any other relation between two words) is that "is" is connected to a special meaning that the machine can understand (and which is defined at the beginning of each script)..
declarer("=","=","=");declarer("is","=","=");
"=" is the only thing the machine knows by default, and "is" is the first word in natural language whose meaning is defined ...

So, the relation "is" is treated slightly differently than others relations. But normally, it should have worked correctly (at least, I was expecting so).
(... so I guess I forgot a line or two between two debugging ...)

> I'm quite interested in computer knowledge representation and low-level AI, and have been charged with helping my brother write a semi-generic AI doober for a web interface he's writing- how 'bout a group or a collaboration? We could actually create the Instructables Robot!

That's something I like too, but I did not read any book or major things about it ... It's mainly improvisation.
I can't even code in Prolog ...

I'm okay for a group.
About a collaboration, I'm not yet experienced enough I think =o]