slide1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
ภาษา LANGUAGE PowerPoint Presentation
Download Presentation
ภาษา LANGUAGE

Loading in 2 Seconds...

play fullscreen
1 / 51

ภาษา LANGUAGE - PowerPoint PPT Presentation


  • 159 Views
  • Uploaded on

1. ภาษา LANGUAGE. LANGUAGE. ภาษาอังกฤษ. หน่วยของภาษา อักขระ letters คำ words ประโยค sentences ย่อหน้า paragraphs เรื่องราว coherent stories. COLLECTION & SEQUENTIAL. How do they do that ?. LANGUAGE. ภาษาคอมพิวเตอร์. หน่วยของภาษาคอมพิวเตอร์ อักขระ letters คำสำคัญ key words

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'ภาษา LANGUAGE' - badrani


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide1

1

ภาษา

LANGUAGE

slide2

LANGUAGE

ภาษาอังกฤษ

หน่วยของภาษา

  • อักขระ letters
  • คำ words
  • ประโยค sentences
  • ย่อหน้า paragraphs
  • เรื่องราว coherent stories

COLLECTION

&

SEQUENTIAL

How do they do that ?

slide3

LANGUAGE

ภาษาคอมพิวเตอร์

หน่วยของภาษาคอมพิวเตอร์

  • อักขระ letters
  • คำสำคัญ keywords
  • คำสั่ง commands
  • โปรแกรมprograms
  • ระบบ systems

Commands can be recognized by certain sequences of words.

Language structure is based on explicitly rules.

It is very hard to state all the rules for the language “spoken English”.

slide4

ภาษา

LANGUAGE

Definition

Language means simply a set of strings involving symbols from alphabet.

LANGUAGE

slide5

LANGUAGE

ทฤษฎีภาษารูปนัย

THEORY OF FORMAL LANGUAGES

Formal refers

  • explicitly rules
    • What sequences of symbols can occur ?
    • No liberties are tolerated.
    • No reference to any “deeper understanding” is required.
  • the form of the sequences of symbols
  • not the meaning
slide6

LANGUAGE

นิยามและสัญลักษณ์

  • One finite set of fundamental units , called “alphabet”, denoted .
  • An element of alphabet is called “character”.
  • A certain specified set of strings of characters will be called “language” denoted L.
  • Those strings that are permissible in the language we call “words”.
  • The string without letter is called “empty string” or “null string”, denoted by .
  • The language that has no word is denoted by .

specified

slide7

LANGUAGE

SYMBOLS

Union operation +

Different operation 

Alphabet 

Empty string 

Language L

Empty language 

slide8

LANGUAGE

ภาษา

การนิยามหรือการบรรยายภาษา

Given an alphabet  = { a b c … z ‘ - }.

We can now specify a language L as

{ all words in a standard dictionary },

named “ENGLISH-WORDS”.

IMPLICITLY

DEFINING

slide9

LANGUAGE

ภาษา

การนิยามหรือการบรรยายภาษา

The trick of defining the language L,

By listing all rules of grammar.

This allows us to give a finite description of an infinite language.

Consider this sentence “I eat three Sundays”.

This is grammatically correct.

INFINITE LANGUAGE DEFINING

RIDICULOUS

LANGUAGE

slide10

LANGUAGE

ภาษา

การนิยามหรือการบรรยายภาษา

Let  = {x} be an alphabet.

Language L can be defined by

L = { x xx xxx xxxx … }

L = { xn for n = 1 2 3 … }.

Language L2 = { x xxx xxxxx xxxxxxx …}

L2 = { xodd }

L2 = { x2n-1 for n = 1 2 3 … }.

Method of exhaustion

slide11

LANGUAGE

ภาษา

นิยาม

We define the function length of a string to be the number of letters in the string.

For example, if a word a = xxxx in L, then length(a)=4.

In any language that includes , we have length()=0.

The function reverse is defined by if a is a word in L, then reverse(a) is the same string of letters spelled backward, called the reverse of a.

For example, reverse(123)=321.

Remark: The reverse(a) is not necessary in the language of a.

slide12

LANGUAGE

ภาษา

นิยาม

We define the function na(w)of a w to be the number of letter a in the string w.

For example, if a word w = aabbac in L,

then na(w)=3.

Concatenation of two strings means that two strings are written down side by side.

For example, xn concatenated with xm is xn+m

slide13

LANGUAGE

ภาษา

นิยาม

Language is called PALINDROME over the alphabet if

Language = {  and all strings x such that reserve(x)=x }.

For example, let ={ a, b }, and

PALINDROME={  a b aa bb aaa aba bab bbb …}.

Remark: Sometimes, we obtain another word in PALINDROME when we concatenate two words in PALINDROME. We shall see the interesting properties of this language later.

slide14

LANGUAGE

ภาษา

นิยาม

Consider the language

PALINDROME={  a b aa bb aaa aba bab bbb …}.

We usually put words in size order and then listed all the words of the same length alphabetically. This order is called lexicographic order.

slide15

LANGUAGE

ภาษา

นิยาม

KLEENE CLOSURE

Given an alphabet , the language that any string of characters in  are in this language is called the closure of the alphabet. It is denoted by

*.

This notation is sometimes known as the Kleene star.

Kleene star can be considered as an operation that makes an infinite language. When we say “infinite language”, we mean infinitely many words, each of finite length.

slide16

LANGUAGE

ภาษา

นิยาม

KLEENE CLOSURE

More general,

if S is a set of words, then by S* we mean the set of all finite strings formed by concatenating words from S and from S*.

Example:

If S = { a ab }then

S* = {  and any word composed of factors of a and ab }.

{  and all strings of a and b except strings with double b }.

{  a aa ab aaa aab aba aaaa aaab aaba … }.

slide17

LANGUAGE

ภาษา

นิยาม

KLEENE CLOSURE

Example:

If S = { a ab }then

S* = {  and any word composed of factors of a and ab }.

{  and all strings of a and b except strings with double b }.

{  a aa ab aaa aab aba aaaa aaab aaba … }.

To prove that a certain word is in the closure language S* , we must show how it can be written as a concatenation of words from the base set S.

Example: abaaba can be factored as (ab)(a)(ab)(a) and

it is unique.

slide18

LANGUAGE

ภาษา

นิยาม

KLEENE CLOSURE

Example:

If S = { xx xxxxx }then

S* = {  xx xxxx xxxxx xxxxxx xxxxxxx xxxxxxxx … }.

{  and xx and xn for n = 4 5 6 7 … }.

How can we prove this statement ?

Hence: proof by constructive algorithm

(showing how to create it).

slide19

LANGUAGE

ภาษา

นิยาม

KLEENE CLOSURE

Example:

If S = { a b ab } and T = { a b ba }, then S* = T* = { a b }*.

Proof: It is clear that { a b }* S* and { a b }*T*.

We have to show that S* and T*  { a b }*.

For x  S*, in the case that x is composed of ab.

Replace ab in x by a, b which are in { a b }*.

Then S* { a b }*.

The proof of T* { a b }* is similarity. QED

slide20

LANGUAGE

ภาษา

นิยาม

POSITIVE CLOSURE

Given an alphabet , the language that any string (not zero) of characters in  are in this language is called the positive closure of the alphabet. It is denoted by

+.

Example: Let ={ ab }.

Then + = { ab abab ababab … }.

slide21

LANGUAGE

ภาษา

นิยาม

TRIVIAL REMARK

Given an alphabet ={ aa bbb }. Then * is the set of all strings where a’s occur in even clumps and b’s in groups of 3, 6, 9…. Some words in * are

bbb aabbbaaaa bbbaa

If we concatenate these three elements of *, we get one big word in **, which is again in *.

bbbaabbbaaaabbbaa = (bbb)(aa)(bbb)(aa)(aa)(bbb)(aa)

Note : ** means (*)*.

slide22

LANGUAGE

ภาษา

นิยาม

THEOREM

Theorem

For any set S of strings, we have S*= S**.

Proof: Every words in S** is made up of factors from S*.

Every words in S* is made up of factors from S.

Therefore every words in S** is made up of factors from S.

We can write this S** S*.

In general, it is true that S  S*. So S* S**.

Then S*= S**. QED

