doc-src/TutorialI/Advanced/document/simp.tex
changeset 10589 b2d1b393b750
parent 10395 7ef380745743
child 10601 894f845c3dbf
equal deleted inserted replaced
10588:3a1755b37757 10589:b2d1b393b750
    26 kind of contextual information can also be made available for other
    26 kind of contextual information can also be made available for other
    27 operators. For example, \isa{xs\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymlongrightarrow}\ xs\ {\isacharat}\ xs\ {\isacharequal}\ xs} simplifies to \isa{True} because we may use \isa{xs\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}} when simplifying \isa{xs\ {\isacharat}\ xs\ {\isacharequal}\ xs}. The generation of contextual information during simplification is
    27 operators. For example, \isa{xs\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymlongrightarrow}\ xs\ {\isacharat}\ xs\ {\isacharequal}\ xs} simplifies to \isa{True} because we may use \isa{xs\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}} when simplifying \isa{xs\ {\isacharat}\ xs\ {\isacharequal}\ xs}. The generation of contextual information during simplification is
    28 controlled by so-called \bfindex{congruence rules}. This is the one for
    28 controlled by so-called \bfindex{congruence rules}. This is the one for
    29 \isa{{\isasymlongrightarrow}}:
    29 \isa{{\isasymlongrightarrow}}:
    30 \begin{isabelle}%
    30 \begin{isabelle}%
    31 \ \ \ \ \ {\isasymlbrakk}P\ {\isacharequal}\ P{\isacharprime}{\isacharsemicolon}\ P{\isacharprime}\ {\isasymLongrightarrow}\ Q\ {\isacharequal}\ Q{\isacharprime}{\isasymrbrakk}\ {\isasymLongrightarrow}\ {\isacharparenleft}P\ {\isasymlongrightarrow}\ Q{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}P{\isacharprime}\ {\isasymlongrightarrow}\ Q{\isacharprime}{\isacharparenright}%
    31 \ \ \ \ \ P\ {\isacharequal}\ P{\isacharprime}\ {\isasymLongrightarrow}\ {\isacharparenleft}P{\isacharprime}\ {\isasymLongrightarrow}\ Q\ {\isacharequal}\ Q{\isacharprime}{\isacharparenright}\ {\isasymLongrightarrow}\ {\isacharparenleft}P\ {\isasymlongrightarrow}\ Q{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}P{\isacharprime}\ {\isasymlongrightarrow}\ Q{\isacharprime}{\isacharparenright}%
    32 \end{isabelle}
    32 \end{isabelle}
    33 It should be read as follows:
    33 It should be read as follows:
    34 In order to simplify \isa{P\ {\isasymlongrightarrow}\ Q} to \isa{P{\isacharprime}\ {\isasymlongrightarrow}\ Q{\isacharprime}},
    34 In order to simplify \isa{P\ {\isasymlongrightarrow}\ Q} to \isa{P{\isacharprime}\ {\isasymlongrightarrow}\ Q{\isacharprime}},
    35 simplify \isa{P} to \isa{P{\isacharprime}}
    35 simplify \isa{P} to \isa{P{\isacharprime}}
    36 and assume \isa{P{\isacharprime}} when simplifying \isa{Q} to \isa{Q{\isacharprime}}.
    36 and assume \isa{P{\isacharprime}} when simplifying \isa{Q} to \isa{Q{\isacharprime}}.
    37 
    37 
    38 Here are some more examples.  The congruence rules for bounded
    38 Here are some more examples.  The congruence rules for bounded
    39 quantifiers supply contextual information about the bound variable:
    39 quantifiers supply contextual information about the bound variable:
    40 \begin{isabelle}%
    40 \begin{isabelle}%
    41 \ \ \ \ \ {\isasymlbrakk}A\ {\isacharequal}\ B{\isacharsemicolon}\ {\isasymAnd}x{\isachardot}\ x\ {\isasymin}\ B\ {\isasymLongrightarrow}\ P\ x\ {\isacharequal}\ Q\ x{\isasymrbrakk}\isanewline
    41 \ \ \ \ \ A\ {\isacharequal}\ B\ {\isasymLongrightarrow}\isanewline
    42 \ \ \ \ \ {\isasymLongrightarrow}\ {\isacharparenleft}{\isasymforall}x{\isasymin}A{\isachardot}\ P\ x{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}{\isasymforall}x{\isasymin}B{\isachardot}\ Q\ x{\isacharparenright}%
    42 \ \ \ \ \ {\isacharparenleft}{\isasymAnd}x{\isachardot}\ x\ {\isasymin}\ B\ {\isasymLongrightarrow}\ P\ x\ {\isacharequal}\ Q\ x{\isacharparenright}\ {\isasymLongrightarrow}\ {\isacharparenleft}{\isasymforall}x{\isasymin}A{\isachardot}\ P\ x{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}{\isasymforall}x{\isasymin}B{\isachardot}\ Q\ x{\isacharparenright}%
    43 \end{isabelle}
    43 \end{isabelle}
    44 The congruence rule for conditional expressions supply contextual
    44 The congruence rule for conditional expressions supply contextual
    45 information for simplifying the arms:
    45 information for simplifying the arms:
    46 \begin{isabelle}%
    46 \begin{isabelle}%
    47 \ \ \ \ \ {\isasymlbrakk}b\ {\isacharequal}\ c{\isacharsemicolon}\ c\ {\isasymLongrightarrow}\ x\ {\isacharequal}\ u{\isacharsemicolon}\ {\isasymnot}\ c\ {\isasymLongrightarrow}\ y\ {\isacharequal}\ v{\isasymrbrakk}\isanewline
    47 \ \ \ \ \ b\ {\isacharequal}\ c\ {\isasymLongrightarrow}\isanewline
    48 \ \ \ \ \ {\isasymLongrightarrow}\ {\isacharparenleft}if\ b\ then\ x\ else\ y{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}if\ c\ then\ u\ else\ v{\isacharparenright}%
    48 \ \ \ \ \ {\isacharparenleft}c\ {\isasymLongrightarrow}\ x\ {\isacharequal}\ u{\isacharparenright}\ {\isasymLongrightarrow}\isanewline
       
    49 \ \ \ \ \ {\isacharparenleft}{\isasymnot}\ c\ {\isasymLongrightarrow}\ y\ {\isacharequal}\ v{\isacharparenright}\ {\isasymLongrightarrow}\ {\isacharparenleft}if\ b\ then\ x\ else\ y{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}if\ c\ then\ u\ else\ v{\isacharparenright}%
    49 \end{isabelle}
    50 \end{isabelle}
    50 A congruence rule can also \emph{prevent} simplification of some arguments.
    51 A congruence rule can also \emph{prevent} simplification of some arguments.
    51 Here is an alternative congruence rule for conditional expressions:
    52 Here is an alternative congruence rule for conditional expressions:
    52 \begin{isabelle}%
    53 \begin{isabelle}%
    53 \ \ \ \ \ b\ {\isacharequal}\ c\ {\isasymLongrightarrow}\ {\isacharparenleft}if\ b\ then\ x\ else\ y{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}if\ c\ then\ x\ else\ y{\isacharparenright}%
    54 \ \ \ \ \ b\ {\isacharequal}\ c\ {\isasymLongrightarrow}\ {\isacharparenleft}if\ b\ then\ x\ else\ y{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}if\ c\ then\ x\ else\ y{\isacharparenright}%
    70 The effect is reversed by \isa{cong\ del} instead of \isa{cong}.
    71 The effect is reversed by \isa{cong\ del} instead of \isa{cong}.
    71 
    72 
    72 \begin{warn}
    73 \begin{warn}
    73 The congruence rule \isa{conj{\isacharunderscore}cong}
    74 The congruence rule \isa{conj{\isacharunderscore}cong}
    74 \begin{isabelle}%
    75 \begin{isabelle}%
    75 \ \ \ \ \ {\isasymlbrakk}P\ {\isacharequal}\ P{\isacharprime}{\isacharsemicolon}\ P{\isacharprime}\ {\isasymLongrightarrow}\ Q\ {\isacharequal}\ Q{\isacharprime}{\isasymrbrakk}\ {\isasymLongrightarrow}\ {\isacharparenleft}P\ {\isasymand}\ Q{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}P{\isacharprime}\ {\isasymand}\ Q{\isacharprime}{\isacharparenright}%
    76 \ \ \ \ \ P\ {\isacharequal}\ P{\isacharprime}\ {\isasymLongrightarrow}\ {\isacharparenleft}P{\isacharprime}\ {\isasymLongrightarrow}\ Q\ {\isacharequal}\ Q{\isacharprime}{\isacharparenright}\ {\isasymLongrightarrow}\ {\isacharparenleft}P\ {\isasymand}\ Q{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}P{\isacharprime}\ {\isasymand}\ Q{\isacharprime}{\isacharparenright}%
    76 \end{isabelle}
    77 \end{isabelle}
    77 is occasionally useful but not a default rule; you have to use it explicitly.
    78 is occasionally useful but not a default rule; you have to use it explicitly.
    78 \end{warn}%
    79 \end{warn}%
    79 \end{isamarkuptext}%
    80 \end{isamarkuptext}%
    80 %
    81 %