Skip to content

Commit

Permalink
WIP: docs: Translate how-it-works.pdf to English
Browse files Browse the repository at this point in the history
  • Loading branch information
kmyk committed Sep 26, 2021
1 parent 423d41c commit 24e6ae1
Show file tree
Hide file tree
Showing 7 changed files with 584 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/format-tex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
- name: Run chktex
run: |
chktex --nowarn={1,2,8,11,12,36,39} docs/*.tex
chktex --nowarn={1,2,8,11,12,13,36,39} docs/*.tex
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ For developpers:
- [CONTRIBUTING.md](https://github.com/kmyk/Jikka/blob/master/CONTRIBUTING.md)
- My blog article [競技プログラミングの問題を自動で解きたい - うさぎ小屋](https://kimiyuki.net/blog/2020/12/09/automated-solvers-of-competitive-programming/) (Japanese)
- On what it means to automatically solve problems of competitive programming / 競技プログラミングの問題を自動で解くとはどういうことなのかについて
- [docs/how-it-works.pdf](https://github.com/kmyk/Jikka/blob/master/docs/how-it-works.pdf) (Japanese)
- [docs/how-it-works.pdf](https://github.com/kmyk/Jikka/blob/master/docs/how-it-works.pdf) / [docs/how-it-works.ja.pdf](https://github.com/kmyk/Jikka/blob/master/docs/how-it-works.ja.pdf)
- How it works and related theories / 動作原理や関連する理論
- [docs/DESIGN.md](https://github.com/kmyk/Jikka/blob/master/docs/DESIGN.md)
- The policy of designs / 実装方針
Expand Down
Binary file added docs/how-it-works.ja.pdf
Binary file not shown.
562 changes: 562 additions & 0 deletions docs/how-it-works.ja.tex

Large diffs are not rendered by default.

Binary file modified docs/how-it-works.pdf
Binary file not shown.
37 changes: 19 additions & 18 deletions docs/how-it-works.tex
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,36 @@
\newenvironment{definition}{\begin{definition*}\renewcommand{\qedsymbol}{\(\diamond\)}\pushQED{\qed}}{\popQED\end{definition*}}


\title{競技プログラミングの問題を自動的に解きたい}
\title{Towards automatically solving problems of \\ competitive programming}
\author{Kimiyuki Onaka}
\date{\today}

\begin{document}
\maketitle

\setcounter{section}{-1}
\section{概要}
\section{Abstract}

この PDF では「競技プログラミングの問題を自動的に解けるか?」という問いについて考える。
あるいは「競技プログラミングのソルバを作ることはできるか?」と言い換えてもよいだろう。
In this PDF, we consider the question, ``Can we automatically solve problems of competitive programming?''.
In other words, ``Can we make a solver for competitive programming?''.

$1$ 章ではこのまだ曖昧な問いをより具体的な問いへと整理する。
競技プログラミングの問題を自動的に解くソルバにも様々な種類のものがあることを説明し、今回我々が作成を目指すソルバがそれらの中のどの種類のものかを明確にする。
我々が作成を目指すのは「形式的に表現された問題を受け取り、それに対する解答を出力する」という種類のものであり、その中でも特に「形式的に表現された問題」として「愚直解のソースコード」を用いるものである。
そのようなソルバはつまり「漸近的計算量のレベルの最適化を伴うトランスパイラ」である。
よって「競技プログラミングのソルバを作ることはできるか?」という問いは「漸近的計算量のレベルの最適化を伴うトランスパイラは作れるか?」という具体的な問いとなる。
また、より実用的には、完全なソースコードでなく小さなコード片を入力とする「漸近的計算量のレベルの最適化を行う IDE プラグイン」としても利用できると扱いやすいであろう。
In section $1$, we organize this still vague question into a more concrete one.
We explain that there are various types of solvers that automatically solve problems of competitive programming, and clarify which type of solver we are aiming to develop.
Our goal is to develop a solver that receives a formally expressed problem as input and outputs a solution to it, especially one that uses naive source code as its ``formally expressed problem''.
Such a solver is, in other words, a transpiler with optimization about asymptotic computational complexity.
Therefore, the question ``Can we make a solver for competitive programming?'' becomes a concrete question: ``Can we make a transpiler with optimization about asymptotic computational complexity?''
Also, for practical use, it would be easier to use it as an IDE plugin that rewrites a code snippet to reduce its asymptotic computational complexity, instead of transpiling the entire source code.

$2$ 章では具体化された問いに対する暫定の答えを与える。
つまり、最適化を伴うトランスパイラとしての競技プログラミングのソルバの実装方針を説明し、またそのような方針で実装されたソルバでいくらかの問題が解けることを見る。
実装方針は機械的な式木の書き換えが中心となる。
たとえば、愚直に何度も区間和を取っている部分を検出すればそれを累積和で置き換えたり、愚直な 2 重ループで畳み込みをしている部分を検出すればそれを FFT を用いた畳み込みで置き換えたりする。
このような書き換えは ``rewrite rule'' と呼ばれる規則として表現され、よってソルバの中心部分は「rewrite rules からなる集合」として実装される。
In section $2$, we give a tentative answer to this concretized question.
We describe how to implement a solver for competitive programming as a transpiler with optimization, and observes that such a solver can solve some problems.
The implementation strategy is mechanical rewriting of expression trees.
For example, when the solver detects a part that is naively taking interval sums many times, the solver replaces it with cumulative sums.
For another example, when it detects a part that is naively doing convolution with double loops, then it replaces the part with convolution using FFT.
Such rewriting is expressed as a rule called ``rewrite rules'', and the core of such a solver is implemented as a set of rewrite rules.

\section{競技プログラミングの問題を自動的に解くとはどのようなことか}
\section{What is automatically solving problems of competitive programming}

\subsection{そもそもなぜ競技プログラミングの問題を自動で解きたいのか}
\subsection{BTW, why do we want to solve problems automatically?}

まず先に、「競技プログラミングの問題を自動的に解けるか?」という問いの意義について述べておこう。
なぜ競技プログラミングの問題を自動で解きたいのだろうか?
Expand Down Expand Up @@ -98,7 +99,7 @@ \subsection{そもそもなぜ競技プログラミングの問題を自動で
あるいは逆にそのようなソルバがまったく失敗してしまうなら、人間の思考には機械的な規則の適用としては捉えきれない暗黙的な部分があることが疑われる。


\subsection{競技プログラミングの問題を人間はどのように解いているのか}
\subsection{How do humans solve problems of competitive programming?}

「競技プログラミングの問題を解く」と言っても、その範囲は意外に広い。まずこれを整理するところから初めよう。
競プロの問題のページが開かれた直後の状態 (たとえば \url{https://atcoder.jp/contests/abc184/tasks/abc184_c} というリンクをクリックした直後のような状態) から初めて、緑色の「AC」という表示を確認するまでの過程において、具体的にはどのようなステップがあるだろうか?
Expand Down
2 changes: 1 addition & 1 deletion scripts/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fi
if git diff --staged --name-only | grep '\.tex$'; then
chktex --version \
|| { echo HINT: Please install chktex, e.g. '$ sudo apt install chktex'; exit 1; }
chktex --nowarn={1,2,8,11,12,36,39} $(git ls-files | grep '\.tex$') \
chktex --nowarn={1,2,8,11,12,13,36,39} $(git ls-files | grep '\.tex$') \
|| exit 1
fi

Expand Down

0 comments on commit 24e6ae1

Please sign in to comment.