\documentclass[11pt,a4paper]{book}
\usepackage{isabelle,isabellesym}
\usepackage{graphicx}
\graphicspath {{figures/}}

% further packages required for unusual symbols (see also
% isabellesym.sty), use only when needed


\usepackage{latexsym}
\usepackage{amssymb}
  %for \<leadsto>, \<box>, \<diamond>, \<sqsupset>, \<mho>, \<Join>,
  %\<lhd>, \<lesssim>, \<greatersim>, \<lessapprox>, \<greaterapprox>,
  %\<triangleq>, \<yen>, \<lozenge>

%\usepackage[greek,english]{babel}
  %option greek for \<euro>
  %option english (default language) for \<guillemotleft>, \<guillemotright>

%\usepackage[latin1]{inputenc}
  %for \<onesuperior>, \<onequarter>, \<twosuperior>, \<onehalf>,
  %\<threesuperior>, \<threequarters>, \<degree>

%\usepackage[only,bigsqcap]{stmaryrd}
  %for \<Sqinter>

%\usepackage{eufrak}
  %for \<AA> ... \<ZZ>, \<aa> ... \<zz> (also included in amssymb)

%\usepackage{textcomp}
  %for \<cent>, \<currency>

% this should be the last package used
\usepackage{pdfsetup}

% urls in roman style, theory text in math-similar italics
\urlstyle{rm}
\isabellestyle{it}
\newcommand{\HOL}[1]{\verb{HOL}}
\newcommand{\eg}[1]{e.g.}
\renewcommand{\isasymdegree}{XXX}


\begin{document}

\title{International Systems of Quantities and Units in Isabelle/HOL}
\author{Simon Foster \and Burkhart Wolff}
\maketitle

