Artificial Intelligent-II

Artificial Intelligent-II

                  So how was the first Artificial Intelligent post? I hope it will informative to all my readers, Friends. Also you can get basic knowledge of Artificial Intelligent.
Now we are continue with second post on Artificial Intelligent. In this post we are cover the same topic related with Artificial Intelligent. In that we can get knowledge on Artificial Intelligent Applications, there Goals, and there Issues.

                     Artificial Intelligent is the best option to handle some areas like Gaming, Natural Language Processing, Speech Recognition, and Intelligent Robots etc. It’s very helpful to fast growth of world because it can do the hard job in easy way and also fastly. So it’s very time consuming than other human working process.
Thus, the development of AI started with the intention of creating similar intelligence in machines that we find and regard high in humans.
                     Artificial intelligence is a science and technology based on disciplines such as Computer Science, Biology, Psychology, Linguistics, Mathematics, and Engineering. A major thrust of AI is in the development of computer functions associated with human intelligence, such as reasoning, learning, and problem solving.
Out of the following areas, one or multiple areas can contribute to build an intelligent system.

Goals of AI
1. To Create Expert Systems: The systems which exhibit intelligent behavior, learn, demonstrate, explain, and advice its users.
2. To Implement Human Intelligence in Machines: Creating systems that understand, think, learn, and behave like humans.

What is AI Technique?
In the real world, the knowledge has some unwelcomed properties:
1. Its volume is huge, next to unimaginable.
2. It is not well-organized or well-formatted.
3. It keeps changing constantly.

AI Technique is a manner to organize and use the knowledge efficiently in such a way that:
1. It should be perceivable by the people who provide it.
2. It should be easily modifiable to correct errors.
3. It should be useful in many situations though it is incomplete or inaccurate.
AI techniques elevate the speed of execution of the complex program it is equipped with.

Applications of AI
AI has been dominant in various fields such as:

1. Gaming
AI plays crucial role in strategic games such as chess, poker, tic-tac-toe, etc., where machine can think of large number of possible positions based on heuristic knowledge.

2. Natural Language Processing
It is possible to interact with the computer that understands natural language spoken by humans.

3. Expert Systems
There are some applications which integrate machine, software, and special information to impart reasoning and advising. They provide explanation and advice to the users.

4. Vision Systems
These systems understand, interpret, and comprehend visual input on the computer. For example,

• A spying aero plane takes photographs which are used to figure out spatial information or map of the areas.

• Doctors use clinical expert system to diagnose the patient.

• Police use computer software that can recognize the face of criminal with the stored portrait made by forensic artist.

5. Speech Recognition
Some intelligent systems are capable of hearing and comprehending the language in terms of sentences and their meanings while a human talks to it. It can handle different accents, slang words, noise in the background, change in human’s noise due to cold, etc.

6. Handwriting Recognition
The handwriting recognition software reads the text written on paper by a pen or on screen by a stylus. It can recognize the shapes of the letters and convert it into editable text.

7 Intelligent Robots
Robots are able to perform the tasks given by a human. They have sensors to detect physical data from the real world such as light, heat, temperature, movement, sound, bump, and pressure. They have efficient processors, multiple sensors and huge memory, to exhibit intelligence. In addition, they are capable of learning from their mistakes and they can adapt to the new environment.

AI ISSUES
                   AI is developing with such an incredible speed, sometimes it seems magical. There is an opinion among researchers and developers that AI could grow so immensely strong that it would be difficult for humans to control.
Humans developed AI systems by introducing into them every possible intelligence they could, for which the humans themselves now seem threatened.
Threat to Privacy an AI program that recognizes speech and understands natural language is theoretically capable of understanding each conversation on e-mails and telephones.


                Threat to Human Dignity AI systems have already started replacing the human beings in few industries. It should not replace people in the sectors where they are holding dignified positions which are pertaining to ethics such as nursing, surgeon, judge, police officer, etc.
Threat to Safety the self-improving AI systems can become so mighty than humans that could be very difficult to stop from achieving their goals, which may lead to unintended consequences.
So this are the some Artificial Intelligent Applications, Goals, and Issues. These topic are small information on AI because our AI field is changing constantly day by day so this information also updating .I try to provide latest updated information on Artificial Intelligent.so keep in touch with that series get complete information on AI. And your eyes on next post I will post as soon.

                To get daily update please subscribe my blog, so you can’t miss any post related with it and also other new posts.
