From 5be0e39d0ce97849d7722bd1ac98563c7014faf3 Mon Sep 17 00:00:00 2001 From: Martin Michalec Date: Sun, 8 Nov 2026 11:19:44 +0300 Subject: publish --- doc/biblio.bib | 13 + doc/gost/gost-7-32-bibliography.sty | 57 +++ doc/gost/gost-7-32-captions.sty | 23 ++ doc/gost/gost-7-32-counters.sty | 44 +++ doc/gost/gost-7-32-headings.sty | 114 ++++++ doc/gost/gost-7-32-lists.sty | 17 + doc/gost/gost-7-32-tables.sty | 29 ++ doc/gost/gost-7-32-toc.sty | 34 ++ doc/gost/gost-7-32.cls | 62 +++ doc/ox-init.el | 31 ++ doc/report.org | 763 ++++++++++++++++++++++++++++++++++++ doc/setup.org | 32 ++ doc/spbstu-report.cls | 74 ++++ 13 files changed, 1293 insertions(+) create mode 100644 doc/biblio.bib create mode 100644 doc/gost/gost-7-32-bibliography.sty create mode 100644 doc/gost/gost-7-32-captions.sty create mode 100644 doc/gost/gost-7-32-counters.sty create mode 100644 doc/gost/gost-7-32-headings.sty create mode 100644 doc/gost/gost-7-32-lists.sty create mode 100644 doc/gost/gost-7-32-tables.sty create mode 100644 doc/gost/gost-7-32-toc.sty create mode 100644 doc/gost/gost-7-32.cls create mode 100644 doc/ox-init.el create mode 100644 doc/report.org create mode 100644 doc/setup.org create mode 100644 doc/spbstu-report.cls (limited to 'doc') diff --git a/doc/biblio.bib b/doc/biblio.bib new file mode 100644 index 0000000..cc53e65 --- /dev/null +++ b/doc/biblio.bib @@ -0,0 +1,13 @@ +@book{WOLFRAM2002, +author = {Стивен Вольфрам}, +title = {Наука нового типа}, +publisher = {Wolfram Media}, +year = {2002}, +pages = {1197} +} +@online{VOSTROV2024, +author = {Востров А. В}, +title = {Теория алгоритмов}, +url = {https://tema.spbstu.ru/algorithm/}, +urldate = {2024-12-01} +} 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 @@ +\ProvidesPackage{gost-7-32-bibliography}[2022/01/28 GOST 7.32-2017] + +\def\UrlBreaks{\do\/\do-} +\RequirePackage{url} + +\newdimen\bibindent +\renewenvironment{thebibliography}[1]{ + \chapter*{\bibname}\addcontentsline{toc}{chapter}{\bibname}% + \list{\@biblabel{\@arabic\c@enumiv}}% + {\settowidth\labelwidth{\@biblabel{#1}}% + \leftmargin\labelwidth + \advance\leftmargin\labelsep + \@openbib@code + \usecounter{enumiv}% + \let\p@enumiv\@empty + \renewcommand\theenumiv{\@arabic\c@enumiv}}% + \sloppy\clubpenalty4000\widowpenalty4000% + \sfcode`\.\@m +}{ + \setcounter{totalbib}{\c@enumiv}% + \def\@noitemerr + {\@latex@warning{Empty `thebibliography' environment}}% + \endlist +} +\renewcommand\@biblabel{}% +\setlength\bibindent{1.5em} + +% Точки после номеров в библиографии. Несовместимо с natbib! -- Коротков И. +%\makeatletter +\renewcommand*{\@biblabel}[1]{\hfill#1.} + + +% +% Remove References header completely +% Stolen from original article.cls +% +\makeatletter +\renewenvironment{thebibliography}[1]{% +% \usection{\refname}% +% \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}% + \list{\@biblabel{\@arabic\c@enumiv}}% + {\settowidth\labelwidth{\@biblabel{#1}}% + \leftmargin\labelwidth + \advance\leftmargin\labelsep + \@openbib@code + \usecounter{enumiv}% + \let\p@enumiv\@empty + \renewcommand\theenumiv{\@arabic\c@enumiv}}% + \sloppy + \clubpenalty4000 + \@clubpenalty \clubpenalty + \widowpenalty4000% + \sfcode`\.\@m} + {\def\@noitemerr + {\@latex@warning{Empty `thebibliography' environment}}% + \endlist} +\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..80d0b90 --- /dev/null +++ b/doc/gost/gost-7-32-captions.sty @@ -0,0 +1,23 @@ +\ProvidesPackage{gost-7-32-captions}[2022/01/28 GOST 7.32-2017] + +\RequirePackage{caption} +\RequirePackage{subcaption} + +% +% Table caption aligned to the left with dash as a separator +% +\captionsetup[table]{labelsep=endash, justification=centering, singlelinecheck=off} + +% +% Dash as separator in figure caption and centering +% +\captionsetup[figure]{labelsep=endash, justification=centering, position=below} + +% +% Listing caption +% +\captionsetup[listing]{labelsep=endash, skip=-0.5em, singlelinecheck=off, position=below} + +\addto\captionsrussian{\renewcommand{\figurename}{Рис.}} +% \addto\captionsrussian{\renewcommand{\mintedname}{Рис.}} +\addto\captionsrussian{\captionsetup[listing]{name=Рис.}} diff --git a/doc/gost/gost-7-32-counters.sty b/doc/gost/gost-7-32-counters.sty new file mode 100644 index 0000000..01d944b --- /dev/null +++ b/doc/gost/gost-7-32-counters.sty @@ -0,0 +1,44 @@ +\ProvidesPackage{gost-7-32-counters}[2022/01/29 GOST 7.32-2017] + +% +% Values for capital russian letters counter +% +\makeatletter +\newcommand\AlphRus[1]{% + \expandafter \@AlphRus \csname c@#1\endcsname +} + +\newcommand\@AlphRus[1]{% + \ifcase #1% + \or А\or Б\or В\or Г\or Д\or Е\or Ж\or И\or К\or + Л\or М\or Н\or П\or Р\or С\or Т\or У\or Ф\or + Х\or Ц\or Ш\or Щ\or Э\or Ю\or Я% + \else \@ctrerr +\fi +} +\makeatother + +% +% Values for lowercase russian letters counter +% +\makeatletter +\newcommand\alphRus[1]{% + \expandafter \@alphRus \csname c@#1\endcsname +} + +\newcommand\@alphRus[1]{% + \ifcase #1% + \or а\or б\or в\or г\or д\or е\or ж\or и\or к\or + л\or м\or н\or п\or р\or с\or т\or у\or ф\or + х\or ц\or ш\or щ\or э\or ю\or я% + \else \@ctrerr +\fi +} +\makeatother + +% Increment figure counter when using lstlisting +\let\oldlstlisting\lstlisting +\renewcommand{\lstlisting}[1][]{% + \refstepcounter{figure} + \oldlstlisting[#1] +} diff --git a/doc/gost/gost-7-32-headings.sty b/doc/gost/gost-7-32-headings.sty new file mode 100644 index 0000000..cb2a7f0 --- /dev/null +++ b/doc/gost/gost-7-32-headings.sty @@ -0,0 +1,114 @@ +\ProvidesPackage{gost-7-32-headings}[2022/01/28 GOST 7.32-2017] + +\RequirePackage{titlesec} +\RequirePackage{titling} +\RequirePackage{setspace} + +\RequirePackage{gost-7-32-counters} + +\setcounter{secnumdepth}{5} + +% +% Set custom formatting to well-known LaTeX commands: section, subsection and subsubsection +% +\titleformat{\section}[block]{\centering\Large\setstretch{1}\bfseries}{\thesection}{0.5em}{} +\titlespacing*{\section}{0cm}{0cm}{0.5cm} +\newcommand{\sectionbreak}{\clearpage} + +\titleformat{\subsection}[block]{\Large\bfseries}{\thesubsection}{0.5em}{} +\titlespacing{\subsection}{0cm}{0.5cm}{0.25cm} + +\titleformat{\subsubsection}[block]{\normalsize\bfseries}{\thesubsubsection}{0.5em}{} +\titlespacing{\subsubsection}{0cm}{0.5em}{0.25cm} + +\titleformat{\paragraph}[block]{\normalsize\bfseries}{\theparagraph}{0.5em}{} +\titlespacing*{\paragraph}{0cm}{0.5em}{0.25cm} + +\titleformat{\subparagraph}[block]{\normalsize\bfseries}{\thesubparagraph}{0.5em}{} +\titlespacing{\subparagraph}{0cm}{0.5em}{0.25cm} + +\makeatletter +\let\oldsection\section +\newcommand{\@sectionnostar}[1]{\oldsection*{#1}\addcontentsline{toc}{section}{#1}} +\newcommand{\@sectionstar}[1]{\oldsection{#1}} +\renewcommand{\section}{\sectionbreak\@ifstar{\@sectionnostar}{\@sectionstar}} +\makeatother + +% +% Make special headings, that have their own formatting rules: +% - centered +% - all-caps +% - bold +% +% Only three of them must appear in TOC: introduction, conclusion and references +% +\newcommand{\introduction}{ + \addcontentsline{toc}{section}{ВВЕДЕНИЕ} + \begin{center} + \bfseries\large + ВВЕДЕНИЕ + \end{center} +} + +\newcommand{\conclusion}{ + \addcontentsline{toc}{section}{ЗАКЛЮЧЕНИЕ} + \begin{center} + \bfseries\large + ЗАКЛЮЧЕНИЕ + \end{center} +} + +\newcommand{\references}{ + \addcontentsline{toc}{section}{СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ} + \begin{center} + \bfseries\large + СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ + \end{center} +} + +\newcommand{\essay}{ + \begin{center} + \bfseries\large + РЕФЕРАТ + \end{center} +} + +\newcommand{\definitions}{ + \begin{center} + \bfseries\large + ОПРЕДЕЛЕНИЯ + \end{center} +} + +\newcommand{\abbreviations}{ + \begin{center} + \bfseries\large + ОБОЗНАЧЕНИЯ И СОКРАЩЕНИЯ + \end{center} +} + +\newcommand{\defsabbrs}{ + \begin{center} + \bfseries\large + ОПРЕДЕЛЕНИЯ, ОБОЗНАЧЕНИЯ И СОКРАЩЕНИЯ + \end{center} +} + +% +% Appendices headings. Appendices have autoincrementing number, +% that is represented with russian letter. +% This heading must appear in TOC +% +\newcounter{appendixcnt} +\setcounter{appendixcnt}{1} + +\renewcommand{\appendix}[1]{ + \addcontentsline{toc}{section}{ПРИЛОЖЕНИЕ \AlphRus{appendixcnt}. #1} + \begin{center} + \bfseries\large + ПРИЛОЖЕНИЕ \AlphRus{appendixcnt} + + #1 + \end{center} + \stepcounter{appendixcnt} +} 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 @@ +\ProvidesPackage{gost-7-32-lists}[2022/01/28 GOST 7.32-2017] + +\RequirePackage{enumitem} +\RequirePackage{gost-7-32-counters} + +\AddEnumerateCounter*{\alphRus}{\c@alphRus}{1} + +\setlist{nosep} +\setlist[itemize, 1]{label=\textendash} +\setlist[itemize, 2]{label=\bullet} +\setlist[itemize, 3]{label=\bullet} + +\setlist[enumerate, 2]{label=\alphRus*)} + +\setlist[1]{wide=\parindent} +\setlist[2]{wide=2\parindent, leftmargin=\parindent} +\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 @@ +\ProvidesPackage{gost-7-32-tables}[2022/01/28 GOST 7.32-2017] + +\RequirePackage{tabularx} + +% +% Center-aligned column with automatic width +% +\newcolumntype{Y}{>{\centering\arraybackslash}X} + +% +% Right-aligned column with automatic width +% +\newcolumntype{Z}{>{\raggedleft\arraybackslash}X} + +% +% Table with designations +% +\newenvironment{designations}{ + \noindent + \tabularx{\textwidth}{@{} + >{\raggedright \arraybackslash \hsize=0.25\hsize}X + >{\centering \arraybackslash \hsize=0.05\hsize}X + >{\arraybackslash \hsize=0.70\hsize}X + } +}{ + \endtabularx +} + +\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 @@ +\ProvidesPackage{gost-7-32-toc}[2022/01/28 GOST 7.32-2017] + +\RequirePackage{tocloft} +\RequirePackage[ + bookmarks=true, + colorlinks=true, + unicode=true, + urlcolor=black, + linkcolor=black, + anchorcolor=black, + citecolor=black, + menucolor=black, + filecolor=black, + hidelinks +]{hyperref} + +% +% Set custom font styles +% +\renewcommand{\cftsecfont}{\normalfont} +\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}} +\renewcommand{\cftsecpagefont}{\normalsize} +\renewcommand{\cftaftertoctitle}{\hfill\hfill} +\renewcommand{\cfttoctitlefont}{\hfill\normalfont\large\bfseries} +\titleformat{\tableofcontents}[block]{\centering\large\bfseries}{\thesection}{0.5em}{} +\titlespacing{\tableofcontents}{0cm}{0cm}{1cm} + +% +% Set indents and line spacing +% +\setlength{\cftbeforesecskip}{0cm} +\setlength{\cftbeforesubsecskip}{0cm} +\setlength{\cftbeforesubsubsecskip}{0cm} +\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..c13b00e --- /dev/null +++ b/doc/gost/gost-7-32.cls @@ -0,0 +1,62 @@ +\NeedsTeXFormat{LaTeX2e} +\ProvidesClass{gost-7-32}[2022/01/28 GOST 7.32-2017] + +% +% Supported font sizes: 12pt, 14pt +% +\DeclareOption{12pt}{\PassOptionsToClass{\CurrentOption}{extarticle}} +\DeclareOption{14pt}{\PassOptionsToClass{\CurrentOption}{extarticle}} + +\ProcessOptions\relax + +% +% Set A4 paper format +% +\LoadClass[a4paper]{extarticle} + +% +% Use 1.5 line spacing +% +\RequirePackage{setspace} +\spacing{1.5} + +% +% First paragraph indentation +% +\RequirePackage{indentfirst} +\setlength{\parindent}{12.5mm} + +% +% Page margin +% +\RequirePackage[ + left=2.5cm, + right=2cm, + top=2cm, + bottom=2cm, + footskip=1cm, +]{geometry} + +% +% Use TMR-like font +% +\RequirePackage{fontspec} +\RequirePackage{xunicode} +\defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase,Mapping=tex-text} +\setmainfont{Times New Roman} + +% +% Use russian language +% +\RequirePackage[main=russian, english]{babel} +\babelhyphenation[russian]{} + +% +% gost-7-32 packages +% +\RequirePackage{gost-7-32-headings} +\RequirePackage{gost-7-32-toc} +\RequirePackage{gost-7-32-lists} +\RequirePackage{gost-7-32-bibliography} +\RequirePackage{gost-7-32-captions} +\RequirePackage{gost-7-32-tables} diff --git a/doc/ox-init.el b/doc/ox-init.el new file mode 100644 index 0000000..94aec5f --- /dev/null +++ b/doc/ox-init.el @@ -0,0 +1,31 @@ +;;; ox-init.el --- Initialization script for async org exprort session +;;; Commentary: +;;; Code: +(org-babel-do-load-languages + 'org-babel-load-languages + '((latex . t) + (C . t))) + +(require 'ox-extra) +(ox-extras-activate '(ignore-headlines)) + +(setq org-latex-src-block-backend 'minted) + +(require 'oc-bibtex) +(setq org-latex-bib-compiler "biber") + +(setq org-latex-remove-logfiles nil) + +(setq org-latex-caption-above '(table)) + +(setq org-latex-pdf-process '("%latex -shell-escape -interaction nonstopmode -output-directory %o %f" + "%bib %b" + "%latex -shell-escape -interaction nonstopmode -output-directory %o %f")) +(setq org-latex-classes '(("spbstu-report" "\\documentclass[12pt]{spbstu-report}" + ("\\section{%s}" . "\\section*{%s}") + ("\\subsection{%s}" . "\\subsection*{%s}") + ("\\subsubsection{%s}" . "\\subsubsection*{%s}") + ("\\paragraph{%s}" . "\\paragraph*{%s}") + ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))) + +;;; ox-init.el ends here diff --git a/doc/report.org b/doc/report.org new file mode 100644 index 0000000..4f0d305 --- /dev/null +++ b/doc/report.org @@ -0,0 +1,763 @@ +#+title: Оснащение грамматики семантикой +#+subtitle: Генерация случайных изображений +#+author: Михалец М. +#+latex_header: \reportof{О ВЫПОЛНЕНИИ ЛАБОРАТОРНОЙ РАБОТЫ №5} +#+latex_header: \subject{по дисциплине «Математическая логика и теория автоматов»} +#+latex_header: \university{Федеральное государственное автономное образовательное учреждение высшего образования \enquote{Санкт-Петербургский политехнический университет Петра Великого}} +#+latex_header: \institute{Институт компьютерных наук и кибербезопасности} +#+latex_header: \school{Высшая школа технологии искусственного интеллекта} +#+latex_header: \direction{02.03.01 Математика и компьютерные науки} +#+latex_header: \reviewertitle{}\reviewer{Востров А.В.} +#+latex_header: \city{Санкт-Петербург} +#+date: 2025 + +#+macro: caption @@latex:\vspace{0em}\captionof{listing}{$2\label{$1}}\vspace{0em}@@ + +#+setupfile: setup.org +#+latex: \sloppy +#+latex: \setlength{\grammarparsep}{0pt} + +* ВВЕДЕНИЕ +:PROPERTIES: +:UNNUMBERED: t +:END: +В данной работе рассмотрена реализация грамматики с семантикой +порождения случайных изображений в виде шейдера фрагментов. + +* Математическое описание +/Случайное изображение/ -- случайным образом построенная функция, в +данном случае 3 таких функции для каждой компоненты sRGB. На вход +такой функции можно подавать произвольные количество значений, мы +будем использовать канонические координаты фрагмента изображения $c$ и +положения курсора $m$ и время $t$. Положение курсора сделает +изображение реактивным, а время -- темпоральным. + +** Грамматика описывающая пространство порождаемых изображений +Для описания пространства порождаемых изображений была за основу взята +штатная грамматика BNF, которая представлена на рис. [[bnf-grammar]]. Для +пояснения, \synt{EOF} означает конец файла, а \synt{EOL} -- конец +строки. + +#+name: bnf-grammar +#+caption: Грамматика BNF +#+attr_latex: :options [H] +#+begin_figure +\setlength{\grammarindent}{9em} +\begin{grammar} + $::=$ | + + $::=$ `<' `>' `::=' + + $::=$ ` ' | $\varepsilon$ + + $::=$ | `|' + + $::=$ | + + $::=$ | + + $::=$ | `<' `>' + + $::=$ `"' `"' | `\'' `\'' + + $::=$ $\varepsilon$ | + + $::=$ $\varepsilon$ | + + $::=$ | | + + $::=$ `A' | `B' | `C' | `D' | `E' | `F' | `G' | `H' | `I' | `J' | `K' | `L' | `M' | `N' | `O' | `P' | `Q' | `R' + \alt `S' | `T' | `U' | `V' | `W' | `X' | `Y' | `Z' | `a' | `b' | `c' | `d' | `e' | `f' | `g' | `h' | `i' | `j' + \alt `k' | `l' | `m' | `n' | `o' | `p' | `q' | `r' | `s' | `t' | `u' | `v' | `w' | `x' | `y' | `z' + + $::=$ `0' | `1' | `2' | `3' | `4' | `5' | `6' | `7' | `8' | `9' + + $::=$ `|' | ` ' | `!' | `#' | `\$' | `\%' | `&' | `(' | `)' | `*' | `+' | `,' | `-' | `.' | `/' | `:' + \alt `;' | `>' | `=' | `<' | `?' | `@' | `[' | `\\' | `]' | `^' | `\_' | \lit{\textasciigrave} | `{' | `}' | `~' + + $::=$ | `\'' + + $::=$ | `"' + + $::=$ | + + $::=$ | | `-' +\end{grammar} +#+end_figure + +Если были бы всё продукции равноправными, было бы трудно управлять +результатом порождаемых программ. Поэтому, BNF расширяется +необязательным указанием вероятности использования продукции, +посредством указания её объёма, в её начале. Если будет объём опущен, +то оно принимает значение 1. Объём -- натуральное число или ноль, +вероятность применения продукции -- отношение объёма продукции к сумме +объёмов продукции нетерминала. Нужные расширения к BNF грамматике +представлены на рис. [[bnf-grammar-extension]]. Таким образом +пространство поражаемых изображений оснащается плотностью -- +производной Радона-Никодима. + +#+name: bnf-grammar-extension +#+caption: Рассширение грамматики BNF +#+attr_latex: :options [H] +#+begin_figure +\setlength{\grammarindent}{8em} +\begin{grammar} + $::=$ + \alt `|' + + $::=$ | +\end{grammar} +#+end_figure + +Полученная грамматика не является LL(1). Чтобы привести её, +понадобится провести только факторизацию левых префиксов, так как в +грамматике и так отсутствует левая рекурсия. Изменённые и новые +правила представлены на рис. [[bnf-grammar-factorization]]. + +#+name: bnf-grammar-factorization +#+caption: Левая факторизация рассширённой грамматики BNF +#+attr_latex: :options [H] +#+begin_figure +\setlength{\grammarindent}{8em} +\begin{grammar} + $::=$ + + $::=$ | + + $::=$ | + + $::=$ $\varepsilon$ | `|' + + $::=$ + + $::=$ $\varepsilon$ | +\end{grammar} +#+end_figure + +По такой грамматике уже можно построить таблицу выбора, но мы её не +будем приводит, поскольку она получится громоздкой. + +** Пример грамматики +Данная грамматика позволяет описать простые выражения с константами, +координатами фрагмента и курсора на экране, времени и бинарными, +тригонометрическими и другими функциями над ними. + +#+begin_export latex +\setlength{\grammarindent}{8em} +\begin{grammar} + $::=$ \[[ + \begin{stack} + $\overset{y_1}{\triangle}$ \\ + $\overset{y_2}{\triangle}$ `-' \\ + $\overset{y_3}{\triangle}$ \\ + $\overset{y_4}{\triangle}$ \\ + $\overset{y_5}{\triangle}$ `abs(' `)' \\ + $\overset{y_6}{\triangle}$ `sqrt(abs(' `))' + \end{stack} + \]] + + $::=$ \[[ + \begin{stack} + $\overset{y_7}{\triangle}$ \\ + $\overset{y_8}{\triangle}$ \\ + $\overset{y_9}{\triangle}$