quick commit

This commit is contained in:
Teddy Cameron-Burke 2026-02-05 16:21:51 +00:00
parent cd52980c31
commit d7a0307bca
38 changed files with 8503 additions and 2 deletions

View File

@ -0,0 +1,4 @@
theory Interval_Lifting
imports Interval_Analysis.Multi_Interval
begin
end

View File

@ -0,0 +1,4 @@
theory Interval_Lifting
imports Interval_Analysis.Interval_Analysis
begin
end

10
Lifting/ROOT Normal file
View File

@ -0,0 +1,10 @@
session Lifting = HOL +
options [document = pdf, document_output = "output"]
(*theories [document = false]
A
B
theories
C
D*)
document_files
"root.tex"

60
Lifting/document/root.tex Normal file
View File

@ -0,0 +1,60 @@
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{isabelle,isabellesym}
% further packages required for unusual symbols (see also
% isabellesym.sty), use only when needed
%\usepackage{amssymb}
%for \<leadsto>, \<box>, \<diamond>, \<sqsupset>, \<mho>, \<Join>,
%\<lhd>, \<lesssim>, \<greatersim>, \<lessapprox>, \<greaterapprox>,
%\<triangleq>, \<yen>, \<lozenge>
%\usepackage{eurosym}
%for \<euro>
%\usepackage[only,bigsqcap,bigparallel,fatsemi,interleave,sslash]{stmaryrd}
%for \<Sqinter>, \<Parallel>, \<Zsemi>, \<Parallel>, \<sslash>
%\usepackage{eufrak}
%for \<AA> ... \<ZZ>, \<aa> ... \<zz> (also included in amssymb)
%\usepackage{textcomp}
%for \<onequarter>, \<onehalf>, \<threequarters>, \<degree>, \<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}
% for uniform font size
%\renewcommand{\isastyle}{\isastyleminor}
\begin{document}
\title{Lifting}
\author{user}
\maketitle
\tableofcontents
% sane default for proof documents
\parindent 0pt\parskip 0.5ex
% generated text of all theories
\input{session}
% optional bibliography
%\bibliographystyle{abbrv}
%\bibliography{root}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:

BIN
Lifting/output/document.pdf Normal file

Binary file not shown.

View File

