Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Advanced Programming Languages Homework Assignment 3F and 3C, Assignments of Programming Languages

Exercises related to regular expressions and their operational semantics. The first exercise requires students to indicate the time spent and the difficulty level of the homework. The second exercise requires students to give large-step operational semantics rules of inference related to regular expressions matching strings. The third exercise requires students to update the operational semantics for regular expressions to capture multiple suffices. related to the topic of Advanced Programming Languages and is suitable for university students in computer science or related fields.

Typology: Assignments

2021/2022

Uploaded on 05/11/2023

lana87
lana87 🇺🇸

4.4

(18)

318 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Advanced Programming Languages
Homework Assignment 3F and 3C
EECS 590
Logistics. You must work alone. Your name and Michigan email address must appear on
the first page of your PDF submission but may not appear anywhere else. This is to protect
your identity during peer review. The first page of your submission is not shared during
peer view but all subsequent pages are.
Exercise 3F-1. Bookkeeping [2 points]. These answers should appear on the first page
of your submission and are kept private.
1. Indicate in a sentence or two how much time you spent on this homework.
2. Indicate in a sentence or two how difficult you found it subjectively.
All subsequent answers should appear after the first page of your submission and may be
shared publicly during peer review.
Exercise 3F-2. Regular Expression, Large-Step [10 points]. Regular Expressions
are commonly used as abstractions for string matching. Here is an abstract grammar for
regular expressions:
e::= x singleton matches the character x
|empty skip matches the empty string
|e1e2concatenation matches e1followed by e2
|e1|e2or matches e1or e2
|eKleene star matches 0 or more occurrence of e
|.matches any single character
|[”xy”] matches any character between x and y inclusive
|e+ matches 1 or more occurrences of e
|e? matches 0 or 1 occurrence of e
We will call the first five cases the primary forms of regular expressions. The last four
cases can be defined in terms of the first five. We also give an abstract grammar for strings
1
pf3
pf4

Partial preview of the text

Download Advanced Programming Languages Homework Assignment 3F and 3C and more Assignments Programming Languages in PDF only on Docsity!

Advanced Programming Languages

Homework Assignment 3F and 3C

EECS 590

Logistics. You must work alone. Your name and Michigan email address must appear on the first page of your PDF submission but may not appear anywhere else. This is to protect your identity during peer review. The first page of your submission is not shared during peer view but all subsequent pages are.

Exercise 3F-1. Bookkeeping [2 points]. These answers should appear on the first page of your submission and are kept private.

  1. Indicate in a sentence or two how much time you spent on this homework.
  2. Indicate in a sentence or two how difficult you found it subjectively.

All subsequent answers should appear after the first page of your submission and may be shared publicly during peer review.

Exercise 3F-2. Regular Expression, Large-Step [10 points]. Regular Expressions are commonly used as abstractions for string matching. Here is an abstract grammar for regular expressions:

e ::= ”x” singleton — matches the character x | empty skip — matches the empty string | e 1 e 2 concatenation — matches e 1 followed by e 2 | e 1 | e 2 or — matches e 1 or e 2 | e∗ Kleene star — matches 0 or more occurrence of e

|. matches any single character | [”x” − ”y”] matches any character between x and y inclusive | e+ matches 1 or more occurrences of e | e? matches 0 or 1 occurrence of e

We will call the first five cases the primary forms of regular expressions. The last four cases can be defined in terms of the first five. We also give an abstract grammar for strings

(modeled as lists of characters):

s ::= nil empty string | ”x” :: s string with first character x and other characters s

We write ”bye” as shorthand for ”b” :: ”y” :: ”e” :: nil. This exercise requires you to give large-step operational semantics rules of inference related to regular expressions matching strings. We introduce a judgment:

` e matches s leaving s′

The interpretation of the judgment is that the regular expression e matches some prefix of the string s, leaving the suffix s′^ unmatched. If s′^ = nil then r matched s exactly. Examples:

` ”h”(”e”+) matches ”hello” leaving ”llo”

Note that this operational semantics may be considered non-deterministic because we expect to be able to derive all three of the following:

(”h” | ”e”)∗ matches ”hello” leaving ”ello” (”h” | ”e”)∗ matches ”hello” leaving ”hello” ` (”h” | ”e”)∗ matches ”hello” leaving ”llo”

Here are two rules of inference:

s = ”x” :: s′ ”x” matches s leaving s′^ empty matches s leaving s

Give large-step operational semantics rules of inference for the other three primal regular expressions.

Exercise 3F-3. Regular Expression and Sets [5 points]. We want to update our operational semantics for regular expressions to capture multiple suffices. We want our new operational semantics to be deterministic — it return the set of all possible answers from the single-answer operational semantics above. We introduce a new judgment:

` e matches s leaving S

And use rules of inference like the following:

”x” matches s leaving {s′^ | s = ”x” :: s′} empty matches s leaving {s}

e 1 matches s leaving S e 2 matches s leaving S′ ` e 1 | e 2 matches s leaving S ∪ S′

You must do one of the following:

Submission. Turn in the formal component of the assignment as a single PDF document via the gradescope website. Your name and Michigan email address must appear on the first page of your PDF submission but may not appear anywhere else. Turn in the coding component of the assignment via the autograder.io website.