1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic: ...

12
1 Strings and Languages

Transcript of 1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic: ...

Page 1: 1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic:      Proof techniques: – Construction, Contradiction,

1

Strings and Languages

Page 2: 1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic:      Proof techniques: – Construction, Contradiction,

2

Review

Sets and sequences Functions and relations Graphs Boolean logic: Proof techniques:

– Construction, Contradiction, Pigeon Hole Principle, Induction

Page 3: 1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic:      Proof techniques: – Construction, Contradiction,

3

Deductive Proof (1/2)

Thm: Every horse has infinite no. of legs.Proof: Horses have an even number of

legs. Behind they have two legs, and in front they have fore legs. This makes six legs, which is certainly an odd number of legs for a horse. But the only number that is both odd and even is infinity. Therefore, horses have an infinite number of legs.

Page 4: 1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic:      Proof techniques: – Construction, Contradiction,

4

Deductive Proof (2/2)

Thm : All numbers are equal to zero.Proof: Suppose that a=b. Then a = b a^2 = ab a^2 - b^2 = ab - b^2(a + b)(a - b) = b(a - b) a + b = b a = 0

Page 5: 1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic:      Proof techniques: – Construction, Contradiction,

5

Problems and Languages

Problem: defined using input and output

Decision Problem: output is either yes or no

Language: set of all inputs where output is yes

Page 6: 1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic:      Proof techniques: – Construction, Contradiction,

6

Alphabets

An alphabet is a finite non-empty set. An alphabet is generally denoted by the

symbol Σ.

Page 7: 1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic:      Proof techniques: – Construction, Contradiction,

7

Strings (or words)

Defined over an alphabet Σ Is a finite sequence of symbols from Σ Length of string w (|w|) – length of

sequence λ – the empty string Concatenation of w1 and w2 – copy of

w1 followed by copy of w2

Reversal wR – w’s symbols reversed

Page 8: 1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic:      Proof techniques: – Construction, Contradiction,

8

Languages

A language over Σ is a set of strings over Σ

Σ* is the set of all strings over Σ A language L over Σ is a subset of Σ* (L

Σ*)

Page 9: 1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic:      Proof techniques: – Construction, Contradiction,

9

Operations on Languages

Star (L*) Concatenation (L1.L2)

Union (L1 L2)

Intersection (L1 L2) Complement Reversal LR

Page 10: 1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic:      Proof techniques: – Construction, Contradiction,

10

Questions (1/3)

What is the language for the following decision problem? Decision Problem:

– Input: String w– Output: Yes, if |w| is even

What is the decision problem for the language L = {u0v | u,v {0,1}* } ?

What alphabet is the language L defined over? Describe the language LR.

Page 11: 1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic:      Proof techniques: – Construction, Contradiction,

11

Questions (2/3)

What is the size of the empty set? What is the size of the set containing

just the empty string? Let L2 = {λ, 00,0000} be defined over

the alphabet ∑ = {0}. Describe the strings in the set L2*.

Describe the complement of L2.

Page 12: 1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic:      Proof techniques: – Construction, Contradiction,

12

Questions (3/3)

Let L3 = {awb | w {a,b}*}. Define the language L3

R

How would you prove that L3 = {a}.{a,b}*.{b}?

How would you prove that L3 ≠ L3R