Formal Languages Philippe de Groote 2018-2019 Philippe de Groote - - PowerPoint PPT Presentation

formal languages
SMART_READER_LITE
LIVE PREVIEW

Formal Languages Philippe de Groote 2018-2019 Philippe de Groote - - PowerPoint PPT Presentation

Formal Languages Philippe de Groote 2018-2019 Philippe de Groote Formal Languages 2018-2019 1 / 12 Outline Phrase Structure Grammars 1 Introduction Alphabets, words, and languages Definition of a phrase structure grammar Chomsky


slide-1
SLIDE 1

Formal Languages

Philippe de Groote 2018-2019

Philippe de Groote Formal Languages 2018-2019 1 / 12

slide-2
SLIDE 2

Outline

1

Phrase Structure Grammars Introduction Alphabets, words, and languages Definition of a phrase structure grammar Chomsky hierarchy Decision problems Exercices

Philippe de Groote Formal Languages 2018-2019 2 / 12

slide-3
SLIDE 3

Phrase Structure Grammars Introduction

Introduction

If the quorum is not met, the president may convene a new meeting.

Philippe de Groote Formal Languages 2018-2019 3 / 12

slide-4
SLIDE 4

Phrase Structure Grammars Introduction

Introduction

If the quorum is not met, the president may convene a new meeting.

S SBAR IN

If

S NP DT

the

NN

quorum

VP VBZ

is

RB

not

VP VBN

met

NP DT

the

NN

president

VP MD

may

VP VB

convene

NP DT

a

JJ

new

NN

meeting

Philippe de Groote Formal Languages 2018-2019 3 / 12

slide-5
SLIDE 5

Phrase Structure Grammars Introduction

Introduction

S → NP VP S → SBAR NP VP SBAR → IN S VP → VBN VP → VB NP VP → MD VP VP → VBZ RB VP NP → DT NN NP → DT JJ NN VB → convene VBN → met VBZ → is MD → may NN → quorum | president | meeting JJ → new DT → the | a IN → if RB → not

Philippe de Groote Formal Languages 2018-2019 4 / 12

slide-6
SLIDE 6

Phrase Structure Grammars Alphabets, words, and languages

Alphabets, words, and languages

An alphabet is a finite, non-empty set of symbols.

Philippe de Groote Formal Languages 2018-2019 5 / 12

slide-7
SLIDE 7

Phrase Structure Grammars Alphabets, words, and languages

Alphabets, words, and languages

An alphabet is a finite, non-empty set of symbols. A word is a finite sequence of symbols chosen from some given alphabet.

Philippe de Groote Formal Languages 2018-2019 5 / 12

slide-8
SLIDE 8

Phrase Structure Grammars Alphabets, words, and languages

Alphabets, words, and languages

An alphabet is a finite, non-empty set of symbols. A word is a finite sequence of symbols chosen from some given alphabet. The empty word, denoted ǫ, is the empty sequence of symbols.

Philippe de Groote Formal Languages 2018-2019 5 / 12

slide-9
SLIDE 9

Phrase Structure Grammars Alphabets, words, and languages

Alphabets, words, and languages

An alphabet is a finite, non-empty set of symbols. A word is a finite sequence of symbols chosen from some given alphabet. The empty word, denoted ǫ, is the empty sequence of symbols. Let Σ be an alphabet. Σ∗ denotes the set of all words over Σ.

Philippe de Groote Formal Languages 2018-2019 5 / 12

slide-10
SLIDE 10

Phrase Structure Grammars Alphabets, words, and languages

Alphabets, words, and languages

An alphabet is a finite, non-empty set of symbols. A word is a finite sequence of symbols chosen from some given alphabet. The empty word, denoted ǫ, is the empty sequence of symbols. Let Σ be an alphabet. Σ∗ denotes the set of all words over Σ. Let α ∈ Σ∗ be such that α = a1 . . . an, with ai ∈ Σ for 1 ≤ i ≤ n. The length of α, in notation |α|, is the number of occurrences of symbols in α, i.e., |α| = n.

Philippe de Groote Formal Languages 2018-2019 5 / 12

slide-11
SLIDE 11

Phrase Structure Grammars Alphabets, words, and languages

Alphabets, words, and languages

An alphabet is a finite, non-empty set of symbols. A word is a finite sequence of symbols chosen from some given alphabet. The empty word, denoted ǫ, is the empty sequence of symbols. Let Σ be an alphabet. Σ∗ denotes the set of all words over Σ. Let α ∈ Σ∗ be such that α = a1 . . . an, with ai ∈ Σ for 1 ≤ i ≤ n. The length of α, in notation |α|, is the number of occurrences of symbols in α, i.e., |α| = n. In particular, |ǫ| = 0.

Philippe de Groote Formal Languages 2018-2019 5 / 12

