This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Homework 4 CSC 7101, Spring 2011 Due: 27 April 2011 1. Translate our operational semantics rules into Prolog clauses. Represent syntactic constructs using functors. E.g., the if-statement could be represented as ifThenElse(B,C0,C1) . Represent the three different eval- uation functions, <.,.>->. , as predicates. Assume that appropriate predicates for arithmetic, comparisons, boolean operations are built in. Assume that a state is represented as a list of pairs of a variable and a value, and that bindings at the beginning of the list shadow later bindings. E.g., the axioms for numeric constants and variables could be written as follows: evalArithExp(const(N), Sigma, N). evalArithExp(var(X), Sigma, Val) :- get(Sigma, X, Val). where get(Sigma,X,Val) computes the result of σ ( X ) in Val and is defined as follows: get(, X, undefined). get([[X,V]|T], X, V). get([H|T], X, V) :- get(T, X, V). You don’t need to test and run your Prolog program. Writing it on paper is good enough. 2. Develop semantic rules for our operational semantics system for the following (simplified) loop construct adopted from Ada:...
View Full Document
- Spring '08
- Expression, guard, Operational Semantics, intexp