# 1 Introduction to Computability Theory  Embed code:

## 1 Introduction to Computability Theory

Download Presentation - The PPT/PDF document "1 Introduction to Computability Theory" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.

### Presentations text content in 1 Introduction to Computability Theory

Slide1

1

Introduction to Computability Theory

Lecture5: Context

Free Languages

Prof. Amos Israeli

Slide2

On the last lecture we completed our study of regular languages. (There is still a lot to learn but our time is limited…).

Introduction and Motivation

2

Slide3

In our study of RL-s we Covered:Motivation and definition of regular languages.DFA-s, NFA-s, RE-s and their equivalence.Non Regular Languages and the Pumping Lemma.

Introduction and Motivation

3

Slide4

In this lecture, we turn to Context Free Grammars and Context Free Languages.The class of Context Free Languages is an intermediate class between the class of regular languages and the class of Decidable Languages (To be defined).

Introduction and Motivation

4

Slide5

A Context Free Grammar is a “machine” that creates a language.A language created by a CF grammar is called A Context Free Language.(We will show that) The class of Context Free Languages Properly Contains the class of Regular Languages.

Introduction and Motivation

5

Slide6

Consider grammar : A CFL consists of substitution rules called Productions.The capital letters are the Variables. The other symbols are the Terminals.

Context Free Grammar - Example

6

Slide7

Consider grammar : The grammar generates the language called the language of , denoted by .

Context Free Grammar - Example

7

Slide8

Consider grammar : This is a Derivation of the word by : On each step, a single rule is activated. This mechanism is nondeterministic.

Context Free Grammar - Example

8

Slide9

This is A Parse Tree of the word by :

Context Free Grammar - Example

9

Slide10

Each internal node of the tree is associated with a single production.

Context Free Grammar - Example

10

Slide11

A Context Free Grammar is a 4-tupple where: is a finite set called the variables. is a finite set, disjoint from V called the terminals. is a set of rules, where a rule is a variable and a string of variables and terminals, and is the start variable .

CF Grammar – A Formal Definition

11

,

Slide12

A word is a string of terminals.A derivation of a word w from a context Free Grammar is a sequence of strings ,over , where: is the start variable of G. For each , is obtained by activating a single production (rule) of G on one of the variables of .

A Derivation – A Formal Definition

12

Slide13

A word w is in the Language of grammar G, denoted by , if there exists a derivation whose rightmost string is w .Thus,

CF Grammar – A Formal Definition

13

Slide14

Grammar

: Rules:1. 2. 3.

Example2: Arithmetical EXPS

14

Slide15

Derivation of by Grammar : input

Example2: Arithmetical EXPS

15

Slide16

Derivation of by Grammar : input rule

Example2: Arithmetical EXPS

16

Slide17

Derivation of by Grammar

: input output rule

Example2: Arithmetical EXPS

17

Slide18

Derivation of by Grammar

: input

Example2: Arithmetical EXPS

18

Slide19

Derivation of by Grammar : input rule

Example2: Arithmetical EXPS

19

Slide20

Derivation of by Grammar : input output rule

Example2: Arithmetical EXPS

20

Slide21

Derivation of by Grammar : input

Example2: Arithmetical EXPS

21

Slide22

Derivation of by Grammar : input rule

Example2: Arithmetical EXPS

22

Slide23

Derivation of by Grammar : input output rule

Example2: Arithmetical EXPS

23

Slide24

Derivation of by Grammar : input

Example2: Arithmetical EXPS

24

Slide25

Derivation of by Grammar : input rule

Example2: Arithmetical EXPS

25

Slide26

Derivation of by Grammar

: input output rule

Example2: Arithmetical EXPS

26

Slide27

Derivation of by Grammar

: input

Example2: Arithmetical EXPS

27

Slide28

Derivation of by Grammar

: input rule

Example2: Arithmetical EXPS

28

Slide29

Derivation of by Grammar

: input output rule

Example2: Arithmetical EXPS

29

Slide30

Derivation of by Grammar

: input

Example2: Arithmetical EXPS

30

Slide31

Derivation of by Grammar

: input rule

Example2: Arithmetical EXPS

31

Slide32

Derivation of by Grammar

: input output rule

Example2: Arithmetical EXPS

32

Slide33

Derivation of by Grammar

: input

Example2: Arithmetical EXPS

33

Slide34

Derivation of by Grammar

: input rule

Example2: Arithmetical EXPS

34

Slide35

Derivation of by Grammar

: input output rule

Example2: Arithmetical EXPS

35

Slide36

Derivation of by Grammar

: input

Example2: Arithmetical EXPS

36

Slide37

Derivation of by Grammar

: input rule

Example2: Arithmetical EXPS

37

Slide38

Derivation of by Grammar

: output rule

Example2: Arithmetical EXPS

38

Slide39

Derivation of by Grammar

: input

Example2: Arithmetical EXPS

39

Slide40

Derivation of by Grammar

: input rule

Example2: Arithmetical EXPS

40

Slide41

Derivation of by Grammar

: output rule

Example2: Arithmetical EXPS

41

Slide42

Derivation of by Grammar

: input

Example2: Arithmetical EXPS

42

Slide43

Derivation of by Grammar

: input rule

Example2: Arithmetical EXPS

43

Slide44

Derivation of by Grammar

:

Example2: Arithmetical EXPS

44

Slide45

Derivation of by Grammar :

Example2: Arithmetical EXPS

45

Note:

There is more than one derivation.

Slide46

To be Demonstrated on the blackboard

Example3: The Language of WF ( )

46

Slide47

We already saw that a word may have more then a single derivation from the same grammar.A Leftmost Derivation is a derivation in which rules are applied in order left to right.A grammar is ambiguous if it has Two parse trees.

Ambiguity

47

Slide48

Reminder: Two parse trees are equal if they are equal as trees and if all productions corresponding to inner nodes are also equal .

Ambiguity

48

Slide49

Grammar : Rules:

Example4: Similar to Arith. EXPS

49

,

,

Slide50

Example4: 1

st

Parse Tree for______

50

Slide51

Example4: 2

nd

Parse Tree for_____

51

Slide52

Note: Some ambiguous grammars may have an unambiguous equivalent grammar.But: There exist Inherently Ambiguous Grammars , i.e. an ambiguous grammar that does not have an equivalent unambiguous one.

Ambiguity

52

Slide53

Q: From a computational point of view, how strong are context free languages?A: Since the language is not regular and it is CF, we conclude that . Q: Can one prove ?A: Yes.

Discussion

53

Slide54

Q: A language is regular if it is recognized by a DFA (or NFA). Does there exist a type of machine that characterizes CFL?A: Yes, those are the Push-Down Automata (Next Lecture). . Q: Can one prove a language not to be CFL ?A: Yes, by the Pumping Lemma for CFL-s . For example: is not CFL.

Discussion

54