prolog_1_2_3

در نمایش آنلاین پاورپوینت، ممکن است بعضی علائم، اعداد و حتی فونت‌ها به خوبی نمایش داده نشود. این مشکل در فایل اصلی پاورپوینت وجود ندارد.






  • جزئیات
  • امتیاز و نظرات
  • متن پاورپوینت

امتیاز

درحال ارسال
امتیاز کاربر [0 رای]

نقد و بررسی ها

هیچ نظری برای این پاورپوینت نوشته نشده است.

اولین کسی باشید که نظری می نویسد “Logic Programming Prolog”

Logic Programming Prolog

اسلاید 1: 1Lecture 12 Introduction to PrologLogic ProgrammingProlog

اسلاید 2: 2Lecture 12 Introduction to PrologProlog(Programming in Logic)Has been around since 70’sW.F. Clocksin, Programming in Prolog, Springer-Verlag New York Inc., 1998. Bratko, I (2001), PROLOG: programming for artificial intelligence, Third edition, Addison-Wesley. Prolog is an un-typed languageProlog is a declarative programming languageProlog is based on First Order (predicate) LogicProlog was selected as the language of the fifth generation computers by the JapaneseProlog, is a suitable language for solving problems involving objects and relationships among these objects. A Prolog program consists of facts and rules.

اسلاید 3: 3Lecture 12 Introduction to PrologAI programmingRelational databasesNatural languagesMachine learning Robot planningSymbolic solution of equationsChemical structure analysisExpert SystemsMechanical Theorem ProversApplications of Prolog

اسلاید 4: 4Lecture 12 Introduction to PrologSolving a problem using Prolog involvesDeclaring factsDefining rules Asking questionsFactsMary likes john. likes(mary, john).Predicate(in lowercase) Arguments (in lowercase) A name beginning with a lowercase letter is an atomA fact ends with a full stop.Arguments are seperated with commas.The order of arguments is arbitrary but the order chosen must be used consistently.A fact may have an arbitrary number of arguments.

اسلاید 5: 5Lecture 12 Introduction to Prologmarylikes(mary, john).and the variable X are all terms.A term may be simple or compound.A simple term may beAn atomA number Or a variable.A compound term consists of a functor followed by a number of arguments. The number of arguments is referred to as the arity of the functor.All Prolog data objects are terms. For instance,

اسلاید 6: 6Lecture 12 Introduction to PrologAlthough we have to be consistent in the use of predicate and object names, they are arbitrary. We could have declared the above fact as: l(m,j). This would, however, make the program less readable. Other examples of factsinteresting(declarative_programming).useful(declarative_programming).male(john).female(mary).father(john,mary).great(massey).has_a_job(mary).happy(john).plays(mary,john,tennis).valuable(money).gives(john,mary,money).

اسلاید 7: 7Lecture 12 Introduction to PrologA prolog database is a collection of facts (and rules).likes(tom,jerry).likes(mary,john).likes(tom,mouse).likes(tom,jerry).likes(jerry,cheeze).likes(mary,fruit).likes(john,book).likes(mary,book).Likes(tom,john).Now that we have some facts, we may ask questions.?- likes(jerry,cheeze).yes?- likes(jerry,mary).no

اسلاید 8: 8Lecture 12 Introduction to Prolog?-knows(mary,john).noWe are getting a no answer because we do not have a fact in the database to indicate that mary and john know each other. This does not mean that the statement is false in reality. It just means that it is false based on the knowledge available. We may ask questions involving variables. If we were interested in objects that like john, we would formulate the following query:?-likes(X,john).X=mary;X=tom;nolikes(tom,jerry).likes(mary,john).likes(tom,mouse).likes(tom,jerry).likes(jerry,cheeze).likes(mary,fruit).likes(john,book).likes(mary,book).likes(tom,john).

اسلاید 9: 9Lecture 12 Introduction to PrologWho likes what??-likes(X,Y)X=tom, Y=jerry;X=mary, Y=john;X=tom, Y=mouse;X=tom, Y=jerry;Prolog tries to resatisfy the question everytime we enter a semicolon “;”.Prolog uses a pointer called a place marker to keep track of the search for more solutions. The variable matches anything. Every time the variable X is bound to a value like mary in the above example, we say that X is instantiated to that value. In the example above, X was instantiated to mary once and to tom the next time. Another Querylikes(tom,jerry).likes(mary,john).likes(tom,mouse).likes(tom,jerry).likes(jerry,cheeze).likes(mary,fruit).likes(john,book).likes(mary,book).likes(tom,john).

