1 / 29

Automi e Linguaggi Regolari

Automi e Linguaggi Regolari. Alberto Cuesta Ca ñada. Introduzione. Lo scopo della informatica e diventare possibile la communicazione tra l’uomo e i computer. Prima dobbiamo trovare un linguaggio commune, o meggio, costruirlo. Linguaggi. Definizioni: Σ= Insieme di letteri

joanne
Download Presentation

Automi e Linguaggi Regolari

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Automi e Linguaggi Regolari Alberto Cuesta Cañada

  2. Introduzione • Lo scopo della informatica e diventare possibile la communicazione tra l’uomo e i computer. • Prima dobbiamo trovare un linguaggio commune, o meggio, costruirlo.

  3. Linguaggi • Definizioni: • Σ= Insieme di letteri • X= a1…ai |ajє Σ = parola (finita) • X*=Tutte le parole generate per Σ

  4. Linguaggi • Un linguaggio e un insieme di parole (puo essere infinito) da un alfabeto finito. • Si genera con grammatiche con struttura di frase.

  5. Phrase Structure Grammars • G={V, Σ, P, S} • Grosso modo una grammatica sono lettere e regole per costrurre parole. • L(G) e’ il linguaggio composto per tutte le parole generate per G. • P=(V- Σ)+ x V*

  6. Context Sensitive Grammars • Le produzione hanno la forma: • uAv→uwv dove u,v є V * (forse λ) A є (V- Σ) w є V*, w≠ λ • Lcsf=(anbncn)

  7. Context Sensitive Grammars • Grosso modo, un non-terminale determinato puo essere cambiato per una cattena di lettere determinata in un certo contesto.

  8. Context Sensitive Grammars • E dimostrabile che queste grammatiche possono essere transformate in altri equivalente: • u→v u є (V- Σ)+, v є (V- Σ) * • A→a A є (V- Σ), a є Σ

  9. Context Free Grammars • Le produzione hanno la forma: • A→x dove x є (V) * (forse λ) A є (V- Σ) • Lcfg=(anbn)

  10. Context Free Grammars • E dimostrabile che queste grammatiche possono essere transformate in altra equivalente del modo: • A→xv dove x,v є V (forse λ) A є (V- Σ) • Questo serve per produrre alberi binari

  11. Context Free Grammars • Definizione: Una parola ‘e in forma canonica se tutte le sue derivazione sono nell stesso senso (destra o sinistra) • S→Sa| λ S S a S a S a

  12. Linear Context Free Grammars • Una grammatica di cui tutte le forme possibili sono canoniche a destra (sinistra) se dice che e’ lineale a destra (sinistra). • E’ dimostrabile che queste grammatiche sono equivalenti alle grammatiche regolari. • L=(aibj)

  13. Grammars Phrase Structure Grammars Context Sensitive Grammars Context Free Grammars Linear Context Free Grammars

  14. Automi • Un automa e’ una 5-tupla {Q, Σ, δ, q0, F} • Q=Stati. • Σ=Alfabeto. • δ =Transizioni. • q0 =Stato Iniziale. • F=Stati Finali. 1 b a λ 0 3 b a 2 a

  15. LCF Grammars e Automi • E’ dimostrabile la correspondenza tra Linguaggi Regolari e Automi Finiti. • L=(a+b)* λ a 3 4 λ λ λ λ λ λ 0 1 2 7 8 9 λ λ b 5 6 λ

  16. Operazioni con Automi: AFλ →AFN • Si puo trovare un automa finito non determinista per ogni automa finito con transizioni vuoti: λ a 3 4 λ λ λ λ λ λ 0 1 2 7 8 9 λ λ b 5 6 λ

  17. Operazioni con Automi: AFλ →AFN λ • Prendiamo uno stato e troviamo la sua λ-clousure. • 0 → 0,1,2,3,5,8,9 a 3 4 λ λ λ λ λ λ 0 1 2 7 8 9 λ λ b 5 6 λ

  18. Operazioni con Automi: AFλ →AFN • Prendiamo un altro stato diverso e ripetiamo: • 4 → 7,0 4 a λ 0 7 λ b 6 λ

  19. Operazioni con Automi: AFλ →AFN a • Ripetiamo: • 6 → 6,4 a,b b 4 6 6 λ Il metodo finisce quando non c’e’ nessuna transizione vuota

  20. Operazioni con Automi: AFN →AFD • Si puo trovare un automa finito determinista per ogni automa finito non determinista: b 1 3 a b 0 a b 5 b a a 2 4

  21. Operazioni con Automi: AFN →AFD Stato a b b 1 3 b a a a a,b b V 4,5 0 a,b a b a b a V,5 b b V,4,5 V,3 a b 2 a 1,4

  22. Operazioni con Automi: AFD →AFD Minimo • E’ molto utile lavorare con automi minimi: b 1 3 b a a a a,b b 9 5 0 a,b a b a b a 6 b b 8 7 a b 2 a 4

  23. Operazioni con Automi: AFD →AFD Minimo 5,6,8 є F → B1={1,2,3,4,7,9}, B2={5,6,8} B1’={0,1,2} B2’={3,7} B3’={4,9} B4’={5,8} B5’={6}

  24. Operazioni con Automi: AFD →AFD Minimo B1’={0} B2’={1} B3’={2} B4’={3,7} B5’={4} B6’={9} B7’={5,8} B8’={6}

  25. Operazioni con Automi: AFD →AFD Minimo El algoritmo finisce qui, abbiamo tolto due stati dell’ originale. a,b B6 a b a B2 B4 B7 b b a a,b a B1 b b a a B3 B5 B8

  26. Pushdown Automata • Un automa pushdown ha due nastri, uno con il input, e altro che funziona come uno stack. • Questi automi sono correspondenti con le Context Free Grammars. a Automa nell stato Q Z

  27. Linear Bounded Automata • Un Linear Bounded Automa ha un solo nastro finito, in cui puo leggere e scrivere • Questi automi sono correspondenti con le Context Sensitive Grammars. a Automa nell stato Q

  28. Turing Machines • Una Machina di Turing e’ una Linear Bounded Machine che lavora su un nastro di input infinito. • Queste machine sono correspondenti con le Phrase Structure Grammars. a Automa nell stato Q

  29. Conclusione Machine di Turing Phrase Structure Grammars Context Sensitive Grammars Linear Bounded Automi Pushdown Automi Context Free Grammars Linear Context Free Grammars Automi Finiti

More Related