@ -0,0 +1,280 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Comment.sty version 3.6, October 1999
%
% Purpose:
% selectively in/exclude pieces of text: the user can define new
% comment versions, and each is controlled separately.
% Special comments can be defined where the user specifies the
% action that is to be taken with each comment line.
%
% Author
% Victor Eijkhout
% Department of Computer Science
% University of Tennessee
% 107 Ayres Hall
% Knoxville TN 37996
% USA
%
% victor@eijkhout.net
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% For a copy of the GNU General Public License, write to the
% Free Software Foundation, Inc.,
% 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA,
% or find it on the net, for instance at
% http://www.gnu.org/copyleft/gpl.html
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This style can be used with plain TeX or LaTeX, and probably
% most other packages too.
%
% Usage: all text included between
% \comment ... \endcomment
% or \begin{comment} ... \end{comment}
% is discarded.
%
% The opening and closing commands should appear on a line
% of their own. No starting spaces, nothing after it.
% This environment should work with arbitrary amounts
% of comment, and the comment can be arbitrary text.
%
% Other `comment' environments are defined by
% and are selected/deselected with
% \includecomment{versiona}
% \excludecoment{versionb}
%
% These environments are used as
% \versiona ... \endversiona
% or \begin{versiona} ... \end{versiona}
% with the opening and closing commands again on a line of
% their own.
%
% LaTeX users note: for an included comment, the
% \begin and \end lines act as if they don't exist.
% In particular, they don't imply grouping, so assignments
% &c are not local.
%
% Special comments are defined as
% \specialcomment{name}{before commands}{after commands}
% where the second and third arguments are executed before
% and after each comment block. You can use this for global
% formatting commands.
% To keep definitions &c local, you can include \begingroup
% in the `before commands' and \endgroup in the `after commands'.
% ex:
% \specialcomment{smalltt}
% {\begingroup\ttfamily\footnotesize}{\endgroup}
% You do *not* have to do an additional
% \includecomment{smalltt}
% To remove 'smalltt' blocks, give \excludecomment{smalltt}
% after the definition.
%
% Processing comments can apply processing to each line.
% \processcomment{name}{each-line commands}%
% {before commands}{after commands}
% By defining a control sequence
% \def\Thiscomment##1{...} in the before commands the user can
% specify what is to be done with each comment line.
% BUG this does not work quite yet BUG
%
% Trick for short in/exclude macros (such as \maybe{this snippet}):
%\includecomment{cond}
%\newcommand{\maybe}[1]{}
%\begin{cond}
%\renewcommand{\maybe}[1]{#1}
%\end{cond}
%
% Basic approach of the implementation:
% to comment something out, scoop up every line in verbatim mode
% as macro argument, then throw it away.
% For inclusions, in LaTeX the block is written out to
% a file \CommentCutFile (default "comment.cut"), which is
% then included.
% In plain TeX (and other formats) both the opening and
% closing comands are defined as noop.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Changes in version 3.1
% - updated author's address
% - cleaned up some code
% - trailing contents on \begin{env} line is always discarded
% even if you've done \includecomment{env}
% - comments no longer define grouping!! you can even
% \includecomment{env}
% \begin{env}
% \begin{itemize}
% \end{env}
% Isn't that something ...
% - included comments are written to file and input again.
% Changes in 3.2
% - \specialcomment brought up to date (thanks to Ivo Welch).
% Changes in 3.3
% - updated author's address again
% - parametrised \CommentCutFile
% Changes in 3.4
% - added GNU public license
% - added \processcomment, because Ivo's fix (above) brought an
% inconsistency to light.
% Changes in 3.5
% - corrected typo in header.
% - changed author email
% - corrected \specialcomment yet again.
% - fixed excludecomment of an earlier defined environment.
% Changes in 3.6
% - The 'cut' file is now written more verbatim, using \meaning;
% some people reported having trouble with ISO latin 1, or umlaute.sty.
% - removed some \newif statements.
% Has this suddenly become \outer again?
%
% Known bugs:
% - excludecomment leads to one superfluous space
% - processcomment leads to a superfluous line break
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\makeinnocent#1{\catcode`#1=12 }
\def\csarg#1#2{\expandafter#1\csname#2\endcsname}
\def\latexname{lplain}\def\latexename{LaTeX2e}
\newwrite\CommentStream
\def\CommentCutFile{comment.cut}
\def\ProcessComment#1% start it all of
{\begingroup
\def\CurrentComment{#1}%
\let\do\makeinnocent \dospecials
\makeinnocent\^^L% and whatever other special cases
\endlinechar`\^^M \catcode`\^^M=12 \xComment}
%\def\ProcessCommentWithArg#1#2% to be used in \leveledcomment
% {\begingroup
% \def\CurrentComment{#1}%
% \let\do\makeinnocent \dospecials
% \makeinnocent\^^L% and whatever other special cases
% \endlinechar`\^^M \catcode`\^^M=12 \xComment}
{\catcode`\^^M=12 \endlinechar=-1 %
\gdef\xComment#1^^M{%
\expandafter\ProcessCommentLine}
\gdef\ProcessCommentLine#1^^M{\def\test{#1}
\csarg\ifx{End\CurrentComment Test}\test
\edef\next{\noexpand\EndOfComment{\CurrentComment}}%
\else \ThisComment{#1}\let\next\ProcessCommentLine
\fi \next}
}
\def\CSstringmeaning#1{\expandafter\CSgobblearrow\meaning#1}
\def\CSstringcsnoescape#1{\expandafter\CSgobbleescape\string#1}
{\escapechar-1
\expandafter\expandafter\expandafter\gdef
\expandafter\expandafter\expandafter\CSgobblearrow
\expandafter\string\csname macro:->\endcsname{}
}
\def\CSgobbleescape#1{\ifnum`\\=`#1 \else #1\fi}
\def\WriteCommentLine#1{\def\CStmp{#1}%
\immediate\write\CommentStream{\CSstringmeaning\CStmp}}
% 3.1 change: in LaTeX and LaTeX2e prevent grouping
\if 0%
\ifx\fmtname\latexename
0%
\else \ifx\fmtname\latexname
0%
\else
1%
\fi \fi
%%%%
%%%% definitions for LaTeX
%%%%
\def\AfterIncludedComment
{\immediate\closeout\CommentStream
\input{\CommentCutFile}\relax
}%
\def\TossComment{\immediate\closeout\CommentStream}
\def\BeforeIncludedComment
{\immediate\openout\CommentStream=\CommentCutFile
\let\ThisComment\WriteCommentLine}
\def\includecomment
#1{\message{Include comment '#1'}%
\csarg\let{After#1Comment}\AfterIncludedComment
\csarg\def{#1}{\BeforeIncludedComment
\ProcessComment{#1}}%
\CommentEndDef{#1}}
\long\def\specialcomment
#1#2#3{\message{Special comment '#1'}%
% note: \AfterIncludedComment does \input, so #2 goes here!
\csarg\def{After#1Comment}{#2\AfterIncludedComment#3}%
\csarg\def{#1}{\BeforeIncludedComment\relax
\ProcessComment{#1}}%
\CommentEndDef{#1}}
\long\def\processcomment
#1#2#3#4{\message{Lines-Processing comment '#1'}%
\csarg\def{After#1Comment}{#3\AfterIncludedComment#4}%
\csarg\def{#1}{\BeforeIncludedComment#2\relax
\ProcessComment{#1}}%
\CommentEndDef{#1}}
\def\leveledcomment
#1#2{\message{Include comment '#1' up to level '#2'}%
%\csname #1IsLeveledCommenttrue\endcsname
\csarg\let{After#1Comment}\AfterIncludedComment
\csarg\def{#1}{\BeforeIncludedComment
\ProcessCommentWithArg{#1}}%
\CommentEndDef{#1}}
\else
%%%%
%%%%plain TeX and other formats
%%%%
\def\includecomment
#1{\message{Including comment '#1'}%
\csarg\def{#1}{}%
\csarg\def{end#1}{}}
\long\def\specialcomment
#1#2#3{\message{Special comment '#1'}%
\csarg\def{#1}{\def\ThisComment{}\def\AfterComment{#3}#2%
\ProcessComment{#1}}%
\CommentEndDef{#1}}
\fi
%%%%
%%%% general definition of skipped comment
%%%%
\def\excludecomment
#1{\message{Excluding comment '#1'}%
\csarg\def{#1}{\let\AfterComment\relax
\def\ThisComment####1{}\ProcessComment{#1}}%
\csarg\let{After#1Comment}\TossComment
\CommentEndDef{#1}}
\if 0%
\ifx\fmtname\latexename
0%
\else \ifx\fmtname\latexname
0%
\else
1%
\fi \fi
% latex & latex2e:
\def\EndOfComment#1{\endgroup\end{#1}%
\csname After#1Comment\endcsname}
\def\CommentEndDef#1{{\escapechar=-1\relax
\csarg\xdef{End#1Test}{\string\\end\string\{#1\string\}}%
}}
\else
% plain & other
\def\EndOfComment#1{\endgroup\AfterComment}
\def\CommentEndDef#1{{\escapechar=-1\relax
\csarg\xdef{End#1Test}{\string\\end#1}%
}}
\fi
\excludecomment{comment}
\endinput
\endinput
%:%file=~~/lib/texinputs/comment.sty%:%

View File

@ -0,0 +1,294 @@
%%
%% macros for Isabelle generated LaTeX output
%%
%%% Simple document preparation (based on theory token language and symbols)
% isabelle environments
\newcommand{\isabellecontext}{UNKNOWN}
\newcommand{\setisabellecontext}[1]{\def\isabellecontext{#1}}
\newcommand{\isastyle}{\UNDEF}
\newcommand{\isastylett}{\UNDEF}
\newcommand{\isastyleminor}{\UNDEF}
\newcommand{\isastyleminortt}{\UNDEF}
\newcommand{\isastylescript}{\UNDEF}
\newcommand{\isastyletext}{\normalsize\normalfont\rmfamily}
\newcommand{\isastyletxt}{\normalfont\rmfamily}
\newcommand{\isastylecmt}{\normalfont\rmfamily}
\newcommand{\isaspacing}{%
\sfcode 42 1000 % .
\sfcode 63 1000 % ?
\sfcode 33 1000 % !
\sfcode 58 1000 % :
\sfcode 59 1000 % ;
\sfcode 44 1000 % ,
}
%symbol markup -- \emph achieves decent spacing via italic corrections
\newcommand{\isamath}[1]{\emph{$#1$}}
\newcommand{\isatext}[1]{\emph{#1}}
\DeclareRobustCommand{\isascriptstyle}{\def\isamath##1{##1}\def\isatext##1{\mbox{\isaspacing\isastylescript##1}}}
\newcommand{\isactrlsub}[1]{\emph{\isascriptstyle${}\sb{#1}$}}
\newcommand{\isactrlsup}[1]{\emph{\isascriptstyle${}\sp{#1}$}}
\DeclareRobustCommand{\isactrlbsub}{\emph\bgroup\math{}\sb\bgroup\mbox\bgroup\isaspacing\isastylescript}
\DeclareRobustCommand{\isactrlesub}{\egroup\egroup\endmath\egroup}
\DeclareRobustCommand{\isactrlbsup}{\emph\bgroup\math{}\sp\bgroup\mbox\bgroup\isaspacing\isastylescript}
\DeclareRobustCommand{\isactrlesup}{\egroup\egroup\endmath\egroup}
\newcommand{\isactrlbold}[1]{{\bfseries\upshape\boldmath#1}}
%blackboard-bold (requires font txmia from pxfonts)
\DeclareSymbolFont{bbbfont}{U}{txmia}{m}{it}
\SetSymbolFont{bbbfont}{bold}{U}{txmia}{bx}{it}
\DeclareMathSymbol{\bbbA}{\mathord}{bbbfont}{129}
\DeclareMathSymbol{\bbbB}{\mathord}{bbbfont}{130}
\DeclareMathSymbol{\bbbC}{\mathord}{bbbfont}{131}
\DeclareMathSymbol{\bbbD}{\mathord}{bbbfont}{132}
\DeclareMathSymbol{\bbbE}{\mathord}{bbbfont}{133}
\DeclareMathSymbol{\bbbF}{\mathord}{bbbfont}{134}
\DeclareMathSymbol{\bbbG}{\mathord}{bbbfont}{135}
\DeclareMathSymbol{\bbbH}{\mathord}{bbbfont}{136}
\DeclareMathSymbol{\bbbI}{\mathord}{bbbfont}{137}
\DeclareMathSymbol{\bbbJ}{\mathord}{bbbfont}{138}
\DeclareMathSymbol{\bbbK}{\mathord}{bbbfont}{139}
\DeclareMathSymbol{\bbbL}{\mathord}{bbbfont}{140}
\DeclareMathSymbol{\bbbM}{\mathord}{bbbfont}{141}
\DeclareMathSymbol{\bbbN}{\mathord}{bbbfont}{142}
\DeclareMathSymbol{\bbbO}{\mathord}{bbbfont}{143}
\DeclareMathSymbol{\bbbP}{\mathord}{bbbfont}{144}
\DeclareMathSymbol{\bbbQ}{\mathord}{bbbfont}{145}
\DeclareMathSymbol{\bbbR}{\mathord}{bbbfont}{146}
\DeclareMathSymbol{\bbbS}{\mathord}{bbbfont}{147}
\DeclareMathSymbol{\bbbT}{\mathord}{bbbfont}{148}
\DeclareMathSymbol{\bbbU}{\mathord}{bbbfont}{149}
\DeclareMathSymbol{\bbbV}{\mathord}{bbbfont}{150}
\DeclareMathSymbol{\bbbW}{\mathord}{bbbfont}{151}
\DeclareMathSymbol{\bbbX}{\mathord}{bbbfont}{152}
\DeclareMathSymbol{\bbbY}{\mathord}{bbbfont}{153}
\DeclareMathSymbol{\bbbZ}{\mathord}{bbbfont}{154}
\newenvironment{isaantiq}{{\isacharat\isacharbraceleft}}{{\isacharbraceright}}
\newdimen\isa@parindent\newdimen\isa@parskip
\newenvironment{isabellebody}{%
\isamarkuptrue\par%
\isa@parindent\parindent\parindent0pt%
\isa@parskip\parskip\parskip0pt%
\isaspacing\isastyle}{\par}
\newenvironment{isabellebodytt}{%
\isamarkuptrue\par%
\isa@parindent\parindent\parindent0pt%
\isa@parskip\parskip\parskip0pt%
\isaspacing\isastylett}{\par}
\newenvironment{isabelle}
{\begin{trivlist}\begin{isabellebody}\item\relax}
{\end{isabellebody}\end{trivlist}}
\newenvironment{isabellett}
{\begin{trivlist}\begin{isabellebodytt}\item\relax}
{\end{isabellebodytt}\end{trivlist}}
\newcommand{\isa}[1]{\emph{\isaspacing\isastyleminor #1}}
\newcommand{\isatt}[1]{\emph{\isaspacing\isastyleminortt #1}}
\newcommand{\isaindent}[1]{\hphantom{#1}}
\newcommand{\isanewline}{\mbox{}\par\mbox{}}
\newcommand{\isasep}{}
\newcommand{\isadigit}[1]{#1}
\newcommand{\isachardefaults}{%
\def\isacharbell{\isamath{\bigbox}}%requires stmaryrd
\chardef\isacharbang=`\!%
\chardef\isachardoublequote=`\"%
\chardef\isachardoublequoteopen=`\"%
\chardef\isachardoublequoteclose=`\"%
\chardef\isacharhash=`\#%
\chardef\isachardollar=`\$%
\chardef\isacharpercent=`\%%
\chardef\isacharampersand=`\&%
\chardef\isacharprime=`\'%
\chardef\isacharparenleft=`\(%
\chardef\isacharparenright=`\)%
\chardef\isacharasterisk=`\*%
\chardef\isacharplus=`\+%
\chardef\isacharcomma=`\,%
\chardef\isacharminus=`\-%
\chardef\isachardot=`\.%
\chardef\isacharslash=`\/%
\chardef\isacharcolon=`\:%
\chardef\isacharsemicolon=`\;%
\chardef\isacharless=`\<%
\chardef\isacharequal=`\=%
\chardef\isachargreater=`\>%
\chardef\isacharquery=`\?%
\chardef\isacharat=`\@%
\chardef\isacharbrackleft=`\[%
\chardef\isacharbackslash=`\\%
\chardef\isacharbrackright=`\]%
\chardef\isacharcircum=`\^%
\chardef\isacharunderscore=`\_%
\def\isacharunderscorekeyword{\_}%
\chardef\isacharbackquote=`\`%
\chardef\isacharbackquoteopen=`\`%
\chardef\isacharbackquoteclose=`\`%
\chardef\isacharbraceleft=`\{%
\chardef\isacharbar=`\|%
\chardef\isacharbraceright=`\}%
\chardef\isachartilde=`\~%
\def\isacartoucheopen{\isatext{\guilsinglleft}}%
\def\isacartoucheclose{\isatext{\guilsinglright}}%
}
% keyword and section markup
\newcommand{\isakeyword}[1]
{\emph{\normalfont\bfseries\def\isachardot{.}\def\isacharunderscore{\isacharunderscorekeyword}%
\def\isacharbraceleft{\{}\def\isacharbraceright{\}}#1}}
\newcommand{\isacommand}[1]{\isakeyword{#1}}
\newcommand{\isakeywordONE}[1]{\isakeyword{#1}}
\newcommand{\isakeywordTWO}[1]{\isakeyword{#1}}
\newcommand{\isakeywordTHREE}[1]{\isakeyword{#1}}
\newcommand{\isatclass}[1]{#1}
\newcommand{\isatconst}[1]{#1}
\newcommand{\isatfree}[1]{#1}
\newcommand{\isatvar}[1]{#1}
\newcommand{\isaconst}[1]{#1}
\newcommand{\isafree}[1]{#1}
\newcommand{\isaskolem}[1]{#1}
\newcommand{\isabound}[1]{#1}
\newcommand{\isavar}[1]{#1}
\newcommand{\isakeywordcontrol}[1]
{\emph{\normalfont\bfseries\itshape\def\isacharunderscore{\isacharunderscorekeyword}#1\,}}
\newcommand{\isamarkupchapter}[1]{\chapter{#1}}
\newcommand{\isamarkupsection}[1]{\section{#1}}
\newcommand{\isamarkupsubsection}[1]{\subsection{#1}}
\newcommand{\isamarkupsubsubsection}[1]{\subsubsection{#1}}
\newcommand{\isamarkupparagraph}[1]{\paragraph{#1}}
\newcommand{\isamarkupsubparagraph}[1]{\subparagraph{#1}}
\newif\ifisamarkup
\newcommand{\isabeginpar}{\par\ifisamarkup\relax\else\medskip\fi}
\newcommand{\isaendpar}{\par\medskip}
\newenvironment{isapar}{\parindent\isa@parindent\parskip\isa@parskip\isabeginpar}{\isaendpar}
\newenvironment{isamarkuptext}{\par\isastyletext\begin{isapar}}{\end{isapar}}
\newenvironment{isamarkuptxt}{\par\isastyletxt\begin{isapar}}{\end{isapar}}
\newcommand{\isamarkupcmt}[1]{{\isastylecmt--- #1}}
% index entries
\newcommand{\isaindexdef}[1]{\textbf{#1}}
\newcommand{\isaindexref}[1]{#1}
% styles
\def\isabellestyle#1{\csname isabellestyle#1\endcsname}
\newcommand{\isabellestyledefault}{%
\def\isastyle{\small\normalfont\ttfamily\slshape}%
\def\isastylett{\small\normalfont\ttfamily}%
\def\isastyleminor{\small\normalfont\ttfamily\slshape}%
\def\isastyleminortt{\small\normalfont\ttfamily}%
\def\isastylescript{\footnotesize\normalfont\ttfamily\slshape}%
\isachardefaults%
}
\isabellestyledefault
\newcommand{\isabellestylett}{%
\def\isastyle{\small\normalfont\ttfamily}%
\def\isastylett{\small\normalfont\ttfamily}%
\def\isastyleminor{\small\normalfont\ttfamily}%
\def\isastyleminortt{\small\normalfont\ttfamily}%
\def\isastylescript{\footnotesize\normalfont\ttfamily}%
\isachardefaults%
}
\newcommand{\isabellestyleit}{%
\def\isastyle{\small\normalfont\itshape}%
\def\isastylett{\small\normalfont\ttfamily}%
\def\isastyleminor{\normalfont\itshape}%
\def\isastyleminortt{\normalfont\ttfamily}%
\def\isastylescript{\footnotesize\normalfont\itshape}%
\isachardefaults%
\def\isacharunderscorekeyword{\mbox{-}}%
\def\isacharbang{\isamath{!}}%
\def\isachardoublequote{}%
\def\isachardoublequoteopen{}%
\def\isachardoublequoteclose{}%
\def\isacharhash{\isamath{\#}}%
\def\isachardollar{\isamath{\$}}%
\def\isacharpercent{\isamath{\%}}%
\def\isacharampersand{\isamath{\&}}%
\def\isacharprime{\isamath{\mskip2mu{'}\mskip-2mu}}%
\def\isacharparenleft{\isamath{(}}%
\def\isacharparenright{\isamath{)}}%
\def\isacharasterisk{\isamath{*}}%
\def\isacharplus{\isamath{+}}%
\def\isacharcomma{\isamath{\mathord,}}%
\def\isacharminus{\isamath{-}}%
\def\isachardot{\isamath{\mathord.}}%
\def\isacharslash{\isamath{/}}%
\def\isacharcolon{\isamath{\mathord:}}%
\def\isacharsemicolon{\isamath{\mathord;}}%
\def\isacharless{\isamath{<}}%
\def\isacharequal{\isamath{=}}%
\def\isachargreater{\isamath{>}}%
\def\isacharat{\isamath{@}}%
\def\isacharbrackleft{\isamath{[}}%
\def\isacharbackslash{\isamath{\backslash}}%
\def\isacharbrackright{\isamath{]}}%
\def\isacharunderscore{\mbox{-}}%
\def\isacharbraceleft{\isamath{\{}}%
\def\isacharbar{\isamath{\mid}}%
\def\isacharbraceright{\isamath{\}}}%
\def\isachartilde{\isamath{{}\sp{\sim}}}%
\def\isacharbackquoteopen{\isatext{\guilsinglleft}}%
\def\isacharbackquoteclose{\isatext{\guilsinglright}}%
}
\newcommand{\isabellestyleliteral}{%
\isabellestyleit%
\def\isacharunderscore{\_}%
\def\isacharunderscorekeyword{\_}%
\chardef\isacharbackquoteopen=`\`%
\chardef\isacharbackquoteclose=`\`%
}
\newcommand{\isabellestyleliteralunderscore}{%
\isabellestyleliteral%
\def\isacharunderscore{\textunderscore}%
\def\isacharunderscorekeyword{\textunderscore}%
}
\newcommand{\isabellestylesl}{%
\isabellestyleit%
\def\isastyle{\small\normalfont\slshape}%
\def\isastylett{\small\normalfont\ttfamily}%
\def\isastyleminor{\normalfont\slshape}%
\def\isastyleminortt{\normalfont\ttfamily}%
\def\isastylescript{\footnotesize\normalfont\slshape}%
}
% cancel text
\usepackage[normalem]{ulem}
\newcommand{\isamarkupcancel}[1]{\isa{\xout{#1}}}
% tags
\newcommand{\isafold}[1]{\emph{$\langle\mathord{\mathit{#1}}\rangle$}}
\IfFileExists{isabelletags.sty}{\usepackage{isabelletags}}{}
\endinput
%:%file=~~/lib/texinputs/isabelle.sty%:%

View File

@ -0,0 +1,506 @@
%%
%% definitions of standard Isabelle symbols
%%
\newcommand{\isasymzero}{\isamath{\mathbf{0}}} %requires amssymb
\newcommand{\isasymone}{\isamath{\mathbf{1}}} %requires amssymb
\newcommand{\isasymtwo}{\isamath{\mathbf{2}}} %requires amssymb
\newcommand{\isasymthree}{\isamath{\mathbf{3}}} %requires amssymb
\newcommand{\isasymfour}{\isamath{\mathbf{4}}} %requires amssymb
\newcommand{\isasymfive}{\isamath{\mathbf{5}}} %requires amssymb
\newcommand{\isasymsix}{\isamath{\mathbf{6}}} %requires amssymb
\newcommand{\isasymseven}{\isamath{\mathbf{7}}} %requires amssymb
\newcommand{\isasymeight}{\isamath{\mathbf{8}}} %requires amssymb
\newcommand{\isasymnine}{\isamath{\mathbf{9}}} %requires amssymb
\newcommand{\isasymA}{\isamath{\mathcal{A}}}
\newcommand{\isasymB}{\isamath{\mathcal{B}}}
\newcommand{\isasymC}{\isamath{\mathcal{C}}}
\newcommand{\isasymD}{\isamath{\mathcal{D}}}
\newcommand{\isasymE}{\isamath{\mathcal{E}}}
\newcommand{\isasymF}{\isamath{\mathcal{F}}}
\newcommand{\isasymG}{\isamath{\mathcal{G}}}
\newcommand{\isasymH}{\isamath{\mathcal{H}}}
\newcommand{\isasymI}{\isamath{\mathcal{I}}}
\newcommand{\isasymJ}{\isamath{\mathcal{J}}}
\newcommand{\isasymK}{\isamath{\mathcal{K}}}
\newcommand{\isasymL}{\isamath{\mathcal{L}}}
\newcommand{\isasymM}{\isamath{\mathcal{M}}}
\newcommand{\isasymN}{\isamath{\mathcal{N}}}
\newcommand{\isasymO}{\isamath{\mathcal{O}}}
\newcommand{\isasymP}{\isamath{\mathcal{P}}}
\newcommand{\isasymQ}{\isamath{\mathcal{Q}}}
\newcommand{\isasymR}{\isamath{\mathcal{R}}}
\newcommand{\isasymS}{\isamath{\mathcal{S}}}
\newcommand{\isasymT}{\isamath{\mathcal{T}}}
\newcommand{\isasymU}{\isamath{\mathcal{U}}}
\newcommand{\isasymV}{\isamath{\mathcal{V}}}
\newcommand{\isasymW}{\isamath{\mathcal{W}}}
\newcommand{\isasymX}{\isamath{\mathcal{X}}}
\newcommand{\isasymY}{\isamath{\mathcal{Y}}}
\newcommand{\isasymZ}{\isamath{\mathcal{Z}}}
\newcommand{\isasyma}{\isamath{\mathrm{a}}}
\newcommand{\isasymb}{\isamath{\mathrm{b}}}
\newcommand{\isasymc}{\isamath{\mathrm{c}}}
\newcommand{\isasymd}{\isamath{\mathrm{d}}}
\newcommand{\isasyme}{\isamath{\mathrm{e}}}
\newcommand{\isasymf}{\isamath{\mathrm{f}}}
\newcommand{\isasymg}{\isamath{\mathrm{g}}}
\newcommand{\isasymh}{\isamath{\mathrm{h}}}
\newcommand{\isasymi}{\isamath{\mathrm{i}}}
\newcommand{\isasymj}{\isamath{\mathrm{j}}}
\newcommand{\isasymk}{\isamath{\mathrm{k}}}
\newcommand{\isasyml}{\isamath{\mathrm{l}}}
\newcommand{\isasymm}{\isamath{\mathrm{m}}}
\newcommand{\isasymn}{\isamath{\mathrm{n}}}
\newcommand{\isasymo}{\isamath{\mathrm{o}}}
\newcommand{\isasymp}{\isamath{\mathrm{p}}}
\newcommand{\isasymq}{\isamath{\mathrm{q}}}
\newcommand{\isasymr}{\isamath{\mathrm{r}}}
\newcommand{\isasyms}{\isamath{\mathrm{s}}}
\newcommand{\isasymt}{\isamath{\mathrm{t}}}
\newcommand{\isasymu}{\isamath{\mathrm{u}}}
\newcommand{\isasymv}{\isamath{\mathrm{v}}}
\newcommand{\isasymw}{\isamath{\mathrm{w}}}
\newcommand{\isasymx}{\isamath{\mathrm{x}}}
\newcommand{\isasymy}{\isamath{\mathrm{y}}}
\newcommand{\isasymz}{\isamath{\mathrm{z}}}
\newcommand{\isasymAA}{\isamath{\mathfrak{A}}} %requires eufrak
\newcommand{\isasymBB}{\isamath{\mathfrak{B}}} %requires eufrak
\newcommand{\isasymCC}{\isamath{\mathfrak{C}}} %requires eufrak
\newcommand{\isasymDD}{\isamath{\mathfrak{D}}} %requires eufrak
\newcommand{\isasymEE}{\isamath{\mathfrak{E}}} %requires eufrak
\newcommand{\isasymFF}{\isamath{\mathfrak{F}}} %requires eufrak
\newcommand{\isasymGG}{\isamath{\mathfrak{G}}} %requires eufrak
\newcommand{\isasymHH}{\isamath{\mathfrak{H}}} %requires eufrak
\newcommand{\isasymII}{\isamath{\mathfrak{I}}} %requires eufrak
\newcommand{\isasymJJ}{\isamath{\mathfrak{J}}} %requires eufrak
\newcommand{\isasymKK}{\isamath{\mathfrak{K}}} %requires eufrak
\newcommand{\isasymLL}{\isamath{\mathfrak{L}}} %requires eufrak
\newcommand{\isasymMM}{\isamath{\mathfrak{M}}} %requires eufrak
\newcommand{\isasymNN}{\isamath{\mathfrak{N}}} %requires eufrak
\newcommand{\isasymOO}{\isamath{\mathfrak{O}}} %requires eufrak
\newcommand{\isasymPP}{\isamath{\mathfrak{P}}} %requires eufrak
\newcommand{\isasymQQ}{\isamath{\mathfrak{Q}}} %requires eufrak
\newcommand{\isasymRR}{\isamath{\mathfrak{R}}} %requires eufrak
\newcommand{\isasymSS}{\isamath{\mathfrak{S}}} %requires eufrak
\newcommand{\isasymTT}{\isamath{\mathfrak{T}}} %requires eufrak
\newcommand{\isasymUU}{\isamath{\mathfrak{U}}} %requires eufrak
\newcommand{\isasymVV}{\isamath{\mathfrak{V}}} %requires eufrak
\newcommand{\isasymWW}{\isamath{\mathfrak{W}}} %requires eufrak
\newcommand{\isasymXX}{\isamath{\mathfrak{X}}} %requires eufrak
\newcommand{\isasymYY}{\isamath{\mathfrak{Y}}} %requires eufrak
\newcommand{\isasymZZ}{\isamath{\mathfrak{Z}}} %requires eufrak
\newcommand{\isasymaa}{\isamath{\mathfrak{a}}} %requires eufrak
\newcommand{\isasymbb}{\isamath{\mathfrak{b}}} %requires eufrak
\newcommand{\isasymcc}{\isamath{\mathfrak{c}}} %requires eufrak
\newcommand{\isasymdd}{\isamath{\mathfrak{d}}} %requires eufrak
\newcommand{\isasymee}{\isamath{\mathfrak{e}}} %requires eufrak
\newcommand{\isasymff}{\isamath{\mathfrak{f}}} %requires eufrak
\newcommand{\isasymgg}{\isamath{\mathfrak{g}}} %requires eufrak
\newcommand{\isasymhh}{\isamath{\mathfrak{h}}} %requires eufrak
\newcommand{\isasymii}{\isamath{\mathfrak{i}}} %requires eufrak
\newcommand{\isasymjj}{\isamath{\mathfrak{j}}} %requires eufrak
\newcommand{\isasymkk}{\isamath{\mathfrak{k}}} %requires eufrak
\newcommand{\isasymll}{\isamath{\mathfrak{l}}} %requires eufrak
\newcommand{\isasymmm}{\isamath{\mathfrak{m}}} %requires eufrak
\newcommand{\isasymnn}{\isamath{\mathfrak{n}}} %requires eufrak
\newcommand{\isasymoo}{\isamath{\mathfrak{o}}} %requires eufrak
\newcommand{\isasympp}{\isamath{\mathfrak{p}}} %requires eufrak
\newcommand{\isasymqq}{\isamath{\mathfrak{q}}} %requires eufrak
\newcommand{\isasymrr}{\isamath{\mathfrak{r}}} %requires eufrak
\newcommand{\isasymss}{\isamath{\mathfrak{s}}} %requires eufrak
\newcommand{\isasymtt}{\isamath{\mathfrak{t}}} %requires eufrak
\newcommand{\isasymuu}{\isamath{\mathfrak{u}}} %requires eufrak
\newcommand{\isasymvv}{\isamath{\mathfrak{v}}} %requires eufrak
\newcommand{\isasymww}{\isamath{\mathfrak{w}}} %requires eufrak
\newcommand{\isasymxx}{\isamath{\mathfrak{x}}} %requires eufrak
\newcommand{\isasymyy}{\isamath{\mathfrak{y}}} %requires eufrak
\newcommand{\isasymzz}{\isamath{\mathfrak{z}}} %requires eufrak
\newcommand{\isasymalpha}{\isamath{\alpha}}
\newcommand{\isasymbeta}{\isamath{\beta}}
\newcommand{\isasymgamma}{\isamath{\gamma}}
\newcommand{\isasymdelta}{\isamath{\delta}}
\newcommand{\isasymepsilon}{\isamath{\varepsilon}}
\newcommand{\isasymzeta}{\isamath{\zeta}}
\newcommand{\isasymeta}{\isamath{\eta}}
\newcommand{\isasymtheta}{\isamath{\vartheta}}
\newcommand{\isasymiota}{\isamath{\iota}}
\newcommand{\isasymkappa}{\isamath{\kappa}}
\newcommand{\isasymlambda}{\isamath{\lambda}}
\newcommand{\isasymmu}{\isamath{\mu}}
\newcommand{\isasymnu}{\isamath{\nu}}
\newcommand{\isasymxi}{\isamath{\xi}}
\newcommand{\isasympi}{\isamath{\pi}}
\newcommand{\isasymrho}{\isamath{\varrho}}
\newcommand{\isasymsigma}{\isamath{\sigma}}
\newcommand{\isasymtau}{\isamath{\tau}}
\newcommand{\isasymupsilon}{\isamath{\upsilon}}
\newcommand{\isasymphi}{\isamath{\varphi}}
\newcommand{\isasymchi}{\isamath{\chi}}
\newcommand{\isasympsi}{\isamath{\psi}}
\newcommand{\isasymomega}{\isamath{\omega}}
\newcommand{\isasymGamma}{\isamath{\Gamma}}
\newcommand{\isasymDelta}{\isamath{\Delta}}
\newcommand{\isasymTheta}{\isamath{\Theta}}
\newcommand{\isasymLambda}{\isamath{\Lambda}}
\newcommand{\isasymXi}{\isamath{\Xi}}
\newcommand{\isasymPi}{\isamath{\Pi}}
\newcommand{\isasymSigma}{\isamath{\Sigma}}
\newcommand{\isasymUpsilon}{\isamath{\Upsilon}}
\newcommand{\isasymPhi}{\isamath{\Phi}}
\newcommand{\isasymPsi}{\isamath{\Psi}}
\newcommand{\isasymOmega}{\isamath{\Omega}}
\newcommand{\isasymbbbA}{\isamath{\bbbA}} %requires font txmia from txfonts
\newcommand{\isasymbool}{\isamath{\bbbB}} %requires font txmia from txfonts
\newcommand{\isasymcomplex}{\isamath{\bbbC}} %requires font txmia from txfonts
\newcommand{\isasymbbbD}{\isamath{\bbbD}} %requires font txmia from txfonts
\newcommand{\isasymbbbE}{\isamath{\bbbE}} %requires font txmia from txfonts
\newcommand{\isasymbbbF}{\isamath{\bbbF}} %requires font txmia from txfonts
\newcommand{\isasymbbbG}{\isamath{\bbbG}} %requires font txmia from txfonts
\newcommand{\isasymbbbH}{\isamath{\bbbH}} %requires font txmia from txfonts
\newcommand{\isasymbbbI}{\isamath{\bbbI}} %requires font txmia from txfonts
\newcommand{\isasymbbbJ}{\isamath{\bbbJ}} %requires font txmia from txfonts
\newcommand{\isasymbbbK}{\isamath{\bbbK}} %requires font txmia from txfonts
\newcommand{\isasymbbbL}{\isamath{\bbbL}} %requires font txmia from txfonts
\newcommand{\isasymbbbM}{\isamath{\bbbM}} %requires font txmia from txfonts
\newcommand{\isasymnat}{\isamath{\bbbN}} %requires font txmia from txfonts
\newcommand{\isasymbbbO}{\isamath{\bbbO}} %requires font txmia from txfonts
\newcommand{\isasymbbbP}{\isamath{\bbbP}} %requires font txmia from txfonts
\newcommand{\isasymrat}{\isamath{\bbbQ}} %requires font txmia from txfonts
\newcommand{\isasymreal}{\isamath{\bbbR}} %requires font txmia from txfonts
\newcommand{\isasymbbbS}{\isamath{\bbbS}} %requires font txmia from txfonts
\newcommand{\isasymbbbT}{\isamath{\bbbT}} %requires font txmia from txfonts
\newcommand{\isasymbbbU}{\isamath{\bbbU}} %requires font txmia from txfonts
\newcommand{\isasymbbbV}{\isamath{\bbbV}} %requires font txmia from txfonts
\newcommand{\isasymbbbW}{\isamath{\bbbW}} %requires font txmia from txfonts
\newcommand{\isasymbbbX}{\isamath{\bbbX}} %requires font txmia from txfonts
\newcommand{\isasymbbbY}{\isamath{\bbbY}} %requires font txmia from txfonts
\newcommand{\isasymint}{\isamath{\bbbZ}} %requires font txmia from txfonts
\newcommand{\isasymleftarrow}{\isamath{\leftarrow}}
\newcommand{\isasymrightarrow}{\isamath{\rightarrow}}
\newcommand{\isasymlongleftarrow}{\isamath{\longleftarrow}}
\newcommand{\isasymlongrightarrow}{\isamath{\longrightarrow}}
\newcommand{\isasymlonglongleftarrow}{\isamath{\xleftarrow{\hphantom{AAA}}}} %requires amsmath
\newcommand{\isasymlonglongrightarrow}{\isamath{\xrightarrow{\hphantom{AAA}}}} %requires amsmath
\newcommand{\isasymlonglonglongleftarrow}{\isamath{\xleftarrow{\hphantom{AAAA}}}} %requires amsmath
\newcommand{\isasymlonglonglongrightarrow}{\isamath{\xrightarrow{\hphantom{AAAA}}}} %requires amsmath
\newcommand{\isasymLeftarrow}{\isamath{\Leftarrow}}
\newcommand{\isasymRightarrow}{\isamath{\Rightarrow}}
\newcommand{\isasymLongleftarrow}{\isamath{\Longleftarrow}}
\newcommand{\isasymLongrightarrow}{\isamath{\Longrightarrow}}
\newcommand{\isasymLleftarrow}{\isamath{\Lleftarrow}} %requires amssymb
\newcommand{\isasymRrightarrow}{\isamath{\Rrightarrow}} %requires amssymb
\newcommand{\isasymleftrightarrow}{\isamath{\leftrightarrow}}
\newcommand{\isasymLeftrightarrow}{\isamath{\Leftrightarrow}}
\newcommand{\isasymlongleftrightarrow}{\isamath{\longleftrightarrow}}
\newcommand{\isasymLongleftrightarrow}{\isamath{\Longleftrightarrow}}
\newcommand{\isasymmapsto}{\isamath{\mapsto}}
\newcommand{\isasymlongmapsto}{\isamath{\longmapsto}}
\newcommand{\isasymmidarrow}{\isamath{\relbar}}
\newcommand{\isasymMidarrow}{\isamath{\Relbar}}
\newcommand{\isasymhookleftarrow}{\isamath{\hookleftarrow}}
\newcommand{\isasymhookrightarrow}{\isamath{\hookrightarrow}}
\newcommand{\isasymleftharpoondown}{\isamath{\leftharpoondown}}
\newcommand{\isasymrightharpoondown}{\isamath{\rightharpoondown}}
\newcommand{\isasymleftharpoonup}{\isamath{\leftharpoonup}}
\newcommand{\isasymrightharpoonup}{\isamath{\rightharpoonup}}
\newcommand{\isasymrightleftharpoons}{\isamath{\rightleftharpoons}}
\newcommand{\isasymleadsto}{\isamath{\leadsto}} %requires amssymb
\newcommand{\isasymdownharpoonleft}{\isamath{\downharpoonleft}} %requires amssymb
\newcommand{\isasymdownharpoonright}{\isamath{\downharpoonright}} %requires amssymb
\newcommand{\isasymupharpoonleft}{\isamath{\upharpoonleft}} %requires amssymb
\newcommand{\isasymupharpoonright}{\isamath{\upharpoonright}} %requires amssymb
\newcommand{\isasymrestriction}{\isamath{\restriction}} %requires amssymb
\newcommand{\isasymColon}{\isamath{\mathrel{::}}}
\newcommand{\isasymup}{\isamath{\uparrow}}
\newcommand{\isasymUp}{\isamath{\Uparrow}}
\newcommand{\isasymdown}{\isamath{\downarrow}}
\newcommand{\isasymDown}{\isamath{\Downarrow}}
\newcommand{\isasymupdown}{\isamath{\updownarrow}}
\newcommand{\isasymUpdown}{\isamath{\Updownarrow}}
\newcommand{\isasymlangle}{\isamath{\langle}}
\newcommand{\isasymrangle}{\isamath{\rangle}}
\newcommand{\isasymllangle}{\isamath{\langle\mskip-5mu\langle}}
\newcommand{\isasymrrangle}{\isamath{\rangle\mskip-5mu\rangle}}
\newcommand{\isasymlceil}{\isamath{\lceil}}
\newcommand{\isasymrceil}{\isamath{\rceil}}
\newcommand{\isasymlfloor}{\isamath{\lfloor}}
\newcommand{\isasymrfloor}{\isamath{\rfloor}}
\newcommand{\isasymlparr}{\isamath{\mathopen{(\mkern-3.3mu\mid}}}
\newcommand{\isasymrparr}{\isamath{\mathclose{\mid\mkern-3.3mu)}}}
\newcommand{\isasymlbrakk}{\isamath{\mathopen{\lbrack\mkern-3mu\lbrack}}}
\newcommand{\isasymrbrakk}{\isamath{\mathclose{\rbrack\mkern-3mu\rbrack}}}
\newcommand{\isasymlbrace}{\isamath{\mathopen{\lbrace\mkern-4.3mu\mid}}}
\newcommand{\isasymrbrace}{\isamath{\mathclose{\mid\mkern-4.3mu\rbrace}}}
\newcommand{\isasymlblot}{\isamath{{\langle}\mkern -3.5mu{|}}}
\newcommand{\isasymrblot}{\isamath{{|}\mkern -3.5mu{\rangle}}}
\newcommand{\isasymguillemotleft}{\isatext{\guillemotleft}}
\newcommand{\isasymguillemotright}{\isatext{\guillemotright}}
\newcommand{\isasymbottom}{\isamath{\bot}}
\newcommand{\isasymtop}{\isamath{\top}}
\newcommand{\isasymand}{\isamath{\wedge}}
\newcommand{\isasymAnd}{\isamath{\bigwedge}}
\newcommand{\isasymor}{\isamath{\vee}}
\newcommand{\isasymOr}{\isamath{\bigvee}}
\newcommand{\isasymforall}{\isamath{\forall\,}}
\newcommand{\isasymexists}{\isamath{\exists\,}}
\newcommand{\isasymnot}{\isamath{\neg}}
\newcommand{\isasymnexists}{\isamath{\nexists\,}} %requires amssymb
\newcommand{\isasymcircle}{\isamath{\ocircle}} %requires wasysym
\newcommand{\isasymbox}{\isamath{\Box}} %requires amssymb
\newcommand{\isasymdiamond}{\isamath{\Diamond}} %requires amssymb
\newcommand{\isasymdiamondop}{\isamath{\diamond}}
\newcommand{\isasymsurd}{\isamath{\surd}}
\newcommand{\isasymturnstile}{\isamath{\vdash}}
\newcommand{\isasymTurnstile}{\isamath{\models}}
\newcommand{\isasymtturnstile}{\isamath{\vdash\!\!\!\vdash}}
\newcommand{\isasymTTurnstile}{\isamath{\mid\!\models}}
\newcommand{\isasymstileturn}{\isamath{\dashv}}
\newcommand{\isasymle}{\isamath{\le}}
\newcommand{\isasymge}{\isamath{\ge}}
\newcommand{\isasymlless}{\isamath{\ll}}
\newcommand{\isasymggreater}{\isamath{\gg}}
\newcommand{\isasymlesssim}{\isamath{\lesssim}} %requires amssymb
\newcommand{\isasymgreatersim}{\isamath{\gtrsim}} %requires amssymb
\newcommand{\isasymlessapprox}{\isamath{\lessapprox}} %requires amssymb
\newcommand{\isasymgreaterapprox}{\isamath{\gtrapprox}} %requires amssymb
\newcommand{\isasymin}{\isamath{\in}}
\newcommand{\isasymnotin}{\isamath{\notin}}
\newcommand{\isasymsubset}{\isamath{\subset}}
\newcommand{\isasymsupset}{\isamath{\supset}}
\newcommand{\isasymsubseteq}{\isamath{\subseteq}}
\newcommand{\isasymsupseteq}{\isamath{\supseteq}}
\newcommand{\isasymsqsubset}{\isamath{\sqsubset}} %requires amssymb
\newcommand{\isasymsqsupset}{\isamath{\sqsupset}} %requires amssymb
\newcommand{\isasymsqsubseteq}{\isamath{\sqsubseteq}}
\newcommand{\isasymsqsupseteq}{\isamath{\sqsupseteq}}
\newcommand{\isasyminter}{\isamath{\cap}}
\newcommand{\isasymInter}{\isamath{\bigcap\,}}
\newcommand{\isasymunion}{\isamath{\cup}}
\newcommand{\isasymUnion}{\isamath{\bigcup\,}}
\newcommand{\isasymsqunion}{\isamath{\sqcup}}
\newcommand{\isasymSqunion}{\isamath{\bigsqcup\,}}
\newcommand{\isasymsqinter}{\isamath{\sqcap}}
\newcommand{\isasymSqinter}{\isamath{\bigsqcap\,}} %requires stmaryrd
\newcommand{\isasymsetminus}{\isamath{\setminus}}
\newcommand{\isasympropto}{\isamath{\propto}}
\newcommand{\isasymuplus}{\isamath{\uplus}}
\newcommand{\isasymUplus}{\isamath{\biguplus\,}}
\newcommand{\isasymnoteq}{\isamath{\not=}}
\newcommand{\isasymsim}{\isamath{\sim}}
\newcommand{\isasymdoteq}{\isamath{\doteq}}
\newcommand{\isasymsimeq}{\isamath{\simeq}}
\newcommand{\isasymapprox}{\isamath{\approx}}
\newcommand{\isasymasymp}{\isamath{\asymp}}
\newcommand{\isasymcong}{\isamath{\cong}}
\newcommand{\isasymsmile}{\isamath{\smile}}
\newcommand{\isasymequiv}{\isamath{\equiv}}
\newcommand{\isasymfrown}{\isamath{\frown}}
\newcommand{\isasymJoin}{\isamath{\Join}} %requires amssymb
\newcommand{\isasymbowtie}{\isamath{\bowtie}}
\newcommand{\isasymprec}{\isamath{\prec}}
\newcommand{\isasymsucc}{\isamath{\succ}}
\newcommand{\isasympreceq}{\isamath{\preceq}}
\newcommand{\isasymsucceq}{\isamath{\succeq}}
\newcommand{\isasymparallel}{\isamath{\parallel}}
\newcommand{\isasymParallel}{\isamath{\bigparallel}} %requires stmaryrd
\newcommand{\isasyminterleace}{\isamath{\interleave}} %requires stmaryrd
\newcommand{\isasymsslash}{\isamath{\sslash}} %requires stmaryrd
\newcommand{\isasymbar}{\isamath{\mid}}
\newcommand{\isasymbbar}{\isamath{[\mskip-1.5mu]}}
\newcommand{\isasymplusminus}{\isamath{\pm}}
\newcommand{\isasymminusplus}{\isamath{\mp}}
\newcommand{\isasymtimes}{\isamath{\times}}
\newcommand{\isasymdiv}{\isamath{\div}}
\newcommand{\isasymcdot}{\isamath{\cdot}}
\newcommand{\isasymsqdot}{\isamath{\sbox\z@{$\centerdot$}\ht\z@=.33333\ht\z@\vcenter{\box\z@}}} %requires amssymb
\newcommand{\isasymstar}{\isamath{\star}}
\newcommand{\isasymbullet}{\boldmath\isamath{\mathchoice{\displaystyle{\cdot}}{\textstyle{\cdot}}{\scriptstyle{\bullet}}{\scriptscriptstyle{\bullet}}}}
\newcommand{\isasymcirc}{\isamath{\circ}}
\newcommand{\isasymdagger}{\isamath{\dagger}}
\newcommand{\isasymddagger}{\isamath{\ddagger}}
\newcommand{\isasymlhd}{\isamath{\lhd}} %requires amssymb
\newcommand{\isasymrhd}{\isamath{\rhd}} %requires amssymb
\newcommand{\isasymunlhd}{\isamath{\unlhd}} %requires amssymb
\newcommand{\isasymunrhd}{\isamath{\unrhd}} %requires amssymb
\newcommand{\isasymtriangleleft}{\isamath{\triangleleft}}
\newcommand{\isasymtriangleright}{\isamath{\triangleright}}
\newcommand{\isasymtriangle}{\isamath{\triangle}}
\newcommand{\isasymtriangleq}{\isamath{\triangleq}} %requires amssymb
\newcommand{\isasymoplus}{\isamath{\oplus}}
\newcommand{\isasymOplus}{\isamath{\bigoplus\,}}
\newcommand{\isasymotimes}{\isamath{\otimes}}
\newcommand{\isasymOtimes}{\isamath{\bigotimes\,}}
\newcommand{\isasymodot}{\isamath{\odot}}
\newcommand{\isasymOdot}{\isamath{\bigodot\,}}
\newcommand{\isasymominus}{\isamath{\ominus}}
\newcommand{\isasymoslash}{\isamath{\oslash}}
\newcommand{\isasymdots}{\isamath{\dots}}
\newcommand{\isasymcdots}{\isamath{\cdots}}
\newcommand{\isasymSum}{\isamath{\sum\,}}
\newcommand{\isasymProd}{\isamath{\prod\,}}
\newcommand{\isasymCoprod}{\isamath{\coprod\,}}
\newcommand{\isasyminfinity}{\isamath{\infty}}
\newcommand{\isasymintegral}{\isamath{\int\,}}
\newcommand{\isasymointegral}{\isamath{\oint\,}}
\newcommand{\isasymclubsuit}{\isamath{\clubsuit}}
\newcommand{\isasymdiamondsuit}{\isamath{\diamondsuit}}
\newcommand{\isasymheartsuit}{\isamath{\heartsuit}}
\newcommand{\isasymspadesuit}{\isamath{\spadesuit}}
\newcommand{\isasymaleph}{\isamath{\aleph}}
\newcommand{\isasymemptyset}{\isamath{\emptyset}}
\newcommand{\isasymnabla}{\isamath{\nabla}}
\newcommand{\isasympartial}{\isamath{\partial}}
\newcommand{\isasymRe}{\isamath{\Re}}
\newcommand{\isasymIm}{\isamath{\Im}}
\newcommand{\isasymflat}{\isamath{\flat}}
\newcommand{\isasymnatural}{\isamath{\natural}}
\newcommand{\isasymsharp}{\isamath{\sharp}}
\newcommand{\isasymangle}{\isamath{\angle}}
\newcommand{\isasymcopyright}{\isatext{\normalfont\rmfamily\copyright}}
\newcommand{\isasymregistered}{\isatext{\normalfont\rmfamily\textregistered}}
\newcommand{\isasyminverse}{\isamath{{}^{-1}}}
\newcommand{\isasymonequarter}{\isatext{\normalfont\rmfamily\textonequarter}} %requires textcomp
\newcommand{\isasymonehalf}{\isatext{\normalfont\rmfamily\textonehalf}} %requires textcomp
\newcommand{\isasymthreequarters}{\isatext{\normalfont\rmfamily\textthreequarters}} %requires textcomp
\newcommand{\isasymordfeminine}{\isatext{\normalfont\rmfamily\textordfeminine}}
\newcommand{\isasymordmasculine}{\isatext{\normalfont\rmfamily\textordmasculine}}
\newcommand{\isasymsection}{\isatext{\normalfont\rmfamily\S}}
\newcommand{\isasymparagraph}{\isatext{\normalfont\rmfamily\P}}
\newcommand{\isasymexclamdown}{\isatext{\normalfont\rmfamily\textexclamdown}}
\newcommand{\isasymquestiondown}{\isatext{\normalfont\rmfamily\textquestiondown}}
\newcommand{\isasymeuro}{\isatext{\euro}} %requires eurosym
\newcommand{\isasympounds}{\isamath{\pounds}}
\newcommand{\isasymyen}{\isatext{\yen}} %requires amssymb
\newcommand{\isasymcent}{\isatext{\textcent}} %requires textcomp
\newcommand{\isasymcurrency}{\isatext{\textcurrency}} %requires textcomp
\newcommand{\isasymdegree}{\isatext{\normalfont\rmfamily\textdegree}} %requires textcomp
\newcommand{\isasymhyphen}{\isatext{\normalfont\rmfamily-}}
\newcommand{\isasymamalg}{\isamath{\amalg}}
\newcommand{\isasymmho}{\isamath{\mho}} %requires amssymb
\newcommand{\isasymlozenge}{\isamath{\lozenge}} %requires amssymb
\newcommand{\isasymwp}{\isamath{\wp}}
\newcommand{\isasymwrong}{\isamath{\wr}}
\newcommand{\isasymacute}{\isatext{\'\relax}}
\newcommand{\isasymindex}{\isatext{\i}}
\newcommand{\isasymdieresis}{\isatext{\"\relax}}
\newcommand{\isasymcedilla}{\isatext{\c\relax}}
\newcommand{\isasymhungarumlaut}{\isatext{\H\relax}}
\newcommand{\isasymsome}{\isamath{\epsilon\,}}
\newcommand{\isasymbind}{\isamath{\mathbin{>\!\!\!>\mkern-6.7mu=}}}
\newcommand{\isasymthen}{\isamath{\mathbin{>\!\!\!>}}}
%Z notation
\newcommand{\isaZhbar}[1]{\rlap{\raise.0001ex\hbox{\isamath{-}}}#1}
\newcommand{\isaZpvbar}[1]{\ooalign{\hfil\isamath{\mapstochar\mkern 5mu}\hfil\cr#1}}
\newcommand{\isaZfvbar}[1]{\ooalign{\hfil\isamath{\mapstochar\mkern 3mu\mapstochar\mkern 5mu}\hfil\cr#1}}
\newcommand{\isaZdarrow}[3]{\ooalign{\isamath{#1}\hfil\cr\isamath{\mkern#3mu\isamath{#2}}}}
\newcommand{\isasymZcomp}{\isamath{\fatsemi}} %requires stmaryrd
\newcommand{\isasymZinj}{\isamath{\rightarrowtail}} %requires amssymb
\newcommand{\isasymZpinj}{\isaZpvbar{\isamath{\rightarrowtail}}} %requires amssymb
\newcommand{\isasymZfinj}{\isaZfvbar{\isasymZinj}} %requires amssymb
\newcommand{\isasymZsurj}{\isaZdarrow{\rightarrow}{\rightarrow}{4}} %requires amssymb
\newcommand{\isasymZpsurj}{\isaZpvbar{\isasymZsurj}} %requires amssymb
\newcommand{\isasymZbij}{\isaZdarrow{\rightarrowtail}{\rightarrow}{5}} %requires amssymb
\newcommand{\isasymZpfun}{\isaZpvbar{\isamath{\rightarrow}}}
\newcommand{\isasymZffun}{\isaZfvbar{\isamath{\rightarrow}}}
\newcommand{\isasymZdres}{\isamath{\lhd}} %requires amssymb
\newcommand{\isasymZndres}{\isaZhbar{\isamath{\lhd}}} %requires amssymb
\newcommand{\isasymZrres}{\isamath{\rhd}} %requires amssymb
\newcommand{\isasymZnrres}{\isaZhbar{\isamath{\rhd}}} %requires amssymb
\newcommand{\isasymZspot}{\isamath{\bullet}}
\newcommand{\isasymZproject}{\isamath{\upharpoonright}} %requires amssymb
\newcommand{\isasymZsemi}{\isatext{\raise 0.66ex\hbox{\oalign{\hfil\isamath{\scriptscriptstyle\mathrm{o}}\hfil\cr\hfil\isamath{\scriptscriptstyle\mathrm{9}}\hfil}}}}
\newcommand{\isasymZtypecolon}{\isatext{\raise 0.6ex\hbox{\oalign{\hfil\isamath{\scriptscriptstyle\mathrm{o}}\hfil\cr\hfil\isamath{\scriptscriptstyle\mathrm{o}}\hfil}}}}
\newcommand{\isasymZhide}{\isamath{\backslash}}
\newcommand{\isasymZcat}{\isatext{\raise 0.8ex\hbox{\isamath{\mathchar\frown}}}}
\newcommand{\isasymZinbag}{\isatext{\ooalign{\isamath{\sqsubset\mkern-1mu}\cr\isamath{-\mkern-1mu}\cr}}}
\newcommand{\isasymhole}{\isatext{\normalfont\rmfamily\wasylozenge}} %requires wasysym
\newcommand{\isasymnewline}{\isatext{\fbox{$\hookleftarrow$}}}
\newcommand{\isasymcomment}{\isatext{\isastylecmt---}}
\newcommand{\isasymproof}{\isamath{\,\langle\mathit{proof}\rangle}}
\newcommand{\isasymopen}{\isatext{\guilsinglleft}}
\newcommand{\isasymclose}{\isatext{\guilsinglright}}
\newcommand{\isasymcheckmark}{\isatext{\ding{51}}} %requires pifont
\newcommand{\isasymcrossmark}{\isatext{\ding{55}}} %requires pifont
\newcommand{\isactrlmarker}{\isatext{\ding{48}}} %requires pifont
\newcommand{\isactrltry}{\isakeywordcontrol{try}}
\newcommand{\isactrlcan}{\isakeywordcontrol{can}}
\newcommand{\isactrlassert}{\isakeywordcontrol{assert}}
\newcommand{\isactrlcancel}{\isakeywordcontrol{cancel}}
\newcommand{\isactrlbinding}{\isakeywordcontrol{binding}}
\newcommand{\isactrlclass}{\isakeywordcontrol{class}}
\newcommand{\isactrlclassUNDERSCOREsyntax}{\isakeywordcontrol{class{\isacharunderscore}syntax}}
\newcommand{\isactrlcommandUNDERSCOREkeyword}{\isakeywordcontrol{command{\isacharunderscore}keyword}}
\newcommand{\isactrlconst}{\isakeywordcontrol{const}}
\newcommand{\isactrlconstUNDERSCOREabbrev}{\isakeywordcontrol{const{\isacharunderscore}abbrev}}
\newcommand{\isactrlconstUNDERSCOREname}{\isakeywordcontrol{const{\isacharunderscore}name}}
\newcommand{\isactrlconstUNDERSCOREsyntax}{\isakeywordcontrol{const{\isacharunderscore}syntax}}
\newcommand{\isactrlcontext}{\isakeywordcontrol{context}}
\newcommand{\isactrlcprop}{\isakeywordcontrol{cprop}}
\newcommand{\isactrlcterm}{\isakeywordcontrol{cterm}}
\newcommand{\isactrlctyp}{\isakeywordcontrol{ctyp}}
\newcommand{\isactrldir}{\isakeywordcontrol{dir}}
\newcommand{\isactrlfile}{\isakeywordcontrol{file}}
\newcommand{\isactrlhere}{\isakeywordcontrol{here}}
\newcommand{\isactrlinstantiate}{\isakeywordcontrol{instantiate}}
\newcommand{\isactrlkeyword}{\isakeywordcontrol{keyword}}
\newcommand{\isactrllatex}{\isakeywordcontrol{latex}}
\newcommand{\isactrllocale}{\isakeywordcontrol{locale}}
\newcommand{\isactrlmakeUNDERSCOREjudgment}{\isakeywordcontrol{make{\isacharunderscore}judgment}}
\newcommand{\isactrldestUNDERSCOREjudgment}{\isakeywordcontrol{dest{\isacharunderscore}judgment}}
\newcommand{\isactrlmakeUNDERSCOREstring}{\isakeywordcontrol{make{\isacharunderscore}string}}
\newcommand{\isactrlmasterUNDERSCOREdir}{\isakeywordcontrol{master{\isacharunderscore}dir}}
\newcommand{\isactrlmethod}{\isakeywordcontrol{method}}
\newcommand{\isactrlnamedUNDERSCOREtheorems}{\isakeywordcontrol{named{\isacharunderscore}theorems}}
\newcommand{\isactrlnonterminal}{\isakeywordcontrol{nonterminal}}
\newcommand{\isactrloracleUNDERSCOREname}{\isakeywordcontrol{oracle{\isacharunderscore}name}}
\newcommand{\isactrlpath}{\isakeywordcontrol{path}}
\newcommand{\isactrlpathUNDERSCOREbinding}{\isakeywordcontrol{path{\isacharunderscore}binding}}
\newcommand{\isactrlplugin}{\isakeywordcontrol{plugin}}
\newcommand{\isactrlprint}{\isakeywordcontrol{print}}
\newcommand{\isactrlprop}{\isakeywordcontrol{prop}}
\newcommand{\isactrlscala}{\isakeywordcontrol{scala}}
\newcommand{\isactrlscalaUNDERSCOREfunction}{\isakeywordcontrol{scala{\isacharunderscore}function}}
\newcommand{\isactrlscalaUNDERSCOREmethod}{\isakeywordcontrol{scala{\isacharunderscore}method}}
\newcommand{\isactrlscalaUNDERSCOREobject}{\isakeywordcontrol{scala{\isacharunderscore}object}}
\newcommand{\isactrlscalaUNDERSCOREtype}{\isakeywordcontrol{scala{\isacharunderscore}type}}
\newcommand{\isactrlsimproc}{\isakeywordcontrol{simproc}}
\newcommand{\isactrlsimprocUNDERSCOREsetup}{\isakeywordcontrol{simproc{\isacharunderscore}setup}}
\newcommand{\isactrlsort}{\isakeywordcontrol{sort}}
\newcommand{\isactrlsyntaxUNDERSCOREconst}{\isakeywordcontrol{syntax{\isacharunderscore}const}}
\newcommand{\isactrlsystemUNDERSCOREoption}{\isakeywordcontrol{system{\isacharunderscore}option}}
\newcommand{\isactrlterm}{\isakeywordcontrol{term}}
\newcommand{\isactrltheory}{\isakeywordcontrol{theory}}
\newcommand{\isactrltheoryUNDERSCOREcontext}{\isakeywordcontrol{theory{\isacharunderscore}context}}
\newcommand{\isactrltyp}{\isakeywordcontrol{typ}}
\newcommand{\isactrltypeUNDERSCOREabbrev}{\isakeywordcontrol{type{\isacharunderscore}abbrev}}
\newcommand{\isactrltypeUNDERSCOREname}{\isakeywordcontrol{type{\isacharunderscore}name}}
\newcommand{\isactrltypeUNDERSCOREsyntax}{\isakeywordcontrol{type{\isacharunderscore}syntax}}
\newcommand{\isactrlundefined}{\isakeywordcontrol{undefined}}
\newcommand{\isactrltvar}{\isakeywordcontrol{tvar}}
\newcommand{\isactrlvar}{\isakeywordcontrol{var}}
\newcommand{\isactrlverbatim}{\isakeywordcontrol{verbatim}}
\newcommand{\isactrlConst}{\isakeywordcontrol{Const}}
\newcommand{\isactrlConstUNDERSCORE}{\isakeywordcontrol{Const{\isacharunderscore}}}
\newcommand{\isactrlConstUNDERSCOREfn}{\isakeywordcontrol{Const{\isacharunderscore}fn}}
\newcommand{\isactrlType}{\isakeywordcontrol{Type}}
\newcommand{\isactrlTypeUNDERSCOREfn}{\isakeywordcontrol{Type{\isacharunderscore}fn}}
\newcommand{\isactrlcode}{\isakeywordcontrol{code}}
\newcommand{\isactrlcomputation}{\isakeywordcontrol{computation}}
\newcommand{\isactrlcomputationUNDERSCOREconv}{\isakeywordcontrol{computation{\isacharunderscore}conv}}
\newcommand{\isactrlcomputationUNDERSCOREcheck}{\isakeywordcontrol{computation{\isacharunderscore}check}}
\newcommand{\isactrlifUNDERSCORElinux}{\isakeywordcontrol{if{\isacharunderscore}linux}}
\newcommand{\isactrlifUNDERSCOREmacos}{\isakeywordcontrol{if{\isacharunderscore}macos}}
\newcommand{\isactrlifUNDERSCOREwindows}{\isakeywordcontrol{if{\isacharunderscore}windows}}
\newcommand{\isactrlifUNDERSCOREunix}{\isakeywordcontrol{if{\isacharunderscore}unix}}
\newcommand{\isactrlifUNDERSCOREnone}{\isakeywordcontrol{if{\isacharunderscore}none}}
\newcommand{\isactrlcite}{\isakeywordcontrol{cite}}
\newcommand{\isactrlnocite}{\isakeywordcontrol{nocite}}
\newcommand{\isactrlcitet}{\isakeywordcontrol{citet}}
\newcommand{\isactrlcitep}{\isakeywordcontrol{citep}}
\endinput
%:%file=~~/lib/texinputs/isabellesym.sty%:%

View File

@ -0,0 +1,20 @@
%plain TeX version of comment package -- much faster!
\let\isafmtname\fmtname\def\fmtname{plain}
\usepackage{comment}
\let\fmtname\isafmtname
\newcommand{\isakeeptag}[1]%
{\includecomment{isadelim#1}\includecomment{isatag#1}\csarg\def{isafold#1}{}}
\newcommand{\isadroptag}[1]%
{\excludecomment{isadelim#1}\excludecomment{isatag#1}\csarg\def{isafold#1}{}}
\newcommand{\isafoldtag}[1]%
{\includecomment{isadelim#1}\excludecomment{isatag#1}\csarg\def{isafold#1}{\isafold{#1}}}
\isakeeptag{ML}
\isakeeptag{document}
\isakeeptag{important}
\isadroptag{invisible}
\isakeeptag{proof}
\isakeeptag{theory}
\isakeeptag{unimportant}
\isakeeptag{visible}

View File

@ -0,0 +1,9 @@
%%
%% default hyperref setup (both for pdf and dvi output)
%%
\usepackage{color}
\definecolor{linkcolor}{rgb}{0,0,0.5}
\usepackage[colorlinks=true,linkcolor=linkcolor,citecolor=linkcolor,filecolor=linkcolor,urlcolor=linkcolor,pdfpagelabels]{hyperref}
\endinput
%:%file=~~/lib/texinputs/pdfsetup.sty%:%

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,62 @@
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{isabelle,isabellesym}
% further packages required for unusual symbols (see also
% isabellesym.sty), use only when needed
%\usepackage{amssymb}
%for \<leadsto>, \<box>, \<diamond>, \<sqsupset>, \<mho>, \<Join>,
%\<lhd>, \<lesssim>, \<greatersim>, \<lessapprox>, \<greaterapprox>,
%\<triangleq>, \<yen>, \<lozenge>
%\usepackage{eurosym}
%for \<euro>
%\usepackage[only,bigsqcap,bigparallel,fatsemi,interleave,sslash]{stmaryrd}
%for \<Sqinter>, \<Parallel>, \<Zsemi>, \<Parallel>, \<sslash>
%\usepackage{eufrak}
%for \<AA> ... \<ZZ>, \<aa> ... \<zz> (also included in amssymb)
%\usepackage{textcomp}
%for \<onequarter>, \<onehalf>, \<threequarters>, \<degree>, \<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}
% for uniform font size
%\renewcommand{\isastyle}{\isastyleminor}
\begin{document}
\title{Lifting}
\author{user}
\maketitle
\tableofcontents
% sane default for proof documents
\parindent 0pt\parskip 0.5ex
% generated text of all theories
\input{session}
% optional bibliography
%\bibliographystyle{abbrv}
%\bibliography{root}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
\endinput
%:%file=~/work/IsabelleClub/Lifting/document/root.tex%:%

View File

Binary file not shown.

462
Probability/Outline.thy Normal file
View File

@ -0,0 +1,462 @@
theory Outline
imports "HOL-Probability.Probability"
begin
section\<open>An overview of the Probability package.\<close>
text\<open>For most of this theory, we will make the neat semantic distinction that Achim made last week between probability and statistics.
Since the Probability package generalises as much as possible, this might not be overly helpful for us as we are not Probability Theorists.
Thus, I plan to give some concrete examples and link it to the theory as much as possible.
I can imagine that we definitely will not have time to go over everything, so I'll have this as an entry point to the Isabelle Club.
I propose we look at the following topics as they relate the most to what we try to do:
\<^item> Giry Monads and Probabilistic Programming
\<^item> Distributions
\<^item> Code Generation of Probability Mass Functions (pmfs)
Before we start with the more interesting topics, we must first be bored with the basic implementations of probability measures so we know
how to really use them\<close>
section\<open>The Probability Measure\<close>
text\<open>The start of the probability implementation can be found in \<^file>\<open>$ISABELLE_HOME/src/HOL/Probability/Probability_Measure.thy\<close>.
This defines a basic probability space. NB: the type @{typ \<open>'a measure\<close>} could be misleading. It defines the type of measure spaces, not a measurement.\<close>
print_locale prob_space
thm prob_space_def[simplified prob_space_axioms_def]
text\<open>Most of the probability theory formalisation occurs directly in the @{locale prob_space} or extensions of such locales (see below for example).
Concrete interpretations of locales are somewhat difficult to specify, but can be done.
The one of the formal requirements on probability spaces is that for the space \<open>(\<Omega>, A)\<close> to form a @{locale sigma_algebra}.
The simplest sigma-algebra possible is \<open>(\<Omega>, {{}, \<Omega>})\<close>. Now, (on a different algebra) the simplest measure function could be a uniform distribution, \<open>P(\<omega>) = 1 / |\<Omega>|\<close>.
Such measurements are known as the Laplace Probability Measures.
For most specifications, the formalism \<open>(\<Omega>, Pow \<Omega>)\<close> that gives the largest possible sigma-algebra will suffice.\<close>
subsection\<open>The Laplace Probability Space\<close>
locale Laplace_Space = prob_space +
fixes N :: nat
assumes N_gr_0: \<open>N > 0\<close>
and lcard: \<open>card (space M) = N\<close>
and lsets: \<open>events = Pow (space M)\<close>
and lprob: \<open>\<forall>\<omega> \<in> space M. prob {\<omega>} = 1 / N\<close>
notes laplace_space_assms = lcard lsets lprob N_gr_0
begin
sublocale sigma_algebra "(space M)" by unfold_locales
lemma laplace_prob_compl: \<open>\<forall>\<omega> \<in> space M. prob ((space M) - {\<omega>}) = (N - 1) / N\<close>
proof
fix \<omega>
assume \<open>\<omega> \<in> space M\<close>
show \<open>prob (space M - {\<omega>}) = real (N - 1) / real N\<close>
proof-
have \<open>prob (space M - {\<omega>}) = 1 - prob {\<omega>}\<close>
using laplace_space_assms \<open>\<omega> \<in> space M\<close> by (blast intro: prob_compl)
moreover have \<open>... = 1 - 1 / N\<close> using laplace_space_assms \<open>\<omega> \<in> space M\<close> by presburger
moreover have \<open>... = N / N - 1 / N\<close> using laplace_space_assms by auto
moreover have \<open>... = (N - 1) / N\<close> using laplace_space_assms
by (metis Multiseries_Expansion.intyness_1 One_nat_def Suc_leI diff_divide_distrib of_nat_diff_if)
ultimately show ?thesis by auto
qed
qed
end
subsection\<open>Example: A deck of cards\<close>
text\<open>Aside from the typical coin example, probably the most infamous example of the @{locale Laplace_Space} is a deck of cards.
This will help us illustrate working with realised probability spaces and maybe used later in some program verification!\<close>
subsubsection\<open>Preliminary Construction\<close>
datatype suit = spade nat | club nat | heart nat | diamond nat
lemma [simp]: \<open>inj spade\<close> \<open>inj club\<close> \<open>inj heart\<close> \<open>inj diamond\<close> by (simp add: inj_def)+
definition \<open>suit_constructors \<equiv> {spade, club, heart, diamond}\<close>
definition \<open>suit_deck f \<equiv> f ` {0..<13}\<close> for f :: \<open>nat \<Rightarrow> suit\<close>
lemma finite_suit_constructors[simp]: \<open>finite suit_constructors\<close> by (simp add: suit_constructors_def)
lemma suit_deck_finite: \<open>finite (suit_deck f)\<close> unfolding suit_deck_def by blast
lemma suit_deck_card:
assumes \<open>inj f\<close>
shows \<open>card (suit_deck f) = 13\<close> unfolding suit_deck_def
by(simp add: card_image inj_on_def assms[simplified inj_def])
lemma suit_decks_disj:
assumes \<open>f ` {0..<13} \<inter> g ` {0..<13} = {}\<close>
shows \<open>disjnt (suit_deck f) (suit_deck g)\<close>
by (simp add: assms disjnt_def suit_deck_def)
lemma disjnt_image_iff: \<open>f ` A \<inter> g ` B = {} \<longleftrightarrow> (\<forall>x \<in> A. \<forall>y \<in> B. f x \<noteq> g y)\<close>
by blast
abbreviation \<open>spades \<equiv> suit_deck spade\<close>
abbreviation \<open>clubs \<equiv> suit_deck club\<close>
abbreviation \<open>hearts \<equiv> suit_deck heart\<close>
abbreviation \<open>diamonds \<equiv> suit_deck diamond\<close>
definition \<open>decks = {spades, clubs, hearts, diamonds}\<close>
lemma [simp]: \<open>decks \<noteq> {}\<close> unfolding decks_def by simp
lemma finite_decks[simp]: \<open>finite decks\<close> by (simp add: decks_def)
lemma decks_card: \<open>card decks = 4\<close> unfolding decks_def by normalization
lemma decks_alt: \<open>decks = suit_deck ` suit_constructors\<close>
by (simp add: decks_def suit_deck_def suit_constructors_def)
definition \<open>deck = \<Union> decks\<close>
lemma decks_disjoint: \<open>disjoint decks\<close> unfolding decks_def
proof
fix x y
assume x0: \<open>x \<in> {spades, clubs, hearts, diamonds}\<close> and y0: \<open>y \<in> {spades, clubs, hearts, diamonds}\<close> and x_neq_y: \<open>x \<noteq> y\<close>
then consider (c0) \<open>x = spades\<close> | (c1) \<open>x = clubs\<close> | (c2) \<open>x = hearts\<close> | (c3) \<open>x = diamonds\<close> by blast
thus \<open>disjnt x y\<close>
proof(cases)
case c0
then consider \<open>y = clubs\<close> | \<open>y = hearts\<close> | \<open>y = diamonds\<close> using x_neq_y y0 by blast
thus ?thesis
by(cases, simp_all add: c0 suit_decks_disj disjnt_image_iff)
next
case c1
then consider \<open>y = spades\<close> | \<open>y = hearts\<close> | \<open>y = diamonds\<close> using x_neq_y y0 by blast
then show ?thesis
by(cases, simp_all add: c1 suit_decks_disj disjnt_image_iff)
next
case c2
then consider \<open>y = clubs\<close> | \<open>y = spades\<close> | \<open>y = diamonds\<close> using x_neq_y y0 by blast
then show ?thesis
by(cases, simp_all add: c2 suit_decks_disj disjnt_image_iff)
next
case c3
then consider \<open>y = clubs\<close> | \<open>y = spades\<close> | \<open>y = hearts\<close> using x_neq_y y0 by blast
then show ?thesis
by(cases, simp_all add: c3 suit_decks_disj disjnt_image_iff)
qed
qed
lemma deck_card: \<open>card deck = 52\<close> unfolding deck_def
proof(subst card_Union_disjoint[OF decks_disjoint])
show \<open>\<And>A. A \<in> decks \<Longrightarrow> finite A\<close>
by (metis decks_alt image_iff suit_deck_finite)
show \<open>(\<Sum>d \<in> decks. card d) = (52::nat)\<close>
proof-
have \<open>\<And>d. d \<in> decks \<Longrightarrow> card d = 13\<close>
by (metis (mono_tags, opaque_lifting) decks_def empty_iff inj_def insert_iff suit.simps(1,2,3,4) suit_deck_card)
hence \<open>(\<Sum>d \<in> decks. card d) = (\<Sum> d \<in> decks. 13)\<close> by auto
moreover have \<open>... = (\<Sum> i < card decks. 13)\<close> by simp
moreover have \<open>... = 13 * (4::nat)\<close> using decks_card by auto
ultimately show ?thesis by simp
qed
qed
lemma [simp]: \<open>deck \<noteq> {}\<close> \<open>finite deck\<close>
using deck_card card_eq_0_iff by force+
lemma free_singleton_cardI:
assumes \<open>S \<noteq> {}\<close> \<open>y \<in> S\<close>
shows \<open>card {x. x = y \<and> x \<in> S} = 1\<close>
by (smt (verit) assms(2) empty_Collect_eq is_singletonI' is_singleton_altdef mem_Collect_eq)
lemma card_single_card_in_deck:
fixes suit :: \<open>nat \<Rightarrow> suit\<close>
assumes \<open>n < 13\<close> \<open>suit \<in> suit_constructors\<close>
shows \<open>card {x. x = suit n \<and> x \<in> deck} = 1\<close>
proof-
consider \<open>suit = spade\<close> | \<open>suit = heart\<close> | \<open>suit = diamond\<close> | \<open>suit = club\<close> using assms(2)[simplified suit_constructors_def] by blast
thus ?thesis
apply(cases)
by(intro free_singleton_cardI, simp, simp add: deck_def decks_def assms suit_deck_def)+
qed
subsubsection\<open>Probability Space Construction\<close>
definition card_prob :: \<open>suit set \<Rightarrow> ennreal\<close> where
\<open>card_prob = (\<lambda>\<omega> :: suit set. \<Sum> i \<in> \<omega>. 1 / 52)\<close>
notation card_prob ("\<^bold>p")
lemma card_prob_alt_def: \<open>\<^bold>p (\<omega>) \<equiv> card \<omega> / 52\<close> unfolding card_prob_def
by (simp add: ennreal_divide_numeral ennreal_of_nat_eq_real_of_nat ennreal_times_divide)
definition \<open>deck_measure \<equiv> measure_of deck (Pow deck) \<^bold>p\<close>
notation deck_measure ("\<D>")
lemma deck_space_def: \<open>space \<D> = deck\<close>
and deck_sets_def: \<open>sets \<D> = Pow deck\<close>
apply(simp add: deck_measure_def)
by (metis deck_measure_def sigma_algebra.sets_measure_of_eq sigma_algebra_Pow)
lemma disjoint_family_repeated_elems_empty:
assumes \<open>disjoint_family A\<close> \<open>x \<noteq> y\<close>
shows \<open>A x = A y \<longrightarrow> A x = {} \<and> A y = {}\<close>
by (metis IntI assms(1,2) disjoint_family_on_def ex_in_conv iso_tuple_UNIV_I)
lemma deck_is_measure_space: \<open>measure_space deck (Pow deck) \<^bold>p\<close> unfolding measure_space_def
proof(safe)
show \<open>sigma_algebra deck (Pow deck)\<close>
by(simp add: sigma_algebra_Pow)
show \<open>positive (Pow deck) card_prob\<close> unfolding positive_def card_prob_def by simp
show \<open>countably_additive (Pow deck) \<^bold>p\<close> unfolding countably_additive_def
text\<open>The following lemma is a great highlight into how potentially tedious this process can be for the naive.
On paper, this proof is extremely trivial (no more than three lines of math) but Isabelle fought hard to make this as annoying as possible.
The complex part of the proof is the @{term \<open>countably_additive (Pow deck) \<^bold>p\<close>} proof obligation.
This requires the validity of @{term \<open>(\<Sum>i. \<^bold>p (A i)) = \<^bold>p (\<Union> (range A))\<close>} which is, on paper, very quick.
However, the lhs of this statement is an infinite sum, and the right side is a finite union (from the assumptions of countably additive).
So we need to map this infinite sum to a finite subset of @{term UNIV}.
This can be done by constructing @{term \<open>(UNIV :: nat set) = {x. A x \<noteq> {}} \<union> {x. A x = {}}\<close>},
effectively splitting @{term UNIV} into the space of sequence inputs that leave no holes, and the space of sequence inputs that do leave holes.
From the assumptions of @{term countably_additive} we know @{term \<open>disjoint_family A\<close>} and @{term \<open>finite (range A)\<close>} hence @{term \<open>finite {x. A x \<noteq> {}}\<close>}.
We know that @{term \<open>\<^bold>p {} = 0\<close>}, hence all elements of the "holed" set of the sum converge to 0 trivially.
From there, it's manipulating formulae identical to that one would do on paper.\<close>
lemma deck_is_measure_space: \<open>measure_space deck (Pow deck) \<^bold>p\<close> unfolding measure_space_def
proof(safe)
show \<open>sigma_algebra deck (Pow deck)\<close>
by(simp add: sigma_algebra_Pow)
show \<open>positive (Pow deck) card_prob\<close> unfolding positive_def card_prob_def by simp
show \<open>countably_additive (Pow deck) \<^bold>p\<close> unfolding countably_additive_def
proof(clarify)
fix A :: \<open>nat \<Rightarrow> suit set\<close>
assume \<open>range A \<subseteq> Pow deck\<close> \<open>disjoint_family A\<close> \<open>\<Union> (range A) \<subseteq> deck\<close>
hence finite_UN_range: \<open>card (\<Union> (range A)) \<le> 52\<close>
by (metis card_eq_0_iff card_mono deck_card numeral_le_iff verit_comp_simplify(8,9))
hence \<open>finite (range A)\<close>
by (metis \<open>\<Union> (range A) \<subseteq> deck\<close> card_eq_0_iff deck_card finite_UnionD not_numeral_le_zero rev_finite_subset)
show \<open>(\<Sum>i. \<^bold>p (A i)) = \<^bold>p (\<Union> (range A))\<close>
proof-
have nat_UNIV_part: \<open>(UNIV :: nat set) = {x. A x \<noteq> {}} \<union> {x. A x = {}}\<close> by blast
have no_holes_A_finite: \<open>finite {x. A x \<noteq> {}}\<close>
proof-
thm finite_imageD
have \<open>(A ` {x. A x \<noteq> {}}) \<subseteq> (range A)\<close> by blast
with \<open>finite (range A)\<close> have \<open>finite (A ` {x. A x \<noteq> {}})\<close>
by (meson infinite_super)
thus ?thesis
apply(intro finite_imageD[of A], simp)
by (metis (mono_tags, lifting) \<open>disjoint_family A\<close> disjoint_family_repeated_elems_empty inj_on_def mem_Collect_eq)
qed
thm suminf_finite
have \<open>(\<Sum>i. \<^bold>p(A i)) = ((\<Sum> i \<in> {x. A x \<noteq> {}}. \<^bold>p(A i)))\<close>
proof(intro suminf_finite)
show \<open>finite {x. A x \<noteq> {}}\<close>
by (simp add: no_holes_A_finite)
next
fix i
assume \<open>i \<notin> {x. A x \<noteq> {}}\<close>
hence \<open>i \<in> {x. A x = {}}\<close> by auto
hence \<open>A i = {}\<close> by auto
thus \<open>\<^bold>p (A i) = 0\<close> unfolding card_prob_alt_def by auto
qed
moreover have \<open>... = (\<Sum> i \<in> {x. A x \<noteq> {}}. card (A i) / 52)\<close> using card_prob_alt_def by auto
moreover have \<open>... = (\<Sum> a \<in> range A - {{}}. card a / 52)\<close>
proof(intro ennreal_cong)
have \<open>A ` {x. A x \<noteq> {}} = range A - {{}}\<close> by auto
moreover have \<open>(\<Sum> a \<in> range A - {{}}. card a / 52) = (\<Sum> a \<in> A ` {x. A x \<noteq> {}}. card a / 52)\<close> using calculation by simp
moreover have \<open>(\<Sum> a \<in> A ` {x. A x \<noteq> {}}. card a) = (\<Sum> i \<in> {x. A x \<noteq> {}}. card (A i))\<close>
apply(intro sum_card_image)
apply(simp add: no_holes_A_finite)
by (smt (verit, best) UNIV_I \<open>disjoint_family A\<close> disjnt_def disjoint_family_on_def pairwise_def)
moreover have \<open>(\<Sum> i \<in> {x. A x \<noteq> {}}. card (A i)) / 52 = (\<Sum> i \<in> range A - {{}}. card (i)) / 52\<close> using calculation by simp
ultimately show \<open>(\<Sum>i\<in>{x. A x \<noteq> {}}. (card (A i)) / 52) = (\<Sum>a\<in>range A - {{}}. (card a) / 52) \<close>
by (simp add: sum_divide_distrib)
qed
moreover have \<open>... = (\<Sum> a \<in> range A. card a) / 52\<close>
proof-
have f1: "ennreal (real (sum card (range A - {{}})) / 52) = ennreal (real (\<Sum>n | A n \<noteq> {}. card (A n)) / 52)"
by (simp add: \<open>ennreal (\<Sum>i\<in>{x. A x \<noteq> {}}. real (card (A i)) / 52) = ennreal (\<Sum>a\<in>range A - {{}}. real (card a) / 52)\<close> sum_divide_distrib)
then have "ennreal (real (sum card (range A)) / 52) = ennreal (real (\<Sum>n | A n \<noteq> {}. card (A n)) / 52)"
by (metis (no_types) card.empty sum_diff1_nat verit_minus_simplify(2))
then show ?thesis
using f1 by (simp add: sum_divide_distrib)
qed
ultimately have *: \<open>(\<Sum>i. \<^bold>p(A i)) = (\<Sum> a \<in> range A. card a) / 52\<close> by auto
have \<open>\<^bold>p(\<Union> (range A)) = card (\<Union> (range A)) / 52\<close> by (simp add: card_prob_alt_def)
moreover have \<open>card (\<Union> (range A)) = (\<Sum>a \<in> range A. card a)\<close>
apply(intro card_Union_disjoint)
apply (simp add: \<open>disjoint_family A\<close> disjoint_family_on_disjoint_image card_Union_disjoint)
by (metis Union_upper \<open>\<Union> (range A) \<subseteq> deck\<close> card_eq_0_iff deck_card infinite_super nat.simps(3) numeral_eq_Suc)
ultimately have **: \<open>\<^bold>p(\<Union> (range A)) = (\<Sum>a \<in> range A. card a) / 52\<close> by auto
show ?thesis using * ** by auto
qed
qed
qed
text\<open>This proof, if one were to inspect the definition of @{locale prob_space} would seem quite redundant, however it gives us extremely helpful coersions later on.
What we have proven here is an extremely generic fact, and with a few side conditions can be molded into any other sort of measure space.
Namely, we get the following very easily.\<close>
lemma deck_emeasure: \<open>\<forall>X \<subseteq> deck. emeasure \<D> (X) = \<^bold>p X\<close>
proof(clarify)
interpret sigma_algebra deck \<open>Pow deck\<close>
by (simp add: sigma_algebra_Pow)
fix X
assume \<open>X \<subseteq> deck\<close>
thus \<open>emeasure \<D> X = \<^bold>p X\<close> unfolding deck_measure_def
proof(subst emeasure_measure_of[where ?\<Omega> = deck and ?A = \<open>Pow deck\<close> and ?\<mu> = \<open>\<^bold>p\<close>], simp_all)
show \<open>positive (Pow deck) \<^bold>p\<close>
using deck_is_measure_space measure_space_def by blast
show \<open>countably_additive (Pow deck) \<^bold>p\<close>
using deck_is_measure_space measure_space_def by blast
qed
qed
context
begin
interpretation Laplace_Space \<D> 52
proof
interpret sigma_algebra deck \<open>Pow deck\<close>
by (simp add: sigma_algebra_Pow)
have cap: \<open>countably_additive (Pow deck) \<^bold>p\<close> using deck_is_measure_space by (simp add: measure_space_def)
show \<open>\<exists>A. countable A \<and> A \<subseteq> sets \<D> \<and> \<Union> A = space \<D> \<and> (\<forall>a\<in>A. emeasure \<D> a \<noteq> \<infinity>)\<close>
proof(rule exI[of _ \<open>decks\<close>], safe)
show \<open>countable (decks)\<close>
by(simp add: countable_finite)
next
fix a
assume \<open>a \<in> decks\<close> \<open>emeasure \<D> a = \<infinity>\<close>
thus False using deck_emeasure card_prob_alt_def
by (simp add: Union_upper deck_def)
qed(auto simp add: deck_measure_def deck_def)
show \<open>emeasure \<D> (space \<D>) \<noteq> \<top>\<close>
by(simp add: deck_emeasure deck_space_def card_prob_alt_def)
show \<open>emeasure \<D> (space \<D>) = 1\<close>
by(simp add: deck_emeasure deck_space_def card_prob_alt_def deck_card)
show \<open>0 < (52 :: nat)\<close> by simp
show \<open>card (space \<D>) = 52\<close> by (simp add: deck_card deck_measure_def)
show \<open>sets \<D> = Pow (space \<D>)\<close> by (simp add: deck_measure_def)
show \<open>\<forall>\<omega>\<in>space \<D>. Sigma_Algebra.measure \<D> {\<omega>} = 1 / real 52 \<close>
proof
fix \<omega>
assume \<open>\<omega> \<in> space \<D>\<close>
thus \<open> Sigma_Algebra.measure \<D> {\<omega>} = 1 / real 52 \<close> unfolding Sigma_Algebra.measure_def
by(subst deck_emeasure, simp_all add: deck_def deck_measure_def card_prob_alt_def)
qed
qed
lemma prob_to_p_def: \<open>\<P>(x in \<D>. P x) = \<^bold>p {x \<in> space \<D>. P x}\<close>
using deck_emeasure deck_space_def emeasure_eq_measure by fastforce
lemma
assumes \<open>n < 13\<close> \<open>suit \<in> suit_constructors\<close>
shows \<open>\<P>(x in \<D>. x = suit n) = 1 / 52\<close>
unfolding Sigma_Algebra.measure_def
apply(subst deck_emeasure, simp add: deck_measure_def, blast)
apply(simp add: card_prob_alt_def deck_measure_def assms card_single_card_in_deck)
done
end
text\<open>Important to note, the above only formalises ONE probability space.
The consequence of this is we cannot talk about the the probability of multiple sequential events.
For instance, the probability of drawing an ace on the nth go (with or without replacement).
To discuss this, there are two entry points \<^file>\<open>~~/src/HOL/Probability/Independent_Family.thy\<close>
where we can formally model independent sets (if our probability space allows) or we can interpret a
@{locale finite_product_prob_space} for the most bare bones approach.\<close>
section\<open>Probability Mass Functions (@{typ \<open>'a pmf\<close>})\<close>
text\<open>While the above formalism gives a very bare bones approach to forming probability spaces,
we have another (hopefully more sane) route that define probability mass functions as types.
PMFs also have extensive code generation support, something that I have no clue what is going on with but works nicely.\<close>
subsection\<open>The Giry Monad\<close>
text\<open>To harness the full power of the @{typ \<open>'a pmf\<close>} type we need to understand the Giry Monad, formalised in \<^file>\<open>~~/src/HOL/Probability/Giry_Monad.thy\<close>.
For a much better and somewhat humorous introduction to the topic, I'll direct the reader to \<^url>\<open>https://jtobin.io/giry-monad-foundations\<close>.
For a different sort of humor, the breakdown on nLab is probably the most terrifying thing I've seen \<^url>\<open>https://ncatlab.org/nlab/show/Giry+monad\<close>.
If you like a video/lecture format, the series on Categorical Probability Theory by Arthur Parzygnat is brilliant \<^url>\<open>https://www.youtube.com/playlist?list=PLSx1kJDjrLRSKKHj4zetTZ45pVnGCRN80\<close>.
The Giry Monad is a vital formal component of modelling probabilities and builds the foundations in Category Theory rather than Set Theory.
From proof tree of the HOL-Probability session, we can see a fork in development when the Giry Monad is introduced. Whilst a scary prospect, the Giry Monad
is actually the nicer formalism to work over (at least in Isabelle) mainly due to the work from Manuel Eberl and Andreas Lochbihler.
It can directly link probabilistic concepts to a functional analogue which seems to agree with Isabelle's type system a bit more.
My current thoughts are that if you're doing anything somewhat applied using probabilities, you should use Giry Monads and @{typ \<open>'a pmf\<close>} functions.
If you plan on extending probability theory, use the set theoretical notion. Reason being is that the Giry Monad is a monad over the category of measurable spaces,
hence if one extends the core measure theoretic notion of probability spaces, you can harness the formalism directly using the monad.
Anano\<close>
subsection\<open>Deck of cards using pmfs.\<close>
text\<open>Eagle-eyed readers/listeners may see that the more common name for Laplace Spaces are Uniform Distributions.
This is something that is defined using the @{typ \<open>'a pmf\<close>} type.\<close>
definition \<open>card_pmf \<equiv> pmf_of_set deck\<close>
value \<open>pmf card_pmf (spade 12)\<close>
thm card_prob_alt_def
lemma pmf_card_pmf: \<open>pmf card_pmf x = of_bool (x \<in> deck) /52\<close> unfolding card_pmf_def
by(subst pmf_of_set[of deck x], simp_all add: deck_card)
text\<open>Something that we couldn't do easily before was model sequential events, something that with pmfs are very simple but require some know-how.
To formally define P(some card in exactly n trials) we need to map the problem to a Bernoulli distribution.\<close>
definition \<open>btrial (n ::nat) p B \<equiv> Pi_pmf {0..<n} B (\<lambda>_. bernoulli_pmf p)\<close>
abbreviation \<open>card_btrial n \<equiv> btrial n (1/52) True\<close>
lemma pmf_card_btrial: \<open>pmf (card_btrial n) (\<lambda>x. x \<notin> {0..<(n - 1)}) = (\<Prod>x \<in> {0..<n}. pmf (bernoulli_pmf (1/52)) (x \<notin> {0..<(n - 1)}))\<close>
unfolding btrial_def by(intro pmf_Pi', simp_all)
lemma card_bernoulli_pmf:
fixes x :: nat
assumes \<open>n > 0\<close> \<open>x < n\<close>
shows \<open>pmf (bernoulli_pmf (1/52)) (x \<notin> {0..<n - 1}) = (if x \<in> {0..<n - 1} then 51/52 else 1/52)\<close>
by(subst bernoulli_pmf.rep_eq, simp add: assms)
lemma pmf_card_btrial':
assumes \<open>n > 0\<close>
shows \<open>pmf (card_btrial n) (\<lambda>x. x \<notin> {0..<(n - 1)}) = 1/52 * (51/52)^(n - 1)\<close>
proof-
have \<open>pmf (card_btrial n) (\<lambda>x. x \<notin> {0..<(n - 1)}) = (\<Prod>x \<in> {0..<n}. pmf (bernoulli_pmf (1/52)) (x \<notin> {0..<(n - 1)}))\<close> unfolding pmf_card_btrial by simp
moreover have \<open>... = (\<Prod>x \<in> {0..<n}. if x < n - Suc 0 then 51 / 52 else 1 / 52)\<close>
using card_bernoulli_pmf by auto
moreover have \<open>... = (\<Prod>x \<in> {..<n - 1} \<union> {n-1..<n}. if x < n - Suc 0 then 51 / 52 else 1 / 52)\<close>
by (simp add: atLeast0LessThan ivl_disj_un_one(2))
moreover have \<open>... = (\<Prod>x \<in> {..<n - 1}. if x < n - Suc 0 then 51 / 52 else 1 / 52) * (\<Prod> x \<in> {n - 1..<n}. if x < n - Suc 0 then 51 / 52 else 1 / 52)\<close>
by(intro comm_monoid_mult_class.prod.union_disjoint, simp_all add: ivl_disj_int(2))
moreover have \<open>... = (\<Prod>x \<in> {..<n - 1}. 51/52) * (\<Prod> x \<in> {n - 1..<n}. 1/52)\<close> by simp
moreover have \<open>... = (51/52)^(n-1) * (1/52)\<close>
by(cases \<open>n = 1\<close>) (simp_all add: Suc_leI assms)
ultimately show ?thesis by auto
qed
lemma pmf_card_btrial'': \<open>pmf (card_btrial n) (\<lambda>x. x \<notin> {0..<(n - 1)}) = (if n = 0 then 1 else 1/52 * (51/52)^(n - 1))\<close>
proof(cases \<open>n = 0\<close>)
case True
then show ?thesis unfolding pmf_card_btrial
by(simp)
next
case False
hence \<open>n > 0\<close> by blast
thus ?thesis using pmf_card_btrial' by auto
qed
text\<open>As evidenced, this is significantly less hassle than before!\<close>
end

453
Probability/Outline.thy~ Normal file
View File

@ -0,0 +1,453 @@
theory Outline
imports "HOL-Probability.Probability"
begin
section\<open>An overview of the Probability package.\<close>
text\<open>For most of this theory, we will make the neat semantic distinction that Achim made last week between probability and statistics.
Since the Probability package generalises as much as possible, this might not be overly helpful for us as we are not Probability Theorists.
Thus, I plan to give some concrete examples and link it to the theory as much as possible.
I can imagine that we definitely will not have time to go over everything, so I'll have this as an entry point to the Isabelle Club.
I propose we look at the following topics as they relate the most to what we try to do:
\<^item> Giry Monads and Probabilistic Programming
\<^item> Distributions
\<^item> Code Generation of Probability Mass Functions (pmfs)
Before we start with the more interesting topics, we must first be bored with the basic implementations of probability measures so we know
how to really use them\<close>
section\<open>The Probability Measure\<close>
text\<open>The start of the probability implementation can be found in \<^file>\<open>$ISABELLE_HOME/src/HOL/Probability/Probability_Measure.thy\<close>.
This defines a basic probability space. NB: the type @{typ \<open>'a measure\<close>} could be misleading. It defines the type of measure spaces, not a measurement.\<close>
print_locale prob_space
thm prob_space_def[simplified prob_space_axioms_def]
text\<open>Most of the probability theory formalisation occurs directly in the @{locale prob_space} or extensions of such locales (see below for example).
Concrete interpretations of locales are somewhat difficult to specify, but can be done.
The one of the formal requirements on probability spaces is that for the space \<open>(\<Omega>, A)\<close> to form a @{locale sigma_algebra}.
The simplest sigma-algebra possible is \<open>(\<Omega>, {{}, \<Omega>})\<close>. Now, (on a different algebra) the simplest measure function could be a uniform distribution, \<open>P(\<omega>) = 1 / |\<Omega>|\<close>.
Such measurements are known as the Laplace Probability Measures.
For most specifications, the formalism \<open>(\<Omega>, Pow \<Omega>)\<close> that gives the largest possible sigma-algebra will suffice.\<close>
subsection\<open>The Laplace Probability Space\<close>
locale Laplace_Space = prob_space +
fixes N :: nat
assumes N_gr_0: \<open>N > 0\<close>
and lcard: \<open>card (space M) = N\<close>
and lsets: \<open>events = Pow (space M)\<close>
and lprob: \<open>\<forall>\<omega> \<in> space M. prob {\<omega>} = 1 / N\<close>
notes laplace_space_assms = lcard lsets lprob N_gr_0
begin
sublocale sigma_algebra "(space M)" by unfold_locales
lemma laplace_prob_compl: \<open>\<forall>\<omega> \<in> space M. prob ((space M) - {\<omega>}) = (N - 1) / N\<close>
proof
fix \<omega>
assume \<open>\<omega> \<in> space M\<close>
show \<open>prob (space M - {\<omega>}) = real (N - 1) / real N\<close>
proof-
have \<open>prob (space M - {\<omega>}) = 1 - prob {\<omega>}\<close>
using laplace_space_assms \<open>\<omega> \<in> space M\<close> by (blast intro: prob_compl)
moreover have \<open>... = 1 - 1 / N\<close> using laplace_space_assms \<open>\<omega> \<in> space M\<close> by presburger
moreover have \<open>... = N / N - 1 / N\<close> using laplace_space_assms by auto
moreover have \<open>... = (N - 1) / N\<close> using laplace_space_assms
by (metis Multiseries_Expansion.intyness_1 One_nat_def Suc_leI diff_divide_distrib of_nat_diff_if)
ultimately show ?thesis by auto
qed
qed
end
subsection\<open>Example: A deck of cards\<close>
text\<open>Aside from the typical coin example, probably the most infamous example of the @{locale Laplace_Space} is a deck of cards.
This will help us illustrate working with realised probability spaces and maybe used later in some program verification!\<close>
subsubsection\<open>Preliminary Construction\<close>
datatype suit = spade nat | club nat | heart nat | diamond nat
lemma [simp]: \<open>inj spade\<close> \<open>inj club\<close> \<open>inj heart\<close> \<open>inj diamond\<close> by (simp add: inj_def)+
definition \<open>suit_constructors \<equiv> {spade, club, heart, diamond}\<close>
definition \<open>suit_deck f \<equiv> f ` {0..<13}\<close> for f :: \<open>nat \<Rightarrow> suit\<close>
lemma finite_suit_constructors[simp]: \<open>finite suit_constructors\<close> by (simp add: suit_constructors_def)
lemma suit_deck_finite: \<open>finite (suit_deck f)\<close> unfolding suit_deck_def by blast
lemma suit_deck_card:
assumes \<open>inj f\<close>
shows \<open>card (suit_deck f) = 13\<close> unfolding suit_deck_def
by(simp add: card_image inj_on_def assms[simplified inj_def])
lemma suit_decks_disj:
assumes \<open>f ` {0..<13} \<inter> g ` {0..<13} = {}\<close>
shows \<open>disjnt (suit_deck f) (suit_deck g)\<close>
by (simp add: assms disjnt_def suit_deck_def)
lemma disjnt_image_iff: \<open>f ` A \<inter> g ` B = {} \<longleftrightarrow> (\<forall>x \<in> A. \<forall>y \<in> B. f x \<noteq> g y)\<close>
by blast
abbreviation \<open>spades \<equiv> suit_deck spade\<close>
abbreviation \<open>clubs \<equiv> suit_deck club\<close>
abbreviation \<open>hearts \<equiv> suit_deck heart\<close>
abbreviation \<open>diamonds \<equiv> suit_deck diamond\<close>
definition \<open>decks = {spades, clubs, hearts, diamonds}\<close>
lemma [simp]: \<open>decks \<noteq> {}\<close> unfolding decks_def by simp
lemma finite_decks[simp]: \<open>finite decks\<close> by (simp add: decks_def)
lemma decks_card: \<open>card decks = 4\<close> unfolding decks_def by normalization
lemma decks_alt: \<open>decks = suit_deck ` suit_constructors\<close>
by (simp add: decks_def suit_deck_def suit_constructors_def)
definition \<open>deck = \<Union> decks\<close>
lemma decks_disjoint: \<open>disjoint decks\<close> unfolding decks_def
proof
fix x y
assume x0: \<open>x \<in> {spades, clubs, hearts, diamonds}\<close> and y0: \<open>y \<in> {spades, clubs, hearts, diamonds}\<close> and x_neq_y: \<open>x \<noteq> y\<close>
then consider (c0) \<open>x = spades\<close> | (c1) \<open>x = clubs\<close> | (c2) \<open>x = hearts\<close> | (c3) \<open>x = diamonds\<close> by blast
thus \<open>disjnt x y\<close>
proof(cases)
case c0
then consider \<open>y = clubs\<close> | \<open>y = hearts\<close> | \<open>y = diamonds\<close> using x_neq_y y0 by blast
thus ?thesis
by(cases, simp_all add: c0 suit_decks_disj disjnt_image_iff)
next
case c1
then consider \<open>y = spades\<close> | \<open>y = hearts\<close> | \<open>y = diamonds\<close> using x_neq_y y0 by blast
then show ?thesis
by(cases, simp_all add: c1 suit_decks_disj disjnt_image_iff)
next
case c2
then consider \<open>y = clubs\<close> | \<open>y = spades\<close> | \<open>y = diamonds\<close> using x_neq_y y0 by blast
then show ?thesis
by(cases, simp_all add: c2 suit_decks_disj disjnt_image_iff)
next
case c3
then consider \<open>y = clubs\<close> | \<open>y = spades\<close> | \<open>y = hearts\<close> using x_neq_y y0 by blast
then show ?thesis
by(cases, simp_all add: c3 suit_decks_disj disjnt_image_iff)
qed
qed
lemma deck_card: \<open>card deck = 52\<close> unfolding deck_def
proof(subst card_Union_disjoint[OF decks_disjoint])
show \<open>\<And>A. A \<in> decks \<Longrightarrow> finite A\<close>
by (metis decks_alt image_iff suit_deck_finite)
show \<open>(\<Sum>d \<in> decks. card d) = (52::nat)\<close>
proof-
have \<open>\<And>d. d \<in> decks \<Longrightarrow> card d = 13\<close>
by (metis (mono_tags, opaque_lifting) decks_def empty_iff inj_def insert_iff suit.simps(1,2,3,4) suit_deck_card)
hence \<open>(\<Sum>d \<in> decks. card d) = (\<Sum> d \<in> decks. 13)\<close> by auto
moreover have \<open>... = (\<Sum> i < card decks. 13)\<close> by simp
moreover have \<open>... = 13 * (4::nat)\<close> using decks_card by auto
ultimately show ?thesis by simp
qed
qed
lemma [simp]: \<open>deck \<noteq> {}\<close> \<open>finite deck\<close>
using deck_card card_eq_0_iff by force+
lemma free_singleton_cardI:
assumes \<open>S \<noteq> {}\<close> \<open>y \<in> S\<close>
shows \<open>card {x. x = y \<and> x \<in> S} = 1\<close>
by (smt (verit) assms(2) empty_Collect_eq is_singletonI' is_singleton_altdef mem_Collect_eq)
lemma card_single_card_in_deck:
fixes suit :: \<open>nat \<Rightarrow> suit\<close>
assumes \<open>n < 13\<close> \<open>suit \<in> suit_constructors\<close>
shows \<open>card {x. x = suit n \<and> x \<in> deck} = 1\<close>
proof-
consider \<open>suit = spade\<close> | \<open>suit = heart\<close> | \<open>suit = diamond\<close> | \<open>suit = club\<close> using assms(2)[simplified suit_constructors_def] by blast
thus ?thesis
apply(cases)
by(intro free_singleton_cardI, simp, simp add: deck_def decks_def assms suit_deck_def)+
qed
subsubsection\<open>Probability Space Construction\<close>
definition card_prob :: \<open>suit set \<Rightarrow> ennreal\<close> where
\<open>card_prob = (\<lambda>\<omega> :: suit set. \<Sum> i \<in> \<omega>. 1 / 52)\<close>
notation card_prob ("\<^bold>p")
lemma card_prob_alt_def: \<open>\<^bold>p (\<omega>) \<equiv> card \<omega> / 52\<close> unfolding card_prob_def
by (simp add: ennreal_divide_numeral ennreal_of_nat_eq_real_of_nat ennreal_times_divide)
definition \<open>deck_measure \<equiv> measure_of deck (Pow deck) \<^bold>p\<close>
notation deck_measure ("\<D>")
lemma deck_space_def: \<open>space \<D> = deck\<close>
and deck_sets_def: \<open>sets \<D> = Pow deck\<close>
apply(simp add: deck_measure_def)
by (metis deck_measure_def sigma_algebra.sets_measure_of_eq sigma_algebra_Pow)
lemma disjoint_family_repeated_elems_empty:
assumes \<open>disjoint_family A\<close> \<open>x \<noteq> y\<close>
shows \<open>A x = A y \<longrightarrow> A x = {} \<and> A y = {}\<close>
by (metis IntI assms(1,2) disjoint_family_on_def ex_in_conv iso_tuple_UNIV_I)
text\<open>The following lemma is a great highlight into how potentially tedious this process can be for the naive.
On paper, this proof is extremely trivial (no more than three lines of math) but Isabelle fought hard to make this as annoying as possible.
The complex part of the proof is the @{term \<open>countably_additive (Pow deck) \<^bold>p\<close>} proof obligation.
This requires the validity of @{term \<open>(\<Sum>i. \<^bold>p (A i)) = \<^bold>p (\<Union> (range A))\<close>} which is, on paper, very quick.
However, the lhs of this statement is an infinite sum, and the right side is a finite union (from the assumptions of countably additive).
So we need to map this infinite sum to a finite subset of @{term UNIV}.
This can be done by constructing @{term \<open>(UNIV :: nat set) = {x. A x \<noteq> {}} \<union> {x. A x = {}}\<close>},
effectively splitting @{term UNIV} into the space of sequence inputs that leave no holes, and the space of sequence inputs that do leave holes.
From the assumptions of @{term countably_additive} we know @{term \<open>disjoint_family A\<close>} and @{term \<open>finite (range A)\<close>} hence @{term \<open>finite {x. A x \<noteq> {}}\<close>}.
We know that @{term \<open>\<^bold>p {} = 0\<close>}, hence all elements of the "holed" set of the sum converge to 0 trivially.
From there, it's manipulating formulae identical to that one would do on paper.\<close>
lemma deck_is_measure_space: \<open>measure_space deck (Pow deck) \<^bold>p\<close> unfolding measure_space_def
proof(safe)
show \<open>sigma_algebra deck (Pow deck)\<close>
by(simp add: sigma_algebra_Pow)
show \<open>positive (Pow deck) card_prob\<close> unfolding positive_def card_prob_def by simp
show \<open>countably_additive (Pow deck) \<^bold>p\<close> unfolding countably_additive_def
proof(clarify)
fix A :: \<open>nat \<Rightarrow> suit set\<close>
assume \<open>range A \<subseteq> Pow deck\<close> \<open>disjoint_family A\<close> \<open>\<Union> (range A) \<subseteq> deck\<close>
hence finite_UN_range: \<open>card (\<Union> (range A)) \<le> 52\<close>
by (metis card_eq_0_iff card_mono deck_card numeral_le_iff verit_comp_simplify(8,9))
hence \<open>finite (range A)\<close>
by (metis \<open>\<Union> (range A) \<subseteq> deck\<close> card_eq_0_iff deck_card finite_UnionD not_numeral_le_zero rev_finite_subset)
show \<open>(\<Sum>i. \<^bold>p (A i)) = \<^bold>p (\<Union> (range A))\<close>
proof-
have nat_UNIV_part: \<open>(UNIV :: nat set) = {x. A x \<noteq> {}} \<union> {x. A x = {}}\<close> by blast
have no_holes_A_finite: \<open>finite {x. A x \<noteq> {}}\<close>
proof-
have \<open>(A ` {x. A x \<noteq> {}}) \<subseteq> (range A)\<close> by blast
with \<open>finite (range A)\<close> have \<open>finite (A ` {x. A x \<noteq> {}})\<close>
by (meson infinite_super)
thus ?thesis
apply(intro finite_imageD[of A], simp)
by (metis (mono_tags, lifting) \<open>disjoint_family A\<close> disjoint_family_repeated_elems_empty inj_on_def mem_Collect_eq)
qed
have \<open>(\<Sum>i. \<^bold>p(A i)) = ((\<Sum> i \<in> {x. A x \<noteq> {}}. \<^bold>p(A i)))\<close>
proof(intro suminf_finite)
show \<open>finite {x. A x \<noteq> {}}\<close>
by (simp add: no_holes_A_finite)
next
fix i
assume \<open>i \<notin> {x. A x \<noteq> {}}\<close>
hence \<open>i \<in> {x. A x = {}}\<close> by auto
hence \<open>A i = {}\<close> by auto
thus \<open>\<^bold>p (A i) = 0\<close> unfolding card_prob_alt_def by auto
qed
moreover have \<open>... = (\<Sum> i \<in> {x. A x \<noteq> {}}. card (A i) / 52)\<close> using card_prob_alt_def by auto
moreover have \<open>... = (\<Sum> a \<in> range A - {{}}. card a / 52)\<close>
proof(intro ennreal_cong)
have \<open>A ` {x. A x \<noteq> {}} = range A - {{}}\<close> by auto
moreover have \<open>(\<Sum> a \<in> range A - {{}}. card a / 52) = (\<Sum> a \<in> A ` {x. A x \<noteq> {}}. card a / 52)\<close> using calculation by simp
moreover have \<open>(\<Sum> a \<in> A ` {x. A x \<noteq> {}}. card a) = (\<Sum> i \<in> {x. A x \<noteq> {}}. card (A i))\<close>
apply(intro sum_card_image)
apply(simp add: no_holes_A_finite)
by (smt (verit, best) UNIV_I \<open>disjoint_family A\<close> disjnt_def disjoint_family_on_def pairwise_def)
moreover have \<open>(\<Sum> i \<in> {x. A x \<noteq> {}}. card (A i)) / 52 = (\<Sum> i \<in> range A - {{}}. card (i)) / 52\<close> using calculation by simp
ultimately show \<open>(\<Sum>i\<in>{x. A x \<noteq> {}}. (card (A i)) / 52) = (\<Sum>a\<in>range A - {{}}. (card a) / 52) \<close>
by (simp add: sum_divide_distrib)
qed
moreover have \<open>... = (\<Sum> a \<in> range A. card a) / 52\<close>
proof-
have f1: "ennreal (real (sum card (range A - {{}})) / 52) = ennreal (real (\<Sum>n | A n \<noteq> {}. card (A n)) / 52)"
by (simp add: \<open>ennreal (\<Sum>i\<in>{x. A x \<noteq> {}}. real (card (A i)) / 52) = ennreal (\<Sum>a\<in>range A - {{}}. real (card a) / 52)\<close> sum_divide_distrib)
then have "ennreal (real (sum card (range A)) / 52) = ennreal (real (\<Sum>n | A n \<noteq> {}. card (A n)) / 52)"
by (metis (no_types) card.empty sum_diff1_nat verit_minus_simplify(2))
then show ?thesis
using f1 by (simp add: sum_divide_distrib)
qed
ultimately have *: \<open>(\<Sum>i. \<^bold>p(A i)) = (\<Sum> a \<in> range A. card a) / 52\<close> by auto
have \<open>\<^bold>p(\<Union> (range A)) = card (\<Union> (range A)) / 52\<close> by (simp add: card_prob_alt_def)
moreover have \<open>card (\<Union> (range A)) = (\<Sum>a \<in> range A. card a)\<close>
apply(intro card_Union_disjoint)
apply (simp add: \<open>disjoint_family A\<close> disjoint_family_on_disjoint_image card_Union_disjoint)
by (metis Union_upper \<open>\<Union> (range A) \<subseteq> deck\<close> card_eq_0_iff deck_card infinite_super nat.simps(3) numeral_eq_Suc)
ultimately have **: \<open>\<^bold>p(\<Union> (range A)) = (\<Sum>a \<in> range A. card a) / 52\<close> by auto
show ?thesis using * ** by auto
qed
qed
qed
text\<open>This proof, if one were to inspect the definition of @{locale prob_space} would seem quite redundant, however it gives us extremely helpful coersions later on.
What we have proven here is an extremely generic fact, and with a few side conditions can be molded into any other sort of measure space.
Namely, we get the following very easily.\<close>
lemma deck_emeasure: \<open>\<forall>X \<subseteq> deck. emeasure \<D> (X) = \<^bold>p X\<close>
proof(clarify)
interpret sigma_algebra deck \<open>Pow deck\<close>
by (simp add: sigma_algebra_Pow)
fix X
assume \<open>X \<subseteq> deck\<close>
thus \<open>emeasure \<D> X = \<^bold>p X\<close> unfolding deck_measure_def
proof(subst emeasure_measure_of[where ?\<Omega> = deck and ?A = \<open>Pow deck\<close> and ?\<mu> = \<open>\<^bold>p\<close>], simp_all)
show \<open>positive (Pow deck) \<^bold>p\<close>
using deck_is_measure_space measure_space_def by blast
show \<open>countably_additive (Pow deck) \<^bold>p\<close>
using deck_is_measure_space measure_space_def by blast
qed
qed
context
begin
interpretation Laplace_Space \<D> 52
proof
interpret sigma_algebra deck \<open>Pow deck\<close>
by (simp add: sigma_algebra_Pow)
have cap: \<open>countably_additive (Pow deck) \<^bold>p\<close> using deck_is_measure_space by (simp add: measure_space_def)
show \<open>\<exists>A. countable A \<and> A \<subseteq> sets \<D> \<and> \<Union> A = space \<D> \<and> (\<forall>a\<in>A. emeasure \<D> a \<noteq> \<infinity>)\<close>
proof(rule exI[of _ \<open>decks\<close>], safe)
show \<open>countable (decks)\<close>
by(simp add: countable_finite)
next
fix a
assume \<open>a \<in> decks\<close> \<open>emeasure \<D> a = \<infinity>\<close>
thus False using deck_emeasure card_prob_alt_def
by (simp add: Union_upper deck_def)
qed(auto simp add: deck_measure_def deck_def)
show \<open>emeasure \<D> (space \<D>) \<noteq> \<top>\<close>
by(simp add: deck_emeasure deck_space_def card_prob_alt_def)
show \<open>emeasure \<D> (space \<D>) = 1\<close>
by(simp add: deck_emeasure deck_space_def card_prob_alt_def deck_card)
show \<open>0 < (52 :: nat)\<close> by simp
show \<open>card (space \<D>) = 52\<close> by (simp add: deck_card deck_measure_def)
show \<open>sets \<D> = Pow (space \<D>)\<close> by (simp add: deck_measure_def)
show \<open>\<forall>\<omega>\<in>space \<D>. Sigma_Algebra.measure \<D> {\<omega>} = 1 / real 52 \<close>
proof
fix \<omega>
assume \<open>\<omega> \<in> space \<D>\<close>
thus \<open> Sigma_Algebra.measure \<D> {\<omega>} = 1 / real 52 \<close> unfolding Sigma_Algebra.measure_def
by(subst deck_emeasure, simp_all add: deck_def deck_measure_def card_prob_alt_def)
qed
qed
lemma prob_to_p_def: \<open>\<P>(x in \<D>. P x) = \<^bold>p {x \<in> space \<D>. P x}\<close>
using deck_emeasure deck_space_def emeasure_eq_measure by fastforce
lemma
assumes \<open>n < 13\<close> \<open>suit \<in> suit_constructors\<close>
shows \<open>\<P>(x in \<D>. x = suit n) = 1 / 52\<close>
unfolding Sigma_Algebra.measure_def
apply(subst deck_emeasure, simp add: deck_measure_def, blast)
apply(simp add: card_prob_alt_def deck_measure_def assms card_single_card_in_deck)
done
end
text\<open>Important to note, the above only formalises ONE probability space.
The consequence of this is we cannot talk about the the probability of multiple sequential events.
For instance, the probability of drawing an ace on the nth go (with or without replacement).
To discuss this, there are two entry points \<^file>\<open>~~/src/HOL/Probability/Independent_Family.thy\<close>
where we can formally model independent sets (if our probability space allows) or we can interpret a
@{locale finite_product_prob_space} for the most bare bones approach.\<close>
section\<open>Probability Mass Functions (@{typ \<open>'a pmf\<close>})\<close>
text\<open>While the above formalism gives a very bare bones approach to forming probability spaces,
we have another (hopefully more sane) route that define probability mass functions as types.
PMFs also have extensive code generation support, something that I have no clue what is going on with but works nicely.\<close>
subsection\<open>The Giry Monad\<close>
text\<open>To harness the full power of the @{typ \<open>'a pmf\<close>} type we need to understand the Giry Monad, formalised in \<^file>\<open>~~/src/HOL/Probability/Giry_Monad.thy\<close>.
For a much better and somewhat humorous introduction to the topic, I'll direct the reader to \<^url>\<open>https://jtobin.io/giry-monad-foundations\<close>.
For a different sort of humor, the breakdown on nLab is probably the most terrifying thing I've seen \<^url>\<open>https://ncatlab.org/nlab/show/Giry+monad\<close>.
If you like a video/lecture format, the series on Categorical Probability Theory by Arthur Parzygnat is brilliant \<^url>\<open>https://www.youtube.com/playlist?list=PLSx1kJDjrLRSKKHj4zetTZ45pVnGCRN80\<close>.
The Giry Monad is a vital formal component of modelling probabilities and builds the foundations in Category Theory rather than Set Theory.
From proof tree of the HOL-Probability session, we can see a fork in development when the Giry Monad is introduced. Whilst a scary prospect, the Giry Monad
is actually the nicer formalism to work over (at least in Isabelle) mainly due to the work from Manuel Eberl and Andreas Lochbihler.
It can directly link probabilistic concepts to a functional analogue which seems to agree with Isabelle's type system a bit more.
My current thoughts are that if you're doing anything somewhat applied using probabilities, you should use Giry Monads and @{typ \<open>'a pmf\<close>} functions.
If you plan on extending probability theory, use the set theoretical notion. Reason being is that the Giry Monad is a monad over the category of measurable spaces,
hence if one extends the core measure theoretic notion of probability spaces, you can harness the formalism directly using the monad.
Anano\<close>
value \<open>binomial_pmf 10 (1/2)\<close>
subsection\<open>Deck of cards using pmfs.\<close>
text\<open>Eagle-eyed readers/listeners may see that the more common name for Laplace Spaces are Uniform Distributions.
This is something that is defined using the @{typ \<open>'a pmf\<close>} type.\<close>
definition \<open>card_pmf \<equiv> pmf_of_set deck\<close>
value \<open>card_pmf\<close>
lemma pmf_card_pmf: \<open>pmf card_pmf x = of_bool (x \<in> deck) /52\<close> unfolding card_pmf_def
by(subst pmf_of_set[of deck x], simp_all add: deck_card)
text\<open>Something that we couldn't do easily before was model sequential events, something that with pmfs are very simple but require some know-how.
To formally define P(some card in exactly n trials) we need to map the problem to a Bernoulli distribution.\<close>
definition \<open>btrial (n ::nat) p B \<equiv> Pi_pmf {0..<n} B (\<lambda>_. bernoulli_pmf p)\<close>
abbreviation \<open>card_btrial n \<equiv> btrial n (1/52) True\<close>
lemma pmf_card_btrial: \<open>pmf (card_btrial n) (\<lambda>x. x \<notin> {0..<(n - 1)}) = (\<Prod>x \<in> {0..<n}. pmf (bernoulli_pmf (1/52)) (x \<notin> {0..<(n - 1)}))\<close>
unfolding btrial_def by(intro pmf_Pi', simp_all)
lemma card_bernoulli_pmf:
fixes x :: nat
assumes \<open>n > 0\<close> \<open>x < n\<close>
shows \<open>pmf (bernoulli_pmf (1/52)) (x \<notin> {0..<n - 1}) = (if x \<in> {0..<n - 1} then 51/52 else 1/52)\<close>
by(subst bernoulli_pmf.rep_eq, simp add: assms)
lemma pmf_card_btrial':
assumes \<open>n > 0\<close>
shows \<open>pmf (card_btrial n) (\<lambda>x. x \<notin> {0..<(n - 1)}) = 1/52 * (51/52)^(n - 1)\<close>
proof-
have \<open>pmf (card_btrial n) (\<lambda>x. x \<notin> {0..<(n - 1)}) = (\<Prod>x \<in> {0..<n}. pmf (bernoulli_pmf (1/52)) (x \<notin> {0..<(n - 1)}))\<close> unfolding pmf_card_btrial by simp
moreover have \<open>... = (\<Prod>x \<in> {0..<n}. if x < n - Suc 0 then 51 / 52 else 1 / 52)\<close>
using card_bernoulli_pmf by auto
moreover have \<open>... = (\<Prod>x \<in> {..<n - 1} \<union> {n-1..<n}. if x < n - Suc 0 then 51 / 52 else 1 / 52)\<close>
by (simp add: atLeast0LessThan ivl_disj_un_one(2))
moreover have \<open>... = (\<Prod>x \<in> {..<n - 1}. if x < n - Suc 0 then 51 / 52 else 1 / 52) * (\<Prod> x \<in> {n - 1..<n}. if x < n - Suc 0 then 51 / 52 else 1 / 52)\<close>
by(intro comm_monoid_mult_class.prod.union_disjoint, simp_all add: ivl_disj_int(2))
moreover have \<open>... = (\<Prod>x \<in> {..<n - 1}. 51/52) * (\<Prod> x \<in> {n - 1..<n}. 1/52)\<close> by simp
moreover have \<open>... = (51/52)^(n-1) * (1/52)\<close>
by(cases \<open>n = 1\<close>) (simp_all add: Suc_leI assms)
ultimately show ?thesis by auto
qed
lemma pmf_card_btrial'': \<open>pmf (card_btrial n) (\<lambda>x. x \<notin> {0..<(n - 1)}) = (if n = 0 then 1 else 1/52 * (51/52)^(n - 1))\<close>
proof(cases \<open>n = 0\<close>)
case True
then show ?thesis unfolding pmf_card_btrial
by(simp)
next
case False
hence \<open>n > 0\<close> by blast
thus ?thesis using pmf_card_btrial' by auto
qed
text\<open>As evidenced, this is significantly less hassle than before!\<close>
end

6
Probability/ROOT Normal file
View File

@ -0,0 +1,6 @@
session Probability = "HOL-Probability" +
options [document = pdf, document_output = "output"]
theories [document = true]
Outline
document_files
"root.tex"

View File

@ -0,0 +1,60 @@
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{isabelle,isabellesym}
% further packages required for unusual symbols (see also
% isabellesym.sty), use only when needed
%\usepackage{amssymb}
%for \<leadsto>, \<box>, \<diamond>, \<sqsupset>, \<mho>, \<Join>,
%\<lhd>, \<lesssim>, \<greatersim>, \<lessapprox>, \<greaterapprox>,
%\<triangleq>, \<yen>, \<lozenge>
%\usepackage{eurosym}
%for \<euro>
%\usepackage[only,bigsqcap,bigparallel,fatsemi,interleave,sslash]{stmaryrd}
%for \<Sqinter>, \<Parallel>, \<Zsemi>, \<Parallel>, \<sslash>
%\usepackage{eufrak}
%for \<AA> ... \<ZZ>, \<aa> ... \<zz> (also included in amssymb)
%\usepackage{textcomp}
%for \<onequarter>, \<onehalf>, \<threequarters>, \<degree>, \<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}
% for uniform font size
%\renewcommand{\isastyle}{\isastyleminor}
\begin{document}
\title{Probability}
\author{user}
\maketitle
\tableofcontents
% sane default for proof documents
\parindent 0pt\parskip 0.5ex
% generated text of all theories
\input{session}
% optional bibliography
%\bibliographystyle{abbrv}
%\bibliography{root}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,280 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Comment.sty version 3.6, October 1999
%
% Purpose:
% selectively in/exclude pieces of text: the user can define new
% comment versions, and each is controlled separately.
% Special comments can be defined where the user specifies the
% action that is to be taken with each comment line.
%
% Author
% Victor Eijkhout
% Department of Computer Science
% University of Tennessee
% 107 Ayres Hall
% Knoxville TN 37996
% USA
%
% victor@eijkhout.net
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% For a copy of the GNU General Public License, write to the
% Free Software Foundation, Inc.,
% 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA,
% or find it on the net, for instance at
% http://www.gnu.org/copyleft/gpl.html
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This style can be used with plain TeX or LaTeX, and probably
% most other packages too.
%
% Usage: all text included between
% \comment ... \endcomment
% or \begin{comment} ... \end{comment}
% is discarded.
%
% The opening and closing commands should appear on a line
% of their own. No starting spaces, nothing after it.
% This environment should work with arbitrary amounts
% of comment, and the comment can be arbitrary text.
%
% Other `comment' environments are defined by
% and are selected/deselected with
% \includecomment{versiona}
% \excludecoment{versionb}
%
% These environments are used as
% \versiona ... \endversiona
% or \begin{versiona} ... \end{versiona}
% with the opening and closing commands again on a line of
% their own.
%
% LaTeX users note: for an included comment, the
% \begin and \end lines act as if they don't exist.
% In particular, they don't imply grouping, so assignments
% &c are not local.
%
% Special comments are defined as
% \specialcomment{name}{before commands}{after commands}
% where the second and third arguments are executed before
% and after each comment block. You can use this for global
% formatting commands.
% To keep definitions &c local, you can include \begingroup
% in the `before commands' and \endgroup in the `after commands'.
% ex:
% \specialcomment{smalltt}
% {\begingroup\ttfamily\footnotesize}{\endgroup}
% You do *not* have to do an additional
% \includecomment{smalltt}
% To remove 'smalltt' blocks, give \excludecomment{smalltt}
% after the definition.
%
% Processing comments can apply processing to each line.
% \processcomment{name}{each-line commands}%
% {before commands}{after commands}
% By defining a control sequence
% \def\Thiscomment##1{...} in the before commands the user can
% specify what is to be done with each comment line.
% BUG this does not work quite yet BUG
%
% Trick for short in/exclude macros (such as \maybe{this snippet}):
%\includecomment{cond}
%\newcommand{\maybe}[1]{}
%\begin{cond}
%\renewcommand{\maybe}[1]{#1}
%\end{cond}
%
% Basic approach of the implementation:
% to comment something out, scoop up every line in verbatim mode
% as macro argument, then throw it away.
% For inclusions, in LaTeX the block is written out to
% a file \CommentCutFile (default "comment.cut"), which is
% then included.
% In plain TeX (and other formats) both the opening and
% closing comands are defined as noop.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Changes in version 3.1
% - updated author's address
% - cleaned up some code
% - trailing contents on \begin{env} line is always discarded
% even if you've done \includecomment{env}
% - comments no longer define grouping!! you can even
% \includecomment{env}
% \begin{env}
% \begin{itemize}
% \end{env}
% Isn't that something ...
% - included comments are written to file and input again.
% Changes in 3.2
% - \specialcomment brought up to date (thanks to Ivo Welch).
% Changes in 3.3
% - updated author's address again
% - parametrised \CommentCutFile
% Changes in 3.4
% - added GNU public license
% - added \processcomment, because Ivo's fix (above) brought an
% inconsistency to light.
% Changes in 3.5
% - corrected typo in header.
% - changed author email
% - corrected \specialcomment yet again.
% - fixed excludecomment of an earlier defined environment.
% Changes in 3.6
% - The 'cut' file is now written more verbatim, using \meaning;
% some people reported having trouble with ISO latin 1, or umlaute.sty.
% - removed some \newif statements.
% Has this suddenly become \outer again?
%
% Known bugs:
% - excludecomment leads to one superfluous space
% - processcomment leads to a superfluous line break
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\makeinnocent#1{\catcode`#1=12 }
\def\csarg#1#2{\expandafter#1\csname#2\endcsname}
\def\latexname{lplain}\def\latexename{LaTeX2e}
\newwrite\CommentStream
\def\CommentCutFile{comment.cut}
\def\ProcessComment#1% start it all of
{\begingroup
\def\CurrentComment{#1}%
\let\do\makeinnocent \dospecials
\makeinnocent\^^L% and whatever other special cases
\endlinechar`\^^M \catcode`\^^M=12 \xComment}
%\def\ProcessCommentWithArg#1#2% to be used in \leveledcomment
% {\begingroup
% \def\CurrentComment{#1}%
% \let\do\makeinnocent \dospecials
% \makeinnocent\^^L% and whatever other special cases
% \endlinechar`\^^M \catcode`\^^M=12 \xComment}
{\catcode`\^^M=12 \endlinechar=-1 %
\gdef\xComment#1^^M{%
\expandafter\ProcessCommentLine}
\gdef\ProcessCommentLine#1^^M{\def\test{#1}
\csarg\ifx{End\CurrentComment Test}\test
\edef\next{\noexpand\EndOfComment{\CurrentComment}}%
\else \ThisComment{#1}\let\next\ProcessCommentLine
\fi \next}
}
\def\CSstringmeaning#1{\expandafter\CSgobblearrow\meaning#1}
\def\CSstringcsnoescape#1{\expandafter\CSgobbleescape\string#1}
{\escapechar-1
\expandafter\expandafter\expandafter\gdef
\expandafter\expandafter\expandafter\CSgobblearrow
\expandafter\string\csname macro:->\endcsname{}
}
\def\CSgobbleescape#1{\ifnum`\\=`#1 \else #1\fi}
\def\WriteCommentLine#1{\def\CStmp{#1}%
\immediate\write\CommentStream{\CSstringmeaning\CStmp}}
% 3.1 change: in LaTeX and LaTeX2e prevent grouping
\if 0%
\ifx\fmtname\latexename
0%
\else \ifx\fmtname\latexname
0%
\else
1%
\fi \fi
%%%%
%%%% definitions for LaTeX
%%%%
\def\AfterIncludedComment
{\immediate\closeout\CommentStream
\input{\CommentCutFile}\relax
}%
\def\TossComment{\immediate\closeout\CommentStream}
\def\BeforeIncludedComment
{\immediate\openout\CommentStream=\CommentCutFile
\let\ThisComment\WriteCommentLine}
\def\includecomment
#1{\message{Include comment '#1'}%
\csarg\let{After#1Comment}\AfterIncludedComment
\csarg\def{#1}{\BeforeIncludedComment
\ProcessComment{#1}}%
\CommentEndDef{#1}}
\long\def\specialcomment
#1#2#3{\message{Special comment '#1'}%
% note: \AfterIncludedComment does \input, so #2 goes here!
\csarg\def{After#1Comment}{#2\AfterIncludedComment#3}%
\csarg\def{#1}{\BeforeIncludedComment\relax
\ProcessComment{#1}}%
\CommentEndDef{#1}}
\long\def\processcomment
#1#2#3#4{\message{Lines-Processing comment '#1'}%
\csarg\def{After#1Comment}{#3\AfterIncludedComment#4}%
\csarg\def{#1}{\BeforeIncludedComment#2\relax
\ProcessComment{#1}}%
\CommentEndDef{#1}}
\def\leveledcomment
#1#2{\message{Include comment '#1' up to level '#2'}%
%\csname #1IsLeveledCommenttrue\endcsname
\csarg\let{After#1Comment}\AfterIncludedComment
\csarg\def{#1}{\BeforeIncludedComment
\ProcessCommentWithArg{#1}}%
\CommentEndDef{#1}}
\else
%%%%
%%%%plain TeX and other formats
%%%%
\def\includecomment
#1{\message{Including comment '#1'}%
\csarg\def{#1}{}%
\csarg\def{end#1}{}}
\long\def\specialcomment
#1#2#3{\message{Special comment '#1'}%
\csarg\def{#1}{\def\ThisComment{}\def\AfterComment{#3}#2%
\ProcessComment{#1}}%
\CommentEndDef{#1}}
\fi
%%%%
%%%% general definition of skipped comment
%%%%
\def\excludecomment
#1{\message{Excluding comment '#1'}%
\csarg\def{#1}{\let\AfterComment\relax
\def\ThisComment####1{}\ProcessComment{#1}}%
\csarg\let{After#1Comment}\TossComment
\CommentEndDef{#1}}
\if 0%
\ifx\fmtname\latexename
0%
\else \ifx\fmtname\latexname
0%
\else
1%
\fi \fi
% latex & latex2e:
\def\EndOfComment#1{\endgroup\end{#1}%
\csname After#1Comment\endcsname}
\def\CommentEndDef#1{{\escapechar=-1\relax
\csarg\xdef{End#1Test}{\string\\end\string\{#1\string\}}%
}}
\else
% plain & other
\def\EndOfComment#1{\endgroup\AfterComment}
\def\CommentEndDef#1{{\escapechar=-1\relax
\csarg\xdef{End#1Test}{\string\\end#1}%
}}
\fi
\excludecomment{comment}
\endinput
\endinput
%:%file=~~/lib/texinputs/comment.sty%:%

View File

@ -0,0 +1,294 @@
%%
%% macros for Isabelle generated LaTeX output
%%
%%% Simple document preparation (based on theory token language and symbols)
% isabelle environments
\newcommand{\isabellecontext}{UNKNOWN}
\newcommand{\setisabellecontext}[1]{\def\isabellecontext{#1}}
\newcommand{\isastyle}{\UNDEF}
\newcommand{\isastylett}{\UNDEF}
\newcommand{\isastyleminor}{\UNDEF}
\newcommand{\isastyleminortt}{\UNDEF}
\newcommand{\isastylescript}{\UNDEF}
\newcommand{\isastyletext}{\normalsize\normalfont\rmfamily}
\newcommand{\isastyletxt}{\normalfont\rmfamily}
\newcommand{\isastylecmt}{\normalfont\rmfamily}
\newcommand{\isaspacing}{%
\sfcode 42 1000 % .
\sfcode 63 1000 % ?
\sfcode 33 1000 % !
\sfcode 58 1000 % :
\sfcode 59 1000 % ;
\sfcode 44 1000 % ,
}
%symbol markup -- \emph achieves decent spacing via italic corrections
\newcommand{\isamath}[1]{\emph{$#1$}}
\newcommand{\isatext}[1]{\emph{#1}}
\DeclareRobustCommand{\isascriptstyle}{\def\isamath##1{##1}\def\isatext##1{\mbox{\isaspacing\isastylescript##1}}}
\newcommand{\isactrlsub}[1]{\emph{\isascriptstyle${}\sb{#1}$}}
\newcommand{\isactrlsup}[1]{\emph{\isascriptstyle${}\sp{#1}$}}
\DeclareRobustCommand{\isactrlbsub}{\emph\bgroup\math{}\sb\bgroup\mbox\bgroup\isaspacing\isastylescript}
\DeclareRobustCommand{\isactrlesub}{\egroup\egroup\endmath\egroup}
\DeclareRobustCommand{\isactrlbsup}{\emph\bgroup\math{}\sp\bgroup\mbox\bgroup\isaspacing\isastylescript}
\DeclareRobustCommand{\isactrlesup}{\egroup\egroup\endmath\egroup}
\newcommand{\isactrlbold}[1]{{\bfseries\upshape\boldmath#1}}
%blackboard-bold (requires font txmia from pxfonts)
\DeclareSymbolFont{bbbfont}{U}{txmia}{m}{it}
\SetSymbolFont{bbbfont}{bold}{U}{txmia}{bx}{it}
\DeclareMathSymbol{\bbbA}{\mathord}{bbbfont}{129}
\DeclareMathSymbol{\bbbB}{\mathord}{bbbfont}{130}
\DeclareMathSymbol{\bbbC}{\mathord}{bbbfont}{131}
\DeclareMathSymbol{\bbbD}{\mathord}{bbbfont}{132}
\DeclareMathSymbol{\bbbE}{\mathord}{bbbfont}{133}
\DeclareMathSymbol{\bbbF}{\mathord}{bbbfont}{134}
\DeclareMathSymbol{\bbbG}{\mathord}{bbbfont}{135}
\DeclareMathSymbol{\bbbH}{\mathord}{bbbfont}{136}
\DeclareMathSymbol{\bbbI}{\mathord}{bbbfont}{137}
\DeclareMathSymbol{\bbbJ}{\mathord}{bbbfont}{138}
\DeclareMathSymbol{\bbbK}{\mathord}{bbbfont}{139}
\DeclareMathSymbol{\bbbL}{\mathord}{bbbfont}{140}
\DeclareMathSymbol{\bbbM}{\mathord}{bbbfont}{141}
\DeclareMathSymbol{\bbbN}{\mathord}{bbbfont}{142}
\DeclareMathSymbol{\bbbO}{\mathord}{bbbfont}{143}
\DeclareMathSymbol{\bbbP}{\mathord}{bbbfont}{144}
\DeclareMathSymbol{\bbbQ}{\mathord}{bbbfont}{145}
\DeclareMathSymbol{\bbbR}{\mathord}{bbbfont}{146}
\DeclareMathSymbol{\bbbS}{\mathord}{bbbfont}{147}
\DeclareMathSymbol{\bbbT}{\mathord}{bbbfont}{148}
\DeclareMathSymbol{\bbbU}{\mathord}{bbbfont}{149}
\DeclareMathSymbol{\bbbV}{\mathord}{bbbfont}{150}
\DeclareMathSymbol{\bbbW}{\mathord}{bbbfont}{151}
\DeclareMathSymbol{\bbbX}{\mathord}{bbbfont}{152}
\DeclareMathSymbol{\bbbY}{\mathord}{bbbfont}{153}
\DeclareMathSymbol{\bbbZ}{\mathord}{bbbfont}{154}
\newenvironment{isaantiq}{{\isacharat\isacharbraceleft}}{{\isacharbraceright}}
\newdimen\isa@parindent\newdimen\isa@parskip
\newenvironment{isabellebody}{%
\isamarkuptrue\par%
\isa@parindent\parindent\parindent0pt%
\isa@parskip\parskip\parskip0pt%
\isaspacing\isastyle}{\par}
\newenvironment{isabellebodytt}{%
\isamarkuptrue\par%
\isa@parindent\parindent\parindent0pt%
\isa@parskip\parskip\parskip0pt%
\isaspacing\isastylett}{\par}
\newenvironment{isabelle}
{\begin{trivlist}\begin{isabellebody}\item\relax}
{\end{isabellebody}\end{trivlist}}
\newenvironment{isabellett}
{\begin{trivlist}\begin{isabellebodytt}\item\relax}
{\end{isabellebodytt}\end{trivlist}}
\newcommand{\isa}[1]{\emph{\isaspacing\isastyleminor #1}}
\newcommand{\isatt}[1]{\emph{\isaspacing\isastyleminortt #1}}
\newcommand{\isaindent}[1]{\hphantom{#1}}
\newcommand{\isanewline}{\mbox{}\par\mbox{}}
\newcommand{\isasep}{}
\newcommand{\isadigit}[1]{#1}
\newcommand{\isachardefaults}{%
\def\isacharbell{\isamath{\bigbox}}%requires stmaryrd
\chardef\isacharbang=`\!%
\chardef\isachardoublequote=`\"%
\chardef\isachardoublequoteopen=`\"%
\chardef\isachardoublequoteclose=`\"%
\chardef\isacharhash=`\#%
\chardef\isachardollar=`\$%
\chardef\isacharpercent=`\%%
\chardef\isacharampersand=`\&%
\chardef\isacharprime=`\'%
\chardef\isacharparenleft=`\(%
\chardef\isacharparenright=`\)%
\chardef\isacharasterisk=`\*%
\chardef\isacharplus=`\+%
\chardef\isacharcomma=`\,%
\chardef\isacharminus=`\-%
\chardef\isachardot=`\.%
\chardef\isacharslash=`\/%
\chardef\isacharcolon=`\:%
\chardef\isacharsemicolon=`\;%
\chardef\isacharless=`\<%
\chardef\isacharequal=`\=%
\chardef\isachargreater=`\>%
\chardef\isacharquery=`\?%
\chardef\isacharat=`\@%
\chardef\isacharbrackleft=`\[%
\chardef\isacharbackslash=`\\%
\chardef\isacharbrackright=`\]%
\chardef\isacharcircum=`\^%
\chardef\isacharunderscore=`\_%
\def\isacharunderscorekeyword{\_}%
\chardef\isacharbackquote=`\`%
\chardef\isacharbackquoteopen=`\`%
\chardef\isacharbackquoteclose=`\`%
\chardef\isacharbraceleft=`\{%
\chardef\isacharbar=`\|%
\chardef\isacharbraceright=`\}%
\chardef\isachartilde=`\~%
\def\isacartoucheopen{\isatext{\guilsinglleft}}%
\def\isacartoucheclose{\isatext{\guilsinglright}}%
}
% keyword and section markup
\newcommand{\isakeyword}[1]
{\emph{\normalfont\bfseries\def\isachardot{.}\def\isacharunderscore{\isacharunderscorekeyword}%
\def\isacharbraceleft{\{}\def\isacharbraceright{\}}#1}}
\newcommand{\isacommand}[1]{\isakeyword{#1}}
\newcommand{\isakeywordONE}[1]{\isakeyword{#1}}
\newcommand{\isakeywordTWO}[1]{\isakeyword{#1}}
\newcommand{\isakeywordTHREE}[1]{\isakeyword{#1}}
\newcommand{\isatclass}[1]{#1}
\newcommand{\isatconst}[1]{#1}
\newcommand{\isatfree}[1]{#1}
\newcommand{\isatvar}[1]{#1}
\newcommand{\isaconst}[1]{#1}
\newcommand{\isafree}[1]{#1}
\newcommand{\isaskolem}[1]{#1}
\newcommand{\isabound}[1]{#1}
\newcommand{\isavar}[1]{#1}
\newcommand{\isakeywordcontrol}[1]
{\emph{\normalfont\bfseries\itshape\def\isacharunderscore{\isacharunderscorekeyword}#1\,}}
\newcommand{\isamarkupchapter}[1]{\chapter{#1}}
\newcommand{\isamarkupsection}[1]{\section{#1}}
\newcommand{\isamarkupsubsection}[1]{\subsection{#1}}
\newcommand{\isamarkupsubsubsection}[1]{\subsubsection{#1}}
\newcommand{\isamarkupparagraph}[1]{\paragraph{#1}}
\newcommand{\isamarkupsubparagraph}[1]{\subparagraph{#1}}
\newif\ifisamarkup
\newcommand{\isabeginpar}{\par\ifisamarkup\relax\else\medskip\fi}
\newcommand{\isaendpar}{\par\medskip}
\newenvironment{isapar}{\parindent\isa@parindent\parskip\isa@parskip\isabeginpar}{\isaendpar}
\newenvironment{isamarkuptext}{\par\isastyletext\begin{isapar}}{\end{isapar}}
\newenvironment{isamarkuptxt}{\par\isastyletxt\begin{isapar}}{\end{isapar}}
\newcommand{\isamarkupcmt}[1]{{\isastylecmt--- #1}}
% index entries
\newcommand{\isaindexdef}[1]{\textbf{#1}}
\newcommand{\isaindexref}[1]{#1}
% styles
\def\isabellestyle#1{\csname isabellestyle#1\endcsname}
\newcommand{\isabellestyledefault}{%
\def\isastyle{\small\normalfont\ttfamily\slshape}%
\def\isastylett{\small\normalfont\ttfamily}%
\def\isastyleminor{\small\normalfont\ttfamily\slshape}%
\def\isastyleminortt{\small\normalfont\ttfamily}%
\def\isastylescript{\footnotesize\normalfont\ttfamily\slshape}%
\isachardefaults%
}
\isabellestyledefault
\newcommand{\isabellestylett}{%
\def\isastyle{\small\normalfont\ttfamily}%
\def\isastylett{\small\normalfont\ttfamily}%
\def\isastyleminor{\small\normalfont\ttfamily}%
\def\isastyleminortt{\small\normalfont\ttfamily}%
\def\isastylescript{\footnotesize\normalfont\ttfamily}%
\isachardefaults%
}
\newcommand{\isabellestyleit}{%
\def\isastyle{\small\normalfont\itshape}%
\def\isastylett{\small\normalfont\ttfamily}%
\def\isastyleminor{\normalfont\itshape}%
\def\isastyleminortt{\normalfont\ttfamily}%
\def\isastylescript{\footnotesize\normalfont\itshape}%
\isachardefaults%
\def\isacharunderscorekeyword{\mbox{-}}%
\def\isacharbang{\isamath{!}}%
\def\isachardoublequote{}%
\def\isachardoublequoteopen{}%
\def\isachardoublequoteclose{}%
\def\isacharhash{\isamath{\#}}%
\def\isachardollar{\isamath{\$}}%
\def\isacharpercent{\isamath{\%}}%
\def\isacharampersand{\isamath{\&}}%
\def\isacharprime{\isamath{\mskip2mu{'}\mskip-2mu}}%
\def\isacharparenleft{\isamath{(}}%
\def\isacharparenright{\isamath{)}}%
\def\isacharasterisk{\isamath{*}}%
\def\isacharplus{\isamath{+}}%
\def\isacharcomma{\isamath{\mathord,}}%
\def\isacharminus{\isamath{-}}%
\def\isachardot{\isamath{\mathord.}}%
\def\isacharslash{\isamath{/}}%
\def\isacharcolon{\isamath{\mathord:}}%
\def\isacharsemicolon{\isamath{\mathord;}}%
\def\isacharless{\isamath{<}}%
\def\isacharequal{\isamath{=}}%
\def\isachargreater{\isamath{>}}%
\def\isacharat{\isamath{@}}%
\def\isacharbrackleft{\isamath{[}}%
\def\isacharbackslash{\isamath{\backslash}}%
\def\isacharbrackright{\isamath{]}}%
\def\isacharunderscore{\mbox{-}}%
\def\isacharbraceleft{\isamath{\{}}%
\def\isacharbar{\isamath{\mid}}%
\def\isacharbraceright{\isamath{\}}}%
\def\isachartilde{\isamath{{}\sp{\sim}}}%
\def\isacharbackquoteopen{\isatext{\guilsinglleft}}%
\def\isacharbackquoteclose{\isatext{\guilsinglright}}%
}
\newcommand{\isabellestyleliteral}{%
\isabellestyleit%
\def\isacharunderscore{\_}%
\def\isacharunderscorekeyword{\_}%
\chardef\isacharbackquoteopen=`\`%
\chardef\isacharbackquoteclose=`\`%
}
\newcommand{\isabellestyleliteralunderscore}{%
\isabellestyleliteral%
\def\isacharunderscore{\textunderscore}%
\def\isacharunderscorekeyword{\textunderscore}%
}
\newcommand{\isabellestylesl}{%
\isabellestyleit%
\def\isastyle{\small\normalfont\slshape}%
\def\isastylett{\small\normalfont\ttfamily}%
\def\isastyleminor{\normalfont\slshape}%
\def\isastyleminortt{\normalfont\ttfamily}%
\def\isastylescript{\footnotesize\normalfont\slshape}%
}
% cancel text
\usepackage[normalem]{ulem}
\newcommand{\isamarkupcancel}[1]{\isa{\xout{#1}}}
% tags
\newcommand{\isafold}[1]{\emph{$\langle\mathord{\mathit{#1}}\rangle$}}
\IfFileExists{isabelletags.sty}{\usepackage{isabelletags}}{}
\endinput
%:%file=~~/lib/texinputs/isabelle.sty%:%

View File

@ -0,0 +1,506 @@
%%
%% definitions of standard Isabelle symbols
%%
\newcommand{\isasymzero}{\isamath{\mathbf{0}}} %requires amssymb
\newcommand{\isasymone}{\isamath{\mathbf{1}}} %requires amssymb
\newcommand{\isasymtwo}{\isamath{\mathbf{2}}} %requires amssymb
\newcommand{\isasymthree}{\isamath{\mathbf{3}}} %requires amssymb
\newcommand{\isasymfour}{\isamath{\mathbf{4}}} %requires amssymb
\newcommand{\isasymfive}{\isamath{\mathbf{5}}} %requires amssymb
\newcommand{\isasymsix}{\isamath{\mathbf{6}}} %requires amssymb
\newcommand{\isasymseven}{\isamath{\mathbf{7}}} %requires amssymb
\newcommand{\isasymeight}{\isamath{\mathbf{8}}} %requires amssymb
\newcommand{\isasymnine}{\isamath{\mathbf{9}}} %requires amssymb
\newcommand{\isasymA}{\isamath{\mathcal{A}}}
\newcommand{\isasymB}{\isamath{\mathcal{B}}}
\newcommand{\isasymC}{\isamath{\mathcal{C}}}
\newcommand{\isasymD}{\isamath{\mathcal{D}}}
\newcommand{\isasymE}{\isamath{\mathcal{E}}}
\newcommand{\isasymF}{\isamath{\mathcal{F}}}
\newcommand{\isasymG}{\isamath{\mathcal{G}}}
\newcommand{\isasymH}{\isamath{\mathcal{H}}}
\newcommand{\isasymI}{\isamath{\mathcal{I}}}
\newcommand{\isasymJ}{\isamath{\mathcal{J}}}
\newcommand{\isasymK}{\isamath{\mathcal{K}}}
\newcommand{\isasymL}{\isamath{\mathcal{L}}}
\newcommand{\isasymM}{\isamath{\mathcal{M}}}
\newcommand{\isasymN}{\isamath{\mathcal{N}}}
\newcommand{\isasymO}{\isamath{\mathcal{O}}}
\newcommand{\isasymP}{\isamath{\mathcal{P}}}
\newcommand{\isasymQ}{\isamath{\mathcal{Q}}}
\newcommand{\isasymR}{\isamath{\mathcal{R}}}
\newcommand{\isasymS}{\isamath{\mathcal{S}}}
\newcommand{\isasymT}{\isamath{\mathcal{T}}}
\newcommand{\isasymU}{\isamath{\mathcal{U}}}
\newcommand{\isasymV}{\isamath{\mathcal{V}}}
\newcommand{\isasymW}{\isamath{\mathcal{W}}}
\newcommand{\isasymX}{\isamath{\mathcal{X}}}
\newcommand{\isasymY}{\isamath{\mathcal{Y}}}
\newcommand{\isasymZ}{\isamath{\mathcal{Z}}}
\newcommand{\isasyma}{\isamath{\mathrm{a}}}
\newcommand{\isasymb}{\isamath{\mathrm{b}}}
\newcommand{\isasymc}{\isamath{\mathrm{c}}}
\newcommand{\isasymd}{\isamath{\mathrm{d}}}
\newcommand{\isasyme}{\isamath{\mathrm{e}}}
\newcommand{\isasymf}{\isamath{\mathrm{f}}}
\newcommand{\isasymg}{\isamath{\mathrm{g}}}
\newcommand{\isasymh}{\isamath{\mathrm{h}}}
\newcommand{\isasymi}{\isamath{\mathrm{i}}}
\newcommand{\isasymj}{\isamath{\mathrm{j}}}
\newcommand{\isasymk}{\isamath{\mathrm{k}}}
\newcommand{\isasyml}{\isamath{\mathrm{l}}}
\newcommand{\isasymm}{\isamath{\mathrm{m}}}
\newcommand{\isasymn}{\isamath{\mathrm{n}}}
\newcommand{\isasymo}{\isamath{\mathrm{o}}}
\newcommand{\isasymp}{\isamath{\mathrm{p}}}
\newcommand{\isasymq}{\isamath{\mathrm{q}}}
\newcommand{\isasymr}{\isamath{\mathrm{r}}}
\newcommand{\isasyms}{\isamath{\mathrm{s}}}
\newcommand{\isasymt}{\isamath{\mathrm{t}}}
\newcommand{\isasymu}{\isamath{\mathrm{u}}}
\newcommand{\isasymv}{\isamath{\mathrm{v}}}
\newcommand{\isasymw}{\isamath{\mathrm{w}}}
\newcommand{\isasymx}{\isamath{\mathrm{x}}}
\newcommand{\isasymy}{\isamath{\mathrm{y}}}
\newcommand{\isasymz}{\isamath{\mathrm{z}}}
\newcommand{\isasymAA}{\isamath{\mathfrak{A}}} %requires eufrak
\newcommand{\isasymBB}{\isamath{\mathfrak{B}}} %requires eufrak
\newcommand{\isasymCC}{\isamath{\mathfrak{C}}} %requires eufrak
\newcommand{\isasymDD}{\isamath{\mathfrak{D}}} %requires eufrak
\newcommand{\isasymEE}{\isamath{\mathfrak{E}}} %requires eufrak
\newcommand{\isasymFF}{\isamath{\mathfrak{F}}} %requires eufrak
\newcommand{\isasymGG}{\isamath{\mathfrak{G}}} %requires eufrak
\newcommand{\isasymHH}{\isamath{\mathfrak{H}}} %requires eufrak
\newcommand{\isasymII}{\isamath{\mathfrak{I}}} %requires eufrak
\newcommand{\isasymJJ}{\isamath{\mathfrak{J}}} %requires eufrak
\newcommand{\isasymKK}{\isamath{\mathfrak{K}}} %requires eufrak
\newcommand{\isasymLL}{\isamath{\mathfrak{L}}} %requires eufrak
\newcommand{\isasymMM}{\isamath{\mathfrak{M}}} %requires eufrak
\newcommand{\isasymNN}{\isamath{\mathfrak{N}}} %requires eufrak
\newcommand{\isasymOO}{\isamath{\mathfrak{O}}} %requires eufrak
\newcommand{\isasymPP}{\isamath{\mathfrak{P}}} %requires eufrak
\newcommand{\isasymQQ}{\isamath{\mathfrak{Q}}} %requires eufrak
\newcommand{\isasymRR}{\isamath{\mathfrak{R}}} %requires eufrak
\newcommand{\isasymSS}{\isamath{\mathfrak{S}}} %requires eufrak
\newcommand{\isasymTT}{\isamath{\mathfrak{T}}} %requires eufrak
\newcommand{\isasymUU}{\isamath{\mathfrak{U}}} %requires eufrak
\newcommand{\isasymVV}{\isamath{\mathfrak{V}}} %requires eufrak
\newcommand{\isasymWW}{\isamath{\mathfrak{W}}} %requires eufrak
\newcommand{\isasymXX}{\isamath{\mathfrak{X}}} %requires eufrak
\newcommand{\isasymYY}{\isamath{\mathfrak{Y}}} %requires eufrak
\newcommand{\isasymZZ}{\isamath{\mathfrak{Z}}} %requires eufrak
\newcommand{\isasymaa}{\isamath{\mathfrak{a}}} %requires eufrak
\newcommand{\isasymbb}{\isamath{\mathfrak{b}}} %requires eufrak
\newcommand{\isasymcc}{\isamath{\mathfrak{c}}} %requires eufrak
\newcommand{\isasymdd}{\isamath{\mathfrak{d}}} %requires eufrak
\newcommand{\isasymee}{\isamath{\mathfrak{e}}} %requires eufrak
\newcommand{\isasymff}{\isamath{\mathfrak{f}}} %requires eufrak
\newcommand{\isasymgg}{\isamath{\mathfrak{g}}} %requires eufrak
\newcommand{\isasymhh}{\isamath{\mathfrak{h}}} %requires eufrak
\newcommand{\isasymii}{\isamath{\mathfrak{i}}} %requires eufrak
\newcommand{\isasymjj}{\isamath{\mathfrak{j}}} %requires eufrak
\newcommand{\isasymkk}{\isamath{\mathfrak{k}}} %requires eufrak
\newcommand{\isasymll}{\isamath{\mathfrak{l}}} %requires eufrak
\newcommand{\isasymmm}{\isamath{\mathfrak{m}}} %requires eufrak
\newcommand{\isasymnn}{\isamath{\mathfrak{n}}} %requires eufrak
\newcommand{\isasymoo}{\isamath{\mathfrak{o}}} %requires eufrak
\newcommand{\isasympp}{\isamath{\mathfrak{p}}} %requires eufrak
\newcommand{\isasymqq}{\isamath{\mathfrak{q}}} %requires eufrak
\newcommand{\isasymrr}{\isamath{\mathfrak{r}}} %requires eufrak
\newcommand{\isasymss}{\isamath{\mathfrak{s}}} %requires eufrak
\newcommand{\isasymtt}{\isamath{\mathfrak{t}}} %requires eufrak
\newcommand{\isasymuu}{\isamath{\mathfrak{u}}} %requires eufrak
\newcommand{\isasymvv}{\isamath{\mathfrak{v}}} %requires eufrak
\newcommand{\isasymww}{\isamath{\mathfrak{w}}} %requires eufrak
\newcommand{\isasymxx}{\isamath{\mathfrak{x}}} %requires eufrak
\newcommand{\isasymyy}{\isamath{\mathfrak{y}}} %requires eufrak
\newcommand{\isasymzz}{\isamath{\mathfrak{z}}} %requires eufrak
\newcommand{\isasymalpha}{\isamath{\alpha}}
\newcommand{\isasymbeta}{\isamath{\beta}}
\newcommand{\isasymgamma}{\isamath{\gamma}}
\newcommand{\isasymdelta}{\isamath{\delta}}
\newcommand{\isasymepsilon}{\isamath{\varepsilon}}
\newcommand{\isasymzeta}{\isamath{\zeta}}
\newcommand{\isasymeta}{\isamath{\eta}}
\newcommand{\isasymtheta}{\isamath{\vartheta}}
\newcommand{\isasymiota}{\isamath{\iota}}
\newcommand{\isasymkappa}{\isamath{\kappa}}
\newcommand{\isasymlambda}{\isamath{\lambda}}
\newcommand{\isasymmu}{\isamath{\mu}}
\newcommand{\isasymnu}{\isamath{\nu}}
\newcommand{\isasymxi}{\isamath{\xi}}
\newcommand{\isasympi}{\isamath{\pi}}
\newcommand{\isasymrho}{\isamath{\varrho}}
\newcommand{\isasymsigma}{\isamath{\sigma}}
\newcommand{\isasymtau}{\isamath{\tau}}
\newcommand{\isasymupsilon}{\isamath{\upsilon}}
\newcommand{\isasymphi}{\isamath{\varphi}}
\newcommand{\isasymchi}{\isamath{\chi}}
\newcommand{\isasympsi}{\isamath{\psi}}
\newcommand{\isasymomega}{\isamath{\omega}}
\newcommand{\isasymGamma}{\isamath{\Gamma}}
\newcommand{\isasymDelta}{\isamath{\Delta}}
\newcommand{\isasymTheta}{\isamath{\Theta}}
\newcommand{\isasymLambda}{\isamath{\Lambda}}
\newcommand{\isasymXi}{\isamath{\Xi}}
\newcommand{\isasymPi}{\isamath{\Pi}}
\newcommand{\isasymSigma}{\isamath{\Sigma}}
\newcommand{\isasymUpsilon}{\isamath{\Upsilon}}
\newcommand{\isasymPhi}{\isamath{\Phi}}
\newcommand{\isasymPsi}{\isamath{\Psi}}
\newcommand{\isasymOmega}{\isamath{\Omega}}
\newcommand{\isasymbbbA}{\isamath{\bbbA}} %requires font txmia from txfonts
\newcommand{\isasymbool}{\isamath{\bbbB}} %requires font txmia from txfonts
\newcommand{\isasymcomplex}{\isamath{\bbbC}} %requires font txmia from txfonts
\newcommand{\isasymbbbD}{\isamath{\bbbD}} %requires font txmia from txfonts
\newcommand{\isasymbbbE}{\isamath{\bbbE}} %requires font txmia from txfonts
\newcommand{\isasymbbbF}{\isamath{\bbbF}} %requires font txmia from txfonts
\newcommand{\isasymbbbG}{\isamath{\bbbG}} %requires font txmia from txfonts
\newcommand{\isasymbbbH}{\isamath{\bbbH}} %requires font txmia from txfonts
\newcommand{\isasymbbbI}{\isamath{\bbbI}} %requires font txmia from txfonts
\newcommand{\isasymbbbJ}{\isamath{\bbbJ}} %requires font txmia from txfonts
\newcommand{\isasymbbbK}{\isamath{\bbbK}} %requires font txmia from txfonts
\newcommand{\isasymbbbL}{\isamath{\bbbL}} %requires font txmia from txfonts
\newcommand{\isasymbbbM}{\isamath{\bbbM}} %requires font txmia from txfonts
\newcommand{\isasymnat}{\isamath{\bbbN}} %requires font txmia from txfonts
\newcommand{\isasymbbbO}{\isamath{\bbbO}} %requires font txmia from txfonts
\newcommand{\isasymbbbP}{\isamath{\bbbP}} %requires font txmia from txfonts
\newcommand{\isasymrat}{\isamath{\bbbQ}} %requires font txmia from txfonts
\newcommand{\isasymreal}{\isamath{\bbbR}} %requires font txmia from txfonts
\newcommand{\isasymbbbS}{\isamath{\bbbS}} %requires font txmia from txfonts
\newcommand{\isasymbbbT}{\isamath{\bbbT}} %requires font txmia from txfonts
\newcommand{\isasymbbbU}{\isamath{\bbbU}} %requires font txmia from txfonts
\newcommand{\isasymbbbV}{\isamath{\bbbV}} %requires font txmia from txfonts
\newcommand{\isasymbbbW}{\isamath{\bbbW}} %requires font txmia from txfonts
\newcommand{\isasymbbbX}{\isamath{\bbbX}} %requires font txmia from txfonts
\newcommand{\isasymbbbY}{\isamath{\bbbY}} %requires font txmia from txfonts
\newcommand{\isasymint}{\isamath{\bbbZ}} %requires font txmia from txfonts
\newcommand{\isasymleftarrow}{\isamath{\leftarrow}}
\newcommand{\isasymrightarrow}{\isamath{\rightarrow}}
\newcommand{\isasymlongleftarrow}{\isamath{\longleftarrow}}
\newcommand{\isasymlongrightarrow}{\isamath{\longrightarrow}}
\newcommand{\isasymlonglongleftarrow}{\isamath{\xleftarrow{\hphantom{AAA}}}} %requires amsmath
\newcommand{\isasymlonglongrightarrow}{\isamath{\xrightarrow{\hphantom{AAA}}}} %requires amsmath
\newcommand{\isasymlonglonglongleftarrow}{\isamath{\xleftarrow{\hphantom{AAAA}}}} %requires amsmath
\newcommand{\isasymlonglonglongrightarrow}{\isamath{\xrightarrow{\hphantom{AAAA}}}} %requires amsmath
\newcommand{\isasymLeftarrow}{\isamath{\Leftarrow}}
\newcommand{\isasymRightarrow}{\isamath{\Rightarrow}}
\newcommand{\isasymLongleftarrow}{\isamath{\Longleftarrow}}
\newcommand{\isasymLongrightarrow}{\isamath{\Longrightarrow}}
\newcommand{\isasymLleftarrow}{\isamath{\Lleftarrow}} %requires amssymb
\newcommand{\isasymRrightarrow}{\isamath{\Rrightarrow}} %requires amssymb
\newcommand{\isasymleftrightarrow}{\isamath{\leftrightarrow}}
\newcommand{\isasymLeftrightarrow}{\isamath{\Leftrightarrow}}
\newcommand{\isasymlongleftrightarrow}{\isamath{\longleftrightarrow}}
\newcommand{\isasymLongleftrightarrow}{\isamath{\Longleftrightarrow}}
\newcommand{\isasymmapsto}{\isamath{\mapsto}}
\newcommand{\isasymlongmapsto}{\isamath{\longmapsto}}
\newcommand{\isasymmidarrow}{\isamath{\relbar}}
\newcommand{\isasymMidarrow}{\isamath{\Relbar}}
\newcommand{\isasymhookleftarrow}{\isamath{\hookleftarrow}}
\newcommand{\isasymhookrightarrow}{\isamath{\hookrightarrow}}
\newcommand{\isasymleftharpoondown}{\isamath{\leftharpoondown}}
\newcommand{\isasymrightharpoondown}{\isamath{\rightharpoondown}}
\newcommand{\isasymleftharpoonup}{\isamath{\leftharpoonup}}
\newcommand{\isasymrightharpoonup}{\isamath{\rightharpoonup}}
\newcommand{\isasymrightleftharpoons}{\isamath{\rightleftharpoons}}
\newcommand{\isasymleadsto}{\isamath{\leadsto}} %requires amssymb
\newcommand{\isasymdownharpoonleft}{\isamath{\downharpoonleft}} %requires amssymb
\newcommand{\isasymdownharpoonright}{\isamath{\downharpoonright}} %requires amssymb
\newcommand{\isasymupharpoonleft}{\isamath{\upharpoonleft}} %requires amssymb
\newcommand{\isasymupharpoonright}{\isamath{\upharpoonright}} %requires amssymb
\newcommand{\isasymrestriction}{\isamath{\restriction}} %requires amssymb
\newcommand{\isasymColon}{\isamath{\mathrel{::}}}
\newcommand{\isasymup}{\isamath{\uparrow}}
\newcommand{\isasymUp}{\isamath{\Uparrow}}
\newcommand{\isasymdown}{\isamath{\downarrow}}
\newcommand{\isasymDown}{\isamath{\Downarrow}}
\newcommand{\isasymupdown}{\isamath{\updownarrow}}
\newcommand{\isasymUpdown}{\isamath{\Updownarrow}}
\newcommand{\isasymlangle}{\isamath{\langle}}
\newcommand{\isasymrangle}{\isamath{\rangle}}
\newcommand{\isasymllangle}{\isamath{\langle\mskip-5mu\langle}}
\newcommand{\isasymrrangle}{\isamath{\rangle\mskip-5mu\rangle}}
\newcommand{\isasymlceil}{\isamath{\lceil}}
\newcommand{\isasymrceil}{\isamath{\rceil}}
\newcommand{\isasymlfloor}{\isamath{\lfloor}}
\newcommand{\isasymrfloor}{\isamath{\rfloor}}
\newcommand{\isasymlparr}{\isamath{\mathopen{(\mkern-3.3mu\mid}}}
\newcommand{\isasymrparr}{\isamath{\mathclose{\mid\mkern-3.3mu)}}}
\newcommand{\isasymlbrakk}{\isamath{\mathopen{\lbrack\mkern-3mu\lbrack}}}
\newcommand{\isasymrbrakk}{\isamath{\mathclose{\rbrack\mkern-3mu\rbrack}}}
\newcommand{\isasymlbrace}{\isamath{\mathopen{\lbrace\mkern-4.3mu\mid}}}
\newcommand{\isasymrbrace}{\isamath{\mathclose{\mid\mkern-4.3mu\rbrace}}}
\newcommand{\isasymlblot}{\isamath{{\langle}\mkern -3.5mu{|}}}
\newcommand{\isasymrblot}{\isamath{{|}\mkern -3.5mu{\rangle}}}
\newcommand{\isasymguillemotleft}{\isatext{\guillemotleft}}
\newcommand{\isasymguillemotright}{\isatext{\guillemotright}}
\newcommand{\isasymbottom}{\isamath{\bot}}
\newcommand{\isasymtop}{\isamath{\top}}
\newcommand{\isasymand}{\isamath{\wedge}}
\newcommand{\isasymAnd}{\isamath{\bigwedge}}
\newcommand{\isasymor}{\isamath{\vee}}
\newcommand{\isasymOr}{\isamath{\bigvee}}
\newcommand{\isasymforall}{\isamath{\forall\,}}
\newcommand{\isasymexists}{\isamath{\exists\,}}
\newcommand{\isasymnot}{\isamath{\neg}}
\newcommand{\isasymnexists}{\isamath{\nexists\,}} %requires amssymb
\newcommand{\isasymcircle}{\isamath{\ocircle}} %requires wasysym
\newcommand{\isasymbox}{\isamath{\Box}} %requires amssymb
\newcommand{\isasymdiamond}{\isamath{\Diamond}} %requires amssymb
\newcommand{\isasymdiamondop}{\isamath{\diamond}}
\newcommand{\isasymsurd}{\isamath{\surd}}
\newcommand{\isasymturnstile}{\isamath{\vdash}}
\newcommand{\isasymTurnstile}{\isamath{\models}}
\newcommand{\isasymtturnstile}{\isamath{\vdash\!\!\!\vdash}}
\newcommand{\isasymTTurnstile}{\isamath{\mid\!\models}}
\newcommand{\isasymstileturn}{\isamath{\dashv}}
\newcommand{\isasymle}{\isamath{\le}}
\newcommand{\isasymge}{\isamath{\ge}}
\newcommand{\isasymlless}{\isamath{\ll}}
\newcommand{\isasymggreater}{\isamath{\gg}}
\newcommand{\isasymlesssim}{\isamath{\lesssim}} %requires amssymb
\newcommand{\isasymgreatersim}{\isamath{\gtrsim}} %requires amssymb
\newcommand{\isasymlessapprox}{\isamath{\lessapprox}} %requires amssymb
\newcommand{\isasymgreaterapprox}{\isamath{\gtrapprox}} %requires amssymb
\newcommand{\isasymin}{\isamath{\in}}
\newcommand{\isasymnotin}{\isamath{\notin}}
\newcommand{\isasymsubset}{\isamath{\subset}}
\newcommand{\isasymsupset}{\isamath{\supset}}
\newcommand{\isasymsubseteq}{\isamath{\subseteq}}
\newcommand{\isasymsupseteq}{\isamath{\supseteq}}
\newcommand{\isasymsqsubset}{\isamath{\sqsubset}} %requires amssymb
\newcommand{\isasymsqsupset}{\isamath{\sqsupset}} %requires amssymb
\newcommand{\isasymsqsubseteq}{\isamath{\sqsubseteq}}
\newcommand{\isasymsqsupseteq}{\isamath{\sqsupseteq}}
\newcommand{\isasyminter}{\isamath{\cap}}
\newcommand{\isasymInter}{\isamath{\bigcap\,}}
\newcommand{\isasymunion}{\isamath{\cup}}
\newcommand{\isasymUnion}{\isamath{\bigcup\,}}
\newcommand{\isasymsqunion}{\isamath{\sqcup}}
\newcommand{\isasymSqunion}{\isamath{\bigsqcup\,}}
\newcommand{\isasymsqinter}{\isamath{\sqcap}}
\newcommand{\isasymSqinter}{\isamath{\bigsqcap\,}} %requires stmaryrd
\newcommand{\isasymsetminus}{\isamath{\setminus}}
\newcommand{\isasympropto}{\isamath{\propto}}
\newcommand{\isasymuplus}{\isamath{\uplus}}
\newcommand{\isasymUplus}{\isamath{\biguplus\,}}
\newcommand{\isasymnoteq}{\isamath{\not=}}
\newcommand{\isasymsim}{\isamath{\sim}}
\newcommand{\isasymdoteq}{\isamath{\doteq}}
\newcommand{\isasymsimeq}{\isamath{\simeq}}
\newcommand{\isasymapprox}{\isamath{\approx}}
\newcommand{\isasymasymp}{\isamath{\asymp}}
\newcommand{\isasymcong}{\isamath{\cong}}
\newcommand{\isasymsmile}{\isamath{\smile}}
\newcommand{\isasymequiv}{\isamath{\equiv}}
\newcommand{\isasymfrown}{\isamath{\frown}}
\newcommand{\isasymJoin}{\isamath{\Join}} %requires amssymb
\newcommand{\isasymbowtie}{\isamath{\bowtie}}
\newcommand{\isasymprec}{\isamath{\prec}}
\newcommand{\isasymsucc}{\isamath{\succ}}
\newcommand{\isasympreceq}{\isamath{\preceq}}
\newcommand{\isasymsucceq}{\isamath{\succeq}}
\newcommand{\isasymparallel}{\isamath{\parallel}}
\newcommand{\isasymParallel}{\isamath{\bigparallel}} %requires stmaryrd
\newcommand{\isasyminterleace}{\isamath{\interleave}} %requires stmaryrd
\newcommand{\isasymsslash}{\isamath{\sslash}} %requires stmaryrd
\newcommand{\isasymbar}{\isamath{\mid}}
\newcommand{\isasymbbar}{\isamath{[\mskip-1.5mu]}}
\newcommand{\isasymplusminus}{\isamath{\pm}}
\newcommand{\isasymminusplus}{\isamath{\mp}}
\newcommand{\isasymtimes}{\isamath{\times}}
\newcommand{\isasymdiv}{\isamath{\div}}
\newcommand{\isasymcdot}{\isamath{\cdot}}
\newcommand{\isasymsqdot}{\isamath{\sbox\z@{$\centerdot$}\ht\z@=.33333\ht\z@\vcenter{\box\z@}}} %requires amssymb
\newcommand{\isasymstar}{\isamath{\star}}
\newcommand{\isasymbullet}{\boldmath\isamath{\mathchoice{\displaystyle{\cdot}}{\textstyle{\cdot}}{\scriptstyle{\bullet}}{\scriptscriptstyle{\bullet}}}}
\newcommand{\isasymcirc}{\isamath{\circ}}
\newcommand{\isasymdagger}{\isamath{\dagger}}
\newcommand{\isasymddagger}{\isamath{\ddagger}}
\newcommand{\isasymlhd}{\isamath{\lhd}} %requires amssymb
\newcommand{\isasymrhd}{\isamath{\rhd}} %requires amssymb
\newcommand{\isasymunlhd}{\isamath{\unlhd}} %requires amssymb
\newcommand{\isasymunrhd}{\isamath{\unrhd}} %requires amssymb
\newcommand{\isasymtriangleleft}{\isamath{\triangleleft}}
\newcommand{\isasymtriangleright}{\isamath{\triangleright}}
\newcommand{\isasymtriangle}{\isamath{\triangle}}
\newcommand{\isasymtriangleq}{\isamath{\triangleq}} %requires amssymb
\newcommand{\isasymoplus}{\isamath{\oplus}}
\newcommand{\isasymOplus}{\isamath{\bigoplus\,}}
\newcommand{\isasymotimes}{\isamath{\otimes}}
\newcommand{\isasymOtimes}{\isamath{\bigotimes\,}}
\newcommand{\isasymodot}{\isamath{\odot}}
\newcommand{\isasymOdot}{\isamath{\bigodot\,}}
\newcommand{\isasymominus}{\isamath{\ominus}}
\newcommand{\isasymoslash}{\isamath{\oslash}}
\newcommand{\isasymdots}{\isamath{\dots}}
\newcommand{\isasymcdots}{\isamath{\cdots}}
\newcommand{\isasymSum}{\isamath{\sum\,}}
\newcommand{\isasymProd}{\isamath{\prod\,}}
\newcommand{\isasymCoprod}{\isamath{\coprod\,}}
\newcommand{\isasyminfinity}{\isamath{\infty}}
\newcommand{\isasymintegral}{\isamath{\int\,}}
\newcommand{\isasymointegral}{\isamath{\oint\,}}
\newcommand{\isasymclubsuit}{\isamath{\clubsuit}}
\newcommand{\isasymdiamondsuit}{\isamath{\diamondsuit}}
\newcommand{\isasymheartsuit}{\isamath{\heartsuit}}
\newcommand{\isasymspadesuit}{\isamath{\spadesuit}}
\newcommand{\isasymaleph}{\isamath{\aleph}}
\newcommand{\isasymemptyset}{\isamath{\emptyset}}
\newcommand{\isasymnabla}{\isamath{\nabla}}
\newcommand{\isasympartial}{\isamath{\partial}}
\newcommand{\isasymRe}{\isamath{\Re}}
\newcommand{\isasymIm}{\isamath{\Im}}
\newcommand{\isasymflat}{\isamath{\flat}}
\newcommand{\isasymnatural}{\isamath{\natural}}
\newcommand{\isasymsharp}{\isamath{\sharp}}
\newcommand{\isasymangle}{\isamath{\angle}}
\newcommand{\isasymcopyright}{\isatext{\normalfont\rmfamily\copyright}}
\newcommand{\isasymregistered}{\isatext{\normalfont\rmfamily\textregistered}}
\newcommand{\isasyminverse}{\isamath{{}^{-1}}}
\newcommand{\isasymonequarter}{\isatext{\normalfont\rmfamily\textonequarter}} %requires textcomp
\newcommand{\isasymonehalf}{\isatext{\normalfont\rmfamily\textonehalf}} %requires textcomp
\newcommand{\isasymthreequarters}{\isatext{\normalfont\rmfamily\textthreequarters}} %requires textcomp
\newcommand{\isasymordfeminine}{\isatext{\normalfont\rmfamily\textordfeminine}}
\newcommand{\isasymordmasculine}{\isatext{\normalfont\rmfamily\textordmasculine}}
\newcommand{\isasymsection}{\isatext{\normalfont\rmfamily\S}}
\newcommand{\isasymparagraph}{\isatext{\normalfont\rmfamily\P}}
\newcommand{\isasymexclamdown}{\isatext{\normalfont\rmfamily\textexclamdown}}
\newcommand{\isasymquestiondown}{\isatext{\normalfont\rmfamily\textquestiondown}}
\newcommand{\isasymeuro}{\isatext{\euro}} %requires eurosym
\newcommand{\isasympounds}{\isamath{\pounds}}
\newcommand{\isasymyen}{\isatext{\yen}} %requires amssymb
\newcommand{\isasymcent}{\isatext{\textcent}} %requires textcomp
\newcommand{\isasymcurrency}{\isatext{\textcurrency}} %requires textcomp
\newcommand{\isasymdegree}{\isatext{\normalfont\rmfamily\textdegree}} %requires textcomp
\newcommand{\isasymhyphen}{\isatext{\normalfont\rmfamily-}}
\newcommand{\isasymamalg}{\isamath{\amalg}}
\newcommand{\isasymmho}{\isamath{\mho}} %requires amssymb
\newcommand{\isasymlozenge}{\isamath{\lozenge}} %requires amssymb
\newcommand{\isasymwp}{\isamath{\wp}}
\newcommand{\isasymwrong}{\isamath{\wr}}
\newcommand{\isasymacute}{\isatext{\'\relax}}
\newcommand{\isasymindex}{\isatext{\i}}
\newcommand{\isasymdieresis}{\isatext{\"\relax}}
\newcommand{\isasymcedilla}{\isatext{\c\relax}}
\newcommand{\isasymhungarumlaut}{\isatext{\H\relax}}
\newcommand{\isasymsome}{\isamath{\epsilon\,}}
\newcommand{\isasymbind}{\isamath{\mathbin{>\!\!\!>\mkern-6.7mu=}}}
\newcommand{\isasymthen}{\isamath{\mathbin{>\!\!\!>}}}
%Z notation
\newcommand{\isaZhbar}[1]{\rlap{\raise.0001ex\hbox{\isamath{-}}}#1}
\newcommand{\isaZpvbar}[1]{\ooalign{\hfil\isamath{\mapstochar\mkern 5mu}\hfil\cr#1}}
\newcommand{\isaZfvbar}[1]{\ooalign{\hfil\isamath{\mapstochar\mkern 3mu\mapstochar\mkern 5mu}\hfil\cr#1}}
\newcommand{\isaZdarrow}[3]{\ooalign{\isamath{#1}\hfil\cr\isamath{\mkern#3mu\isamath{#2}}}}
\newcommand{\isasymZcomp}{\isamath{\fatsemi}} %requires stmaryrd
\newcommand{\isasymZinj}{\isamath{\rightarrowtail}} %requires amssymb
\newcommand{\isasymZpinj}{\isaZpvbar{\isamath{\rightarrowtail}}} %requires amssymb
\newcommand{\isasymZfinj}{\isaZfvbar{\isasymZinj}} %requires amssymb
\newcommand{\isasymZsurj}{\isaZdarrow{\rightarrow}{\rightarrow}{4}} %requires amssymb
\newcommand{\isasymZpsurj}{\isaZpvbar{\isasymZsurj}} %requires amssymb
\newcommand{\isasymZbij}{\isaZdarrow{\rightarrowtail}{\rightarrow}{5}} %requires amssymb
\newcommand{\isasymZpfun}{\isaZpvbar{\isamath{\rightarrow}}}
\newcommand{\isasymZffun}{\isaZfvbar{\isamath{\rightarrow}}}
\newcommand{\isasymZdres}{\isamath{\lhd}} %requires amssymb
\newcommand{\isasymZndres}{\isaZhbar{\isamath{\lhd}}} %requires amssymb
\newcommand{\isasymZrres}{\isamath{\rhd}} %requires amssymb
\newcommand{\isasymZnrres}{\isaZhbar{\isamath{\rhd}}} %requires amssymb
\newcommand{\isasymZspot}{\isamath{\bullet}}
\newcommand{\isasymZproject}{\isamath{\upharpoonright}} %requires amssymb
\newcommand{\isasymZsemi}{\isatext{\raise 0.66ex\hbox{\oalign{\hfil\isamath{\scriptscriptstyle\mathrm{o}}\hfil\cr\hfil\isamath{\scriptscriptstyle\mathrm{9}}\hfil}}}}
\newcommand{\isasymZtypecolon}{\isatext{\raise 0.6ex\hbox{\oalign{\hfil\isamath{\scriptscriptstyle\mathrm{o}}\hfil\cr\hfil\isamath{\scriptscriptstyle\mathrm{o}}\hfil}}}}
\newcommand{\isasymZhide}{\isamath{\backslash}}
\newcommand{\isasymZcat}{\isatext{\raise 0.8ex\hbox{\isamath{\mathchar\frown}}}}
\newcommand{\isasymZinbag}{\isatext{\ooalign{\isamath{\sqsubset\mkern-1mu}\cr\isamath{-\mkern-1mu}\cr}}}
\newcommand{\isasymhole}{\isatext{\normalfont\rmfamily\wasylozenge}} %requires wasysym
\newcommand{\isasymnewline}{\isatext{\fbox{$\hookleftarrow$}}}
\newcommand{\isasymcomment}{\isatext{\isastylecmt---}}
\newcommand{\isasymproof}{\isamath{\,\langle\mathit{proof}\rangle}}
\newcommand{\isasymopen}{\isatext{\guilsinglleft}}
\newcommand{\isasymclose}{\isatext{\guilsinglright}}
\newcommand{\isasymcheckmark}{\isatext{\ding{51}}} %requires pifont
\newcommand{\isasymcrossmark}{\isatext{\ding{55}}} %requires pifont
\newcommand{\isactrlmarker}{\isatext{\ding{48}}} %requires pifont
\newcommand{\isactrltry}{\isakeywordcontrol{try}}
\newcommand{\isactrlcan}{\isakeywordcontrol{can}}
\newcommand{\isactrlassert}{\isakeywordcontrol{assert}}
\newcommand{\isactrlcancel}{\isakeywordcontrol{cancel}}
\newcommand{\isactrlbinding}{\isakeywordcontrol{binding}}
\newcommand{\isactrlclass}{\isakeywordcontrol{class}}
\newcommand{\isactrlclassUNDERSCOREsyntax}{\isakeywordcontrol{class{\isacharunderscore}syntax}}
\newcommand{\isactrlcommandUNDERSCOREkeyword}{\isakeywordcontrol{command{\isacharunderscore}keyword}}
\newcommand{\isactrlconst}{\isakeywordcontrol{const}}
\newcommand{\isactrlconstUNDERSCOREabbrev}{\isakeywordcontrol{const{\isacharunderscore}abbrev}}
\newcommand{\isactrlconstUNDERSCOREname}{\isakeywordcontrol{const{\isacharunderscore}name}}
\newcommand{\isactrlconstUNDERSCOREsyntax}{\isakeywordcontrol{const{\isacharunderscore}syntax}}
\newcommand{\isactrlcontext}{\isakeywordcontrol{context}}
\newcommand{\isactrlcprop}{\isakeywordcontrol{cprop}}
\newcommand{\isactrlcterm}{\isakeywordcontrol{cterm}}
\newcommand{\isactrlctyp}{\isakeywordcontrol{ctyp}}
\newcommand{\isactrldir}{\isakeywordcontrol{dir}}
\newcommand{\isactrlfile}{\isakeywordcontrol{file}}
\newcommand{\isactrlhere}{\isakeywordcontrol{here}}
\newcommand{\isactrlinstantiate}{\isakeywordcontrol{instantiate}}
\newcommand{\isactrlkeyword}{\isakeywordcontrol{keyword}}
\newcommand{\isactrllatex}{\isakeywordcontrol{latex}}
\newcommand{\isactrllocale}{\isakeywordcontrol{locale}}
\newcommand{\isactrlmakeUNDERSCOREjudgment}{\isakeywordcontrol{make{\isacharunderscore}judgment}}
\newcommand{\isactrldestUNDERSCOREjudgment}{\isakeywordcontrol{dest{\isacharunderscore}judgment}}
\newcommand{\isactrlmakeUNDERSCOREstring}{\isakeywordcontrol{make{\isacharunderscore}string}}
\newcommand{\isactrlmasterUNDERSCOREdir}{\isakeywordcontrol{master{\isacharunderscore}dir}}
\newcommand{\isactrlmethod}{\isakeywordcontrol{method}}
\newcommand{\isactrlnamedUNDERSCOREtheorems}{\isakeywordcontrol{named{\isacharunderscore}theorems}}
\newcommand{\isactrlnonterminal}{\isakeywordcontrol{nonterminal}}
\newcommand{\isactrloracleUNDERSCOREname}{\isakeywordcontrol{oracle{\isacharunderscore}name}}
\newcommand{\isactrlpath}{\isakeywordcontrol{path}}
\newcommand{\isactrlpathUNDERSCOREbinding}{\isakeywordcontrol{path{\isacharunderscore}binding}}
\newcommand{\isactrlplugin}{\isakeywordcontrol{plugin}}
\newcommand{\isactrlprint}{\isakeywordcontrol{print}}
\newcommand{\isactrlprop}{\isakeywordcontrol{prop}}
\newcommand{\isactrlscala}{\isakeywordcontrol{scala}}
\newcommand{\isactrlscalaUNDERSCOREfunction}{\isakeywordcontrol{scala{\isacharunderscore}function}}
\newcommand{\isactrlscalaUNDERSCOREmethod}{\isakeywordcontrol{scala{\isacharunderscore}method}}
\newcommand{\isactrlscalaUNDERSCOREobject}{\isakeywordcontrol{scala{\isacharunderscore}object}}
\newcommand{\isactrlscalaUNDERSCOREtype}{\isakeywordcontrol{scala{\isacharunderscore}type}}
\newcommand{\isactrlsimproc}{\isakeywordcontrol{simproc}}
\newcommand{\isactrlsimprocUNDERSCOREsetup}{\isakeywordcontrol{simproc{\isacharunderscore}setup}}
\newcommand{\isactrlsort}{\isakeywordcontrol{sort}}
\newcommand{\isactrlsyntaxUNDERSCOREconst}{\isakeywordcontrol{syntax{\isacharunderscore}const}}
\newcommand{\isactrlsystemUNDERSCOREoption}{\isakeywordcontrol{system{\isacharunderscore}option}}
\newcommand{\isactrlterm}{\isakeywordcontrol{term}}
\newcommand{\isactrltheory}{\isakeywordcontrol{theory}}
\newcommand{\isactrltheoryUNDERSCOREcontext}{\isakeywordcontrol{theory{\isacharunderscore}context}}
\newcommand{\isactrltyp}{\isakeywordcontrol{typ}}
\newcommand{\isactrltypeUNDERSCOREabbrev}{\isakeywordcontrol{type{\isacharunderscore}abbrev}}
\newcommand{\isactrltypeUNDERSCOREname}{\isakeywordcontrol{type{\isacharunderscore}name}}
\newcommand{\isactrltypeUNDERSCOREsyntax}{\isakeywordcontrol{type{\isacharunderscore}syntax}}
\newcommand{\isactrlundefined}{\isakeywordcontrol{undefined}}
\newcommand{\isactrltvar}{\isakeywordcontrol{tvar}}
\newcommand{\isactrlvar}{\isakeywordcontrol{var}}
\newcommand{\isactrlverbatim}{\isakeywordcontrol{verbatim}}
\newcommand{\isactrlConst}{\isakeywordcontrol{Const}}
\newcommand{\isactrlConstUNDERSCORE}{\isakeywordcontrol{Const{\isacharunderscore}}}
\newcommand{\isactrlConstUNDERSCOREfn}{\isakeywordcontrol{Const{\isacharunderscore}fn}}
\newcommand{\isactrlType}{\isakeywordcontrol{Type}}
\newcommand{\isactrlTypeUNDERSCOREfn}{\isakeywordcontrol{Type{\isacharunderscore}fn}}
\newcommand{\isactrlcode}{\isakeywordcontrol{code}}
\newcommand{\isactrlcomputation}{\isakeywordcontrol{computation}}
\newcommand{\isactrlcomputationUNDERSCOREconv}{\isakeywordcontrol{computation{\isacharunderscore}conv}}
\newcommand{\isactrlcomputationUNDERSCOREcheck}{\isakeywordcontrol{computation{\isacharunderscore}check}}
\newcommand{\isactrlifUNDERSCORElinux}{\isakeywordcontrol{if{\isacharunderscore}linux}}
\newcommand{\isactrlifUNDERSCOREmacos}{\isakeywordcontrol{if{\isacharunderscore}macos}}
\newcommand{\isactrlifUNDERSCOREwindows}{\isakeywordcontrol{if{\isacharunderscore}windows}}
\newcommand{\isactrlifUNDERSCOREunix}{\isakeywordcontrol{if{\isacharunderscore}unix}}
\newcommand{\isactrlifUNDERSCOREnone}{\isakeywordcontrol{if{\isacharunderscore}none}}
\newcommand{\isactrlcite}{\isakeywordcontrol{cite}}
\newcommand{\isactrlnocite}{\isakeywordcontrol{nocite}}
\newcommand{\isactrlcitet}{\isakeywordcontrol{citet}}
\newcommand{\isactrlcitep}{\isakeywordcontrol{citep}}
\endinput
%:%file=~~/lib/texinputs/isabellesym.sty%:%

View File

@ -0,0 +1,20 @@
%plain TeX version of comment package -- much faster!
\let\isafmtname\fmtname\def\fmtname{plain}
\usepackage{comment}
\let\fmtname\isafmtname
\newcommand{\isakeeptag}[1]%
{\includecomment{isadelim#1}\includecomment{isatag#1}\csarg\def{isafold#1}{}}
\newcommand{\isadroptag}[1]%
{\excludecomment{isadelim#1}\excludecomment{isatag#1}\csarg\def{isafold#1}{}}
\newcommand{\isafoldtag}[1]%
{\includecomment{isadelim#1}\excludecomment{isatag#1}\csarg\def{isafold#1}{\isafold{#1}}}
\isakeeptag{ML}
\isakeeptag{document}
\isakeeptag{important}
\isadroptag{invisible}
\isakeeptag{proof}
\isakeeptag{theory}
\isakeeptag{unimportant}
\isakeeptag{visible}

View File

@ -0,0 +1,9 @@
%%
%% default hyperref setup (both for pdf and dvi output)
%%
\usepackage{color}
\definecolor{linkcolor}{rgb}{0,0,0.5}
\usepackage[colorlinks=true,linkcolor=linkcolor,citecolor=linkcolor,filecolor=linkcolor,urlcolor=linkcolor,pdfpagelabels]{hyperref}
\endinput
%:%file=~~/lib/texinputs/pdfsetup.sty%:%

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,62 @@
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{isabelle,isabellesym}
% further packages required for unusual symbols (see also
% isabellesym.sty), use only when needed
%\usepackage{amssymb}
%for \<leadsto>, \<box>, \<diamond>, \<sqsupset>, \<mho>, \<Join>,
%\<lhd>, \<lesssim>, \<greatersim>, \<lessapprox>, \<greaterapprox>,
%\<triangleq>, \<yen>, \<lozenge>
%\usepackage{eurosym}
%for \<euro>
%\usepackage[only,bigsqcap,bigparallel,fatsemi,interleave,sslash]{stmaryrd}
%for \<Sqinter>, \<Parallel>, \<Zsemi>, \<Parallel>, \<sslash>
%\usepackage{eufrak}
%for \<AA> ... \<ZZ>, \<aa> ... \<zz> (also included in amssymb)
%\usepackage{textcomp}
%for \<onequarter>, \<onehalf>, \<threequarters>, \<degree>, \<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}
% for uniform font size
%\renewcommand{\isastyle}{\isastyleminor}
\begin{document}
\title{Probability}
\author{user}
\maketitle
\tableofcontents
% sane default for proof documents
\parindent 0pt\parskip 0.5ex
% generated text of all theories
\input{session}
% optional bibliography
%\bibliographystyle{abbrv}
%\bibliography{root}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
\endinput
%:%file=~/work/IsabelleClub/Probability/document/root.tex%:%

View File

@ -0,0 +1 @@
\input{Outline.tex}

Binary file not shown.

2
ROOTS
View File

@ -1 +1,3 @@
VerifyThis2024
Probability
Lifting

View File

@ -0,0 +1,48 @@
theory Example_Sep
imports "Separation_Algebra.Separation_Algebra" "Optics.Optics"
begin
typedef 'a idem_scene = \<open>{F :: 'a scene. idem_scene F}\<close>
using top_idem_scene by blast
instantiation set :: (type) sep_algebra
begin
definition \<open>sep_disj_set \<equiv> \<lambda>a b. a \<inter> b = {}\<close>
definition \<open>plus_set \<equiv> (\<union>)\<close>
definition \<open>zero_set \<equiv> {}\<close>
instance by(intro_classes, simp_all add: sep_disj_set_def plus_set_def zero_set_def) blast+
end
instantiation scene :: (type) pre_sep_algebra
begin
definition \<open>sep_disj_scene \<equiv> (\<bowtie>\<^sub>S)\<close>
definition \<open>plus_scene \<equiv> (\<squnion>\<^sub>S)\<close>
definition \<open>zero_scene = \<bottom>\<^sub>S\<close>
instance
apply(intro_classes, simp_all add: sep_disj_scene_def plus_scene_def zero_scene_def)
using scene_indep_sym apply blast
using scene_union_commute apply blast
apply (simp add: scene_union_assoc)
done
end
lemma
assumes \<open>idem_scene x\<close> \<open>idem_scene y\<close> \<open>idem_scene z\<close> \<open>x \<bowtie>\<^sub>S y \<squnion>\<^sub>S z\<close> \<open>y \<bowtie>\<^sub>S z\<close>
shows \<open>x \<bowtie>\<^sub>S z\<close>
by (metis (full_types) assms(1,2,3,4,5) idem_scene_union indep_then_compl_in scene_indep_sym scene_le_iff_indep_inv scene_union_commute
scene_union_ub subscene_antisym subscene_refl subscene_trans)
instantiation lens_ext :: (type, type, type) pre_sep_algebra
begin
definition \<open>sep_disj_lens_ext \<equiv> (\<bowtie>)\<close>
end
end

View File

@ -0,0 +1,49 @@
theory Example_Sep
imports "Separation_Algebra.Separation_Algebra" "Optics.Optics"
begin
typedef 'a wf_scene = \<open>{F :: 'a scene. idem_scene F}\<close>
using top_idem_scene by blast
instantiation set :: (type) sep_algebra
begin
definition \<open>sep_disj_set \<equiv> \<lambda>a b. a \<inter> b = {}\<close>
definition \<open>plus_set \<equiv> (\<union>)\<close>
definition \<open>zero_set \<equiv> {}\<close>
instance by(intro_classes, simp_all add: sep_disj_set_def plus_set_def zero_set_def) blast+
end
instantiation scene :: (type) pre_sep_algebra
begin
definition \<open>sep_disj_scene \<equiv> (\<bowtie>\<^sub>S)\<close>
definition \<open>plus_scene \<equiv> (\<squnion>\<^sub>S)\<close>
definition \<open>zero_scene = \<bottom>\<^sub>S\<close>
instance
apply(intro_classes, simp_all add: sep_disj_scene_def plus_scene_def zero_scene_def)
using scene_indep_sym apply blast
using scene_union_commute apply blast
apply (simp add: scene_union_assoc)
done
end
lemma
assumes \<open>idem_scene x\<close> \<open>idem_scene y\<close> \<open>idem_scene z\<close> \<open>x \<bowtie>\<^sub>S y \<squnion>\<^sub>S z\<close> \<open>y \<bowtie>\<^sub>S z\<close>
shows \<open>x \<bowtie>\<^sub>S z\<close>
by (metis (full_types) assms(1,2,3,4,5) idem_scene_union indep_then_compl_in scene_indep_sym scene_le_iff_indep_inv scene_union_commute
scene_union_ub subscene_antisym subscene_refl subscene_trans)
instantiation lens_ext :: (type, type, type) pre_sep_algebra
begin
definition \<open>sep_disj_lens_ext \<equiv> (\<bowtie>)\<close>
end
end

View File

@ -64,4 +64,5 @@ next
qed
qed
end

View File

@ -0,0 +1,67 @@
theory Fibonacci
imports Main HOL.NthRoot
begin
fun fib :: \<open>nat \<Rightarrow> nat\<close> where
\<open>fib 0 = 0\<close>|
\<open>fib (Suc 0) = Suc 0\<close>|
\<open>fib (Suc (Suc n)) = fib (Suc n) + fib n\<close>
definition \<open>\<phi> = (1 + sqrt 5)/2\<close>
definition \<open>\<psi> = (1 - sqrt 5)/2\<close>
definition fib_intvl :: \<open>nat \<Rightarrow> nat set\<close> where
\<open>fib_intvl n = {fib n..<fib (Suc n)}\<close>
definition fib_intvl_seq :: \<open>nat \<Rightarrow> (nat set) list\<close> where
\<open>fib_intvl_seq n = map (fib_intvl o nat) [2..int n]\<close>
lemma \<phi>_pow_2: \<open>\<phi>^2 = (1 + \<phi>)\<close> unfolding \<phi>_def
proof-
have *: \<open>(1+sqrt 5)\<^sup>2 = (1 + 2*sqrt 5 + 5)\<close> using power2_sum[of \<open>1\<close> \<open>sqrt 5\<close>] by auto
have \<open>((1 + sqrt 5) / 2)\<^sup>2 = (1+sqrt 5)\<^sup>2 / 4\<close>
by (simp add: power_divide)
hence \<open>... = (1 + 2*sqrt 5 + 5) / 4\<close> using * by auto
hence \<open>... = 2*(1 + sqrt 5)/4 + 1\<close> by simp
thus \<open>((1 + sqrt 5) / 2)\<^sup>2= 1 + (1 + sqrt 5) / 2\<close>
by (smt (z3) "*" field_sum_of_halves four_x_squared)
qed
lemma \<psi>_pow_2: \<open>\<psi>^2 = (1 + \<psi>)\<close>
proof-
have *: \<open>(1-sqrt 5)\<^sup>2 = (1 - 2*sqrt 5 + 5)\<close> using power2_diff[of \<open>1\<close> \<open>sqrt 5\<close>] by auto
hence \<open>(1-sqrt 5)\<^sup>2/4 = (1 - 2*sqrt 5 + 5)/4\<close> by auto
hence \<open>... = 2*(1 - sqrt 5)/4 + 1\<close> by simp
thus ?thesis
by (smt (z3) "*" \<psi>_def field_sum_of_halves four_x_squared)
qed
lemmas golden_ratios = \<phi>_def \<psi>_def
lemma golden_diff: \<open>(\<phi> - \<psi>) = sqrt 5\<close> unfolding golden_ratios
by (smt (z3) field_sum_of_halves)
lemma fib_correct: \<open>fib n = (\<phi>^n - \<psi>^n) / sqrt 5\<close>
proof(induction n rule: fib.induct)
case 1
then show ?case by simp
next
case 2
then show ?case
by (simp add: golden_diff)
next
case (3 n)
then show ?case
proof-
have \<open>real (fib (Suc (Suc n))) = real (fib (Suc n)) + real (fib n)\<close> by auto
moreover have \<open>... = (\<phi> ^ Suc n - \<psi> ^ Suc n) / sqrt 5 + (\<phi> ^ n - \<psi> ^ n) / sqrt 5\<close> using 3 by auto
moreover have \<open>... = (\<phi> ^ Suc n + \<phi>^n - \<psi> ^ Suc n - \<psi> ^ n)/sqrt 5\<close>
by (smt (verit, best) add_divide_distrib)
moreover have \<open>... = (\<phi> ^ n * (\<phi> + 1) - \<psi> ^ n * (\<psi> + 1))/ sqrt 5\<close>
by (simp add: distrib_right mult.commute)
ultimately show ?case using \<psi>_pow_2 \<phi>_pow_2
by (metis add.commute add_2_eq_Suc power_add)
qed
qed
end

View File

@ -29,14 +29,123 @@ Basic ropes require the implementation of efficient length calculation,
inefficient "naive" concatenation and finally splitting a rope into two across an index.
\<close>
fun str_len :: \<open>Rope \<Rightarrow> nat\<close> where
\<open>str_len (Leaf _ w) = w\<close> |
\<open>str_len (Node _ w r) = w + str_len r\<close>
lemma str_len_sum_weights: assumes \<open>valid_rope x\<close> shows \<open>str_len x = sum_weights x\<close>
using assms by (induction x, auto)
lemma str_len_correct:
assumes \<open>valid_rope r\<close>
shows \<open>str_len r = size (to_str r)\<close>
using assms proof(induction r)
case (Leaf x1 x2)
then show ?case by simp
next
case (Node r1 x2 r2)
hence \<open>valid_rope r1\<close> and \<open>valid_rope r2\<close> and \<open>x2 = sum_weights r1\<close> by simp+
have \<open>size(to_str (Node r1 x2 r2)) = size (to_str r1 + to_str r2)\<close> by simp
hence \<open>... = size(to_str r1) + size(to_str r2)\<close> by (simp add: literal_plus_size_eq)
hence \<open>... = str_len r1 + str_len r2\<close> using Node by simp
also have \<open>str_len r1 = sum_weights r1\<close>
using \<open>valid_rope r1\<close> proof(induction r1)
case (Leaf x1 x2)
then show ?case by simp
next
case (Node r11 x2 r12)
then show ?case by simp
qed
finally show ?case
by (simp add: \<open>size (to_str r1 + to_str r2) = size (to_str r1) + size (to_str r2)\<close> \<open>x2 = sum_weights r1\<close>)
qed
definition rope_concat :: \<open>Rope \<Rightarrow> Rope \<Rightarrow> Rope\<close> where
\<open>rope_concat l r = Node l (str_len l) r\<close>
lemma rope_concat_correct: \<open>\<lbrakk>valid_rope l; valid_rope r\<rbrakk> \<Longrightarrow> to_str (rope_concat l r) = to_str l + to_str r \<and> valid_rope (rope_concat l r)\<close>
by (simp add: rope_concat_def str_len_sum_weights)
lemma rope_concat_valid: \<open>\<lbrakk>valid_rope l; valid_rope r\<rbrakk> \<Longrightarrow> valid_rope (rope_concat l r)\<close> by (simp add: rope_concat_correct)
fun split :: \<open>Rope \<Rightarrow> nat \<Rightarrow> Rope \<times> Rope\<close> where
\<open>split (Leaf s w) i = (mk_leaf (sub_str s {0..<i}), mk_leaf (sub_str s {i..size s}))\<close>|
\<open>split (Node l w r) i = (if i < w then
(let (left, right) = split l i
in (left, rope_concat right r))
else
(if i > w then
(let (left,right) = split r (i - w)
in (rope_concat l left, right))
else (l,r)))\<close>
lemma
assumes \<open>valid_rope r\<close>
shows \<open>valid_rope (fst (split r i)) \<and> valid_rope (snd (split r i))\<close>
using assms proof(induction r arbitrary: i)
case (Leaf x1 x2)
then show ?case by simp
next
case (Node l w r)
hence valid_left: \<open>valid_rope l\<close> and valid_right: \<open>valid_rope r\<close> by simp+
show ?case (is \<open>?p \<and> ?q\<close>)
proof
obtain left right where split_def: \<open>split l i = (left,right)\<close>
using old.prod.exhaust by blast
obtain left' right' where split_def': \<open>split r (i - w) = (left',right')\<close>
using old.prod.exhaust by blast
show ?q
proof(cases \<open>i < w\<close>)
case True
moreover have \<open>valid_rope (fst (split l i)) \<and> valid_rope (snd (split l i))\<close> using valid_left Node by auto
ultimately show ?thesis apply (simp add: split_def)
apply(intro rope_concat_valid, simp)
using valid_right by blast
next
case False note * = this
then show ?thesis
proof(cases \<open>i = w\<close>)
case True
then show ?thesis using Node by simp
next
case False
hence \<open>i > w\<close> using * by auto
moreover have \<open>valid_rope (fst (split r (i - w))) \<and> valid_rope (snd (split r (i-w)))\<close> using valid_right Node by auto
ultimately show ?thesis using split_def' by simp
qed
qed
show ?p
proof(cases \<open>i < w\<close>)
case True
moreover have \<open>valid_rope (fst (split l i)) \<and> valid_rope (snd (split l i))\<close> using valid_left Node by auto
ultimately show ?thesis by (simp add: split_def)
next
case False note * = this
then show ?thesis
proof(cases \<open>i = w\<close>)
case True
then show ?thesis using Node by simp
next
case False
hence \<open>i > w\<close> using * by auto
moreover have \<open>valid_rope (fst (split r (i - w))) \<and> valid_rope (snd (split r (i-w)))\<close> using valid_right Node by auto
ultimately show ?thesis using split_def'
using Node.prems rope_concat_def str_len_sum_weights by fastforce
qed
qed
qed
qed
locale Basic_Ropes =
fixes str_len :: \<open>Rope \<Rightarrow> nat\<close>
and rope_concat :: \<open>Rope \<Rightarrow> Rope \<Rightarrow> Rope\<close>
and rope_split :: \<open>Rope \<Rightarrow> nat \<Rightarrow> Rope \<times> Rope\<close>
assumes \<open>\<And>r. valid_rope r \<Longrightarrow> str_len r = size (to_str r)\<close>
\<open>\<And>l r. \<lbrakk>valid_rope l; valid_rope r\<rbrakk> \<Longrightarrow> to_str (rope_concat l r) = to_str l + to_str r\<close>
\<open>\<And>l r. \<lbrakk>valid_rope l; valid_rope r\<rbrakk> \<Longrightarrow> to_str (rope_concat l r) = to_str l + to_str r \<and> valid_rope (rope_concat l r)\<close>
\<open>\<And>i r. valid_rope r \<Longrightarrow> valid_rope (fst (rope_split r i)) \<and> valid_rope (snd (rope_split r i))\<close>
subsection\<open>Intermediate Ropes\<close>
text\<open>Intermediate Ropes require the implementation of "efficient" concatenation as similar to Boehm's \<^url>\<open>https://www.cs.tufts.edu/comp/150FP/archive/hans-boehm/ropes.pdf\<close>.

View File

@ -0,0 +1,125 @@
theory Ropes_Template
imports Utils
begin
chapter\<open>Challenge 0 from VerifyThis 2024: \<^url>\<open>https://www.pm.inf.ethz.ch/research/verifythis.html\<close>\<close>
section\<open>The Rope Data Structure\<close>
text\<open>The task is to implement a "Rope" ( \<^url>\<open>https://en.wikipedia.org/wiki/Rope_(data_structure)\<close> )
originally published by Boehm - \<^url>\<open>https://www.cs.tufts.edu/comp/150FP/archive/hans-boehm/ropes.pdf\<close>
- a special type of binary tree to efficiently store strings (in honor of Billy who can't be here today).\<close>
text\<open>Since the first half of this challenge is quite easy in HOL (termination and non crashing of basic functions),
we will skip the "trivial components" that can be found in \<^file>\<open>Utils.thy\<close>\<close>
section\<open>Tasks\<close>
text\<open>The following are my play on ADTs using locales. We have three tiers:
\<bullet> Basic
\<bullet> Intermediate
\<bullet> Advanced
\<close>
subsection\<open>Basic Ropes\<close>
text\<open>
Basic ropes require the implementation of efficient length calculation,
inefficient "naive" concatenation and finally splitting a rope into two across an index.
\<close>
fun str_len :: \<open>Rope \<Rightarrow> nat\<close> where
\<open>str_len (Leaf _ w) = w\<close> |
\<open>str_len (Node _ w r) = w + str_len r\<close>
lemma str_len_sum_weights: assumes \<open>valid_rope x\<close> shows \<open>str_len x = sum_weights x\<close>
using assms by (induction x, auto)
lemma str_len_correct:
assumes \<open>valid_rope r\<close>
shows \<open>str_len r = size (to_str r)\<close>
using assms proof(induction r)
case (Leaf x1 x2)
then show ?case by simp
next
case (Node r1 x2 r2)
hence \<open>valid_rope r1\<close> and \<open>valid_rope r2\<close> and \<open>x2 = sum_weights r1\<close> by simp+
have \<open>size(to_str (Node r1 x2 r2)) = size (to_str r1 + to_str r2)\<close> by simp
hence \<open>... = size(to_str r1) + size(to_str r2)\<close> by (simp add: literal_plus_size_eq)
hence \<open>... = str_len r1 + str_len r2\<close> using Node by simp
also have \<open>str_len r1 = sum_weights r1\<close>
using \<open>valid_rope r1\<close> proof(induction r1)
case (Leaf x1 x2)
then show ?case by simp
next
case (Node r11 x2 r12)
then show ?case by simp
qed
finally show ?case
by (simp add: \<open>size (to_str r1 + to_str r2) = size (to_str r1) + size (to_str r2)\<close> \<open>x2 = sum_weights r1\<close>)
qed
definition rope_concat :: \<open>Rope \<Rightarrow> Rope \<Rightarrow> Rope\<close> where
\<open>rope_concat l r = Node l (str_len l) r\<close>
lemma \<open>\<lbrakk>valid_rope l; valid_rope r\<rbrakk> \<Longrightarrow> to_str (rope_concat l r) = to_str l + to_str r \<and> valid_rope (rope_concat l r)\<close>
by (simp add: rope_concat_def str_len_sum_weights)
fun split :: \<open>Rope \<Rightarrow> nat \<Rightarrow> Rope \<times> Rope\<close> where
\<open>split (Leaf s w) i = (mk_leaf (sub_str s {0..<i}), mk_leaf (sub_str s {i..size s}))\<close>|
\<open>split (Node l w r) i = (if i < w then
(let (left, right) = split l i
in (left, rope_concat right r))
else
(if i > w then
(let (left,right) = split r (i - w)
in (rope_concat l left, right))
else (l,r)))\<close>
locale Basic_Ropes =
fixes str_len :: \<open>Rope \<Rightarrow> nat\<close>
and rope_concat :: \<open>Rope \<Rightarrow> Rope \<Rightarrow> Rope\<close>
and rope_split :: \<open>Rope \<Rightarrow> nat \<Rightarrow> Rope \<times> Rope\<close>
assumes \<open>\<And>r. valid_rope r \<Longrightarrow> str_len r = size (to_str r)\<close>
\<open>\<And>l r. \<lbrakk>valid_rope l; valid_rope r\<rbrakk> \<Longrightarrow> to_str (rope_concat l r) = to_str l + to_str r \<and> valid_rope (rope_concat l r)\<close>
\<open>\<And>i r. valid_rope r \<Longrightarrow> valid_rope (fst (rope_split r i)) \<and> valid_rope (snd (rope_split r i))\<close>
subsection\<open>Intermediate Ropes\<close>
text\<open>Intermediate Ropes require the implementation of "efficient" concatenation as similar to Boehm's \<^url>\<open>https://www.cs.tufts.edu/comp/150FP/archive/hans-boehm/ropes.pdf\<close>.
and a naive implementation of delete, sub string and insert. Naive in the sense that deleting then inserting the same string is not structure preserving.
However inserting then deleting the same string should be structure preserving.
\<close>
locale Intermediate_Ropes = Basic_Ropes +
fixes boehm_concat :: \<open>Rope \<Rightarrow> Rope \<Rightarrow> Rope\<close>
and rope_delete :: \<open>Rope \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> Rope\<close>
and rope_sub_str :: \<open>Rope \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> Rope\<close>
and rope_insert :: \<open>Rope \<Rightarrow> nat \<Rightarrow> String.literal \<Rightarrow> Rope\<close>
assumes \<open>\<And>l r. \<lbrakk>valid_rope l; valid_rope r\<rbrakk> \<Longrightarrow> to_str (boehm_concat l r) = to_str l + to_str r\<close>
\<open>\<And>l r. \<lbrakk>valid_rope l; valid_rope r\<rbrakk> \<Longrightarrow> size (boehm_concat l r) \<le> size (rope_concat l r)\<close>
\<open>\<And>r i str. valid_rope r \<Longrightarrow> rope_delete (rope_insert r i str) i (size str) = r\<close>
\<open>\<And>r i len. valid_rope r \<Longrightarrow> to_str (rope_insert (rope_delete r i len) i (to_str (rope_sub_str r i len))) = to_str r\<close>
subsection\<open>Advanced Ropes\<close>
text\<open>Advanced Ropes are really what makes them useful data structures.
Before, all rope functions have been functionally correct, but not efficient due to the lack of rebalancing.
These require the implementation of a rebalance function to balance a Rope, and a function mk_rope which constructs a non-trivially balanced Rope from a string.
Using this rebalance function, implement efficient an efficient insert and delete which preserves the balancing of the tree\<close>
locale Advanced_Ropes = Intermediate_Ropes +
fixes max_leaf_size :: \<open>nat\<close>
and rebalance :: \<open>Rope \<Rightarrow> Rope\<close>
and mk_Rope :: \<open>String.literal \<Rightarrow> Rope\<close>
and efficient_delete :: \<open>Rope \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> Rope\<close>
and efficient_insert :: \<open>Rope \<Rightarrow> nat \<Rightarrow> String.literal \<Rightarrow> Rope\<close>
assumes \<open>\<And>r. \<not> is_balanced r \<and> valid_rope r \<Longrightarrow> is_balanced (rebalance r)\<close>
\<open>\<And>s. is_balanced (mk_Rope s)\<close>
\<open>\<And>r i str. is_balanced r \<Longrightarrow> is_balanced (rope_insert r i str) \<and> (\<forall>leaf \<in># all_leaves (rope_insert r i str). str_len leaf \<in> {0<..max_leaf_size})\<close>
\<open>\<And>r i len. is_balanced r \<Longrightarrow> is_balanced (efficient_delete r i len)\<close>
end

View File

@ -58,7 +58,7 @@ fun mk_leaf :: \<open>String.literal \<Rightarrow> Rope\<close> where
\<open>mk_leaf s = Leaf s (size s)\<close>
fun sum_weights :: \<open>Rope \<Rightarrow> nat\<close> where
\<open>sum_weights (Leaf _ s) = s\<close>|
\<open>sum_weights (Leaf _ w) = w\<close>|
\<open>sum_weights (Node l w r) = sum_weights l + sum_weights r\<close>
fun valid_rope :: \<open>Rope \<Rightarrow> bool\<close> where

89
VerifyThis2024/Utils.thy~ Normal file
View File

@ -0,0 +1,89 @@
theory Utils
imports Main Fibonacci "HOL-Library.Multiset" "List-Index.List_Index"
begin
chapter\<open>Helper Lemmas, Functions and Definitions\<close>
section\<open>String Literal helper lemmas for Rope proofs\<close>
lemma literal_plus_size_eq: \<open>size ((l::String.literal) + r) = size l + size r\<close>
by (simp add: plus_literal.rep_eq size_literal.rep_eq)
fun sub_str :: \<open>String.literal \<Rightarrow> nat set \<Rightarrow> String.literal\<close> where
\<open>sub_str s I = String.implode (nths (literal.explode s) I)\<close>
lemma explode_sub_str: \<open>literal.explode (sub_str s I) = nths (literal.explode s) I\<close>
by (metis String.implode_explode_eq implode.rep_eq nths_map sub_str.simps)
lemma size_implode_single: \<open>size (String.implode [x]) = Suc 0\<close> by (simp add: size_literal.rep_eq)
lemma size_implode: \<open>size (String.implode xs) = length xs\<close>
proof(induction xs)
case Nil
then show ?case
by (simp add: size_literal.rep_eq)
next
case (Cons a xs)
have \<open>size (String.implode (a # xs)) = (size (String.implode [a] + String.implode xs))\<close>
apply (simp add: String.implode_def)
by (metis String.explode_implode_eq add_0 add_Suc implode.abs_eq length_Cons list.simps(8,9)
list.size(3) literal_plus_size_eq size_literal.rep_eq)
moreover have \<open>... = Suc (size (String.implode xs))\<close> by (simp add: literal_plus_size_eq size_implode_single)
moreover have \<open>... = Suc (length xs)\<close> using Cons by blast
ultimately show ?case by simp
qed
lemma size_sub_str: \<open>size (sub_str s I) = card {i. i < size s \<and> i \<in> I}\<close>
by(simp add: size_implode length_nths size_literal.rep_eq)
lemma atLeastLessThan_eq: \<open>{i..<size s} = {ia. ia < size s \<and> i \<le> ia}\<close> by auto
lemma atLeastAtMost_eq: \<open>(if i < size s then {..i} else {..<size s}) = {ia. ia < size s \<and> ia \<le> i}\<close> by auto
lemma size_sub_str_atLeast: \<open>size (sub_str s {i..}) = size s - i\<close> unfolding size_sub_str[of s \<open>{i..}\<close>]
by (simp add: atLeastLessThan_eq[symmetric])
lemma size_sub_str_atMost: \<open>size (sub_str s {..i}) = (if i < size s then Suc i else size s)\<close> unfolding size_sub_str[of s \<open>{..i}\<close>]
by (simp add: atLeastAtMost_eq[symmetric])
section\<open>Rope Definitions\<close>
subsection\<open>Basics\<close>
datatype Rope = Leaf String.literal nat | Node Rope nat Rope
definition \<open>hello_world_rope \<equiv> Node (Leaf (STR ''Hello '') 6) 6 (Leaf (STR ''World'') 5)\<close>
fun mk_leaf :: \<open>String.literal \<Rightarrow> Rope\<close> where
\<open>mk_leaf s = Leaf s (size s)\<close>
fun sum_weights :: \<open>Rope \<Rightarrow> nat\<close> where
\<open>sum_weights (Leaf _ s) = s\<close>|
\<open>sum_weights (Node l w r) = sum_weights l + sum_weights r\<close>
fun valid_rope :: \<open>Rope \<Rightarrow> bool\<close> where
\<open>valid_rope (Leaf s w) = (size s = w)\<close>|
\<open>valid_rope (Node l w r) = (valid_rope l \<and> valid_rope r \<and> (w = sum_weights l))\<close>
fun to_str :: \<open>Rope \<Rightarrow> String.literal\<close> where
\<open>to_str (Leaf s _) = s\<close>|
\<open>to_str (Node l _ r) = to_str l + to_str r\<close>
fun all_leaves :: \<open>Rope \<Rightarrow> Rope multiset\<close> where
\<open>all_leaves (Leaf s w) = {# Leaf s w #}\<close>|
\<open>all_leaves (Node l _ r) = all_leaves l \<union># all_leaves r\<close>
subsection\<open>Advanced\<close>
text\<open>The following formalises the definition of balanced from Boehm \<^url>\<open>https://www.cs.tufts.edu/comp/150FP/archive/hans-boehm/ropes.pdf\<close>\<close>
definition rope_width :: \<open>Rope \<Rightarrow> nat\<close> where
\<open>rope_width r = size (all_leaves r)\<close>
definition is_balanced :: \<open>Rope \<Rightarrow> bool\<close> where
\<open>is_balanced r = (fib (size r + 2) \<le> sum_weights r)\<close>
value \<open>is_balanced hello_world_rope\<close>
value \<open>fib 5\<close>
end