اسلاید 10: 10Lecture 12 Introduction to PrologRules

اسلاید 11: 11Lecture 12 Introduction to PrologIn the above database we have a fact indicating that mary likes john. This however does not make the fact that john also likes mary true. If we wanted that to be true, we would have to add a relevant fact to the database.likes(john,mary).likes(X,Y):-likes(Y,X).Rule head if Rule bodyRulesWe could make this a generalization by adding a rule to our database as follows:

اسلاید 12: 12Lecture 12 Introduction to PrologOther examples of rules:likes(john,X):-valuable(X).To define a rule indicating that X is a bird if it is an animal and it has feathers.We would say,is_a_bird(X):- is_an_animal(X),has(X,feathers).To define the rule,X is brother of Y if X is a male andX and Y have the same parents.we would sayis_brother_of(X,Y):-male(X), parents(X, Father, Mother), parents(Y, Father, Mother).

اسلاید 13: 13Lecture 12 Introduction to Prologmale(andrew).male(john). male(george). male(greg). male(adam). female(mary). female(jennifer). female(eve). parents(john,george,mary).parents(greg,adam,eve).parents(jennifer, adam,eve).parents(andrew, adam,eve).is_brother_of(X,Y):-male(X), parents(X, Father, Mother), parents(Y, Father, Mother).is_sister_of(X,Y):-female(X), parents(X, Father, Mother), parents(Y, Father, Mother).Another database

اسلاید 14: 14Lecture 12 Introduction to PrologYes?- is_sister_of(jennifer,greg).Yes?- is_brother_of(greg,X).X = greg ;X = jennifer ;X = andrew ;No?- is_brother_of(X,Y).X = andrewY = greg ;X = andrewY = jennifer ;X = andrewY = andrew ;X = johnY = john ;X = gregY = greg ;X = gregY = jennifer ;X = gregY = andrew ;No?- is_brother_of(greg,andrew).male(andrew).male(john). male(george). male(greg). male(adam). female(mary). female(jennifer). female(eve). parents(john,george,mary).parents(greg,adam,eve).parents(jennifer, adam,eve).parents(andrew, adam,eve).is_brother_of(X,Y):-male(X), parents(X, Father, Mother), parents(Y, Father, Mother).is_sister_of(X,Y):-female(X), parents(X, Father, Mother), parents(Y, Father, Mother).

اسلاید 15: 15Lecture 12 Introduction to Prolog% d:/Prolog/sis.pl compiled 0.00 sec, 2,048 bytesWelcome to SWI-Prolog (Version 4.0.9)Copyright (c) 1990-2000 University of Amsterdam. Copy policy: GPL-2 (see www.gnu.org)For help, use ?- help(Topic). or ?- apropos(Word).?- is_sister_of(X,Y).X = jenniferY = greg ;X = jenniferY = jennifer ;X = jenniferY = andrew ;No?- SWI-Prolog

اسلاید 16: 16Lecture 12 Introduction to PrologSWI-Prolog

اسلاید 17: 17Lecture 12 Introduction to PrologWelcome to SWI-Prolog (Version 4.0.9) Copyright (c) 1990-2000 University of Amsterdam. Copy policy: GPL-2 (see www.gnu.org)  For help, use ?- help(Topic). or ?- apropos(Word). ?-SWI-PrologYou may query Prolog now. Use the built-in Predicate “halt” to exit Prolog.

اسلاید 18: 18Lecture 12 Introduction to Prolog?- append([abc,def],[ghi,lmn],L).L = [abc, def, ghi, lmn] Yes?- append([abc,def],L,[abc,def,ghi,lmn]).L = [ghi, lmn] Yes?- Query mode

اسلاید 19: 19Lecture 12 Introduction to Prolog?- [user]. |:Do not forget the period at the end of your input. At the “|:” prompt, type in what you want entered into your database.male(john).female(mary).father(john,mary).great(massey).has_a_job(mary).After the last fact is entered and at the “|:” prompt, enter a ctrl-D to exit the consult mode. An example is shown on the next slide.Consult modeYou can enter consult mode by typing in “[user]” at the “?-” Prompt:

اسلاید 20: 20Lecture 12 Introduction to Prolog?- [user].|: likes(tom,jerry).|: likes(mary,john).|: likes(tom,mouse).|: likes(tom,jerry).|: likes(jerry,cheeze).|: likes(mary,fruit).|: likes(john,book).|: knows(mary,book).|: knows(tom,john).|: % user compiled 0.01 sec, 64 bytesYes?- listing. likes(tom, jerry).likes(mary, john).likes(tom, mouse).likes(tom, jerry).likes(jerry, cheeze).likes(mary, fruit).likes(john, book).knows(mary,book).knows(tom,john).Yes

اسلاید 21: 21Lecture 12 Introduction to Prologlisting.listing(likes/2).Listing your predicates

اسلاید 22: 22Lecture 12 Introduction to Prolog?- listing(likes/2).  /* we could have said “listing(likes).” in this case*/likes(tom, jerry).likes(mary, john).likes(tom, mouse).likes(tom, jerry).likes(jerry, cheeze).likes(john,book).?- listing(knows). knows(mary,book).knows(tom,john).

اسلاید 23: 23Lecture 12 Introduction to Prologtrace.notrace.Or simply n.spy(likes/2).nospyTracing your program

اسلاید 24: 24Lecture 12 Introduction to Prolog Call: (7) likes(_G332, _G333) ? creep Exit: (7) likes(tom, jerry) ? creep X = tomY = jerry ; Redo: (7) likes(_G332, _G333) ? creep Exit: (7) likes(mary, john) ? creepX = maryY = john ; Redo: (7) likes(_G332, _G333) ? creep Exit: (7) likes(tom, mouse) ? creepX = tomY = mouse ; Redo: (7) likes(_G332, _G333) ? creep Exit: (7) likes(tom, jerry) ? creepX = tomY = jerry ; Redo: (7) likes(_G332, _G333) ? creep Exit: (7) likes(jerry, cheeze) ? creep?- trace.Yes[trace] ?- likes(X,Y).

اسلاید 25: 25Lecture 12 Introduction to PrologX = jerryY = cheeze ; Redo: (7) likes(_G332, _G333) ? creep Exit: (7) likes(mary, fruit) ? creepX = maryY = fruit ; Redo: (7) likes(_G332, _G333) ? creep Exit: (7) likes(john, book) ? creepX = johnY = book ;Fail: (7) likes(_G332, _G333) ? creepNo

اسلاید 26: 26Lecture 12 Introduction to PrologStructures

اسلاید 27: 27Lecture 12 Introduction to Prolog?- owns(john,book(prolog,author( _ ),year( X ),edition( _ ))),X >1990.owns(john,book(prolog,author(clocksin_and_mellish),year(1994),edition(4))).owns(victoria,book(prolog,author(bratko),year(2001),edition(3))).owns(john,book(prolog,clocksin_and_mellish)).owns(victoria,book(prolog,bratko)).owns(john, book).owns(victoria, book).owns(george,book).

اسلاید 28: 28Lecture 12 Introduction to PrologArithmetic

اسلاید 29: 29Lecture 12 Introduction to Prolog?- A is 2+3, B is A-1, C is A*2, D is C/B, E is C // B.A = 5B = 4C = 10D = 2.5E = 2 +additionX + Y- subtractionX - Y*multiplicationX * Y/divisionX / Y//division (integer)X // Ymodmodulo (remainder)X mod Y**powerX ** YisequalsZ is X + YArithmetic Operators

اسلاید 30: 30Lecture 12 Introduction to Prologpopulation(us,275000).population(china,1262000).population(nz,4000).Population(india,1000000).land(us,3000).land(china,4000).land(nz,250).land(india,3288).concen(X,Y):-population(X,P),land(X,L),Y is P / L.

اسلاید 31: 31Lecture 12 Introduction to Prolog?- concen(X,Y).X = usY = 91.6667 Yes?- concen(X,Y).X = usY = 91.6667 ;X = chinaY = 315.5 ;X = nzY = 16 ;X = indiaY = 304.136 ;No

17,000 تومان

خرید پاورپوینت توسط کلیه کارت‌های شتاب امکان‌پذیر است و بلافاصله پس از خرید، لینک دانلود پاورپوینت در اختیار شما قرار خواهد گرفت.

در صورت عدم رضایت سفارش برگشت و وجه به حساب شما برگشت داده خواهد شد.

در صورت نیاز با شماره 09353405883 در واتساپ، ایتا و روبیکا تماس بگیرید.

افزودن به سبد خرید