INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo...

66
INF2080 Context-Sensitive Langugaes Daniel Lupp Universitetet i Oslo 15th February 2017 Department of Informatics University of Oslo INF2080 Lecture :: 15th February 1 / 20

Transcript of INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo...

Page 1: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

INF2080Context-Sensitive Langugaes

Daniel Lupp

Universitetet i Oslo

15th February 2017

Department ofInformatics

University ofOslo

INF2080 Lecture :: 15th February 1 / 20

Page 2: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Context-Free Grammar

Definition (Context-Free Grammar)

A context-free grammar is a 4-tuple (V ,Σ,R, S) where1 V is a finite set of variables2 Σ is a finite set disjoint from V of terminals3 R is a finite set of rules, each consisting of a variable and of a string of variables and

terminals4 and S is the start variable

Rules are of the form A→ B1B2B3 . . .Bm, where A ∈ V and each Bi ∈ V ∪ Σ.

INF2080 Lecture :: 15th February 2 / 20

Page 3: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Why Context-Sensitive?

Many building blocks of programming languages are context-free, but not all!

consider the following toy programming language, where you can “declare” and “assign” avariable a value.

S → declare v ; S | assign v : x ;S

this is context-free...but what if we only want to allow assignment after declaration and an infinite amount ofvariable names? → context-sensitive!

INF2080 Lecture :: 15th February 3 / 20

Page 4: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Why Context-Sensitive?

Many building blocks of programming languages are context-free, but not all!consider the following toy programming language, where you can “declare” and “assign” avariable a value.

S → declare v ; S | assign v : x ;S

this is context-free...but what if we only want to allow assignment after declaration and an infinite amount ofvariable names? → context-sensitive!

INF2080 Lecture :: 15th February 3 / 20

Page 5: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Why Context-Sensitive?

Many building blocks of programming languages are context-free, but not all!consider the following toy programming language, where you can “declare” and “assign” avariable a value.

S → declare v ; S | assign v : x ;S

this is context-free...

but what if we only want to allow assignment after declaration and an infinite amount ofvariable names? → context-sensitive!

INF2080 Lecture :: 15th February 3 / 20

Page 6: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Why Context-Sensitive?

Many building blocks of programming languages are context-free, but not all!consider the following toy programming language, where you can “declare” and “assign” avariable a value.

S → declare v ; S | assign v : x ;S

this is context-free...but what if we only want to allow assignment after declaration and an infinite amount ofvariable names? → context-sensitive!

INF2080 Lecture :: 15th February 3 / 20

Page 7: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Context-Sensitive Languages

Some believe natural languages reside in the class of context-sensitive languages, thoughthis is a controversial topic amongst linguists.

But many characteristics of natural languages (e.g., verb-noun agreement) arecontext-sensitive!

INF2080 Lecture :: 15th February 4 / 20

Page 8: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Context-Sensitive Languages

Some believe natural languages reside in the class of context-sensitive languages, thoughthis is a controversial topic amongst linguists.But many characteristics of natural languages (e.g., verb-noun agreement) arecontext-sensitive!

INF2080 Lecture :: 15th February 4 / 20

Page 9: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Context-Sensitive Grammars

So, instead of allowing for a single variable on the left-hand side of a rule, we allow for acontext:

αBγ → αβγ (1)

with α, β, γ ∈ (V ∪ Σ)∗, but β 6= ε.

Definition (Context-sensitive grammar)

A context-sensitive grammar is a 4-tuple (V ,Σ,R,S) consisting ofa finite set V of variables;a finite set Σ of terminals, disjoint from V ;a set R of rules of the form (1);a start variable S ∈ V . If S does not occur on any righthand side of a rule in S , we alsoallow for the rule S → ε in R .

INF2080 Lecture :: 15th February 5 / 20

Page 10: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Context-Sensitive Grammars

So, instead of allowing for a single variable on the left-hand side of a rule, we allow for acontext:

αBγ → αβγ (1)

with α, β, γ ∈ (V ∪ Σ)∗, but β 6= ε.

Definition (Context-sensitive grammar)

A context-sensitive grammar is a 4-tuple (V ,Σ,R,S) consisting ofa finite set V of variables;a finite set Σ of terminals, disjoint from V ;a set R of rules of the form (1);a start variable S ∈ V . If S does not occur on any righthand side of a rule in S , we alsoallow for the rule S → ε in R .

INF2080 Lecture :: 15th February 5 / 20

Page 11: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Example

Recall that the language {anbncn | n ≥ 1} was not context-free. (pumping lemma for CFLs)

It is, however, context-sensitive!A context-sensitive grammar that produces this language:

S → ABC

S → ASB ′C

CB ′ → Z1B′

Z1B′ → Z1Z2

Z1Z2 → B ′Z2

B ′Z2 → B ′C

BB ′ → BB

A→ a

B → b

C → c

INF2080 Lecture :: 15th February 6 / 20

Page 12: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Example

Recall that the language {anbncn | n ≥ 1} was not context-free. (pumping lemma for CFLs)It is, however, context-sensitive!

