doc-src/TutorialI/Types/document/Pairs.tex
author berghofe
Fri, 31 Aug 2001 16:30:31 +0200
changeset 11535 7f4c5cdea239
parent 11494 23a118849801
child 11708 d27253c4594f
permissions -rw-r--r--
Added new option for setting level of detail for proof objects.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
     1
%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
     2
\begin{isabellebody}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
     3
\def\isabellecontext{Pairs}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
     4
%
11428
332347b9b942 tidying the index
paulson
parents: 11277
diff changeset
     5
\isamarkupsection{Pairs and Tuples%
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
     6
}
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
     7
%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
     8
\begin{isamarkuptext}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
     9
\label{sec:products}
11428
332347b9b942 tidying the index
paulson
parents: 11277
diff changeset
    10
Ordered pairs were already introduced in \S\ref{sec:pairs}, but only with a minimal
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    11
repertoire of operations: pairing and the two projections \isa{fst} and
11149
e258b536a137 *** empty log message ***
nipkow
parents: 10950
diff changeset
    12
\isa{snd}. In any non-trivial application of pairs you will find that this
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
    13
quickly leads to unreadable nests of projections. This
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
    14
section introduces syntactic sugar to overcome this
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    15
problem: pattern matching with tuples.%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    16
\end{isamarkuptext}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    17
%
10878
b254d5ad6dd4 auto update
paulson
parents: 10824
diff changeset
    18
\isamarkupsubsection{Pattern Matching with Tuples%
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    19
}
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    20
%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    21
\begin{isamarkuptext}%
10878
b254d5ad6dd4 auto update
paulson
parents: 10824
diff changeset
    22
Tuples may be used as patterns in $\lambda$-abstractions,
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    23
for example \isa{{\isasymlambda}{\isacharparenleft}x{\isacharcomma}y{\isacharcomma}z{\isacharparenright}{\isachardot}x{\isacharplus}y{\isacharplus}z} and \isa{{\isasymlambda}{\isacharparenleft}{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}{\isacharcomma}z{\isacharparenright}{\isachardot}x{\isacharplus}y{\isacharplus}z}. In fact,
10878
b254d5ad6dd4 auto update
paulson
parents: 10824
diff changeset
    24
tuple patterns can be used in most variable binding constructs,
b254d5ad6dd4 auto update
paulson
parents: 10824
diff changeset
    25
and they can be nested. Here are
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    26
some typical examples:
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    27
\begin{quote}
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    28
\isa{let\ {\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}\ {\isacharequal}\ f\ z\ in\ {\isacharparenleft}y{\isacharcomma}\ x{\isacharparenright}}\\
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    29
\isa{case\ xs\ of\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymRightarrow}\ {\isadigit{0}}\ {\isacharbar}\ {\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}\ {\isacharhash}\ zs\ {\isasymRightarrow}\ x\ {\isacharplus}\ y}\\
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    30
\isa{{\isasymforall}{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}{\isasymin}A{\isachardot}\ x{\isacharequal}y}\\
10878
b254d5ad6dd4 auto update
paulson
parents: 10824
diff changeset
    31
\isa{{\isacharbraceleft}{\isacharparenleft}x{\isacharcomma}y{\isacharcomma}z{\isacharparenright}{\isachardot}\ x{\isacharequal}z{\isacharbraceright}}\\
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    32
\isa{{\isasymUnion}{\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}{\isasymin}A{\isachardot}\ {\isacharbraceleft}x\ {\isacharplus}\ y{\isacharbraceright}}
11149
e258b536a137 *** empty log message ***
nipkow
parents: 10950
diff changeset
    33
\end{quote}
10878
b254d5ad6dd4 auto update
paulson
parents: 10824
diff changeset
    34
The intuitive meanings of these expressions should be obvious.
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    35
Unfortunately, we need to know in more detail what the notation really stands
10878
b254d5ad6dd4 auto update
paulson
parents: 10824
diff changeset
    36
