I have seen some papers that describe how to use the Z notation with Isabelle/HOL using the tools HOL-Z and ZETA. I was not able to find these tools, have they ever been published? Are there other ways to use Isabelle with the Z notation?
If you are prepared to substitute Isabelle/HOL for one of the HOL theorem provers (which also adopt the LCF approach to soundness) then you should consider ProofPower, which also embeds the Z notation in HOL. ProofPower-Z has been used on large industrial examples for many years, in particular to discharge verification conditions to show the correctness of Ada source code.
Related
I’ve completed the better part of a major development in Isabelle, and is wondering how best to go about writing the corresponding academic paper.
From Isabelle sources I can generate a somewhat idiosyncratic take on such a paper. However, the default rendering of theorems, lemmas and definitions seems almost certain to alienate reviewers.
The LaTeX-sugar theories help, but apparently only if I manually restate the entire theory using anti-quotations.
Are there examples of Isabelle developments underpinning publications that I can look to for inspiration on how best to proceed here?
I have done that in the past (for my master's thesis), there is only one case where you should do that: the documentation of Isabelle and the documentation of Isabelle developments (like the AFP).
There are some people who do that (Makarius Wenzel, e.g., https://sketis.net/2019/11), similarly the "Concrete Semantics". However, this is not a great solution.
The reasons not to do that:
The compilation takes much longer than using pdflatex, even if you base your work on an image of your development.
Unless you type LaTeX macros directly, you are much more limited in what you can do (LaTeX wise). And if you do type latex macros directly, you cannot produce HMTL output anymore. So the gain of Isabelle is limited.
Many conferences want to see LaTeX sources and they don't run Isabelle, so you will have to generate LaTeX at some point anyhow (and even possibly do some post-productions effects because Isabelle is not able to do some things).
You rarely want to use the exact theorem of Isabelle (LaTeXsugar can help, but it is not perfect).
What if you write the paper now and discover a typo you want to fix in 5 years? In 5 years, latex will still work. Isabelle2020 probably not.
Do all your co-authors use Isabelle on all their computers, including your laptop if you are on vacation and have an emergency fix to do?
And you will fight Isabelle a lot, for example:
text "
\begin{counterexample}
"
lemma True
by auto
text "
\end{counterexample}
"
does not work, because text is its own environment, so you need post-production effects.
Basically, use the snippets mechanism to extract LaTeX out of the theories and then use your favorite LaTeX editor.
I'm currently working on a Calculator app and I want output to be in both a simplified expression and decimal answer form. An example would be sqrt 2 * sqrt 3 = sqrt 6 which can also be outputted as 2.44948... What is the best approach to this and is there any well-established algorithms to do this?
Yes. What you likely want is a computer algebra system, which understands formulas as artifacts to be manipulated by explicit mathematics rules.
Mathematica and Macsyma are applications which do this. However, these are quite sophisticated systems and it is not easy to see how they "work".
What you need to do is:
Represent formulas as abstract syntax trees
Parse text formulas (your example equations) into such trees
Encode a set of tree-manipulation rules that represent algebra operations
Apply these rules to your algebra trees
Prettyprint the algebra trees back as text when done
Rules are best written in the surface syntax of algebra. (Mathematica doesn't do this; it represents formulas as trees using a kind of prefix S-expressions, and rules as the same kind of trees with special variable nodes).
One of the issues is deciding how many "algebra" rules you are wiling to encode. Mathematics is a lot more than pure 9th grade algebra, and people using such systems tend to want to extend what is there by adding more knowledge (the point of Mathematica and Macsyma: they are infinitely extendable).
Here's a very simple version of this. You can see all the "gears" and how things are described, in terms of parse trees and rewrite rules.
http://www.semdesigns.com/Products/DMS/SimpleDMSDomainExample.html
How do I apply case analysis in Isabelle? I was looking for something similar to apply (induct x) (which is used for induction).
Case analysis is usually performed with the cases method (also see "cases (method)" in the index of the Isabelle/Isar Reference manual of Isabelle2014). If you are a beginner, I recommend the tutorial Programming and Proving in Isabelle/HOL.
Note that since Isabelle 2014, the documentation is also available in the Isabelle/jEdit IDE in the Documentation panel.
Given my previous questions about the the usage of AMPL.
Are there any other programming/scripting languages that are strictly meant for mathmatical processing?
For example: Matlab (it does deviate a bit from a mathematical structure, but its close enough), Mathematica, and AMPL
R / S+ for statistical computing
Other stat languages: SAS, SPSS, STATA, GAUSS, etc.
Octave, an open source clone of Matlab
Fortress, "a language for high-performance computation that provides abstraction and type safety on par with modern programming language principles."
Maple
Maxima
There's always APL, with its builtin matrix operators. Modern APL even supports .NET.
R, Numpy/scipy for Python, Maple, Yacas, even Fortran.
This may be only of historical significance, but Fortan (The IBM Mathematical Formula Translating System) is especially suited to numeric computation and scientific computing.
OPL (Optimization Programming Language) is one of the most comprehensive modelling languages for Mathematical Programming. You can do Linear Programming (LP), Mixed Integer Programming (MIP), Quadratic Programming (QP), Constraint Programming (CP), MIQP, etc.
IBM-ILOG CPLEX Optimization Studio uses this language.
Maple for symbolic math (similar to Mathematica).
SAS, SPSS, R for statistics.
The Operation Research / Management Science magazine has a yearly survey of Simulation Software, and while I can't find the link I believe they have one yearly survey on optimization packages, such as AMPL you are quoting.
Sage is basically Python with a load of packages and a few language extensions put into a "notebook" interface like that of Mathematica. It has interfaces to all sorts of computer algebra systems. And with Numpy and Scipy (which are included) it's a fine replacement for Matlab. And it's open source and actively developed.
Given your previous question, I assume you are looking for an alternative to commercial mathematics packages. If so, you should try Sage, it is open source and is a unified front end for almost all of the open source mathematics/sci.calc. packages out there (list).
The way it works, is that it uses your web browser as a graphical front end for displaying, editing and evaluating Mathematica style notebooks (it is also possible to just use the command line). All the dirty work, such as selecting the appropriate package for the situation, is done transparently in the background.
Sage uses Python as it's main language / syntax, so it's fairly easy to learn, and if you have old Python scripts, they should work straight out of the box. If I didn't have access to a Mathematica license, I would definitely use this.
Interactive Data Language (IDL) is a proprietary language used in astronomy, medicine and other sciences at least in part because of its built-in array operations and mathematical library.
As this question is still open and well indexed in Google, I would definitively add to the list the Julia language.
Aside the technical aspects that make shine this high level/high performance new language, an important consideration is that the community of developers/users is clearly biased toward mathematicians.
I have a number of small algorithms that I would like to write up in a paper. They are relatively short, and concise. However, instead of writing them in pseudo-code (à la Cormen or even Knuth), I would like to write an algebraic representation of them (more linear and better LaTeX rendering) . However, I cannot find resources as to the best notation for this, if there is anything: e.g. how do I represent a loop? If? The addition of a tuple to a list?
Has any of you encountered this problem, and somehow solved it?
Thanks.
EDIT: Thanks, people. I think I did a poor job at phrasing the question. Here goes again, hoping I make it clearer: what is the common notation for talking about loops and if-then clauses in a mathematical notation? For instance, I can use $acc \leftarrow acc \cup \langle i,i+1 \rangle$ to represent the "add" method of a list.
Don't do this. You are deviating from what people expect to see when they read a paper about algorithms. You should follow expected practices; your ideas are more likely to get the attention that they deserve. When in Rome, do as the Romans do.
Formatting code (or pseudocode as it may be) in a LaTeXed paper is very easy. See, for example, Formatting code in LaTeX.
I see if-expressions in mathematical notation fairly often. The usual thing for a loop is a recurrence relation, or equivalently, a function defined recursively.
Here's how the Ackermann function is defined on Wikipedia, for instance:
This picture is nice because it feels mathematical in flavor and yet you could clearly type it in almost exactly as written and have an implementation. It is not always possible to achieve that.
Other mathematical notations that correspond to loops include ∑-notation for summation and set-builder notation.
I hope this answers your question! But if your aim is to describe how something is done and have someone understand, I think it is probably a mistake to assume that mathematicians would prefer to see equations. I don't think they're interchangeable tools (despite Turing equivalence). If your algorithm involves mutable data structures, procedural code is probably going to be better than equations for explaining it.
I'd copy Knuth. Few know how to communicate better than him in a computer science setting.
A symbol for general loops does not exist; usually you will use the summation operator. "if" is represented using implications, and to "add a tuple to a list" you would use union.
However, in general, a bit of verbosity is not necessarily a bad thing - sometimes, especially for complex algorithms, it is best to spell it out in plain English, using examples and diagrams. This is doubly-true for non-coders.
Think about it: when you read a math text-book on Euclid's algorithm for GCD, or the sieve of Eratosthenes, how is it written? Usually, the algorithm itself is in prose, while the proof of the algorithm is where the mathematical symbols lie.
You might take a look at Haskell. Haskell formats well in latex, has a nice algebraic syntax, and you can even compile a latex file with Haskell in it, provided the code is wrapped in \begin{code} and \end{code}. See here: http://www.haskell.org/haskellwiki/Literate_programming. There are probably literate programming tools for other languages.
Lisp started out as a mathematical notation of a computing model so that the lecturer would have a better tool than turing machines. By accident, it turns out that it can be implemented in assembly - thus lisp, the programming language was born.
But I don't think this is really what you are looking for since the computing model that lisp describes doesn't have loops: recursion is used instead. The syntax derives from algebra where braces denote evaluate-this-and-substitute-the-result. Indeed, lisp's model of computing is basically substitution - what algebra essentially is.
Indeed, most functional languages like Lisp, Haskell and Erlang are derived from mathematics. Haskell is actually a result of proving that lambda calculus can be used to implement type systems. So Haskell, like Lisp was born out of pure mathematics. But again, the syntax is not what you would probably be used to.
You can certainly explain Lisp and Haskell syntax to mathematicians and they would treat it as a "game". Language constructs like loops, recursion and conditionals can be proven out of the rules of the game rather than blindly implemented like in other languages. This would lead you into the realms of combinatronics, another branch of mathematics. Indeed, in combinatronics, even the concept of numbers can be constructed out of the rules of the game rather than being a native part of the language (google Church Numerals).
So have a look at Lisp/Scheme, Erlang and Haskell if you want. Erlang especially has syntax close to what you want:
add(a,b) -> a + b
But my recommendation is to write in C-like pseudocode. It's sort of the lowest common denominator in programming languages. Has a syntax that is fairly easy to understand and clean. And the function syntax even derives from functions in mathematics. Remember f(x)?
As a plus, mathematicians are used to writing C, statisticians are used to writing C (though generally they prefer R), physicists are used to writing C, programmers are used to at least looking at C (I know a few who've never touched C).
Actually, scratch that. You mention that your target audience are statisticians. Write in R
Something like this website describes?
APL? The only problem is that few people can read it.