doc-src/TutorialI/Misc/types.thy
author paulson
Thu, 26 Jul 2001 16:43:02 +0200
changeset 11456 7eb63f63e6c6
parent 11428 332347b9b942
child 11457 279da0358aa9
permissions -rw-r--r--
revisions and indexing
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10788
ea48dd8b0232 *** empty log message ***
nipkow
parents: 9933
diff changeset
     1
(*<*)theory "types" = Main:(*>*)
ea48dd8b0232 *** empty log message ***
nipkow
parents: 9933
diff changeset
     2
types number       = nat
9933
9feb1e0c4cb3 *** empty log message ***
nipkow
parents: 9792
diff changeset
     3
      gate         = "bool \<Rightarrow> bool \<Rightarrow> bool"
9feb1e0c4cb3 *** empty log message ***
nipkow
parents: 9792
diff changeset
     4
      ('a,'b)alist = "('a \<times> 'b)list";
8745
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
     5
11428
332347b9b942 tidying the index
paulson
parents: 10885
diff changeset
     6
text{*\noindent
8745
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
     7
Internally all synonyms are fully expanded.  As a consequence Isabelle's
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
     8
output never contains synonyms.  Their main purpose is to improve the
8771
026f37a86ea7 *** empty log message ***
nipkow
parents: 8745
diff changeset
     9
readability of theories.  Synonyms can be used just like any other
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11428
diff changeset
    10
type.  Here, we declare two constants of type \isa{gate}:
8745
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    11
*}
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    12
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    13
consts nand :: gate
10788
ea48dd8b0232 *** empty log message ***
nipkow
parents: 9933
diff changeset
    14
       xor  :: gate;
8745
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    15
10885
90695f46440b lcp's pass over the book, chapters 1-8
paulson
parents: 10788
diff changeset
    16
subsection{*Constant Definitions*}
8745
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    17
11428
332347b9b942 tidying the index
paulson
parents: 10885
diff changeset
    18
text{*\label{sec:ConstDefinitions}\indexbold{definitions}%
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11428
diff changeset
    19
The constants @{term"nand"} and @{term"xor"} above are non-recursive and can 
7eb63f63e6c6 revisions and indexing
paulson
parents: 11428
diff changeset
    20
be defined directly:
8745
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    21
*}
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    22
9933
9feb1e0c4cb3 *** empty log message ***
nipkow
parents: 9792
diff changeset
    23
defs nand_def: "nand A B \<equiv> \<not>(A \<and> B)"
10788
ea48dd8b0232 *** empty log message ***
nipkow
parents: 9933
diff changeset
    24
     xor_def:  "xor A B  \<equiv> A \<and> \<not>B \<or> \<not>A \<and> B";
8745
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    25
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    26
text{*\noindent%
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11428
diff changeset
    27
Here \commdx{defs} is a keyword and
10788
ea48dd8b0232 *** empty log message ***
nipkow
parents: 9933
diff changeset
    28
@{thm[source]nand_def} and @{thm[source]xor_def} are user-supplied names.
8745
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    29
The symbol \indexboldpos{\isasymequiv}{$IsaEq} is a special form of equality
9541
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 8771
diff changeset
    30
that must be used in constant definitions.
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11428
diff changeset
    31
A \commdx{constdefs} command combines the effects of \isacommand{consts} and 
7eb63f63e6c6 revisions and indexing
paulson
parents: 11428
diff changeset
    32
\isacommand{defs}.  For instance, we can introduce @{term"nand"} and @{term"xor"} by a 
7eb63f63e6c6 revisions and indexing
paulson
parents: 11428
diff changeset
    33
single command: 
8745
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    34
*}
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    35
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    36
constdefs nor :: gate
9933
9feb1e0c4cb3 *** empty log message ***
nipkow
parents: 9792
diff changeset
    37
         "nor A B \<equiv> \<not>(A \<or> B)"
10788
ea48dd8b0232 *** empty log message ***
nipkow
parents: 9933
diff changeset
    38
          xor2 :: gate
ea48dd8b0232 *** empty log message ***
nipkow
parents: 9933
diff changeset
    39
         "xor2 A B \<equiv> (A \<or> B) \<and> (\<not>A \<or> \<not>B)";
8745
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    40
11428
332347b9b942 tidying the index
paulson
parents: 10885
diff changeset
    41
text{*\noindent
332347b9b942 tidying the index
paulson
parents: 10885
diff changeset
    42
The default name of each definition is $f$@{text"_def"}, where
10788
ea48dd8b0232 *** empty log message ***
nipkow
parents: 9933
diff changeset
    43
$f$ is the name of the defined constant.*}
ea48dd8b0232 *** empty log message ***
nipkow
parents: 9933
diff changeset
    44
(*<*)end(*>*)