SlideShare uma empresa Scribd logo
1 de 22
Programação Lógica
Christian Spinelli
Demis Gomes
Renan Azeredo
#Com base em Sebesta e Tucker#
Programação lógica é um paradigma de programação que
difere dos demais por ser declarativa.
- Somente as especificações dos resultados(objetivos)
desejados são declarados.
- Os objetivos são organizados como uma coleção de regras.
- Os programas são expressos na forma de lógica simbólica.
- Um processo de inferência lógica é utilizado para produzir
os resultados.
Programação lógica⇔Programação declarativa⇔Programação
baseada em regras
Introdução
# Segundo Tucker#
As aplicações de programação lógica se classificam em
dois domínios principais:
- Inteligência artificial (Prolog e MYCIN)
- Acesso a informação em banco de dados (SQL)
Introdução
Proposição é uma sentença negativa ou positiva na qual
podemos atribuir um valor de verdadeiro (v) ou falso (f).
As proposições lógicas podem ser compostas de
conectivos lógicos ¬ (negação), ^ (conjunção, “e”), v
(disjunção, “ou”), ⊕(disjunção exclusiva),
(condicional, “se..então”), (bicondicional, “se
somente se”).
Lógica Proposicional
4
Lógica Proposicional
Tipo: Conjunção (^) “e”
Tabela verdade:
A proposição resultante só é verdadeira quando as
proposições individuais forem verdadeiras.
Lógica Proposicional
Tipo: Disjunção (v) “ou”
Tabela verdade:
A proposição resultante só é falsa quando as proposições
individuais forem falsas.
Lógica Proposicional
Tipo: Disjunção exclusiva (v)
Tabela verdade:
A proposição resultante só é verdadeira quando uma
proposição individual for verdadeira e a outra for falsa.
Lógica Proposicional
Tipo: condicional ( ) “se… então”
Tabela verdade:
A proposição resultante só é falsa quando a proposição
antecedente for verdadeira e a consequente for falsa.
Lógica Proposicional
Tipo: bicondicional ( ) “se e somente se”
Tabela verdade:
A proposição resultante só é falsa quando as proposição tem
valores diferentes.
Cláusulas de Horn
● É a linguagem utilizada para a programação lógica
● Linguagem mais “orientada ao homem”
● Uma cláusula de Horn tem uma única ou nenhuma
proposicao implicada.
● A cláusula que não tem nenhuma proposição é
considerada um fato.
Cláusulas de Horn
Ela é definida da seguinte forma:
Exemplo:
fato: regra:
Prolog
nao_morre(algo,perpétuo).
imortal(_) :- nao_morre(algo,perpétuo).
final(_).
imortalSandy(_) :- nao_morre(algo,perpétuo), final(_).
Prolog
● Criada por Alain Colmerauer, Philipe Roussel e Robert
Kowalski em 1970
● Deriva de PROgrammation en LOGiqué
● Implementa as cláusulas de Horn
Prolog
Elementos:
Fatos: cláusulas sempre verdadeiras
nao_morre(algo,imortal).
Regras: conjunto de condições necessárias para um termo
ser verdadeiro.
gostaGOT(pessoa) :- estudaBSI(pessoa),gostaSeries(pessoa),
gostaSacanagem(pessoa).
Prolog
, significa “E”
:- significa <-
_ significa “não importa” ou “don’t care”
Prolog
O “.” sempre deve estar no fim, indicando o fim da cláusula.
respeito(voltou).
Prolog
Voltando ao exemplo:
nao_morre(algo,perpétuo).
imortal(_) :- nao_morre(algo,perpétuo).
final(_).
imortalSandy(_) :- nao_morre(algo,perpétuo), final(_).
Se algo
não morre,
ele é
imortal
Mas pra Sandy, o
imortal não morre
no final
Perceberam que o
imortalSandy e o
imortal são a
mesma coisa?
PUTS! PQ
NÃO
ESTUDEI
ISSO
ANTES?
Prolog
Morena é
um ladrão
Outro exemplo de música:
Mc Rael (Vem Morena)
“O amarelo lembra ouro,
O ouro lembra ladrão,
Ladrão lembra você
Que roubou meu coração”
amarelo_lembra(ouro).
ouro_lembra(ladrao).
rouba(_).
ladrao() :- rouba(_).
morena() :- rouba(meu_coracao).
Prolog
Exemplo: O que falar?
Algumas pessoas falam sobre determinados assuntos. O
programa a seguir irá informar quais assuntos as pessoas
podem conversar entre si, caso a pessoa 1 também fale algo
que a pessoa 2 também fala.
Vamos ao código!
Dúvidas?
FIM
Nossa apresentação não é imortal...
Referências
Sebesta, R. Conceitos de Linguagem de Programação, 5ª ed. Bookmamn,
2005.
Tucker, A; Noonan, R. Linguagens de Programação: Princípios e Paradigmas.
2ª ed. McGraw-Hill, 2009.
http://letras.mus.br/mc-rael/1513730/
http://pt.slideshare.net/GJ510/programao-lgica
Slides do prof. Gabriel Alves - Programação lógica:
https://docs.google.com/presentation/d/14sHNHkBWZoW5ZGb5_ww5RC5JNc
qiiH2nwY3O7-YKqrk/edit?hl=pt_BR#slide=id.gc118d086_8245
22

