Paper/Paper.thy
changeset 2349 eaf5209669de
parent 2348 09b476c20fe1
child 2350 0a5320c6a7e6
equal deleted inserted replaced
2348:09b476c20fe1 2349:eaf5209669de
  1273   \begin{center}
  1273   \begin{center}
  1274   @{text "bn\<^isub>1 l\<^isub>1, \<dots>, bn\<^isub>r l\<^isub>r"}
  1274   @{text "bn\<^isub>1 l\<^isub>1, \<dots>, bn\<^isub>r l\<^isub>r"}
  1275   \end{center}
  1275   \end{center}
  1276 
  1276 
  1277   \noindent
  1277   \noindent
  1278   with none of the @{text "l"}$_{1..r}$ being among the bodies @{text
  1278   with @{text "l"}$_{1..r}$ $\subseteq$ @{text "b"}$_{1..p}$ and none of the 
       
  1279   @{text "l"}$_{1..r}$ being among the bodies @{text
  1279   "d"}$_{1..q}$. The set @{text "B'"} is defined as
  1280   "d"}$_{1..q}$. The set @{text "B'"} is defined as
  1280   %
  1281   %
  1281   \begin{center}
  1282   \begin{center}
  1282   @{text "B' \<equiv> fa_bn\<^isub>1 l\<^isub>1 \<union> ... \<union> fa_bn\<^isub>r l\<^isub>r"}
  1283   @{text "B' \<equiv> fa_bn\<^isub>1 l\<^isub>1 \<union> ... \<union> fa_bn\<^isub>r l\<^isub>r"}
  1283   \end{center} 
  1284   \end{center} 
  1285   \noindent
  1286   \noindent
  1286   This completes the definition of the free-atom functions @{text "fa_ty"}$_{1..n}$.
  1287   This completes the definition of the free-atom functions @{text "fa_ty"}$_{1..n}$.
  1287 
  1288 
  1288   Note that for non-recursive deep binders, we have to add in \eqref{fadef}
  1289   Note that for non-recursive deep binders, we have to add in \eqref{fadef}
  1289   the set of atoms that are left unbound by the binding functions @{text
  1290   the set of atoms that are left unbound by the binding functions @{text
  1290   "bn"}$_{1..m}$. We use for the definition of
  1291   "bn"}$_{1..m}$. We used for the definition of
  1291   this set the functions @{text "fa_bn"}$_{1..m}$, which are also defined by mutual
  1292   this set the functions @{text "fa_bn"}$_{1..m}$, which are also defined by mutual
  1292   recursion. Assume the user specified a @{text bn}-clause of the form
  1293   recursion. Assume the user specified a @{text bn}-clause of the form
  1293   %
  1294   %
  1294   \begin{center}
  1295   \begin{center}
  1295   @{text "bn (C z\<^isub>1 \<dots> z\<^isub>s) = rhs"}
  1296   @{text "bn (C z\<^isub>1 \<dots> z\<^isub>s) = rhs"}
  1333   @{text "fa\<^bsub>bn\<^esub> (ACons a t as)"} & @{text "="} & @{text "(fa\<^bsub>trm\<^esub> t) \<union> (fa\<^bsub>bn\<^esub> as)"}
  1334   @{text "fa\<^bsub>bn\<^esub> (ACons a t as)"} & @{text "="} & @{text "(fa\<^bsub>trm\<^esub> t) \<union> (fa\<^bsub>bn\<^esub> as)"}
  1334   \end{tabular}
  1335   \end{tabular}
  1335   \end{center}
  1336   \end{center}
  1336 
  1337 
  1337   \noindent
  1338   \noindent
  1338   For these definitions, recall that @{text ANil} and @{text "ACons"} have no
  1339   Recall that @{text ANil} and @{text "ACons"} have no
  1339   binding clause in the specification. The corresponding free-atom
  1340   binding clause in the specification. The corresponding free-atom
  1340   function @{text "fa\<^bsub>assn\<^esub>"} therefore returns all free atoms
  1341   function @{text "fa\<^bsub>assn\<^esub>"} therefore returns all free atoms
  1341   occurring in an assignment (in case of @{text "ACons"}, they are given by 
  1342   occurring in an assignment (in case of @{text "ACons"}, they are given by 
  1342   calls to @{text supp}, @{text "fa\<^bsub>trm\<^esub>"} and @{text "fa\<^bsub>assn\<^esub>"}). 
  1343   calls to @{text supp}, @{text "fa\<^bsub>trm\<^esub>"} and @{text "fa\<^bsub>assn\<^esub>"}). 
  1343   The binding only takes place in @{text Let} and
  1344   The binding only takes place in @{text Let} and
  1349   in contrast with @{text "Let_rec"} where we have a recursive
  1350   in contrast with @{text "Let_rec"} where we have a recursive
  1350   binder to bind all occurrences of the atoms in @{text
  1351   binder to bind all occurrences of the atoms in @{text
  1351   "set (bn as)"} also inside @{text "as"}. Therefore we have to subtract
  1352   "set (bn as)"} also inside @{text "as"}. Therefore we have to subtract
  1352   @{text "set (bn as)"} from both @{text "fa\<^bsub>trm\<^esub> t"} and @{text "fa\<^bsub>assn\<^esub> as"}. 
  1353   @{text "set (bn as)"} from both @{text "fa\<^bsub>trm\<^esub> t"} and @{text "fa\<^bsub>assn\<^esub> as"}. 
  1353   Like the function @{text "bn"}, the function @{text "fa\<^bsub>bn\<^esub>"} traverses the 
  1354   Like the function @{text "bn"}, the function @{text "fa\<^bsub>bn\<^esub>"} traverses the 
  1354   list of assignments, but instead returns the free atoms, that means in this 
  1355   list of assignments, but instead returns the free atoms, which means in this 
  1355   example the free atoms in the argument @{text "t"}.  
  1356   example the free atoms in the argument @{text "t"}.  
  1356 
  1357 
  1357   An interesting point in this
  1358   An interesting point in this
  1358   example is that a ``naked'' assignment (@{text "ANil"} or @{text "ACons"}) does not bind any
  1359   example is that a ``naked'' assignment (@{text "ANil"} or @{text "ACons"}) does not bind any
  1359   atoms, even if the binding function is specified over assignments. 
  1360   atoms, even if the binding function is specified over assignments. 
  1447   \noindent
  1448   \noindent
  1448   In this case we define a premise @{text P} using the relation
  1449   In this case we define a premise @{text P} using the relation
  1449   $\approx_{\,\textit{set}}$ given in Section~\ref{sec:binders} (similarly
  1450   $\approx_{\,\textit{set}}$ given in Section~\ref{sec:binders} (similarly
  1450   $\approx_{\,\textit{res}}$ and $\approx_{\,\textit{list}}$ for the other
  1451   $\approx_{\,\textit{res}}$ and $\approx_{\,\textit{list}}$ for the other
  1451   binding modes). This premise defines $\alpha$-equivalence of two abstractions
  1452   binding modes). This premise defines $\alpha$-equivalence of two abstractions
  1452   involving multiple binders. We first define as above the tuples @{text "D"} and
  1453   involving multiple binders. As above, we first build the tuples @{text "D"} and
  1453   @{text "D'"} for the bodies @{text "d"}$_{1..q}$, and the corresponding
  1454   @{text "D'"} for the bodies @{text "d"}$_{1..q}$, and the corresponding
  1454   compound $\alpha$-relation @{text "R"} (shown in \eqref{rempty}). 
  1455   compound $\alpha$-relation @{text "R"} (shown in \eqref{rempty}). 
  1455   For $\approx_{\,\textit{set}}$ we also need
  1456   For $\approx_{\,\textit{set}}$ we also need
  1456   a compound free-atom function for the bodies defined as
  1457   a compound free-atom function for the bodies defined as
  1457   %
  1458   %
  1470 
  1471 
  1471   \noindent
  1472   \noindent
  1472   Similarly for @{text "B'"} using the labels @{text "b\<PRIME>"}$_{1..p}$. This 
  1473   Similarly for @{text "B'"} using the labels @{text "b\<PRIME>"}$_{1..p}$. This 
  1473   lets us formally define the premise @{text P} for a non-empty binding clause as:
  1474   lets us formally define the premise @{text P} for a non-empty binding clause as:
  1474   %
  1475   %
  1475   \begin{equation}\label{pprem}
  1476   \begin{center}
  1476   \mbox{@{term "P \<equiv> \<exists>p. (B, D) \<approx>gen R fa p (B', D')"}}\;.
  1477   \mbox{@{term "P \<equiv> \<exists>p. (B, D) \<approx>gen R fa p (B', D')"}}\;.
  1477   \end{equation}
  1478   \end{center}
  1478 
  1479 
  1479   \noindent
  1480   \noindent
  1480   This premise accounts for $\alpha$-equivalence of the bodies of the binding
  1481   This premise accounts for $\alpha$-equivalence of the bodies of the binding
  1481   clause. However, in case the binders have non-recursive deep binders, then
  1482   clause. Similarly for the other binding modes.
       
  1483   However, in case the binders have non-recursive deep binders, this premise
       
  1484   is not enough:
  1482   we also have to ``propagate'' $\alpha$-equivalence inside the structure of
  1485   we also have to ``propagate'' $\alpha$-equivalence inside the structure of
  1483   these binders. An example is @{text "Let"} where we have to make sure the
  1486   these binders. An example is @{text "Let"} where we have to make sure the
  1484   right-hand sides of assignments are $\alpha$-equivalent. For this we use the
  1487   right-hand sides of assignments are $\alpha$-equivalent. For this we use the
  1485   relations @{text "\<approx>bn"}$_{1..m}$ (which we will formally define shortly).
  1488   relations @{text "\<approx>bn"}$_{1..m}$ (which we will formally define shortly).
  1486   Let us assume the non-recursive deep binders in @{text "bc\<^isub>i"} are
  1489   Let us assume the non-recursive deep binders in @{text "bc\<^isub>i"} are
  1488   \begin{center}
  1491   \begin{center}
  1489   @{text "bn\<^isub>1 l\<^isub>1, \<dots>, bn\<^isub>r l\<^isub>r"}.
  1492   @{text "bn\<^isub>1 l\<^isub>1, \<dots>, bn\<^isub>r l\<^isub>r"}.
  1490   \end{center}
  1493   \end{center}
  1491 
  1494 
  1492   \noindent
  1495   \noindent
  1493   The premises for @{text "bc\<^isub>i"} are then defined as
  1496   All premises for @{text "bc\<^isub>i"} are then given by
  1494   %
  1497   %
  1495   \begin{center}
  1498   \begin{center}
  1496   @{text "prems(bc\<^isub>i) \<equiv> P  \<and>  l\<^isub>1 \<approx>bn\<^isub>1 l\<PRIME>\<^isub>1  \<and> ... \<and>  l\<^isub>r \<approx>bn\<^isub>r l\<PRIME>\<^isub>r"}
  1499   @{text "prems(bc\<^isub>i) \<equiv> P  \<and>  l\<^isub>1 \<approx>bn\<^isub>1 l\<PRIME>\<^isub>1  \<and> ... \<and>  l\<^isub>r \<approx>bn\<^isub>r l\<PRIME>\<^isub>r"}
  1497   \end{center} 
  1500   \end{center} 
  1498 
  1501 
  1499   \noindent
  1502   \noindent 
  1500   where @{text "P"} is defined in \eqref{pprem}. 
  1503   where the auxiliary $\alpha$-equivalence relations @{text "\<approx>bn"}$_{1..m}$ 
  1501  
  1504   are defined as follows: assuming a @{text bn}-clause is of the form
  1502   The $\alpha$-equivalence relations @{text "\<approx>bn"}$_{1..m}$ are defined as follows:
       
  1503   given a @{text bn}-clause of the form
       
  1504   %
  1505   %
  1505   \begin{center}
  1506   \begin{center}
  1506   @{text "bn (C z\<^isub>1 \<dots> z\<^isub>s) = rhs"}
  1507   @{text "bn (C z\<^isub>1 \<dots> z\<^isub>s) = rhs"}
  1507   \end{center}
  1508   \end{center}
  1508 
  1509 
  1514   \mbox{\infer{@{text "C z\<^isub>1 \<dots> z\<^isub>s \<approx>bn C z\<PRIME>\<^isub>1 \<dots> z\<PRIME>\<^isub>s"}}
  1515   \mbox{\infer{@{text "C z\<^isub>1 \<dots> z\<^isub>s \<approx>bn C z\<PRIME>\<^isub>1 \<dots> z\<PRIME>\<^isub>s"}}
  1515   {@{text "z\<^isub>1 R\<^isub>1 z\<PRIME>\<^isub>1 \<dots> z\<^isub>s R\<^isub>s z\<PRIME>\<^isub>s"}}}
  1516   {@{text "z\<^isub>1 R\<^isub>1 z\<PRIME>\<^isub>1 \<dots> z\<^isub>s R\<^isub>s z\<PRIME>\<^isub>s"}}}
  1516   \end{center}
  1517   \end{center}
  1517   
  1518   
  1518   \noindent
  1519   \noindent
  1519   whereby the relations @{text "R"}$_{1..s}$ are given by 
  1520   In this clause the relations @{text "R"}$_{1..s}$ are given by 
  1520 
  1521 
  1521   \begin{center}
  1522   \begin{center}
  1522   \begin{tabular}{c@ {\hspace{2mm}}p{7cm}}
  1523   \begin{tabular}{c@ {\hspace{2mm}}p{7cm}}
  1523   $\bullet$ & @{text "z\<^isub>i \<approx>ty z\<PRIME>\<^isub>i"} provided @{text "z\<^isub>i"} does not occur in @{text rhs} and 
  1524   $\bullet$ & @{text "z\<^isub>i \<approx>ty z\<PRIME>\<^isub>i"} provided @{text "z\<^isub>i"} does not occur in @{text rhs} and 
  1524   is a recursive argument of @{text C},\\
  1525   is a recursive argument of @{text C},\\
  1533 
  1534 
  1534   \noindent
  1535   \noindent
  1535   This completes the definition of $\alpha$-equivalence. As a sanity check, we can show
  1536   This completes the definition of $\alpha$-equivalence. As a sanity check, we can show
  1536   that the premises of empty binding clauses are a special case of the clauses for 
  1537   that the premises of empty binding clauses are a special case of the clauses for 
  1537   non-empty ones (we just have to unfold the definition of $\approx_{\,\textit{set}}$ and take @{text "0"}
  1538   non-empty ones (we just have to unfold the definition of $\approx_{\,\textit{set}}$ and take @{text "0"}
  1538   as the permutation).
  1539   for the existentially quantified permutation).
  1539 *}
  1540 *}
  1540 (*<*)consts alpha_ty ::'a
  1541 (*<*)
       
  1542 consts alpha_ty ::'a
  1541 consts alpha_trm ::'a
  1543 consts alpha_trm ::'a
  1542 consts fa_trm :: 'a
  1544 consts fa_trm :: 'a
  1543 consts alpha_trm2 ::'a
  1545 consts alpha_trm2 ::'a
  1544 consts fa_trm2 :: 'a
  1546 consts fa_trm2 :: 'a
       
  1547 (*consts ast :: 'a
       
  1548 consts ast' :: 'a*)
       
  1549 (*
  1545 notation (latex output) 
  1550 notation (latex output) 
  1546   alpha_ty ("\<approx>ty") and
  1551   alpha_ty ("\<approx>ty") and
  1547   alpha_trm ("\<approx>\<^bsub>trm\<^esub>") and
  1552   alpha_trm ("\<approx>\<^bsub>trm\<^esub>") and
  1548   fa_trm ("fa\<^bsub>trm\<^esub>") and
  1553   fa_trm ("fa\<^bsub>trm\<^esub>") and
  1549   alpha_trm2 ("\<approx>\<^bsub>assn\<^esub> \<otimes> \<approx>\<^bsub>trm\<^esub>") and
  1554   alpha_trm2 ("\<approx>\<^bsub>assn\<^esub>\<approx>\<^bsub>trm\<^esub>") and
  1550   fa_trm2 ("fa\<^bsub>assn\<^esub> \<oplus> fa\<^bsub>trm\<^esub>")(*>*)
  1555   fa_trm2 ("fa\<^bsub>assn\<^esub>fa\<^bsub>trm\<^esub>") and
       
  1556   ast ("'(as, t')") and
       
  1557   ast' ("'(as', t\<PRIME> ')")
       
  1558 *)
       
  1559 (*>*)
  1551 text {*
  1560 text {*
  1552   Again lets take a look at a concrete example for these definitions. For \eqref{letrecs}
  1561   Again lets take a look at a concrete example for these definitions. For \eqref{letrecs}
  1553   we have three relations $\approx_{\textit{trm}}$, $\approx_{\textit{assn}}$ and
  1562   we have three relations $\approx_{\textit{trm}}$, $\approx_{\textit{assn}}$ and
  1554   $\approx_{\textit{bn}}$ with the following clauses:
  1563   $\approx_{\textit{bn}}$ with the following clauses:
  1555 
  1564 
  1556   \begin{center}
  1565   \begin{center}
  1557   \begin{tabular}{@ {}c @ {}}
  1566   \begin{tabular}{@ {}c @ {}}
  1558   \infer{@{text "Let as t \<approx>\<^bsub>trm\<^esub> Let as' t'"}}
  1567 %  \infer{@{text "Let as t \<approx>\<^bsub>trm\<^esub> Let as' t'"}}
  1559   {@{term "\<exists>p. (bn as, t) \<approx>lst alpha_trm fa_trm p (bn as', t')"} & @{text "as \<approx>\<^bsub>bn\<^esub> as'"}}\smallskip\\
  1568 %  {@{term "\<exists>p. (bn as, t) \<approx>lst alpha_trm fa_trm p (bn as', t')"} & @{text "as \<approx>\<^bsub>bn\<^esub> as'"}}\smallskip\\
  1560   \infer{@{text "Let_rec as t \<approx>\<^bsub>trm\<^esub> Let_rec as' t'"}}
  1569 %  \infer{@{text "Let_rec as t \<approx>\<^bsub>trm\<^esub> Let_rec as' t'"}}
  1561   {@{term "\<exists>p. (bn as, (as, t)) \<approx>lst alpha_trm2 fa_trm2 p (bn as', (as', t'))"}}
  1570 %  {@{term "\<exists>p. (bn as, ast) \<approx>lst alpha_trm2 fa_trm2 p (bn as', ast')"}}
  1562   \end{tabular}
  1571   \end{tabular}
  1563   \end{center}
  1572   \end{center}
  1564 
  1573 
  1565   \begin{center}
  1574   \begin{center}
  1566   \begin{tabular}{@ {}c @ {}}
  1575   \begin{tabular}{@ {}c @ {}}