A context-sensitive grammar that produces this language:

S → ABC

S → ASB ′C

CB ′ → Z1B′

Z1B′ → Z1Z2

Z1Z2 → B ′Z2

B ′Z2 → B ′C

BB ′ → BB

A→ a

B → b

C → c

INF2080 Lecture :: 15th February 6 / 20

Page 13: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Example

Recall that the language {anbncn | n ≥ 1} was not context-free. (pumping lemma for CFLs)It is, however, context-sensitive!A context-sensitive grammar that produces this language:

S → ABC

S → ASB ′C

CB ′ → Z1B′

Z1B′ → Z1Z2

Z1Z2 → B ′Z2

B ′Z2 → B ′C

BB ′ → BB

A→ a

B → b

C → c

INF2080 Lecture :: 15th February 6 / 20

Page 14: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Noncontracting Grammars

So CSGs can be quite cumbersome...

many rules needed to encode, e.g., the swapping rulecB → Bc .

Definition (Noncontracting Grammars)

A noncontracting grammar is a set of rules α→ β, where α, β ∈ (V ∪ Σ)∗ and |α| ≤ |β|. Inaddition, it may contain S → ε if S does not occur on any righthand side of a rule.

Examples:

cC → abABc

ab → de

cB → Bc

Note: none of these rules are context-sensitive!

INF2080 Lecture :: 15th February 7 / 20

Page 15: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Noncontracting Grammars

So CSGs can be quite cumbersome...many rules needed to encode, e.g., the swapping rulecB → Bc .

Definition (Noncontracting Grammars)

A noncontracting grammar is a set of rules α→ β, where α, β ∈ (V ∪ Σ)∗ and |α| ≤ |β|. Inaddition, it may contain S → ε if S does not occur on any righthand side of a rule.

Examples:

cC → abABc

ab → de

cB → Bc

Note: none of these rules are context-sensitive!

INF2080 Lecture :: 15th February 7 / 20

Page 16: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Noncontracting Grammars

So CSGs can be quite cumbersome...many rules needed to encode, e.g., the swapping rulecB → Bc .

Definition (Noncontracting Grammars)

A noncontracting grammar is a set of rules α→ β, where α, β ∈ (V ∪ Σ)∗ and |α| ≤ |β|. Inaddition, it may contain S → ε if S does not occur on any righthand side of a rule.

Examples:

cC → abABc

ab → de

cB → Bc

Note: none of these rules are context-sensitive!

INF2080 Lecture :: 15th February 7 / 20

Page 17: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Noncontracting Grammars

So CSGs can be quite cumbersome...many rules needed to encode, e.g., the swapping rulecB → Bc .

Definition (Noncontracting Grammars)

A noncontracting grammar is a set of rules α→ β, where α, β ∈ (V ∪ Σ)∗ and |α| ≤ |β|. Inaddition, it may contain S → ε if S does not occur on any righthand side of a rule.

Examples:

cC → abABc

ab → de

cB → Bc

Note: none of these rules are context-sensitive!

INF2080 Lecture :: 15th February 7 / 20

Page 18: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Noncontracting Grammars

So CSGs can be quite cumbersome...many rules needed to encode, e.g., the swapping rulecB → Bc .

Definition (Noncontracting Grammars)

A noncontracting grammar is a set of rules α→ β, where α, β ∈ (V ∪ Σ)∗ and |α| ≤ |β|. Inaddition, it may contain S → ε if S does not occur on any righthand side of a rule.

Examples:

cC → abABc

ab → de

cB → Bc

Note: none of these rules are context-sensitive!

INF2080 Lecture :: 15th February 7 / 20

Page 19: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Noncontracting vs. Context-sensitive Grammars

First note: context-sensitive rules αBγ → αβγ are noncontracting, since we requiredβ 6= ε.

So it would seem that noncontracting grammars are quite a bit more expressive thancontext-sensitive grammars. After all, α→ β is far more general...

TheoremEvery noncontracting grammar can be transformed into a context-sensitive grammar thatproduces the same language.

So, in the spirit of INF2080’s love of abbreviations: NCG = CSG!

INF2080 Lecture :: 15th February 8 / 20

Page 20: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Noncontracting vs. Context-sensitive Grammars

First note: context-sensitive rules αBγ → αβγ are noncontracting, since we requiredβ 6= ε.So it would seem that noncontracting grammars are quite a bit more expressive thancontext-sensitive grammars. After all, α→ β is far more general...

TheoremEvery noncontracting grammar can be transformed into a context-sensitive grammar thatproduces the same language.

So, in the spirit of INF2080’s love of abbreviations: NCG = CSG!

INF2080 Lecture :: 15th February 8 / 20

Page 21: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Noncontracting vs. Context-sensitive Grammars

First note: context-sensitive rules αBγ → αβγ are noncontracting, since we requiredβ 6= ε.So it would seem that noncontracting grammars are quite a bit more expressive thancontext-sensitive grammars. After all, α→ β is far more general...

TheoremEvery noncontracting grammar can be transformed into a context-sensitive grammar thatproduces the same language.

