# HG changeset patch # User Christian Urban # Date 1501719679 -3600 # Node ID ea47c3b8f35f4357676e4ef20b44c04e69279307 # Parent c498cb53a9a84a84ba899f49b01fb704d52506b9 updated diff -r c498cb53a9a8 -r ea47c3b8f35f hws/hw01.pdf Binary file hws/hw01.pdf has changed diff -r c498cb53a9a8 -r ea47c3b8f35f hws/hw01.tex --- a/hws/hw01.tex Wed Jun 28 12:46:23 2017 +0100 +++ b/hws/hw01.tex Thu Aug 03 01:21:19 2017 +0100 @@ -29,10 +29,11 @@ \item Read the handout of the first lecture and the handout about notation. Make sure you understand the concepts of - strings and languages. In the context of the AFL-course, + strings and languages. In the context of the CFL-course, what is meant by the term \emph{language}? -\item Give the definition for regular expressions. What is the + \item Give the definition for regular expressions---this is an + inductive datatype. What is the meaning of a regular expression? (Hint: The meaning is defined recursively.) @@ -41,6 +42,7 @@ \emph{concatenating} two sets of strings. This operation is also written as $\_ \,@\, \_$. According to this definition, what is $A \,@\, \{\}$ equal to? + Is in general $A\,@\,B$ equal to $B\,@\,A$? \item Assume a set $A$ contains 4 strings and a set $B$ contains 7 strings. None of the strings is the empty diff -r c498cb53a9a8 -r ea47c3b8f35f hws/hw04.pdf Binary file hws/hw04.pdf has changed diff -r c498cb53a9a8 -r ea47c3b8f35f hws/hw04.tex --- a/hws/hw04.tex Wed Jun 28 12:46:23 2017 +0100 +++ b/hws/hw04.tex Thu Aug 03 01:21:19 2017 +0100 @@ -97,7 +97,13 @@ \item What is the purpose of the record regular expression in the Sulzmann \& Lu algorithm? - + +\item Recall the functions \textit{nullable} and \textit{zeroable}. + Define recursive functions \textit{atmostempty} (for regular expressions + that match no string or only the empty string), \textit{somechars} (for regular + expressions that match some non-empty string), \textit{infinitestrings} (for regular + expressions that can match infinitely many strings). + %\item (Optional) The tokenizer in \texttt{regexp3.scala} takes as %argument a string and a list of rules. The result is a list of tokens. Improve this tokenizer so diff -r c498cb53a9a8 -r ea47c3b8f35f progs/re1.scala --- a/progs/re1.scala Wed Jun 28 12:46:23 2017 +0100 +++ b/progs/re1.scala Thu Aug 03 01:21:19 2017 +0100 @@ -1,5 +1,6 @@ // Simple matcher for basic regular expressions +object Test { abstract class Rexp case object ZERO extends Rexp // matches nothing @@ -21,6 +22,8 @@ } +} + // derivative of a regular expression w.r.t. a character def der (c: Char, r: Rexp) : Rexp = r match { case ZERO => ZERO