













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Contains the recursive definitions and some examples
Typology: Slides
1 / 21
This page cannot be seen from the preview
Don't miss anything!














The following three steps are used in recursive definition
case)
language. (Recursive case)
to be in the language.
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.
▪ 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
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 }
Recursive definition of the set POLYNOMIAL
also in POLYNOMIAL.
constructed by following rules 1, 2, and 3.
constitutes a valid arithmetic expression, or AE for short.
)}
◼ 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.
◼ No arithmetic expression can begin or end with the symbol /. ◼ Proof? ◼ No arithmetic expression can contain the substring //. ◼ Proof?
◼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).