diff options
| author | 2026-11-08 04:29:28 +0000 | |
|---|---|---|
| committer | 2026-11-08 04:29:28 +0000 | |
| commit | 44e725659b941682c621a2fd9309ab4acc8ab199 (patch) | |
| tree | d6f8ff36b790a0b1b77688d488a88859d20a9ec1 /doc | |
| download | lab-04-44e725659b941682c621a2fd9309ab4acc8ab199.tar.gz | |
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/biblio.bib | 13 | ||||
| -rw-r--r-- | doc/gost/gost-7-32-bibliography.sty | 57 | ||||
| -rw-r--r-- | doc/gost/gost-7-32-captions.sty | 28 | ||||
| -rw-r--r-- | doc/gost/gost-7-32-counters.sty | 44 | ||||
| -rw-r--r-- | doc/gost/gost-7-32-headings.sty | 106 | ||||
| -rw-r--r-- | doc/gost/gost-7-32-lists.sty | 17 | ||||
| -rw-r--r-- | doc/gost/gost-7-32-tables.sty | 29 | ||||
| -rw-r--r-- | doc/gost/gost-7-32-toc.sty | 34 | ||||
| -rw-r--r-- | doc/gost/gost-7-32.cls | 63 | ||||
| -rw-r--r-- | doc/ox-init.el | 30 | ||||
| -rw-r--r-- | doc/report.org | 235 | ||||
| -rw-r--r-- | doc/setup.org | 24 | ||||
| -rw-r--r-- | doc/spbstu-report.cls | 74 |
13 files changed, 754 insertions, 0 deletions
diff --git a/doc/biblio.bib b/doc/biblio.bib new file mode 100644 index 0000000..bfdf8b3 --- /dev/null +++ b/doc/biblio.bib | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | @article{LucianoPrichett1987, | ||
| 2 | author = {Luciano, D. and Prichett, G.}, | ||
| 3 | title = {Cryptology: From Caesar Ciphers to Public-Key Cryptosystems}, | ||
| 4 | location = {The College Mathematics Journal}, | ||
| 5 | year = 1987, | ||
| 6 | urldate = {2014-11-23} | ||
| 7 | } | ||
| 8 | |||
| 9 | @online{JuicyPixels, | ||
| 10 | title = {Hackage -- JuicyPixels: Picture loading/serialization}, | ||
| 11 | url = {https://hackage.haskell.org/package/JuicyPixels}, | ||
| 12 | urldate = {2014-11-23} | ||
| 13 | } | ||
diff --git a/doc/gost/gost-7-32-bibliography.sty b/doc/gost/gost-7-32-bibliography.sty new file mode 100644 index 0000000..dca60fa --- /dev/null +++ b/doc/gost/gost-7-32-bibliography.sty | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | \ProvidesPackage{gost-7-32-bibliography}[2022/01/28 GOST 7.32-2017] | ||
| 2 | |||
| 3 | \def\UrlBreaks{\do\/\do-} | ||
| 4 | \RequirePackage{url} | ||
| 5 | |||
| 6 | \newdimen\bibindent | ||
| 7 | \renewenvironment{thebibliography}[1]{ | ||
| 8 | \chapter*{\bibname}\addcontentsline{toc}{chapter}{\bibname}% | ||
| 9 | \list{\@biblabel{\@arabic\c@enumiv}}% | ||
| 10 | {\settowidth\labelwidth{\@biblabel{#1}}% | ||
| 11 | \leftmargin\labelwidth | ||
| 12 | \advance\leftmargin\labelsep | ||
| 13 | \@openbib@code | ||
| 14 | \usecounter{enumiv}% | ||
| 15 | \let\p@enumiv\@empty | ||
| 16 | \renewcommand\theenumiv{\@arabic\c@enumiv}}% | ||
| 17 | \sloppy\clubpenalty4000\widowpenalty4000% | ||
| 18 | \sfcode`\.\@m | ||
| 19 | }{ | ||
| 20 | \setcounter{totalbib}{\c@enumiv}% | ||
| 21 | \def\@noitemerr | ||
| 22 | {\@latex@warning{Empty `thebibliography' environment}}% | ||
| 23 | \endlist | ||
| 24 | } | ||
| 25 | \renewcommand\@biblabel{}% | ||
| 26 | \setlength\bibindent{1.5em} | ||
| 27 | |||
| 28 | % Точки после номеров в библиографии. Несовместимо с natbib! -- Коротков И. | ||
| 29 | %\makeatletter | ||
| 30 | \renewcommand*{\@biblabel}[1]{\hfill#1.} | ||
| 31 | |||
| 32 | |||
| 33 | % | ||
| 34 | % Remove References header completely | ||
| 35 | % Stolen from original article.cls | ||
| 36 | % | ||
| 37 | \makeatletter | ||
| 38 | \renewenvironment{thebibliography}[1]{% | ||
| 39 | % \usection{\refname}% | ||
| 40 | % \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}% | ||
| 41 | \list{\@biblabel{\@arabic\c@enumiv}}% | ||
| 42 | {\settowidth\labelwidth{\@biblabel{#1}}% | ||
| 43 | \leftmargin\labelwidth | ||
| 44 | \advance\leftmargin\labelsep | ||
| 45 | \@openbib@code | ||
| 46 | \usecounter{enumiv}% | ||
| 47 | \let\p@enumiv\@empty | ||
| 48 | \renewcommand\theenumiv{\@arabic\c@enumiv}}% | ||
| 49 | \sloppy | ||
| 50 | \clubpenalty4000 | ||
| 51 | \@clubpenalty \clubpenalty | ||
| 52 | \widowpenalty4000% | ||
| 53 | \sfcode`\.\@m} | ||
| 54 | {\def\@noitemerr | ||
| 55 | {\@latex@warning{Empty `thebibliography' environment}}% | ||
| 56 | \endlist} | ||
| 57 | \makeatother | ||
diff --git a/doc/gost/gost-7-32-captions.sty b/doc/gost/gost-7-32-captions.sty new file mode 100644 index 0000000..3720026 --- /dev/null +++ b/doc/gost/gost-7-32-captions.sty | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | \ProvidesPackage{gost-7-32-captions}[2022/01/28 GOST 7.32-2017] | ||
| 2 | |||
| 3 | \RequirePackage{caption} | ||
| 4 | \RequirePackage{subcaption} | ||
| 5 | |||
| 6 | % | ||
| 7 | % Table caption aligned to the left with dash as a separator | ||
| 8 | % | ||
| 9 | \captionsetup[table]{labelsep=endash, justification=centering, singlelinecheck=off} | ||
| 10 | |||
| 11 | % | ||
| 12 | % Dash as separator in figure caption and centering | ||
| 13 | % | ||
| 14 | \captionsetup[figure]{labelsep=endash, justification=centering} | ||
| 15 | \addto\captionsrussian{\renewcommand{\figurename}{Рис.}} | ||
| 16 | |||
| 17 | % | ||
| 18 | % Listing caption | ||
| 19 | % | ||
| 20 | \captionsetup[listing]{labelsep=endash, skip=-0.5em, singlelinecheck=off, position=above} | ||
| 21 | \addto\captionsrussian{\captionsetup[listing]{name=Рис.}} | ||
| 22 | \makeatletter | ||
| 23 | \AtBeginDocument{% | ||
| 24 | \let\c@figure\c@listing | ||
| 25 | \let\thefigure\thelisting | ||
| 26 | \let\ftype@listing\ftype@figure | ||
| 27 | } | ||
| 28 | \makeatother | ||
diff --git a/doc/gost/gost-7-32-counters.sty b/doc/gost/gost-7-32-counters.sty new file mode 100644 index 0000000..ee95480 --- /dev/null +++ b/doc/gost/gost-7-32-counters.sty | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | \ProvidesPackage{gost-7-32-counters}[2022/01/29 GOST 7.32-2017] | ||
| 2 | |||
| 3 | % | ||
| 4 | % Values for capital russian letters counter | ||
| 5 | % | ||
| 6 | \makeatletter | ||
| 7 | \newcommand\AlphRus[1]{% | ||
| 8 | \expandafter \@AlphRus \csname c@#1\endcsname | ||
| 9 | } | ||
| 10 | |||
| 11 | \newcommand\@AlphRus[1]{% | ||
| 12 | \ifcase #1% | ||
| 13 | \or А\or Б\or В\or Г\or Д\or Е\or Ж\or И\or К\or | ||
| 14 | Л\or М\or Н\or П\or Р\or С\or Т\or У\or Ф\or | ||
| 15 | Х\or Ц\or Ш\or Щ\or Э\or Ю\or Я% | ||
| 16 | \else \@ctrerr | ||
| 17 | \fi | ||
| 18 | } | ||
| 19 | \makeatother | ||
| 20 | |||
| 21 | % | ||
| 22 | % Values for lowercase russian letters counter | ||
| 23 | % | ||
| 24 | \makeatletter | ||
| 25 | \newcommand\alphRus[1]{% | ||
| 26 | \expandafter \@alphRus \csname c@#1\endcsname | ||
| 27 | } | ||
| 28 | |||
| 29 | \newcommand\@alphRus[1]{% | ||
| 30 | \ifcase #1% | ||
| 31 | \or а\or б\or в\or г\or д\or е\or ж\or и\or к\or | ||
| 32 | л\or м\or н\or п\or р\or с\or т\or у\or ф\or | ||
| 33 | х\or ц\or ш\or щ\or э\or ю\or я% | ||
| 34 | \else \@ctrerr | ||
| 35 | \fi | ||
| 36 | } | ||
| 37 | \makeatother | ||
| 38 | |||
| 39 | % Increment figure counter when using lstlisting | ||
| 40 | % \let\oldlstlisting\lstlisting | ||
| 41 | % \renewcommand{\lstlisting}[1][]{% | ||
| 42 | % \refstepcounter{figure} | ||
| 43 | % \oldlstlisting[#1] | ||
| 44 | % } | ||
diff --git a/doc/gost/gost-7-32-headings.sty b/doc/gost/gost-7-32-headings.sty new file mode 100644 index 0000000..033f4a8 --- /dev/null +++ b/doc/gost/gost-7-32-headings.sty | |||
| @@ -0,0 +1,106 @@ | |||
| 1 | \ProvidesPackage{gost-7-32-headings}[2022/01/28 GOST 7.32-2017] | ||
| 2 | |||
| 3 | \RequirePackage{titlesec} | ||
| 4 | \RequirePackage{titling} | ||
| 5 | \RequirePackage{setspace} | ||
| 6 | |||
| 7 | \RequirePackage{gost-7-32-counters} | ||
| 8 | |||
| 9 | % | ||
| 10 | % Set custom formatting to well-known LaTeX commands: section, subsection and subsubsection | ||
| 11 | % | ||
| 12 | \titleformat{\section}[block]{\centering\large\setstretch{1}\bfseries}{\thesection}{0.5em}{} | ||
| 13 | \titlespacing*{\section}{0cm}{0cm}{0.5cm} | ||
| 14 | \newcommand{\sectionbreak}{\clearpage} | ||
| 15 | |||
| 16 | \titleformat{\subsection}[block]{\normalsize\bfseries}{\thesubsection}{0.5em}{} | ||
| 17 | \titlespacing{\subsection}{0cm}{0.5cm}{0.5cm} | ||
| 18 | |||
| 19 | \titleformat{\subsubsection}[runin]{\normalsize\bfseries}{\thesubsubsection}{0.5em}{}[\newline\indent] | ||
| 20 | \titlespacing{\subsubsection}{1.25cm}{0.5em}{0cm} | ||
| 21 | |||
| 22 | \makeatletter | ||
| 23 | \let\oldsection\section | ||
| 24 | \newcommand{\@sectionnostar}[1]{\phantomsection\oldsection*{#1}\addcontentsline{toc}{section}{#1}} | ||
| 25 | \newcommand{\@sectionstar}[1]{\oldsection{#1}} | ||
| 26 | \renewcommand{\section}{\sectionbreak\@ifstar{\@sectionnostar}{\@sectionstar}} | ||
| 27 | \makeatother | ||
| 28 | |||
| 29 | % | ||
| 30 | % Make special headings, that have their own formatting rules: | ||
| 31 | % - centered | ||
| 32 | % - all-caps | ||
| 33 | % - bold | ||
| 34 | % | ||
| 35 | % Only three of them must appear in TOC: introduction, conclusion and references | ||
| 36 | % | ||
| 37 | \newcommand{\introduction}{ | ||
| 38 | \addcontentsline{toc}{section}{ВВЕДЕНИЕ} | ||
| 39 | \begin{center} | ||
| 40 | \bfseries\large | ||
| 41 | ВВЕДЕНИЕ | ||
| 42 | \end{center} | ||
| 43 | } | ||
| 44 | |||
| 45 | \newcommand{\conclusion}{ | ||
| 46 | \addcontentsline{toc}{section}{ЗАКЛЮЧЕНИЕ} | ||
| 47 | \begin{center} | ||
| 48 | \bfseries\large | ||
| 49 | ЗАКЛЮЧЕНИЕ | ||
| 50 | \end{center} | ||
| 51 | } | ||
| 52 | |||
| 53 | \newcommand{\references}{ | ||
| 54 | \addcontentsline{toc}{section}{СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ} | ||
| 55 | \begin{center} | ||
| 56 | \bfseries\large | ||
| 57 | СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ | ||
| 58 | \end{center} | ||
| 59 | } | ||
| 60 | |||
| 61 | \newcommand{\essay}{ | ||
| 62 | \begin{center} | ||
| 63 | \bfseries\large | ||
| 64 | РЕФЕРАТ | ||
| 65 | \end{center} | ||
| 66 | } | ||
| 67 | |||
| 68 | \newcommand{\definitions}{ | ||
| 69 | \begin{center} | ||
| 70 | \bfseries\large | ||
| 71 | ОПРЕДЕЛЕНИЯ | ||
| 72 | \end{center} | ||
| 73 | } | ||
| 74 | |||
| 75 | \newcommand{\abbreviations}{ | ||
| 76 | \begin{center} | ||
| 77 | \bfseries\large | ||
| 78 | ОБОЗНАЧЕНИЯ И СОКРАЩЕНИЯ | ||
| 79 | \end{center} | ||
| 80 | } | ||
| 81 | |||
| 82 | \newcommand{\defsabbrs}{ | ||
| 83 | \begin{center} | ||
| 84 | \bfseries\large | ||
| 85 | ОПРЕДЕЛЕНИЯ, ОБОЗНАЧЕНИЯ И СОКРАЩЕНИЯ | ||
| 86 | \end{center} | ||
| 87 | } | ||
| 88 | |||
| 89 | % | ||
| 90 | % Appendices headings. Appendices have autoincrementing number, | ||
| 91 | % that is represented with russian letter. | ||
| 92 | % This heading must appear in TOC | ||
| 93 | % | ||
| 94 | \newcounter{appendixcnt} | ||
| 95 | \setcounter{appendixcnt}{1} | ||
| 96 | |||
| 97 | \renewcommand{\appendix}[1]{ | ||
| 98 | \addcontentsline{toc}{section}{ПРИЛОЖЕНИЕ \AlphRus{appendixcnt}. #1} | ||
| 99 | \begin{center} | ||
| 100 | \bfseries\large | ||
| 101 | ПРИЛОЖЕНИЕ \AlphRus{appendixcnt} | ||
| 102 | |||
| 103 | #1 | ||
| 104 | \end{center} | ||
| 105 | \stepcounter{appendixcnt} | ||
| 106 | } | ||
diff --git a/doc/gost/gost-7-32-lists.sty b/doc/gost/gost-7-32-lists.sty new file mode 100644 index 0000000..6f41980 --- /dev/null +++ b/doc/gost/gost-7-32-lists.sty | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | \ProvidesPackage{gost-7-32-lists}[2022/01/28 GOST 7.32-2017] | ||
| 2 | |||
| 3 | \RequirePackage{enumitem} | ||
| 4 | \RequirePackage{gost-7-32-counters} | ||
| 5 | |||
| 6 | \AddEnumerateCounter*{\alphRus}{\c@alphRus}{1} | ||
| 7 | |||
| 8 | \setlist{nosep} | ||
| 9 | \setlist[itemize, 1]{label=\textendash} | ||
| 10 | \setlist[itemize, 2]{label=\bullet} | ||
| 11 | \setlist[itemize, 3]{label=\bullet} | ||
| 12 | |||
| 13 | \setlist[enumerate, 2]{label=\alphRus*)} | ||
| 14 | |||
| 15 | \setlist[1]{wide=\parindent} | ||
| 16 | \setlist[2]{wide=2\parindent, leftmargin=\parindent} | ||
| 17 | \setlist[3]{wide=2\parindent} | ||
diff --git a/doc/gost/gost-7-32-tables.sty b/doc/gost/gost-7-32-tables.sty new file mode 100644 index 0000000..750ab75 --- /dev/null +++ b/doc/gost/gost-7-32-tables.sty | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | \ProvidesPackage{gost-7-32-tables}[2022/01/28 GOST 7.32-2017] | ||
| 2 | |||
| 3 | \RequirePackage{tabularx} | ||
| 4 | |||
| 5 | % | ||
| 6 | % Center-aligned column with automatic width | ||
| 7 | % | ||
| 8 | \newcolumntype{Y}{>{\centering\arraybackslash}X} | ||
| 9 | |||
| 10 | % | ||
| 11 | % Right-aligned column with automatic width | ||
| 12 | % | ||
| 13 | \newcolumntype{Z}{>{\raggedleft\arraybackslash}X} | ||
| 14 | |||
| 15 | % | ||
| 16 | % Table with designations | ||
| 17 | % | ||
| 18 | \newenvironment{designations}{ | ||
| 19 | \noindent | ||
| 20 | \tabularx{\textwidth}{@{} | ||
| 21 | >{\raggedright \arraybackslash \hsize=0.25\hsize}X | ||
| 22 | >{\centering \arraybackslash \hsize=0.05\hsize}X | ||
| 23 | >{\arraybackslash \hsize=0.70\hsize}X | ||
| 24 | } | ||
| 25 | }{ | ||
| 26 | \endtabularx | ||
| 27 | } | ||
| 28 | |||
| 29 | \newcommand{\designation}[2]{#1 &---& #2. \\} | ||
diff --git a/doc/gost/gost-7-32-toc.sty b/doc/gost/gost-7-32-toc.sty new file mode 100644 index 0000000..328079d --- /dev/null +++ b/doc/gost/gost-7-32-toc.sty | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | \ProvidesPackage{gost-7-32-toc}[2022/01/28 GOST 7.32-2017] | ||
| 2 | |||
| 3 | \RequirePackage{tocloft} | ||
| 4 | \RequirePackage[ | ||
| 5 | bookmarks=true, | ||
| 6 | colorlinks=true, | ||
| 7 | unicode=true, | ||
| 8 | urlcolor=black, | ||
| 9 | linkcolor=black, | ||
| 10 | anchorcolor=black, | ||
| 11 | citecolor=black, | ||
| 12 | menucolor=black, | ||
| 13 | filecolor=black, | ||
| 14 | hidelinks | ||
| 15 | ]{hyperref} | ||
| 16 | |||
| 17 | % | ||
| 18 | % Set custom font styles | ||
| 19 | % | ||
| 20 | \renewcommand{\cftsecfont}{\normalfont} | ||
| 21 | \renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}} | ||
| 22 | \renewcommand{\cftsecpagefont}{\normalsize} | ||
| 23 | \renewcommand{\cftaftertoctitle}{\hfill\hfill} | ||
| 24 | \renewcommand{\cfttoctitlefont}{\hfill\normalfont\large\bfseries} | ||
| 25 | \titleformat{\tableofcontents}[block]{\centering\large\bfseries}{\thesection}{0.5em}{} | ||
| 26 | \titlespacing{\tableofcontents}{0cm}{0cm}{1cm} | ||
| 27 | |||
| 28 | % | ||
| 29 | % Set indents and line spacing | ||
| 30 | % | ||
| 31 | \setlength{\cftbeforesecskip}{0cm} | ||
| 32 | \setlength{\cftbeforesubsecskip}{0cm} | ||
| 33 | \setlength{\cftbeforesubsubsecskip}{0cm} | ||
| 34 | \setlength{\cftbeforeparaskip}{0cm} | ||
diff --git a/doc/gost/gost-7-32.cls b/doc/gost/gost-7-32.cls new file mode 100644 index 0000000..5cfca06 --- /dev/null +++ b/doc/gost/gost-7-32.cls | |||
| @@ -0,0 +1,63 @@ | |||
| 1 | % https://github.com/weterans/gost | ||
| 2 | \NeedsTeXFormat{LaTeX2e} | ||
| 3 | \ProvidesClass{gost-7-32}[2022/01/28 GOST 7.32-2017] | ||
| 4 | |||
| 5 | % | ||
| 6 | % Supported font sizes: 12pt, 14pt | ||
| 7 | % | ||
| 8 | \DeclareOption{12pt}{\PassOptionsToClass{\CurrentOption}{extarticle}} | ||
| 9 | \DeclareOption{14pt}{\PassOptionsToClass{\CurrentOption}{extarticle}} | ||
| 10 | |||
| 11 | \ProcessOptions\relax | ||
| 12 | |||
| 13 | % | ||
| 14 | % Set A4 paper format | ||
| 15 | % | ||
| 16 | \LoadClass[a4paper]{extarticle} | ||
| 17 | |||
| 18 | % | ||
| 19 | % Use 1.5 line spacing | ||
| 20 | % | ||
| 21 | \RequirePackage{setspace} | ||
| 22 | \spacing{1.5} | ||
| 23 | |||
| 24 | % | ||
| 25 | % First paragraph indentation | ||
| 26 | % | ||
| 27 | \RequirePackage{indentfirst} | ||
| 28 | \setlength{\parindent}{12.5mm} | ||
| 29 | |||
| 30 | % | ||
| 31 | % Page margin | ||
| 32 | % | ||
| 33 | \RequirePackage[ | ||
| 34 | left=2.5cm, | ||
| 35 | right=2cm, | ||
| 36 | top=2cm, | ||
| 37 | bottom=2cm, | ||
| 38 | footskip=1cm, | ||
| 39 | ]{geometry} | ||
| 40 | |||
| 41 | % | ||
| 42 | % Use TMR-like font | ||
| 43 | % | ||
| 44 | \RequirePackage{fontspec} | ||
| 45 | \RequirePackage{xunicode} | ||
| 46 | \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase,Mapping=tex-text} | ||
| 47 | \setmainfont{Times New Roman} | ||
| 48 | |||
| 49 | % | ||
| 50 | % Use russian language | ||
| 51 | % | ||
| 52 | \RequirePackage[main=russian, english]{babel} | ||
| 53 | \babelhyphenation[russian]{} | ||
| 54 | |||
| 55 | % | ||
| 56 | % gost-7-32 packages | ||
| 57 | % | ||
| 58 | \RequirePackage{gost-7-32-headings} | ||
| 59 | \RequirePackage{gost-7-32-toc} | ||
| 60 | \RequirePackage{gost-7-32-lists} | ||
| 61 | % \RequirePackage{gost-7-32-bibliography} | ||
| 62 | \RequirePackage{gost-7-32-captions} | ||
| 63 | \RequirePackage{gost-7-32-tables} | ||
diff --git a/doc/ox-init.el b/doc/ox-init.el new file mode 100644 index 0000000..a7cfed5 --- /dev/null +++ b/doc/ox-init.el | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | ;;; ox-init.el --- Initialization script for async org exprort session | ||
| 2 | ;;; Commentary: | ||
| 3 | ;;; Code: | ||
| 4 | (org-babel-do-load-languages | ||
| 5 | 'org-babel-load-languages | ||
| 6 | '((latex . t) | ||
| 7 | (haskell . t))) | ||
| 8 | |||
| 9 | (require 'ox-extra) | ||
| 10 | (ox-extras-activate '(ignore-headlines)) | ||
| 11 | |||
| 12 | (setq org-latex-src-block-backend 'minted) | ||
| 13 | |||
| 14 | (require 'oc-bibtex) | ||
| 15 | (setq org-latex-bib-compiler "biber") | ||
| 16 | |||
| 17 | (setq org-latex-remove-logfiles nil) | ||
| 18 | |||
| 19 | (setq org-latex-caption-above '(table src-block special-block)) | ||
| 20 | |||
| 21 | (setq org-latex-pdf-process '("%latex -shell-escape -interaction nonstopmode -output-directory %o %f" | ||
| 22 | "%bib %b" | ||
| 23 | "%latex -shell-escape -interaction nonstopmode -output-directory %o %f")) | ||
| 24 | (setq org-latex-classes '(("spbstu-report" "\\documentclass[12pt]{spbstu-report}" | ||
| 25 | ("\\section{%s}" . "\\section*{%s}") | ||
| 26 | ("\\subsection{%s}" . "\\subsection*{%s}") | ||
| 27 | ("\\subsubsection{%s}" . "\\subsubsection*{%s}") | ||
| 28 | ("\\paragraph{%s}" . "\\paragraph*{%s}") | ||
| 29 | ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))) | ||
| 30 | ;;; ox-init.el ends here | ||
diff --git a/doc/report.org b/doc/report.org new file mode 100644 index 0000000..101ec1e --- /dev/null +++ b/doc/report.org | |||
| @@ -0,0 +1,235 @@ | |||
| 1 | #+title: Тестирование в Haskell | ||
| 2 | #+author: Михалец М. | ||
| 3 | #+latex_header: \reportof{О ВЫПОЛНЕНИИ ЛАБОРАТОРНОЙ РАБОТЫ №4} | ||
| 4 | #+latex_header: \subject{по дисциплине «Функциональное программирование»} | ||
| 5 | #+latex_header: \university{Федеральное государственное автономное образовательное учреждение высшего образования \enquote{Санкт-Петербургский политехнический университет Петра Великого}} | ||
| 6 | #+latex_header: \institute{Институт компьютерных наук и кибербезопасности} | ||
| 7 | #+latex_header: \school{Высшая школа технологии искусственного интеллекта} | ||
| 8 | #+latex_header: \direction{02.03.01 Математика и компьютерные науки} | ||
| 9 | #+latex_header: \reviewertitle{}\reviewer{Моторин Д.Е.} | ||
| 10 | #+latex_header: \city{Санкт-Петербург} | ||
| 11 | #+date: 2024 | ||
| 12 | |||
| 13 | #+setupfile: setup.org | ||
| 14 | #+latex: \sloppy | ||
| 15 | |||
| 16 | * ВВЕДЕНИЕ | ||
| 17 | :PROPERTIES: | ||
| 18 | :UNNUMBERED: t | ||
| 19 | :END: | ||
| 20 | В данном отчете, описана реализация и результаты тестирования | ||
| 21 | ~QuickCheck~. Тестирование реализовано для двух заданных математических | ||
| 22 | функций, на проверку их свойств. Все тесты были записаны в =Spec.hs=. | ||
| 23 | |||
| 24 | Ограничения: | ||
| 25 | - Функции нужно записать в библиотеку =Lib.hs= и ограничить доступ к | ||
| 26 | вспомогательным функциям. | ||
| 27 | |||
| 28 | * Постановка задачи | ||
| 29 | Для реализации данной лабораторной работы, необходимо создать проект в | ||
| 30 | =stack=. В проекте =stack=, есть директория =tests=, в которой есть файл | ||
| 31 | =Spec.hs=, где можно так же прописать ~main~, для вывода результатов | ||
| 32 | тестирования. Необходимо проверить две функции: | ||
| 33 | 1. ~isCongruent :: Int -> Int -> Int -> Bool~ | ||
| 34 | 2. ~zipWithSum :: [Int] -> [Int] -> [Int]~ | ||
| 35 | |||
| 36 | ** ~isCongruent :: Int -> Int -> Int -> Bool Int -> Bool~ | ||
| 37 | Функция проверки равенства по модулю ~isCongruent :: Int -> Int -> Int | ||
| 38 | -> Bool Int -> Bool~ --- проверяет, равны ли два числа по модулю | ||
| 39 | третьего числа. | ||
| 40 | |||
| 41 | Используя ~QuickCheck~, проверьте следующие свойства: | ||
| 42 | 1. Если два числа равны по модулю, то их разность делится на модуль: | ||
| 43 | - ~isCongruent a b m == (modulus (a - b) m == 0)~. | ||
| 44 | 2. Равенство по модулю является симметричным: | ||
| 45 | - ~isCongruent a b m == isCongruent b a m~. | ||
| 46 | 3. Если одно число равно другому, то они равны по любому модулю: | ||
| 47 | - если a = b, то ~isCongruent a b m == True~. | ||
| 48 | |||
| 49 | ** ~zipWithSum :: [Int] -> [Int] -> [Int]~ | ||
| 50 | функция ~zipWithSum :: [Int] -> [Int] -> [Int]~ --- принимает два списка | ||
| 51 | целых чисел и возвращает новый список, где каждый элемент является | ||
| 52 | суммой соответствующих элементов двух списков. Если длины списков | ||
| 53 | различаются, остатки более длинного списка должны быть добавлены в | ||
| 54 | конец результата. | ||
| 55 | |||
| 56 | Используя ~QuickCheck~, проверьте следующие свойства: | ||
| 57 | 1. Длины результата равна максимальной длине входных списков: | ||
| 58 | - ~length (zipWithSum xs ys) == max (length xs) (length ys)~. | ||
| 59 | 2. Если один из списков пустой, то результат совпадает с непустым | ||
| 60 | списком: | ||
| 61 | - если ~xs~ пустой, то ~zipWithSum [] ys == ys~. | ||
| 62 | 3. Сумма элементов результата равна сумме всех элементов входных | ||
| 63 | списков: | ||
| 64 | - ~sum (zipWithSum xs ys) == sum xs + sum ys~. | ||
| 65 | |||
| 66 | * Реализация функций | ||
| 67 | Функция реализована в =Lib.hs=. | ||
| 68 | ** ~isCongruent :: Int -> Int -> Int -> Bool Int -> Bool~ | ||
| 69 | #+include: "../src/Lib.hs" src haskell :lines "6-8" | ||
| 70 | |||
| 71 | Функция проверяет равенство ~a~ и ~b~ по модулю ~m~. | ||
| 72 | |||
| 73 | Пример: | ||
| 74 | 1. ~isCongruent 2 5 3~ | ||
| 75 | 2. ~(2 `mod` 3) == (5 `mod` 3)~ | ||
| 76 | 3. ~2 == 2~ | ||
| 77 | 4. ~True~ | ||
| 78 | |||
| 79 | ** ~zipWithSum :: [Int] -> [Int] -> [Int]~ | ||
| 80 | #+include: "../src/Lib.hs" src haskell :lines "9-" | ||
| 81 | |||
| 82 | Функция принимает два списка целых чисел и возвращает новый список, | ||
| 83 | где каждый элемент является суммой соответствующих элементов двух | ||
| 84 | списков. Если длины списков различаются, остатки более длинного | ||
| 85 | списка должны быть добавлены в конец результата. | ||
| 86 | |||
| 87 | Пример: ~zipWithSum [0, 3] [1, 2, 3] == [1,5,3]~ | ||
| 88 | |||
| 89 | * Тестирование функций | ||
| 90 | В тестах необходимо проверить свойства описанные в пункте [[* Постановка | ||
| 91 | задачи]], соответственно. | ||
| 92 | |||
| 93 | Функций реализованы в =Spec.hs=. | ||
| 94 | |||
| 95 | ** ~isCongruent :: Int -> Int -> Int -> Bool Int -> Bool~ | ||
| 96 | *** ~prop_isCongruent_diffDivisible :: Int -> Int -> Int -> Property~ | ||
| 97 | #+include: "../test/Spec.hs" src haskell :lines "7-10" | ||
| 98 | |||
| 99 | Если два числа равны по модулю, то их разность делится на модуль. | ||
| 100 | |||
| 101 | ~isCongruent a b m == (modulus (a - b) m == 0)~. | ||
| 102 | |||
| 103 | *** ~prop_isCongruent_symmetry :: Int -> Int -> Int -> Property~ | ||
| 104 | #+include: "../test/Spec.hs" src haskell :lines "14-17" | ||
| 105 | |||
| 106 | Равенство по модулю является симметричным. | ||
| 107 | |||
| 108 | ~isCongruent a b m == isCongruent b a m~. | ||
| 109 | |||
| 110 | *** ~prop_isCongruent_equalAlwaysCongruent :: Int -> Int -> Property~ | ||
| 111 | #+include: "../test/Spec.hs" src haskell :lines "21-23" | ||
| 112 | |||
| 113 | Если одно число равно другому, то они равны по любому модулю. | ||
| 114 | |||
| 115 | Если $a = b$, то ~isCongruent a b m == True~. | ||
| 116 | |||
| 117 | ** ~zipWithSum :: [Int] -> [Int] -> [Int]~ | ||
| 118 | *** ~prop_zipWithSum_length :: [Int] -> [Int] -> Bool~ | ||
| 119 | #+include: "../test/Spec.hs" src haskell :lines "27-30" | ||
| 120 | |||
| 121 | Длины результата равна максимальной длине входных списков. | ||
| 122 | |||
| 123 | ~length (zipWithSum xs ys) == max (length xs) (length ys)~ | ||
| 124 | |||
| 125 | *** ~prop_zipWithSum_emptyList :: [Int] -> Bool~ | ||
| 126 | #+include: "../test/Spec.hs" src haskell :lines "35-37" | ||
| 127 | |||
| 128 | Если один из списков пустой, то результат совпадает с непустым | ||
| 129 | списком. | ||
| 130 | |||
| 131 | Если ~xs~ пустой, то ~zipWithSum [] ys == ys~. | ||
| 132 | |||
| 133 | *** ~prop_zipWithSum_sum :: [Int] -> [Int] -> Bool~ | ||
| 134 | #+include: "../test/Spec.hs" src haskell :lines "42-44" | ||
| 135 | |||
| 136 | Сумма элементов результата равна сумме всех элементов входных списков. | ||
| 137 | |||
| 138 | ~sum (zipWithSum xs ys) == sum xs + sum ys~ | ||
| 139 | |||
| 140 | ** ~main :: IO ()~ | ||
| 141 | #+include: "../test/Spec.hs" src haskell :lines "45-" | ||
| 142 | |||
| 143 | Выводит заголовки для каждой группы тестов (для функций ~isCongruent~ и | ||
| 144 | ~zipWithSum~). Вызывает ~QuickCheck~ для каждого свойства, чтобы | ||
| 145 | проверить его на большом наборе случайных данных. | ||
| 146 | |||
| 147 | Если тесты проходят, QuickCheck сообщает об успешных проверках. Если | ||
| 148 | находятся ошибки, QuickCheck выведет пример, на котором свойство | ||
| 149 | нарушается. | ||
| 150 | |||
| 151 | * Результаты тестирования | ||
| 152 | Для тестирования функций необходимо в директории папки с проектом | ||
| 153 | запустить команду: ~stack test~ | ||
| 154 | |||
| 155 | После чего увидим результаты тестов прописанных в =Spec.hs=: | ||
| 156 | #+begin_example | ||
| 157 | lab4> test (suite: lab4-test) | ||
| 158 | |||
| 159 | +++ OK, passed 100 tests; 15 discarded. | ||
| 160 | +++ OK, passed 100 tests; 12 discarded. | ||
| 161 | +++ OK, passed 100 tests; 14 discarded. | ||
| 162 | +++ OK, passed 100 tests. | ||
| 163 | +++ OK, passed 100 tests. | ||
| 164 | +++ OK, passed 100 tests. | ||
| 165 | |||
| 166 | |||
| 167 | |||
| 168 | lab4> Test suite lab4-test passed | ||
| 169 | Completed 2 action(s). | ||
| 170 | #+end_example | ||
| 171 | |||
| 172 | Здесь $N$ =discarded= --- означает, что ~QuickCheck~ сгенерировал $N$ | ||
| 173 | случайных наборов данных, которые не соответствовали условиям теста, | ||
| 174 | например, потому что $m \ne 0$ для тестов ~isCongruent~. ~QuickCheck~ | ||
| 175 | продолжает генерировать данные, пока не наберёт достаточно случаев, | ||
| 176 | которые проходят проверку условия. | ||
| 177 | |||
| 178 | #+latex: \clearpage | ||
| 179 | |||
| 180 | Чтобы доказать, что тесты реально проверяются, введём изменения, | ||
| 181 | которые прекратят выполнение исключительно одного теста, допустим | ||
| 182 | ~prop_zipWithSum_sum~: | ||
| 183 | #+attr_latex: :options linenos=false | ||
| 184 | #+begin_src haskell | ||
| 185 | zipWithSum (x:xs) (y:ys) = (x + y + 1) : zipWithSum xs ys | ||
| 186 | #+end_src | ||
| 187 | Здесь мы дополнительно добавляем к сумме единицу, что помещает | ||
| 188 | исключительно одному тесту, так как только одно из свойств смотрит на | ||
| 189 | значения обрабатываемых списков. | ||
| 190 | |||
| 191 | После запуска проверки мы получает следующий результат: | ||
| 192 | #+begin_example | ||
| 193 | lab4> test (suite: lab4-test) | ||
| 194 | |||
| 195 | +++ OK, passed 100 tests; 11 discarded. | ||
| 196 | +++ OK, passed 100 tests; 12 discarded. | ||
| 197 | +++ OK, passed 100 tests; 12 discarded. | ||
| 198 | +++ OK, passed 100 tests. | ||
| 199 | +++ OK, passed 100 tests. | ||
| 200 | ,*** Failed! Falsified (after 3 tests and 2 shrinks): | ||
| 201 | [0] | ||
| 202 | [0] | ||
| 203 | |||
| 204 | |||
| 205 | |||
| 206 | lab4> Test suite lab4-test passed | ||
| 207 | Completed 2 action(s). | ||
| 208 | #+end_example | ||
| 209 | |||
| 210 | * ЗАКЛЮЧЕНИЕ | ||
| 211 | :PROPERTIES: | ||
| 212 | :UNNUMBERED: t | ||
| 213 | :END: | ||
| 214 | В результате выполнения данной лабораторной работы, были изучены | ||
| 215 | основы тестирования ПО, на языке Haskell, с использованием библиотеки | ||
| 216 | ~QuickCheck~ написанный в stack проекте в =Spec.hs=. | ||
| 217 | |||
| 218 | Были протестированы две функции на их свойства: | ||
| 219 | 1. ~isCongruent :: Int -> Int -> Int -> Bool Int -> Bool~ | ||
| 220 | 2. ~zipWithSum :: [Int] -> [Int] -> [Int]~ | ||
| 221 | |||
| 222 | В ходе тестирования, обе функции «прошли» все тесты. Что подтверждает | ||
| 223 | корректность свойств функций в нашей программе. | ||
| 224 | |||
| 225 | # * СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ | ||
| 226 | # :PROPERTIES: | ||
| 227 | # :UNNUMBERED: t | ||
| 228 | # :END: | ||
| 229 | # #+print_bibliography: :heading none | ||
| 230 | |||
| 231 | # Local Variables: | ||
| 232 | # org-confirm-babel-evaluate: nil | ||
| 233 | # org-export-async-init-file: "ox-init.el" | ||
| 234 | # org-export-in-background: t | ||
| 235 | # End: | ||
diff --git a/doc/setup.org b/doc/setup.org new file mode 100644 index 0000000..2daa8e8 --- /dev/null +++ b/doc/setup.org | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | #+options: ':nil *:t -:t ::t <:t H:3 \n:nil ^:{} arch:headline | ||
| 2 | #+options: author:t broken-links:nil c:nil creator:nil | ||
| 3 | #+options: d:(not "LOGBOOK") date:t e:t email:nil f:t inline:f num:t | ||
| 4 | #+options: p:nil pri:nil prop:nil stat:f tags:f tasks:f tex:t | ||
| 5 | #+options: timestamp:nil title:t toc:t todo:t |:t | ||
| 6 | #+creator: Emacs 29.4 (Org mode 9.7.14) | ||
| 7 | |||
| 8 | #+select_tags: export | ||
| 9 | #+exclude_tags: noexport | ||
| 10 | |||
| 11 | #+bibliography: biblio.bib | ||
| 12 | #+cite_export: biblatex | ||
| 13 | |||
| 14 | #+latex_compiler: xelatex | ||
| 15 | #+latex_class: spbstu-report | ||
| 16 | # #+latex_class_options: [draft] | ||
| 17 | #+latex_header: \usepackage{enumitem} | ||
| 18 | #+latex_header: \usepackage[newfloat]{minted} | ||
| 19 | #+latex_header: \usemintedstyle{bw} | ||
| 20 | #+latex_header: \setminted{baselinestretch=1,linenos,breaklines,escapeinside=\#\#,ignorelexererrors} | ||
| 21 | #+latex_header: \renewcommand\theFancyVerbLine{\large\arabic{FancyVerbLine}} | ||
| 22 | #+latex_header: \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase,Mapping=tex-text} | ||
| 23 | #+latex_header: \setmainfont{Times New Roman} | ||
| 24 | #+latex_header: \setmonofont{Iosevka Term Slab}[Contextuals=AlternateOff] | ||
diff --git a/doc/spbstu-report.cls b/doc/spbstu-report.cls new file mode 100644 index 0000000..7ae6b05 --- /dev/null +++ b/doc/spbstu-report.cls | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | \NeedsTeXFormat{LaTeX2e} | ||
| 2 | \ProvidesClass{spbstu-report}[2023/05/12 Класс для отчетов] | ||
| 3 | |||
| 4 | % | ||
| 5 | % Support font sizes: 12pt, 14pt | ||
| 6 | % | ||
| 7 | \DeclareOption{12pt}{\PassOptionsToClass{\CurrentOption}{extarticle}} | ||
| 8 | \DeclareOption{14pt}{\PassOptionsToClass{\CurrentOption}{extarticle}} | ||
| 9 | |||
| 10 | \ProcessOptions\relax | ||
| 11 | |||
| 12 | \LoadClass[a4paper]{gost-7-32} | ||
| 13 | |||
| 14 | \RequirePackage{csquotes} | ||
| 15 | \RequirePackage{amsmath} | ||
| 16 | \RequirePackage{adjustbox} | ||
| 17 | \RequirePackage{setspace} | ||
| 18 | |||
| 19 | \newcommand{\@reportof}{}\newcommand{\reportof}[1]{\renewcommand{\@reportof}{#1}} | ||
| 20 | \newcommand{\@university}{}\newcommand{\university}[1]{\renewcommand{\@university}{#1}} | ||
| 21 | \newcommand{\@institute}{}\newcommand{\institute}[1]{\renewcommand{\@institute}{#1}} | ||
| 22 | \newcommand{\@school}{}\newcommand{\school}[1]{\renewcommand{\@school}{#1}} | ||
| 23 | \newcommand{\@direction}{}\newcommand{\direction}[1]{\renewcommand{\@direction}{#1}} | ||
| 24 | \newcommand{\@subject}{}\newcommand{\subject}[1]{\renewcommand{\@subject}{#1}} | ||
| 25 | \newcommand{\@reviewer}{}\newcommand{\reviewer}[1]{\renewcommand{\@reviewer}{#1}} | ||
| 26 | \newcommand{\@reviewertitle}{}\newcommand{\reviewertitle}[1]{\renewcommand{\@reviewertitle}{#1}} | ||
| 27 | \newcommand{\signdate}{$\underset{\centering\text{\normalsize подпись, дата}}{\underline{\hspace{5cm}}}$} | ||
| 28 | \newcommand{\@city}{}\newcommand{\city}[1]{\renewcommand{\@city}{#1}} | ||
| 29 | \renewcommand{\maketitle}{ | ||
| 30 | \begin{titlepage} | ||
| 31 | \begin{center} | ||
| 32 | \vspace{2cm} | ||
| 33 | \small{МИНИСТЕРСТВО НАУКИ И ВЫСШЕГО ОБРАЗОВАНИЯ РОССИЙСКОЙ ФЕДЕРАЦИИ} | ||
| 34 | |||
| 35 | \normalsize{\@university} | ||
| 36 | |||
| 37 | \vspace{0.5cm} | ||
| 38 | \normalsize{\@institute} | ||
| 39 | |||
| 40 | \normalsize{\@school} | ||
| 41 | |||
| 42 | \normalsize{Направление \@direction} | ||
| 43 | |||
| 44 | \vspace{2cm} | ||
| 45 | \LARGE{ОТЧЁТ} | ||
| 46 | |||
| 47 | \normalsize{\@reportof} | ||
| 48 | |||
| 49 | \large{\@subject} | ||
| 50 | |||
| 51 | \large{\textit{\@title}} | ||
| 52 | \end{center} | ||
| 53 | |||
| 54 | \vspace{3cm} | ||
| 55 | \small{ | ||
| 56 | \begin{tabular}{lrrl} | ||
| 57 | \!\!\!Студент, & \hspace{2cm} & & \\ | ||
| 58 | \!\!\!группы 5130201/20102 & \hspace{2cm} & \underline{\hspace{3cm}} & \@author \\\\ | ||
| 59 | \!\!\!Преподаватель, & \hspace{2cm} & \\ | ||
| 60 | \!\!\!\@reviewertitle & \hspace{2cm} & \underline{\hspace{3cm}} & \@reviewer \\\\ | ||
| 61 | &&\hspace{5cm} | ||
| 62 | \end{tabular} | ||
| 63 | \begin{flushright} | ||
| 64 | \enquote{\underline{\hspace{1cm}}}\underline{\hspace{2.5cm}} \@date г. | ||
| 65 | \end{flushright} | ||
| 66 | } | ||
| 67 | |||
| 68 | \vspace*{\fill} | ||
| 69 | \begin{center} | ||
| 70 | \small{\@city, \@date} | ||
| 71 | \end{center} | ||
| 72 | \end{titlepage} | ||
| 73 | \setcounter{page}{2} | ||
| 74 | } | ||