Thank You …!!!
   

Introduction of Prolog

Prolog

1. Basic Introduction of Prolog



Prolog (programming in logic) is one of the most widely used programming languages
in artificial intelligence research. As opposed to imperative languages such as C or Java
(which also happens to be object-oriented) it is a declarative programming language.
That means, when implementing the solution to a problem, instead of specifying how
to achieve a certain goal in a certain situation, we specify what the situation (rules and
facts) and the goal (query) are and let the Prolog interpreter derive the solution for
us. Prolog is very useful in some problem areas, such as artificial intelligence, natural
language processing, databases, . . . , but pretty useless in others, such as graphics or
numerical algorithms.
The following three are
well-known titles, but you may also consult any other textbook on Prolog.
• I. Bratko. Prolog Programming for Artificial Intelligence. 3rd edition, Addison-
Wesley Publishers, 2001.
• F. W. Clocksin and C. S. Mellish. Programming in Prolog. 5th edition, Springer-
Verlag, 2003.
• L. Sterling and E. Shapiro. The Art of Prolog. 2nd edition, MIT Press, 1994.

2. Getting Started: An Example

In the introduction it has been said that Prolog is a declarative (or descriptive) language.
Programming in Prolog means describing the world. Using such programs means asking
Prolog questions about the previously described world. The simplest way of describing
the world is by stating facts, like this one:

bigger(elephant, horse).

This states, quite intuitively, the fact that an elephant is bigger than a horse. (Whether
the world described by a Prolog program has anything to do with our real world is, of
course, entirely up to the programmer.) Let’s add a few more facts to our little program:

bigger(elephant, horse).
bigger(horse, donkey).
bigger(donkey, dog).
bigger(donkey, monkey).

This is a syntactically correct program, and after having compiled it we can ask the Prolog
system questions (or queries in proper Prolog-jargon) about it. Here’s an example:

?- bigger(donkey, dog).
Yes

The query bigger(donkey, dog) (i.e. the question “Is a donkey bigger than a dog?”)
succeeds, because the fact bigger(donkey, dog) has previously been communicated to
the Prolog system. Now, is a monkey bigger than an elephant?

?- bigger(monkey, elephant).
No
No, it’s not. We get exactly the answer we expected: the corresponding query, namely
bigger(monkey, elephant) fails. But what happens when we ask the other way round?

?- bigger(elephant, monkey).
No

According to this elephants are not bigger than monkeys. This is clearly wrong as far as
our real world is concerned, but if you check our little program again, you will find that
it says nothing about the relationship between elephants and monkeys. Still, we know
that if elephants are bigger than horses, which in turn are bigger than donkeys, which in
turn are bigger than monkeys, then elephants also have to be bigger than monkeys. In
mathematical terms: the bigger-relation is transitive. But this has also not been defined
in our program. The correct interpretation of the negative answer Prolog has given is
the following: from the information communicated to the system it cannot be proved
that an elephant is bigger than a monkey.
If, however, we would like to get a positive reply for a query like bigger(elephant,
monkey), we have to provide a more accurate description of the world. One way of doing
this would be to add the remaining facts, like e.g. bigger(elephant, monkey), to our
program. For our little example this would mean adding another 5 facts. Clearly too
much work and probably not too clever anyway.
The far better solution would be to define a new relation, which we will call
is_bigger, as the transitive closure (don’t worry if you don’t know what that means)
of bigger. Animal X is bigger than animal Y either if this has been stated as a fact or if
there is an animal Z for which it has been stated as a fact that animal X is bigger than
animal Z and it can be shown that animal Z is bigger than animal Y. In Prolog such
statements are called rules and are implemented like this:

is_bigger(X, Y) :- bigger(X, Y).
is_bigger(X, Y) :- bigger(X, Z), is_bigger(Z, Y).
In these rules :- means something like “if” and the comma between the two terms
bigger(X, Z) and is_bigger(Z, Y) stands for “and”. X, Y, and Z are variables, which
in Prolog is indicated by using capital letters.
You can think of the the bigger-facts as data someone has collected by browsing
through the local zoo and comparing pairs of animals. The implementation of is_bigger,
on the other hand, could have been provided by a knowledge engineer who may not
know anything at all about animals, but understands the general concept of something
being bigger than something else and thereby has the ability to formulate general rules
regarding this relation. If from now on we use is_bigger instead of bigger in our
queries, the program will work as intended:

?- is_bigger(elephant, monkey).
Yes

Prolog still cannot find the fact bigger(elephant, monkey) in its database, so it tries
to use the second rule instead. This is done by matching the query with the head of the
rule, which is is_bigger(X, Y). When doing so the two variables get instantiated: X =
elephant and Y = monkey. The rule says that in order to prove the goal is_bigger(X,
Y) (with the variable instantiations that’s equivalent to is_bigger(elephant, monkey))
Prolog has to prove the two subgoals bigger(X, Z) and is_bigger(Z, Y), again with
the same variable instantiations. This process is repeated recursively until the facts
that make up the chain between elephant and monkey are found and the query finally
succeeds.

3. Prolog Syntax


This section describes the most basic features of the Prolog programming language.
1. Terms
The central data structure in Prolog is that of a term. There are terms of four kinds:
atoms, numbers, variables, and compound terms. Atoms and numbers are sometimes
grouped together and called atomic terms.

Atoms.: Atoms are usually strings made up of lower- and uppercase letters, digits, and
the underscore, starting with a lowercase letter. The following are all valid Prolog atoms:

elephant, b, abcXYZ, x_123, another_pint_for_me_please

On top of that also any series of arbitrary characters enclosed in single quotes denotes
an atom.

’This is also a Prolog atom.’

Finally, strings made up solely of special characters like + - * = < > : & (check the
manual of your Prolog system for the exact set of these characters) are also atoms.
Examples:

+, ::, <------>, ***

Numbers.: All Prolog implementations have an integer type: a sequence of digits,
optionally preceded by a - (minus). Some also support floats. Check the manual for
details.
Variables.:" Variables are strings of letters, digits, and the underscore, starting with a
capital letter or an underscore. Examples:

X, Elephant, _4711, X_1_2, MyVariable, _

The last one of the above examples (the single underscore) constitutes a special case.
It is called the anonymous variable and is used when the value of a variable is of no
particular interest. Multiple occurrences of the anonymous variable in one expression
are assumed to be distinct, i.e. their values don’t necessarily have to be the same.

Compound terms.: Compound terms are made up of a functor (a Prolog atom) and
a number of arguments (Prolog terms, i.e. atoms, numbers, variables, or other compound
terms) enclosed in parentheses and separated by commas. The following are some
examples for compound terms:

is_bigger(horse, X), f(g(X, _), 7), ’My Functor’(dog)

It’s important not to put any blank characters between the functor and the opening
parentheses, or Prolog won’t understand what you’re trying to say. In other places,
however, spaces can be very helpful for making programs more readable.
The sets of compound terms and atoms together form the set of Prolog predicates.
A term that doesn’t contain any variables is called a ground term.

Clauses, Programs and Queries


In the introductory example we have already seen how Prolog programs are made up of
facts and rules. Facts and rules are also called clauses.
Facts. A fact is a predicate followed by a dot.
Examples:

bigger(whale, _).
life_is_beautiful.

The intuitive meaning of a fact is that we define a certain instance of a relation as being
true.

Rules.: A rule consists of a head (a predicate) and a body. (a sequence of predicates
separated by commas). Head and body are separated by the sign :- and, like every
Prolog expression, a rule has to be terminated by a dot.
Examples:
is_smaller(X, Y) :- is_bigger(Y, X).
aunt(Aunt, Child) :-
sister(Aunt, Parent),
parent(Parent, Child).

The intuitive meaning of a rule is that the goal expressed by its head is true, if we (or
rather the Prolog system) can show that all of the expressions (subgoals) in the rule’s
body are true.

Programs.: A Prolog program is a sequence of clauses.
Queries.: After compilation a Prolog program is run by submitting queries to the interpreter.
A query has the same structure as the body of a rule, i.e. it is a sequence
of predicates separated by commas and terminated by a dot. They can be entered at
the Prolog prompt, which in most implementations looks something like this: ?-. When
writing about queries we often include the ?-.

Examples:
?- is_bigger(elephant, donkey).
?- small(X), green(X), slimy(X).

Intuitively, when submitting a query like the last example, we ask Prolog whether all its
predicates are provably true, or in other words whether there is an X such that small(X),
green(X), and slimy(X) are all true.

Some Built-in Predicates

What we have seen so far is already enough to write simple programs by defining predicates
in terms of facts and rules, but Prolog also provides a range of useful built-in
predicates. Some of them will be introduced in this section; all of them should be explained
in manual of your Prolog system.
Built-ins can be used in a similar way as user-defined predicates. The important
difference between the two is that a built-in predicate is not allowed to appear as the
principal functor in a fact or the head of a rule. This must be so, because using them in
such a position would effectively mean changing their definition.

Goal Execution
Submitting a query means asking Prolog to try to prove that the statement(s) implied
by the query can be made true provided the right variable instantiations are made. The
search for such a proof is usually referred to as goal execution. Each predicate in the query
constitutes a (sub)goal, which Prolog tries to satisfy one after the other. If variables are
shared between several subgoals their instantiations have to be the same throughout the
entire expression.
If a goal matches with the head of a rule, the respective variable instantiations are
made inside the rule’s body, which then becomes the new goal to be satisfied. If the body
consists of several predicates the goal is again split into subgoals to be executed in turn.
In other words, the head of a rule is considered provably true, if the conjunction of all
its body-predicates are provably true. If a goal matches with a fact in our program the
proof for that goal is complete and the variable instantiations made during matching are
communicated back to the surface. Note that the order in which facts and rules appear
in our program is important here. Prolog will always try to match its current goal with
the first possible fact or rule-head it can find.

If the principal functor of a goal is a built-in predicate the associated action is executed
whilst the goal is satisfied. For example, as far as goal execution is concerned the
predicate

write(’Hello World!’)

will simply succeed, but at the same time it will also print the words Hello World! on
the screen.
As mentioned before the built-in predicate true will always succeed (without any
further side-effects), whereas fail will always fail.
Sometimes there is more than one way of satisfying the current goal. Prolog chooses
the first possibility (as determined by the order of clauses in a program), but the fact
that there are alternatives is recorded. If at some point Prolog fails to prove a certain
subgoal, the system can go back and try an alternative way of executing the previous
goal. This process is known as backtracking.

Prolog agrees with our own logical reasoning. Which is nice. But how did it come to its
conclusion? Let’s follow the goal execution step by step.
(1) The query mortal(socrates) is made the initial goal.
(2) Scanning through the clauses of our program, Prolog tries to match
mortal(socrates) with the first possible fact or head of rule. It finds mortal(X),
the head of the first (and only) rule. When matching the two terms the instantiation
X = socrates needs to be made.
(3) The variable instantiation is extended to the body of the rule, i.e. man(X) becomes
man(socrates).
(4) The newly instantiated body becomes our new goal: man(socrates).
(5) Prolog executes the new goal by again trying to match it with a rule-head or a fact.
Obviously, the goal man(socrates) matches the fact man(socrates), because they
are identical. This means the current goal succeeds.
(6) This, again, means that also the initial goal succeeds.

One of the major advantages of Prolog is that it allows for writing very short and compact
programs solving not only comparatively difficult problems, but also being readable and

(again: comparatively) easy to understand.

Of course, this can only work, if the programmer (you!) pays some attention to his
or her programming style. As with every programming language, comments do help.
In Prolog comments are enclosed between the two signs /* and */, like this:

/* This is a comment. */

Comments that only run over a single line can also be started with the percentage sign
%. This is usually used within a clause.
aunt(X, Z) :-
sister(X, Y), % A comment on this subgoal.
parent(Y, Z).

Besides the use of comments a good layout can improve the readability of your programs
significantly. The following are some basic rules most people seem to agree on:
(1) Separate clauses by one or more blank lines.
(2) Write only one predicate per line and use indentation:

blond(X) :-
father(Father, X),
blond(Father),
mother(Mother, X),
blond(Mother).

(Very short clauses may also be written in a single line.)

(3) Insert a space after every comma inside a compound term:
born(mary, yorkshire, ’01/01/1980’)
(4) Write short clauses with bodies consisting of only a few goals. If necessary, split
into shorter sub-clauses.
(5) Choose meaningful names for your variables and atoms.