for once we have to reason about it.  Abstraction
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    37
over pairs and tuples is merely a convenient shorthand for a more complex
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    38
internal representation.  Thus the internal and external form of a term may
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    39
differ, which can affect proofs. If you want to avoid this complication,
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    40
stick to \isa{fst} and \isa{snd} and write \isa{{\isasymlambda}p{\isachardot}\ fst\ p\ {\isacharplus}\ snd\ p}
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
    41
instead of \isa{{\isasymlambda}{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}{\isachardot}\ x{\isacharplus}y}.  These terms are distinct even though they
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
    42
denote the same function.
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    43
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    44
Internally, \isa{{\isasymlambda}{\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}{\isachardot}\ t} becomes \isa{split\ {\isacharparenleft}{\isasymlambda}x\ y{\isachardot}\ t{\isacharparenright}}, where
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
    45
\cdx{split} is the uncurrying function of type \isa{{\isacharparenleft}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}b\ {\isasymRightarrow}\ {\isacharprime}c{\isacharparenright}\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymtimes}\ {\isacharprime}b\ {\isasymRightarrow}\ {\isacharprime}c} defined as
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    46
\begin{center}
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    47
\isa{split\ {\isasymequiv}\ {\isasymlambda}c\ p{\isachardot}\ c\ {\isacharparenleft}fst\ p{\isacharparenright}\ {\isacharparenleft}snd\ p{\isacharparenright}}
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    48
\hfill(\isa{split{\isacharunderscore}def})
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    49
\end{center}
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    50
Pattern matching in
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    51
other variable binding constructs is translated similarly. Thus we need to
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    52
understand how to reason about such constructs.%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    53
\end{isamarkuptext}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    54
%
10878
b254d5ad6dd4 auto update
paulson
parents: 10824
diff changeset
    55
\isamarkupsubsection{Theorem Proving%
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    56
}
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    57
%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    58
\begin{isamarkuptext}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    59
The most obvious approach is the brute force expansion of \isa{split}:%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    60
\end{isamarkuptext}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    61
\isacommand{lemma}\ {\isachardoublequote}{\isacharparenleft}{\isasymlambda}{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}{\isachardot}x{\isacharparenright}\ p\ {\isacharequal}\ fst\ p{\isachardoublequote}\isanewline
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    62
\isacommand{by}{\isacharparenleft}simp\ add{\isacharcolon}split{\isacharunderscore}def{\isacharparenright}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    63
\begin{isamarkuptext}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    64
This works well if rewriting with \isa{split{\isacharunderscore}def} finishes the
11149
e258b536a137 *** empty log message ***
nipkow
parents: 10950
diff changeset
    65
proof, as it does above.  But if it does not, you end up with exactly what
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    66
we are trying to avoid: nests of \isa{fst} and \isa{snd}. Thus this
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    67
approach is neither elegant nor very practical in large examples, although it
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    68
can be effective in small ones.
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    69
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
    70
If we consider why this lemma presents a problem, 
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
    71
we quickly realize that we need to replace the variable~\isa{p} by some pair \isa{{\isacharparenleft}a{\isacharcomma}\ b{\isacharparenright}}.  Then both sides of the
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
    72
equation would simplify to \isa{a} by the simplification rules
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
    73
\isa{split\ c\ {\isacharparenleft}a{\isacharcomma}\ b{\isacharparenright}\ {\isacharequal}\ c\ a\ b} and \isa{fst\ {\isacharparenleft}a{\isacharcomma}\ b{\isacharparenright}\ {\isacharequal}\ a}.  
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
    74
To reason about tuple patterns requires some way of
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
    75
converting a variable of product type into a pair.
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    76
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    77
In case of a subterm of the form \isa{split\ f\ p} this is easy: the split
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    78
rule \isa{split{\isacharunderscore}split} replaces \isa{p} by a pair:%
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
    79