slide23
โจทย์น่าคิด

ให้ Lเป็นภาษาที่นิยามบน ={0,1} จงอธิบาย ความสัมพันธ์ของ

  • L*+
  • L+*

?

slide24

2

RECURSIVELY DEFINING LANGUAGE

การบรรยายภาษาแบบวนซ้ำ

slide25

RECURSIVELY DEFINING LANGUAGE

การบรรยายแบบวนซ้ำ

นิยายของภาษา

EVEN language

EVEN is the set of all positive whole numbers divisible by 2.

EVEN is the set of all 2n where n = 1 2 3 4 …

Another way we might try this:

The set is defined by these three rules:

Rule1: 2 is in EVEN.

Rule2: if x is in EVEN, then so is x+2.

Rule3: The only elements in the set EVEN are those that

can be produced from the two rules above.

The last rule above is completely redundant.

slide26

RECURSIVELY DEFINING LANGUAGE

การบรรยายแบบวนซ้ำ

นิยายของภาษา

EVEN language

The set is defined by these three rules:

Rule1: 2 is in EVEN.

Rule2: if x is in EVEN, then so is x+2.

Rule3: The only elements in the set EVEN are those that

can be produced from the two rules above.

PROBLEM: Show that 10 is in this language.

By Rule1, 2 is in EVEN.

By Rule2, 2+2=4 is in EVEN.

By Rule2, 4+2=6 is in EVEN.

By Rule2, 6+2=8 is in EVEN.

By Rule2, 8+2=10 is in EVEN.

PRETTY HORRIBLE !

1000000

slide27

RECURSIVELY DEFINING LANGUAGE

การบรรยายแบบวนซ้ำ

นิยายของภาษา

EVEN language

The set is defined by these three rules:

Rule1: 2 is in EVEN.

Rule2: if x,y are in EVEN, then so is x+y.

Rule3: The only elements in the set EVEN are those that

can be produced from the two rules above.

PROBLEM: Show that 10 is in this language.

By Rule1, 2 is in EVEN.

By Rule2, 2+2=4 is in EVEN.

By Rule2, 4+4=8 is in EVEN.

By Rule2, 8+2=10 is in EVEN.

DECIDEDLY HARD

slide28

RECURSIVELY DEFINING LANGUAGE

การบรรยายแบบวนซ้ำ

นิยายของภาษา

POSITIVE language

The set is defined by these three rules:

Rule1: 1 is in POSITIVE.

Rule2: if x,y are in POSITIVE, then so is x+y, x-y, xy and x/y where y is not zero.

Rule3: The only elements in the set POSITIVE are those that

can be produced from the two rules above.

PROBLEM: What is POSITIVE language ?

slide29

RECURSIVELY DEFINING LANGUAGE

การบรรยายแบบวนซ้ำ

นิยายของภาษา

POLYNOMIAL language

The set is defined by these four rules:

Rule1: Any number is in POLYNOMIAL

Rule2: Any variable x is in POLYNOMIAL.

Rule3: if x,y are in POLYNOMIAL,

then so is x+y, x-y, xy and (x).

Rule4: The only elements in the set POLYNOMIAL are those that

can be produced from the three rules above.

PROBLEM: Show that 3x2+2x-5 is in POLYNOMIAL.

Proof:

Rule1: 2, 3, 5 are in POLYNOMIAL, Rule2: x is in POLYNOMIAL,

Rule3: 3x, 2x are in POLYNOMIAL, Rule3: 3xx is in POLYNOMIAL,

Rule3: 3xxx+2x, 3x2+2x-5 are in POLYNOMIAL. QED.

slide30

RECURSIVELY DEFINING LANGUAGE

การบรรยายแบบวนซ้ำ

นิยายของภาษา

ARITHMETIC EXPRESSIONS

Language:

Let  be an alphabet for AE language.

 = { 0 1 2 3 4 5 6 7 8 9 + - * / ( ) }.

Define rules for this language.

Problems:

  • Show that the language does not contain substring //.
  • Show that ((3+4)-(2*6))/5 is in this language.
slide31

RECURSIVELY DEFINING LANGUAGE

ข้อสังเกต

การบรรยายภาษา

Languages can be defined by

  • L1={ xn for n = 1 2 3 … }
  • L2={ xn for n = 1 3 5 7 … }
  • L3={ xn for n = 1 4 9 16 … }
  • L4={ xn for n = 3 4 8 22 … }.

More precision and less guesswork are required.

slide32

3

REGULAR EXPRESSION

การบรรยายแบบสม่ำเสมอ

slide33

REGULAR EXPRESSION

การบรรยายภาษาแบบสม่ำเสมอการบรรยายภาษาแบบสม่ำเสมอ

Kleene star

Definition:

The simple expression x* will be used to indicate some sequence of x’s (may be none at all).

We also define x0 = .

The star is as an unknown power or undetermined power. This notation can be used to help us define languages by writing

L = language(x*)

where L = {  and xn for n = 1 2 3 … }.

slide34

REGULAR EXPRESSION

การบรรยายภาษาแบบสม่ำเสมอการบรรยายภาษาแบบสม่ำเสมอ

ตัวอย่าง

L1 = language(ab*)

L1 = { a ab abb abbb abbbb abbbbb abbbbbb … }

L2 = language(a*ba*)

L2 = { b ab ba aab aba baa aaab aaba abaa baaa … }

L3 = language(a*b*)

L3 = {  a b aa ab bb aaa aab abb bbb aaaa aaab aabb … }

L4 = language((ab)*)

L4 = {  ab abab ababab abababab ababababab … }

L5 = language(xx*)

L5 = { x xx xxx xxxx xxxxx xxxxxx … } = language(x+)

slide35

REGULAR EXPRESSION

การบรรยายภาษาแบบสม่ำเสมอการบรรยายภาษาแบบสม่ำเสมอ

การบวก (union)

Definition:

The plus expression x + y where x and y are string of characters from an alphabet, we mean “either x or y, but not both”.

Example:

L = language((a+b)c*)

L = { a b ac bc acc bcc accc bccc … }.

slide36

REGULAR EXPRESSION

การบรรยายภาษาแบบสม่ำเสมอการบรรยายภาษาแบบสม่ำเสมอ

Exercise:

L = language(a*+(a+bb)*c*+d)

  • Is  in this language ?
  • Find words with length 1, 2, 3 and 4.
  • Compare L with language(a*c*+(bb)*c*+d).
slide37

REGULAR EXPRESSION

การบรรยายภาษาแบบสม่ำเสมอการบรรยายภาษาแบบสม่ำเสมอ

Finite language

The language L where

L = { aaa aab aba abb baa bab bba bbb }

can be expressed by L = language((a+b)3) or

L = language((a+b)(a+b)(a+b)).

slide38

REGULAR EXPRESSION

การบรรยายภาษาแบบสม่ำเสมอการบรรยายภาษาแบบสม่ำเสมอ

REGULAR EXPRESSIONS

Definition:

The set of regular expressions is defined by the following rules:

Rule1: Every element of alphabet  is a regular

expression.

Rule2:  is a regular expression.

Rule3: For every regular expressions r and s,

then so are:

(r) rs r+s r*

Rule4: Nothing else is not a regular expression.

slide39

REGULAR EXPRESSION

การบรรยายภาษาแบบสม่ำเสมอการบรรยายภาษาแบบสม่ำเสมอ

REGULAR EXPRESSIONS

Example:

Given a regular expression (a+b)*a(a+b)*+b(a+b)*

This regular expression can be written more simple expression, as follow:

(a+b)(a+b)*.

slide40

REGULAR EXPRESSION

การบรรยายภาษาแบบสม่ำเสมอการบรรยายภาษาแบบสม่ำเสมอ

REGULAR EXPRESSIONS

Finite & Positive closure:

Is (a+b)4 a regular expression ?

This can be accepted to be a regular expression, since it equals to (a+b)(a+b)(a+b)(a+b) which is a regular expression.

Is (a+c)+ a regular expression ?

This is also be accepted to be a regular expression since it represents a regular expression (a+c)(a+c)*.

slide41

REGULAR EXPRESSION

การบรรยายภาษาแบบสม่ำเสมอการบรรยายภาษาแบบสม่ำเสมอ

