doc-src/Exercises/2002/a1/generated/a1.tex
author kleing
Sat, 01 Mar 2003 16:57:32 +0100
changeset 13841 ed4e97874454
child 13844 44f741cdcea3
permissions -rw-r--r--
keep a copy of generated files in repository
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13841
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     1
%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     2
\begin{isabellebody}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     3
\def\isabellecontext{a{\isadigit{1}}}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     4
\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     5
%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     6
\isamarkupsubsection{Lists%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     7
}
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     8
\isamarkuptrue%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     9
%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    10
\begin{isamarkuptext}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    11
Define a universal and an existential quantifier on lists.
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    12
Expression \isa{alls\ P\ xs} should be true iff \isa{P\ x} holds
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    13
for every element \isa{x} of \isa{xs}, and \isa{exs\ P\ xs}
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    14
should be true iff \isa{P\ x} holds for some element \isa{x} of
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    15
\isa{xs}.%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    16
\end{isamarkuptext}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    17
\isamarkuptrue%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    18
\isacommand{consts}\ \isanewline
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    19
\ \ alls\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}{\isacharprime}a\ {\isasymRightarrow}\ bool{\isacharparenright}\ {\isasymRightarrow}\ {\isacharprime}a\ list\ {\isasymRightarrow}\ bool{\isachardoublequote}\isanewline
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    20
\ \ exs\ \ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}{\isacharprime}a\ {\isasymRightarrow}\ bool{\isacharparenright}\ {\isasymRightarrow}\ {\isacharprime}a\ list\ {\isasymRightarrow}\ bool{\isachardoublequote}\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    21
%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    22
\begin{isamarkuptext}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    23
Prove or disprove (by counter example) the following theorems.
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    24
You may have to prove some lemmas first.
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    25
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    26
Use the \isa{{\isacharbrackleft}simp{\isacharbrackright}}-attribute only if the equation is truly a
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    27
simplification and is necessary for some later proof.%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    28
\end{isamarkuptext}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    29
\isamarkuptrue%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    30
\isacommand{lemma}\ {\isachardoublequote}alls\ {\isacharparenleft}{\isasymlambda}x{\isachardot}\ P\ x\ {\isasymand}\ Q\ x{\isacharparenright}\ xs\ {\isacharequal}\ {\isacharparenleft}alls\ P\ xs\ {\isasymand}\ alls\ Q\ xs{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    31
\isanewline
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    32
\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    33
\isacommand{lemma}\ {\isachardoublequote}alls\ P\ {\isacharparenleft}rev\ xs{\isacharparenright}\ {\isacharequal}\ alls\ P\ xs{\isachardoublequote}\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    34
\isanewline
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    35
\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    36
\isacommand{lemma}\ {\isachardoublequote}exs\ {\isacharparenleft}{\isasymlambda}x{\isachardot}\ P\ x\ {\isasymand}\ Q\ x{\isacharparenright}\ xs\ {\isacharequal}\ {\isacharparenleft}exs\ P\ xs\ {\isasymand}\ exs\ Q\ xs{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    37
\isanewline
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    38
\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    39
\isacommand{lemma}\ {\isachardoublequote}exs\ P\ {\isacharparenleft}map\ f\ xs{\isacharparenright}\ {\isacharequal}\ exs\ {\isacharparenleft}P\ o\ f{\isacharparenright}\ xs{\isachardoublequote}\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    40
\isanewline
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    41
\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    42
\isacommand{lemma}\ {\isachardoublequote}exs\ P\ {\isacharparenleft}rev\ xs{\isacharparenright}\ {\isacharequal}\ exs\ P\ xs{\isachardoublequote}\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    43
\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    44
%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    45
\begin{isamarkuptext}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    46
Find a term \isa{Z} such that the following equation holds:%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    47
\end{isamarkuptext}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    48
\isamarkuptrue%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    49
\isacommand{lemma}\ {\isachardoublequote}exs\ {\isacharparenleft}{\isasymlambda}x{\isachardot}\ P\ x\ {\isasymor}\ Q\ x{\isacharparenright}\ xs\ {\isacharequal}\ Z{\isachardoublequote}\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    50
\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    51
%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    52
\begin{isamarkuptext}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    53
Express the existential via the universal quantifier ---
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    54
\isa{exs} should not occur on the right-hand side:%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    55
\end{isamarkuptext}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    56
\isamarkuptrue%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    57
\isacommand{lemma}\ {\isachardoublequote}exs\ P\ xs\ {\isacharequal}\ Z{\isachardoublequote}\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    58
\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    59
%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    60
\begin{isamarkuptext}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    61
Define a function \isa{is{\isacharunderscore}in\ x\ xs} that checks if \isa{x} occurs in
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    62
\isa{xs} vorkommt. Now express \isa{is{\isacharunderscore}in} via \isa{exs}:%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    63
\end{isamarkuptext}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    64
\isamarkuptrue%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    65
\isacommand{lemma}\ {\isachardoublequote}is{\isacharunderscore}in\ a\ xs\ {\isacharequal}\ Z{\isachardoublequote}\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    66
\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    67
%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    68
\begin{isamarkuptext}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    69
Define a function \isa{nodups\ xs} that is true iff
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    70
\isa{xs} does not contain duplicates, and a function \isa{deldups\ xs} that removes all duplicates. Note that \isa{deldups\ {\isacharbrackleft}x{\isacharcomma}\ y{\isacharcomma}\ x{\isacharbrackright}}
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    71
(where \isa{x} and \isa{y} are distinct) can be either
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    72
\isa{{\isacharbrackleft}x{\isacharcomma}\ y{\isacharbrackright}} or \isa{{\isacharbrackleft}y{\isacharcomma}\ x{\isacharbrackright}}.
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    73
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    74
Prove or disprove (by counter example) the following theorems.%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    75
\end{isamarkuptext}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    76
\isamarkuptrue%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    77
\isacommand{lemma}\ {\isachardoublequote}length\ {\isacharparenleft}deldups\ xs{\isacharparenright}\ {\isacharless}{\isacharequal}\ length\ xs{\isachardoublequote}\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    78
\isanewline
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    79
\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    80
\isacommand{lemma}\ {\isachardoublequote}nodups\ {\isacharparenleft}deldups\ xs{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    81
\isanewline
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    82
\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    83
\isacommand{lemma}\ {\isachardoublequote}deldups\ {\isacharparenleft}rev\ xs{\isacharparenright}\ {\isacharequal}\ rev\ {\isacharparenleft}deldups\ xs{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    84
\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    85
\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    86
\end{isabellebody}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    87
%%% Local Variables:
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    88
%%% mode: latex
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    89
%%% TeX-master: "root"
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    90
%%% End: