SlideShare una empresa de Scribd logo
1 de 14
Descargar para leer sin conexión
Mecanismos avançados para
manipulação de tabelas em sistemas
Prolog com suporte para tabulação

         Flávio Manuel Fernandes Cruz
           Orientador: Ricardo Rocha
           Instituição: CRACS / FCUP
Palavras-chave

Prolog
Tabulação
Call-Subsumption
YAP
XSB Prolog
Prolog
 SLD (Selective Linear Definite) é a estratégia de avaliação
 tradicional do Prolog
 Apesar de ser muito usada tem algumas lacunas...

path(X, Y) :- path(X, Z), edge(Z, Y).
path(X, Y) :- edge(X, Y).

edge(1, 2). edge(2, 3).
Prolog
                path(1, Z)


           path(1, Z), edge(Z, Y)


             CICLO INFINITO


E agora?
Tabulação

A tabulação é uma forma diferente de avaliar Prolog
Resolve as incapacidades da SLD quanto aos ciclos infinitos e
computações redundantes
Consiste em guardar numa tabela as soluções intermédias de
determinados objectivos para que possam ser reutilizadas
quando surgirem chamadas repetidas
Tabulação
                           1. path(1, Z)      11. complete




   2. path(1, Z), edge(Z, Y)               3. edge(1, Y)
                                                              path(1, VAR0):
                                                              4. VAR0 = 2
      Z=2                Z=3
                                                              7. VAR0 = 3

  6. edge(2, Y)       9. edge(3, Y)    4. Y = 2     5. fail




7. Y = 3    8. fail     10. fail
Call-Subsumption

A extensão do YAP para Tabulação (YapTab) só suporta
chamadas variantes (Call-Variance)
O objectivo do trabalho é alterar o YapTab para também
suportar Call-Subsumption
Call-Subsumption
Call-Variance só reaproveita soluções de um golo se este for variante de um
já colocado na tabela. Exemplo: p(X, 1, Y) é variante de P(X, 1, Z)
No entanto podemos fazer ainda melhor, reaproveitando as soluções de
golos mais gerais caso existam
Dizemos assim que um golo T1 subsume um golo T2 quando T1 é mais
geral que T2: path(X, Y) subsume p(1, X)
Com este mecanismo podemos reutilizar resultados computados e diminuir
a redundância nas tabelas do engine, poupando espaço e tempo
Perspectivas de solução

O mecanismo de tabulação do XSB Prolog já implementa
Call-Subsumption
Existem dois artigos que descrevem soluções implementadas
para o XSB
A ideia principal será usar as TST (time stamped tries) como
base e tentar melhorar a partir daí
Plano de Trabalhos

Estudo dos modelos de execução de tabulação em sistemas
Prolog com particular ênfase na implementação do sistema
YapTab (feito)
Estudo dos algoritmos e estruturas de dados utilizados para
suporte de Call-Subsumption e Common Global Trie (feito)
Plano de Trabalhos

Tentar reutilizar algoritmos e estruturas de dados do XSB
Prolog e integrá-los na máquina do Yap (2,5 meses)
Melhorar os algoritmos e estruturas de dados do XSB. O
objectivo será que ambos, XSB e YAP, façam proveito das
novas melhorias (2 meses)
Plano de Trabalhos

Testes e validação (1 mes)
Escrita de 1 ou 2 artigos sobre o trabalho efectuado
Dissertação! (1 mes)
:- Fim.
Obrigado pela vossa atenção!
Prasad Rao, C. R. Ramakrishnan, I. V. Ramakrishna. A Thread in Time Saves Tabling Time. 1996.

Ernie Johnson, C. R. Ramakrishnan, I.V. Ramakrishnan, Prasad Rao. A Space Efficient Engine for Subsumption-Based
Tabled Evaluation of Logic Programs. 1999.

Ricardo Rocha, Fernando Silva, Vítor Santos Costa. The YapTab Tabling System. 2003.


http://github.com/flavioc/yap
http://flaviocruz.net
Call-Subsumption
                                      1. path(X, Y)        11. complete

                                                                                            path(VAR0, VAR1):
                                                                                            3. VAR0 = 1, VAR1 = 2
                                                                                            4. VAR0 = 2, VAR1 = 3
           2. edge(X, Y)                             7. edge(X, Z), path(Z, Y)              5. VAR0 = 3, VAR1 = 4
                                                                                            10. VAR0 = 1, VAR1 = 3

                                                                                 15. fail   13. VAR0 = 2, VAR1 = 4
                                                                                            17. VAR0 = 1, VAR1 = 4
3. X = 1 4. X = 2 5. X = 3 6. fail
   Y=2      Y=3      Y=4             8. path(2, Y)     11. path(3, Y)     14. path(4, Y)
                                                                                            path(2, VAR0):
                                        9. Y = 3           12. Y = 4                        9. VAR0 = 3
                                                                                            16. VAR0 = 4
                                        16. Y = 4

                                                                                            path(3, VAR0):
         path(X, Y) :- edge(X, Y).                                                          12. VAR0 = 4

         path(X, Y) :- edge(X,Z), path(Z, Y).

         edge(1, 2). edge(2, 3). edge(3, 4).

