260 likes | 343 Views
Learn LaTeX, a typesetting software used by the scientific community. Start with MikTeX & TeXnicCenter. Master math mode, formatting, images, tutorials & more. Understand non-determinism concepts with examples. Implement DFA conversion and solve extra problems using subset sum, bijection, and DFA expansion techniques.
E N D
Problem Session 1 CS 302
Topics • LaTeX • Questions from Class • Extra problems
LaTeX • Typesetting software for math • Used by scientific community • Why should you learn it?
How to get LaTeX (windows) • Download MikTeX (www.miktex.org) • Download TeXnicCenter (or other IDE) (www.toolscenter.org)
Starting a document • \documentclass[12pt]{article} • \pagestyle{plain} • \usepackage{anysize} • \marginsize{2.5cm}{2.5cm}{1.5cm}{1.5cm} • \begin{document} • … • \end{document}
Math Mode • $ - begins math mode • ^ - superscript • _ - subscript • \mbox – enter text in math mode • \ - begins a command or escapes a character
Using the Preamble • LaTeX allows you to create your own environments • \begin{proof} • Blah blah blah • \end{proof} • There are lots provided in the preamble
Lists • \begin{enumerate}, \begin{itemize} • \item creates a new item • \begin{enumerate*} omits numbering
Formatting • \newpage • \vspace{10mm}, \hspace{10mm} • newlines
Including Images • \usepackage{graphicx} • \begin{figure}[!htbp] • \includegraphics[scale=.75]{hw1-9a.jpg} • \end{figure} • It probably won’t put things where you want. • Supports jpg, ps, but not gif
Tutorials • Links on course webpage • Lots of links on wikipedia • Search for what you want!
Example of Conceptual Power of Non-determinism • Let L be regular • Let ½(L)={x : y |x|=|y| and xy L} • i.e., ½(L) = first halves of strings in L • Is ½(L) regular?
½(L) is regular • Let M be a DFA for L • Construct M’ for ½(L) • M’ uses the “finger method” • Place left finger on q0 in M • Middle finger on qj, nondeterministic guess as to where x will lead • Right finger on qj
Transition Function • As characters of x are read • M’ moves left finger along transitions dictated by characters read • And simultaneously moves right finger along a non-deterministically chosen edge • which may be labeled with any character, not necessarily the one of x being read
Acceptance • M’ accepts x iff at the end • Left finger is on qj • Right finger is on accept state • Thus, M’ accepts x iff |x| |y| q0 qj
Formal Implementation • Given M=(Q,,,q0,F) • Construct M’=(Q’,,’,q0’,F) • Q’ = Q x Q x Q {s} • Q x Q x Q = (left,middle,right) • s = new start state
Formal Implementation • Guess the state qj that input x will lead to • ’(s,) = {<q0,qj,qj> : qj in Q} • ’(<qi,qj,qk>, a) = • { <ql,qj,qm> : ’(qi,a)=ql and there is b in such that (qk,b)=qm} • Note that the middle finger does not change after initial guess. • F’={ <qj,qj,qk> : qj in Q, qk in F}.
Extra Problems • True or false: if T is countable, then the set {S|S a subset of T, S is finite} is also countable.
True • Use the Subset Sum technique • T = { a1, a2, a3,…} • Add up the subscripts of each set of S • Order by sum of subscripts, then lexicographically (i.e. a set with a1 comes before a set with a2)
Extra Problems • Is there a bijection between the interval (0,1) on the real line and all the real numbers?
Yes • Tan(x-½ π)/π/2 • Project (0,1) to semi circle centered at (½, ½). Draw the ray passing through (½, ½) and intersecting the x-axis.
Extra Problems • Show that if we add a single 32-bit register to a DFA and that each state can store some value in it then every language this machine accepts can be accepted by a regular DFA.
The register adds a finite number of states to each state • Add states to the machine representing all the possible values the register could have at that state
Extra Problems • Create a DFA the recognizes the set of strings in which the number of 0s is divisible by 2 and the number of 1s is divisible by 3.