Thanks For Reading.Keep Visiting.!!!

Ajax


Ajax Technology in Web


AJAX

Ajax, shorthand for Asynchronous JavaScript
and XML

• Web development technique for creating
interactive web applications

• The intent is to make web pages feel more
responsive by exchanging small amounts of
data with the server behind the scenes, so
that the entire web page does not have to be
reloaded each time the user makes a change

• This is meant to increase the web page's
interactivity, speed, and usability
The first known use of the term in public
was by Jesse James Garrett in his
February 2005 article Ajax: A New
Approach to Web Applications

• At subsequent talks and seminars
Garrett has made the point that Ajax is
not an acronym
Ajax Technology

Ajax Technology

The Ajax technique uses a combination of:

– XHTML (or HTML), CSS, for marking up and styling information.

– The DOM accessed with a client-side scripting language,
especially ECMAScript implementations such as JavaScript
and JScript, to dynamically display and interact with the
information presented.

– The XMLHttpRequest object to exchange data asynchronously
with the web server. In some Ajax frameworks and in certain
situations, an IFrame object is used instead of the
XMLHttpRequest object to exchange data with the web server.

– XML is sometimes used as the format for transferring data
between the server and client, although any format will work,
including preformatted HTML, plain text, JSON and other
formats.

• Like DHTML, LAMP, or SPA, Ajax is not a technology in
itself, but a term that refers to the use of a group of
technologies together.

XMLHttpRequest

• XMLHttpRequest is an API that can be
used by JavaScript, JScript, VBScript
and other web browser scripting
languages to transfer and manipulate
XML data to and from a web server
using HTTP, establishing an
independent connection channel
between a web page's Client-Side and
Server-Side.

• The XMLHttpRequest concept was originally
developed by Microsoft.

• The Microsoft implementation is called
XMLHTTP and, as an ActiveX object, it differs
from the published standard in a few small
ways. It has been available since Internet
Explorer 5.0 and is accessible via JScript,
VBScript and other scripting languages
supported by IE browsers.

• The Mozilla project incorporated the first
compatible native implementation of
XMLHttpRequest in Mozilla 1.0 in 2002.

• This implementation was later followed
by Apple since Safari 1.2, Konqueror,
Opera Software since Opera 8.0 and
iCab since 3.0b352.

• The World Wide Web Consortium published a
Working Draft specification for the
XMLHttpRequest object's API on 5 April
2006.

• While this is still a work in progress, its goal is
"to document a minimum set of interoperable
features based on existing implementations,
allowing Web developers to use these
features without platform-specific code".

• The draft specification is based upon existing
popular implementations, to help improve and
ensure interoperability of code across web
platforms.

• Methods:
– abort()
– getAllResponseHeaders()
– getResponseHeader(header)
– open(method, url, asyncronous, user,
password):
– send(content)
– setRequestHeader(header, value)


• open(method, url, async,
user, password):
– Initializes an XMLHTTP request.
– Specifies the method, URL, and
authentication information for the request.
– After calling this method, you must call
send to send the request and data, if any,
to the server.

• send(content):
– Sends an HTTP request to the server and
receives a response.
– null for no data.

• Properties:
– onreadystatechange
– readyState
– responseText
– responseXML
– status
– statusText

• onreadystatechange:
– Function than handles the different events

• readyState:
– The property is read-only
– It represents the state of the request as an
integer
– The following values are defined:

• readyState:
– 0 (UNINITIALIZED): The object has been created, but not
initialized (the open method has not been called)
– (1) LOADING: The object has been created, but the send method has not been called.
– (2) LOADED: The send method has been called, but the
status and headers are not yet available.
– (3) INTERACTIVE: Some data has been received. Calling
the responseText property at this state to obtain partial
results will return an error, because status and response
headers are not fully available.
– (4) COMPLETED: All the data has been received, and the
complete data is available in the responseText property.

• readyState:
– 0 (UNINITIALIZED): The object has been created, but not
initialized (the open method has not been called)
– (1) LOADING: The object has been created, but the send
method has not been called.
– (2) LOADED: The send method has been called, but the
status and headers are not yet available.
– (3) INTERACTIVE: Some data has been received. Calling
the responseText property at this state to obtain partial
results will return an error, because status and response
headers are not fully available.
– (4) COMPLETED: All the data has been received, and the
complete data is available in the responseText property