So, in the spirit of INF2080’s love of abbreviations: NCG = CSG!

INF2080 Lecture :: 15th February 8 / 20

Page 22: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Noncontracting vs. Context-sensitive Grammars

First note: context-sensitive rules αBγ → αβγ are noncontracting, since we requiredβ 6= ε.So it would seem that noncontracting grammars are quite a bit more expressive thancontext-sensitive grammars. After all, α→ β is far more general...

TheoremEvery noncontracting grammar can be transformed into a context-sensitive grammar thatproduces the same language.

So, in the spirit of INF2080’s love of abbreviations: NCG = CSG!

INF2080 Lecture :: 15th February 8 / 20

Page 23: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Example

The language {anbncn | n ≥ 1} described by CSG:

S → ABC

S → ASB ′C

CB ′ → Z1B′

Z1B′ → Z1Z2

Z1Z2 → B ′Z2

B ′Z2 → B ′C

BB ′ → BB

A→ a

B → b

C → c

INF2080 Lecture :: 15th February 9 / 20

Page 24: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Example

The language {anbncn | n ≥ 1} described by NCG:

S → abc

S → aSBc

cB → Bc

bB → bb

Due to the equivalence, some people define context-senstive languages using noncontractinggrammars.

INF2080 Lecture :: 15th February 10 / 20

Page 25: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Example

The language {anbncn | n ≥ 1} described by NCG:

S → abc

S → aSBc

cB → Bc

bB → bb

Due to the equivalence, some people define context-senstive languages using noncontractinggrammars.

INF2080 Lecture :: 15th February 10 / 20

Page 26: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Kuroda Normal Form

Similar to CFG’s Chomsky Normal Form, CSG’s have a normal form of their own:

Definition (Kuroda Normal Form)

A noncontracting grammar is in Kuroda normal form if all rules are of the form

AB → CD

A→ BC

A→ B

A→ a

for variables A,B,C ,D and terminals a.

TheoremFor every context-sensitive grammar there exists a noncontracting grammar in Kuroda normalform that produces the same language.

INF2080 Lecture :: 15th February 11 / 20

Page 27: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Kuroda Normal Form

Similar to CFG’s Chomsky Normal Form, CSG’s have a normal form of their own:

Definition (Kuroda Normal Form)

A noncontracting grammar is in Kuroda normal form if all rules are of the form

AB → CD

A→ BC

A→ B

A→ a

for variables A,B,C ,D and terminals a.

TheoremFor every context-sensitive grammar there exists a noncontracting grammar in Kuroda normalform that produces the same language.

INF2080 Lecture :: 15th February 11 / 20

Page 28: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Linear Bounded Automata

So what type of computational model accepts precisely the context-sensitive languages?

→ linear bounded automata!Essentially, LBAs are NFAs with a bounded tape as memory (as opposed to the stack for PDAs)

DefinitionA linear bounded automaton (LBA) is a tuple (Q,Σ, Γ, δ, <,>, q0, qa, qr ) whereQ,Σ, Γ, δ, q0, qa, qr are defined precisely as in a Turing machine, except that the transitionfunction can neither move the head to the left of the left marker < nor to the right of the rightmarker >.

A LBA initializes in the configuration < q0w1w2 · · ·wn >. So, intuitively, the tape of theTuring machine is restricted to the length of the input.

INF2080 Lecture :: 15th February 12 / 20

Page 29: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Linear Bounded Automata

So what type of computational model accepts precisely the context-sensitive languages?→ linear bounded automata!

Essentially, LBAs are NFAs with a bounded tape as memory (as opposed to the stack for PDAs)

DefinitionA linear bounded automaton (LBA) is a tuple (Q,Σ, Γ, δ, <,>, q0, qa, qr ) whereQ,Σ, Γ, δ, q0, qa, qr are defined precisely as in a Turing machine, except that the transitionfunction can neither move the head to the left of the left marker < nor to the right of the rightmarker >.

A LBA initializes in the configuration < q0w1w2 · · ·wn >. So, intuitively, the tape of theTuring machine is restricted to the length of the input.

INF2080 Lecture :: 15th February 12 / 20

Page 30: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Linear Bounded Automata

So what type of computational model accepts precisely the context-sensitive languages?→ linear bounded automata!Essentially, LBAs are NFAs with a bounded tape as memory (as opposed to the stack for PDAs)

DefinitionA linear bounded automaton (LBA) is a tuple (Q,Σ, Γ, δ, <,>, q0, qa, qr ) whereQ,Σ, Γ, δ, q0, qa, qr are defined precisely as in a Turing machine, except that the transitionfunction can neither move the head to the left of the left marker < nor to the right of the rightmarker >.

A LBA initializes in the configuration < q0w1w2 · · ·wn >. So, intuitively, the tape of theTuring machine is restricted to the length of the input.

INF2080 Lecture :: 15th February 12 / 20

Page 31: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Linear Bounded Automata

So what type of computational model accepts precisely the context-sensitive languages?→ linear bounded automata!Essentially, LBAs are NFAs with a bounded tape as memory (as opposed to the stack for PDAs)

