1331 \] |
1331 \] |
1332 |
1332 |
1333 While we obtained a theorem as result, this theorem is not |
1333 While we obtained a theorem as result, this theorem is not |
1334 yet stored in Isabelle's theorem database. Consequently, it cannot be |
1334 yet stored in Isabelle's theorem database. Consequently, it cannot be |
1335 referenced on the user level. One way to store it in the theorem database is |
1335 referenced on the user level. One way to store it in the theorem database is |
1336 by using the function @{ML_ind note in LocalTheory}.\footnote{\bf FIXME: make sure a pointer |
1336 by using the function @{ML_ind note in Local_Theory}.\footnote{\bf FIXME: make sure a pointer |
1337 to the section about local-setup is given earlier.} |
1337 to the section about local-setup is given earlier.} |
1338 *} |
1338 *} |
1339 |
1339 |
1340 local_setup %gray {* |
1340 local_setup %gray {* |
1341 LocalTheory.note Thm.theoremK |
1341 Local_Theory.note ((@{binding "my_thm"}, []), [my_thm]) #> snd *} |
1342 ((@{binding "my_thm"}, []), [my_thm]) #> snd *} |
1342 |
1343 |
1343 text {* |
1344 text {* |
1344 The fourth argument of @{ML note in Local_Theory} is the list of theorems we |
1345 The fourth argument of @{ML note in LocalTheory} is the list of theorems we |
|
1346 want to store under a name. We can store more than one under a single name. |
1345 want to store under a name. We can store more than one under a single name. |
1347 The first argument @{ML_ind theoremK in Thm} is |
1346 The first argument @{ML_ind theoremK in Thm} is |
1348 a kind indicator, which classifies the theorem. There are several such kind |
1347 a kind indicator, which classifies the theorem. There are several such kind |
1349 indicators: for a theorem arising from a definition you should use @{ML_ind |
1348 indicators: for a theorem arising from a definition you should use @{ML_ind |
1350 definitionK in Thm}, for an axiom @{ML_ind axiomK in Thm}, and for |
1349 definitionK in Thm}, and for |
1351 ``normal'' theorems the kinds @{ML_ind theoremK in Thm} or @{ML_ind lemmaK |
1350 ``normal'' theorems the kinds @{ML_ind theoremK in Thm} or @{ML_ind lemmaK |
1352 in Thm}. The second argument of @{ML note in LocalTheory} is the name under |
1351 in Thm}. The second argument of @{ML note in Local_Theory} is the name under |
1353 which we store the theorem or theorems. The third argument can contain a |
1352 which we store the theorem or theorems. The third argument can contain a |
1354 list of theorem attributes, which we will explain in detail in |
1353 list of theorem attributes, which we will explain in detail in |
1355 Section~\ref{sec:attributes}. Below we just use one such attribute for |
1354 Section~\ref{sec:attributes}. Below we just use one such attribute for |
1356 adding the theorem to the simpset: |
1355 adding the theorem to the simpset: |
1357 *} |
1356 *} |
1358 |
1357 |
1359 local_setup %gray {* |
1358 local_setup %gray {* |
1360 LocalTheory.note Thm.theoremK |
1359 Local_Theory.note ((@{binding "my_thm_simp"}, |
1361 ((@{binding "my_thm_simp"}, |
|
1362 [Attrib.internal (K Simplifier.simp_add)]), [my_thm]) #> snd *} |
1360 [Attrib.internal (K Simplifier.simp_add)]), [my_thm]) #> snd *} |
1363 |
1361 |
1364 text {* |
1362 text {* |
1365 Note that we have to use another name under which the theorem is stored, |
1363 Note that we have to use another name under which the theorem is stored, |
1366 since Isabelle does not allow us to call @{ML_ind note in LocalTheory} twice |
1364 since Isabelle does not allow us to call @{ML_ind note in Local_Theory} twice |
1367 with the same name. The attribute needs to be wrapped inside the function @{ML_ind |
1365 with the same name. The attribute needs to be wrapped inside the function @{ML_ind |
1368 internal in Attrib} from the structure @{ML_struct Attrib}. If we use the function |
1366 internal in Attrib} from the structure @{ML_struct Attrib}. If we use the function |
1369 @{ML get_thm_names_from_ss} from |
1367 @{ML get_thm_names_from_ss} from |
1370 the previous chapter, we can check whether the theorem has actually been |
1368 the previous chapter, we can check whether the theorem has actually been |
1371 added. |
1369 added. |
1390 \end{isabelle} |
1388 \end{isabelle} |
1391 |
1389 |
1392 or with the @{text "@{thm \<dots>}"}-antiquotation on the ML-level. Otherwise the |
1390 or with the @{text "@{thm \<dots>}"}-antiquotation on the ML-level. Otherwise the |
1393 user has no access to these theorems. |
1391 user has no access to these theorems. |
1394 |
1392 |
1395 Recall that Isabelle does not let you call @{ML note in LocalTheory} twice |
1393 Recall that Isabelle does not let you call @{ML note in Local_Theory} twice |
1396 with the same theorem name. In effect, once a theorem is stored under a name, |
1394 with the same theorem name. In effect, once a theorem is stored under a name, |
1397 this association is fixed. While this is a ``safety-net'' to make sure a |
1395 this association is fixed. While this is a ``safety-net'' to make sure a |
1398 theorem name refers to a particular theorem or collection of theorems, it is |
1396 theorem name refers to a particular theorem or collection of theorems, it is |
1399 also a bit too restrictive in cases where a theorem name should refer to a |
1397 also a bit too restrictive in cases where a theorem name should refer to a |
1400 dynamically expanding list of theorems (like a simpset). Therefore Isabelle |
1398 dynamically expanding list of theorems (like a simpset). Therefore Isabelle |
1648 two premises of the lemma. This can be done with the function @{ML_ind name in Rule_Cases} |
1646 two premises of the lemma. This can be done with the function @{ML_ind name in Rule_Cases} |
1649 from the structure @{ML_struct Rule_Cases}. |
1647 from the structure @{ML_struct Rule_Cases}. |
1650 *} |
1648 *} |
1651 |
1649 |
1652 local_setup %gray {* |
1650 local_setup %gray {* |
1653 LocalTheory.note Thm.lemmaK |
1651 Local_Theory.note ((@{binding "foo_data'"}, []), |
1654 ((@{binding "foo_data'"}, []), |
1652 [(Rule_Cases.name ["foo_case_one", "foo_case_two"] |
1655 [(Rule_Cases.name ["foo_case_one", "foo_case_two"] |
1653 @{thm foo_data})]) #> snd *} |
1656 @{thm foo_data})]) #> snd *} |
|
1657 |
1654 |
1658 text {* |
1655 text {* |
1659 The data of the theorem @{thm [source] foo_data'} is then as follows: |
1656 The data of the theorem @{thm [source] foo_data'} is then as follows: |
1660 |
1657 |
1661 @{ML_response_fake [display,gray] |
1658 @{ML_response_fake [display,gray] |
2475 |
2475 |
2476 ML {* Pretty.mark Markup.hilite (Pretty.str "foo") |> Pretty.string_of |> tracing *} |
2476 ML {* Pretty.mark Markup.hilite (Pretty.str "foo") |> Pretty.string_of |> tracing *} |
2477 ML {* (Pretty.str "bar") |> Pretty.string_of |> tracing *} |
2477 ML {* (Pretty.str "bar") |> Pretty.string_of |> tracing *} |
2478 *) |
2478 *) |
2479 |
2479 |
|
2480 section {* Morphisms (TBD) *} |
|
2481 |
|
2482 text {* |
|
2483 Morphisms are arbitrary transformations over terms, types, theorems and bindings. |
|
2484 They can be constructed using the function @{ML_ind morphism in Morphism}, |
|
2485 which expects a record with functions of type |
|
2486 |
|
2487 \begin{isabelle} |
|
2488 \begin{tabular}{rl} |
|
2489 @{text "binding:"} & @{text "binding -> binding"}\\ |
|
2490 @{text "typ:"} & @{text "typ -> typ"}\\ |
|
2491 @{text "term:"} & @{text "term -> term"}\\ |
|
2492 @{text "fact:"} & @{text "thm list -> thm list"} |
|
2493 \end{tabular} |
|
2494 \end{isabelle} |
|
2495 |
|
2496 The simplest morphism is the @{ML_ind identity in Morphism}-morphism defined as |
|
2497 *} |
|
2498 |
|
2499 ML{*val identity = Morphism.morphism {binding = I, typ = I, term = I, fact = I}*} |
|
2500 |
|
2501 text {* |
|
2502 Morphisms can be composed with the function @{ML_ind "$>" in Morphism} |
|
2503 *} |
|
2504 |
|
2505 ML{*fun trm_phi (Free (x, T)) = Var ((x, 0), T) |
|
2506 | trm_phi (Abs (x, T, t)) = Abs (x, T, trm_phi t) |
|
2507 | trm_phi (t $ s) = (trm_phi t) $ (trm_phi s) |
|
2508 | trm_phi t = t*} |
|
2509 |
|
2510 ML{*val phi = Morphism.term_morphism trm_phi*} |
|
2511 |
|
2512 ML{*Morphism.term phi @{term "P x y"}*} |
|
2513 |
|
2514 text {* |
|
2515 @{ML_ind term_morphism in Morphism} |
|
2516 |
|
2517 @{ML_ind term in Morphism}, |
|
2518 @{ML_ind thm in Morphism} |
|
2519 |
|
2520 \begin{readmore} |
|
2521 Morphisms are implemented in the file @{ML_file "Pure/morphism.ML"}. |
|
2522 \end{readmore} |
|
2523 *} |
2480 |
2524 |
2481 section {* Misc (TBD) *} |
2525 section {* Misc (TBD) *} |
2482 |
2526 |
2483 ML {*Datatype.get_info @{theory} "List.list"*} |
2527 ML {*Datatype.get_info @{theory} "List.list"*} |
2484 |
2528 |