Correção dos exercícios de engenharia do conhecimento em Prolog

Slides:



Advertisements
Apresentações semelhantes
Presenter’s Notes Some Background on the Barber Paradox
Advertisements

Prolog: Predicados Built-in 1
Uso de Alcool e Problemas no Brasil e nos E.U.A..
TELEVISION. Escola E/B de S. Silvestre Trabalho realizado por: Nome: André Filipe Mendes Mira Turma: CEF Nº 2 Dava do trabalho: De: 26/01/2010 a.
PENSAMENTOS DE EMMANUEL Nº 1 Emmanuel EMMANUELS THOUGHTS Nº 1 Emmanuel.
Present Perfect Presente Perfeito
Relative Pronouns Pronomes Relativos
As Horas Que horas são?.
GESTÃO INTERNACIONAL PROGRAMA.
Tipos de igualdade X = Y é verdadeiro se X é igual a Y. X is E é verdadeiro se X é a avaliação da expressão E. E1 =:= E2 é verdadeiro se a avaliação da.
Experiências de Indução.
ANÁLISE DA PRODUÇÃO EM PERIÓDICOS ( ) SEGUNDO NOVOS ESTRATOS VITÓRIA, ES – OUTUBRO 2008 Kenneth Camargo – IMS/UERJ Cláudia Medina – IESC/UFRJ.
Indirect Speech By Laecio Miranda.
DIRETORIA ACADÊMICA NÚCLEO DE CIÊNCIAS HUMANAS E ENGENHARIAS DISCIPLINA: INGLÊS FUNDAMENTAL - NOITE PROFESSOR: JOSÉ GERMANO DOS SANTOS PERÍODO LETIVO
DIRETORIA ACADÊMICA NÚCLEO DE CIÊNCIAS HUMANAS E ENGENHARIAS DISCIPLINA: INGLÊS FUNDAMENTAL - NOITE PROFESSOR: JOSÉ GERMANO DOS SANTOS PERÍODO LETIVO
DIRETORIA ACADÊMICA NÚCLEO DE CIÊNCIAS HUMANAS E ENGENHARIAS DISCIPLINA: INGLÊS FUNDAMENTAL - NOITE PROFESSOR: JOSÉ GERMANO DOS SANTOS PERÍODO LETIVO.
Prolog e lógica Jacques Robin, DI-UFPE
Programação em lógica e lógica
Rodar Prolog2 no Unix Shell Conectar-se em limoeiro. Incluir /usr/local/prolog2/sys no seu path. Digitar prolog2 no prompt Unix. Digitar consult(" ").
Departamento de Informática
Correção dos exercícios de engenharia do conhecimento em LIFE Jacques Robin, DI-UFPE
Correção dos exercícios de engenharia do conhecimento em Prolog Jacques Robin, DI-UFPE
LIFE: predicados, funções e sorts built-in Jacques Robin Paulo Oliva Leonardo Lemos DI-UFPE.
LIFE: integração de predicados, funções e classes
LIFE: integração de predicados, funções e classes
Vetor da rede recíproca.
Uniform Resource Identifier (URI). Uniform Resource Identifiers Uniform Resource Identifiers (URI) ou Identificador de Recursos Uniforme provê um meio.
National Anthem Fado Amália Rodriquez Folk music.
SECEX SECRETARIA DE COMÉRCIO EXTERIOR MINISTÉRIO DO DESENVOLVIMENTO, INDUSTRIA E COMÉRCIO EXTERIOR BRAZILIAN EXPORTS STATISTICAL DEPURATION SYSTEM Presentation.
IEEE PES General Meeting, Tampa FL June 24-28, 2007 Conferência Brasileira de Qualidade de Energia Santos, São Paulo, Agosto 5-8, Chapter 3 Harmonic.
Indirect Object Pronouns - Pronomes Pessoais Complemento Indirecto
Números de 0 a 1,000,000,000 É uma dúvida de muitos estudantes do nível básico como dizer os números em inglês. Segue abaixo a lista de 0 a 1,000,000,000.
DISCURSO DIRETO E INDIRETO
The Berlin Declaration on Open Access to Knowledge in the Sciences and Humanities.
The Present Perfect Tense
Avaliação Constituição dos grupos de trabalho:
Lecture 4 Pressure distribution in fluids. Pressure and pressure gradient. Hydrostatic pressure 1.
Lecture 2 Properties of Fluids Units and Dimensions 1.
Instituto de Engenharia de Sistemas e Computadores Investigação e Desenvolvimento em Lisboa Ontology Building Process: The Wine Domain João Graça, Márcio.
Instituto de Engenharia de Sistemas e Computadores Investigação e Desenvolvimento em Lisboa Understanding Epidemic Quorum Systems INESC-ID Lisbon/Technical.
WG 47 New frontiers of DGA interpretation Reunião Cigré D1 – 24/01/2012 Representantes do D1.01 Brasil: Adriana de Castro Passos Martins – CEMIG Jayme.
English Classes Relative Pronouns.
RELATÓRIO CEMEC 06 COMPARAÇÕES INTERNACIONAIS Novembro 2013.
Unit 22 Relative Clauses and Pronouns.
VOCÊ JÁ FALA INGLÊS FLUENTEMENTE?
Milhões de estrelas, colocadas nos céus, por um Deus. Millions of stars placed in the skies, by one God.
Introdução a Programação em Lógica e Prolog
© 2007 IBM Corporation Academic Initiative 07/05/07 Aula 2 – Parte 1: Java Basics Autores: Argemiro José de Juliano Marcos
GESTÃO DE NEGÓCIOS INTERNACIONAIS. Introdução 1 A Envolvente Internacional da Empresas 2 Processos de Internacionalização 4 Teorias do Investimento.
FUTURE TENSES Professora Ellen Ikeda Inglês Técnico.
Learning english with comics …………….. Aprendendo inglês com quadrinhos.
THERE IS / THERE ARE A / AN, SOME, ANY.
One God Um Deus.
Sunday School Adolescents Theme: Evangelism.
Sunday Bible School Theme: Evangelism Children & Intermediates
Grammar Reference: Modal Verbs
Three analogies to explain reactive power Why an analogy? Reactive power is an essential aspect of the electricity system, but one that is difficult to.
SIMPLE PRESENT TENSE.
Unidade 1 Family Life Freeway - Vol. 1
Grammar Reference Simple Future Future Continuous Upgrade 2 - Unit 2
Workshop Pesquisa Acadêmica
Grammar Reference: Modal Verbs
Unit 9 Possessive pronouns & Possessive adjectives.
The one that revolutionized the world
Simple Present Tense. . In English the Simple Present is used to express actions that are made with a certain frequency, like go to school, work, study…
Introduction to density estimation Modelação EcoLÓGICA
One God Um Deus.
Complete with the verb to be My name ______ Maria. I ______ thirteen years old. I ______ from Venice. My father’s name ______ Paolo. He _____ forty-five.
Making Every Gift Count
Transcrição da apresentação:

Correção dos exercícios de engenharia do conhecimento em Prolog Jacques Robin, DI-UFPE www.di.ufpe.br/~jr

Estudo de caso: a terrível novela Requisitos em Inglês 1. A soap opera is a TV show whose characters include a husband, a wife and a mailman such that: 2. the wife and the mailman blackmail each other 3. everybody is either alcoholic, drug addict or gay 4. Dick is gay, Jane is alcoholic and Harry is a drug addict 5. the wife is always an alcoholic and the long-lost sister of her husband 6. the husband is always called Dick and the lover of the mailman 7. the long-lost sister of any gay is called either Jane or Cleopatra 8. Harry is the lover of every gay 9. Jane blackmails every drug addicted lover of Dick 10. soap operas are invariably terrible! 0. Who are the characters of a terrible TV show?

Correção do exercício 1: A terrível novela em L1

Correção do exercício 2: A terrível novela em Prolog tvShow(Cast,Qual) :- soapOpera(Cast,Qual). soapOpera([dick,W,M],terrible) :- soapCast([dick,W,M]), blackmail(W,M), alcoholic(W), longLostSister(W,dick), lover(M,dick). soapCast([]). soapCast([H|T]) :- soapChar(H), soapCast(T). soapChar(C) :- alcoholic(C). soapChar(C) :- drugAddict(C). soapChar(C) :- gay(C). gay(dick). alcoholic(jane). drugAddict(harry). lover(harry,G) :- gay(G). longLostSister(jane,G) :- gay(G). longLostSister(cleopatra,G) :- gay(G). blackmail(jane,M) :- lover(M,dick), drugAddict(M). ?-tvShow(Cast,terrible). Cast = [dick,jane,harry].