DefinitionA linear bounded automaton (LBA) is a tuple (Q,Σ, Γ, δ, <,>, q0, qa, qr ) whereQ,Σ, Γ, δ, q0, qa, qr are defined precisely as in a Turing machine, except that the transitionfunction can neither move the head to the left of the left marker < nor to the right of the rightmarker >.

A LBA initializes in the configuration < q0w1w2 · · ·wn >. So, intuitively, the tape of theTuring machine is restricted to the length of the input.

INF2080 Lecture :: 15th February 12 / 20

Page 32: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Linear Bounded Automata

So what type of computational model accepts precisely the context-sensitive languages?→ linear bounded automata!Essentially, LBAs are NFAs with a bounded tape as memory (as opposed to the stack for PDAs)

DefinitionA linear bounded automaton (LBA) is a tuple (Q,Σ, Γ, δ, <,>, q0, qa, qr ) whereQ,Σ, Γ, δ, q0, qa, qr are defined precisely as in a Turing machine, except that the transitionfunction can neither move the head to the left of the left marker < nor to the right of the rightmarker >.

A LBA initializes in the configuration < q0w1w2 · · ·wn >. So, intuitively, the tape of theTuring machine is restricted to the length of the input.

INF2080 Lecture :: 15th February 12 / 20

Page 33: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Myhill-Landweber-Kuroda Theorem

Theorem (Myhill-Landweber-Kuroda Theorem)

A language is context-sensitive iff there exists a linear bounded automaton that recognizes it.

Proof sketch for “⇒”: Construct an automaton with a tape containing the input,nondeterministically guesses a rule in the languages grammar and applies the rule“backwards”, i.e., replaces the input’s symbols occuring on the righthand side (RHS) of therule with the lefthand side (LHS) of the rule.Example: Let aabbcc be the input and let the grammar contain the rule bB → bb. Thenapplying this rule “backwards” on aabbcc yields the string aabBcc .If the input can thus be rewritten to the start variable S , the machine accepts. Since thegrammar is noncontracting, i.e. |LHS|≤|RHS|, the string cannot get longer throughbackwards application of rules. thus the head of the machine never has to leave the scopeof the input.→ this machine is a LBA.Proof for “⇐” much more involved.

INF2080 Lecture :: 15th February 13 / 20

Page 34: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Myhill-Landweber-Kuroda Theorem

Theorem (Myhill-Landweber-Kuroda Theorem)

A language is context-sensitive iff there exists a linear bounded automaton that recognizes it.

Proof sketch for “⇒”: Construct an automaton with a tape containing the input,nondeterministically guesses a rule in the languages grammar and applies the rule“backwards”, i.e., replaces the input’s symbols occuring on the righthand side (RHS) of therule with the lefthand side (LHS) of the rule.

Example: Let aabbcc be the input and let the grammar contain the rule bB → bb. Thenapplying this rule “backwards” on aabbcc yields the string aabBcc .If the input can thus be rewritten to the start variable S , the machine accepts. Since thegrammar is noncontracting, i.e. |LHS|≤|RHS|, the string cannot get longer throughbackwards application of rules. thus the head of the machine never has to leave the scopeof the input.→ this machine is a LBA.Proof for “⇐” much more involved.

INF2080 Lecture :: 15th February 13 / 20

Page 35: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Myhill-Landweber-Kuroda Theorem

Theorem (Myhill-Landweber-Kuroda Theorem)

A language is context-sensitive iff there exists a linear bounded automaton that recognizes it.

Proof sketch for “⇒”: Construct an automaton with a tape containing the input,nondeterministically guesses a rule in the languages grammar and applies the rule“backwards”, i.e., replaces the input’s symbols occuring on the righthand side (RHS) of therule with the lefthand side (LHS) of the rule.Example: Let aabbcc be the input and let the grammar contain the rule bB → bb. Thenapplying this rule “backwards” on aabbcc yields the string aabBcc .

If the input can thus be rewritten to the start variable S , the machine accepts. Since thegrammar is noncontracting, i.e. |LHS|≤|RHS|, the string cannot get longer throughbackwards application of rules. thus the head of the machine never has to leave the scopeof the input.→ this machine is a LBA.Proof for “⇐” much more involved.

INF2080 Lecture :: 15th February 13 / 20

Page 36: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Myhill-Landweber-Kuroda Theorem

Theorem (Myhill-Landweber-Kuroda Theorem)

A language is context-sensitive iff there exists a linear bounded automaton that recognizes it.

Proof sketch for “⇒”: Construct an automaton with a tape containing the input,nondeterministically guesses a rule in the languages grammar and applies the rule“backwards”, i.e., replaces the input’s symbols occuring on the righthand side (RHS) of therule with the lefthand side (LHS) of the rule.Example: Let aabbcc be the input and let the grammar contain the rule bB → bb. Thenapplying this rule “backwards” on aabbcc yields the string aabBcc .If the input can thus be rewritten to the start variable S , the machine accepts.