\index{*split (method)}%
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    80
\end{isamarkuptext}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    81
\isacommand{lemma}\ {\isachardoublequote}{\isacharparenleft}{\isasymlambda}{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}{\isachardot}y{\isacharparenright}\ p\ {\isacharequal}\ snd\ p{\isachardoublequote}\isanewline
10654
458068404143 *** empty log message ***
nipkow
parents: 10608
diff changeset
    82
\isacommand{apply}{\isacharparenleft}split\ split{\isacharunderscore}split{\isacharparenright}%
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    83
\begin{isamarkuptxt}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    84
\begin{isabelle}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    85
\ {\isadigit{1}}{\isachardot}\ {\isasymforall}x\ y{\isachardot}\ p\ {\isacharequal}\ {\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}\ {\isasymlongrightarrow}\ y\ {\isacharequal}\ snd\ p%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    86
\end{isabelle}
10824
4a212e635318 *** empty log message ***
nipkow
parents: 10654
diff changeset
    87
This subgoal is easily proved by simplification. Thus we could have combined
4a212e635318 *** empty log message ***
nipkow
parents: 10654
diff changeset
    88
simplification and splitting in one command that proves the goal outright:%
4a212e635318 *** empty log message ***
nipkow
parents: 10654
diff changeset
    89
\end{isamarkuptxt}%
4a212e635318 *** empty log message ***
nipkow
parents: 10654
diff changeset
    90
\isacommand{by}{\isacharparenleft}simp\ split{\isacharcolon}\ split{\isacharunderscore}split{\isacharparenright}%
4a212e635318 *** empty log message ***
nipkow
parents: 10654
diff changeset
    91
\begin{isamarkuptext}%
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    92
Let us look at a second example:%
10824
4a212e635318 *** empty log message ***
nipkow
parents: 10654
diff changeset
    93
\end{isamarkuptext}%
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    94
\isacommand{lemma}\ {\isachardoublequote}let\ {\isacharparenleft}x{\isacharcomma}y{\isacharparenright}\ {\isacharequal}\ p\ in\ fst\ p\ {\isacharequal}\ x{\isachardoublequote}\isanewline
10824
4a212e635318 *** empty log message ***
nipkow
parents: 10654
diff changeset
    95
\isacommand{apply}{\isacharparenleft}simp\ only{\isacharcolon}\ Let{\isacharunderscore}def{\isacharparenright}%
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    96
\begin{isamarkuptxt}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    97
\begin{isabelle}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    98
\ {\isadigit{1}}{\isachardot}\ {\isacharparenleft}{\isasymlambda}{\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}{\isachardot}\ fst\ p\ {\isacharequal}\ x{\isacharparenright}\ p%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
    99
\end{isabelle}
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   100
A paired \isa{let} reduces to a paired $\lambda$-abstraction, which
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   101
can be split as above. The same is true for paired set comprehension:%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   102
\end{isamarkuptxt}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   103
\isacommand{lemma}\ {\isachardoublequote}p\ {\isasymin}\ {\isacharbraceleft}{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}{\isachardot}\ x{\isacharequal}y{\isacharbraceright}\ {\isasymlongrightarrow}\ fst\ p\ {\isacharequal}\ snd\ p{\isachardoublequote}\isanewline
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   104
\isacommand{apply}\ simp%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   105
\begin{isamarkuptxt}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   106
\begin{isabelle}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   107
\ {\isadigit{1}}{\isachardot}\ split\ op\ {\isacharequal}\ p\ {\isasymlongrightarrow}\ fst\ p\ {\isacharequal}\ snd\ p%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   108
\end{isabelle}
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   109
Again, simplification produces a term suitable for \isa{split{\isacharunderscore}split}
11277
a2bff98d6e5d *** empty log message ***
nipkow
parents: 11161
diff changeset
   110
as above. If you are worried about the strange form of the premise:
a2bff98d6e5d *** empty log message ***
nipkow
parents: 11161
diff changeset
   111
\isa{split\ op\ {\isacharequal}} is short for \isa{{\isasymlambda}{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}{\isachardot}\ x{\isacharequal}y}.
a2bff98d6e5d *** empty log message ***
nipkow
parents: 11161
diff changeset
   112