slide-12
SLIDE 12

Phrase Structure Grammars Alphabets, words, and languages

Alphabets, words, and languages

Let α, β ∈ Σ∗ be such that α = a1 . . . an, with ai ∈ Σ for 1 ≤ i ≤ n, and β = b1 . . . bm, with bi ∈ Σ for 1 ≤ i ≤ m. α · β is defined to be the concatenation of α and β, i.e., α · β = a1 . . . anb1 . . . bm.

Philippe de Groote Formal Languages 2018-2019 6 / 12

slide-13
SLIDE 13

Phrase Structure Grammars Alphabets, words, and languages

Alphabets, words, and languages

Let α, β ∈ Σ∗ be such that α = a1 . . . an, with ai ∈ Σ for 1 ≤ i ≤ n, and β = b1 . . . bm, with bi ∈ Σ for 1 ≤ i ≤ m. α · β is defined to be the concatenation of α and β, i.e., α · β = a1 . . . anb1 . . . bm. In particular, ǫ · α = α = α · ǫ.

Philippe de Groote Formal Languages 2018-2019 6 / 12

slide-14
SLIDE 14

Phrase Structure Grammars Alphabets, words, and languages

Alphabets, words, and languages

Let α, β ∈ Σ∗ be such that α = a1 . . . an, with ai ∈ Σ for 1 ≤ i ≤ n, and β = b1 . . . bm, with bi ∈ Σ for 1 ≤ i ≤ m. α · β is defined to be the concatenation of α and β, i.e., α · β = a1 . . . anb1 . . . bm. In particular, ǫ · α = α = α · ǫ. Σ∗, ·, ǫ is a monoid.

Philippe de Groote Formal Languages 2018-2019 6 / 12

slide-15
SLIDE 15

Phrase Structure Grammars Alphabets, words, and languages

Alphabets, words, and languages

Let α, β ∈ Σ∗ be such that α = a1 . . . an, with ai ∈ Σ for 1 ≤ i ≤ n, and β = b1 . . . bm, with bi ∈ Σ for 1 ≤ i ≤ m. α · β is defined to be the concatenation of α and β, i.e., α · β = a1 . . . anb1 . . . bm. In particular, ǫ · α = α = α · ǫ. Σ∗, ·, ǫ is a monoid. A language over Σ is a subset of Σ∗.

Philippe de Groote Formal Languages 2018-2019 6 / 12

slide-16
SLIDE 16

Phrase Structure Grammars Alphabets, words, and languages

Alphabets, words, and languages

Operation on languages:

Philippe de Groote Formal Languages 2018-2019 7 / 12

slide-17
SLIDE 17

Phrase Structure Grammars Alphabets, words, and languages

Alphabets, words, and languages

Operation on languages: Usual set-theoretic operations: union, intersection, complement (w.r.t. Σ∗), ...

Philippe de Groote Formal Languages 2018-2019 7 / 12

slide-18
SLIDE 18

Phrase Structure Grammars Alphabets, words, and languages

Alphabets, words, and languages

Operation on languages: Usual set-theoretic operations: union, intersection, complement (w.r.t. Σ∗), ... Concatenation: L1 · L2 = {ω : ∃α ∈ L1.∃β ∈ L2.ω = α · β}

Philippe de Groote Formal Languages 2018-2019 7 / 12

slide-19
SLIDE 19

Phrase Structure Grammars Alphabets, words, and languages

Alphabets, words, and languages

Operation on languages: Usual set-theoretic operations: union, intersection, complement (w.r.t. Σ∗), ... Concatenation: L1 · L2 = {ω : ∃α ∈ L1.∃β ∈ L2.ω = α · β} Exponentiation: L0 = {ǫ} Ln+1 = L · Ln

Philippe de Groote Formal Languages 2018-2019 7 / 12

slide-20
SLIDE 20

Phrase Structure Grammars Alphabets, words, and languages

Alphabets, words, and languages

Operation on languages: Usual set-theoretic operations: union, intersection, complement (w.r.t. Σ∗), ... Concatenation: L1 · L2 = {ω : ∃α ∈ L1.∃β ∈ L2.ω = α · β} Exponentiation: L0 = {ǫ} Ln+1 = L · Ln Closure: L∗ =

  • i∈N

Li

Philippe de Groote Formal Languages 2018-2019 7 / 12

slide-21
SLIDE 21

Phrase Structure Grammars Definition of a phrase structure grammar

Definition of a phrase structure grammar

A phrase structure grammar is a 4-tuple G = N, Σ, P, S, where N is an alphabet, the elements of which are called non-terminal symbols; Σ is an alphabet disjoint from N, the elements of which are called terminal symbols; P ⊂ ((N ∪ Σ)∗N(N ∪ Σ)∗) × (N ∪ Σ)∗ is a set of production rules; S ∈ N is called the start symbol.

Philippe de Groote Formal Languages 2018-2019 8 / 12

slide-22
SLIDE 22

Phrase Structure Grammars Definition of a phrase structure grammar

Definition of a phrase structure grammar

A phrase structure grammar is a 4-tuple G = N, Σ, P, S, where N is an alphabet, the elements of which are called non-terminal symbols; Σ is an alphabet disjoint from N, the elements of which are called terminal symbols; P ⊂ ((N ∪ Σ)∗N(N ∪ Σ)∗) × (N ∪ Σ)∗ is a set of production rules; S ∈ N is called the start symbol. A production rule (α, β) ∈ P will be written as α → β.

Philippe de Groote Formal Languages 2018-2019 8 / 12

slide-23
SLIDE 23

Phrase Structure Grammars Definition of a phrase structure grammar

Definition of a phrase structure grammar

Let G = N, Σ, P, S be a phrase structure grammar, and let α, β ∈ (N ∪ Σ)∗. We say that α directly generates β, and we write α ⇒ β, if and only if there exist α0, β0, γ, δ ∈ (N ∪ Σ)∗ such that: α = γα0δ and β = γβ0δ and (α0 → β0) ∈ P

Philippe de Groote Formal Languages 2018-2019 9 / 12

slide-24
SLIDE 24

Phrase Structure Grammars Definition of a phrase structure grammar

Definition of a phrase structure grammar

Let G = N, Σ, P, S be a phrase structure grammar, and let α, β ∈ (N ∪ Σ)∗. We say that α directly generates β, and we write α ⇒ β, if and only if there exist α0, β0, γ, δ ∈ (N ∪ Σ)∗ such that: α = γα0δ and β = γβ0δ and (α0 → β0) ∈ P We write ⇒∗ for the reflexive-transitive closure of ⇒.

Philippe de Groote Formal Languages 2018-2019 9 / 12

slide-25
SLIDE 25

Phrase Structure Grammars Definition of a phrase structure grammar

Definition of a phrase structure grammar

Let G = N, Σ, P, S be a phrase structure grammar, and let α, β ∈ (N ∪ Σ)∗. We say that α directly generates β, and we write α ⇒ β, if and only if there exist α0, β0, γ, δ ∈ (N ∪ Σ)∗ such that: α = γα0δ and β = γβ0δ and (α0 → β0) ∈ P We write ⇒∗ for the reflexive-transitive closure of ⇒. Let G = N, Σ, P, S be a phrase structure grammar. The language generated by G, in notation L(G), is defined as follows: L(G) = {α ∈ Σ∗ : S ⇒∗ α}

Philippe de Groote Formal Languages 2018-2019 9 / 12

slide-26
SLIDE 26

Phrase Structure Grammars Chomsky hierarchy

Chomsky hierarchy

type rules languages automata αAβ → γ recursively enumerable Turing machines 1 αAβ → αδβ context-sensitive linear bounded Turing machines 2 A → α context-free pushdown automata 3 A → aB or A → b regular finite state automata where: α, β, γ, δ ∈ (N ∪ Σ)∗; δ = ǫ; A, B ∈ N; a ∈ Σ; b ∈ Σ ∪ {ǫ};

Philippe de Groote Formal Languages 2018-2019 10 / 12

slide-27
SLIDE 27

Phrase Structure Grammars Decision problems

Decision problems

Let G = N, Σ, P, S be a phrase structure grammar.

Philippe de Groote Formal Languages 2018-2019 11 / 12

slide-28
SLIDE 28

Phrase Structure Grammars Decision problems

Decision problems

Let G = N, Σ, P, S be a phrase structure grammar. Emptiness:

Is L(G) different from the empty set?

Philippe de Groote Formal Languages 2018-2019 11 / 12

slide-29
SLIDE 29

Phrase Structure Grammars Decision problems

Decision problems

Let G = N, Σ, P, S be a phrase structure grammar. Emptiness:

Is L(G) different from the empty set?

Membership:

Let α ∈ Σ∗. Does α belong L(G)?

Philippe de Groote Formal Languages 2018-2019 11 / 12

slide-30
SLIDE 30

Phrase Structure Grammars Exercices

Exercices

1 Write a phrase structure grammar that generates {(ab)n : n ≥ 0} 2 Write a phrase structure grammar that generates {(ab)n : n ≥ 1} 3 Write a phrase structure grammar that generates {anbn : n ≥ 1} 4 Write a phrase structure grammar that generates {anbncn : n ≥ 1} 5 Write a type-3 grammar that generates {(ab)n : n ≥ 1} 6 Write a type-2 grammar that generates {anbn : n ≥ 1} 7 Write a type-1 grammar that generates {anbncn : n ≥ 1} Philippe de Groote Formal Languages 2018-2019 12 / 12