Since thegrammar is noncontracting, i.e. |LHS|≤|RHS|, the string cannot get longer throughbackwards application of rules. thus the head of the machine never has to leave the scopeof the input.→ this machine is a LBA.Proof for “⇐” much more involved.

INF2080 Lecture :: 15th February 13 / 20

Page 37: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Myhill-Landweber-Kuroda Theorem

Theorem (Myhill-Landweber-Kuroda Theorem)

A language is context-sensitive iff there exists a linear bounded automaton that recognizes it.

Proof sketch for “⇒”: Construct an automaton with a tape containing the input,nondeterministically guesses a rule in the languages grammar and applies the rule“backwards”, i.e., replaces the input’s symbols occuring on the righthand side (RHS) of therule with the lefthand side (LHS) of the rule.Example: Let aabbcc be the input and let the grammar contain the rule bB → bb. Thenapplying this rule “backwards” on aabbcc yields the string aabBcc .If the input can thus be rewritten to the start variable S , the machine accepts. Since thegrammar is noncontracting, i.e. |LHS|≤|RHS|, the string cannot get longer throughbackwards application of rules. thus the head of the machine never has to leave the scopeof the input.

→ this machine is a LBA.Proof for “⇐” much more involved.

INF2080 Lecture :: 15th February 13 / 20

Page 38: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Myhill-Landweber-Kuroda Theorem

Theorem (Myhill-Landweber-Kuroda Theorem)

A language is context-sensitive iff there exists a linear bounded automaton that recognizes it.

Proof sketch for “⇒”: Construct an automaton with a tape containing the input,nondeterministically guesses a rule in the languages grammar and applies the rule“backwards”, i.e., replaces the input’s symbols occuring on the righthand side (RHS) of therule with the lefthand side (LHS) of the rule.Example: Let aabbcc be the input and let the grammar contain the rule bB → bb. Thenapplying this rule “backwards” on aabbcc yields the string aabBcc .If the input can thus be rewritten to the start variable S , the machine accepts. Since thegrammar is noncontracting, i.e. |LHS|≤|RHS|, the string cannot get longer throughbackwards application of rules. thus the head of the machine never has to leave the scopeof the input.→ this machine is a LBA.

Proof for “⇐” much more involved.

INF2080 Lecture :: 15th February 13 / 20

Page 39: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Myhill-Landweber-Kuroda Theorem

Theorem (Myhill-Landweber-Kuroda Theorem)

A language is context-sensitive iff there exists a linear bounded automaton that recognizes it.

Proof sketch for “⇒”: Construct an automaton with a tape containing the input,nondeterministically guesses a rule in the languages grammar and applies the rule“backwards”, i.e., replaces the input’s symbols occuring on the righthand side (RHS) of therule with the lefthand side (LHS) of the rule.Example: Let aabbcc be the input and let the grammar contain the rule bB → bb. Thenapplying this rule “backwards” on aabbcc yields the string aabBcc .If the input can thus be rewritten to the start variable S , the machine accepts. Since thegrammar is noncontracting, i.e. |LHS|≤|RHS|, the string cannot get longer throughbackwards application of rules. thus the head of the machine never has to leave the scopeof the input.→ this machine is a LBA.Proof for “⇐” much more involved.

INF2080 Lecture :: 15th February 13 / 20

Page 40: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Closure properties of CSLs

Union L1 ∪ L2

: add new start variable S and rule S → S1|S2.Concatanation L1L2: add new start variable S and rule S → S1S2.Kleene star L∗1: add new start variable S and rules S → ε|S1S1

Reversal LR1 = {wR | w ∈ L1}: create grammar that contains a rule γRBαR → γRβRαR

for each rule αBγ → αβγ in the grammar of L1.Intersection L1 ∩ L2: Use multitape LBAs (equivalent to LBA, without proof). Simulatethe computation for each language on a separate tape; if both accept, the automatonaccepts.Recall that context-free languages are not closed under intersection and complementation!

INF2080 Lecture :: 15th February 14 / 20

Page 41: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Closure properties of CSLs

Union L1 ∪ L2: add new start variable S and rule S → S1|S2.Concatanation L1L2

: add new start variable S and rule S → S1S2.Kleene star L∗1: add new start variable S and rules S → ε|S1S1

Reversal LR1 = {wR | w ∈ L1}: create grammar that contains a rule γRBαR → γRβRαR

for each rule αBγ → αβγ in the grammar of L1.Intersection L1 ∩ L2: Use multitape LBAs (equivalent to LBA, without proof). Simulatethe computation for each language on a separate tape; if both accept, the automatonaccepts.Recall that context-free languages are not closed under intersection and complementation!

INF2080 Lecture :: 15th February 14 / 20

Page 42: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Closure properties of CSLs

Union L1 ∪ L2: add new start variable S and rule S → S1|S2.Concatanation L1L2: add new start variable S and rule S → S1S2.Kleene star L∗1

: add new start variable S and rules S → ε|S1S1

Reversal LR1 = {wR | w ∈ L1}: create grammar that contains a rule γRBαR → γRβRαR

