updated draft
authorChristian Urban <urbanc@in.tum.de>
Fri, 12 Oct 2018 10:16:54 +0100
changeset 576 414f1daf5728
parent 575 5ca3abaa76d0
child 577 1d6043a87a3e
updated
coursework/cw01.pdf
coursework/cw01.tex
progs/dfa.scala
slides/slides01.pdf
slides/slides01.tex
slides/slides03.pdf
Binary file coursework/cw01.pdf has changed
--- a/coursework/cw01.tex	Tue Oct 09 08:25:40 2018 +0100
+++ b/coursework/cw01.tex	Fri Oct 12 10:16:54 2018 +0100
@@ -1,3 +1,4 @@
+
 \documentclass{article}
 \usepackage{../style}
 \usepackage{../langs}
@@ -70,7 +71,8 @@
   like that.} That means do not treat the extended regular expressions
 by just translating them into the basic ones. See also Question 3,
 where you are asked to explicitly give the rules for \textit{nullable}
-and \textit{der} for the extended regular expressions.\medskip
+and \textit{der} for the extended regular expressions. So something like
+$der\,c\,(r^+) \dn der\,c\,(r\cdot r^*)$ is \emph{not} allowed.\medskip
 
 \noindent
 The meanings of the extended regular expressions are
@@ -201,7 +203,16 @@
 by using $\textit{ALL}^*$). In order to avoid having an explicit constructor
 for each case, we can generalise all these cases and introduce a single
 constructor $\textit{CFUN}(f)$ where $f$ is a function from characters
-to booleans. The idea is that the function $f$ determines which character(s)
+to booleans. In Scala code this would look as follows:
+
+\begin{lstlisting}[numbers=none]
+abstract class Rexp
+...
+case class CFUN(f: Char => Boolean) extends Rexp 
+\end{lstlisting}\smallskip
+
+\noindent
+The idea is that the function $f$ determines which character(s)
 are matched, namely those where $f$ returns \texttt{true}.
 In this question implement \textit{CFUN} and define
 
--- a/progs/dfa.scala	Tue Oct 09 08:25:40 2018 +0100
+++ b/progs/dfa.scala	Fri Oct 12 10:16:54 2018 +0100
@@ -4,6 +4,7 @@
 // type abbreviation for partial functions
 type :=>[A, B] = PartialFunction[A, B]
 
+
 case class DFA[A, C](start: A,               // starting state
                      delta: (A, C) :=> A,    // transition (partial fun)
                      fins:  A => Boolean) {  // final states
@@ -38,10 +39,11 @@
     case (Q4, 'b') => Q4 }
 
 val dfa = DFA(Q0, delta, Set[State](Q4))
+dfa.accepts("aaabbb".toList) 
 
 dfa.accepts("bbabaab".toList)   // true
 dfa.accepts("baba".toList)      // false
-
+dfa.accepts("abc".toList)       // false
 
 // another DFA test with a Sink state
 abstract class S
Binary file slides/slides01.pdf has changed
--- a/slides/slides01.tex	Tue Oct 09 08:25:40 2018 +0100
+++ b/slides/slides01.tex	Fri Oct 12 10:16:54 2018 +0100
@@ -20,6 +20,8 @@
 
 \begin{document}
 
+
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{frame}[t]
 \frametitle{%  
@@ -228,7 +230,7 @@
   \node [above=5mm of 0]
   {\makebox[0mm]{\footnotesize
       \begin{tabular}{@{}l@{}}input\\[-1mm]program\end{tabular}}}; 
-  
+     
   \node (A) at (0,0)  [node] {};
   \node [below right] at (A.north west) {lexer};
 
Binary file slides/slides03.pdf has changed