The same proof procedure works for%
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   113
\end{isamarkuptxt}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   114
\isacommand{lemma}\ {\isachardoublequote}p\ {\isasymin}\ {\isacharbraceleft}{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}{\isachardot}\ x{\isacharequal}y{\isacharbraceright}\ {\isasymLongrightarrow}\ fst\ p\ {\isacharequal}\ snd\ p{\isachardoublequote}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   115
\begin{isamarkuptxt}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   116
\noindent
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   117
except that we now have to use \isa{split{\isacharunderscore}split{\isacharunderscore}asm}, because
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   118
\isa{split} occurs in the assumptions.
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   119
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   120
However, splitting \isa{split} is not always a solution, as no \isa{split}
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   121
may be present in the goal. Consider the following function:%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   122
\end{isamarkuptxt}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   123
\isacommand{consts}\ swap\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isasymtimes}\ {\isacharprime}b\ {\isasymRightarrow}\ {\isacharprime}b\ {\isasymtimes}\ {\isacharprime}a{\isachardoublequote}\isanewline
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   124
\isacommand{primrec}\isanewline
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   125
\ \ {\isachardoublequote}swap\ {\isacharparenleft}x{\isacharcomma}y{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}y{\isacharcomma}x{\isacharparenright}{\isachardoublequote}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   126
\begin{isamarkuptext}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   127
\noindent
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   128
Note that the above \isacommand{primrec} definition is admissible
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   129
because \isa{{\isasymtimes}} is a datatype. When we now try to prove%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   130
\end{isamarkuptext}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   131
\isacommand{lemma}\ {\isachardoublequote}swap{\isacharparenleft}swap\ p{\isacharparenright}\ {\isacharequal}\ p{\isachardoublequote}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   132
\begin{isamarkuptxt}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   133
\noindent
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   134
simplification will do nothing, because the defining equation for \isa{swap}
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   135
expects a pair. Again, we need to turn \isa{p} into a pair first, but this
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   136
time there is no \isa{split} in sight. In this case the only thing we can do
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   137
is to split the term by hand:%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   138
\end{isamarkuptxt}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   139
\isacommand{apply}{\isacharparenleft}case{\isacharunderscore}tac\ p{\isacharparenright}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   140
\begin{isamarkuptxt}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   141
\noindent
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   142
\begin{isabelle}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   143
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}a\ b{\isachardot}\ p\ {\isacharequal}\ {\isacharparenleft}a{\isacharcomma}\ b{\isacharparenright}\ {\isasymLongrightarrow}\ swap\ {\isacharparenleft}swap\ p{\isacharparenright}\ {\isacharequal}\ p%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   144
\end{isabelle}
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   145
Again, \methdx{case_tac} is applicable because \isa{{\isasymtimes}} is a datatype.
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   146
The subgoal is easily proved by \isa{simp}.
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   147
10824
4a212e635318 *** empty log message ***
nipkow
parents: 10654
diff changeset
   148
Splitting by \isa{case{\isacharunderscore}tac} also solves the previous examples and may thus
4a212e635318 *** empty log message ***
nipkow
parents: 10654
diff changeset
   149
appear preferable to the more arcane methods introduced first. However, see
4a212e635318 *** empty log message ***
nipkow
parents: 10654
diff changeset
   150
