summaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorstuebinm2024-06-29 21:31:22 +0200
committerstuebinm2024-06-29 22:11:04 +0200
commit59214186b817329342d9d72e23adf12f7a3b1348 (patch)
tree8292abe4ca52e9742f6a4ff9d102565a6362e665 /backends
parent5590dc87a5426cbcb32a2387701d179e107a9792 (diff)
had some fun writing an IsabelleHOL backend
(do not actually use this, most things are broken, and the primitives lib barely exists and is simply incorrect. But it is enough to create syntax-correct Isabelle code for relatively simply rust code, as long as it does not contain any uses of traits)
Diffstat (limited to 'backends')
-rw-r--r--backends/IsabelleHOL/Primitives.thy19
-rw-r--r--backends/IsabelleHOL/ROOT6
-rw-r--r--backends/IsabelleHOL/document/root.tex60
3 files changed, 85 insertions, 0 deletions
diff --git a/backends/IsabelleHOL/Primitives.thy b/backends/IsabelleHOL/Primitives.thy
new file mode 100644
index 00000000..a0cc40bd
--- /dev/null
+++ b/backends/IsabelleHOL/Primitives.thy
@@ -0,0 +1,19 @@
+theory Primitives imports
+ Main
+ "HOL-Library.Monad_Syntax"
+begin
+
+
+datatype u32 = u32 nat
+datatype 'a result = Ok 'a | Err
+fun u32_lt :: "u32 \<Rightarrow> u32 \<Rightarrow> bool" where
+ "u32_lt (u32 a) (u32 b) = (a < b)"
+
+definition bind :: "'a result \<Rightarrow> ('a \<Rightarrow> 'b result) \<Rightarrow> 'b result" where
+ "bind m f \<equiv> (case m of Err \<Rightarrow> Err | Ok a \<Rightarrow> f a)"
+
+adhoc_overloading Monad_Syntax.bind bind
+
+declare bind_def[simp]
+
+end \ No newline at end of file
diff --git a/backends/IsabelleHOL/ROOT b/backends/IsabelleHOL/ROOT
new file mode 100644
index 00000000..9f8e0820
--- /dev/null
+++ b/backends/IsabelleHOL/ROOT
@@ -0,0 +1,6 @@
+session Aeneas = "HOL-Library" +
+ options [document = pdf, document_output = "output"]
+ theories [document = false]
+ Primitives
+ document_files
+ "root.tex"
diff --git a/backends/IsabelleHOL/document/root.tex b/backends/IsabelleHOL/document/root.tex
new file mode 100644
index 00000000..63ac8e42
--- /dev/null
+++ b/backends/IsabelleHOL/document/root.tex
@@ -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{IsabelleHOL}
+\author{stuebinm}
+\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: