doc-src/TutorialI/Misc/def_rewr.thy
author wenzelm
Wed, 09 Aug 2000 20:43:03 +0200
changeset 9561 714ad541a133
parent 8745 13b32661dde4
child 9689 751fde5307e4
permissions -rw-r--r--
thms "atomize";
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8745
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
     1
(*<*)
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
     2
theory def_rewr = Main:;
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
     3
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
     4
(*>*)text{*\noindent Constant definitions (\S\ref{sec:ConstDefinitions}) can
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
     5
be used as simplification rules, but by default they are not.  Hence the
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
     6
simplifier does not expand them automatically, just as it should be:
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
     7
definitions are introduced for the purpose of abbreviating complex
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
     8
concepts. Of course we need to expand the definitions initially to derive
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
     9
enough lemmas that characterize the concept sufficiently for us to forget the
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    10
original definition. For example, given
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
constdefs exor :: "bool \\<Rightarrow> bool \\<Rightarrow> bool"
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    14
         "exor A B \\<equiv> (A \\<and> \\<not>B) \\<or> (\\<not>A \\<and> B)";
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    15
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    16
text{*\noindent
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    17
we may want to prove
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    18
*}
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    19
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    20
lemma "exor A (\\<not>A)";
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    21
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    22
txt{*\noindent
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    23
There is a special method for \emph{unfolding} definitions, which we need to
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    24
get started:\indexbold{*unfold}\indexbold{definition!unfolding}
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    25
*}
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    26
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    27
apply(unfold exor_def);
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    28
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    29
txt{*\noindent
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    30
It unfolds the given list of definitions (here merely one) in all subgoals:
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    31
\begin{isabellepar}%
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    32
~1.~A~{\isasymand}~{\isasymnot}~{\isasymnot}~A~{\isasymor}~{\isasymnot}~A~{\isasymand}~{\isasymnot}~A%
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    33
\end{isabellepar}%
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    34
The resulting goal can be proved by simplification.
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    35
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    36
In case we want to expand a definition in the middle of a proof, we can
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    37
simply include it locally:*}(*<*)oops;lemma "exor A (\\<not>A)";(*>*)
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    38
apply(simp add: exor_def);(*<*).(*>*)
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    39
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    40
text{*\noindent
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    41
In fact, this one command proves the above lemma directly.
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    42
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    43
You should normally not turn a definition permanently into a simplification
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    44
rule because this defeats the whole purpose of an abbreviation.
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    45
*}
13b32661dde4 I wonder which files i forgot.
nipkow
parents:
diff changeset
    46
(*<*)end(*>*)