CTP-userinterfaces: cite, ref, paragraph decompose-isar
authorWalther Neuper <neuper@ist.tugraz.at>
Mon, 10 Jan 2011 10:15:44 +0100
branchdecompose-isar
changeset 38089042b19985ea0
parent 38087 d45fae3237f1
child 38090 4e128838c313
CTP-userinterfaces: cite, ref, paragraph
doc-src/isac/CTP-userinterfaces.bib
doc-src/isac/CTP-userinterfaces.tex
doc-src/isac/fig/coqide.png
doc-src/isac/fig/pgisabelle.png
     1.1 --- a/doc-src/isac/CTP-userinterfaces.bib	Thu Jan 06 09:02:02 2011 +0100
     1.2 +++ b/doc-src/isac/CTP-userinterfaces.bib	Mon Jan 10 10:15:44 2011 +0100
     1.3 @@ -1,3 +1,11 @@
     1.4 +@book{Paulson:Isa94,
     1.5 +        title={Isabelle: a generic theorem prover}, 
     1.6 +        author={Paulson, Lawrence C. }, publisher={Springer-Verlag},year={1994}, 
     1.7 +	volume={828},series={Lecture Notes in Computer Science},address={},edition={},month={}, 
     1.8 +	note={With contributions by Topias Nipkow},
     1.9 +        status={},source={},location={-} 
    1.10 +        }  
    1.11 +
    1.12  @Book{pl:milner97,
    1.13    author = 	 {Robin Milner and Mads Tofte and Robert Harper and David MacQueen},
    1.14    title = 	 {The Definition of Standard ML (Revised)},
     2.1 --- a/doc-src/isac/CTP-userinterfaces.tex	Thu Jan 06 09:02:02 2011 +0100
     2.2 +++ b/doc-src/isac/CTP-userinterfaces.tex	Mon Jan 10 10:15:44 2011 +0100
     2.3 @@ -9,8 +9,8 @@
     2.4  \def\sisac{{\footnotesize${\cal I}\mkern-2mu{\cal S}\mkern-5mu{\cal AC}$}}
     2.5  \def\Problem{ {\tt Problem }}
     2.6  
     2.7 -\title{Upcoming Userinterfaces for Computer Theorem Provers.\\
     2.8 -	The case of Isabelle
     2.9 +\title{Userinterfaces for Computer Theorem Provers.\\
    2.10 +	Contributions to Isabelle
    2.11  }
    2.12  
    2.13  \author{G. Schafhauser, A. Schulhofer, M. Steger\\
    2.14 @@ -31,61 +31,167 @@
    2.15  \section{State of the art in CTP Interfaces}
    2.16  
    2.17  \subsection{A European technology: Coq and Isabelle}\label{ctp-techn}
    2.18 -     http://en.wikipedia.org/wiki/Coq\\
    2.19 -     http://coq.inria.fr/
    2.20 +%     http://en.wikipedia.org/wiki/Coq\\
    2.21 +%     http://coq.inria.fr/
    2.22 +%
    2.23 +%     http://en.wikipedia.org/wiki/Isabelle\_(theorem\_prover)\\
    2.24 +%     http://isabelle.in.tum.de/index.html
    2.25 +%
    2.26 +%why math -- functional: some of the languages have been specifically designed for constructing software for symbolic computation (SC). 
    2.27 +%%+ required for \ref{ml-users}
    2.28 +%
    2.29 +%SC http://en.wikipedia.org/wiki/Symbolic\_computation
    2.30 +%% mainly does not compute numerical values, but terms containing variables like functions (symbols)
    2.31 +%
    2.32 +%The LCF project
    2.33 +%http://hopl.murdoch.edu.au/showlanguage.prx?exp=8177
    2.34 +%specifically designed a 'meta language' (ML)
    2.35 +%http://en.wikipedia.org/wiki/ML\_(programming\_language)
    2.36 +%\cite{pl:milner97}
    2.37 +%for developing CTP
    2.38 +\subsubsection{Standard ML}
    2.39 +Standard ML is a general-purpose, modular, functional programming language. 
    2.40 +Programs written in Standard ML consist of expressions to be evaluated, as opposed to statements or commands. 
    2.41 +SML is a modern descendant of the ML programming language used in the Logic for Computable Functions (LCF) theorem-proving project. 
    2.42 +It is invented by Robin Milner. %http://en.wikipedia.org/wiki/Standard_M 
    2.43 +\subsubsection{Coq}
    2.44 +Coq is an interactive theorem prover, developed in France. The team leader is Senior Scientist Benjamin Werner. 
    2.45 +Coq is in Objective Caml programmed, an ML based programming language.
    2.46 +It has the ability to express  mathematical  assertions and check proof of mathematical  assertions. 
    2.47 +Furthermore Coq includes automatic theorem proving tactics and decision procedures.
    2.48 +Proof development in Coq is done through a language of tactics that allows a user-guided proof process. 
    2.49 +At the end, the user can check that tactics build lambda-terms. 
    2.50 +Another feature of Coq is “that it can automatically extract executable programs from specifications, as either Objective Caml 
    2.51 +or Haskell source code.“
    2.52 +Properties, programs and proofs are written a language called the Calculus of Inductive Constructions (CIC).
    2.53 +Coq is based on a type-checking algorithm, therefore Coq uses only typing judgements.
    2.54 +Coq supports a functional programming language.
    2.55 +(http://coq.inria.fr/a-short-introduction-to-coq)
    2.56 +\subsubsection{Isabelle}
    2.57 +Isabelle is an interactive theorem proving framework for high-level natural deduction proofs \cite{Paulson:Isa94}, written in Standard ML. 
    2.58 +Isabelle is developed at University of Cambridge (Larry Paulson), Technische Universität München (Tobias Nipkow) 
    2.59 +and Université Paris-Sud (Makarius Wenzel).
    2.60 +The most widespread instance of Isabelle nowadays is Isabelle/HOL, providing a higher-order logic theorem proving environment.
    2.61 +Isabelle/HOL includes several  specification tools, e.g. for datatypes, inductive definitions and functions with complex pattern matching.
    2.62 +Proofs are written in the structured proof language Isar. Isabelle implements several tools to increase the user's productivity in theorem proving. 
    2.63 +Isabelle's classical reasoner is used to check formulas. The simplifier can reason with and about equations. 
    2.64 +Linear arithmetic facts are proved automatically.
    2.65 +Isabelle provides notational support: new notations can be introduced, using normal mathematical symbols.
    2.66 +Definitions and proofs may include LaTeX source, from which Isabelle can automatically generate typeset documents.
    2.67 +Isabelle/HOL allows to turn executable specifications directly into code in SML, OCaml, and Haskell.
    2.68 +(http://www.cl.cam.ac.uk/research/hvg/Isabelle/overview.html)
    2.69 +\subsection{Userinterfaces for CTP: Coq and Isabelle}\label{gui-coq-isa}
    2.70 +%     CoqIDE, ..
    2.71 +%         http://coq.inria.fr/what-is-coq?q=node/57\\
    2.72 +%         earlier than Isabelle/jEdit
    2.73 +%
    2.74 +%     ProofGeneral for Isabelle
    2.75 +%         http://proofgeneral.inf.ed.ac.uk/\\
    2.76 +%         emacs stone age ?
    2.77 +\subsubsection{Coq Integrated Development Environment}
    2.78 +CoqIde is a graphical interface for Coq. It is written in Ocaml. (http://coq.inria.fr/cocorico/CoqIde)
    2.79 +Its main purpose is to allow the user to navigate forward and backward into a Coq vernacular file, 
    2.80 +executing corresponding commands or undoing them respectively. 
    2.81 +There are several  buffers for helping to write proof scripts.
    2.82 +Among all these buffers, there is always one which is the current running buffer, whose name is displayed on a green background,
    2.83 +which is the one where Coq commands are currently executed. 
    2.84 +Buffers may be edited as in any text editor, and classical basic editing commands (Copy/Paste, ...) are available.  
    2.85 +CoqIde provides also a feedback system for the user. 
    2.86 +Therefore the background is green when a command succeeds, otherwise an errormessage is displayed in the message window and the error location is underlined red.
    2.87 +CoqIDE offers only basic editing commands, therefore it is possible to launch another more sophisticated text editor. 
    2.88 +Furthermore CoqIde provides a proof wizard “for automatically trying to solve the current goal using simple tactics.”
    2.89 +Another features of this IDE are the customization options, which can be accessed by the Edit menu. 
    2.90 +This allows the user to change the apeareance of the IDE.
    2.91  
    2.92 -     http://en.wikipedia.org/wiki/Isabelle\_(theorem\_prover)\\
    2.93 -     http://isabelle.in.tum.de/index.html
    2.94  
    2.95 -why math -- functional: some of the languages have been specifically designed for constructing software for symbolic computation (SC). 
    2.96 -%+ required for \ref{ml-users}
    2.97 +\begin{figure}[htbp]
    2.98 +\centering
    2.99 +%\includegraphics[bb=0 0 10 10]{coqide.png}
   2.100 +\includegraphics[scale=0.25]{fig/coqide}
   2.101 +\caption{CoqIDE main screen}
   2.102 +\end{figure}
   2.103  
   2.104 -SC http://en.wikipedia.org/wiki/Symbolic\_computation
   2.105 -% mainly does not compute numerical values, but terms containing variables like functions (symbols)
   2.106  
   2.107 -The LCF project
   2.108 -http://hopl.murdoch.edu.au/showlanguage.prx?exp=8177
   2.109 -specifically designed a 'meta language' (ML)
   2.110 -http://en.wikipedia.org/wiki/ML\_(programming\_language)
   2.111 -\cite{pl:milner97}
   2.112 -for developing CTP
   2.113 - 
   2.114 +(http://coq.inria.fr/V8.1/refman/Reference-Manual016.html)
   2.115 +\subsubsection{Proof General for Isabelle}
   2.116 +Proof General is a generic front-end for proof assistants, based on the customizable text editor Emacs.
   2.117 +Proof General has been developed at the LFCS in the University of Edinburgh with contributions from other sites.
   2.118 +Proof General comes ready-to-go for these proof assistants: Isabelle, Coq, PhoX, LEGO.
   2.119 +Proof General is used to write proof scripts. A Proof Script is a sequence of commands sent to theorem prover. 
   2.120 +The communication between the user and the theorem prover takes place via two or  more Emacs text widgets. 
   2.121 +Therefore the user sees only the output from the latest proof step.(proofgeneral.ps.gz)
   2.122  
   2.123 -\subsection{Userinterfaces for CTP: Coq and Isabelle}\label{gui-coq-isa}
   2.124 -     CoqIDE, ..
   2.125 -         http://coq.inria.fr/what-is-coq?q=node/57\\
   2.126 -         earlier than Isabelle/jEdit
   2.127  
   2.128 -     ProofGeneral for Isabelle
   2.129 -         http://proofgeneral.inf.ed.ac.uk/\\
   2.130 -         emacs stone age ?
   2.131 +Isabelle/Isar Proof General has full support for multiple file scripting, with dependencies between theories communicated between Isabelle and Proof General. 
   2.132 +There is full support for Unicode Tokens, using the Isabelle print mode for X Symbol tokens. Many Isabelle theories have X Symbol syntax already defined 
   2.133 +and it's easy to add to your own theories. 
   2.134 +(http://proofgeneral.inf.ed.ac.uk/fileshow.php?file=releases%2FProofGeneral%2Fisar%2FREADME)
   2.135 +\begin{figure}[htbp]
   2.136 +\centering
   2.137 +\includegraphics[scale=0.5]{fig/pgisabelle}
   2.138 +\caption{Proof General for Isabelle}%
   2.139 +\end{figure}
   2.140 +\subsubsection{Isabelle/Jedit}
   2.141 +jEdit is a text editor for programmers, written in Java.
   2.142 +Compared to fully-featured IDEs, such as Eclipse or Netbeans, jEdit is much 
   2.143 +smaller and better focused on its primary task of text editing.
   2.144 +The general look of the Isabelle/jEdit plugin is similar to existing Java IDEs.
   2.145 +The main Isabelle/jEdit plugin consists of ≈ 10 small Scala files  that augment some key jEdit components in order to provide a metaphor of asynchronous 
   2.146 +proof document editing. 
   2.147 +Isabelle/jEdit integrates the jEdit 4.3.2 framework  and some further  jEdit plugins. 
   2.148 +It also implements custom-made IsabelleText Unicode font that actually contains the usual Isabelle symbols that users expect from long 
   2.149 +years of Proof General X-Symbol support. 
   2.150 +The editor provides useful feedback, via semantic information from the processed document in the background. 
   2.151 +This achieves continuous proof checking based on our 
   2.152 +asynchronous prover toplevel. A lot of information can be directly attached 
   2.153 +to the source text, via coloring, tooltips, popups etc.
   2.154  
   2.155  \subsection{Upcoming requirements for userinterfaces in CTP}\label{gui-requir}
   2.156 -     @ interaction close to tty (Telegraph)\\
   2.157 -       BUT: separate parts in {\em one} proof could be processed in parallel
   2.158 -
   2.159 -     @ http://www.informatik.uni-bremen.de/uitp/
   2.160 -
   2.161 -     @ ... see\\
   2.162 -       http://www4.in.tum.de/~wenzelm/papers/async-isabelle-scala.pdf,\\
   2.163 -       http://www4.in.tum.de/~wenzelm/papers/parallel-isabelle.pdf
   2.164 -
   2.165 +%     @ interaction close to tty (Telegraph)\\
   2.166 +%       BUT: separate parts in {\em one} proof could be processed in parallel
   2.167 +%
   2.168 +%     @ http://www.informatik.uni-bremen.de/uitp/
   2.169 +%
   2.170 +%     @ ... see\\
   2.171 +%       http://www4.in.tum.de/~wenzelm/papers/async-isabelle-scala.pdf,\\
   2.172 +%       http://www4.in.tum.de/~wenzelm/papers/parallel-isabelle.pdf
   2.173 +After several decades, most proof assistants are still centered around TTY-based(Fußnote)  interaction in a
   2.174 +tight read-eval-print loop. All Emacs-based GUI's for CTPs follow this synchronous
   2.175 +model based on single commands with immediate response, meaning that the editor waits for the
   2.176 +prover after each command. As to multicore politics of leading semiconductor chip manufacturer,  parallelism in software technology has become very popular. 
   2.177 +Therefore the support of parallelism in CTP technology could improve the performance and the multiuser support. 
   2.178 +So it is necessary to use proof documents instead of proof scripts.  
   2.179 +Proof scripts are  sequences of commands however proof documents are  structured texts. 
   2.180 +So the proof document idea seems to guarantee the perfect support for parallelism in the CTP technology. 
   2.181 +(MW async-isabelle-scala.pdf)
   2.182 +\newpage
   2.183  %Andreas
   2.184  \section{Isabelle's plans for new user-interfaces}\label{gui-plans}
   2.185 -       http://www4.in.tum.de/~wenzelm/papers/async-isabelle-scala.pdf,\\
   2.186 -       http://www4.in.tum.de/~wenzelm/papers/parallel-isabelle.pdf
   2.187 +%       http://www4.in.tum.de/~wenzelm/papers/async-isabelle-scala.pdf,\\
   2.188 +%       http://www4.in.tum.de/~wenzelm/papers/parallel-isabelle.pdf
   2.189 +%
   2.190 +%theorem proving will be integrated into software development
   2.191 +%
   2.192 +%hundreds of proof obligations are generated during a software verification process 
   2.193 +%
   2.194 +%so the final goald of Isabelle's planning is integration with other software development tools in an integrated development environment (IDE).
   2.195 +%
   2.196 +%still many principal issues need to be clarified with respect to integration of CTP and other development tools. So engaging into details makes no sense at the present, and Isabelle will approach the final goal via experimental intermediate steps of integration.
   2.197  
   2.198 -theorem proving will be integrated into software development
   2.199 -
   2.200 -hundreds of proof obligations are generated during a software verification process 
   2.201 -
   2.202 -so the final goald of Isabelle's planning is integration with other software development tools in an integrated development environment (IDE).
   2.203 -
   2.204 -still many principal issues need to be clarified with respect to integration of CTP and other development tools. So engaging into details makes no sense at the present, and Isabelle will approach the final goal via experimental intermediate steps of integration.
   2.205 +\begin{itemize}
   2.206 +\item theorem proving will be integrated into software development
   2.207 +\item hundreds of proof obligations are generated during a software verification process
   2.208 +\item so the final goal of Isabelle's planning is integration with other software development tolls in an integrated development environment (IDE)
   2.209 +\item still many principal issues need to be clarified with respect to integration of CTP and other development tools. So engaging into details makes no sense at the present, and Isabelle will approach the final goal via experimental intermediate steps of integration
   2.210 +\item favorite IDE is the jEdit, because it is clearer than Eclipse or NetBeans. The reason behind this choice follows in section 4.2
   2.211 +\end{itemize}
   2.212  
   2.213  \subsection{Connect ML-world to the users' world via JVM}\label{ml-users}
   2.214  In Sect.\ref{ctp-techn} reasons have been given, why mathematics software at the state-of-the-art cannot be written in Java or the like. On the other side, Sect.\ref{gui-requir} stated requirements for mathematical user interfaces, which cannot be accomplished by ML-like languages. These requirements can be best accomplished by languages like Java, which have powerful libraries available for convenient assembly of GUIs.
   2.215  
   2.216 +
   2.217 +
   2.218 +
   2.219  \paragraph{Example: a functional mathematics engine} as the experimental one in the \sisac-project is given by the following signature:
   2.220  {\it
   2.221  \begin{tabbing}
   2.222 @@ -109,16 +215,74 @@
   2.223  Now, the point with functional programming is, that the functions do {\em not} cause persistent updates in some memory, rather: all three functions above take the current state of the calculation, \textit{calcstate}, as an argument and after they have done they work return the updated \textit{calcstate}.
   2.224  
   2.225  There are several advantages of this kind of programming: more straight forward verification, which is not discussed here, and other features. For instance, given the three functions above, it is easy to undo steps of calculations, or go back to an earlier step of calculations: one just needs to store the \textit{calcstate}s (in a list), even without knowing the details of the \textit{calcstate}, which thus can be encapsulated for internal access only.
   2.226 -
   2.227 -\paragraph{Example: an object-oriented wrapper} as required for embedding the above mathematics engine into an object-oriented system. Such a wrapper looks like this:
   2.228 -
   2.229 -TODO
   2.230 +%
   2.231 +%\paragraph{Example: an object-oriented wrapper} as required for embedding the above mathematics engine into an object-oriented system. Such a wrapper looks like this:
   2.232 +%
   2.233 +%TODO
   2.234  
   2.235  \subsection{Scala as a mediator between ML and JVM}\label{scala-medi}
   2.236 -{\em new} language --- what for, ideas ...
   2.237 +{\em new} %language --- what for, ideas ...
   2.238 +Scala is a hybrid multi-paradigm programming language. It combines object-oriented programming and functional programming. Scala runs on the Java Virtual Machine and is byte-code compatible with existing Java programs. The compilation model of Scala is nearly the same as the Java's model. So existing tools, libraries and applications can be used with Scala. The Syntax of Scala is similar to Java and ML. A number of keywords plus the block syntax is adopted from Java and from ML the syntax for type annotation and declaration. The source-code is typically reduced, concisely and more compact compared to equivalent Java code.\\
   2.239 +Scala is pure object-oriented, this means every value is an object. The same is true for primitive data types, because compiler-generated byte code is using primitive data types. Known design patterns from OOP can be used with Scala as well. Data types and behaviors of objects are described by classes and traits [wiki]. Traits not only consist of definitions, they also can contain implementations of methods. To avoid the problems of multiple inheritance, classes are able to extend various traits, this is a flexible mixin-based mechanism. The keyword Object is used to implement a Singleton-Class. \\
   2.240 +In Scala every function is a value, hence Scala is also a functional language. Functions in Scala are first-class objects, this means it is possible to pass a function as a parameter, return a function from a subroutine, or assign to a variable. Scala also supports case classes, which are used for pattern matching. Case classes are regular classes which export their constructor parameters[wiki-11-1s]. Furthermore Scala supports higher-order functions, currying and allows functions to be nested. \\
   2.241 +Scala is more statically typed than Java, but is able to infer types by usage. So most static type declarations are optional. This static type system ensures a safe and coherent use of abstraction. Scala supports:
   2.242 +\\
   2.243 +\begin{itemize}
   2.244 +\item generic classes
   2.245 +\item variance annotations
   2.246 +\item upper and lower type bounds
   2.247 +\item classes and abstract types as object members
   2.248 +\item compound types
   2.249 +\item explicitly typed self references
   2.250 +\item views
   2.251 +\item polymorphic methods
   2.252 +\end{itemize}
   2.253 +Static types need no explicit declaration but can be given to give the code some clarity.\\\\
   2.254 +Scala supports threads, but the Scala library contains an actor model inspired from Erlang. Concurrency and Scala actors follow in the next section.\\
   2.255 +
   2.256 +%quellen
   2.257 +%%http://de.wikipedia.org/wiki/Scala_%28Programmiersprache%29
   2.258 +%%http://en.wikipedia.org/wiki/Scala_%28programming_language%29
   2.259 +%%http://creativekarma.com/ee.php/weblog/comments/why_scala_instead_of_java/
   2.260 +%%http://www.scalasolutions.com/scala
   2.261 +
   2.262  
   2.263  \subsection{Support for parallel processing}\label{actors}
   2.264 -actors copied from erlang
   2.265 +%actors copied from erlang
   2.266 +
   2.267 +Concurrency has lately become more and more attention, because multicore processors make concurrency very important for efficient program execution, by running multiple threads parallel and so concurrent programming gets indispensable and distributed computing,web services and mobile environments are naturally concurrent. \\
   2.268 +A very attractive model, because of the fact that it might addresses multicore processors and several techniques which are basically concurrent, is message-based concurrency. Most of the message passing systems, which are used in practice, are based on the actor model. \\
   2.269 +An actor is a concurrent process that executes a function. The state of an actor gets never shared, so it doesn't need to compete for locks of shared data. Actors own a mailbox where incoming messages are stored in. A mailbox is mainly a queue with several producers and one consumer, which are other actors. Actors share data by sending Messages which are sent asynchronously. Messages are unchangeable, so they don't require a lock and are used for communication between actors. By creating new actors, by sending messages to known actors, or changing its behavior, an actor is able to reply to a message. The actor-based process is combined with pattern matching for messages.\\
   2.270 +The Erlang programming language is a functional programming language and a very popular implementation of message-based concurrency, which operates with actors. It was developed for real-time control systems. Such systems are telephone exchanges, network simulators and distributed resource controllers [IoC]. These systems use a very lightweight implementation and a large number of concurrent processes, which can active simultaneously.\\
   2.271 +Operating system threads and threads of virtual machines, are too heavyweight for the implementation of such processes. The standard concurrency for mainstream platforms where shared-memory threads with locks. Such a platform is the Java Virtual Machine (JVM), which suffers from high memory consumption and context-switching overhead.
   2.272 +The main reasons are:
   2.273 +\begin{enumerate}
   2.274 +\item quick exhaustion of virtual address space
   2.275 +\item locking mechanisms often lack suitable contention managers
   2.276 +\end{enumerate}
   2.277 +%[IoC]
   2.278 +For that reasons Erlang uses lightweight concurrent processes by its own run time system and not by the underlying operating system [IoC] and the computations on these platforms are often modeled in an event-driven style, which is complicated and error-prone.
   2.279 +\paragraph{Two different strategies for concurrency} are being used for implementation. This two strategies often follow different programming models, the benefit of thread-based models is that they are easier to use, but they still suffer from the memory consumption and the context-switching. The event-based models are just the opposite of the thread-based, they are more efficient, but in massive designs they are very difficult.
   2.280 +
   2.281 +\subparagraph{Thread-based implementation:} The behavior of a concurrent process is defined by implementing a thread-specific method. The execution state is maintained by an associated thread stack [2.P].
   2.282 +Supports blocking operations and can be executed on multicore processors in parallel.
   2.283 +
   2.284 +\subparagraph{Event-based implementation:} The behavior is defined by a number of (non-nested) event-handlers which are called from inside an event loop. The execution state of a concurrent process is maintained by an associated record or object [2.P]. Targets to a large number of actor which can be active simultaneously, because they are more lightweight.
   2.285 +
   2.286 +\paragraph{Actors in Scala} are based on actors in Erlang. Scala uses the basic thread model of Erlang, but on the other hand all higher-level functions got implemented in the Scala library as classes or methods. The Scala-actors are a unification of the concurrent process implementation models, mentioned above and they are compatible with normal Virtual Machine thread. Normal VM threads can use the same communication and monitoring capabilities, because they are treated like an actor. A message-based concurrency seems to be more secure than shared-memory with locks, because accessing an actor's mailbox is race-free. The advantage of a implementation in a library is that it can be flexibly extended and adapted to new needs. The library makes use of Scala abstraction opportunities, like partial functions and pattern matching.
   2.287 +
   2.288 +The main idea of this model is that an actor is able to wait for a message by using two different operations, which try to remove a message from the current actor's mailbox. To do so, a partial function must be given to the operation, that specifies a set of message patterns. These operations are receive and react. An actor can suspend with a full thread stack (receive) or it can suspend with just a continuation closure (react) [2.P]. The first operation of an actor to wait for an message is equal to thread-based programming and the second operation to event-based programming.
   2.289 +
   2.290 +receive:         def receive[R](f: PartialFunction[Any, R]): R
   2.291 +The current actor's mailbox get scanned and if there is one message which matches one of the patterns declared in the partial function, the message is removed from the mailbox and the partial function is applied to the message, the result is returned. Otherwise the current thread blocks. Thus the receiving actor has the ability to execute normally when receiving a message which matches.  Note that receive retains the complete call stack of the receiving actor; the actor’s behavior is therefore a sequential program which corresponds to thread-based programming [2.P]. \\
   2.292 +react:          
   2.293 +$$\mathit{def}\;\mathit{react}(f: \mathit{PartialFunction}[Any, Unit]): \mathit{Nothing}$$
   2.294 +The action which is specified in the partial function is the last code that the current actor executes, if the message is matching. The partial function gets registered by the current actor and the underlying thread gets released. React has the return type Nothing, this means that the method never returns normally. When the actor receives a matching message, the earlier registered partial function gets called and the actor's execution gets continued. The partial function f which corresponds to a set of event handlers [2.P]. \\
   2.295 +For this implementation multiple acotrs are executed by multiple threads and therefore a thread pool is used. Whenever it is necessary the pool can be re sized, to support the operations of the thread-based and event-based model. If only operations of the event-based model are executed then the thread pool could be fixed. To avoid system-included deadlocks, if some actors use thread-based operations, the thread pool has to grow, because if there are outstanding tasks and every worker thread is occupied by a blocked actor, new threads are necessary. \\
   2.296 +Since the communication between actors takes place through asynchronous message passing, asynchronous operations get executed, tasks have to be created and submitted to a thread pool for execution. A new task is created, when an actor spawns a new actor or a message, which enables an actor to continue, is send to an actor which is suspended in a react operation or by calling react, where a message can be immediately removed from the mailbox.\\
   2.297 +Event-Based Programming without Inversion of Control - Philipp Haller, Martin Odersky  [IoC]\\
   2.298 +Scala actors: Unifying thread-based and event-based programming - Philipp Haller, Martin Odersky [2.P]\\
   2.299 +
   2.300  
   2.301  % Marco
   2.302  \section{Planned contributions at TU Graz}
   2.303 @@ -147,14 +311,106 @@
   2.304  This plan involves the following details.
   2.305  
   2.306  \subsection{Add a plug-in to jEdit}\label{plugin}
   2.307 -     file structure, copied from example project ...
   2.308 +    % file structure, copied from example project ...
   2.309 +%Die von jEdit verfolgte Strategie im Bezug auf Plugin-Management und natürlich generell die totale Offenlegegung des Codes ist für ein Projekt wie Isabelle und auch für das Isac-Project an der TU ideal. Plugins lassen sich sehr einfach anfügen und durch die riesige Vielfalt von bereits bestehenden Plugins ist auch die Adaption von Plugins möglich bzw. zu empfehlen, denn warum sollte nicht bereits funktionierender Code verwendet werden?\\
   2.310 +The importance of connecting the ML-world with the world of user interfaces has been is discussed in Sect.\ref{ml-users}. jEdit follows these lines, it is an open-source, Java-based text editor that works on Windows, Mac OS X, and Linux. A big advantage of jEdit is, that there is a very good and also simple way to use and write a Plugin. There are a lot of useful and powerful Plugins available in the net and it is also possible to use a existing Plugin as part of a new one. Because of this facts, jEdit is very suitable for a project like Isabelle and also for the Isac-project at TU-Graz. \\\\
   2.311 +Each jEdit-Plugin basically consists of source files, written in Java or Scala, XML-files and property files. The XML-Files are important for the administration of a Plugin and provides information like the name, author, ... of the Plugin. They are also containing small pieces of BeanShell code which is executed upon a user request. (Like pressing the 'start plugin' button.) So the XML-files provide the “glue” between user input and specific Plugin routines located in the source files. As you see, this files are used as interface between the Plugin and the jEdit engine itself.\\
   2.312 +Based on the jEdit API, you are allowed to design your code quit freely and don't have to use a prescribed way to implement your ideas.    
   2.313 +To get more information about the jEdit infrastructure see: http://jedit.org/users-guide/plugin-intro
   2.314 +\\\\
   2.315 +%isabell plugin beschreiben!!!!!!!!
   2.316 +The Isabelle-team also follow use this Plugin-structure. In the next paragraph the involved files will be described. The jEdit-Isabelle-Plugin consists of:
   2.317 +\begin{itemize}
   2.318 +\item 14 Scala-source-files
   2.319 +\item three XML-files
   2.320 +\item one property file
   2.321 +\end{itemize}
   2.322 +%Das vom Isabelle-Team erstellte jEdit-Plugin folgt natürlich auch dem oben erklärten Muster. Es wird nun genauer auf dieses Plugin eingegangen. The plugin consits of 14 scala-source-files, three xml-files and one property-file. 
   2.323 +The property-file \textit{Isabelle.props} contains general informations about the Isabelle-Plugin and the needed dependencies between Isabelle and the other used Plugins like sidekick. \\
   2.324 +The XML-file \textit{dockables.xml} is used to create the needed dock-able windows which are important to set up the GUI of the Plugin.\\
   2.325 +In the file \textit{actions.xml}, the dockable windows are added to the window-manager \textit{wm} and there is also some Beanshell-code to activate the Isabelle-GUI.\\
   2.326 +The last XML-file is \textit{services.xml} and is used to create instances of needed jEdit-Plugins.\\
   2.327 +This four files are located in the folder \textit{plugin}.\\\\
   2.328 +The more interesting files, the scala-files of the Plugin, can be found in the 'src/jedit'-directory. In this directory you can find the file \textit{Dummy.java} which is a dummy class and is simply used to make javadoc work. Just forget about this file. Also there is a folder/package \textit{jedit} which contains all Scala-source-files. Now it is time to take a closer look on the source-files: \\
   2.329 +The file \textit{plugin.scala} is the main-file of the Isabelle-Plugin and there are two important parts. First the \textit{Isabelle object}. This object contains data like name and path and also few basic functions. The second part is the \textit{class Plugin} which is derived from EBPlugin. Here the basic methods \textit{handleMessage}, \textit{start} and \textit{stop} are implemented. Each jEdit-Plugin should have this methods because they are very important for the handling of the Plugin! \\
   2.330 +jEdit and also the Isabelle Plugin work with dock-able windows. This means that you can move around each single window and dock it somewhere on the screen. So it is possible to individualize the jEdit-GUI. To support this, the file \textit{dockable.scala} is needed. The file \textit{output-dockable.scala} is derived from \textit{dockable.scala} and is used to print the result/output in a dock-able window. The same thing with \textit{protocol-dockable.scala} and \textit{raw-output-dockable.scala}.\\
   2.331 +The next interesting file is \textit{scala-console.scala} with the main-class Scala-Console. This class is used to expand the Console-Plugin in a way, that it is possible to interpret Scala-code with a Shell inside of jEdit.\\ 
   2.332 +The file \textit{isabelle-sidekick.scala} is related to the file \textit{scala-console.scala} because it is also used to adapt the Plugin Sidekick for Isabelle.\\
   2.333 +The files \textit{document-model.scala} and \textit{document-view.scala1} are used to connect the jEdit-buffer/the text-area to Isabelle. Both classes offer, upon others, methods to activate and deactivate this features.\\
   2.334 +There also some other source-files but they aren’t discussed here, because the main goal of this paragraph is to give a basic idea how a jEdit-Plugin should be set up and the remaining files are not as important for the Isabelle-Plugin-structure:
   2.335 +\begin{itemize}
   2.336 +\item $html_panel.scala$
   2.337 +\item $isabelle_encoding.scala$
   2.338 +\item $isabelle_hyperlinks.scala$
   2.339 +\item $isabelle_options.scala$
   2.340 +\item $isabelle_token_maker.scala$
   2.341 +\item $isabelle_hyperlinks.scala$
   2.342 +\end{itemize}
   2.343 +
   2.344 +
   2.345 +%  Like each other jEdit-Plugin also this 
   2.346 +
   2.347 +%Das Konzept des frei wählbaren Designs ist am Beginn villeicht etwas schwierig umzusetzten, da es leichter ist, sich irgendwo anzulehnen bzw. ein bereits bestehendes sowie funktionierendes Konzept zu übernehmen. So wurden auch die ersten Schritte an der TU gemacht. Zu diesem Zweck wurde das von den Entwicklern von jEdit zur Verfügung gestellte plugin 'QuickNotepad' übernommen und in Scala übersetzt. Obwohl Scala eng mit Java verknüpft ist, war doch einiges an 'rewritting' notwendig bis das Scala-plugin lauffähig wurde. Die benötigten XML-files konnten dazu nahezu unberührt gelassen werden.\\
   2.348  
   2.349  \subsection{Details of NetBeans projects}\label{netbeans}
   2.350 -     Scala + Java: html project files
   2.351 +%     Scala + Java: html project files
   2.352 +As described in the last paragraph, jEdit is a open-source-project. The jEdit-developers use a NetBeans-project to produce the source-code and so it is beneficial to use a NetBeans project too, because there is a quite good documentation about setting up a NetBeans-project with the jEdit-source. See http://wiki.netbeans.org/NetbeansedJEdit for further information.\\\\
   2.353 +If you want to set up a new jEdit-Plugin-project you have to attend that you have to create some source-files and that there must be a connection to the jEdit-source because you will need to exchange data with the jEdit engine. This could probably look like: \textit{jEdit.getProperty("options.isabelle.isabelle")}\\
   2.354 +As shown above, the jEdit-source is needed to compile and build your Plugin. There are two ways to organize your project:
   2.355 +\begin{itemize}
   2.356 +\item with jEdit source code - two projects in one
   2.357 +\item with jedit.jar library
   2.358 +\end{itemize}
   2.359 +\subsubsection{Plugin with jEdit-source}
   2.360 +It is a good way to download the jEdit source as Netbeans project because then it is possible to add another subproject to the existing jEdit-NetBeans-project. As you see it is also possible to mix Scala and Java. A big advantage is, that debugging will now work really fine. If you want to set up a project like this, you should complete the following steps.
   2.361 +\begin{enumerate}
   2.362 +\item {Create a new NetBeans-project for your Plugin like \textit{example-plugin}. This will probably be a Scala-Project.}
   2.363 +\item Download (and try out) the \textit{jEdit-NetBeans-project}
   2.364 +\item at project \textit{example-plugin}: \textit{Project-browser} $\rightarrow$ Right-click at \textit{Libraries} $\rightarrow$ \textit{add Project...} and then choose the \textit{jEdit-NetBeans-project}.
   2.365 +\item at project \textit{example-plugin}: \textit{Project-browser} $\rightarrow$ Right-click at project-name-label $\rightarrow$ \textit{Properties} $\rightarrow$ \textit{Run} $\rightarrow$ \textit{Main Class:} org.gjt.sp.jedit.jEdit
   2.366 +\item compile and run
   2.367 +\end{enumerate}
   2.368 +
   2.369 +\subsubsection{Plugin with jedit.jar}
   2.370 +It is also possible to use the \textit{jedit.jar} file. This file is already included in \$ISABELLE-HOME/contrib/jedit-4.3.2. Now you just have to follow this steps:
   2.371 +\begin{enumerate}
   2.372 +\item {Create a new NetBeans-project for your Plugin like \textit{example-plugin}. This will probably be a Scala-Project.}
   2.373 +\item at project \textit{example-plugin}: \textit{Project-browser} $\rightarrow$ Right-click at \textit{Libraries} $\rightarrow$ \textit{add JAR/Folder...} and then choose the \textit{jedit.jar} file.
   2.374 +\item at project \textit{example-plugin}: \textit{Project-browser} $\rightarrow$ Right-click at project-name-label $\rightarrow$ \textit{Properties} $\rightarrow$ \textit{Run} $\rightarrow$ \textit{Main Class:} org.gjt.sp.jedit.jEdit
   2.375 +\item compile and run
   2.376 +\end{enumerate}
   2.377 +This are two different ways to get started. It is difficult to say what is better because both versions have advantages. Now it is time to start coding your own Plugin but there are still a few things to think about. Remember, that a Plugin consists of source-, XML- and property-files. On default, NetBeans will just pack the source-files in the \textit{example-plugin.jar}-package. So you have to add a copy/move-routine in the \textit{build.xml} file of your NetBeans-project to get a complemented package.
   2.378 +\begin{itemize}
   2.379 +\item $\langle target name="-pre-jar"\rangle$
   2.380 +\item $	\langle copy $file="plugin/services.xml" todir="\${build.classes.dir}" $/\rangle$
   2.381 +\item $	\langle copy $file="plugin/dockables.xml" todir="\${build.classes.dir}" $/\rangle$
   2.382 +\item $	\langle copy $file="plugin/actions.xml" todir="\${build.classes.dir}" $/\rangle$	
   2.383 +\item $	\langle copy $file="plugin/Isabelle.props" todir="\${build.classes.dir}" $/\rangle$
   2.384 +\item $	\langle /target\rangle$
   2.385 +\end{itemize}
   2.386 +%* kurze aufzählung der xml-netbeans-files + erklärung\\
   2.387 +\subsubsection{NetBeans project files}
   2.388 +As you see in the paragraph above, it is also important to have basic knowledge about NetBeans, the project structure and how to change the operational sequences. A typical NetBeans-project consist of the source- and library-files and administrative XML- and property-files. In this paragraph the administrative part of the project is of note. The most important file is \textit{build.xml}. This file can be found in the project directory. There is also a folder \textit{nbproject} which contains the remaining XML- and property-files and also a folder \textit{private}, where individual user informations about the project is stored. The files in this \textit{private} folder are not important to describe (and they should not be pushed on the repository!).\\
   2.389 +A build-file like \textit{build.xml} contains one project and at least one (default) target. Targets contain task elements. Each task element of the build-file can have an id attribute and can later be referred to by the value supplied to this. So the id has to be unique. Such targets can be "run", "debug", "build", ... and can have dependencies to other targets. Tasks define what should happen, if a target is executed. So like in the example above, the target is \textit{pre-jar}, that means that this things will happen before the jar-package is packed. The tasks of this target are copying some files into the package.\\
   2.390 +The files inside the \textit{nbproject}-folder are not so important because some of it are generated from \textit{build.xml} and changes in this files are useless. Just the file project.properties is really interesting because this file gives a nice and tight overview about the project settings.
   2.391  
   2.392  \subsection{Use interfaces between Java and Scala}\label{java-scala}
   2.393 -     how are data exchanged between Scala and Java ...
   2.394 -
   2.395 +%     how are data exchanged between Scala and Java ...
   2.396 +jEdit is completely written in Java and the required plugin(s) for Isac will be coded in Scala - so there must be ways to exchange data between Java and Scala. One way is to connect this two worlds with the in 4.2 described XML-files. Here you need to use a third type of code to get an interface between Java and Scala code. But there is also a way to get a direct connection.\\
   2.397 +This link should be shown on the graphic-library \textit{Swing}. In both languages it is possible to use Swing which provides a lot of different shapes and useful functionality. So there is a Java-Swing and also a Scala-Swing-library. Now it is interesting to examine the connection between this two libraries.\\
   2.398 +In Scala a direct use of Java-Libs (like Java-Swing) is possible. So if you are Java-Programmer and want to use Java-Swing in Scala, you can simply type \textit{import javax.swing.JButton} to work with a Java-button. But you can also use the Scala-equivalent \textit{scala.swing.Button}. This two button-types will provide nearly the same functionality.\\So what is the idea of creating a nearly similar library a second time? Why have the Scala-developers done such extra work? The answer is, that they have tried to improve and simplify the usage of the Swing-library(and many other libs too!). So big parts of this Scala-Libraries are just Wrapper-objects, Wrapper-Classes and Wrapper-Methods of already existing parts in Java-Libraries. Needless to say that they also added new useful shapes and functionality.\\
   2.399 +But there is one important question left: Is it possible to mix Scala- and Java-objects? And yes, it is possible. There is a really easy way to convert a Scala-object to the Java-equivalent:
   2.400 +\begin{enumerate}
   2.401 +\item \textit{import javax.swing.JButton}
   2.402 +\item \textit{import scala.swing.Button}
   2.403 +\item \textit{var b: scala.swing.Button}
   2.404 +\item \textit{var jb: javax.swing.JButton}
   2.405 +\item \textit{jb = b.peer}
   2.406 +\end{enumerate}
   2.407 +As the example above illustrates, a conversion of Scala- to Java-objects is possible. It looks easy but also a little bit useless. Why should you need this? Just imagine that there is a Plugin written in Scala and one coded in Java. With this connection between Scala and Java, it would be easy to connect this two Plugins! 
   2.408 +%Diesen direkten Zusammenhang zwischen Java und Scala soll anhand der Grafik-Bibliotheken Swing. Beide Sprachen stellen diese Grafik-Bibliotheken zur Verfügung (und darin auch eigene Shapes und Funktionalität). Es ist jedoch möglich, Java-Bibliotheken, wie eben auch Java-Swing in Scala zu verwenden. Ein JButton kann zum Beispiel mittels \textit{import javax.swing.JButton} eingebunden und damit sofort auch verwendet werden. Auch Scala stellt in seiner Swing-Bibliothek zur Verfügung: \textit{scala.swing.Button}. Es wird nahezu die selbe Funktionalität angeboten und teilweise die Erzeugung bzw. Verwendung vereinfacht(???). Man kann sich nun fragen, warum sich die Scala-Entwickler einerseit die Mühe gemacht haben die Verwendung Java-Swing, wie in Java selbst, möglich zu machen und andererseits mit Scala-Swing eine nahezu idente Alternative geschaffen haben. Die Antwort darauf zeigt wie der objektorientierte Teil von Scala in vielen Bereichen aufgebaut wurden. Es wurde kein neues Konzept für diese Grafikklassen entworfen sondern Wrapper-Objekte/Methoden/Klassen erstellt, die das Arbeiten mit diesen Grafikkomponenten erleichtern soll. Ein Letztes Problem bleibt noch: Es ist zwar sehr einfach ein Java-Swing-Objekt an einen Scala-Swing-Container (zb. Frame) anzubinden, da eine Konvertierung von Java-Komponente in ein Scala-Äquivalent ist problemlos möglich. ...
   2.409 +http://www.scala-lang.org/api/current/scala/swing/Button.html\\
   2.410 +http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/JButton.html
   2.411  
   2.412  \section{Conclusion and future work}
   2.413  
     3.1 Binary file doc-src/isac/fig/coqide.png has changed
     4.1 Binary file doc-src/isac/fig/pgisabelle.png has changed