REGULAR EXPRESSIONS

ทำอย่างไร

Define the set A by a regular expression.

A = {  b ab bb

aba abb bbb

abaa abab abbb bbbb

abaaa abaab ababb abbbb bbbbb … }.

The regular expression is(aba*)*b*

slide42

REGULAR EXPRESSION

การบรรยายภาษาแบบสม่ำเสมอการบรรยายภาษาแบบสม่ำเสมอ

REGULAR EXPRESSIONS

แบบฝึกหัด

Given a regular expression

(a+b)*ab(a+b)*+E

where E is unknown expression.

Find E if this expression equals (a+b)*

and E  (a+b)*ab(a+b)* = 

The regular expression E isb*a*.

slide43

REGULAR EXPRESSION

การบรรยายภาษาแบบสม่ำเสมอการบรรยายภาษาแบบสม่ำเสมอ

REGULAR EXPRESSIONS

Definition:

Let S and T be sets of strings of letters. The product set of S and T is the set of all combinations of a string from S concatenated with a string from T in that order.

ST = { uv : u  S and v  T }

Example: S = { a bb aba }

T = { a ab }

then ST = { aa aab bba bbab abaa abaab }.

slide44

REGULAR EXPRESSION

การบรรยายภาษาแบบสม่ำเสมอการบรรยายภาษาแบบสม่ำเสมอ

REGULAR EXPRESSIONS

Example:

P = {  aa b } and Q = {  ba }

Then PQ = {  aa b ba aaba bba }.

slide45

REGULAR EXPRESSION

การบรรยายภาษาแบบสม่ำเสมอการบรรยายภาษาแบบสม่ำเสมอ

REGULAR EXPRESSIONS

Definition:

A language L is called a language associated with regular expression r if

L = language(r).

We also have

L1L2 = language(r1r2)

L1+L2 = language(r1+r2)

L1* = language(r*).

slide46

REGULAR EXPRESSION

การบรรยายภาษาแบบสม่ำเสมอการบรรยายภาษาแบบสม่ำเสมอ

REGULAR EXPRESSIONS

ทฤษฎีบท

If L is a finite language (only finitely many words), then L can be defined by a regular expression. In other words, all finite languages are regular.

slide47

REGULAR EXPRESSION

การบรรยายภาษาแบบสม่ำเสมอการบรรยายภาษาแบบสม่ำเสมอ

REGULAR EXPRESSIONS

What strings contain in the language?

  • Given (a+b)*(aa+bb)(a+b)*+(+b)(ab)*(+a)
  • Consider the regular (a+b)*(aa+bb)(a+b)*, strings that contain a double letter.
  • {  a b ab ba aba bab abab baba ... } is the set of all strings that do not contain a double letter.
  • (+b)(ab)*(+a) defines all strings without a double letter.
  • This language is (a+b)*.
slide48

REGULAR EXPRESSION

การบรรยายภาษาแบบสม่ำเสมอการบรรยายภาษาแบบสม่ำเสมอ

REGULAR EXPRESSIONS

Consider a regular expression

(aa+bb+(ab+ba)(aa+bb)*(ab+ba))*.

This represents the collection of all words that are made up of three type:

type1 aa

type2 bb

type3 (ab+ba)(aa+bb)*(ab+ba)

Every words contain an even number of a and even number of b.

EVEN-EVEN

LANGUAGE

slide49
โจทย์น่าคิด

จงหาภาษา Lที่นิยามบน ={0,1} ที่สอดคล้องกับ

  • L ไม่เป็น {}
  • L ไม่เป็น *

โดยที่ L = L*

?

slide50
โจทย์น่าคิด

กำหนดให้ภาษา L และ S นิยามบน ={0,1} ที่สอดคล้องกับ

  • LS = SL
  • L ไม่เป็น subset ของ S
  • S ไม่เป็น subset ของ L
  • ทั้ง L และ S ไม่เป็น {}

?

slide51
โจทย์น่าคิด

กำหนดให้ภาษา L และ S นิยามบน ={0,1} ที่สอดคล้องกับ

  • LS = SL
  • L เป็น proper nonempty subset ของ S
  • L ไม่เป็น {}

?