16 fresh ("_ # _" [51, 51] 50) and |
16 fresh ("_ # _" [51, 51] 50) and |
17 fresh_star ("_ #\<^sup>* _" [51, 51] 50) and |
17 fresh_star ("_ #\<^sup>* _" [51, 51] 50) and |
18 supp ("supp _" [78] 73) and |
18 supp ("supp _" [78] 73) and |
19 uminus ("-_" [78] 73) and |
19 uminus ("-_" [78] 73) and |
20 If ("if _ then _ else _" 10) and |
20 If ("if _ then _ else _" 10) and |
21 alpha_gen ("_ \<approx>\<^raw:\raisebox{-1pt}{\makebox[0mm][l]{$\,_{\textit{set}}$}}>\<^bsup>_,_,_\<^esup> _") and |
21 alpha_gen ("_ \<approx>\<^raw:\raisebox{-1pt}{\makebox[0mm][l]{$\,_{\textit{set}}$}}>\<^bsup>_, _, _\<^esup> _") and |
22 alpha_lst ("_ \<approx>\<^raw:\raisebox{-1pt}{\makebox[0mm][l]{$\,_{\textit{list}}$}}>\<^bsup>_,_,_\<^esup> _") and |
22 alpha_lst ("_ \<approx>\<^raw:\raisebox{-1pt}{\makebox[0mm][l]{$\,_{\textit{list}}$}}>\<^bsup>_, _, _\<^esup> _") and |
23 alpha_res ("_ \<approx>\<^raw:\raisebox{-1pt}{\makebox[0mm][l]{$\,_{\textit{res}}$}}>\<^bsup>_,_,_\<^esup> _") and |
23 alpha_res ("_ \<approx>\<^raw:\raisebox{-1pt}{\makebox[0mm][l]{$\,_{\textit{res}}$}}>\<^bsup>_, _, _\<^esup> _") and |
24 abs_set ("_ \<approx>\<^raw:{$\,_{\textit{abs\_set}}$}> _") and |
24 abs_set ("_ \<approx>\<^raw:{$\,_{\textit{abs\_set}}$}> _") and |
25 fv ("fv'(_')" [100] 100) and |
25 fv ("fv'(_')" [100] 100) and |
26 equal ("=") and |
26 equal ("=") and |
27 alpha_abs ("_ \<approx>\<^raw:{$\,_{\textit{abs\_set}}$}> _") and |
27 alpha_abs ("_ \<approx>\<^raw:{$\,_{\textit{abs\_set}}$}> _") and |
28 Abs ("[_]\<^raw:$\!$>\<^bsub>set\<^esub>._" [20, 101] 999) and |
28 Abs ("[_]\<^raw:$\!$>\<^bsub>set\<^esub>._" [20, 101] 999) and |
29 Abs_lst ("[_]\<^raw:$\!$>\<^bsub>list\<^esub>._") and |
29 Abs_lst ("[_]\<^raw:$\!$>\<^bsub>list\<^esub>._") and |
30 Abs_res ("[_]\<^raw:$\!$>\<^bsub>res\<^esub>._") and |
30 Abs_res ("[_]\<^raw:$\!$>\<^bsub>res\<^esub>._") and |
31 Cons ("_::_" [78,77] 73) and |
31 Cons ("_::_" [78,77] 73) and |
32 supp_gen ("aux _" [1000] 10) and |
32 supp_gen ("aux _" [1000] 10) and |
33 alpha_bn ("_ \<approx>bn _") |
33 alpha_bn ("_ \<approx>bn _") |
34 |
|
35 (*>*) |
34 (*>*) |
36 |
35 |
37 |
36 |
38 section {* Introduction *} |
37 section {* Introduction *} |
39 |
38 |
40 text {* |
39 text {* |
|
40 @{text "(1, (2, 3))"} |
|
41 |
41 So far, Nominal Isabelle provides a mechanism for constructing |
42 So far, Nominal Isabelle provides a mechanism for constructing |
42 alpha-equated terms, for example |
43 alpha-equated terms, for example |
43 |
44 |
44 \begin{center} |
45 \begin{center} |
45 @{text "t ::= x | t t | \<lambda>x. t"} |
46 @{text "t ::= x | t t | \<lambda>x. t"} |
731 \noindent |
732 \noindent |
732 (similarly for $\approx_{\textit{abs\_list}}$ |
733 (similarly for $\approx_{\textit{abs\_list}}$ |
733 and $\approx_{\textit{abs\_res}}$). We can show that these relations are equivalence |
734 and $\approx_{\textit{abs\_res}}$). We can show that these relations are equivalence |
734 relations and equivariant. |
735 relations and equivariant. |
735 |
736 |
736 \begin{lemma}\label{alphaeq} The relations |
737 \begin{lemma}\label{alphaeq} |
737 $\approx_{\textit{abs\_set}}$, |
738 The relations $\approx_{\textit{abs\_set}}$, $\approx_{\textit{abs\_list}}$ |
738 $\approx_{\textit{abs\_list}}$ |
739 and $\approx_{\textit{abs\_res}}$ are equivalence relations, and if @{term |
739 and $\approx_{\textit{abs\_res}}$ |
740 "abs_set (as, x) (bs, y)"} then also @{term "abs_set (p \<bullet> as, p \<bullet> x) (p \<bullet> |
740 are equivalence |
741 bs, p \<bullet> y)"} (similarly for the other two relations). |
741 relations, and if @{term "abs_set (as, x) (bs, y)"} then also |
|
742 @{term "abs_set (p \<bullet> as, p \<bullet> x) (p \<bullet> bs, p \<bullet> y)"} (similarly for |
|
743 the other two relations). |
|
744 \end{lemma} |
742 \end{lemma} |
745 |
743 |
746 \begin{proof} |
744 \begin{proof} |
747 Reflexivity is by taking @{text "p"} to be @{text "0"}. For symmetry we have |
745 Reflexivity is by taking @{text "p"} to be @{text "0"}. For symmetry we have |
748 a permutation @{text p} and for the proof obligation take @{term "-p"}. In case |
746 a permutation @{text p} and for the proof obligation take @{term "-p"}. In case |
1341 be easier to analyse these pairs according to ``clusters'' of the binding clauses. |
1339 be easier to analyse these pairs according to ``clusters'' of the binding clauses. |
1342 Therefore we distinguish the following cases: |
1340 Therefore we distinguish the following cases: |
1343 *} |
1341 *} |
1344 (*<*) |
1342 (*<*) |
1345 consts alpha_ty ::'a |
1343 consts alpha_ty ::'a |
1346 notation alpha_ty ("\<approx>ty") |
1344 consts alpha_trm ::'a |
|
1345 consts fv_trm :: 'a |
|
1346 consts alpha_trm2 ::'a |
|
1347 consts fv_trm2 :: 'a |
|
1348 notation (latex output) |
|
1349 alpha_ty ("\<approx>ty") and |
|
1350 alpha_trm ("\<approx>\<^bsub>trm\<^esub>") and |
|
1351 fv_trm ("fv\<^bsub>trm\<^esub>") and |
|
1352 alpha_trm2 ("\<approx>\<^bsub>assn\<^esub> \<otimes> \<approx>\<^bsub>trm\<^esub>") and |
|
1353 fv_trm2 ("fv\<^bsub>assn\<^esub> \<oplus> fv\<^bsub>trm\<^esub>") |
1347 (*>*) |
1354 (*>*) |
1348 text {* |
1355 text {* |
1349 \begin{itemize} |
1356 \begin{itemize} |
1350 \item The @{text "(x\<^isub>i, y\<^isub>i)"} are bodies of shallow binders with type @{text "ty"}. We assume the |
1357 \item The @{text "(x\<^isub>i, y\<^isub>i)"} are bodies of shallow binders with type @{text "ty"}. We assume the |
1351 \mbox{@{text "(u\<^isub>1, v\<^isub>1),\<dots>,(u\<^isub>m, v\<^isub>m)"}} are the corresponding binders. For the binding mode |
1358 \mbox{@{text "(u\<^isub>1, v\<^isub>1),\<dots>,(u\<^isub>m, v\<^isub>m)"}} are the corresponding binders. For the binding mode |
1397 neither a binder nor a body. Then we just generate @{text "x\<^isub>i \<approx>ty y\<^isub>i"} provided |
1404 neither a binder nor a body. Then we just generate @{text "x\<^isub>i \<approx>ty y\<^isub>i"} provided |
1398 the type of @{text "x\<^isub>i"} and @{text "y\<^isub>i"} is @{text ty} and the arguments are |
1405 the type of @{text "x\<^isub>i"} and @{text "y\<^isub>i"} is @{text ty} and the arguments are |
1399 recursive arguments of the term-constructor. If they are non-recursive arguments |
1406 recursive arguments of the term-constructor. If they are non-recursive arguments |
1400 then we generate just @{text "x\<^isub>i = y\<^isub>i"}. |
1407 then we generate just @{text "x\<^isub>i = y\<^isub>i"}. |
1401 |
1408 |
1402 TODO |
1409 {\bf TODO (I do not understand the definition below yet).} |
1403 |
1410 |
1404 The alpha-equivalence relations for binding functions are similar to the alpha-equivalences |
1411 The alpha-equivalence relations for binding functions are similar to the alpha-equivalences |
1405 for their respective types, the difference is that they ommit checking the arguments that |
1412 for their respective types, the difference is that they ommit checking the arguments that |
1406 are bound. We assumed that there are no bindings in the type on which the binding function |
1413 are bound. We assumed that there are no bindings in the type on which the binding function |
1407 is defined so, there are no permutations involved. For a binding function clause |
1414 is defined so, there are no permutations involved. For a binding function clause |
1416 occuring in @{text "rhs"} under the binding function @{text "bn\<^isub>m"}\\ |
1423 occuring in @{text "rhs"} under the binding function @{text "bn\<^isub>m"}\\ |
1417 $\bullet$ & @{text "x\<^isub>j \<approx> y\<^isub>j"} otherwise\\ |
1424 $\bullet$ & @{text "x\<^isub>j \<approx> y\<^isub>j"} otherwise\\ |
1418 \end{tabular} |
1425 \end{tabular} |
1419 \end{center} |
1426 \end{center} |
1420 |
1427 |
|
1428 Again lets take a look at an example for these definitions. For \eqref{letrecs} |
|
1429 we have three relations, namely $\approx_{\textit{trm}}$, $\approx_{\textit{assn}}$ and |
|
1430 $\approx_{\textit{bn}}$, with the clauses as follows: |
|
1431 |
|
1432 \begin{center} |
|
1433 \begin{tabular}{@ {}c @ {}} |
|
1434 \infer{@{text "Let as t \<approx>\<^bsub>trm\<^esub> Let as' t'"}} |
|
1435 {@{text "as \<approx>\<^bsub>bn\<^esub> as'"} & @{term "\<exists>p. (bn as, t) \<approx>lst alpha_trm fv_trm p (bn as', t')"}}\smallskip\\ |
|
1436 \infer{@{text "Let_rec as t \<approx>\<^bsub>trm\<^esub> Let_rec as' t'"}} |
|
1437 {@{term "\<exists>p. (bn as, (as, t)) \<approx>lst alpha_trm2 fv_trm2 p (bn as', (as', t'))"}} |
|
1438 \end{tabular} |
|
1439 \end{center} |
|
1440 |
|
1441 \begin{center} |
|
1442 \begin{tabular}{@ {}c @ {}} |
|
1443 \infer{@{text "ANil \<approx>\<^bsub>assn\<^esub> ANil"}}{}\\ |
|
1444 \infer{@{text "ACons a t as \<approx>\<^bsub>assn\<^esub> ACons a' t' as"}} |
|
1445 {@{text "a = a'"} & @{text "t \<approx>\<^bsub>trm\<^esub> t'"} & @{text "as \<approx>\<^bsub>assn\<^esub> as'"}}\medskip\\ |
|
1446 \end{tabular} |
|
1447 \end{center} |
|
1448 |
|
1449 \begin{center} |
|
1450 \begin{tabular}{@ {}c @ {}} |
|
1451 \infer{@{text "ANil \<approx>\<^bsub>bn\<^esub> ANil"}}{}\\ |
|
1452 \infer{@{text "ACons a t as \<approx>\<^bsub>bn\<^esub> ACons a' t' as"}} |
|
1453 {@{text "t \<approx>\<^bsub>trm\<^esub> t'"} & @{text "as \<approx>\<^bsub>bn\<^esub> as'"}}\medskip\\ |
|
1454 \end{tabular} |
|
1455 \end{center} |
|
1456 |
|
1457 \noindent |
|
1458 Note the difference between $\approx_{\textit{assn}}$ and |
|
1459 $\approx_{\textit{bn}}$: the latter only ``tracks'' alpha-equivalence of |
|
1460 the components in an assignment that are \emph{not} bound. Therefore we have |
|
1461 a $\approx_{\textit{bn}}$-premise in the clause for @{text "Let"} (which is |
|
1462 a non-recursive binder), since the terms inside an assignment are not meant |
|
1463 to be under the binder. Such a premise is not needed in @{text "Let_rec"}, |
|
1464 because there everything from the assignment is under the binder. |
1421 *} |
1465 *} |
1422 |
1466 |
1423 section {* The Lifting of Definitions and Properties *} |
1467 section {* Establishing the Reasoning Infrastructure *} |
1424 |
1468 |
1425 text {* |
1469 text {* |
1426 To define the quotient types we first need to show that the defined |
1470 Having made all these definition for raw terms, we can start to introduce |
1427 relations are equivalence relations. |
1471 the resoning infrastructure for the specified types. For this we first |
1428 |
1472 have to show that the alpha-equivalence relation defined in the previous |
1429 \begin{lemma} The relations @{text "\<approx>\<^isub>1 \<dots> \<approx>\<^isub>1"} and @{text "\<approx>bn\<^isub>1 \<dots> \<approx>bn\<^isub>m"} |
1473 sections are indeed equivalence relations. |
1430 defined as above are equivalence relations and are equivariant. |
1474 |
|
1475 \begin{lemma} |
|
1476 Given the raw types @{text "ty\<^isub>1, \<dots>, ty\<^isub>n"} and binding functions |
|
1477 @{text "bn\<^isub>1, \<dots>, bn\<^isub>m"}, the relations @{text "\<approx>ty\<^isub>1, \<dots>, \<approx>ty\<^isub>n"} and |
|
1478 @{text "\<approx>bn\<^isub>1 \<dots> \<approx>bn\<^isub>m"} are equivalence relations and equivariant. |
1431 \end{lemma} |
1479 \end{lemma} |
1432 \begin{proof} Reflexivity by induction on the raw datatype. Symmetry, |
1480 |
1433 transitivity and equivariance by induction on the alpha equivalence |
1481 \begin{proof} |
1434 relation. Using lemma \ref{alphaeq}, the conditions follow by simple |
1482 The proof is by induction over the definitions. The non-trivial |
1435 calculations. \end{proof} |
1483 cases involves premises build up by $\approx_{\textit{set}}$, |
1436 |
1484 $\approx_{\textit{res}}$ and $\approx_{\textit{list}}$. They |
1437 \noindent We then define the quotient types @{text "ty\<^isub>1\<^isup>\<alpha> \<dots> ty\<^isub>n\<^isup>\<alpha>"}. To lift |
1485 can be dealt with like in Lemma~\ref{alphaeq}. |
|
1486 \end{proof} |
|
1487 |
|
1488 \noindent |
|
1489 We can feed this lemma into our quotient package and obtain new types @{text |
|
1490 "ty"}$^\alpha_{1..n}$ representing alpha-equated terms of types @{text |
|
1491 "ty"}$_{1..n}$. We also obtain definitions for the term-constructors @{text |
|
1492 "C"}$^\alpha_{1..m}$ from the raw term-constructors @{text |
|
1493 "C"}$_{1..m}$. Similarly for the free-variable functions @{text |
|
1494 "fv_ty"}$^\alpha_{1..n}$ and the binding functions @{text |
|
1495 "bn"}$^\alpha_{1..k}$. However, these definitions are of not much use for the |
|
1496 user, since the are formulated in terms of the isomorphism we obtained by |
|
1497 cerating a new type in Isabelle/HOL (remember the picture shown in the |
|
1498 Introduction). |
|
1499 |
|
1500 {\bf TODO below.} |
|
1501 |
|
1502 then define the quotient types @{text "ty\<^isub>1\<^isup>\<alpha> \<dots> ty\<^isub>n\<^isup>\<alpha>"}. To lift |
1438 the raw definitions to the quotient type, we need to prove that they |
1503 the raw definitions to the quotient type, we need to prove that they |
1439 \emph{respect} the relation. We follow the definition of respectfullness given |
1504 \emph{respect} the relation. We follow the definition of respectfullness given |
1440 by Homeier~\cite{Homeier05}. The intuition behind a respectfullness condition |
1505 by Homeier~\cite{Homeier05}. The intuition behind a respectfullness condition |
1441 is that when a function (or constructor) is given arguments that are |
1506 is that when a function (or constructor) is given arguments that are |
1442 alpha-equivalent the results are also alpha equivalent. For arguments that are |
1507 alpha-equivalent the results are also alpha equivalent. For arguments that are |
1627 \phantom{$|$}~@{text "Var var"}~$|$~@{text "K string"}\\ |
1672 \phantom{$|$}~@{text "Var var"}~$|$~@{text "K string"}\\ |
1628 $|$~@{text "LAM_ty tv::tvar tkind t::trm"} \isacommand{bind}~@{text "tv"}~\isacommand{in}~@{text t}\\ |
1673 $|$~@{text "LAM_ty tv::tvar tkind t::trm"} \isacommand{bind}~@{text "tv"}~\isacommand{in}~@{text t}\\ |
1629 $|$~@{text "LAM_cty cv::cvar ckind t::trm"} \isacommand{bind}~@{text "cv"}~\isacommand{in}~@{text t}\\ |
1674 $|$~@{text "LAM_cty cv::cvar ckind t::trm"} \isacommand{bind}~@{text "cv"}~\isacommand{in}~@{text t}\\ |
1630 $|$~@{text "App_ty trm ty"}~$|$~@{text "App_cty trm cty"}~$|$~@{text "App trm trm"}\\ |
1675 $|$~@{text "App_ty trm ty"}~$|$~@{text "App_cty trm cty"}~$|$~@{text "App trm trm"}\\ |
1631 $|$~@{text "Lam v::var ty t::trm"} \isacommand{bind}~@{text "v"}~\isacommand{in}~@{text t}\\ |
1676 $|$~@{text "Lam v::var ty t::trm"} \isacommand{bind}~@{text "v"}~\isacommand{in}~@{text t}\\ |
1632 $|$~@{text "Let x::var ty trm t::trm"} \isacommand{bind}~{text x}~\isacommand{in}~{text t}\\ |
1677 $|$~@{text "Let x::var ty trm t::trm"} \isacommand{bind}~@{text x}~\isacommand{in}~@{text t}\\ |
1633 $|$~@{text "Case trm assoc_lst"}~$|$~@{text "Cast trm co"}\\ |
1678 $|$~@{text "Case trm assoc_lst"}~$|$~@{text "Cast trm co"}\\ |
1634 \isacommand{and}~@{text "assoc_lst ="}\\ |
1679 \isacommand{and}~@{text "assoc_lst ="}\\ |
1635 \phantom{$|$}~@{text ANil}~% |
1680 \phantom{$|$}~@{text ANil}~% |
1636 $|$~@{text "ACons p::pat t::trm assoc_lst"} \isacommand{bind}~@{text "bv p"}~\isacommand{in}~@{text t}\\ |
1681 $|$~@{text "ACons p::pat t::trm assoc_lst"} \isacommand{bind}~@{text "bv p"}~\isacommand{in}~@{text t}\\ |
1637 \isacommand{and}~@{text "pat ="}\\ |
1682 \isacommand{and}~@{text "pat ="}\\ |
1655 $|$~@{text "bv2 (TVTKCons a ty tl) = (atom a)::(bv2 tl)"}\\ |
1700 $|$~@{text "bv2 (TVTKCons a ty tl) = (atom a)::(bv2 tl)"}\\ |
1656 $|$~@{text "bv3 TVCKNil = []"}\\ |
1701 $|$~@{text "bv3 TVCKNil = []"}\\ |
1657 $|$~@{text "bv3 (TVCKCons c cty tl) = (atom c)::(bv3 tl)"}\\ |
1702 $|$~@{text "bv3 (TVCKCons c cty tl) = (atom c)::(bv3 tl)"}\\ |
1658 \end{tabular} |
1703 \end{tabular} |
1659 \end{boxedminipage} |
1704 \end{boxedminipage} |
1660 \caption{\label{nominalcorehas}} |
1705 \caption{The nominal datatype declaration for Core-Haskell. At the moment we |
|
1706 do not support nested types; therefore we explicitly have to unfold the |
|
1707 lists @{text "co_lst"}, @{text "assoc_lst"} and so on. This will be improved |
|
1708 in a future version of Nominal Isabelle. Apart from that, the |
|
1709 declaration follows closely the original in Figure~\ref{corehas}. The |
|
1710 point of our work is that having made such a declaration one obtains |
|
1711 automatically a reasoning infrastructure for Core-Haskell.\label{nominalcorehas}} |
1661 \end{figure} |
1712 \end{figure} |
1662 *} |
1713 *} |
1663 |
1714 |
1664 |
1715 |
1665 |
1716 (* @{thm "ACons_subst[no_vars]"}*) |
1666 |
1717 |
1667 section {* Adequacy *} |
1718 section {* Strong Induction Principles *} |
1668 |
1719 |
1669 section {* Related Work *} |
1720 section {* Related Work *} |
1670 |
1721 |
1671 text {* |
1722 text {* |
1672 To our knowledge the earliest usage of general binders in a theorem prover setting is |
1723 To our knowledge the earliest usage of general binders in a theorem prover setting is |
1716 The formalisation presented here will eventually become part of the |
1781 The formalisation presented here will eventually become part of the |
1717 Isabelle distribution, but for the moment it can be downloaded from |
1782 Isabelle distribution, but for the moment it can be downloaded from |
1718 the Mercurial repository linked at |
1783 the Mercurial repository linked at |
1719 \href{http://isabelle.in.tum.de/nominal/download} |
1784 \href{http://isabelle.in.tum.de/nominal/download} |
1720 {http://isabelle.in.tum.de/nominal/download}.\medskip |
1785 {http://isabelle.in.tum.de/nominal/download}.\medskip |
1721 *} |
1786 |
1722 |
|
1723 text {* |
|
1724 \noindent |
1787 \noindent |
1725 {\bf Acknowledgements:} We are very grateful to Andrew Pitts for |
1788 {\bf Acknowledgements:} We are very grateful to Andrew Pitts for |
1726 many discussions about Nominal Isabelle. We thank Peter Sewell for |
1789 many discussions about Nominal Isabelle. We thank Peter Sewell for |
1727 making the informal notes \cite{SewellBestiary} available to us and |
1790 making the informal notes \cite{SewellBestiary} available to us and |
1728 also for patiently explaining some of the finer points about the abstract |
1791 also for patiently explaining some of the finer points about the abstract |
1729 definitions and about the implementation of the Ott-tool. We |
1792 definitions and about the implementation of the Ott-tool. We |
1730 also thank Stephanie Weirich for suggesting to separate the subgrammars |
1793 also thank Stephanie Weirich for suggesting to separate the subgrammars |
1731 of kinds and types in our Core-Haskell example. |
1794 of kinds and types in our Core-Haskell example. |
1732 |
|
1733 |
|
1734 |
|
1735 |
|
1736 *} |
1795 *} |
1737 |
1796 |
1738 |
1797 |
1739 |
1798 |
1740 (*<*) |
1799 (*<*) |