1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920
|
% $Id: mpcref.tex,v 1.12 2008/01/25 13:30:19 logik Exp $
\documentclass[11pt,a4paper]{article}
% for pdftex
\usepackage[backref]{hyperref}
% set all margins to 1 inch
\evensidemargin 0pt
\oddsidemargin 0pt
\textwidth \paperwidth
\addtolength\textwidth{-2in}
\topmargin 0pt
\addtolength\topmargin{-\headheight}
\addtolength\topmargin{-\headsep}
\topskip 0pt
\textheight \paperheight
\addtolength\textheight{-2in}
\parindent 0pt
\parskip .5\baselineskip plus .5\baselineskip
\def\MPC{\textsc{Mpc}}
\def\Minlog{\textsc{Minlog}}
\title{The \Minlog\ Proof Checker: \MPC}
\author{Martin Ruckert}
\begin{document}
\maketitle
\tableofcontents
\newpage
\section{Lexical Structure}
The input of \MPC\ is a stream of characters that usually comes from a regular text
file (see Invocation). \MPC\ will group these characters together to form
whitespace, comments, punctuation, strings, names, keywords, numbers, or indices.
Keywords, punctuation, names, numbers and indices are collectively called tokens.
\paragraph{Whitespace:}
You will know whitespace, when you see it. Otherwise, you may look up
the function isspace in a scheme revised five report. Whatever this function
regards as whitespace, is whitespace.
Whitespace is of no
significance to \textsc{MPC}---except between a name and an index (see below).
Its only purpose is to separate two
tokens and to make files more readable.
\paragraph{Comments:} Comments are started with \verb\//\ and
extend until the end of line or the end of file. Like whitespace,
comments separate tokens and can improve readability.
\paragraph{Numbers and Indices}
Numbers and Indices are both formed from the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and
9. They form an index, if they follow immediately after a
name, or after an underscore \verb/_/, or after a caret \verb/^/.
Otherwise, they form a number.
\paragraph{Punctuation}
The following characters are punctuation:
\verb/{/,
\verb/}/,
\verb/[/,
\verb/]/,
\verb/(/,
\verb/)/,
\verb/./,
\verb/;/,
\verb/,/,
and
\verb/"/.
\paragraph{Strings}
Strings start with a ``\verb/"/'' character and end with the following ``\verb/"/''
character or the end of the input. Inside a string any character can be
escaped by a preceding backslash ``\verb/\/''. The preceding backslash strips
a character of any special meaning and inserts it plainly into the string.
This is useful only for the characters that have any special
meaning: the quote and the backslash itself. That is, ``\verb/\"/'' will insert
a double-quote into the string without terminating it, and ``\verb/\\/'' will
insert a single backslash into the string.
\paragraph{Names} Names are formed either from letters only or from
special characters only. All characters except whitespace, digits, letters, and
punctuation are considered special characters.
Names can be indexed by a number. There must be no
whitespace between name and index. E.g \verb/f15/ is the function
$f_{15}$ whereas \verb/f 15/ is the function $f$ applied to the
number $15$.
Examples of names are ``\verb/hello/'', ``\verb/sigma/'', ``\verb/==>/'', and ``\verb/|-/''.
The following strings are {\bf not} names: ``\verb/x_i/'', ``\verb/(;-)/'',
or ``\verb/id3tag/''.
Note: All names of types,
variables, functions, or pre\-di\-cates must be declared before they
can be used. Once an alphabetic name is declared, it provides an
infinite sequence of objects (types, variables, functions, predicates)
using indexing.
\paragraph{Keywords} Keywords are predefined names with a fixed, build in meaning.
All the keywords that \MPC\ knows about are explained below.
\section{Syntax}
The syntax of \MPC\ uses as main ingredients formulas and terms.
Since \MPC\ is a front-end to the \Minlog\ system it uses the \Minlog\ syntax
to specify formulas and terms. To find out how to
write formulas and terms you can either rely on your intuition or consult the
\Minlog\ manual. Here we describe only the syntax that is particular to \MPC.
\MPC\ is designed to process normal text files.
Every text file starts with the keyword
``\texttt{MPC}'' followed by a semicolon ``\texttt{;}''.
Then a list of commands follows.
\subsection{Commands}
A command can be one of the following:
\begin{itemize}
\item \texttt{LOAD} \texttt{"}\textit{Filename}\texttt{"} \texttt{;}\\
reads in the given file as \textsc{Scheme} code. Every possible effect
can be obtained in this way by writing appropriate \textsc{Scheme} code.
If the file does not exist in the current directory, it is searched
for in a directory of library files.
\item \texttt{INCLUDE} \texttt{"}\textit{Filename}\texttt{"} \texttt{;}\\
reads in the given file as \MPC\ code.
It can be used to store e.g.\ a collection of definitions
and axioms in a file and load them into several proofs.
If the file does not exist in the current directory, it is searched
for in a directory of library files. Currently two libraries exist:
nat.mpc gives definitions of natural numbers, and list.mpc gives
definitions for lists.
\item \texttt{SCHEME} \texttt{"}\textit{Scheme Expression}\texttt{";}\\
reads the given string with the \textsc{Scheme} function
\texttt{read} and supplies the result as an argument to the
\textsc{Scheme} function \texttt{eval}, in effect evaluating the
given string like regular \textsc{Scheme} code. Note that inside a
string doublequotes need to be escaped by a preceding
backslash. For example:
\verb/SCHEME "(display \"hello world!\")";/.
\item \texttt{PROOF;}
starts a proof. This will set the list of known facts to
an empty list. \MPC\ will forget all previously proved formulas.
Two variations exist: \texttt{CLASSIC PROOF} starts a proof with the
rule of Stability enabled---that is you can conclude $A$ from $\lnot\lnot A$.
\texttt{INTUITIONISTIC PROOF} starts a proof with the special
rule of Ex-Falso-Quodlibet enabled --- that is you can conclude any $A$ from
$\bot$.
\item \texttt{END;}
terminates a proof (currently optional).
\item A declaration,
\item an assumption,
\item a claim,
\item a block, or
\item a syntax specification as detailed below.
\end{itemize}
\subsection{Declarations}
Declarations are used to tell \MPC\ about types, variables,
functions, and predicates.
\paragraph{Types:}
Types come as type variables, as simultaneously defined finite algebras,
or as composed types. Only variable types and algebra types need
to be declared. Type operators (mostly \verb/=>/) can be freely
used to construct composed types.
To declare a type variable the keyword ``\texttt{TYPE}'' is followed
by a dot ``\texttt{.}'', a list of names, and finally a semicolon
``\texttt{;}''. It will make the given names type variables. For
example:
\texttt{TYPE . rho sigma tau;}
will make \texttt{rho}, \texttt{sigma}, and \texttt{tau} new type variables.
There is one predefined type variable \texttt{alpha} that exists, for
internal reasons, right from the start.
By adding an index to a variable name, an infinite number of different
type variables can be obtained, e.g.\ \texttt{alpha5},
\texttt{tau123}, or \texttt{sigma1}.
Algebra types are described in the next section.
\paragraph{Algebra Types:}
Objects of a free algebra type are build by applying an appropriate
constructor to already existing objects. For example, the free
algebra of natural numbers can be defined with the constructors
\texttt{zero} and \texttt{successor}.
\texttt{zero} is a constructor of empty arity, that is, it is applied to
no object and yields a natural number, and \texttt{successor}
is applied to a natural number and yields again a natural number.
Hence ``\texttt{successor zero}'' is for example a natural number.
To specify an algebra, the name of the algebra together with the name
of the constructors and their arity has to be given. The syntax is:
\noindent
\texttt{ALGEBRA} \textit{algebra-name} \verb/{/ \verb/{/ \verb/{/\\
\texttt{\ \ \textit{constructor-type} . \textit{constructor-name} ; }\\
\texttt{\ \ \textit{constructor-type} . \textit{constructor-name} ; }\\
\ldots\\
\ \verb/}/\ \texttt{;}
For example to define the algebra of natural numbers, one can write
\noindent
\texttt{ALGEBRA nat}\ \verb/{/\\
\texttt{\ \ nat . zero ;} \\
\texttt{\ \ nat => nat . successor ;} \\
\ \verb/}/
Algebras can have type parameters. For example a list type, might
have the type of the list elements as a parameter. To declare an
algebra with type parameters, the number of type parameters has to be
given after the algebra name. In this case the type variables
\texttt{alpha0}, \texttt{alpha1}, \ldots can be used in the
\textit{constructor-types}.
For example to define the free algebra of lists of elements of type
\texttt{alpha0} one can write:
\noindent
\texttt{ALGEBRA list 1}\ \verb/{/\\
\texttt{\ \ list . nil ;} \\
\texttt{\ \ alpha0 => list => list . cons ;} \\
\ \verb/}/\ \texttt{;}
Finally, several algebras can be defined simultaneously
by listing all their names after the keyword \texttt{ALGEBRA}.
As a last example we construct an algebra of labeled trees, where labels
can be either of type \texttt{alpha0}, or of type \texttt{alpha1}, or
again labeled trees.
\noindent
\texttt{ALGEBRA tree label 2}\ \verb/{/\\
\texttt{alpha0 => label . first ;}\\
\texttt{alpha1 => label . second ;}\\
\texttt{tree => label . third ;}
\noindent
\texttt{tree . empty;}\\
\texttt{label => tree => tree => tree . node ;}\\
\ \verb/}/\ \texttt{;}
\paragraph{Variables:}
Variables are declared by specifying their type. The syntax is:
\noindent
\textit{type} \texttt{.} \textit{variablenames} \texttt{;}
For example
\noindent
\texttt{nat => nat . f g ; }
defines \texttt{f} and \texttt{g} as function variables
mapping natural numbers to natural numbers. Similarly \texttt{f3} or
\texttt{g2} are such function variables.
\paragraph{Functions:}
Function constants have a name and a type (like function variables)
but in addition have fixed computational rules or rewrite rules
attached to them. These rules are used automatically by the prover
to find out whether two terms are equal.
A function declaration starts with the keyword \texttt{FUNCTION}
followed by the target type of the function, a dot, the name of the
function and a list of argument types. After the name follows a list
of rules enclosed in braces. A semicolon terminates the function
declaration. As a special convenience, syntax declarations (see below)
can be used inside the rule list.
A rule has the form \textit{term} \texttt{->} \textit{term} \texttt{;}
It states that the left term can be replaced by the right term. Of
course, the principal operator of the left term has to be the function
currently being defined. Furthermore each rule must have a unique
left hand side. More rules can be added if prefixed with the keyword
\texttt{REWRITE}. These additional rules are applied more carefully
(avoiding rewrite loops) and hence are more flexible but slower.
The following example illustrates this:
\begin{tabbing}
\tt SYNTAX ++ PREFIXOP successor ; \\
\tt FUNCTION nat . plus (nat nat) \\
\tt \verb/{/ \= \\
\>\tt SYNTAX + ADDOP plus ;\\
\\
\>\tt \phantom{REWRITE} n + zero -> n ;\\
\>\tt \phantom{REWRITE} n + ++m -> ++(n + m) ;\\
\>\tt REWRITE zero + n -> n;\\
\>\tt REWRITE ++n + m -> ++(n + m) ;\\
\>\tt REWRITE n + ( m+ k) -> (n + m) + k ; \\
\tt \verb/}/;\\
\end{tabbing}
Note, that syntax declarations, explained below, are allowed inside
a function declaration to enable the use of a more convenient
syntax, e.g.\ infix notation, if so desired.
Functions, by default, are total functions. It is possible to define
partial functions by adding the keyword \texttt{PARTIAL} in front of
the keyword \texttt{FUNCTION}.
\paragraph{Predicates:}
To declare a predicate the keyword \texttt{PRED} is used followed by a
list of types of the arguments (if any), a dot, a list of predicate
names, and finally a semicolon.
For example:
\noindent
\texttt{PRED . A B ; }
defines two predicate variables \texttt{A} and \texttt{B} (as well as
\texttt{A0}, \texttt{A1}, \ldots). They take no arguments and can be
used like propositional variables.
\noindent
\texttt{PRED nat nat . R ; }
defines a binary predicate over natural numbers (a relation), and
\noindent
\texttt{PRED nat=>nat . P ; }
defines a unary predicate over functions of natural numbers.
\subsection{Assumptions and Claims}
An assumption is a formula followed by a dot ``\texttt{.}'' and a
claim is a formula followed by a semicolon ``\texttt{;}''. In the
first case the formula is added to the list of known formulas, in the
second case an attempt is made to prove the formula form the formulas
already known to be true.
Formulas are defined inductively: Every predicate variable \texttt{A}
is a formula. If \texttt{M} and \texttt{N} are formulas then
\texttt{M \& N} (conjunction) and \texttt{M -> N} (implication) are
formulas. If \texttt{M} is a formula and \texttt{x} is a variable,
then \texttt{all x M} and \texttt{ex x M} are formulas.
Examples of formulas and details of how proofs work can be found
below.
For example:
\noindent
\texttt{PRED . A ; // A is a proposition }\\
\texttt{A. // we assume A holds }\\
\texttt{A \& A; // we claim that A \& A can be proven}
\subsection{Blocks}
Blocks are used to construct conditional proofs.
They start with \verb\{\ and end with \verb\}\.
After the opening brace follows either a formula or a variable
followed by a dot. This is the local formula or variable of
this block.
Next a block contains a non empty sequence of claims or other blocks.
When the block is closed it proves an implication --- in case of a
local formula --- or an all quantified formula --- in case of a local
variable. The exact usage is explained below. Here an example may
suffice:
\begin{tabbing}
\tt PRED alpha . P ; // P is a predicate \\
\tt alpha . x ; // x is a variable of type alpha \\
\tt \verb/{/ \=\tt x0 . // assume x0 is given \\
\tt \>\tt \verb/{/ \= \tt P x0 . // assume further that P of x0 holds \\
\tt \> \>\tt P x0 ; // then P of x0 holds \\
\tt \>\tt \verb/}/ // this proves P x0 -> P x0 \\
\tt \verb/}/ // this proves all x0 . P x0 -> P x0 \\
\end{tabbing}
\subsection{Syntax Declarations}
In mathematics, functions are often written in infix, prefix, or
postfix notation. Instead of writing \texttt{plus x y} --- the
function \texttt{plus} applied to \texttt{x} and \texttt{y} --- we
like to write \texttt{x + y}. To facilitate this \MPC\ has
syntax declarations.
A syntax declaration starts with the keyword \texttt{SYNTAX} followed
by the name of the new operator, followed by the tokentype, followed
by a term, and a semicolon.
A tokentype is one of the following (in order of increasing
binding strength):
\texttt{PAIROP},
\texttt{IMPOP},
\texttt{OROP},
\texttt{ANDOP},
\texttt{RELOP},
\texttt{ADDOP},
\texttt{MULOP},
\texttt{PREFIXOP},
\texttt{POSTFIXOP}, or
\texttt{CONST}.
A \texttt{PAIROP} and \texttt{IMPOP} are right associative,
a \texttt{RELOP} is not associative, and all other infix operators are
left associative.
After the syntax declaration, any term containing the new operator as
main connective is replaced by the term given in the syntax
declaration applied to the arguments of the operator.
For example:
\noindent
\texttt{boole . a b; // a and b are booleans. }\\
\texttt{boole=>boole=>boole . f ; // f is a function. }\\
\texttt{SYNTAX | ADDOP f0 ; // we write | as infix operator for f0.}
\noindent
\texttt{all a . true|a . // for all a ((f0 true) a) holds.}\\
\texttt{all a,b . a|b -> b|a. // f0 is commutative.}\\
\texttt{false|false -> bot. // ((f0 false) false) implies bot.}
Syntax declarations might be parameterized with type variables
\texttt{alpha0}, \texttt{alpha1}, \ldots If the defining term contains
one of these type variables, the types of the actual arguments are matched
against the type of the operator to instantiate the type variables.
If the types match, the syntax declaration is used.
Further, the same operator might be redefined in several syntax declarations
as long as all of these declarations use the same tokentype. Multiple
declarations are tested in the order declared and the first matching declaration is
used.
Note: Syntax declarations are allowed inside a function declaration.
\section{Proofs}
The \Minlog\ Proof Checker is able to check proofs in ``natural
deduction'' style.
It maintains a list of formulas, called the context, which are assumed
or known or proven to be true. Initially this list is empty; using
the keyword \texttt{PROOF;} it can be reset to an empty list at any
time to start a new proof.
There are only two methods to add a formula to the context: First, one
can assume the formula by just stating it and putting a dot behind it.
This is called an assumption. Example:
\begin{verbatim}
PRED . A B; // A and B are propositional variables
A. // Let's assume A holds
A -> B. // Let's assume A implies B
\end{verbatim}
Second, one can prove a formula from other formulas already known ---
i.e.\ fformulas already part of the context --- using the rules of
natural deduction. The claim that a formula can be proved is
expressed by stating the formula followed by semicolon. This is
called a claim. \MPC\ then will check whether there are indeed
formulas in the context, which prove the new formula using exactly one
rule of natural deduction.
If that is not possible, \MPC\ will start a limited proof
search trying to obtain a more complicated proof of the claimed
formula. If a proof is found this is indicated in an appropriate
warning message. It tells the user that the formula is indeed
provable, but not with a single step.
If the proof search does not discover a proof, \MPC\ will
simply assume the formula and continue. It will output a
corresponding error message, and it should be clear that the proof has
still a gap at this point.
Whenever a formula is added to the context, it receives a unique
number and \MPC\ will use this number later to refer to this
formula in its output.
A typical proof will first define the necessary types, variables,
functions and predicates to establish the language of the theory, then
it states a list of assumptions made (these are the axioms of the
theory) and finally it starts to make claims, adding one formula at a
time to the pool of knowledge (the context) available for the theory.
In the end it will conclude with the final formula, a theorem of the
theory.
Often the language of the theory and its axioms are put into include
files, to be able to conveniently load them before starting a proof.
In the following sections, we will discuss all the proof rules of
natural deduction, one at a time.
\subsection{Simple Rules}
To be applicable, these rules just require certain formulas to be
already in the context.
\paragraph{Trivial Proofs}
If a formula, after normalization, is the same as a formula
in the context, it is proven by identity. Likewise,
if a formula, by normalization, reduces to \texttt{True}, it is
proven.
\paragraph{And Elimination:}
If a formula of the form $A \land B$ is in the context,
it is possible to derive either $A$ or $B$ in one step.
Example:
\begin{verbatim}
A & B. // 0 assumed.
A; // OK, 1 proved by and-elim-left from 0
B; // OK, 2 proved by and-elim-right from 0
\end{verbatim}
\paragraph{And Introduction:}
If two formulas $A$ and $B$ are part of the context,
it is possible to derive $A \land B$ in one step.
Example:
\begin{verbatim}
A. // 0 assumed.
B. // 1 assumed.
A & B; // OK, 2 proved by and-intro from 0 and 1
\end{verbatim}
\paragraph{Implication Elimination:}
If an implication $A \to B$ and its condition $A$
are part of the context,
it is possible to derive the conclusion $B$ in one step.
Example:
\begin{verbatim}
A -> B. // 0 assumed.
A. // 1 assumed.
B; // OK, 2 proved by imp-elim from 0 and 1
\end{verbatim}
\paragraph{All Elimination:}
If an all formula $\forall x\, A x$
is part of the context,
it is possible to derive the conclusion $A t$
for any term $t$ of the appropriate type in one step.
Example:
\begin{verbatim}
all x A x. // 0 assumed.
A t; // OK, 1 proved by all-elim from 0 using t
\end{verbatim}
\paragraph{Existential Introduction:}
If a formula $A t$ for some term $t$ is part of the context,
it is possible to derive $\exists x\, A x$ in one step,
where $x$ is a variable of the same type as $t$.
Example:
\begin{verbatim}
A t. // 0 assumed.
ex x A x; // OK, 1 proved by ex-intro from 0 using t
\end{verbatim}
\subsection{Block Rules}
Sometimes it is necessary in a proof to temporarily make an assumption
only to discard it later again. For example, for proving an
implication $A \to B$, one would first assume $A$ holds, and then
prove $B$ under this assumption. Once this is done, one can conclude
that $A \to B$, and this does no longer depend on the assumption $A$.
The assumption $A$ in this example behaves like a local assumption
with a limited scope. In programming languages, the usual way to
introduce objects with limited scope is a block structure. In
\textsc{MPC}, blocks are enclosed in curly braces and introduce
exactly one local object, either a formula or a variable. The scope
of this local object is its defining block and all blocks nested
inside it.
\paragraph{Implication Introduction:}
As said before, an implication $A \to B$ is proved by assuming $A$ and
then proving $B$ under this assumption. Once this is done, one can
conclude that $A \to B$. In \textsc{MPC}, one opens a block with the
local assumption $A$ and proves inside this block the formula $B$.
Immediately after the formula $B$ the block is closed again. After
the closing brace of the block, \MPC\ will discard all the
formulas added to the context during the block (since these may depend
on the assumption $A$) and adds the implication $A \to B$ to the
context, $A$ being the local formula of the block and $B$ the last
formula of the block.
Example:
\begin{verbatim}
{ A t. // 0 assumed.
ex x A x; // OK, 1 proved by ex-intro from 0 using t
} OK, 2 A t -> ex x A x proved.
ex x A x; // ERROR: 3 assumed. Proof not found.
\end{verbatim}
\paragraph{All Introduction:}
The proof of a formula with an outer universal quantifier is similar
to the proof of an implication: Under the assumption that some $x$ is
given, one proves $A x$. This is sufficient to conclude $\forall x\,
Ax$.
For \textsc{MPC}, the proof consists of a block with a local variable
$x$ with the last formula being $A x$. At the end of the block,
\MPC\ will discard all the formulas added to the context during
the block and adds the formula $\forall x\, Ax$ to the context.
Example:
\begin{verbatim}
{ x. // x assumed.
{ A x. // 0 assumed.
A x; // OK, 1 proved by 0
} OK, 2 A x -> A x proved.
} OK, 3 all x.A x -> A x proved.
\end{verbatim}
\paragraph{Existential Elimination:}
A proof of a formula $B$ may use an existentially quantified formula
$\exists x\, Ax$. It typically proceeds like this: If we know that
$\exists x\, Ax$, let us assume we have such an $x$, call it $x_0$,
such that $A x_0$ holds,\ldots and from this the proof continues to
prove the formula B. This then constitutes a proof of $B$ from
$\exists x\, Ax$ under the side condition that the $x_0$ is not a free
variable of $B$.
This proof can be formulated for \MPC\ in exactly the same
fashion as outlined above using two nested blocks. The first block
introduces the local variable $x_0$ and the second block the local
assumption $A x_0$. Once the formula $B$ is proved from this, both
blocks are closed. This in effect proves the formula $\forall x. Ax
\to B$. This, together with the formula $\exists x\, Ax$, can be used
to finally prove $B$ using the rule of existential elimination.
Example:
\begin{verbatim}
ex x.A x & B. // 0 assumed.
{ x0. // x0 assumed.
{ A x0 & B. // 1 assumed.
B; // OK, 2 proved by and-elim-right from 1
} OK, 3 A x0 & B -> B proved.
} OK, 4 all x0.A x0 & B -> B proved.
B; // OK, 5 proved by ex-elim from 4 and 0
\end{verbatim}
\subsection{Induction}
Induction is used to prove that a formula $Ax$ holds for all objects
$x$ of a given algebra type $\tau$. This is done by considering all
constructors $C_1,\ldots,C_n$ of the algebra that are capable of
producing an object of the type in question and proving for each one
of them that the formula $A C_i \ldots$ holds provided that the
formula holds already for all arguments of $C_i$ of type $\tau$. Once
this is done, all these formulas together, prove by the principle of
induction, that $\forall x\, Ax$.
We illustrate this using the standard example of natural numbers.
The free algebra of natural numbers \texttt{nat} is generated
from two constructors: \texttt{Zero} of type \texttt{nat}
and \texttt{Succ} of type $\texttt{nat}\to\texttt{nat}$.
For convenience we write \texttt{0} for \texttt{Zero} and
$\mathtt{++}n$ for $\texttt{Succ}\,n$
To prove $\forall n\, An$ by induction, we need to prove first $A
\mathtt{0}$ and $\forall n\, An \to A \mathtt{++} n$, then we can
conclude the desired result. For example lets prove that $\forall n
\exists m \, m = n+1$. We proceed like this:
First $1 = \mathtt{0}+1$ and therefore $\exists m\, m=\mathtt{0}+1$.
Second, assume $n$ is given and $\exists m\, m = n + 1$ holds.
Then there is an $m_0$ with $m_0 = n + 1$, and thus
$m_0 +1 = \mathtt{++}n +1$. By existential introduction,
we conclude $\exists m\, m= \mathtt{++}n + 1$ and
have proved $\forall n\, (\exists m\, m = n + 1 \to
\exists m\, m= \mathtt{++}n + 1)$.
From these, by induction, we infer: $\forall n \exists m \, m = n+1$.
The complete proof written for \MPC\ reads:
\begin{verbatim}
MPC;
INCLUDE "nat.mpc";
PROOF; // initializing mpc1
1=0+1; // OK, 0 proved trivial
ex m m=0+1; // OK, 1 proved by ex-intro from 0 using 1
{ n. // n assumed.
{ ex m m=n+1. // 2 assumed.
{ m0. // m0 assumed.
{ m0=n+1. // 3 assumed.
m0+1= ++n+1; // OK, 4 proved by 3
ex m m= ++n+1; // OK, 5 proved by ex-intro from 4 using m0+1
} // OK, 6 m0=n+1 -> ex m m= ++n+1 proved.
} // OK, 7 all m0.m0=n+1 -> ex m m= ++n+1 proved.
ex m m= ++n+1; // OK, 8 proved by ex-elim from 7 and 2
} // OK, 9 ex m m=n+1 -> ex m m= ++n+1 proved.
} // OK, 10 all n.ex m m=n+1 -> ex m m= ++n+1 proved.
all n ex m m=n+1; // OK, 11 proved by ind from 10 1
\end{verbatim}
\subsection{Proof by Cases}
Proof by cases is similar to induction but weaker. Again, we prove
that a proposition $Ax$ holds for all objects
$x$ of a given algebra type $\tau$. This is done by considering all
constructors $C_1,\ldots,C_n$ of the algebra that are capable of
producing an object of the type in question and proving for each one
of them that the formula $A C_i \ldots$ holds.
In contrast to the rule of induction however, no induction hypothesis
is available in the proof.
A special case is the proof by cases for objects of type \texttt{boole}.
Here, the constructors are \texttt{True} and \texttt{False}. We prove
$Ax$ by considering the two cases, proving $A\texttt{True}$ and
$A\texttt{False}$ to conclude $\forall x\, Ax$. Typically, this
formula is then applied to the boolean term $t$ in question
to obtaining $At$.
Since this process is quite common, in addition to the usual proof by cases
rule, an equivalent and more convenient
rule is built into \MPC: the proof by boolean cases.
To prove any formula $A$, you just have to prove $t \rightarrow A$ and
$(\lnot t) \rightarrow A$.
\subsection{Intuitionistic and Classical Logic}
\MPC\ provides two keywords \texttt{CLASSIC} and
\texttt{INTUITIONISTIC} to activate proof rules for classic and
intuitionistic logic, respectively. If a proof starts with
``\texttt{INTUITIONISTIC PROOF;}'', the proof rule ``ex falso
quodlibet'' is enabled. It allows to conclude from \texttt{bot} any
formula whatsoever. If a proof starts with ``\texttt{CLASSIC
PROOF;}'' in addition the stronger proof rule of ``stability'' is
enabled. It allows to conclude the formula $A$ from a statement of
$\lnot \lnot A$. It is an easy exercise to prove $\bot \to A$ from
$\lnot \lnot A \to A$, and therefore stability alone would be
sufficient to have classical logic. It is however convenient to have
``ex falso quodlibet'' in addition. This weaker rule is always tested
first.
As an example, we present a proof of the Pierce Formula
$((P\rightarrow Q) \rightarrow P) \rightarrow P$.
\begin{verbatim}
CLASSIC PROOF;
PRED . P Q;
{ (P -> Q) -> P. // 0 assumed.
{ P -> bot. // 1 assumed.
{ P. // 2 assumed.
bot; // OK, 3 proved by imp-elim from 1 and 2
Q; // OK, 4 proved by EFQ from 3
} // OK, 5 P -> Q proved.
P -> Q; // OK, 6 proved by 5
P; // OK, 7 proved by imp-elim from 0 and 6
bot; // OK, 8 proved by imp-elim from 1 and 7
} // OK, 9 (P -> bot) -> bot proved.
(P -> bot) -> bot; // OK, 10 proved by 9
P; // OK, 11 proved by Stability from 10
} // OK, 12 ((P -> Q) -> P) -> P proved.
END;
\end{verbatim}
\newpage
\appendix
\section{Library code}
This \MPC\ code may serve as an example to illustrate
the concepts of \MPC.
\subsection{Natural Numbers}
\begin{verbatim}
MPC;
ALGEBRA nat 0
{ nat=>nat . Succ ;
nat . Zero ;
};
nat . n m k;
// to use numbers we have to provide scheme code
// converting numbers to terms using internals of Minlog
SCHEME
"(define (make-numeric-term n)
(if (= n 0)
(pt \"Zero\")
(make-term-in-app-form
(pt \"Succ\")
(make-numeric-term (- n 1)))))" ;
SCHEME
"(define (is-numeric-term? term)
(or
(and (term-in-const-form? term)
(string=? \"Zero\"
(const-to-name
(term-in-const-form-to-const term))))
(and (term-in-app-form? term)
(let ((op (term-in-app-form-to-op term)))
(and (term-in-const-form? op)
(string=? \"Succ\"
(const-to-name
(term-in-const-form-to-const op)))
(is-numeric-term?
(term-in-app-form-to-arg term)))))))";
SCHEME
"(define (numeric-term-to-number term)
(if (equal? term (pt \"Zero\"))
0
(+ 1 (numeric-term-to-number
(term-in-app-form-to-arg term)))))";
SYNTAX ++ PREFIXOP Succ;
FUNCTION nat . Plus(nat nat)
{ SYNTAX + ADDOP Plus;
n + 0 -> n;
n + ++m -> ++(n + m);
REWRITE 0 + n -> n;
REWRITE ++n + m -> ++(n + m);
REWRITE n + (m + k) -> n + m + k;
};
FUNCTION nat . Times(nat nat)
{ SYNTAX * MULOP Times;
n * 0 -> 0;
n * ++m -> (n*m)+n;
REWRITE 0*n -> 0;
REWRITE ++n*m -> (n*m)+m;
REWRITE n * (m * k) -> n * m * k;
};
FUNCTION boole . Less(nat nat)
{ SYNTAX < RELOP Less;
n < 0 -> False;
0 < ++n -> True;
++n < ++m -> n<m;
};
\end{verbatim}
\newpage
\subsection{Polymorphic Lists}
\begin{verbatim}
MPC;
ALGEBRA list 1 {
list . Nil;
alpha1 => list => list . Cons ;
};
// a generic variable of type (list alpha)
(list alpha) . l;
SYNTAX :: PAIROP (Cons alpha);
SYNTAX : POSTFIXOP [alpha] alpha ::(Nil alpha);
// example x :: y :: z :
FUNCTION list alpha => list alpha . ListAppend (list alpha)
{ SYNTAX :+: PAIROP (ListAppend alpha);
(ListAppend alpha)(Nil alpha) -> [l_2]l_2;
(ListAppend alpha)(alpha :: l1) -> [l2] alpha::(l1:+:l2);
};
INCLUDE "nat.mpc";
FUNCTION nat . ListLength(list alpha)
{ SYNTAX lh PREFIXOP (ListLength alpha);
lh (Nil alpha) -> 0 ;
lh (alpha :: l) -> ++ lh l;
REWRITE lh (l1 :+: l2) -> lh l1 + lh l2;
};
\end{verbatim}
\end{document}
%%% Local Variables:
%%% mode: latex-math
%%% End:
|