diff --git a/Lectures/L24_SpecificationQuality/SpecificationQuality.pdf b/Lectures/L24_SpecificationQuality/SpecificationQuality.pdf index 858cb629ddbefa0eb8ff9a1d62fe45b00a5e6cac..9e9853a443c4f22af01031dc90b7c0c0f858a801 100644 Binary files a/Lectures/L24_SpecificationQuality/SpecificationQuality.pdf and b/Lectures/L24_SpecificationQuality/SpecificationQuality.pdf differ diff --git a/Lectures/L24_SpecificationQuality/SpecificationQuality.tex b/Lectures/L24_SpecificationQuality/SpecificationQuality.tex index e8a82456a78476ec017044c7164fc5eca8c61423..219f5a81efb5480e16ef03d8a8503fb9ec8335ae 100755 --- a/Lectures/L24_SpecificationQuality/SpecificationQuality.tex +++ b/Lectures/L24_SpecificationQuality/SpecificationQuality.tex @@ -1,5 +1,5 @@ -\documentclass[t,12pt,numbers,fleqn,handout]{beamer} -%\documentclass[t,12pt,numbers,fleqn]{beamer} +%\documentclass[t,12pt,numbers,fleqn,handout]{beamer} +\documentclass[t,12pt,numbers,fleqn]{beamer} \usepackage{pgfpages} \usepackage{hyperref} @@ -505,385 +505,4 @@ See %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame} -\frametitle{Correct Syntax for Mathematics} - -\begin{itemize} - -\item Make sure the syntax of your mathematical expressions is correct -\item Correct syntax does not guarantee correct semantics -\item Incorrect syntax makes the mathematics ambiguous -\item Example problems to watch for -\begin{itemize} -\item Mismatch of types -\begin{itemize} -\item ($\mbox{p.xcoord()} + \mathit{width}) \wedge \mbox{p.xcoord()}$ -\item $\neg(\mbox{integer})$ -\item Set of sequences accessed by $[i]$ -\item $\forall (i: \mathbb{N} \wedge j: \mathbb{N} ...)$ -\end{itemize} -\item Use of programming language notation in mathematics -\begin{itemize} -\item Integer values instead of boolean -\item length $==$ MAX\_SIZE -\end{itemize} -\item $(x > 7) = \mathit{true}$ instead of $(x > 7)$ (bad form) -\end{itemize} -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Different World Views} - -\begin{itemize} - -\item English and other natural languages -\begin{itemize} -\item Express both static and dynamic views -\item States and actions (verbs of being and action) -\end{itemize} -\item Imperative programming languages -\begin{itemize} -\item Primarily dynamic world view (changes) -\end{itemize} -\item Functional programming languages -\begin{itemize} -\item Static world view -\end{itemize} -\item Mathematics -\begin{itemize} -\item Static world view only -\end{itemize} -\item Fundamental conceptual differences -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Static Versus Dynamic Views} - -\begin{itemize} - -\item These very different world views pose a conceptual hurdle for the translator -\item The translator must bridge the gap between -\begin{itemize} -\item Dynamic and static view of problem statement -\item Dynamic world view of programming and -\item Purely static world view of mathematics -\end{itemize} -\item Not hard, but requires conscious attention - -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Translating Between Languages} - -\begin{itemize} - -\item Translating a statement from one language to another is a multistep (not single) process -\begin{enumerate} -\item Statement in source language to a mental understanding of the \structure{meaning} of the statement -\item Reformulate \structure{mental understanding} into target language view, concepts, culture -\item Mental understanding of the \structure{meaning} of the statement to a statement in the target language -\end{enumerate} -\item The first and last statement must \structure{mean} the same - -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Translators} - -\begin{itemize} - -\item Knowing two languages: not enough to translate -\item A good translator knows well -\begin{itemize} -\item The two languages -\item AND the subject being translated -\item AND how to translate -\end{itemize} -\item These three things are \structure{different} - -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Organization and Style} - -\begin{itemize} - -\item When writing in English, or any other natural language, one pays careful - attention to -\begin{itemize} -\item Organization of the essay, report, etc. -\item Style of expression -\end{itemize} -\item When writing in Mathematics, to do the same: -\begin{itemize} -\item Clear, complete, conscise -\item KISSS (Keep it Simple Sharp and Straightforward) -\item Understandable -\item Interesting -\end{itemize} - -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Strategies} - -\begin{itemize} - -\item Understand the meaning of the original -\item Obtain all needed information -\item Close the gap between the English text and mathematics -\item Divide and conquer (complexity) - -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Strategy: Understand the Original} - -\begin{itemize} - -\item Describe specific instance of general problem -\item Distinguish essentials from background -\item Draw a diagram -\item Express in intermediate or mixed language -\item Identify object referred to -\item Identify implicit (but false) ``information'' -\item Identify missing information -\item Identify relationships between essential objects -\item Identify special cases - -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Strategy: Obtain all Needed Information} - -\begin{itemize} - -\item Ask the author of the task description -\item Identify gaps in the description of the task -\item Identify implicit ``information'' -\item Ask if implicit ``information'' may be assumed -\item Identify data present and ask about related details -\item Ask if missing information is really needed -\item Read \structure{carefully}, \structure{thoroughly}, \structure{precisely} - -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Strategy: Close Gap English -- Mathematics} - -\begin{itemize} - -\item Express implicit information explicitly -\item Reduce vagueness and ambiguity -\item Reword English text to be closer to mathematics (express in an intermediate, mixed language) - -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Strategy: Divide and Conquer} - -\begin{itemize} - -\item Construct a table -\item Distinguish between specific cases -\item Introduce an auxiliary mathematics function -\item Modularize - -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Strategy: Draw Diagrams, Describe Specific Instances of the Given Problem} - -\begin{itemize} - -\item Graphical representations help understand the meaning of the message -\item For specific instances, think of extreme cases first to simplify -\begin{itemize} -\item $n=0$ -\item $n=1$ -\item $n=\inf$ -\end{itemize} -\item Think of a normal sized problem, usually something like $n \geq 3$ -\item You might want to write down truth tables - -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{A Small Translator's Glossary} - -\begin{tabular}{p{4cm} | p{6cm}} -\toprule -English & Mathematics\\ -\midrule -and, but & $\wedge$\\ -\hline -or & $\vee$\\ -\hline -for all, each, every, any & $\forall$, $\wedge$ series, universal quantification\\ -\hline -for no, none & $\forall$, $\wedge$ series, universal quantification, with a negated assertion\\ -\hline -there is (are), there exist(s), for some, at least one & $\exists$, $\vee$ series, existential quantification\\ -\hline -\bottomrule -\end{tabular} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{A Small Translator's Glossary Continued} - -\begin{tabular}{p{4cm} | p{6cm}} -\toprule -English & Mathematics\\ -\midrule -integer & $... \in \mathbb{Z}$\\ -\hline -sorted & $\wedge_{i=0}^{n-2} A[i] \leq A[i+1]$, \newline -$\forall ( i : \mathbb{N} | 0 \leq i < n-1 : A[i] \leq A[i+1])$\\ -\hline -if (when, whenever) ... then ... & ... $\rightarrow$ ..., sometimes $\wedge$ \\ -\hline -search, find, equal, present & $=$\\ -\hline -exchange, rearrange, different order, different sequence, merge, copy, sort & permutation\\ -\hline -\bottomrule -\end{tabular} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Your Translator's Glossary} - -\begin{itemize} - -\item A professional translator compiles his/her own translation glossary -\begin{itemize} -\item Over time -\item Based on own accumulated experience -\end{itemize} -\item You should too! -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Exercise} - -Consider an array $D$ with index values ranging from $1$ to $n$. The subject of this example is part of a specification -for a subprogram that will count how many times a particular given value occurs in the array $D$.\\ -~\newline - -The goal of this exercise is to write a postcondition for the subprogram, relating the various relevant variablesÕ -values when the search is complete. - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Exercise Continued} - -Understand the task in the original language - -\begin{itemize} - -\item Identify objects referred to (look for nouns in the original English text) -\item<2-> \structure<2>{Array $D$, index value, times (count), particular given value, relevant variables's value} -\item Identify missing information -\item<3-> \structure<3>{Names of variable for: index, times (count), particular given value} -\item<4-> \structure<4>{Are there any other relevant variables?} -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Exercise} - -\begin{itemize} - -\item Identify missing information -\item Names of variable for -\begin{itemize} -\item Index: assume $i$ -\item Times (count): ask the author of the task, assume $\mathit{count}$ -\item Particular given value: Ask the author of the task, assume $\mathit{key}$ -\item Are there any other relevant variables? (no?) -\end{itemize} -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Reference} - -\begin{itemize} - -\item Baber, Robert L., \textit{Translating English to Mathematics}, 2002 - -\end{itemize} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - \end{document} \ No newline at end of file diff --git a/Lectures/L25_EnglishToMath/EnglishToMath.pdf b/Lectures/L25_EnglishToMath/EnglishToMath.pdf index c917ba1800c2b1be9869173c6fa73b6ffb190e40..312ee74dfe55534c858d32ada6dce103a843730d 100644 Binary files a/Lectures/L25_EnglishToMath/EnglishToMath.pdf and b/Lectures/L25_EnglishToMath/EnglishToMath.pdf differ diff --git a/Lectures/L25_EnglishToMath/EnglishToMath.tex b/Lectures/L25_EnglishToMath/EnglishToMath.tex index 61669eb95585973fe1aff6351e9a3ab637a16930..a7902c3ea32464206e00ba136c39aeb69639a56e 100755 --- a/Lectures/L25_EnglishToMath/EnglishToMath.tex +++ b/Lectures/L25_EnglishToMath/EnglishToMath.tex @@ -23,7 +23,7 @@ \mode<presentation>{} \input{../def-beamer} -\Drafttrue +\Draftfalse \newcommand{\topicTitle}{25 English To Math} \ifDraft @@ -47,7 +47,6 @@ \begin{itemize} \item Administrative details -\item Line Formatter Example \item English and mathematics as languages \item Different world views \item Translating between languages @@ -73,25 +72,19 @@ TBD \item Midterm \bi \item Grades on Avenue -\item Out of 27 instead of 30 -\bi -\item The test was more difficult than most expected -\item Final will also require knowledge of course material and attention to - detail -\item Remember the goal of the test is to measure your ability to design and - develop software as part of a University degree -\ei +\item Out of 29 instead of 30: Average around 70\% \ei -\item A3 deadlines +\item A3 \begin{itemize} -\item Part 2 - Code: due 11:59 pm Mar 20 -\item \structure{Part 1 spec available on Wednesday} +\item Part 1 - Specification: due 11:59 pm Mar 12 +\item Part 1 - Solution: Mar 18 +\item Part 2 - Code: due 11:59 pm Mar 26 \end{itemize} \item A4 \bi \item Your own design and specification -\item Due April 3 at 11:59 pm +\item Due April 9 at 11:59 pm \ei \end{itemize} @@ -102,196 +95,6 @@ TBD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame} -\frametitle{Line Formatter} - -\bi -\item \structure{Input} stream signalled with ET -\item Exactly one ET character in each input stream -\item \structure{Character} classifications: -\bi -\item Break character - BL (blank) and NL (new line) -\item Non Break Character - all others except ET -\item End of text indicator ET -\ei -\item \structure{Word} is a non-empty sequence of non break characters -\item \structure{Break} is a sequence of one or more break characters -\item \structure{Output} same sequence of words, except if there is an oversize - word -\bi -\item Oversize means more than MAXPOS characters, where MAXPOS is a positive - integer -\item If there is an oversize word -\bi -\item Set Alarm to TRUE -\item Exit the program -\ei -\ei -\ei -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Line Formatter} - -\bi -\item Up to the point of an error, the program's output should have the - following properties -\bi -\item A new line should start only between words and at the beginning of the -output text, if any - -\item A break in the input is reduced to a single break character in the output - -\item As many words as possible should be placed on each line (i.e.\ between -successive NL characters) - -\item No line may contain more than MAXPOS characters (words and BLs) -\ei -\ei -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Abstract?} - -\uncover<2->{ -\bi -\item Not abstract! -\item Specifies an implementation for error handling (variable named Alarm) -\item Do not have to name the variable Alarm -\item Could use exception handling (or another approach) instead -\item ET is a machine dependent (program domain) concept -\ei -} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Correct?} - -\uncover<2->{ -\bi -\item The definition of line is incorrect! -\item A line is defined as being between NLs, which ignores text before the - first NL and after the last NL -\item The output file does not contain ET, which is either a bug in the spec or - a significant non-uniformity -\ei -} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Unambiguous?} - -\uncover<2->{ -\bi -\item Ambiguous! -\item ``point of error'' is not defined -\item Output matches input to the last acceptable word, or the last acceptable character? -\item ``trailing blanks ending with ET'' is ambiguous -\item The program's output should be the same sequence of words as in the input -\bi -\item But the input is not a sequence of words -\item If the input were a sequence of words, what about leading or trailing - breaks? -\item ``As many words as possible should be placed on each line'' -\bi -\item WHO WHAT ``NL'' WHEN -\item WHO ``NL'' WHAT WHEN -\ei -\ei -\ei -} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Complete?} - -\uncover<2->{ -\bi -\item Not complete! -\item Meaning of NL and its relation to the concept of line is left implicit -\item Alarm is not specified if MAXPOS is never exceeded -\ei -} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Consistent?} - -\uncover<2->{ -\bi -\item Not consistent! -\item ``non-empty'' and ``one or more'' (synonyms) -\item ``stream'' and ``sequence'' (synonyms) -\item Is the input a ``stream of characters'' or a ``sequence of words separated - by breaks''? -- sequence of T is not the same as sequence of sequence of T -\ei -} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Verifiable?} - -\uncover<2->{ -\bi -\item The specification cannot be verified, since it is ambiguous and incorrect -\ei -} - -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\begin{frame} -\frametitle{Advantages and Disadvantages?} - -\bi -\item \structure{Advantages and disadvantages of maintaining both - formal and a natural language spec?} -\ei - -\uncover<2->{ -\bi -\item Advantage of natural language - understandability -\item Advantage of formal spec -\bi -\item Unambiguous -\item Highlights difficult to informally detect cases -\item Checking for completeness and consistency -\item Amenable to tool support -\ei -\item Advantage of both - all of the above advantages -\item Disadvantages - have to maintain two specs -\item Automatic translation -\bi -\item Formal spec to natural language has been - researched -\item Natural language to formal spec has received more attention -\ei -\ei -} -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - \begin{frame} \frametitle{English and Mathematics as Languages}