210 We can install this pretty printer with the function |
210 We can install this pretty printer with the function |
211 @{ML_ind addPrettyPrinter in PolyML} as follows. |
211 @{ML_ind addPrettyPrinter in PolyML} as follows. |
212 *} |
212 *} |
213 |
213 |
214 ML{*PolyML.addPrettyPrinter typ_raw_pretty_printer*} |
214 ML{*PolyML.addPrettyPrinter typ_raw_pretty_printer*} |
|
215 |
|
216 (* |
|
217 classes s |
|
218 |
|
219 ML {* @{typ "bool \<Rightarrow> ('a::s)"} *} |
|
220 |
|
221 ML {* |
|
222 fun test ty = |
|
223 case ty of |
|
224 TVar ((v, n), s) => Pretty.block [Pretty.str "TVar "] |
|
225 | TFree (x, s) => Pretty.block [Pretty.str "TFree "] |
|
226 | Type (s, tys) => Pretty.block [Pretty.str "Type "] |
|
227 *} |
|
228 |
|
229 ML {* toplevel_pp ["typ"] "test" *} |
|
230 *) |
215 |
231 |
216 text {* |
232 text {* |
217 Now the type bool is printed out in full detail. |
233 Now the type bool is printed out in full detail. |
218 |
234 |
219 @{ML_response [display,gray] |
235 @{ML_response [display,gray] |
1271 section {* Theorems *} |
1287 section {* Theorems *} |
1272 |
1288 |
1273 text {* |
1289 text {* |
1274 Just like @{ML_type cterm}s, theorems are abstract objects of type @{ML_type thm} |
1290 Just like @{ML_type cterm}s, theorems are abstract objects of type @{ML_type thm} |
1275 that can only be built by going through interfaces. As a consequence, every proof |
1291 that can only be built by going through interfaces. As a consequence, every proof |
1276 in Isabelle is correct by construction. This follows the tradition of the LCF approach. |
1292 in Isabelle is correct by construction. This follows the tradition of the LCF-approach. |
1277 |
1293 |
1278 |
1294 |
1279 To see theorems in ``action'', let us give a proof on the ML-level for the following |
1295 To see theorems in ``action'', let us give a proof on the ML-level for the following |
1280 statement: |
1296 statement: |
1281 *} |
1297 *} |
1516 \begin{readmore} |
1532 \begin{readmore} |
1517 The basic functions for theorems are defined in |
1533 The basic functions for theorems are defined in |
1518 @{ML_file "Pure/thm.ML"}, @{ML_file "Pure/more_thm.ML"} and @{ML_file "Pure/drule.ML"}. |
1534 @{ML_file "Pure/thm.ML"}, @{ML_file "Pure/more_thm.ML"} and @{ML_file "Pure/drule.ML"}. |
1519 \end{readmore} |
1535 \end{readmore} |
1520 |
1536 |
1521 The simplifier can be used to unfold definition in theorems. To show |
1537 Although we will explain the simplifier in more detail as tactic in |
|
1538 Section~\ref{sec:simplifier}, the simplifier |
|
1539 can be used to work directly over theorems, for example to unfold definitions. To show |
1522 this, we build the theorem @{term "True \<equiv> True"} (Line 1) and then |
1540 this, we build the theorem @{term "True \<equiv> True"} (Line 1) and then |
1523 unfold the constant @{term "True"} according to its definition (Line 2). |
1541 unfold the constant @{term "True"} according to its definition (Line 2). |
1524 |
1542 |
1525 @{ML_response_fake [display,gray,linenos] |
1543 @{ML_response_fake [display,gray,linenos] |
1526 "Thm.reflexive @{cterm \"True\"} |
1544 "Thm.reflexive @{cterm \"True\"} |
1583 |
1601 |
1584 @{ML_response_fake [display, gray] |
1602 @{ML_response_fake [display, gray] |
1585 "atomize_thm @{thm list.induct}" |
1603 "atomize_thm @{thm list.induct}" |
1586 "\<forall>P list. P [] \<longrightarrow> (\<forall>a list. P list \<longrightarrow> P (a # list)) \<longrightarrow> P list"} |
1604 "\<forall>P list. P [] \<longrightarrow> (\<forall>a list. P list \<longrightarrow> P (a # list)) \<longrightarrow> P list"} |
1587 |
1605 |
|
1606 \footnote{\bf FIXME: say someting about @{ML_ind standard in Drule}.} |
|
1607 |
1588 Theorems can also be produced from terms by giving an explicit proof. |
1608 Theorems can also be produced from terms by giving an explicit proof. |
1589 One way to achieve this is by using the function @{ML_ind prove in Goal} |
1609 One way to achieve this is by using the function @{ML_ind prove in Goal} |
1590 in the structure @{ML_struct Goal}. For example below we use this function |
1610 in the structure @{ML_struct Goal}. For example below we use this function |
1591 to prove the term @{term "P \<Longrightarrow> P"}. |
1611 to prove the term @{term "P \<Longrightarrow> P"}. |
1592 |
1612 |
1604 is proved. The fourth argument is the term to be proved. The fifth is a |
1624 is proved. The fourth argument is the term to be proved. The fifth is a |
1605 corresponding proof given in form of a tactic (we explain tactics in |
1625 corresponding proof given in form of a tactic (we explain tactics in |
1606 Chapter~\ref{chp:tactical}). In the code above, the tactic proves the theorem |
1626 Chapter~\ref{chp:tactical}). In the code above, the tactic proves the theorem |
1607 by assumption. As before this code will produce a theorem, but the theorem |
1627 by assumption. As before this code will produce a theorem, but the theorem |
1608 is not yet stored in the theorem database. |
1628 is not yet stored in the theorem database. |
|
1629 |
|
1630 While the LCF-approach of going through interfaces ensures soundness in Isabelle, there |
|
1631 is the function @{ML_ind make_thm in Skip_Proof} in the structure |
|
1632 @{ML_struct Skip_Proof} that allows us to turn any proposition into a theorem. |
|
1633 Potentially making the system unsound. This is sometimes useful for developing |
|
1634 purposes, or when explicit proof construction should be omitted due to performace |
|
1635 reasons. An example of this function is as follows: |
|
1636 |
|
1637 @{ML_response_fake [display, gray] |
|
1638 "Skip_Proof.make_thm @{theory} @{prop \"True = False\"}" |
|
1639 "True = False"} |
|
1640 |
|
1641 The function @{ML make_thm in Skip_Proof} however only works if |
|
1642 the ``quick-and-dirty'' mode is switched on. |
1609 |
1643 |
1610 Theorems also contain auxiliary data, such as the name of the theorem, its |
1644 Theorems also contain auxiliary data, such as the name of the theorem, its |
1611 kind, the names for cases and so on. This data is stored in a string-string |
1645 kind, the names for cases and so on. This data is stored in a string-string |
1612 list and can be retrieved with the function @{ML_ind get_tags in |
1646 list and can be retrieved with the function @{ML_ind get_tags in |
1613 Thm}. Assume you prove the following lemma. |
1647 Thm}. Assume you prove the following lemma. |
2479 text {* |
2513 text {* |
2480 @{ML_ind "Binding.str_of"} returns the string with markup; |
2514 @{ML_ind "Binding.str_of"} returns the string with markup; |
2481 @{ML_ind "Binding.name_of"} returns the string without markup |
2515 @{ML_ind "Binding.name_of"} returns the string without markup |
2482 *} |
2516 *} |
2483 |
2517 |
2484 |
2518 section {* Concurrency (TBD) *} |
|
2519 |
|
2520 text {* |
|
2521 @{ML_ind prove_future in Goal} |
|
2522 @{ML_ind future_result in Goal} |
|
2523 @{ML_ind fork_pri in Future} |
|
2524 *} |
2485 |
2525 |
2486 section {* Summary *} |
2526 section {* Summary *} |
2487 |
2527 |
2488 text {* |
2528 text {* |
2489 \begin{conventions} |
2529 \begin{conventions} |