\documentclass[12pt]{article}
\usepackage{fancyhdr,fancybox,amssymb,epsfig,amsmath,latexsym,bm}
\usepackage{enumerate}
\usepackage{tikz}
\usepackage[all]{xy}
\usepackage{stackrel}
\usepackage[]{hyperref}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}

\tikzset{big arrow/.style={decoration={markings,mark=at position 0.6
      with {\arrow[scale=2]{>}}}, postaction={decorate}, shorten >=1pt}}

% Code to make an augmented matrix (Usage: \begin{bmatrix}[ccc|c])
\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
  \hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{#1}}
\makeatother

\topmargin=-.5in
\headsep=0.2in
\oddsidemargin=0in
\textwidth=6.7in
\textheight=9.2in
\footskip=.5in

% Change this line to \def\bold{\mathbf} for ``upright boldface.''
\def\bold{\bm}

\newcommand{\F}{\mathbb{F}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\Z}{\mathbb{Z}}

\def\b{\mathbf{b}}

\DeclareMathOperator{\A}{A}
\DeclareMathOperator{\C}{C}
\DeclareMathOperator{\G}{G}
\DeclareMathOperator{\T}{T}
\DeclareMathOperator{\U}{U}

\DeclareMathOperator{\AU}{AU}
\DeclareMathOperator{\CG}{CG}
\DeclareMathOperator{\GU}{GU}
\DeclareMathOperator{\GC}{GC}
\DeclareMathOperator{\UG}{UG}

\def\<{\langle}
\def\>{\rangle}
\def\longto{\longrightarrow}

\DeclareMathOperator{\Span}{Span}
\DeclareMathOperator{\rank}{rank}
\newcommand{\vv}[2]{\begin{bmatrix} #1 \\ #2 \end{bmatrix}}
\newcommand{\vvv}[3]{\begin{bmatrix} #1 \\ #2 \\ #3 \end{bmatrix}}

\newcommand{\ds}{\displaystyle}

\renewcommand{\footrulewidth}{1pt}
\newenvironment{proof}[1][Proof.]{\smallskip\begin{trivlist}
    \item[\hskip \labelsep {\sffamily #1}]}{\qed\end{trivlist}\bigskip}
\newenvironment{sol}[1][Solution.]{\smallskip\begin{trivlist}
    \item[\hskip \labelsep {\sffamily #1}]}{\qed\end{trivlist}\bigskip}
\newenvironment{fminipage}
{\setlength{\fboxsep}{15pt}\begin{Sbox}\begin{minipage}}
{\end{minipage}\end{Sbox}\fbox{\TheSbox}}
\newcommand{\qed}{\hfill \ensuremath{\Box}}
\newcommand{\disp}{\displaystyle}


\pagestyle{fancy} \lhead{{\sf Homework 11 $|$ Due April 8 (Friday)
}} \rhead{\thepage} \cfoot{{\sf Math 4500 $|$ Mathematical Modeling
    $|$ Spring 2016 $|$ M.~Macauley}}


\begin{document}

$\;$

\noindent \emph{Read}: Algebraic and Discrete Mathematical Methods for
Modern Biology, Chapter 13.4--13.5: \emph{RNA Secondary Structures:
  Combinatorial Models and Folding Algorithms}, by Q.~He, M.~Macauley,
and R.~Davies. Pages 335--345. \\


\begin{enumerate}

\item Construct a regular grammar that generates the language
  $\{b^na\mid n\geq 0\}$. Try to construct a regular grammar that
  generates the languge $\{ab^na\mid n\geq 0\}$. What goes wrong? \\



\item The \emph{Knudsen-Hein grammar} is a stochastic context free grammar
  (SCFG) defined by the following production rules:
  \begin{align*}
    &S\longto LS\;(p_1)\,|\,L\;(q_1) \\
    &L\longto dFd'\;(p_2)\,|\,s\;(q_2) \\
    &F\longto dFd'\;(p_3)\,|\,LS\;(q_3)
  \end{align*}
  \begin{enumerate}
  \item Construct a derivation of the hairpin loop $ssddsssd'd'ss$ and
    draw the parse tree. What is the probability of this structure
    given this grammar?
  \item Modify the rules to make the minimum loop size $j-i\geq 4$ and
    repeat the above problem. \\
  \end{enumerate}



\item Allowing arc lengths of length $\lambda=3$, there $7$ legal
  folds of the sequence $\b=\mathrm{GGACUGC}$. Two of these are shown
  below.
  \[
  \begin{tikzpicture}[scale=.6, shorten >= -2pt, shorten <= -2pt]
    \begin{scope}[shift={(0,0)}]
      \node (1) at (1,0) {$\G$};
      \node (2) at (2,0) {$\G$};
      \node (3) at (3,0) {$\A$};
      \node (4) at (4,0) {$\C$};
      \node (5) at (5,0) {$\U$};
      \node (6) at (6,0) {$\G$};
      \node (7) at (7,0) {$\C$};
      \draw (1) to [bend left=70] (7);
      \draw (2) to [bend left=70] (5);
      \node at (4,-1.5) {\footnotesize $P(S)=p_2^2q_1^3q_2^3q_3^2$};
    \end{scope}
    %%
    \begin{scope}[shift={(15,0)}]
      \node (1) at (1,0) {$\G$};
      \node (2) at (2,0) {$\G$};
      \node (3) at (3,0) {$\A$};
      \node (4) at (4,0) {$\C$};
      \node (5) at (5,0) {$\U$};
      \node (6) at (6,0) {$\G$};
      \node (7) at (7,0) {$\C$};
      \draw (2) to [bend left=70] (7);
      \node at (4,-1.5) {\footnotesize $P(S')=p_1^3p_2q_1^2q_2^5q_3$};
    \end{scope}
  \end{tikzpicture}
  \]
  Find a derivation for each of these using the Knudsen Hein grammar
  and construct its parse tree. \\



\item Consider the following ``mystery grammar'' from (Durbin, 1998):
  \begin{align*}
    &S\longto aAu\,|\,cAg\,|\,gAc\,|\,uAa \\
    &A\longto aBu\,|\,cBg\,|\,gBc\,|\,uBa \\
    &B\longto aCu\,|\,cCg\,|\,gCc\,|\,uCa \\
    &C\longto gaaa\,|\,gcaa.
  \end{align*}
What is the language $L$ derived from this grammar? Describe it in
terms of RNA secondary structures.


\end{enumerate}


\end{document}


