test/Tools/isac/ADDTESTS/course/phst11/T1_Basics.thy
author wneuper <Walther.Neuper@jku.at>
Wed, 11 Jan 2023 11:38:01 +0100
changeset 60650 06ec8abfd3bc
parent 60424 c3acf9c442ac
child 60663 2197e3597cba
permissions -rw-r--r--
eliminate use of Thy_Info 12: TermC partially
neuper@38067
     1
(*
neuper@38077
     2
/usr/local/Isabelle/bin/isabelle jedit -l Isac T1_Basics.thy &
neuper@38077
     3
####.####.####.####.####.####.####.####.####.####.####.####.####.####.####.####.
neuper@38077
     4
0         1         2         3         4         5         6         7         8
neuper@38067
     5
*)
neuper@38067
     6
wneuper@59592
     7
theory T1_Basics imports Isac.Isac_Knowledge
wneuper@59460
     8
begin
neuper@38067
     9
wneuper@59472
    10
chapter \<open>Basics on Linux, Isabelle and ISAC\<close>
neuper@38067
    11
wneuper@59472
    12
text \<open>This is an Isabelle/Isar theory, that means: in between the text there 
neuper@38077
    13
  are parts which can be evaluated by the theorem prover Isabelle, if installed 
neuper@38077
    14
  properly.
neuper@38067
    15
neuper@38077
    16
  The goal of the course beginning with this theory is to give a quick 
neuper@38077
    17
  introduction to authoring the mathematics knowledge for the math assistant 
neuper@38077
    18
  ISAC www.ist.tugraz.at/projects/isac.
neuper@38067
    19
neuper@38077
    20
  The course is self-contained for mathematics teachers, and probably for 
neuper@38077
    21
  interested students.
wneuper@59472
    22
\<close>
neuper@38067
    23
wneuper@59472
    24
section \<open>Linux\<close>
wneuper@59472
    25
text \<open>Isabelle is a computer theorem prover (CTP) under ongoing development. 
neuper@38077
    26
  This development is done using Linux. However, now Isabelle supports cygwin 
neuper@38077
    27
  and thus also can be run on Microsoft Windows.
neuper@38067
    28
neuper@38077
    29
  ISAC uses Isabelle as 'logical operating system'. You get both, ISAC and 
neuper@38077
    30
  Isabelle installed into cygwin on an USB-stick at the beginning of the course.
neuper@38067
    31
neuper@38077
    32
  Authoring mathematics knowledge for ISAC (for instance, extending) requires 
neuper@38077
    33
  basics in handling Linux (cygwin is Linux-like). Please note that ISAC is an 
neuper@38077
    34
  experimental system and as such usability in authoring has not yet been considered.
neuper@38067
    35
neuper@38077
    36
  Having started cygwin you see a prompt '$' at the beginning of a line where 
neuper@38077
    37
  you can input commands ('#' is the begin of a comment not interpreted by 
neuper@38077
    38
  cygwin), for instance:
neuper@38067
    39
  \begin{itemize}
neuper@38067
    40
  \item $ cd /usr/local/Isabelle             # changes to directory of Isabelle
neuper@38067
    41
  \item $ ls -l                              # lists all files and subdirectories
neuper@38067
    42
  \item $ cd test/Tools/isac/ADDTESTS/course # go on to start the course
neuper@38077
    43
  \item $ /usr/local/Isabelle/bin/isabelle jedit -l Isac T1_Basics.thy &
neuper@38067
    44
  \item $                                    # starts the first exercise
neuper@38067
    45
  \end{itemize}
neuper@38067
    46
neuper@38077
    47
  The arguments required for starting the first exercise tell about the 
neuper@38077
    48
  underlying technology:
neuper@38067
    49
  \begin{itemize}
neuper@38067
    50
  \item $ \emph{jedit} is the editor to be used. jEdit www.jedit.org will be introduced to 
neuper@38077
    51
          Isabelle-users within the next few years (so we are front-of-the-wave ;-).
neuper@38067
    52
  \item $ \emph{-l Isac} loads all functionality and knowledge of ISAC
neuper@38067
    53
  \item $ \emph{T1_Basics.thy} is the file name of the first exercise
neuper@38067
    54
  \item $ \emph{&} allows to use the same command line for further commands.
neuper@38067
    55
  \end{itemize}
neuper@38067
    56
neuper@38077
    57
  Since paths are long, we abbreviate '/usr/local/Isabelle/' to '~~' below.
wneuper@59472
    58
\<close>
neuper@38067
    59
wneuper@59472
    60
section \<open>Isabelle terms\<close>
wneuper@59472
    61
text \<open>The most basic kind of data required for mathematics are terms. 
neuper@38077
    62
  ISAC uses Isabelle's terms.
neuper@38077
    63
  In order to allow for 'symbolic computation' terms require representation in 
neuper@38077
    64
  an  appropriate data structure, which is defined at ~~/src/Pure/term.ML
neuper@38077
    65
  ().
neuper@38067
    66
neuper@38067
    67
  Let us give an example:
wneuper@59472
    68
\<close>
wneuper@59472
    69
ML \<open>@{term "a + b * 9"}\<close>
neuper@38067
    70