\textbf{ Abstract } 
The International System of Units 
(SI, abbreviated from the French Syst\`eme international (d’unit\'es)) is the modern form of 
the metric system and is the most widely used system of measurement. It comprises a coherent 
system of units of measurement built on seven base units, which are the second, metre, kilogram, 
ampere, kelvin, mole, candela, and a set of twenty prefixes to the unit names and unit symbols 
that may be used when specifying multiples and fractions of the units. The system also specifies 
names for 22 derived units, such as lumen and watt, for other common physical quantities. 

This theory represents a formal model of SI Units together with a deep integration in Isabelle's
type system: unitswere represented in a way that they have a \emph{unit type} comprising its 
\emph{magnitude type} and its physical \emph{dimension}. Congruences on dimensions were supported. 
Our construction is validated by a test-set of known equivalences between SI Units.
Moreover, the presented theory can be used for type-safe conversions between the SI system and
others, like the British Imperial System (BIS).

\tableofcontents

% sane default for proof documents
\parindent 0pt\parskip 0.5ex


\chapter{SI Units in Isabelle \\ An Introduction}

The International System of Units (SI, abbreviated from the French
Système international (d'unités)) is the modern form of the metric
system and is the most widely used system of measurement. It comprises
a coherent system of units of measurement built on seven base units,
which are the second, metre, kilogram, ampere, kelvin, mole, candela,
and a set of twenty prefixes to the unit names and unit symbols that
may be used when specifying multiples and fractions of the units.
The system also specifies names for 22 derived units, such as lumen and
watt, for other common physical quantities.

(cited from \url{https://en.wikipedia.org/wiki/International_System_of_Units}).

In more detail, the SI provides the following fundamental concepts:

%
\begin{enumerate}%
\item \emph{quantities}, i.e. \emph{time}, \emph{length}, \emph{mass}, \emph{electric current},
\emph{temperature}, \emph{amount of substance},\emph{luminous intensity},
and other derived quantities such as \emph{volume};

\item \emph{dimensions}, i.e. a set of the symbols  \isa{T}, \isa{L}, \isa{M}, \isa{I},  \isa{{\isasymTheta}}, \isa{N}, \isa{J}  corresponding
to the above mentioned base quantities,  indexed by an integer exponent
(dimensions were also called \emph{base unit names} or just \emph{base units});

\item \emph{magnitudes}, i.e. a factor or \emph{prefix}
(typically integers, reals, vectors on real or complex numbers);

\item \emph{units}, which are basically pairs of magnitudes and dimensions denoting quantities.
\end{enumerate}

Note that \emph{quantities} are understood as idealized  \emph{physical concepts}, and are sharply 
distinguished from  \emph{units} representing \emph{a means to measure} them. The difference is 
roughly similar between words (or: symbols) and notions. This distinction reflects the fact that
these concepts have been at times heavily questioned in the history of physics; the interested
reader is referred to the debate around the "relativistic mass" at in the twenties of the last century.

The purpose of the presented theory is to model SI units with polymorphic magnitudes inside the
Isabelle/HOL\cite{nipkow.ea:isabelle:2002} system. The objective of our construction is to
reflect the types of the magnitudes as well as their dimensions in order to allow type-safe 
calculations on SI units.

As a result, it is possible to express "4500.0 kilogram times meter per second square" which can
have the type 
\isa{{\isasymreal}\ {\isacharbrackleft}M\ \isactrlsup {\isachardot}\ L\ \isactrlsup 
 {\isachardot}\ T\isactrlsup {\isacharminus}\isactrlsup {\isadigit{3}} 
 \isactrlsup {\isachardot}\   T\isactrlsup {\isadigit{1}}{\isacharbrackright}}. 
For units of this type we can infer that this corresponds to the derived unit "4.5 kN" (kilo-Newton) 
 of type \isa{{\isasymreal}\ {\isacharbrackleft}M\ \isactrlsup {\isachardot}\ L\ \isactrlsup 
 {\isachardot}\ T\isactrlsup {\isacharminus}\isactrlsup {\isadigit{2}}{\isacharbrackright}}.  

This is an attempt to model the standard SI system and its derived entities (cf.
\url{https://www.quora.com/What-are-examples-of-SI-units}),
both from a type-checking as well as a proof-support perspective.
These design objectives are for the case of Isabelle system somewhat contradictory.
Since the Isabelle type system follows the Curry-style paradigm, which can be 
characterized by: "be as implicit as possible, inference as automatic as possible", it is not
possible to do computations on type-terms (in contrast to, for example, Coq). We therefore
need a more involved construction using Isabelle's type-classes to establish a semantic 
interpretation on certain classes of types. This paves the way to derive rules that
establish and exploit type isomorphisms implicitely. For example, the implicit
type isomorhisms for the dimensions $T^{-2} * T$ and $T^{-1}$ is dealt with appropriate
rules on terms and a special form of equivalence. 

Our construction proceeds in three phases:
\begin{enumerate}%
\item We construct a type \isa{Dimension} which is basically a "semantic representation" or
"semantic domain" of all SI dimensions. Since SI-types have an interpretation in this domain,
it serves to give semantics to type-constructors by operations on this domain, too.
We construct a multiplicative group on it.

\item From \isa{Dimension} we build a language of type-constructors of \isa{dimS}-types, 
 captured in a type class \isa{dim-types} giving it a pseudo-inductive structure. Types of
 this class are required to have  an interpretation function into \isa{Dimension}'s, which
 allows for establishing equivalences on \isa{dim-types}.
      
\item We construct a SI Unit-type as a pair of a polymorphic magnitude and a dimension type.
  This type will be inhabited by all basic SI units and predicates expressing their relationship.
\end{enumerate}%

On this basis, an algebra of SI units can be derived; while types can not be "touched" inside
an Isabelle/HOL logic, it is possible to transform unit types by applying rules of this algebra.
Tactical support over this algebra is provided enabling the construction of normal forms on 
both units and their type.  

\subsubsection{Previous Attempts.} The work of \cite{HayesBrendan95} represents to our knowledge a
first attempt to formalize SI units in Z, thus a similar language of HOL. While our typing
representation is more rigourous due to the use of type-classes, this works lacks any attempt
to support formal and automated deduction on Si unit equivalences.

MORE TO COME.

\input{session}

% optional bibliography
\bibliographystyle{abbrv}
\bibliography{adb-long,root}

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
