صفحه 1:
Summary

صفحه 2:
Prolog: Facts Queries ?- likes(jerry,cheeze). yes ?-likes(X,john). X=mary; X=tom; no

صفحه 3:
SS ‏با‎ ‎Rules ‎X is brother of Y if X is a male and X and Y have the same parents. In Prolog is_brother_of(X,Y):-male(X), parents(X, Father, Mother), parents(Y, Father, Mother).

صفحه 4:
a Backtracking population(us,275). population(china,1262). ?- concen(X,Y). population(nz,4). X= us Population(india, 1000). Y = 91.6667 ; land(us,3000). X =china land(china,4000). = . land(nz,250). Yr SES land(india,3288). eine concen(X,Y):- Y= 16; population(X,P), X = india land(X,L), Y = 304.136 ; Y is P*1000/L. No

صفحه 5:
max(X,Y,Y) :- Y>X, !. max(X,Y,X). ?- max(1,2,X). X=2; No 9 max(X,Y,Y) :- Y>X. max(X,Y,X). ?- max(1,2,X). X=2; 8-1 No De

صفحه 6:
SS ۲ Lists ][ [a,b,c,d,e] [5,8,3,9,7] [the, boy, run] ist can be split into a head and a tail: [H grades(john, [70,87,90,58]). ?- grades(john, [H|T]). H=70 T= [87,90,58] Recursion and Lists member(X,[X| _ ]). member(X, [ _ | Y]) :- member(X, Y). ?- member(1, [3,4,5,8,1,9]). Yes

صفحه 7:
1/0 put(Ch). get(Ch). get0(Ch). tab(X). nl. read(X). write(X). File /O tell(Filename) telling(X) told see(Filename) seeing(X) seen

صفحه 8:
fifidall(X,Term, List). =e ee male(andrew). X= andrew; X= mary; oes X= john; ennifer; male(george). X= george; X= eve; male(greg). xe : male(adam). a greg; female(mary). X= adam; female(jennifer). 2 Perera ‏تك‎ adam, eve). ۲ parents(john,george,ma B= ‏ا‎ 27 ۳ X= andrew; parents(greg,adam,eve). parents(jennifer, ?- findall(X, male(X), List). adam,eve). List= [andrew, john, george, greg, ada parents(andrew, ?- findall(X, female(X), List). adam,eve). List= [mary, jennifer, eve] ?- findall(X, parents(X,adam,eve), List). List= [greg, jennifer, andrew]

صفحه 9:
۹۹۰۰۰۰ nctor(Term, Functor, Arity) 2 2 ۱ ۲ ۲ arg(N,Term, Value) functor(likes(mary,john),Fun,Arity). Fun = likes ?- arg(2,likes(mary,john),X). Arity = 2 X = john Yes Yes 9 ?- arg(2,likes(mary,X),john). X=likes(mary john) functor(% Func A ‏د عد‎ john rity). X = likes(mary, john) Func = likes Yes 0 arg(3,parents(john,george,X),Val) Arity = 2 pe X= _G346 functor(parents(adamjohnmary)E, | (= y-o0° N). Yes F = parents e ‎arg(3,parents(john,george,victori‏ دع ور ‎a),Val).‏ ‎Yes ‎Re eg

صفحه 10:
SS ‏با‎ Games Robot control Natural language processing Expert systems Image processing Parsing of context-free languages Compiler writing VLSI Design Relational database کت ‎Dat Syn Bere‏ مت خی

صفحه 11:
SS A ‘simple grammar for expressioris expr ::= term | term addop expr term ::= factor | factor multop term factor ::= ‘x’ | ‘y’ | lbr expr rbr addop ::= ‘+’ | ~’ multop ::= ‘*’ | ‘/’ Tbr es ‘(’

صفحه 12:
expr --> term. expr --> term, addop, expr. term --> factor. ?- phrase(expr, Ly, '*', '(', x, term --> factor, multop, t'+', x, ')']) factor -->[x]. Yes factor -->[y]. ?- phrase(factor, [y]) ۷99 factor --> lbr, expr, rbr. addop ->['+']. ‏ی‎ yy) addop -->['-']. ?- phrase(factor, [y , '*', x]) multop -->['*"']. No multop -->['/']. ?- phrase(expr, [y, '*', x]) . Ibr -->['(‘]. eS: rbr -->[')']. ?- phrase(factor, ['(y, *', xy).

صفحه 13:
SS A Grammar for a very small fragment of F sentence --> noun_phrase, verb_phrase. noun_phrase --> determiner, noun. noun_phrase --> proper_noun. determiner -->[the]. determiner -->[a]. proper _noun -->[pedro]. noun -->[man]. noun -->[apple]. verb_phrase --> verb, noun_phrase. verb_phrase --> verb. verb -->[eats]. verb -->[sings].

صفحه 14:
Oppivaicns Explanation Facility Working Memory Domain Expert(S) 5 _ Knowledge User Interface Inference Engine Base Knowledge 5 owledge ngineer Formalized Knowledeg

صفحه 15:
bora Chess Ocehatica: @ Wore couse is a couse wilh ot cost vor postive titer. 0 Wore chouse therePore betas to vor oP Pour coteqories: Fh oe eons ttre crm tera © ride bar the Porn: ۳0-9 0 ...۵ ~PROQ@ ‏تس‎ logically equivocal 7 ۳0۸66۶ ... ۸۲ << 6 hus, ‏کرت مرن ما ون‎ cay ovecber oP couric but Cxavples: ~arra(X) O wort), ‏ل ل ان‎ at) ‏عسي ۵ را ۲ص 0 (۷ سس‎ 1:( PC is paredt oP YY! aed ۲ ‏و وه و‎ LD thea ‏وه وا‎ oP TD.

صفحه 16:
(xavples: wani(svorutes) poreu(eizabeth,chorles)", © veqnted qo | O postive tierub, uf bust | cequtve tera, اوه با خن ماو سل ‎the oexaied yoo‏ ,وا واه وا ان امن اه امش و ‎Wo be proved‏ Dre wl clawe: O postive vod O cexniive liercds. @ppeus voy oF the ead oP ‏ممم و‎

صفحه 17:
٠" ‏2227ل‎ roby * is desiqned to represen Word chee, ¢ does backward chaiciagy val, * ‏جز‎ a Pal Durdeg equivded ‏كوادك بو ور‎ ‏اه ره ارو وس موه كمه رععصسيوهها‎ ‏رتور‎ hrogquage cod. Oodera Proloy iwpleweutativas kave (BO Pontes, Past

صفحه 18:
Prolog Grammer Program ::= Clause... Query | Query Clause ::= Predicate . | Predicate :- PredicateList . PredicateList ::= Predicate | PredicateList , Predicate Predicate Atom | Atom( TermList ) TermList ::= Term | TermList , Term Term ::= Numeral | Atom | Variable | Structure Structure ::= Atom ( TermList ) Query ::= ?- PredicateList . Numeral an integer or real number Atom ::= string of characters beginning with a lowercase letter or enclosed in apostrophes. Variable ::= string of characters beginning with an uppercase letter or underscore Terminals = {Numeral, Atom, Variable, : comma, period, left and

صفحه 19:
۹۹۰۰۰۰ Comparing Prolog and Haskell Syntax In Prolog: * functions are not evaluated - they are like data constructors * the language is untyped * variables begin with upper-case letters or an underscore * predicate and function symbols begin with a lower-case letter * the list constructor functor is [ | ], not :

صفحه 20:
Prolog relations variable; indicated with jn ending start with upper case start with lower case separated by commas . (when body is needed) separated by semi-colons full stop | (always inside brackets) Haskell functions fixed; if fewer arguments, then return a function start with lower case start with upper case separated by spaces = (after possible alternatives) preceded by | (or can use iftthen-else) off-side rule (or semi-colon) (inside parens when potentially ambiguous) اي —_ Kinds of objects Arity (number of parameters) Variables Values Clause parameters ‘Head-body separator Alternatives Clause ending List constructor

صفحه 21:
SS ‏با‎ ‎۲۵7۵۲96 ][ =[] reverse (h:t) = (reverse t) + + [h] reverse([], []). reverse([H|T], R) :- reverse(T, RT), append(RT, [H], R).

Summary Prolog: Facts 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). Queries ?- likes(jerry,cheeze). yes ?-likes(X,john). X=mary; X=tom; no Rules X is brother of Y if X is a male and X and Y have the same parents. In Prolog is_brother_of(X,Y):-male(X), parents(X, Father, Mother), parents(Y, Father, Mother). Backtracking population(us,275). population(china,1262). population(nz,4). Population(india,1000). land(us,3000). land(china,4000). land(nz,250). land(india,3288). concen(X,Y):population(X,P), land(X,L), Y is P*1000/L. ?- concen(X,Y). X = us Y = 91.6667 ; X = china Y = 315.5 ; X = nz Y = 16 ; X = india Y = 304.136 ; No Cut: ! Eliminates choices Always succeeds but stops backtracking :-b,c,!,d. :-e,f. max(X,Y,Y) :- Y>X. max(X,Y,X). ?- max(1,2,X). X=2; X=1; No ?- max(X,Y,Y) :- Y>X, !. max(X,Y,X). ?- max(1,2,X). X=2; No ?- Lists [ ] [a,b,c,d,e] [5,8,3,9,7] [the, boy, run] A list can be split into a head and a tail: [H|T]. grades(john, [70,87,90,58]). ?- grades(john, [H|T]). H = 70 T = [87,90,58] Recursion and Lists member(X,[X| _ ]). member(X, [ _ | Y]) :member(X, Y). ?- member(1, [3,4,5,8,1,9]). Yes I/O put(Ch). get(Ch). get0(Ch). tab(X). nl. read(X). write(X). File I/O tell(Filename) telling(X) told see(Filename) seeing(X) seen findall(X,Term,List). ?- male(X). X= andrew; X= john; X= george; X= greg; X= adam; ?- female(X). X= mary; X= jennifer; X= eve; male(andrew). male(john). male(george). male(greg). male(adam). female(mary). female(jennifer). ?- parents(X, adam, eve). female(eve). X= greg; parents(john,george,ma X= jennifer; ry). X= andrew; parents(greg,adam,eve) . ?- findall(X, male(X), List). parents(jennifer, List= [andrew, john, george, greg, ada ?- findall(X, female(X), List). adam,eve). List= [mary, jennifer, eve] parents(andrew, ?- findall(X, parents(X,adam,eve), List). adam,eve). List= [greg, jennifer, andrew] unctor(Term, Functor, Arity) ?functor(likes(mary,john),Fun,Arity). Fun = likes Arity = 2 Yes ?X=likes(mary,john),functor(X,Func,A rity). X = likes(mary, john) Func = likes Arity = 2 Yes ?functor(parents(adam,john,mary),F, N). F = parents N=3 Yes arg(N,Term,Value) ?- arg(2,likes(mary,john),X). X = john Yes ?- arg(2,likes(mary,X),john). X = john Yes ?arg(3,parents(john,george,X),Val) . X = _G346 Val = _G346 Yes ?arg(3,parents(john,george,victori a),Val). Applications Games Robot control Natural language processing Expert systems Image processing Parsing of context-free languages Compiler writing VLSI Design Relational database Applications A simple grammar for expressions expr ::= term | term addop expr term ::= factor | factor multop term factor ::= ‘x’ | ‘y’ | lbr expr rbr addop ::= ‘+’ | ‘-’ multop ::= ‘*’ | ‘/’ Applications expr --> term. expr --> term, addop, expr. term --> factor. ?- phrase(expr, [y, '*', '(', x, '+', x, ')']) term --> factor, multop, term. Yes factor -->[x]. ?- phrase(factor, [y]) factor -->[y]. factor --> lbr, expr, rbr. Yes ?- phrase(rbr, [')']) addop -->['+']. Yes addop -->['-']. ?- phrase(factor, [y , '*', x]) multop -->['*']. No multop -->['/']. ?- phrase(expr, [y , '*', x]) . lbr -->['(']. Yes rbr -->[')']. ?- phrase(factor, ['(',y , '*', x,')']). Applications A Grammar for a very small fragment of English sentence --> noun_phrase, verb_phrase. noun_phrase --> determiner, noun. noun_phrase --> proper_noun. determiner -->[the]. determiner -->[a]. proper_noun -->[pedro]. noun -->[man]. noun -->[apple]. verb_phrase --> verb, noun_phrase. verb_phrase --> verb. verb -->[eats]. verb -->[sings]. Domain Expert(S) User Applications Knowledge User Interface Knowledge Engineer Formalized Knowledeg Inference Engine Explanation Facility Knowledge Base Working Memory Horn Clauses Definition: A Horn clause is a clause with at most one positive literal. A Horn clause therefore belongs to one of four categories: A rule: 1 positive literal, at least 1 negative literal. A rule has the form: ~P1 V ~P2 V ... V ~Pk V Q This is logically equivalent to P1^P2^ ... ^Pk => Q thus, an if-then implication with any number of conditions but one conclusion. Examples: ~man(X) V mortal(X) (All men are mortal); ~parent(X,Y) V ~ancestor(Y,Z) V ancestor(X,Z) If X is parent of Y and Y is ancestor of Z then X is ancestor of Z. A fact or unit: 1 positive literal, 0 negative literals. Examples: man(socrates) parent(elizabeth,charles)", A negated goal : 0 positive literals, at least 1 negative literal. In virtually all implementations of Horn clause logic, the negated goal is the negation of the statement to be proved The null clause: 0 positive and 0 negative literals. Appears only as the end of a proof. Prolog • is designed to represent Horn clauses, • does backward chaining only, • is a full Turing equivalent programming language, and can compute anything any other programming language can. Modern Prolog implementations have GUI facilities, fast compilers and (if your code is designed appropriately) very high run-time performance. Prolog Grammer Program ::= Clause... Query | Query Clause ::= Predicate . | Predicate :- PredicateList . PredicateList ::= Predicate | PredicateList , Predicate Predicate ::= Atom | Atom( TermList ) TermList ::= Term | TermList , Term Term ::= Numeral | Atom | Variable | Structure Structure ::= Atom ( TermList ) Query ::= ?- PredicateList . Numeral ::= an integer or real number Atom ::= string of characters beginning with a lowercase letter or enclosed in apostrophes. Variable ::= string of characters beginning with an uppercase letter or underscore Terminals = {Numeral, Atom, Variable, :-, ?-, comma, period, left and Comparing Prolog and Haskell Syntax In Prolog: • functions are not evaluated - they are like data constructors • the language is untyped • variables begin with upper-case letters or an underscore • predicate and function symbols begin with a lower-case letter • the list constructor functor is [ | ], not : Haskell Prolog Kinds of objects functions relations Arity (number of parameters) fixed; if fewer arguments, then return a function variable; indicated with /n ending Variables start with lower case start with upper case Values start with upper case start with lower case Clause parameters separated by spaces separated by commas Head-body separator = (after possible alternatives) :- (when body is needed) Alternatives preceded by | (or can use if-then-else) separated by semi-colons Clause ending off-side rule (or semi-colon) full stop List constructor : (inside parens when potentially ambiguous) | (always inside brackets) reverse [] = [] reverse (h:t) = (reverse t) + + [h] reverse([], []). reverse([H|T], R) :reverse(T, RT), append(RT, [H], R).

51,000 تومان