Más contenido relacionado

Destacado

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destacado (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Implementação de Call-Subsumption no YapTab

  • 1. Mecanismos avançados para manipulação de tabelas em sistemas Prolog com suporte para tabulação Flávio Manuel Fernandes Cruz Orientador: Ricardo Rocha Instituição: CRACS / FCUP
  • 3. Prolog SLD (Selective Linear Definite) é a estratégia de avaliação tradicional do Prolog Apesar de ser muito usada tem algumas lacunas... path(X, Y) :- path(X, Z), edge(Z, Y). path(X, Y) :- edge(X, Y). edge(1, 2). edge(2, 3).
  • 4. Prolog path(1, Z) path(1, Z), edge(Z, Y) CICLO INFINITO E agora?
  • 5. Tabulação A tabulação é uma forma diferente de avaliar Prolog Resolve as incapacidades da SLD quanto aos ciclos infinitos e computações redundantes Consiste em guardar numa tabela as soluções intermédias de determinados objectivos para que possam ser reutilizadas quando surgirem chamadas repetidas
  • 6. Tabulação 1. path(1, Z) 11. complete 2. path(1, Z), edge(Z, Y) 3. edge(1, Y) path(1, VAR0): 4. VAR0 = 2 Z=2 Z=3 7. VAR0 = 3 6. edge(2, Y) 9. edge(3, Y) 4. Y = 2 5. fail 7. Y = 3 8. fail 10. fail
  • 7. Call-Subsumption A extensão do YAP para Tabulação (YapTab) só suporta chamadas variantes (Call-Variance) O objectivo do trabalho é alterar o YapTab para também suportar Call-Subsumption
  • 8. Call-Subsumption Call-Variance só reaproveita soluções de um golo se este for variante de um já colocado na tabela. Exemplo: p(X, 1, Y) é variante de P(X, 1, Z) No entanto podemos fazer ainda melhor, reaproveitando as soluções de golos mais gerais caso existam Dizemos assim que um golo T1 subsume um golo T2 quando T1 é mais geral que T2: path(X, Y) subsume p(1, X) Com este mecanismo podemos reutilizar resultados computados e diminuir a redundância nas tabelas do engine, poupando espaço e tempo
  • 9. Perspectivas de solução O mecanismo de tabulação do XSB Prolog já implementa Call-Subsumption Existem dois artigos que descrevem soluções implementadas para o XSB A ideia principal será usar as TST (time stamped tries) como base e tentar melhorar a partir daí
  • 10. Plano de Trabalhos Estudo dos modelos de execução de tabulação em sistemas Prolog com particular ênfase na implementação do sistema YapTab (feito) Estudo dos algoritmos e estruturas de dados utilizados para suporte de Call-Subsumption e Common Global Trie (feito)
  • 11. Plano de Trabalhos Tentar reutilizar algoritmos e estruturas de dados do XSB Prolog e integrá-los na máquina do Yap (2,5 meses) Melhorar os algoritmos e estruturas de dados do XSB. O objectivo será que ambos, XSB e YAP, façam proveito das novas melhorias (2 meses)
  • 12. Plano de Trabalhos Testes e validação (1 mes) Escrita de 1 ou 2 artigos sobre o trabalho efectuado Dissertação! (1 mes)
  • 13. :- Fim. Obrigado pela vossa atenção! Prasad Rao, C. R. Ramakrishnan, I. V. Ramakrishna. A Thread in Time Saves Tabling Time. 1996. Ernie Johnson, C. R. Ramakrishnan, I.V. Ramakrishnan, Prasad Rao. A Space Efficient Engine for Subsumption-Based Tabled Evaluation of Logic Programs. 1999. Ricardo Rocha, Fernando Silva, Vítor Santos Costa. The YapTab Tabling System. 2003. http://github.com/flavioc/yap http://flaviocruz.net
  • 14. Call-Subsumption 1. path(X, Y) 11. complete path(VAR0, VAR1): 3. VAR0 = 1, VAR1 = 2 4. VAR0 = 2, VAR1 = 3 2. edge(X, Y) 7. edge(X, Z), path(Z, Y) 5. VAR0 = 3, VAR1 = 4 10. VAR0 = 1, VAR1 = 3 15. fail 13. VAR0 = 2, VAR1 = 4 17. VAR0 = 1, VAR1 = 4 3. X = 1 4. X = 2 5. X = 3 6. fail Y=2 Y=3 Y=4 8. path(2, Y) 11. path(3, Y) 14. path(4, Y) path(2, VAR0): 9. Y = 3 12. Y = 4 9. VAR0 = 3 16. VAR0 = 4 16. Y = 4 path(3, VAR0): path(X, Y) :- edge(X, Y). 12. VAR0 = 4 path(X, Y) :- edge(X,Z), path(Z, Y). edge(1, 2). edge(2, 3). edge(3, 4).