CS 454, Section 001 | Sonoma State University | Spring, 2024 |
Theory of Computation
|
||
Instructor: Henry M. Walker
Lecturer, Sonoma State University |
Although much of this course has been well developed in recent semesters, the SSU CS faculty recently have approved an updated course description. Also, the required SSU Signature Project for SSU's Upper Division GE Area B Requirement for CS Majors has been rethought for this course. Currently, the Web site is reasonably stable, but modest refinements are likely. Check these pages regularly for adjustments.
Since May, 2024, the California Faculty Association (CFA) – the labor union of professors, lecturers, librarians, counselors, and coaches across the 23 California State University campuses – has been in negotiations with the management of the California State University System. After a one-day strike on Monday, January 22, the two sides have reached a tentative agreement, and the strike has been called off. Effective Tuesday, January 23, SSU classes (including CS 454) will be held as scheduled.
Unions and Intersections of Context Free Languages:
Strings with complementary numbers of a's, b's, and a's: Working with the alphabet Σ = {a, b}, consider the language M that contains all strings over Σ of the form anbnan, where n is any non-negative integer.
Determine whether or not M is a context-free language.
Strings with twice the number of a's than b's: Working with the alphabet Σ = {a, b}, consider the language L that contains all strings over Σ for which the number of a's is exactly twice the number of b's .
Determine whether or not L is a context-free language.
Optional, for Extra Credit: Context-free Grammars, Programming Languages, and Compilers: For many [most? all?] modern programming languages, the parsing of a program depends upon the specification of the language though a context-free grammar. For example, considerable time and effort is allocated in CS 452, Compiler Design and Construction, to parsing techniques that typically are based on context-free grammars. However, such parsing techniques are beyond the scope of CS 454. (That is, CS 452 already covers this material, and coverage of parsing in CS 454 would prevent coverage of other topics related to the Theory of Computation). As a partial substitute, this exercise may provide some historical context and insight regarding the use of context-free grammers in specifying a programming language.
For the purposes of this exercise we focus on a small part of an overall programming language: accessing an element within an array. For example, if arr has been declared as an array, a simple access to element 5 might have the following form:
(Here, FORTRAN uses round parentheses for array indices, whereas several other languages us square brackets, but the idea of an array is quite similar.)
In what follows, for consistency in specification alphabets, arithmetic expressions may include all one-digit integers, as well as two integer variables, a and b.
Two basic question for this exercise are, "what expressions are allowed for an array subscript", and "how should an expression be evaluated"? Three different specifications might be considered:
In 1966, FORTRAN was the second programming language to be standardized (the first language was COBOL in 1960.) In particular, Section 5.1.3.2 of the FORTRAN 66 standard specifies possible options for array subscripts,
Notes:
Example 2.4 in both Sipser's Second Edition and Sipser's Third Edition provides a context free grammar for arithmetic expressions that is somewhat simplified from the grammar used in C/C++. For this exercise, expand the grammar to allow one-digit integers and both variable a and b in expressions.
The following grammar is another, simple grammar for arithmetic expressions over the same alphabet used in Example 2.4.
<expr> → | <expr> + <expr> | <expr> - <expr> |
| <expr> * <expr> | <expr> / <expr> | | ( <expr> ) | a | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
Exercise: For each of these specifications, consider each of the following expressions, and determine if the expression is a valid array subscript according to the specification.
Expressions (where * is used for the multiplication operator):
created Fall, 2023 revised Fall, 2023 |
|
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu. |