SlideShare une entreprise Scribd logo
1  sur  15
Notions de base
de la théorie des langages
1
Plan du cours
 Définitions
 Alphabet
 Mot
 Langage
• Système générateur (Grammaire)
• Système reconnaisseur (Automate)
• Types des langages
• Langage algébrique (Type2)
• Récapitulatif
2
1
• Connaître les concepts issus de la théorie
des langages.
2
• Générer des mots d’un langage précis.
3
• Reconnaître l’appartenance d’un mot à un
langage.
Objectif du cours
3
Définition
 Alphabet : Ensemble fini de symboles (ou caractères), noté X
• Mot (ou phrase) : Suite finie d’éléments de X
 Notations:
• X*: L’ensemble des mots formés à partir de X
• | | : X+ → IN : Nombre d’occurrences de symboles de X
x → |x| (ou Longueur d’un mot)
Exemple: X={a, b}; Soit m1= abbab ; |a|=2, |m1|=5
• X+: X* /{ε} :Ensemble de tous les mots, sauf le mot vide
• an : Le mot composé de n occurrences de a (a0 est le mot vide).
Vocabulaire
• {a, b}
• { il, ballon, ,joue, au, je}
• {if, then, else, C, X,=,0}
Mots
• aab, bba, ababa
• je joue ballon, il joue
• if C then X=0, C if else
4
Définition
 Langage : Un langage L sur X est une partie de X*
 Un langage est un ensemble de mots
Exemple:
X={a,b}
 L1:{aa, abba, bba }: langage fini
 L2 =
= {ab, aaaab, a…….b}: langage infini
Comment décrire un langage d’une manière formelle
pour faciliter son traitement par un ordinateur?
5
Grammaire
 Formalisme général permettant de décrire un langage.
 Repose sur l’utilisation d’un mécanisme génératif capable de
produire tous les mots d’un langage donné.
 Définition
Une grammaire est un quadruplet G = (VT, VN, S, P) où:
VT : vocabulaire terminal qui est le vocabulaire du langage
VN : vocabulaire non-terminal, (VN ∩ VT = ∅)
S : axiome: Є VN
P : un ensemble de règles de la forme A → B, A ≠ ε, où A et B Є (VN ∪ VT)*
Une règle α → β : α peut être réécrit en β permet de réécrire des mots sur VN ∪ VT
Exemple : α β
ω2
β
ω1
ω2
α
ω1
G
6
Grammaire
 Exemple
G=({a}, {S,S1}, S, P)
VT : {a}
VN : {S,S1}
P : (SaS1, S1aS1 , S1  ε)
 Notation
Etant donné une grammaire G, le langage L(G) est défini par :
L(G) = { m ∈ X* | S ⇒G* m}
L(G)={an/ n ≥1}
SaS1
S1aS1| ε
1). G =
<S>::a<S1>
<S1>::a<S1>| ε
2). G =
7
Automate
 Un automate permet de caractériser un langage (les mots acceptés).
 Définition
Un automate à état fini est le cinquplet A = (Q, VT, δ, q0, F) avec
Q: Ensemble fini d’états
F : Ensemble des états finaux
δ : Fonction de transition , δ: Q X VTQ
q0 : Etat initial
Automate G
Un mot m Oui : si m ∈ L(G)
Non :sinon
8
Automate
 Exemple:
Reconnaître les mot du langage L={ac*b}={ab, acb,accb,acccb,…}
A = ({q0,q1,q2}, {a,b,c}, δ, q0, {q2})
δ: Q X VTQ
(q0,a) q1
(q1,b)q2
(q1,c)q1
q1 q2
q0
a
c
b
9
Type de langages
 Type 3:langage régulier
Toutes les règles sont sous la forme:
α → x ou α → xβ Avec x Є VT ; α et β Є VN
 Type 2: Langage algébrique
Toutes les règles sont sous la forme:
α → β avec α Є VN ; et β Є (VN U VT ) *
 Type 1:langage à contexte lié
Toutes les règles sont sous la forme:
α → β avec α Є (VN U VT )+ , β Є (VN U VT )* et | α |<=| β |
 Type 0: Aucune restriction sur la forme des règles
Exemple 1:
pour un langage L={a*
}
G=
SaS
Sε
SSa
Sε
ou
Exemple 2:
Soit L={an
bn
/n ≥1}
G= SaSb|ab
Exemple 3:
Soit L={an
bn
cn
/n ≥0}
G=
Sε
SaRbc|abc
RaRTb
R aTb
TbbT
Tccc
10
Type de langages
* Langage naturel
* | α | ≤ | β |
* {anbncn/n≥1}
* A → β
* {anbn/n≥0}, Langages de programmation
* Automate à pile
* A → a ou A → aB
* {Ac*b}, langage de commandes
* Automate à états finis
• Hiérarchie de Chomsky
Type 0
Type 1
Type 2
Type 3
11
 Définitions
 Grammaire ambigüe :
Un mot est ambigüe s’il dispose de plus qu’une suite de dérivation
gauche(ou droite)
Une grammaire est ambigüe si elle génère au moins un mot ambigüe
 Factorisation à gauche :
AaB|aC 
Exemple: soit G= E →E+E | E*E
G’=
A → aD
D → B |C
E →E E’
E’ →+E|*E
Langages Algébrique
12
Langages Algebriques
 Récursivité à gauche :
A → Aα| β 
Exemple : soit G = S →Sa|a
 Soit G’=
 G’G
 Dérivation de m: S=>aS’=>aaS’=>aaaS’aaa ε=>aaa = m est accepté
A → β A’
A’ →α A’ | ε
S → aS’
S’ →aS’| ε
13
 Soit un alphabet X={a,b},
1. Écrire une grammaire du langage L formé sur X .
2. L est une suite de a et b
3. Quel est le type de cette grammaire ?
4. Donner un exemple de dérivation d’un mot.
Langages Algébrique
Solution:
1.
S → a S a
S → b S b
S → a
S → b
S → ε
2.
Cette grammaire est de Type 2 car S Є VN ,
a S a Є (VN U VT ) *
(α Є VN et β Є (VN U VT ) * )
3.
SaSaabSbaabaSaba abaεaba
Le mot est abaaba
14
¤ La théorie des langages = Comprendre le fonctionnement des
langages.
¤ Un langage = Ensemble de mots
¤ Un mot (ou lexème) = Une combinaison de symboles
¤ L'ensemble des symboles élémentaires  alphabet
¤ La fonction associant l'alphabet au langage  grammaire
¤ On peut associer à une grammaire un automate Déterminer si
un mot fait partie d'un langage.
¤ Domaines d’application : les compilateurs…
Récapitulatif
15

Contenu connexe

En vedette

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
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

En vedette (20)

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...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 

Introduction au compilation

  • 1. Notions de base de la théorie des langages 1
  • 2. Plan du cours  Définitions  Alphabet  Mot  Langage • Système générateur (Grammaire) • Système reconnaisseur (Automate) • Types des langages • Langage algébrique (Type2) • Récapitulatif 2
  • 3. 1 • Connaître les concepts issus de la théorie des langages. 2 • Générer des mots d’un langage précis. 3 • Reconnaître l’appartenance d’un mot à un langage. Objectif du cours 3
  • 4. Définition  Alphabet : Ensemble fini de symboles (ou caractères), noté X • Mot (ou phrase) : Suite finie d’éléments de X  Notations: • X*: L’ensemble des mots formés à partir de X • | | : X+ → IN : Nombre d’occurrences de symboles de X x → |x| (ou Longueur d’un mot) Exemple: X={a, b}; Soit m1= abbab ; |a|=2, |m1|=5 • X+: X* /{ε} :Ensemble de tous les mots, sauf le mot vide • an : Le mot composé de n occurrences de a (a0 est le mot vide). Vocabulaire • {a, b} • { il, ballon, ,joue, au, je} • {if, then, else, C, X,=,0} Mots • aab, bba, ababa • je joue ballon, il joue • if C then X=0, C if else 4
  • 5. Définition  Langage : Un langage L sur X est une partie de X*  Un langage est un ensemble de mots Exemple: X={a,b}  L1:{aa, abba, bba }: langage fini  L2 = = {ab, aaaab, a…….b}: langage infini Comment décrire un langage d’une manière formelle pour faciliter son traitement par un ordinateur? 5
  • 6. Grammaire  Formalisme général permettant de décrire un langage.  Repose sur l’utilisation d’un mécanisme génératif capable de produire tous les mots d’un langage donné.  Définition Une grammaire est un quadruplet G = (VT, VN, S, P) où: VT : vocabulaire terminal qui est le vocabulaire du langage VN : vocabulaire non-terminal, (VN ∩ VT = ∅) S : axiome: Є VN P : un ensemble de règles de la forme A → B, A ≠ ε, où A et B Є (VN ∪ VT)* Une règle α → β : α peut être réécrit en β permet de réécrire des mots sur VN ∪ VT Exemple : α β ω2 β ω1 ω2 α ω1 G 6
  • 7. Grammaire  Exemple G=({a}, {S,S1}, S, P) VT : {a} VN : {S,S1} P : (SaS1, S1aS1 , S1  ε)  Notation Etant donné une grammaire G, le langage L(G) est défini par : L(G) = { m ∈ X* | S ⇒G* m} L(G)={an/ n ≥1} SaS1 S1aS1| ε 1). G = <S>::a<S1> <S1>::a<S1>| ε 2). G = 7
  • 8. Automate  Un automate permet de caractériser un langage (les mots acceptés).  Définition Un automate à état fini est le cinquplet A = (Q, VT, δ, q0, F) avec Q: Ensemble fini d’états F : Ensemble des états finaux δ : Fonction de transition , δ: Q X VTQ q0 : Etat initial Automate G Un mot m Oui : si m ∈ L(G) Non :sinon 8
  • 9. Automate  Exemple: Reconnaître les mot du langage L={ac*b}={ab, acb,accb,acccb,…} A = ({q0,q1,q2}, {a,b,c}, δ, q0, {q2}) δ: Q X VTQ (q0,a) q1 (q1,b)q2 (q1,c)q1 q1 q2 q0 a c b 9
  • 10. Type de langages  Type 3:langage régulier Toutes les règles sont sous la forme: α → x ou α → xβ Avec x Є VT ; α et β Є VN  Type 2: Langage algébrique Toutes les règles sont sous la forme: α → β avec α Є VN ; et β Є (VN U VT ) *  Type 1:langage à contexte lié Toutes les règles sont sous la forme: α → β avec α Є (VN U VT )+ , β Є (VN U VT )* et | α |<=| β |  Type 0: Aucune restriction sur la forme des règles Exemple 1: pour un langage L={a* } G= SaS Sε SSa Sε ou Exemple 2: Soit L={an bn /n ≥1} G= SaSb|ab Exemple 3: Soit L={an bn cn /n ≥0} G= Sε SaRbc|abc RaRTb R aTb TbbT Tccc 10
  • 11. Type de langages * Langage naturel * | α | ≤ | β | * {anbncn/n≥1} * A → β * {anbn/n≥0}, Langages de programmation * Automate à pile * A → a ou A → aB * {Ac*b}, langage de commandes * Automate à états finis • Hiérarchie de Chomsky Type 0 Type 1 Type 2 Type 3 11
  • 12.  Définitions  Grammaire ambigüe : Un mot est ambigüe s’il dispose de plus qu’une suite de dérivation gauche(ou droite) Une grammaire est ambigüe si elle génère au moins un mot ambigüe  Factorisation à gauche : AaB|aC  Exemple: soit G= E →E+E | E*E G’= A → aD D → B |C E →E E’ E’ →+E|*E Langages Algébrique 12
  • 13. Langages Algebriques  Récursivité à gauche : A → Aα| β  Exemple : soit G = S →Sa|a  Soit G’=  G’G  Dérivation de m: S=>aS’=>aaS’=>aaaS’aaa ε=>aaa = m est accepté A → β A’ A’ →α A’ | ε S → aS’ S’ →aS’| ε 13
  • 14.  Soit un alphabet X={a,b}, 1. Écrire une grammaire du langage L formé sur X . 2. L est une suite de a et b 3. Quel est le type de cette grammaire ? 4. Donner un exemple de dérivation d’un mot. Langages Algébrique Solution: 1. S → a S a S → b S b S → a S → b S → ε 2. Cette grammaire est de Type 2 car S Є VN , a S a Є (VN U VT ) * (α Є VN et β Є (VN U VT ) * ) 3. SaSaabSbaabaSaba abaεaba Le mot est abaaba 14
  • 15. ¤ La théorie des langages = Comprendre le fonctionnement des langages. ¤ Un langage = Ensemble de mots ¤ Un mot (ou lexème) = Une combinaison de symboles ¤ L'ensemble des symboles élémentaires  alphabet ¤ La fonction associant l'alphabet au langage  grammaire ¤ On peut associer à une grammaire un automate Déterminer si un mot fait partie d'un langage. ¤ Domaines d’application : les compilateurs… Récapitulatif 15

Notes de l'éditeur

  1. Un automate est un algorithme (une machine) prenant en entrée un mot et donnant une réponse oui (l’automate accepte le mot) ou non (l’automate refuse le mot). On dit qu’une grammaire est un procédé génératif alors qu’un automate fonctionne en reconnaissance.
  2. Exemple: on pourra vérifier si un mot (ex: w=acccc) appartient à L en parcourant le mot de gauche à droite et en naviguant dans l’automate selon la fonction de transition δ. Le mot est accepté si tout les symboles sont lu et on est dans un état final
  3. Les grammaires peuvent être plus ou moins compliquées. Une hiérarchie a été proposée par CHOMSKY et dépend de la forme des règles. Si on a α → x ou α → xβ : grammaire régulière à gauche (respectivement si on a α → βx elle est régulière à droite) On constate une inclusion des diverses classes.
  4. Toutes les grammaires sont de type 0. •Toutes les grammaires dont les règles α → β vérifient | α | ≤ | β | sont de type 1. •Toutes les grammaires dont les règles sont de la forme A → β sont de type 2. •Toutes les grammaires dont les règles sont de la forme A → a ou de la forme A → aB sont de type 3. Toutes les grammaires sont de type 0. •Toutes les grammaires dont les règles α → β vérifient | α | ≤ | β | sont de type 1. •Toutes les grammaires dont les règles sont de la forme A → β sont de type 2. •Toutes les grammaires dont les règles sont de la forme A → a ou de la forme A → aB sont de type 3. Toutes les grammaires sont de type 0. •Toutes les grammaires dont les règles α → β vérifient | α | ≤ | β | sont de type 1. •Toutes les grammaires dont les règles sont de la forme A → β sont de type 2. •Toutes les grammaires dont les règles sont de la forme A → a ou de la forme A → aB sont de type 3.