wneuper@59472
    71
text \<open>In the 'Output' window below you see what the above command produces, 
neuper@38077
    72
  the internal representation of "a + b * 3". The '...' indicate that some 
neuper@38077
    73
  details are still hidden; further details are received this way:
wneuper@59472
    74
\<close>
wneuper@59472
    75
ML \<open>(*default_print_depth 99;*) @{term "a + b * 9"}; (*default_print_depth 5;*)
wneuper@59472
    76
\<close>
wneuper@59472
    77
text \<open>The internal representation is too comprehensive for several kinds of 
neuper@38077
    78
  inspection. Thus ISAC provides additional features, as we see below. First 
neuper@38077
    79
  let us store the term in a variable 't':
wneuper@59472
    80
\<close>
wneuper@59472
    81
ML \<open>
neuper@38067
    82
  val t = @{term "a + b * 9"};
Walther@60650
    83
  TermC.atom_write_detail @{context} t;
wneuper@59472
    84
\<close>
wneuper@59472
    85
text \<open>Please, observe that in this case (whenever 'writeln' is involved, even 
neuper@38077
    86
  invisibly) the output of 'atomwy t' is placed on top of the 'Output' window.
neuper@38067
    87
neuper@38077
    88
  Presently, ISAC uses a slightly different representation for terms (which soon
neuper@38077
    89
  will disappear), which does not encode numerals as binary numbers:
wneuper@59472
    90
\<close>
Walther@60424
    91
ML \<open>
Walther@60424
    92
  val t = TermC.parseNEW' (ThyC.id_to_ctxt "Isac_Knowledge") "a + b * 3";
wneuper@59472
    93
\<close>
wneuper@59472
    94
text \<open>From the above we see: the internal representation of a term contains 
neuper@38077
    95
  all the knowledge it is built from, see
neuper@38067
    96
  http://isabelle.in.tum.de/dist/library/HOL/Groups.html for the definitions
neuper@38067
    97
  \begin{itemize}
neuper@38067
    98
  \item plus  :: "'a => 'a => 'a"  (infixl "+" 65)
neuper@38067
    99
  \item times :: "'a => 'a => 'a"  (infixl "*" 70)
neuper@38067
   100
  \end{itemize}
neuper@38067
   101
  together with relevant theorems about + and *.
neuper@38067
   102
  
neuper@38077
   103
  In the near future you will just click in order to get the requested knowledge.
neuper@38077
   104
  (The present experimental state of Isabelle/jEdit already shows the signature 
neuper@38077
   105
  of the function under the cursor, if kept on place for a second.)
wneuper@59472
   106
\<close>
neuper@38067
   107
wneuper@59472
   108
section \<open>Isabelle theories\<close>
wneuper@59472
   109
text \<open>As just mentioned, (almost) all the math knowledge used in a theorem 
neuper@38077
   110
  prover is explicitly defined (and not built into the code like in a CAS). The 
neuper@38077
   111
  knowledge is organised in \emph{theories}.
neuper@38067
   112
neuper@38067
   113
  Without these theories Isabelle cannot do any thing, it even does not understand '+' or '*'.
neuper@38067
   114
  For instance, in the theory 'HOL' (short for high order logic) even more basic knowledge is 
neuper@38067
   115
  defined ('=' etc), but not yet '+' and '*', so you get 'NONE':
wneuper@59472
   116
\<close>
Walther@60424
   117
ML \<open>
Walther@60424
   118
  val t = TermC.parseNEW' (ThyC.id_to_ctxt "Isac_Knowledge") "a + b * 3";
wneuper@59472
   119
\<close>
wneuper@59472
   120
text \<open>ISAC uses comparatively few definitions and theorems from Isabelle, see 
neuper@38067
   121
  \begin{itemize}
neuper@38067
   122
  \item http://www.ist.tugraz.at/projects/isac/www/kbase/thy/index_thy.html
neuper@38067
   123
  \end{itemize}
neuper@38067
   124
  We call this the dimension of 'deductive knowledge'.
neuper@38067
   125
neuper@38067
   126
  \bigskip However, ISAC provides two additional dimensions of knowledge, 'application
neuper@38067
   127
  oriented knowledge' (simply called \emph{problems}) and 'algorithmic knowledge' 
neuper@38067
   128
  (simply called \emph{methods}); See
neuper@38067
   129
  \begin{itemize}
neuper@38067
   130
  \item problems http://www.ist.tugraz.at/projects/isac/www/kbase/pbl/index_pbl.html
neuper@38067
   131
  \item methods http://www.ist.tugraz.at/projects/isac/www/kbase/met/index_met.html
neuper@38067
   132
  \end{itemize}
neuper@38067
   133
neuper@38067
   134
  \bigskip The three dimensions of knowledge together provide all what a 
neuper@38067
   135
  \emph{mechanized math assistant} like ISAC requires for autonomously solving problems.
neuper@38067
   136
  So, in ISAC too, is (almost) nothing built into the program code, rather, all
neuper@38067
   137
  is up to authoring.
neuper@38067
   138
neuper@38067
   139
  This coures intends to provide basic knowledge for authoring new examples in ISAC.
wneuper@59472
   140
\<close>
neuper@38067
   141
end