513 |
513 |
514 thm lor_triv [where z = True] (* Check strict prefix. *) |
514 thm lor_triv [where z = True] (* Check strict prefix. *) |
515 x.lor_triv |
515 x.lor_triv |
516 |
516 |
517 |
517 |
|
518 subsection {* Inheritance of mixins *} |
|
519 |
|
520 locale reflexive = |
|
521 fixes le :: "'a => 'a => o" (infix "\<sqsubseteq>" 50) |
|
522 assumes refl: "x \<sqsubseteq> x" |
|
523 begin |
|
524 |
|
525 definition less (infix "\<sqsubset>" 50) where "x \<sqsubset> y <-> x \<sqsubseteq> y & x ~= y" |
|
526 |
|
527 end |
|
528 |
|
529 consts |
|
530 gle :: "'a => 'a => o" gless :: "'a => 'a => o" |
|
531 gle' :: "'a => 'a => o" gless' :: "'a => 'a => o" |
|
532 |
|
533 axioms |
|
534 grefl: "gle(x, x)" gless_def: "gless(x, y) <-> gle(x, y) & x ~= y" |
|
535 grefl': "gle'(x, x)" gless'_def: "gless'(x, y) <-> gle'(x, y) & x ~= y" |
|
536 |
|
537 text {* Mixin not applied to locales further up the hierachy. *} |
|
538 |
|
539 locale mixin = reflexive |
|
540 begin |
|
541 lemmas less_thm = less_def |
|
542 end |
|
543 |
|
544 interpretation le: mixin gle where "reflexive.less(gle, x, y) <-> gless(x, y)" |
|
545 proof - |
|
546 show "mixin(gle)" by unfold_locales (rule grefl) |
|
547 note reflexive = this[unfolded mixin_def] |
|
548 show "reflexive.less(gle, x, y) <-> gless(x, y)" |
|
549 by (simp add: reflexive.less_def[OF reflexive] gless_def) |
|
550 qed |
|
551 |
|
552 thm le.less_def (* mixin not applied *) |
|
553 lemma "reflexive.less(gle, x, y) <-> gle(x, y) & x ~= y" by (rule le.less_def) |
|
554 thm le.less_thm (* mixin applied *) |
|
555 lemma "gless(x, y) <-> gle(x, y) & x ~= y" by (rule le.less_thm) |
|
556 |
|
557 lemma "reflexive.less(gle, x, y) <-> gle(x, y) & x ~= y" |
|
558 by (rule le.less_def) |
|
559 lemma "gless(x, y) <-> gle(x, y) & x ~= y" |
|
560 by (rule le.less_thm) |
|
561 |
|
562 text {* Mixin propagated along the locale hierarchy *} |
|
563 |
|
564 locale mixin2 = mixin |
|
565 begin |
|
566 lemmas less_thm2 = less_def |
|
567 end |
|
568 |
|
569 interpretation le: mixin2 gle |
|
570 by unfold_locales |
|
571 |
|
572 thm le.less_thm2 (* mixin applied *) |
|
573 lemma "gless(x, y) <-> gle(x, y) & x ~= y" |
|
574 by (rule le.less_thm2) |
|
575 |
|
576 text {* Mixin only available in original context *} |
|
577 |
|
578 (* This section is not finished. *) |
|
579 |
|
580 locale mixin3 = mixin le' for le' :: "'a => 'a => o" (infix "\<sqsubseteq>''" 50) |
|
581 |
|
582 lemma (in mixin2) before: |
|
583 "reflexive.less(gle, x, y) <-> gle(x, y) & x ~= y" |
|
584 proof - |
|
585 have "reflexive(gle)" by unfold_locales (rule grefl) |
|
586 note th = reflexive.less_def[OF this] |
|
587 then show ?thesis by (simp add: th) |
|
588 qed |
|
589 |
|
590 interpretation le': mixin2 gle' |
|
591 apply unfold_locales apply (rule grefl') done |
|
592 |
|
593 lemma (in mixin2) after: |
|
594 "reflexive.less(gle, x, y) <-> gle(x, y) & x ~= y" |
|
595 proof - |
|
596 have "reflexive(gle)" by unfold_locales (rule grefl) |
|
597 note th = reflexive.less_def[OF this] |
|
598 then show ?thesis by (simp add: th) |
|
599 qed |
|
600 |
|
601 thm le'.less_def le'.less_thm le'.less_thm2 le'.before le'.after |
|
602 |
|
603 locale combined = le: reflexive le + le': mixin le' |
|
604 for le :: "'a => 'a => o" (infixl "\<sqsubseteq>" 50) and le' :: "'a => 'a => o" (infixl "\<sqsubseteq>''" 50) |
|
605 |
|
606 interpretation combined gle gle' |
|
607 apply unfold_locales done |
|
608 |
|
609 thm le.less_def le.less_thm le'.less_def le'.less_thm |
|
610 |
|
611 |
518 subsection {* Interpretation in proofs *} |
612 subsection {* Interpretation in proofs *} |
519 |
613 |
520 lemma True |
614 lemma True |
521 proof |
615 proof |
522 interpret "local": lgrp "op +" "0" "minus" |
616 interpret "local": lgrp "op +" "0" "minus" |