Estudo de caso: o BD acadêmico Requisitos em Inglês 1. Bob is 40 and the manager of the CS department. 2. His assistants are John and Sally. 3. Mary’s highest degree is an MS and she works at the CS department. 4. She co-authored with her boss and her friends, John and Sally, a paper published in the Journal of the ACM. 5. Phil is a faculty, who published a paper on F-Logic at a Conference of the ACM, jointly with Mary and Bob. 6. Every faculty is a midaged person who writes article, makes in the average $50,000 a year and owns a degree of some kind, typically a PhD. 7. One is considered midage if one is between 30 and 50 years old. 8. A faculty’s boss is both a faculty and a manager. 9. Friends and children of a person are also persons. 10. Every department has a manager who is an employee and assistants who are both employees and students 11. A boss is an employee who is the manager of another employee of the same department. 12. A joint work is a paper that is written by two faculties 13. There are three types of papers: technical reports, journal papers and conference papers 0a: Who are the midaged employees of the CS department and who are their boss? 0b: Who published jointly with Mary in the Journal of the ACM? 0c: Where did Mary published joint work with Phil?

Correção do exercício 3: O banco de dados acadêmico em Prolog 1/ fatos ground person(bob). age(bob,40). works(bob,cs,faculty). manager(cs,bob). dept(cs). works(john,cs,assistant). study(john,cs). works(sally,cs,assistant). study(sally,cs). hiDeg(mary,ms). works(mary,cs,faculty). friends(mary,bob). friends(mary,sally). works(phil,cs,faculty). degree(phd). degree(ms). journal(jacm). conf(cacm). article(flogic,[john,sally,mary,bob],jacm). article(florid,[phil,mary,bob],cacm).

Correção do exercício 3: O banco de dados acadêmico em Prolog 2/ regras de dedução hiDeg(F,phd) :- works(F,_,faculty), not hiDeg(F,ms). salary(P,5000) :- works(F,_,faculty), not salary(F,_). midaged(F) :- age(F,A), !, integer(A), A >= 30, A =< 50. midaged(F) :- works(F,_,faculty). works(B,D,faculty) :- manager(D,B), works(E,D,faculty), !. activity(F,paperWriting) :- works(F,_,faculty). person(P2) :- friends(P1,P2), person(P1). person(C) :- parent(A,C), person(A). person(P) :- study(P,D), dept(D). person(P) :- works(P,_,D), dept(D). works(S,D,assistant) :- study(S,D), dept(D), works(S,D,_), !. works(M,D,_) :- manager(M,D). boss(B,E) :- manager(D,B), works(E,D,_). jointWork(W,F1,F2,P) :- works(F1,_,faculty), works(F2,_,faculty), F1 \= F2, report(W,Fl,P), member(F1,Fl), member(F2,Fl). member(H,[H|T]). member(X,[H|T]) :- member(X,T). report(T,Al,J) :- article(T,Al,J), journal(J). report(T,Al,C) :- article(T,Al,C), conf(C). report(T,Al,D) :- techrep(T,Al,D), dept(D).

