Recursive Definition of Languages, Slides of Theory of Automata

Contains the recursive definitions and some examples

Typology: Slides

2020/2021

Uploaded on 09/16/2023

i210531-haris-sohail
i210531-haris-sohail 🇵🇰

1 document

1 / 21

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Theory of Automata
Chapter 3
Recursive definition of languages
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Partial preview of the text

Download Recursive Definition of Languages and more Slides Theory of Automata in PDF only on Docsity!

Theory of Automata

Chapter 3

Recursive definition of languages

The following three steps are used in recursive definition

1. Some basic words are specified in the language. (base

case)

2. Rules for constructing more words are defined in the

language. (Recursive case)

3. No strings except those constructed in above, are allowed

to be in the language.

Recursive definition of languages

Step 1 : 2 is in EVEN. Step 2 : If x is in EVEN then x+ 2 and x- 2 are also in EVEN. Step 3 : No strings except those constructed in above, are allowed to be in EVEN.

Example 2 : Recursive definition of language EVEN

Prove: 12 is in EVEN

◼Use rules of the recursive definition:

▪ Rule 1 : 2  EVEN ▪ Rule 2 : x= 2 , 2 + 2 = 4  EVEN ▪ Rule 2 : x= 4 , 4 + 2 = 6  EVEN ▪ Rule 2 : x= 6 , 6 + 2 = 8  EVEN ▪ Rule 2 : x= 8 , 8 + 2 = 10  EVEN ▪ Rule 2 : x= 10 , 10 + 2 = 12  EVEN

Step 1: λ, a and b are in PALINDROME Step 2: if x is palindrome, then s(x)Rev(s) and xx will also be palindrome, where s belongs to Σ* Step 3: No strings except those constructed in above, are allowed to be in palindrome

Example 4:
Recursive definition of the language PALINDROME,
defined over Σ = {a,b}

Defining the language {a n b n }, n= 1 , 2 , 3 ,… , of strings defined over Σ={a,b} Step 1 : ab is in { a n b n } Step 2 : if x is in { a n b n }, then a x b is in { a n b n } Step 3 : No strings except those constructed in above, are allowed to be in { a n b n }

Example 5 a:

Example 8

◼ Kleene closure S* of a language S

▪ Rule 1: L is in S. All words in S are in S.

▪ Rule 2: If x and y are in S*, their

concatenation xy is also in S*.

Example 9: set POLYNOMIAL

Recursive definition of the set POLYNOMIAL

1. All numbers are in POLYNOMIAL.
2. The variable x is in POLYNOMIAL.
3. If p and q are in POLYNOMIAL, p+q, p – q, (p), and pq are

also in POLYNOMIAL.

▪ The only elements in POLYNOMIAL are the ones that are

constructed by following rules 1, 2, and 3.

Arithmetic Expressions

◼Suppose we ask ourselves what

constitutes a valid arithmetic expression, or AE for short.

◼ The alphabet for this language is

)}

Arithmetic Expression AE

◼ Obviously, the following expressions are not valid: (3 + 5) + 6) 2(/8 + 9) (3 + (4-)8) ◼ The first contains unbalanced parentheses; the second contains the forbidden substring (/; the third contains the forbidden substring - ). ◼ Are there more rules? The substrings // and */ are also forbidden. ◼ Are there still more? ◼ The most natural way of defining a valid AE is by using a recursive definition , rather than a long list of forbidden substrings.

◼ The above definition is the most natural, because it is the method we use to recognize valid arithmetic expressions in real life. ◼ For instance, we wish to determine if the following expression is valid: (2 + 4) * (7 * (9 - 3)/4)/4 * (2 + 8) - 1 ◼ We do not really scan over the string, looking for forbidden substrings or count the parentheses. ◼ We actually imagine the expression in our mind broken down into components: Is (2 + 4) OK? Yes Is (9 - 3) OK? Yes Is 7 * (9 - 3)/4 OK? Yes, and so on.

◼ Note that the recursive definition of the set AE gives us the possibility of writing 8 / 4 / 2 , which is ambiguous, because it could mean 8 /( 4 / 2 ) = 4 or ( 8 / 4 )/ 2 = 1. ◼ However, the ambiguity of 8 / 4 / 2 is a problem of meaning. There is no doubt that this string is a word in AE, only doubt about what it means. ◼ By applying Rule 2 , we could always put enough parentheses to avoid such a confusion. ◼ The recursive definition of the set AE is useful for proving many theorems about arithmetic expressions, as we shall see in the next few slides.

Theorem 3 & 4

No arithmetic expression can begin or end with the symbol /.Proof?No arithmetic expression can contain the substring //. ◼ Proof?

Propositional Calculus

◼Propositional calculus (or sentential calculus) is a branch of symbolic logic that we shall be interested in. ◼The version we define here uses only negation (¬) and implication (→), together with the phrase variables. ◼ The alphabet for this language is ▪ Σ = {¬, →, (, ), a, b, c, d, …} ◼ A valid expression in this language is called WFF ( well-form formula).