the warning about \isa{case{\isacharunderscore}tac} in \S\ref{sec:struct-ind-case}.
4a212e635318 *** empty log message ***
nipkow
parents: 10654
diff changeset
   151
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   152
In case the term to be split is a quantified variable, there are more options.
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   153
You can split \emph{all} \isa{{\isasymAnd}}-quantified variables in a goal
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   154
with the rewrite rule \isa{split{\isacharunderscore}paired{\isacharunderscore}all}:%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   155
\end{isamarkuptxt}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   156
\isacommand{lemma}\ {\isachardoublequote}{\isasymAnd}p\ q{\isachardot}\ swap{\isacharparenleft}swap\ p{\isacharparenright}\ {\isacharequal}\ q\ {\isasymlongrightarrow}\ p\ {\isacharequal}\ q{\isachardoublequote}\isanewline
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   157
\isacommand{apply}{\isacharparenleft}simp\ only{\isacharcolon}split{\isacharunderscore}paired{\isacharunderscore}all{\isacharparenright}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   158
\begin{isamarkuptxt}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   159
\noindent
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   160
\begin{isabelle}%
10577
b9c290f0343d auto update
paulson
parents: 10560
diff changeset
   161
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}a\ b\ aa\ ba{\isachardot}\isanewline
10950
aa788fcb75a5 updated;
wenzelm
parents: 10878
diff changeset
   162
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ }swap\ {\isacharparenleft}swap\ {\isacharparenleft}a{\isacharcomma}\ b{\isacharparenright}{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}aa{\isacharcomma}\ ba{\isacharparenright}\ {\isasymlongrightarrow}\ {\isacharparenleft}a{\isacharcomma}\ b{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}aa{\isacharcomma}\ ba{\isacharparenright}%
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   163
\end{isabelle}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   164
\end{isamarkuptxt}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   165
\isacommand{apply}\ simp\isanewline
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   166
\isacommand{done}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   167
\begin{isamarkuptext}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   168
\noindent
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   169
Note that we have intentionally included only \isa{split{\isacharunderscore}paired{\isacharunderscore}all}
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   170
in the first simplification step, and then we simplify again. 
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   171
This time the reason was not merely
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   172
pedagogical:
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   173
\isa{split{\isacharunderscore}paired{\isacharunderscore}all} may interfere with other functions
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   174
of the simplifier.
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   175
The following command could fail (here it does not)
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   176
where two separate \isa{simp} applications succeed.%
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   177
\end{isamarkuptext}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   178
\isacommand{apply}{\isacharparenleft}simp\ add{\isacharcolon}split{\isacharunderscore}paired{\isacharunderscore}all{\isacharparenright}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   179
\begin{isamarkuptext}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   180
\noindent
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   181
Finally, the simplifier automatically splits all \isa{{\isasymforall}} and
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   182
\isa{{\isasymexists}}-quantified variables:%
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   183
\end{isamarkuptext}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   184
\isacommand{lemma}\ {\isachardoublequote}{\isasymforall}p{\isachardot}\ {\isasymexists}q{\isachardot}\ swap\ p\ {\isacharequal}\ swap\ q{\isachardoublequote}\isanewline
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   185
\isacommand{by}\ simp%
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   186
\begin{isamarkuptext}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   187
\noindent
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   188
To turn off this automatic splitting, just disable the
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   189
responsible simplification rules:
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   190
\begin{center}
10654
458068404143 *** empty log message ***
nipkow
parents: 10608
diff changeset
   191
\isa{{\isacharparenleft}{\isasymforall}x{\isachardot}\ P\ x{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}{\isasymforall}a\ b{\isachardot}\ P\ {\isacharparenleft}a{\isacharcomma}\ b{\isacharparenright}{\isacharparenright}}
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   192
\hfill
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   193
(\isa{split{\isacharunderscore}paired{\isacharunderscore}All})\\
10654
458068404143 *** empty log message ***
nipkow
parents: 10608
diff changeset
   194
\isa{{\isacharparenleft}{\isasymexists}x{\isachardot}\ P\ x{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}{\isasymexists}a\ b{\isachardot}\ P\ {\isacharparenleft}a{\isacharcomma}\ b{\isacharparenright}{\isacharparenright}}
10560
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   195
\hfill
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   196
(\isa{split{\isacharunderscore}paired{\isacharunderscore}Ex})
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   197
\end{center}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   198
\end{isamarkuptext}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   199
\end{isabellebody}%
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   200
%%% Local Variables:
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   201
%%% mode: latex
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   202
%%% TeX-master: "root"
f4da791d4850 *** empty log message ***
nipkow
parents:
diff changeset
   203
%%% End: