equal
deleted
inserted
replaced
260 ML \<open>test_internal_fact @{context} "uses_test\<^sub>1_uses"\<close> |
260 ML \<open>test_internal_fact @{context} "uses_test\<^sub>1_uses"\<close> |
261 |
261 |
262 ML \<open>test_internal_fact @{context} "Tests.uses_test\<^sub>1_uses"\<close> |
262 ML \<open>test_internal_fact @{context} "Tests.uses_test\<^sub>1_uses"\<close> |
263 ML \<open>test_internal_fact @{context} "Tests.uses_test\<^sub>1.uses_test\<^sub>1_uses"\<close> |
263 ML \<open>test_internal_fact @{context} "Tests.uses_test\<^sub>1.uses_test\<^sub>1_uses"\<close> |
264 |
264 |
|
265 subsection \<open>Basic fact passing\<close> |
|
266 |
|
267 method find_fact for x y :: bool uses facts1 facts2 = |
|
268 (match facts1 in U: "x" \<Rightarrow> \<open>insert U, |
|
269 match facts2 in U: "y" \<Rightarrow> \<open>insert U\<close>\<close>) |
|
270 |
|
271 lemma assumes A: A and B: B shows "A \<and> B" |
|
272 apply (find_fact "A" "B" facts1: A facts2: B) |
|
273 apply (rule conjI; assumption) |
|
274 done |
|
275 |
265 |
276 |
266 subsection \<open>Testing term and fact passing in recursion\<close> |
277 subsection \<open>Testing term and fact passing in recursion\<close> |
|
278 |
267 |
279 |
268 method recursion_example for x :: bool uses facts = |
280 method recursion_example for x :: bool uses facts = |
269 (match (x) in |
281 (match (x) in |
270 "A \<and> B" for A B \<Rightarrow> \<open>(recursion_example A facts: facts, recursion_example B facts: facts)\<close> |
282 "A \<and> B" for A B \<Rightarrow> \<open>(recursion_example A facts: facts, recursion_example B facts: facts)\<close> |
271 \<bar> "?H" \<Rightarrow> \<open>match facts in U: "x" \<Rightarrow> \<open>insert U\<close>\<close>) |
283 \<bar> "?H" \<Rightarrow> \<open>match facts in U: "x" \<Rightarrow> \<open>insert U\<close>\<close>) |
528 apply (test_method a b)? |
540 apply (test_method a b)? |
529 apply (test_method' a b rule: refl)? |
541 apply (test_method' a b rule: refl)? |
530 apply (test_method' a b rule: assms [symmetric])? |
542 apply (test_method' a b rule: assms [symmetric])? |
531 done |
543 done |
532 |
544 |
533 end |
545 subsection \<open>Eisbach methods in locales\<close> |
|
546 |
|
547 locale my_locale1 = fixes A assumes A: A begin |
|
548 |
|
549 method apply_A = |
|
550 (match conclusion in "A" \<Rightarrow> |
|
551 \<open>match A in U:"A" \<Rightarrow> |
|
552 \<open>print_term A, print_fact A, rule U\<close>\<close>) |
|
553 |
|
554 end |
|
555 |
|
556 locale my_locale2 = fixes B assumes B: B begin |
|
557 |
|
558 interpretation my_locale1 B by (unfold_locales; rule B) |
|
559 |
|
560 lemma B by apply_A |
|
561 |
|
562 end |
|
563 |
|
564 context fixes C assumes C: C begin |
|
565 |
|
566 interpretation my_locale1 C by (unfold_locales; rule C) |
|
567 |
|
568 lemma C by apply_A |
|
569 |
|
570 end |
|
571 |
|
572 context begin |
|
573 |
|
574 interpretation my_locale1 "True \<longrightarrow> True" by (unfold_locales; blast) |
|
575 |
|
576 lemma "True \<longrightarrow> True" by apply_A |
|
577 |
|
578 end |
|
579 |
|
580 locale locale_poly = fixes P assumes P: "\<And>x :: 'a. P x" begin |
|
581 |
|
582 method solve_P for z :: 'a = (rule P[where x = z]) |
|
583 |
|
584 end |
|
585 |
|
586 context begin |
|
587 |
|
588 interpretation locale_poly "\<lambda>x:: nat. 0 \<le> x" by (unfold_locales; blast) |
|
589 |
|
590 lemma "0 \<le> (n :: nat)" by (solve_P n) |
|
591 |
|
592 end |
|
593 |
|
594 end |