Question: The first two is the old question and the answer, the last picture is the new question, but I am not sure how to answer



The first two is the old question and the answer, the last picture is the new question, but I am not sure how to answer this question, please help
6. JH-Lisp is a simple programming language for evaluating arithmetic expressions. It is described from the following components: (a) The alphabet of JH-Lisp consists of the open 'l and close 'D' parentheses, the digits 0-9, the space character ' ', and the symbols + - */ (b) An operator is a substring in JH-Lisp containing one of the symbols + - * /. 2 (c) A number is a substring in JH-Lisp containing one or more of the digits 0-9 (d) An expression is defined as either a number or a list expression (e) A list expression is defined by the following, in order: i. An open parenthesis:'( ii. An operator iii. A space: iv. An expression v. A space: vi. An expression vii. A close parenthesis: '' (f) A string in the JH-Lisp language is a single list expression. Examples of JH-Lisp strings may include: (* 2 3) (+ (* 5 3) (/ 8 4)) (- 25 (+ 4 2)) Is JH-Lisp a regular language? Why or why not? If you think it is, provide a regular expression or finite automaton which recognizes the language. If you think it is not, provide an explanation as to why no regular expression or finite automaton should be able to recognize it. 6. JH-Lisp is not regular, as the definition of a list expression is both recursive, and requiring that for every open parenthesis, there is a matching close parenthesis. Furthermore, the close parenthesis occurs several symbols after the matching open parenthesis, so at any point in time, determining whether a string is in the language requires a running count of the number of current open parentheses. This count is arbitrarily high, as JH-Lisp lacks a maximum recursion depth. In a finite automaton, the ability to "count" symbols is limited. Cycles of states can be used to ensure that the count of some symbol stays within a pre-defined modulus (e.g. an even number of Os). States may also encode the counts of one or more symbols in the string, however doing so requires a new state for every possible number to count to, as there is no other mechanism for storing stateful information (i.e. memory). As their name implies, however, they must have a finite number of states, meaning that counting to an arbitrarily high number is impossible. 6. The following is a description for JH-Lisp2", which is a modified version of the language previously described in homework 3, problem 6: (a) The alphabet of JH-Lisp2 consists of the open '[' and close ']square brackets, the digits 0-9, the underscore character ?-?, and the letters {a,b,d,i,1,m,0,s,u,v} (b) An operator is a substring in JH-Lisp2 containing one of the following strings: {add, sub, mul, div, mod}. (c) A number is a substring in JH-Lisp2 containing one or more of the digits 0-9 (d) An expression is defined as either a number or a list expression (e) A list expression is defined by the following, in order: i. An open bracket: '[' ii. An operator iii. An underscore: iv. An expression v. An underscore: '.' vi. An expression vii. A close bracket: ']' (f) A string in the JH-Lisp2 language is a single list expression. An example string in this language might be [add_[mod_4_3]_21] Give a context-free grammar for JH-Lisp2. 6. JH-Lisp is a simple programming language for evaluating arithmetic expressions. It is described from the following components: (a) The alphabet of JH-Lisp consists of the open 'l and close 'D' parentheses, the digits 0-9, the space character ' ', and the symbols + - */ (b) An operator is a substring in JH-Lisp containing one of the symbols + - * /. 2 (c) A number is a substring in JH-Lisp containing one or more of the digits 0-9 (d) An expression is defined as either a number or a list expression (e) A list expression is defined by the following, in order: i. An open parenthesis:'( ii. An operator iii. A space: iv. An expression v. A space: vi. An expression vii. A close parenthesis: '' (f) A string in the JH-Lisp language is a single list expression. Examples of JH-Lisp strings may include: (* 2 3) (+ (* 5 3) (/ 8 4)) (- 25 (+ 4 2)) Is JH-Lisp a regular language? Why or why not? If you think it is, provide a regular expression or finite automaton which recognizes the language. If you think it is not, provide an explanation as to why no regular expression or finite automaton should be able to recognize it. 6. JH-Lisp is not regular, as the definition of a list expression is both recursive, and requiring that for every open parenthesis, there is a matching close parenthesis. Furthermore, the close parenthesis occurs several symbols after the matching open parenthesis, so at any point in time, determining whether a string is in the language requires a running count of the number of current open parentheses. This count is arbitrarily high, as JH-Lisp lacks a maximum recursion depth. In a finite automaton, the ability to "count" symbols is limited. Cycles of states can be used to ensure that the count of some symbol stays within a pre-defined modulus (e.g. an even number of Os). States may also encode the counts of one or more symbols in the string, however doing so requires a new state for every possible number to count to, as there is no other mechanism for storing stateful information (i.e. memory). As their name implies, however, they must have a finite number of states, meaning that counting to an arbitrarily high number is impossible. 6. The following is a description for JH-Lisp2", which is a modified version of the language previously described in homework 3, problem 6: (a) The alphabet of JH-Lisp2 consists of the open '[' and close ']square brackets, the digits 0-9, the underscore character ?-?, and the letters {a,b,d,i,1,m,0,s,u,v} (b) An operator is a substring in JH-Lisp2 containing one of the following strings: {add, sub, mul, div, mod}. (c) A number is a substring in JH-Lisp2 containing one or more of the digits 0-9 (d) An expression is defined as either a number or a list expression (e) A list expression is defined by the following, in order: i. An open bracket: '[' ii. An operator iii. An underscore: iv. An expression v. An underscore: '.' vi. An expression vii. A close bracket: ']' (f) A string in the JH-Lisp2 language is a single list expression. An example string in this language might be [add_[mod_4_3]_21] Give a context-free grammar for JH-Lisp2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
