Skip to content

Latest commit

 

History

History
130 lines (110 loc) · 5.25 KB

theory_documentation.md

File metadata and controls

130 lines (110 loc) · 5.25 KB
title
Theory Documentation

Documentation is key for the long-term value of a development. Without documentation, once a project loses its original maintainer(s), the project virtually dies due to inaccessibility. In general, all comments must be written using Isabelle markdown (see Isabelle reference manual).

References

Every project comes with a .bib containing the references that were used when developing the theories. This file should be placed in the folder document. Those references are then inserted at the appropriate places when documenting the theories (using the antiquation @cite).

Header Documentation

Every file starts with:

  • a comment declaring the author(s) of the file if there is more than one person working on the project
  • the list of imports
  • a file comment containing the general documentation in this order. Original authors should mark themselves with the ✐‹creator ...› tag. Additional (later) contributors should use the ✐‹contributor ...› tag.

The file comment consists of the following sections:

  • the title of the file followed by a summary of the content of the file
  • main definitions (optional; can be covered in the summary)
  • main theorems (optional; can be covered in the summary)
  • notations (if notation is introduced)
  • fact collections and bundles (if relevant fact collections or bundles are introduced)
  • implementation notes (optional; description of important design decisions or interface features, including use of type classes and simp canonical form for new definitions)
  • references (references to textbooks, papers, or Wikipedia pages)
  • tags (a list of keywords that could be useful for search)

The following is an example of a file header:

✐‹creator "Kevin Kappelmann"›
✐‹contributor "Simon Wimmer"chapterContinued Fractionstheory Scratch
  imports HOL.Archimedean_Field "HOL-Library.Stream"
begin

paragraphSummarytextWe define generalised, simple, and regular continued fractions and
functions to evaluate their convergents. We follow the naming conventions from
@{cite wikicontinuedfractions} and @{cite wall2018analytic}.paragraphMain Definitionstext ‹
▪ Generalised continued fractions (gcfs)Simple continued fractions (scfs)(Regular) continued fractions ((r)cfs)Computation of convergents using the recurrence relation in
@{const convergents}.Computation of convergents by directly evaluating the fraction described by
the gcf in @{const convergents'}.paragraphNotationstext ‹
▪ @{term "⌊x⌋"} is the floor for anyxof an integral domain.paragraphFact Collectionstext ‹
▪ ‹gcf_simpscontains simplification rules for gcfsparagraphImplementation Notestext ‹
▪ The most commonly used kind of continued fractions in the literature are
regular continued fractions. We hence just call them @{const continued_fractions}
in the library.We use streams from @{theory "HOL-Library.Stream"} to encode infinite sequences.paragraphTagstextnumerics, number theory, approximations, fractions

Theory-Body Documentation and Sectioning

Every theory should result in a human-readable file. For this, we document and section theories. Regarding the former, all definitions and major theorems are accompanied by a text block (or comment).

  • For definitions, the block should convey the mathematical meaning and motivation. For clarity, minor technicalities need not be mentioned (e.g. divisions by zero)
  • For major theorems, the block should address the importance and re-usability of the theorem.
  • When referring to constants (@const), terms (@term), types (@typ), theorems (@thm) etc., antiquotations must be used. In particular, for constants, @const must be preferred over @term.

Moreover, the theory should be sectioned using the chapter, section, subsection, paragraph, etc. commands. If a new section starts at the start of a theory, the corresponding sectioning command should go before the theory header. Explanatory text that motivates and guides the user through the theory development should be added.

Example:

paragraphGeneralised Continued FractionstextA ∗‹generalised continued fraction(gcf) is a potentially infinite expression
of the form

\begin{equation*}
h+\cfrac{a_0}
  {b_0+\cfrac{a_1}
    {b_1+\cfrac{a_2}
      {b_2+\cfrac{a_3}
        {b_3+\dotsb}}}}
\end{equation*}(* Above code produces:
                a₀
h + ---------------------------
                  a₁
      b₀ + --------------------
                    a₂
            b₁ + --------------
                        a₃
                  b₂ + --------
                      b₃ + ...
*)

textwherehis called the ∗‹head termor ∗‹integer part, theais⇙› are
called the ∗‹partial numeratorsand thebis⇙› the ∗‹partial denominatorsof the
gcf. We store the sequence of partial numerators and denominators in a sequence
of @{term generalized_continued_fraction_pairs}s.
For convenience, one often writes[h; (a0, b0), (a1, b1), (a2, b2),].definition "generalised_continued_fraction ≡ ..."