Курсы английского
<<  Metadata for Formatting with Multiple Aspect Ratios Активные туры по России для иностранного туриста: проблемы и перспективы  >>
The Basics
The Basics
The Basics
The Basics
Картинки из презентации «Artificial Intelligence Prolog Language Tutorial» к уроку английского языка на тему «Курсы английского»

Автор: Michael Scherger. Чтобы познакомиться с картинкой полного размера, нажмите на её эскиз. Чтобы можно было использовать все картинки для урока английского языка, скачайте бесплатно презентацию «Artificial Intelligence Prolog Language Tutorial.ppt» со всеми картинками в zip-архиве размером 52 КБ.

Artificial Intelligence Prolog Language Tutorial

содержание презентации «Artificial Intelligence Prolog Language Tutorial.ppt»
Сл Текст Сл Текст
1Artificial Intelligence Prolog 18the “%” character Multi-line comments use
Language Tutorial. Michael Scherger /* and */. October 21, 2004. AI: Prolog
Department of Computer Science Kent State Language Tutorial. 18.
University. October 21, 2004. AI: Prolog 19The Basics. Simple I/O in Prolog Use
Language Tutorial. 1. the write statement write(‘hello’)
2Contents. A Small Example The Basics write(‘Hello’), write(‘World’) Use a
Another Example: Towers of Hanoi Other Newline write(‘hello’), nl,
Examples More to add!!!!!! October 21, write(‘World’). October 21, 2004. AI:
2004. AI: Prolog Language Tutorial. 2. Prolog Language Tutorial. 19.
3A Small Example. Let us consider the 20The Basics. Reading a value from stdin
following description of a “system”; Ann Prolog Syntax: read(X) Example read(X),
likes every toy she plays with. A doll is write(X). October 21, 2004. AI: Prolog
a toy. A train is a toy. Ann plays with Language Tutorial. 20.
trains. John likes everything Ann likes. 21The Basics. Using Arithmetic Different
To express this in Prolog we must: to what you may have seen with other
Identify the entities, or actual things, languages. Operators < <= == !=
mentioned in the description Identify the => > + - * / Arithmetic is done via
types of properties that things can have, evaluation then unification. October 21,
as well as the relations that can hold 2004. AI: Prolog Language Tutorial. 21.
between these things Figure out which 22The Basics. Arithmetic Example X is Y
properties/relations hold for which compute Y then unify X and Y X is Y * 2 N
entities There is really no unique way of is N - 1. October 21, 2004. AI: Prolog
doing this; we must decide the best way to Language Tutorial. 22.
structure our data (based on what we want 23The Basics. X == Y This is the
to do with it). October 21, 2004. AI: identity relation. In order for this to be
Prolog Language Tutorial. 3. true, X and Y must both be identical
4A Small Example. We will choose the variables (i.e. have the same name), or
following: Things: Ann, Sue, doll, train both be identical constants, or both be
Properties: “... is a toy” Relations: “... identical operations applied to identical
likes ...”, “... plays with ...” terms X = Y This is unification It is true
Constructing our knowledge base then if X is unifiable with Y. October 21,
consists of writing down which properties 2004. AI: Prolog Language Tutorial. 23.
and relationships hold for which things. 24The Basics. X=:=Y This means “compute
October 21, 2004. AI: Prolog Language X, compute Y, and see if they both have
Tutorial. 4. the same value” both X and Y must be
5A Small Example. We write: arithmetic expressions X is Y This means
likes(ann,X) :- toy(X), plays(ann,X). compute Y and then unify X and Y Y must be
toy(doll). toy(train). plays(ann,train). an arithmetic expression X can either be
likes(john,Y) :- likes(ann,Y). October 21, an arithmetic expression (of the same
2004. AI: Prolog Language Tutorial. 5. form), or a variable. October 21, 2004.
6A Small Example – What It Means. There AI: Prolog Language Tutorial. 24.
are three important logical symbols :- if 25The Basics. Arithmetic Exercises X =
, and ; or X and Y are variables ann, 2, Y is X+1 X = 2, Y = X+1 X = 2, Y == X+1
john, doll and train are constants likes, X = 2, Y =:= X+1 X = 2, 3 =:= X+1. October
toy and plays are predicate symbols. 21, 2004. AI: Prolog Language Tutorial.
October 21, 2004. AI: Prolog Language 25.
Tutorial. 6. 26The Basics. Arithmetic Examples
7A Small Example – What It Means. A gcd(X,X,X). gcd(X,Y,Z) :- X<Y, Y1 is
variable represents some unspecified Y-X, gcd(X,Y1,Z). gcd(X,Y,Z) :- X>Y, X1
element of the system A constant is X-Y, gcd(X1,Y,Z). October 21, 2004. AI:
represents a particular, known, member of Prolog Language Tutorial. 26.
the system A predicate represents some 27The Basics. Arithmetic Example:
relation or property in the system. Note factorial.pl fact(0,1). fact(X,F) :-
that: Variables always start with an X>0, X1 is X-1, fact(X1,F1), F is X*F1.
upper-case letter or an underscore October 21, 2004. AI: Prolog Language
Predicates and constants always start with Tutorial. 27.
a lower-case letter or digit. October 21, 28Towers of Hanoi. The Problem A group
2004. AI: Prolog Language Tutorial. 7. of over-proud monks in a Hanoi monastery
8A Small Example – What It Means. Each were assigned a task to perform: they had
line in a Prolog program is called a to move 100 discs from one peg to another
clause There are two types of clauses - with the help of a third peg. There are
facts and rules Rules are clauses which only two rules: Only one disc can be moved
contain the “:-” symbol Facts are clauses at a time The discs are all of different
which don't Each fact consists of just one sizes, and no disc can be placed on top of
predicate Each rule consists of a a smaller one We want to write a Prolog
predicate, followed by a “:-” symbol, program to solve this. October 21, 2004.
followed by a list of predicates separated AI: Prolog Language Tutorial. 28.
by “,” or “;” Every clause is terminated 29Towers of Hanoi. The Rules!!!! In
by a “.” (full-stop). In a rule, the order to work out a recursive solution we
predicate before the “:-” is called the must find something to "do" the
head of the rule The predicates coming recursion on, that is, something with: a
after the ``:-'' are called the body. base case an inductive case that can be
October 21, 2004. AI: Prolog Language expressed in terms of something smaller We
Tutorial. 8. will choose to proceed by induction on the
9A Small Example – What It Means. For number of discs that we want to transfer.
example: likes(ann,X) :- toy(X), October 21, 2004. AI: Prolog Language
plays(ann,X). <---Head---> Tutorial. 29.
<-------Body-------> October 21, 30Towers of Hanoi. Moving a disc The
2004. AI: Prolog Language Tutorial. 9. basic activity will be moving a single
10A Small Example – What It Means. We disc from one peg to another. Suppose we
“define a predicate” by writing down a want to define a predicate for this called
number of clauses which have that move; thus: move(A,B) means move the
predicate at their head The order in which topmost disc from peg A to peg B. So how
we write these down is important Any should we define move? If we were doing
predicates mentioned in the body must the problem in reality then we would want
either: be defined somewhere else in the to formulate some instructions to a robot
program, or be one of Prolog's “built-in” arm (attached to the computer) to move the
predicates. Defining a predicate in Prolog pegs. October 21, 2004. AI: Prolog
corresponds roughly to defining a Language Tutorial. 30.
procedure Predicates occurring in the body 31Towers of Hanoi. Moving a disk (cont.)
of a clause correspond roughly to For our purposes, we will assume that what
procedure calls Note also that: Constants we want is a list of instructions for the
and variables will never appear “on their monks; thus we define: move(A,B) :- nl,
own” in a clause. They can only appear as write('Move topmost disc from '),
the “arguments” to some predicate. write(A), write(' to '), write(B). Every
Predicates will (almost) never appear as time we call move, the appropriate
arguments to another predicate. October instruction will be printed out on screen.
21, 2004. AI: Prolog Language Tutorial. October 21, 2004. AI: Prolog Language
10. Tutorial. 31.
11A Small Example – What It Says. So, 32Towers of Hanoi. Base Case An initial
after all that, what does our little attempt might select 1 as the base case.
program say? Having all the relations To transfer one disc from A to B, simply
expressed as a predicate followed by move it: transfer(1,A,B,I) :- move(A,B).
arguments is not particularly intuitive, In fact there is an even simpler base case
so with some suitable swapping-around we - when N=0! If we have no discs to
get: For any X, (ann likes X) if (X transfer, then the solution is to simply
is-a-toy) and (ann plays-with X). (doll do nothing. That is, transfer(0,A,B,I) is
is-a-toy). (train is-a-toy). (ann satisfied by default. We write this as a
plays-with train). For any Y, (john likes fact: transfer(0,A,B,I). October 21, 2004.
Y) if (ann likes Y). October 21, 2004. AI: AI: Prolog Language Tutorial. 32.
Prolog Language Tutorial. 11. 33Towers of Hanoi. Inductive Case To do
12A Small Example – Running It. So how the inductive case, suppose we are trying
do we run it? We run it by giving Prolog a to transfer N discs from A to B. By
query to prove A query has exactly the induction, we may assume that we have a
same format as a clause-body: one or more program that transfers N-1 discs. The way
predicates, separated by “,” or “;”, we proceed is: Transfer the top N-1 discs
terminated by a full-stop Thus, we might from A to I Transfer the last disc from A
enter in the following as a query: to B Transfer the N-1 discs from I to B
likes(john,Z). Logically, this can be Example: Towers of Hanoi. October 21,
interpreted as “is there a Z such that 2004. AI: Prolog Language Tutorial. 33.
john likes Z?” From a relational point of 34Other Examples. Example: Making Change
view, we can read it as: “List all those Example: Who owns what car Example: Things
Z's that john likes”. October 21, 2004. in my kitchen. October 21, 2004. AI:
AI: Prolog Language Tutorial. 12. Prolog Language Tutorial. 34.
13A Small Example – Running It. In 35Prolog Lists. Lists are a collection
general terms we call the query our of terms inside [ and ] [ chevy, ford,
“goal”, and say that Prolog is being asked dodge] loc_list([apple, broccoli,
to (find ways to) “satisfy” the goal This crackers], kitchen). loc_list([desk,
process is also known as inferencing: computer], office). loc_list([flashlight,
Prolog has to infer the solution to the envelope], desk). loc_list([stamp, key],
query from the knowledge base Note that envelope). loc_list(['washing machine'],
solving a query results in either: cellar). loc_list([nani], 'washing
failure, in which case “no” is printed machine'). loc_list([], hall). October 21,
out, or success, in which case all sets of 2004. AI: Prolog Language Tutorial. 35.
values for the variables in the goal 36Prolog Lists. Unification works on
(which cause it to be satisfied) are lists just as it works on other data
printed out. October 21, 2004. AI: Prolog structures. loc_list(X, kitchen). X =
Language Tutorial. 13. [apple, broccoli, crackers] ?- [_,X,_] =
14A Small Example – How It Works. So how [apples, broccoli, crackers]. X = broccoli
does Prolog get an answer? We have to The patterns won't unify unless both lists
solve likes(john,Y), so we must examine have the same number of elements. October
all the clauses which start with the 21, 2004. AI: Prolog Language Tutorial.
predicate likes. The first one is of no 36.
use at this point, since it only tells us 37Prolog Lists. List functions [H|T]
what ann likes. The second rule for likes separate list into head and tail member
tells us us that in order to find test if X is a member of a list append
something that john likes, we need only to append two lists to form a third list.
find something which ann likes. So now we October 21, 2004. AI: Prolog Language
have a new goal to solve - likes(ann,Z). Tutorial. 37.
To solve this we again examine all the 38Prolog Lists. Head and Tail of a List
rules for likes. This time the first rule Syntax [H|T] Examples ?- [a|[b,c,d]] =
matches (and the second doesn't), and so [a,b,c,d]. yes ?- [a|b,c,d] = [a,b,c,d].
we are told that in order to find no. October 21, 2004. AI: Prolog Language
something which ann likes, we must find Tutorial. 38.
something which is a toy, and which ann 39Prolog Lists. More Examples ?- [H|T] =
plays with. October 21, 2004. AI: Prolog [apple, broccoli, refrigerator]. H = apple
Language Tutorial. 14. T = [broccoli, refrigerator] ?- [H|T] =
15A Small Example – How It Works. So [a, b, c, d, e]. H = a T = [b, c, d, e] ?-
first of all we try to find a toy. To do [H|T] = [apples, bananas]. H = apples T =
this we examine the clauses with toy at [bananas]. October 21, 2004. AI: Prolog
their head. There are two possibilities Language Tutorial. 39.
here: a toy is either a doll or train. We 40Prolog Lists. More Examples ?- [One,
now take these two toys, and test to see Two | T] = [apple, sprouts, fridge, milk].
which one ann plays with; that is, we One = apple Two = sprouts T = [fridge,
generate two new sub-goals to solve: milk] ?- [a|[b|[c|[d|[]]]]] = [a,b,c,d].
plays(ann,doll) and plays(ann,train). In yes. October 21, 2004. AI: Prolog Language
general, to solve these, we must look at Tutorial. 40.
the clauses for plays. There is only one: 41Prolog Lists. Testing if an element is
since it is for train, we conclude with in a list. Syntax member(X, L). Example
the answer: Z = train. October 21, 2004. member(apple, [apple, broccoli,
AI: Prolog Language Tutorial. 15. crackers]). member(X, CarList). Full
16A Small Example - Exercises. Example: Predicate defined as: member(H,[H|T]).
toys.pl Does Ann like dolls? Who likes member(X,[H|T]) :- member(X,T). October
trains? What does John like? Who plays 21, 2004. AI: Prolog Language Tutorial.
with trains? October 21, 2004. AI: Prolog 41.
Language Tutorial. 16. 42Prolog Lists. Appending two lists to
17A Small Example - Exercises. Translate form a third. Syntax append(L1, L2, L3).
the following sentences into Prolog: John Example append( [a,b,c], [d,e,f], X). X =
eats all kinds of food. Apples are food. [a,b,c,d,e,f] Full predicate defined as:
Oysters are food. Anything anyone eats is append([],X,X). append([H|T1],X,[H|T2]) :-
food. Tom eats snakes. Sue eats everything append(T1,X,T2). October 21, 2004. AI:
that Tom eats. Save the program in a file Prolog Language Tutorial. 42.
called food.pl. Now read them into Prolog, 43Control Structures. Looping…Repeat
and formulate queries to find out: What until user enters “end” command_loop:-
John eats What Sue eats If there is repeat, write('Enter command (end to
anything which both John and Sue eat. Who exit): '), read(X), write(X), nl, X = end.
eats snakes. October 21, 2004. AI: Prolog October 21, 2004. AI: Prolog Language
Language Tutorial. 17. Tutorial. 43.
18The Basics. Single line comments use
Artificial Intelligence Prolog Language Tutorial.ppt
http://900igr.net/kartinka/anglijskij-jazyk/artificial-intelligence-prolog-language-tutorial-110829.html
cсылка на страницу

Artificial Intelligence Prolog Language Tutorial

другие презентации на тему «Artificial Intelligence Prolog Language Tutorial»

«Курс обучения в Language Link» - Отзывы клиентов. Международные экзамены. Методика обучения. Бизнес-английский для специалистов. Профессионализм Language Link вполне оправдал наши ожидания. Корпоративное обучение иностранным языкам. Преимущества обучения в Language Link. Услуги. Переводы. Преимущества документооборота. Обучение за рубежом.

«Центр английского языка» - Докажи самому себе, что сможешь сам раскрасить свою жизнь новыми красками. Все в ваших руках. Пользоваться свободно Интернетом. Ваше время бесценно. Вы сможете всецело насладиться искусством. Casual English. Центр английского языка. Центр английского языка «You’re the best». Мы расширим Ваши возможности получения информации.

«Деловой английский» - Аннотация проекта. Обладаешь ли ты качествами лидера? Подготовка презентации по отчету о проделанной работе. Обсуждение плана работы. Учащиеся должны научиться методам работы с информацией. Информационные ресурсы. Какие разделы следует включить в резюме. Методы оформления информации в виде слайдовой презентации, публикации, веб-сайта.

«Профессор Хиггинс» - Программа . Уроки состоят из нескольких упражнений. Возможности программы. Приложения. Курс фонетики увеличен в объеме, расширена возможностью видеть имена фонем в эталонном произношении. Курс . Выполняя упражнения, учащийся может натренировать данное правило и проверить, насколько хорошо он его понял.

«Курс обучения в Language Link» - Деловой английский. Методика обучения. Бизнес-английский для специалистов. Основные программы обучения. Преимущества документооборота. Переводы. Международный языковой центр Language Link. Корпоративное обучение иностранным языкам. Профессиональные преимущества. Бизнес-английский для специальных целей.

«Английский язык дома» - Помощь по дому. grandfather grandmother mother brother sister. В доме у нас появилась девчонка! Радость в глазах, в глазах удивленье, в семье у нас нынче еще прибавленье! do- go- make- lay- repair- answer- clean- water- wash-. Для сестры –авторитет, смелее мальчишки на свете нет … Отгадать загадки; перевести отгадки на английский язык.

Курсы английского

25 презентаций о курсах английского
Урок

Английский язык

29 тем
Картинки