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.
Let CFG W be
if Statements in Pascal: Suppose the symbols Boolean-expression and statement have been defined for the Pascal language through a context-free grammar. Then, the Pascal Standard specifies the following context-free grammar for "if" statements:
if-statement → "if" Boolean-expression "then" statement | "if" Boolean-expression "then" statement else-part else-part → "else" statement
Assume both (x < 1.5) and (y > 4) are valid Boolean-expressions, and assume assignments a := 6.7 and b := -x are valid statements. Consider the Pascal code:
if (x < 1.5) then if (y > 4) then a := 6.7 else b := -x
Note that the Pascal standard added a note to resolve this issue for compilers. Thus, while the formal grammar was ambiguous, the interpretation in actual programs was not.
Conditional Statements in Some Programming Languages: In some programming languages, a cond statement is roughly defined as a type of generalized if statement in C/C++. This exercise explores a variation of this construction.
Notes:
(cond ((< x 0) "negative") ((< x 10) "single-digit") ((< x 100) "double-digit") (else "big") ) (cond ((< x 0) "negative" (f x)) ((>= x 0) "nonnegative") ) (cond ((< x 0) "negative" (f x)) (else "nonnegative" (g (f y) z) "nice example") ) (cond (else "any value")
Suppose the symbols condition and statement have been defined through a context-free grammar for Boolean expressions and statements, respectively, within the programming language.
Using the alphabet Σ = {a, b}, consider the language L of strings with the same number of a's and b's.
Consider the problem of checking whether an expression has balanced parentheses. For example, (())() is balanced, but ())()), ((), and ())(() are not. (In the last case, there are the same number of left and right parentheses, but the second right parenthesis appears before the a corresponding left parenthesis appears—that is, the left and right parentheses appear in the wrong order to balance.)
The following diagram is a proposed to accepted expressions with matching parentheses:
For example, the string ({<>}) is properly matched, but neither ({><}) nor ({<)}>) are.
created Fall, 2023 revised Fall, 2023 |
|
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu. |