• responseText:
– The property is read-only.
– This property represents only one of
several forms in which the HTTP response
can be returned.

• responseXML:
– The property is read-only.
– This property represents the parsed
response entity body.

AJAX step by step

1. Create XMLHttpRequest object
2. Assign a function to the state change event
3. Send a request to the server
4. On a state change, manage the response
5. On a correct response, process the result
and show to the user.

Create XMLHttpRequest object

• Depending on the browser:
– Internet Explorer
request = new ActiveXObject("Microsoft.XMLHTTP");
– Otros navegadores:
request = new XMLHttpRequest();

• Code adapted for different browsers:
if(window.XMLHttpRequest) {
request = new XMLHttpRequest();
}
else if(window.ActiveXObject) {
request = new ActiveXObject("Microsoft.XMLHTTP");

Assign a function to the state change event

• This function will be called
automatically, every time the state of
the XMLHttpRequest object changes:
request.onreadystatechange = nameOfFunction
Important: without “( )”, only the name.

Send a request to the server
• Open the connection, define the method and
the type of connection:
– A synchronous connection (false) blocks the
browser until the response is obtained
– An asynchronous connection (true and default
value) executes on the background
– Important: the URL must belong to the same
domain of the current page
request.open('GET','http://www.ua.es/ajax.jsp',
true);
• Send the additional data:request.send(data or null)

On a state change, manage the response
• The handler is called every time there is a change:
• 0: UNINITIALIZED
• 1: LOADING
• 2: LOADED
• 3: INTERACTIVE
• 4: COMPLETED
• Example of handler:
if (request.readyState == 4) { // Finished
if (request.status==200) { // OK
// Process the result
}
}
else {
// Not finished
}

On a correct response, process the result and
show to the user

• The result can be in different formats:
plain text, HTML, JSON, XML, etc.

• responseText when not structured
result as XML:
alert(request.responseText);

• responseXML when structured result
as XML:
– Returns an XMLDocument object
– Use DOM functions

Example

<script type="text/javascript">
function ajaxFunction() {
var xmlHttp;
if (window.XMLHttpRequest)
xmlHttp = new XMLHttpRequest();
else
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.onreadystatechange=function() {
if(xmlHttp.readyState == 4) {
document.myForm.time.value += xmlHttp.responseText + "\n";
}
}
xmlHttp.open("GET","time.php",true);
xmlHttp.send(null);
}
</script>

Anather one Example

Example
<html>
<head>
<title>Ajax example</title>
<!-- script -->
</head>
<body>
<form name="myForm">
Name: <input type="text"
onkeyup="ajaxFunction();" name="username" />
<br />
Time: <textarea name="time" cols="40"
rows="10"></textarea>
</form>
</body>
</html>

• PHP:
<?php
header("Expires: -1");
$str1 = date('h:i:s A');
sleep(2);
$str2 = date('h:i:s A');
echo "$str1 -- $str2";
?>

Who’s Using Ajax

Google is making a huge investment in developing the Ajax approach. All of the major products Google has introduced over the last
year — Orkut, Gmail, the latest beta version of Google Groups, Google Suggest, and Google Maps — are Ajax applications. (For more
on the technical nuts and bolts of these Ajax implementations, check out these excellent analyses of Gmail, Google Suggest, and
Google Maps.) Others are following suit: many of the features that people love in Flickr depend on Ajax, and Amazon’s A9.com
search engine applies similar techniques.

These projects demonstrate that Ajax is not only technically sound, but also practical for real-world applications. This isn’t another
technology that only works in a laboratory. And Ajax applications can be any size, from the very simple, single-function Google
Suggest to the very complex and sophisticated Google Maps.

At Adaptive Path, we’ve been doing our own work with Ajax over the last several months, and we’re realizing we’ve only scratched the
surface of the rich interaction and responsiveness that Ajax applications can provide. Ajax is an important development for Web
applications, and its importance is only going to grow. And because there are so many developers out there who already know how to use these technologies, we expect to see many more organizations following Google’s lead in reaping the competitive advantage Ajax
provides.

Artificial Intelligent-IV

Artificial Intelligent-IV Hello ,                So    we have go forward to learn new about Artificial Intelligent S...