for each rule αBγ → αβγ in the grammar of L1.Intersection L1 ∩ L2: Use multitape LBAs (equivalent to LBA, without proof). Simulatethe computation for each language on a separate tape; if both accept, the automatonaccepts.Recall that context-free languages are not closed under intersection and complementation!

INF2080 Lecture :: 15th February 14 / 20

Page 43: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Closure properties of CSLs

Union L1 ∪ L2: add new start variable S and rule S → S1|S2.Concatanation L1L2: add new start variable S and rule S → S1S2.Kleene star L∗1: add new start variable S and rules S → ε|S1S1

Reversal LR1 = {wR | w ∈ L1}

: create grammar that contains a rule γRBαR → γRβRαR

for each rule αBγ → αβγ in the grammar of L1.Intersection L1 ∩ L2: Use multitape LBAs (equivalent to LBA, without proof). Simulatethe computation for each language on a separate tape; if both accept, the automatonaccepts.Recall that context-free languages are not closed under intersection and complementation!

INF2080 Lecture :: 15th February 14 / 20

Page 44: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Closure properties of CSLs

Union L1 ∪ L2: add new start variable S and rule S → S1|S2.Concatanation L1L2: add new start variable S and rule S → S1S2.Kleene star L∗1: add new start variable S and rules S → ε|S1S1

Reversal LR1 = {wR | w ∈ L1}: create grammar that contains a rule γRBαR → γRβRαR

for each rule αBγ → αβγ in the grammar of L1.Intersection L1 ∩ L2

: Use multitape LBAs (equivalent to LBA, without proof). Simulatethe computation for each language on a separate tape; if both accept, the automatonaccepts.Recall that context-free languages are not closed under intersection and complementation!

INF2080 Lecture :: 15th February 14 / 20

Page 45: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Closure properties of CSLs

Union L1 ∪ L2: add new start variable S and rule S → S1|S2.Concatanation L1L2: add new start variable S and rule S → S1S2.Kleene star L∗1: add new start variable S and rules S → ε|S1S1

Reversal LR1 = {wR | w ∈ L1}: create grammar that contains a rule γRBαR → γRβRαR

for each rule αBγ → αβγ in the grammar of L1.Intersection L1 ∩ L2: Use multitape LBAs (equivalent to LBA, without proof). Simulatethe computation for each language on a separate tape; if both accept, the automatonaccepts.Recall that context-free languages are not closed under intersection and complementation!

INF2080 Lecture :: 15th February 14 / 20

Page 46: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

LBA Problems

But what about the complement of a context-sensitive language?

Kuroda phrased two openproblems related to LBAs in the 60’s.

First LBA Problem: Are nondeterministic LBA’s equivalent to deterministic LBA’s?equivalent complexity theoretic question: is NSPACE(O(n)) = DSPACE(O(n))?Second LBA Problem: Is the class of languages accepted by LBA’s closed undercomplementation?equivalent complexity theoretic question: is NSPACE(O(n)) = co-NSPACE(O(n))?

The first problem is still an open question, while the second was answered in 1988 byImmerman and Szelepscényi.

INF2080 Lecture :: 15th February 15 / 20

Page 47: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

LBA Problems

But what about the complement of a context-sensitive language? Kuroda phrased two openproblems related to LBAs in the 60’s.

First LBA Problem: Are nondeterministic LBA’s equivalent to deterministic LBA’s?equivalent complexity theoretic question: is NSPACE(O(n)) = DSPACE(O(n))?Second LBA Problem: Is the class of languages accepted by LBA’s closed undercomplementation?equivalent complexity theoretic question: is NSPACE(O(n)) = co-NSPACE(O(n))?

The first problem is still an open question, while the second was answered in 1988 byImmerman and Szelepscényi.

INF2080 Lecture :: 15th February 15 / 20

Page 48: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

LBA Problems

But what about the complement of a context-sensitive language? Kuroda phrased two openproblems related to LBAs in the 60’s.

First LBA Problem: Are nondeterministic LBA’s equivalent to deterministic LBA’s?equivalent complexity theoretic question: is NSPACE(O(n)) = DSPACE(O(n))?

Second LBA Problem: Is the class of languages accepted by LBA’s closed undercomplementation?equivalent complexity theoretic question: is NSPACE(O(n)) = co-NSPACE(O(n))?

The first problem is still an open question, while the second was answered in 1988 byImmerman and Szelepscényi.

INF2080 Lecture :: 15th February 15 / 20

Page 49: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

LBA Problems

But what about the complement of a context-sensitive language? Kuroda phrased two openproblems related to LBAs in the 60’s.

First LBA Problem: Are nondeterministic LBA’s equivalent to deterministic LBA’s?equivalent complexity theoretic question: is NSPACE(O(n)) = DSPACE(O(n))?Second LBA Problem: Is the class of languages accepted by LBA’s closed undercomplementation?equivalent complexity theoretic question: is NSPACE(O(n)) = co-NSPACE(O(n))?

The first problem is still an open question, while the second was answered in 1988 byImmerman and Szelepscényi.

