doc-src/Logics/LK.tex
changeset 5151 1e944fe5ce96
parent 3148 f081757ce757
child 6072 5583261db33d
equal deleted inserted replaced
5150:6e2e9b92c301 5151:1e944fe5ce96
    20 
    20 
    21 No generic packages are instantiated, since Isabelle does not provide
    21 No generic packages are instantiated, since Isabelle does not provide
    22 packages for sequent calculi at present.  \LK{} implements a classical
    22 packages for sequent calculi at present.  \LK{} implements a classical
    23 logic theorem prover that is as powerful as the generic classical reasoner,
    23 logic theorem prover that is as powerful as the generic classical reasoner,
    24 except that it does not perform equality reasoning.
    24 except that it does not perform equality reasoning.
       
    25 
       
    26 To work in LK, start up Isabelle specifying  \texttt{Sequents} as the
       
    27 object-logic.  Once in Isabelle, change the context to theory \texttt{LK.thy}:
       
    28 \begin{ttbox}
       
    29 isabelle Sequents
       
    30 context LK.thy;
       
    31 \end{ttbox}
       
    32 Model logic and linear logic are also available, but unfortunately they are
       
    33 not documented.
    25 
    34 
    26 
    35 
    27 \begin{figure} 
    36 \begin{figure} 
    28 \begin{center}
    37 \begin{center}
    29 \begin{tabular}{rrr} 
    38 \begin{tabular}{rrr} 
   109 
   118 
   110 \section{Unification for lists}
   119 \section{Unification for lists}
   111 Higher-order unification includes associative unification as a special
   120 Higher-order unification includes associative unification as a special
   112 case, by an encoding that involves function composition
   121 case, by an encoding that involves function composition
   113 \cite[page~37]{huet78}.  To represent lists, let $C$ be a new constant.
   122 \cite[page~37]{huet78}.  To represent lists, let $C$ be a new constant.
   114 The empty list is $\lambda x.x$, while $[t@1,t@2,\ldots,t@n]$ is
   123 The empty list is $\lambda x. x$, while $[t@1,t@2,\ldots,t@n]$ is
   115 represented by
   124 represented by
   116 \[ \lambda x.C(t@1,C(t@2,\ldots,C(t@n,x))).  \]
   125 \[ \lambda x. C(t@1,C(t@2,\ldots,C(t@n,x))).  \]
   117 The unifiers of this with $\lambda x.\Var{f}(\Var{g}(x))$ give all the ways
   126 The unifiers of this with $\lambda x.\Var{f}(\Var{g}(x))$ give all the ways
   118 of expressing $[t@1,t@2,\ldots,t@n]$ as the concatenation of two lists.
   127 of expressing $[t@1,t@2,\ldots,t@n]$ as the concatenation of two lists.
   119 
   128 
   120 Unlike orthodox associative unification, this technique can represent certain
   129 Unlike orthodox associative unification, this technique can represent certain
   121 infinite sets of unifiers by flex-flex equations.   But note that the term
   130 infinite sets of unifiers by flex-flex equations.   But note that the term
   122 $\lambda x.C(t,\Var{a})$ does not represent any list.  Flex-flex constraints
   131 $\lambda x. C(t,\Var{a})$ does not represent any list.  Flex-flex constraints
   123 containing such garbage terms may accumulate during a proof.
   132 containing such garbage terms may accumulate during a proof.
   124 \index{flex-flex constraints}
   133 \index{flex-flex constraints}
   125 
   134 
   126 This technique lets Isabelle formalize sequent calculus rules,
   135 This technique lets Isabelle formalize sequent calculus rules,
   127 where the comma is the associative operator:
   136 where the comma is the associative operator:
   170 \tdx{notR}    $H, P |- $E, $F ==> $H |- $E, ~P, $F
   179 \tdx{notR}    $H, P |- $E, $F ==> $H |- $E, ~P, $F
   171 \tdx{notL}    $H, $G |- $E, P ==> $H, ~P, $G |- $E
   180 \tdx{notL}    $H, $G |- $E, P ==> $H, ~P, $G |- $E
   172 
   181 
   173 \tdx{FalseL}  $H, False, $G |- $E
   182 \tdx{FalseL}  $H, False, $G |- $E
   174 
   183 
   175 \tdx{allR}    (!!x.$H|- $E, P(x), $F) ==> $H|- $E, ALL x.P(x), $F
   184 \tdx{allR}    (!!x. $H|- $E, P(x), $F) ==> $H|- $E, ALL x. P(x), $F
   176 \tdx{allL}    $H, P(x), $G, ALL x.P(x) |- $E ==> $H, ALL x.P(x), $G|- $E
   185 \tdx{allL}    $H, P(x), $G, ALL x. P(x) |- $E ==> $H, ALL x. P(x), $G|- $E
   177             
   186             
   178 \tdx{exR}     $H|- $E, P(x), $F, EX x.P(x) ==> $H|- $E, EX x.P(x), $F
   187 \tdx{exR}     $H|- $E, P(x), $F, EX x. P(x) ==> $H|- $E, EX x. P(x), $F
   179 \tdx{exL}     (!!x.$H, P(x), $G|- $E) ==> $H, EX x.P(x), $G|- $E
   188 \tdx{exL}     (!!x. $H, P(x), $G|- $E) ==> $H, EX x. P(x), $G|- $E
   180 
   189 
   181 \tdx{The}     [| $H |- $E, P(a), $F;  !!x.$H, P(x) |- $E, x=a, $F |] ==>
   190 \tdx{The}     [| $H |- $E, P(a), $F;  !!x. $H, P(x) |- $E, x=a, $F |] ==>
   182         $H |- $E, P(THE x.P(x)), $F
   191         $H |- $E, P(THE x. P(x)), $F
   183 \subcaption{Logical rules}
   192 \subcaption{Logical rules}
   184 \end{ttbox}
   193 \end{ttbox}
   185 
   194 
   186 \caption{Rules of {\tt LK}}  \label{lk-rules}
   195 \caption{Rules of {\tt LK}}  \label{lk-rules}
   187 \end{figure}
   196 \end{figure}
   192 
   201 
   193 Figure~\ref{lk-syntax} gives the syntax for {\tt LK}, which is complicated
   202 Figure~\ref{lk-syntax} gives the syntax for {\tt LK}, which is complicated
   194 by the representation of sequents.  Type $sobj\To sobj$ represents a list
   203 by the representation of sequents.  Type $sobj\To sobj$ represents a list
   195 of formulae.
   204 of formulae.
   196 
   205 
   197 The {\bf definite description} operator~$\iota x.P[x]$ stands for some~$a$
   206 The {\bf definite description} operator~$\iota x. P[x]$ stands for some~$a$
   198 satisfying~$P[a]$, if one exists and is unique.  Since all terms in \LK{}
   207 satisfying~$P[a]$, if one exists and is unique.  Since all terms in \LK{}
   199 denote something, a description is always meaningful, but we do not know
   208 denote something, a description is always meaningful, but we do not know
   200 its value unless $P[x]$ defines it uniquely.  The Isabelle notation is
   209 its value unless $P[x]$ defines it uniquely.  The Isabelle notation is
   201 \hbox{\tt THE $x$.$P[x]$}.  The corresponding rule (Fig.\ts\ref{lk-rules})
   210 \hbox{\tt THE $x$. $P[x]$}.  The corresponding rule (Fig.\ts\ref{lk-rules})
   202 does not entail the Axiom of Choice because it requires uniqueness.
   211 does not entail the Axiom of Choice because it requires uniqueness.
   203 
   212 
   204 Figure~\ref{lk-grammar} presents the grammar of \LK.  Traditionally,
   213 Figure~\ref{lk-grammar} presents the grammar of \LK.  Traditionally,
   205 \(\Gamma\) and \(\Delta\) are meta-variables for sequences.  In Isabelle's
   214 \(\Gamma\) and \(\Delta\) are meta-variables for sequences.  In Isabelle's
   206 notation, the prefix~\verb|$| on a variable makes it range over sequences.
   215 notation, the prefix~\verb|$| on a variable makes it range over sequences.
   239             $H |- $E, P<->Q, $F
   248             $H |- $E, P<->Q, $F
   240 
   249 
   241 \tdx{iffL}        [| $H, $G |- $E, P, Q;  $H, Q, P, $G |- $E |] ==>
   250 \tdx{iffL}        [| $H, $G |- $E, P, Q;  $H, Q, P, $G |- $E |] ==>
   242             $H, P<->Q, $G |- $E
   251             $H, P<->Q, $G |- $E
   243 
   252 
   244 \tdx{allL_thin}   $H, P(x), $G |- $E ==> $H, ALL x.P(x), $G |- $E
   253 \tdx{allL_thin}   $H, P(x), $G |- $E ==> $H, ALL x. P(x), $G |- $E
   245 \tdx{exR_thin}    $H |- $E, P(x), $F ==> $H |- $E, EX x.P(x), $F
   254 \tdx{exR_thin}    $H |- $E, P(x), $F ==> $H |- $E, EX x. P(x), $F
   246 \end{ttbox}
   255 \end{ttbox}
   247 
   256 
   248 \caption{Derived rules for {\tt LK}} \label{lk-derived}
   257 \caption{Derived rules for {\tt LK}} \label{lk-derived}
   249 \end{figure}
   258 \end{figure}
   250 
   259 
   468 is easy using~{\LK}, as you can see by comparing this proof with the one
   477 is easy using~{\LK}, as you can see by comparing this proof with the one
   469 given in~\S\ref{fol-cla-example}.  From a logical point of view, the
   478 given in~\S\ref{fol-cla-example}.  From a logical point of view, the
   470 proofs are essentially the same; the key step here is to use \tdx{exR}
   479 proofs are essentially the same; the key step here is to use \tdx{exR}
   471 rather than the weaker~\tdx{exR_thin}.
   480 rather than the weaker~\tdx{exR_thin}.
   472 \begin{ttbox}
   481 \begin{ttbox}
   473 goal LK.thy "|- EX y. ALL x. P(y)-->P(x)";
   482 Goal "|- EX y. ALL x. P(y)-->P(x)";
   474 {\out Level 0}
   483 {\out Level 0}
   475 {\out  |- EX y. ALL x. P(y) --> P(x)}
   484 {\out  |- EX y. ALL x. P(y) --> P(x)}
   476 {\out  1.  |- EX y. ALL x. P(y) --> P(x)}
   485 {\out  1.  |- EX y. ALL x. P(y) --> P(x)}
   477 by (resolve_tac [exR] 1);
   486 by (resolve_tac [exR] 1);
   478 {\out Level 1}
   487 {\out Level 1}
   515 {\out Level 6}
   524 {\out Level 6}
   516 {\out  |- EX y. ALL x. P(y) --> P(x)}
   525 {\out  |- EX y. ALL x. P(y) --> P(x)}
   517 {\out  1. !!x xa. P(?x), P(?x7(x)) |- P(x), P(xa)}
   526 {\out  1. !!x xa. P(?x), P(?x7(x)) |- P(x), P(xa)}
   518 \end{ttbox}
   527 \end{ttbox}
   519 Subgoal~1 seems to offer lots of possibilities.  Actually the only useful
   528 Subgoal~1 seems to offer lots of possibilities.  Actually the only useful
   520 step is instantiating~$\Var{x@7}$ to $\lambda x.x$,
   529 step is instantiating~$\Var{x@7}$ to $\lambda x. x$,
   521 transforming~$\Var{x@7}(x)$ into~$x$.
   530 transforming~$\Var{x@7}(x)$ into~$x$.
   522 \begin{ttbox}
   531 \begin{ttbox}
   523 by (resolve_tac [basic] 1);
   532 by (resolve_tac [basic] 1);
   524 {\out Level 7}
   533 {\out Level 7}
   525 {\out  |- EX y. ALL x. P(y) --> P(x)}
   534 {\out  |- EX y. ALL x. P(y) --> P(x)}
   526 {\out No subgoals!}
   535 {\out No subgoals!}
   527 \end{ttbox}
   536 \end{ttbox}
   528 This theorem can be proved automatically.  Because it involves quantifier
   537 This theorem can be proved automatically.  Because it involves quantifier
   529 duplication, we employ best-first search:
   538 duplication, we employ best-first search:
   530 \begin{ttbox}
   539 \begin{ttbox}
   531 goal LK.thy "|- EX y. ALL x. P(y)-->P(x)";
   540 Goal "|- EX y. ALL x. P(y)-->P(x)";
   532 {\out Level 0}
   541 {\out Level 0}
   533 {\out  |- EX y. ALL x. P(y) --> P(x)}
   542 {\out  |- EX y. ALL x. P(y) --> P(x)}
   534 {\out  1.  |- EX y. ALL x. P(y) --> P(x)}
   543 {\out  1.  |- EX y. ALL x. P(y) --> P(x)}
   535 by (best_tac LK_dup_pack 1);
   544 by (best_tac LK_dup_pack 1);
   536 {\out Level 1}
   545 {\out Level 1}
   551 short manual proof.  See the directory {\tt LK/ex} for many more
   560 short manual proof.  See the directory {\tt LK/ex} for many more
   552 examples.
   561 examples.
   553 
   562 
   554 We set the main goal and move the negated formula to the left.
   563 We set the main goal and move the negated formula to the left.
   555 \begin{ttbox}
   564 \begin{ttbox}
   556 goal LK.thy "|- ~ (EX x. ALL y. F(y,x) <-> ~F(y,y))";
   565 Goal "|- ~ (EX x. ALL y. F(y,x) <-> ~F(y,y))";
   557 {\out Level 0}
   566 {\out Level 0}
   558 {\out  |- ~ (EX x. ALL y. F(y,x) <-> ~ F(y,y))}
   567 {\out  |- ~ (EX x. ALL y. F(y,x) <-> ~ F(y,y))}
   559 {\out  1.  |- ~ (EX x. ALL y. F(y,x) <-> ~ F(y,y))}
   568 {\out  1.  |- ~ (EX x. ALL y. F(y,x) <-> ~ F(y,y))}
   560 by (resolve_tac [notR] 1);
   569 by (resolve_tac [notR] 1);
   561 {\out Level 1}
   570 {\out Level 1}