Correção do exercício 3: O banco de dados acadêmico em Prolog 3/ consultas midagedWorkerOf(E,D) :- works(E,D,_), midaged(E). bossOfMidagedWorkerOf(B,D) :- midagedWorkerOf(E,D), boss(B,E). ? setof(E,midagedWorkerOf(E,cs),Le), setof(B,bossOfMidagedWorkerOf(B,cs),Lb). E = _20, Le = [bob,mary], B = _51, Lb = [bob]; no. ? setof(F,jointWork(_,F,mary,jacm),Lf). F = _20, Lf = [bob]; ? setof(P,jointWork(_,phil,mary,P),Lp). P = _20, Lp = [cacm]; no

Correção do exercício 4: O banco de dados acadêmico em L1 1/ formulas ground

Correção do exercício 4: O banco de dados acadêmico em L1 2/ formulas quantificadas

Correção do exercício 4: O banco de dados acadêmico em L1 3/ consultas

Estudo de caso: A curiosidade matou o gato? Requisitos em inglês 1. Jack owns a dog. 2. Every dog owner is an animal lover. 3. No animal lover kills an animal. 4. Either Jack or curiosity killed Tuna 5. Tuna is a cat A. Did curiosity kill the cat? B. Quem matou o gato? Em L1 1. $x Dog(x) Ù Owns(Jack,x) 2. "x ($y Dog(y) Ù Owns(x,y)) Þ AnimalLover(x) 3. "x,y (AnimalLover(x) Ù Animal(y)) Þ ØKills(x,y) 4. (Kills(Jack, Tuna) Ú Kills(Curiosity, Tuna)) Ù Ø(Kills(Jack, Tuna) Ù Kills(Curiosity, Tuna)) 5. Cat(Tuna) 6. "x Cat(x) Þ Animal(x) 0. Kills(Curiosity,Tuna) B.  X, Kills(X,Tuna)

Exercício 5: A curiosidade matou o gatou? em Prolog owns(jack,dog1). /* 1 */ dog(dog1). /* 1 */ animalLover(H) :- owns(H,A), animal(A). /* 2 */ notKills(X,A) :- animalLover(X), animal(A), !. /* 3 */ notKills(X,A) :- not kills(X,A). /* 3 */ kills(curiosity,tuna) :- notKills(jack,tuna). /* 4 */ kills(jack,tuna) :- notKills(curiosity,tuna). /* 4 */ cat(tuna). /* 5 */ animal(A) :- cat(A). /* 6 */ animal(A) :- dog(A). /* 7 */ ?- kills(curiosity,tuna). yes ?- kills(curiosity,X). X = tuna More (y/n)? y no ?

Exercício 6: A curiosidade matou o gato? em LIFE Arquivo da curiosidade e tuna load("glOnto.lf")? animal := {cat; dog}. % 6-7 dog1 <| dog. % 1 tuna <| cat. % 5 feeling <| abstObj. curiosity <| feeling. owns(jack,dog1). % 1 love(H,animal) :- owns(H,dog). % 2 notKills(X,Y) :- love(X,Y), !. % 3 notKills(X,Y) :- not kills(X,Y). % 3 kills(curiosity,tuna) :- notKills(jack,tuna). % 4 kills(jack,tuna) :- notKills(curiosity,tuna). % 4 Arquivo da ontologia geral entities := {situation; object; quality; quantity; place; time}. situation := {event; relation}. event := {action; happening}. object := {physObj; abstObj}. physObj := {liveBeing; artefact}. person <| liveBeing. checkList([],Sort) -> true. checkList([Sort|Tail],Sort) -> checkList(Tail). Consultas: > kills(curiosity,tuna)? *** Yes --1> *** No > kills(X,Y)? *** Yes, X = curiosity, Y = tuna.

Estudo de caso: Coloração de mapa Colorir mapa tal que: países adjacentes de cores diferentes Instância de problema de resolução de restrições B A B A C C D D E F E F

Exercício 7: Coloração de mapa em Prolog

Exercício 8: Coloração de mapa em LIFE