INF2080 Lecture :: 15th February 15 / 20

Page 50: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

LBA Problems

But what about the complement of a context-sensitive language? Kuroda phrased two openproblems related to LBAs in the 60’s.

First LBA Problem: Are nondeterministic LBA’s equivalent to deterministic LBA’s?equivalent complexity theoretic question: is NSPACE(O(n)) = DSPACE(O(n))?Second LBA Problem: Is the class of languages accepted by LBA’s closed undercomplementation?equivalent complexity theoretic question: is NSPACE(O(n)) = co-NSPACE(O(n))?

The first problem is still an open question, while the second was answered in 1988 byImmerman and Szelepscényi.

INF2080 Lecture :: 15th February 15 / 20

Page 51: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Complement of CSLs

Theorem (Immerman-Szelepcsényi Theorem)

NSPACE(O(n)) = co-NSPACE(O(n)).

And hence

TheoremThe class of context-sensitive languages is closed under complementation.

INF2080 Lecture :: 15th February 16 / 20

Page 52: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Decidability spoilers for the next weeks

We will soon have a look at some decidability results of the various classes of languages wehave seen:

x ∈ L L = ∅ L = Σ∗ L = K L ∩ K = ∅regular X X X X X(DCFL X X X X X)CFL X X X X XCSL X X X X Xdecidable X X X X XTuring-rec. X X X X X

INF2080 Lecture :: 15th February 17 / 20

Page 53: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Chomsky Hierarchy

Type-0: recursively enumerable, i.e., Turing-recognizable languages.Type-1: context-sensitive languages.Type-2: context-free languages.Type-3: regular languages.

So we’ve seen/will see:{Regular Languages} ( {CFLs}( {CSLs} ( {Turing-rec. Languages} and{Regular Languages} ( {CFLs}( {Decidable Languages} ( {Turing-rec. Languages}.But what is the relationship between {CSLs} and {Decidable Languages}?

INF2080 Lecture :: 15th February 18 / 20

Page 54: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Chomsky Hierarchy

Type-0: recursively enumerable, i.e., Turing-recognizable languages.Type-1: context-sensitive languages.Type-2: context-free languages.Type-3: regular languages.

So we’ve seen/will see:{Regular Languages} ( {CFLs}( {CSLs} ( {Turing-rec. Languages} and{Regular Languages} ( {CFLs}( {Decidable Languages} ( {Turing-rec. Languages}.

But what is the relationship between {CSLs} and {Decidable Languages}?

INF2080 Lecture :: 15th February 18 / 20

Page 55: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Chomsky Hierarchy

Type-0: recursively enumerable, i.e., Turing-recognizable languages.Type-1: context-sensitive languages.Type-2: context-free languages.Type-3: regular languages.

So we’ve seen/will see:{Regular Languages} ( {CFLs}( {CSLs} ( {Turing-rec. Languages} and{Regular Languages} ( {CFLs}( {Decidable Languages} ( {Turing-rec. Languages}.But what is the relationship between {CSLs} and {Decidable Languages}?

INF2080 Lecture :: 15th February 18 / 20

Page 56: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Decidable vs. Context-sensitive

Without proof:

TheoremThe class of context-sensitive languages is decidable.

Hence, {CSLs} ⊆ {Decidable Languages}. However, there exists a decidable language that isnot context-sensitive!Let L = {w | w is a string representation of a CSG G and w 6∈ L(G )}. First of all:

TheoremL is decidable.

Proof idea: Given an input w , check if it represents a CSG. Then use the decider from theprevious theorem to check whether w 6∈ L(G ).

INF2080 Lecture :: 15th February 19 / 20

Page 57: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Decidable vs. Context-sensitive

Without proof:

TheoremThe class of context-sensitive languages is decidable.

Hence, {CSLs} ⊆ {Decidable Languages}.

However, there exists a decidable language that isnot context-sensitive!Let L = {w | w is a string representation of a CSG G and w 6∈ L(G )}. First of all:

TheoremL is decidable.

Proof idea: Given an input w , check if it represents a CSG. Then use the decider from theprevious theorem to check whether w 6∈ L(G ).

INF2080 Lecture :: 15th February 19 / 20

Page 58: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Decidable vs. Context-sensitive

Without proof:

TheoremThe class of context-sensitive languages is decidable.

Hence, {CSLs} ⊆ {Decidable Languages}. However, there exists a decidable language that isnot context-sensitive!

Let L = {w | w is a string representation of a CSG G and w 6∈ L(G )}. First of all:

TheoremL is decidable.

Proof idea: Given an input w , check if it represents a CSG. Then use the decider from theprevious theorem to check whether w 6∈ L(G ).

INF2080 Lecture :: 15th February 19 / 20

Page 59: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Decidable vs. Context-sensitive

Without proof:

TheoremThe class of context-sensitive languages is decidable.

Hence, {CSLs} ⊆ {Decidable Languages}. However, there exists a decidable language that isnot context-sensitive!Let L = {w | w is a string representation of a CSG G and w 6∈ L(G )}.

First of all:

TheoremL is decidable.

Proof idea: Given an input w , check if it represents a CSG. Then use the decider from theprevious theorem to check whether w 6∈ L(G ).

INF2080 Lecture :: 15th February 19 / 20

Page 60: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Decidable vs. Context-sensitive

Without proof:

TheoremThe class of context-sensitive languages is decidable.

Hence, {CSLs} ⊆ {Decidable Languages}. However, there exists a decidable language that isnot context-sensitive!Let L = {w | w is a string representation of a CSG G and w 6∈ L(G )}. First of all:

TheoremL is decidable.

Proof idea: Given an input w , check if it represents a CSG. Then use the decider from theprevious theorem to check whether w 6∈ L(G ).

INF2080 Lecture :: 15th February 19 / 20

Page 61: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

Decidable vs. Context-sensitive

Without proof:

TheoremThe class of context-sensitive languages is decidable.

Hence, {CSLs} ⊆ {Decidable Languages}. However, there exists a decidable language that isnot context-sensitive!Let L = {w | w is a string representation of a CSG G and w 6∈ L(G )}. First of all:

TheoremL is decidable.

Proof idea: Given an input w , check if it represents a CSG. Then use the decider from theprevious theorem to check whether w 6∈ L(G ).

INF2080 Lecture :: 15th February 19 / 20

Page 62: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

A decidable, non-context-sensitive language

Let L = {w | w is a string representation of a CSG G and w 6∈ L(G )}.

TheoremL is not context-sensitive.

Proof idea: Assume L is context-sensitive. Then let w be a string representation of its CSGG .

Question: Is w ∈ L(G ) = L?

Assume w ∈ L. Then by definition of L, w is not contained in L(G ) = L, i.e., w 6∈ L.Contradiction!Assume w 6∈ L. Then w represents a CSG and is not a member of of the language itrepresents. Hence, w ∈ L(G ) = L. Contradiction!

⇒ {CSLs} ( {Decidable Languages}!

INF2080 Lecture :: 15th February 20 / 20

Page 63: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

A decidable, non-context-sensitive language

Let L = {w | w is a string representation of a CSG G and w 6∈ L(G )}.

TheoremL is not context-sensitive.

Proof idea: Assume L is context-sensitive. Then let w be a string representation of its CSGG . Question: Is w ∈ L(G ) = L?

Assume w ∈ L. Then by definition of L, w is not contained in L(G ) = L, i.e., w 6∈ L.Contradiction!Assume w 6∈ L. Then w represents a CSG and is not a member of of the language itrepresents. Hence, w ∈ L(G ) = L. Contradiction!

⇒ {CSLs} ( {Decidable Languages}!

INF2080 Lecture :: 15th February 20 / 20

Page 64: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

A decidable, non-context-sensitive language

Let L = {w | w is a string representation of a CSG G and w 6∈ L(G )}.

TheoremL is not context-sensitive.

Proof idea: Assume L is context-sensitive. Then let w be a string representation of its CSGG . Question: Is w ∈ L(G ) = L?

Assume w ∈ L. Then by definition of L, w is not contained in L(G ) = L, i.e., w 6∈ L.Contradiction!

Assume w 6∈ L. Then w represents a CSG and is not a member of of the language itrepresents. Hence, w ∈ L(G ) = L. Contradiction!

⇒ {CSLs} ( {Decidable Languages}!

INF2080 Lecture :: 15th February 20 / 20

Page 65: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

A decidable, non-context-sensitive language

Let L = {w | w is a string representation of a CSG G and w 6∈ L(G )}.

TheoremL is not context-sensitive.

Proof idea: Assume L is context-sensitive. Then let w be a string representation of its CSGG . Question: Is w ∈ L(G ) = L?

Assume w ∈ L. Then by definition of L, w is not contained in L(G ) = L, i.e., w 6∈ L.Contradiction!Assume w 6∈ L. Then w represents a CSG and is not a member of of the language itrepresents. Hence, w ∈ L(G ) = L. Contradiction!

⇒ {CSLs} ( {Decidable Languages}!

INF2080 Lecture :: 15th February 20 / 20

Page 66: INF2080 - uio.no€¦ · INF2080 Context-SensitiveLangugaes DanielLupp Universitetet i Oslo 15thFebruary2017 Department of ... Examples: cC !abABc ab !de cB !Bc Note: noneoftheserulesarecontext-sensitive!

A decidable, non-context-sensitive language

Let L = {w | w is a string representation of a CSG G and w 6∈ L(G )}.

TheoremL is not context-sensitive.

Proof idea: Assume L is context-sensitive. Then let w be a string representation of its CSGG . Question: Is w ∈ L(G ) = L?

Assume w ∈ L. Then by definition of L, w is not contained in L(G ) = L, i.e., w 6∈ L.Contradiction!Assume w 6∈ L. Then w represents a CSG and is not a member of of the language itrepresents. Hence, w ∈ L(G ) = L. Contradiction!

⇒ {CSLs} ( {Decidable Languages}!

INF2080 Lecture :: 15th February 20 / 20