Mais conteúdo relacionado

Destaque

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
 

Destaque (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...
 

Programação Lógica

  • 2. #Com base em Sebesta e Tucker# Programação lógica é um paradigma de programação que difere dos demais por ser declarativa. - Somente as especificações dos resultados(objetivos) desejados são declarados. - Os objetivos são organizados como uma coleção de regras. - Os programas são expressos na forma de lógica simbólica. - Um processo de inferência lógica é utilizado para produzir os resultados. Programação lógica⇔Programação declarativa⇔Programação baseada em regras Introdução
  • 3. # Segundo Tucker# As aplicações de programação lógica se classificam em dois domínios principais: - Inteligência artificial (Prolog e MYCIN) - Acesso a informação em banco de dados (SQL) Introdução
  • 4. Proposição é uma sentença negativa ou positiva na qual podemos atribuir um valor de verdadeiro (v) ou falso (f). As proposições lógicas podem ser compostas de conectivos lógicos ¬ (negação), ^ (conjunção, “e”), v (disjunção, “ou”), ⊕(disjunção exclusiva), (condicional, “se..então”), (bicondicional, “se somente se”). Lógica Proposicional 4
  • 5. Lógica Proposicional Tipo: Conjunção (^) “e” Tabela verdade: A proposição resultante só é verdadeira quando as proposições individuais forem verdadeiras.
  • 6. Lógica Proposicional Tipo: Disjunção (v) “ou” Tabela verdade: A proposição resultante só é falsa quando as proposições individuais forem falsas.
  • 7. Lógica Proposicional Tipo: Disjunção exclusiva (v) Tabela verdade: A proposição resultante só é verdadeira quando uma proposição individual for verdadeira e a outra for falsa.
  • 8. Lógica Proposicional Tipo: condicional ( ) “se… então” Tabela verdade: A proposição resultante só é falsa quando a proposição antecedente for verdadeira e a consequente for falsa.
  • 9. Lógica Proposicional Tipo: bicondicional ( ) “se e somente se” Tabela verdade: A proposição resultante só é falsa quando as proposição tem valores diferentes.
  • 10. Cláusulas de Horn ● É a linguagem utilizada para a programação lógica ● Linguagem mais “orientada ao homem” ● Uma cláusula de Horn tem uma única ou nenhuma proposicao implicada. ● A cláusula que não tem nenhuma proposição é considerada um fato.
  • 11. Cláusulas de Horn Ela é definida da seguinte forma: Exemplo: fato: regra:
  • 13. Prolog ● Criada por Alain Colmerauer, Philipe Roussel e Robert Kowalski em 1970 ● Deriva de PROgrammation en LOGiqué ● Implementa as cláusulas de Horn
  • 14. Prolog Elementos: Fatos: cláusulas sempre verdadeiras nao_morre(algo,imortal). Regras: conjunto de condições necessárias para um termo ser verdadeiro. gostaGOT(pessoa) :- estudaBSI(pessoa),gostaSeries(pessoa), gostaSacanagem(pessoa).
  • 15. Prolog , significa “E” :- significa <- _ significa “não importa” ou “don’t care”
  • 16. Prolog O “.” sempre deve estar no fim, indicando o fim da cláusula. respeito(voltou).
  • 17. Prolog Voltando ao exemplo: nao_morre(algo,perpétuo). imortal(_) :- nao_morre(algo,perpétuo). final(_). imortalSandy(_) :- nao_morre(algo,perpétuo), final(_). Se algo não morre, ele é imortal Mas pra Sandy, o imortal não morre no final Perceberam que o imortalSandy e o imortal são a mesma coisa? PUTS! PQ NÃO ESTUDEI ISSO ANTES?
  • 18. Prolog Morena é um ladrão Outro exemplo de música: Mc Rael (Vem Morena) “O amarelo lembra ouro, O ouro lembra ladrão, Ladrão lembra você Que roubou meu coração” amarelo_lembra(ouro). ouro_lembra(ladrao). rouba(_). ladrao() :- rouba(_). morena() :- rouba(meu_coracao).
  • 19. Prolog Exemplo: O que falar? Algumas pessoas falam sobre determinados assuntos. O programa a seguir irá informar quais assuntos as pessoas podem conversar entre si, caso a pessoa 1 também fale algo que a pessoa 2 também fala. Vamos ao código!
  • 22. Referências Sebesta, R. Conceitos de Linguagem de Programação, 5ª ed. Bookmamn, 2005. Tucker, A; Noonan, R. Linguagens de Programação: Princípios e Paradigmas. 2ª ed. McGraw-Hill, 2009. http://letras.mus.br/mc-rael/1513730/ http://pt.slideshare.net/GJ510/programao-lgica Slides do prof. Gabriel Alves - Programação lógica: https://docs.google.com/presentation/d/14sHNHkBWZoW5ZGb5_ww5RC5JNc qiiH2nwY3O7-YKqrk/edit?hl=pt_BR#slide=id.gc118d086_8245 22