author | ballarin |
Mon, 14 Apr 2008 17:54:56 +0200 | |
changeset 26645 | e114be97befe |
parent 26343 | 0dd2eab7b296 |
child 27618 | 72fe9939a2ab |
permissions | -rw-r--r-- |
15596 | 1 |
(* Title: FOL/ex/LocaleTest.thy |
2 |
ID: $Id$ |
|
3 |
Author: Clemens Ballarin |
|
4 |
Copyright (c) 2005 by Clemens Ballarin |
|
5 |
||
6 |
Collection of regression tests for locales. |
|
7 |
*) |
|
8 |
||
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
9 |
header {* Test of Locale Interpretation *} |
15596 | 10 |
|
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
11 |
theory LocaleTest |
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
12 |
imports FOL |
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
13 |
begin |
15596 | 14 |
|
16168
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset
|
15 |
ML {* set Toplevel.debug *} |
15696 | 16 |
ML {* set show_hyps *} |
17 |
ML {* set show_sorts *} |
|
18 |
||
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
19 |
ML {* |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
20 |
fun check_thm name = let |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
21 |
val thy = the_context (); |
26343
0dd2eab7b296
simplified get_thm(s): back to plain name argument;
wenzelm
parents:
26336
diff
changeset
|
22 |
val thm = PureThy.get_thm thy name; |
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
23 |
val {prop, hyps, ...} = rep_thm thm; |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
24 |
val prems = Logic.strip_imp_prems prop; |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
25 |
val _ = if null hyps then () |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
26 |
else error ("Theorem " ^ quote name ^ " has meta hyps.\n" ^ |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
27 |
"Consistency check of locales package failed."); |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
28 |
val _ = if null prems then () |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
29 |
else error ("Theorem " ^ quote name ^ " has premises.\n" ^ |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
30 |
"Consistency check of locales package failed."); |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
31 |
in () end; |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
32 |
*} |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
33 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
34 |
section {* Context Elements and Locale Expressions *} |
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
35 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
36 |
text {* Naming convention for global objects: prefixes L and l *} |
16168
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset
|
37 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
38 |
subsection {* Renaming with Syntax *} |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
39 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
40 |
locale (open) LS = var mult + |
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
41 |
assumes "mult(x, y) = mult(y, x)" |
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
42 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
43 |
print_locale LS |
16168
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset
|
44 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
45 |
locale LS' = LS mult (infixl "**" 60) |
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
46 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
47 |
print_locale LS' |
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
48 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
49 |
locale LT = var mult (infixl "**" 60) + |
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
50 |
assumes "x ** y = y ** x" |
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
51 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
52 |
locale LU = LT mult (infixl "**" 60) + LT add (infixl "++" 55) + var h + |
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
53 |
assumes hom: "h(x ** y) = h(x) ++ h(y)" |
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
54 |
|
25282 | 55 |
|
56 |
(* FIXME: graceful handling of type errors? |
|
19783 | 57 |
locale LY = LT mult (infixl "**" 60) + LT add (binder "++" 55) + var h + |
58 |
assumes "mult(x) == add" |
|
59 |
*) |
|
60 |
||
25282 | 61 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
62 |
locale LV = LU _ add |
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
63 |
|
19783 | 64 |
locale LW = LU _ mult (infixl "**" 60) |
65 |
||
16168
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset
|
66 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
67 |
subsection {* Constrains *} |
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
68 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
69 |
locale LZ = fixes a (structure) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
70 |
locale LZ' = LZ + |
16168
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset
|
71 |
constrains a :: "'a => 'b" |
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset
|
72 |
assumes "a (x :: 'a) = a (y)" |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
73 |
print_locale LZ' |
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
74 |
|
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
75 |
|
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
76 |
section {* Interpretation *} |
15696 | 77 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
78 |
text {* Naming convention for global objects: prefixes I and i *} |
15596 | 79 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
80 |
text {* interpretation input syntax *} |
15596 | 81 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
82 |
locale IL |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
83 |
locale IM = fixes a and b and c |
15596 | 84 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
85 |
interpretation test [simp]: IL + IM a b c [x y z] . |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
86 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
87 |
print_interps IL (* output: test *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
88 |
print_interps IM (* output: test *) |
15596 | 89 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
90 |
interpretation test [simp]: IL print_interps IM . |
15596 | 91 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
92 |
interpretation IL . |
15596 | 93 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
94 |
text {* Processing of locale expression *} |
15596 | 95 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
96 |
locale IA = fixes a assumes asm_A: "a = a" |
15596 | 97 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
98 |
locale (open) IB = fixes b assumes asm_B [simp]: "b = b" |
15596 | 99 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
100 |
locale IC = IA + IB + assumes asm_C: "c = c" |
15596 | 101 |
(* TODO: independent type var in c, prohibit locale declaration *) |
102 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
103 |
locale ID = IA + IB + fixes d defines def_D: "d == (a = b)" |
15596 | 104 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
105 |
theorem (in IA) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
106 |
includes ID |
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
107 |
shows True |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
108 |
print_interps! IA |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
109 |
print_interps! ID |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
110 |
.. |
15696 | 111 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
112 |
theorem (in ID) True .. |
15596 | 113 |
|
114 |
typedecl i |
|
115 |
arities i :: "term" |
|
116 |
||
15598
4ab52355bb53
Registrations of global locale interpretations: improved, better naming.
ballarin
parents:
15596
diff
changeset
|
117 |
|
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
118 |
interpretation i1: IC ["X::i" "Y::i"] by unfold_locales auto |
15596 | 119 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
120 |
print_interps IA (* output: i1 *) |
15596 | 121 |
|
15696 | 122 |
(* possible accesses *) |
26645
e114be97befe
Changed naming scheme for theorems generated by interpretations.
ballarin
parents:
26343
diff
changeset
|
123 |
thm i1.a.asm_A thm LocaleTest.IA_locale.i1.a.asm_A thm IA_locale.i1.a.asm_A |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
124 |
thm i1.asm_A thm LocaleTest.i1.asm_A |
15696 | 125 |
|
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
126 |
ML {* check_thm "i1.a.asm_A" *} |
15624
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset
|
127 |
|
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset
|
128 |
(* without prefix *) |
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset
|
129 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
130 |
interpretation IC ["W::i" "Z::i"] . (* subsumed by i1: IC *) |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
131 |
interpretation IC ["W::'a" "Z::i"] by unfold_locales auto |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
132 |
(* subsumes i1: IA and i1: IC *) |
15696 | 133 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
134 |
print_interps IA (* output: <no prefix>, i1 *) |
15596 | 135 |
|
15837 | 136 |
(* possible accesses *) |
26645
e114be97befe
Changed naming scheme for theorems generated by interpretations.
ballarin
parents:
26343
diff
changeset
|
137 |
thm asm_C thm a_b.asm_C thm LocaleTest.IC_locale.a_b.asm_C thm IC_locale.a_b.asm_C |
15696 | 138 |
|
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
139 |
ML {* check_thm "asm_C" *} |
15596 | 140 |
|
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
141 |
interpretation i2: ID [X "Y::i" "Y = X"] |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
142 |
by (simp add: eq_commute) unfold_locales |
15837 | 143 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
144 |
print_interps IA (* output: <no prefix>, i1 *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
145 |
print_interps ID (* output: i2 *) |
15837 | 146 |
|
147 |
||
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
148 |
interpretation i3: ID [X "Y::i"] by simp unfold_locales |
15598
4ab52355bb53
Registrations of global locale interpretations: improved, better naming.
ballarin
parents:
15596
diff
changeset
|
149 |
|
17436 | 150 |
(* duplicate: thm not added *) |
15696 | 151 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
152 |
(* thm i3.a.asm_A *) |
15696 | 153 |
|
15596 | 154 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
155 |
print_interps IA (* output: <no prefix>, i1 *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
156 |
print_interps IB (* output: i1 *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
157 |
print_interps IC (* output: <no prefix, i1 *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
158 |
print_interps ID (* output: i2, i3 *) |
15596 | 159 |
|
160 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
161 |
interpretation i10: ID + ID a' b' d' [X "Y::i" _ u "v::i" _] . |
15696 | 162 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
163 |
corollary (in ID) th_x: True .. |
15696 | 164 |
|
165 |
(* possible accesses: for each registration *) |
|
166 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
167 |
thm i2.th_x thm i3.th_x |
15696 | 168 |
|
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
169 |
ML {* check_thm "i2.th_x"; check_thm "i3.th_x" *} |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
170 |
|
26199 | 171 |
lemma (in ID) th_y: "d == (a = b)" by (rule d_def) |
15696 | 172 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
173 |
thm i2.th_y thm i3.th_y |
15696 | 174 |
|
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
175 |
ML {* check_thm "i2.th_y"; check_thm "i3.th_y" *} |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
176 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
177 |
lemmas (in ID) th_z = th_y |
15696 | 178 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
179 |
thm i2.th_z |
15696 | 180 |
|
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
181 |
ML {* check_thm "i2.th_z" *} |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
182 |
|
15596 | 183 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
184 |
subsection {* Interpretation in Proof Contexts *} |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
185 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
186 |
locale IF = fixes f assumes asm_F: "f & f --> f" |
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
187 |
|
25282 | 188 |
consts default :: "'a" |
189 |
||
15624
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset
|
190 |
theorem True |
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset
|
191 |
proof - |
25282 | 192 |
fix alpha::i and beta |
193 |
have alpha_A: "IA(alpha)" by unfold_locales |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
194 |
interpret i5: IA [alpha] . (* subsumed *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
195 |
print_interps IA (* output: <no prefix>, i1 *) |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
196 |
interpret i6: IC [alpha beta] by unfold_locales auto |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
197 |
print_interps IA (* output: <no prefix>, i1 *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
198 |
print_interps IC (* output: <no prefix>, i1, i6 *) |
25282 | 199 |
interpret i11: IF ["default = default"] by (fast intro: IF.intro) |
200 |
thm i11.asm_F [where 'a = i] (* default has schematic type *) |
|
15624
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset
|
201 |
qed rule |
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset
|
202 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
203 |
theorem (in IA) True |
15696 | 204 |
proof - |
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
205 |
print_interps! IA |
15696 | 206 |
fix beta and gamma |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
207 |
interpret i9: ID [a beta _] |
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
208 |
apply - apply assumption |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
209 |
apply unfold_locales |
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
210 |
apply (rule refl) done |
15696 | 211 |
qed rule |
15624
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset
|
212 |
|
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset
|
213 |
|
15696 | 214 |
(* Definition involving free variable *) |
215 |
||
216 |
ML {* reset show_sorts *} |
|
217 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
218 |
locale IE = fixes e defines e_def: "e(x) == x & x" |
15696 | 219 |
notes e_def2 = e_def |
220 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
221 |
lemma (in IE) True thm e_def by fast |
15696 | 222 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
223 |
interpretation i7: IE ["%x. x"] by simp |
15696 | 224 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
225 |
thm i7.e_def2 (* has no premise *) |
15696 | 226 |
|
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
227 |
ML {* check_thm "i7.e_def2" *} |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
228 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
229 |
locale IE' = fixes e defines e_def: "e == (%x. x & x)" |
15696 | 230 |
notes e_def2 = e_def |
231 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
232 |
interpretation i7': IE' ["(%x. x)"] by simp |
15696 | 233 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
234 |
thm i7'.e_def2 |
15696 | 235 |
|
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
236 |
ML {* check_thm "i7'.e_def2" *} |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
237 |
|
15696 | 238 |
(* Definition involving free variable in assm *) |
239 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
240 |
locale (open) IG = fixes g assumes asm_G: "g --> x" |
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
241 |
notes asm_G2 = asm_G |
15696 | 242 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
243 |
interpretation i8: IG ["False"] by fast |
15696 | 244 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
245 |
thm i8.asm_G2 |
15696 | 246 |
|
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
247 |
ML {* check_thm "i8.asm_G2" *} |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
248 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
249 |
text {* Locale without assumptions *} |
15696 | 250 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
251 |
locale IL1 = notes rev_conjI [intro] = conjI [THEN iffD1 [OF conj_commute]] |
15696 | 252 |
|
253 |
lemma "[| P; Q |] ==> P & Q" |
|
254 |
proof - |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
255 |
interpret my: IL1 . txt {* No chained fact required. *} |
15696 | 256 |
assume Q and P txt {* order reversed *} |
257 |
then show "P & Q" .. txt {* Applies @{thm my.rev_conjI}. *} |
|
258 |
qed |
|
259 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
260 |
locale IL11 = notes rev_conjI = conjI [THEN iffD1 [OF conj_commute]] |
15696 | 261 |
|
262 |
lemma "[| P; Q |] ==> P & Q" |
|
263 |
proof - |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
264 |
interpret [intro]: IL11 . txt {* Attribute supplied at instantiation. *} |
15696 | 265 |
assume Q and P |
266 |
then show "P & Q" .. |
|
267 |
qed |
|
268 |
||
269 |
subsection {* Simple locale with assumptions *} |
|
270 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
271 |
consts ibin :: "[i, i] => i" (infixl "#" 60) |
15696 | 272 |
|
273 |
axioms i_assoc: "(x # y) # z = x # (y # z)" |
|
274 |
i_comm: "x # y = y # x" |
|
275 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
276 |
locale IL2 = |
15696 | 277 |
fixes OP (infixl "+" 60) |
278 |
assumes assoc: "(x + y) + z = x + (y + z)" |
|
279 |
and comm: "x + y = y + x" |
|
280 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
281 |
lemma (in IL2) lcomm: "x + (y + z) = y + (x + z)" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
282 |
proof - |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
283 |
have "x + (y + z) = (x + y) + z" by (simp add: assoc) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
284 |
also have "... = (y + x) + z" by (simp add: comm) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
285 |
also have "... = y + (x + z)" by (simp add: assoc) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
286 |
finally show ?thesis . |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
287 |
qed |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
288 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
289 |
lemmas (in IL2) AC = comm assoc lcomm |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
290 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
291 |
lemma "(x::i) # y # z # w = y # x # w # z" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
292 |
proof - |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
293 |
interpret my: IL2 ["op #"] by (rule IL2.intro [of "op #", OF i_assoc i_comm]) |
17033 | 294 |
show ?thesis by (simp only: my.OP.AC) (* or my.AC *) |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
295 |
qed |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
296 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
297 |
subsection {* Nested locale with assumptions *} |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
298 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
299 |
locale IL3 = |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
300 |
fixes OP (infixl "+" 60) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
301 |
assumes assoc: "(x + y) + z = x + (y + z)" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
302 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
303 |
locale IL4 = IL3 + |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
304 |
assumes comm: "x + y = y + x" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
305 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
306 |
lemma (in IL4) lcomm: "x + (y + z) = y + (x + z)" |
15696 | 307 |
proof - |
308 |
have "x + (y + z) = (x + y) + z" by (simp add: assoc) |
|
309 |
also have "... = (y + x) + z" by (simp add: comm) |
|
310 |
also have "... = y + (x + z)" by (simp add: assoc) |
|
311 |
finally show ?thesis . |
|
312 |
qed |
|
313 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
314 |
lemmas (in IL4) AC = comm assoc lcomm |
15696 | 315 |
|
316 |
lemma "(x::i) # y # z # w = y # x # w # z" |
|
317 |
proof - |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
318 |
interpret my: IL4 ["op #"] |
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
319 |
by (auto intro: IL4.intro IL3.intro IL4_axioms.intro i_assoc i_comm) |
15696 | 320 |
show ?thesis by (simp only: my.OP.AC) (* or simply AC *) |
321 |
qed |
|
322 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
323 |
text {* Locale with definition *} |
15696 | 324 |
|
325 |
text {* This example is admittedly not very creative :-) *} |
|
326 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
327 |
locale IL5 = IL4 + var A + |
15696 | 328 |
defines A_def: "A == True" |
329 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
330 |
lemma (in IL5) lem: A |
15696 | 331 |
by (unfold A_def) rule |
332 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
333 |
lemma "IL5(op #) ==> True" |
15696 | 334 |
proof - |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
335 |
assume "IL5(op #)" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
336 |
then interpret IL5 ["op #"] by (auto intro: IL5.axioms) |
15696 | 337 |
show ?thesis by (rule lem) (* lem instantiated to True *) |
338 |
qed |
|
339 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
340 |
text {* Interpretation in a context with target *} |
15696 | 341 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
342 |
lemma (in IL4) |
15696 | 343 |
fixes A (infixl "$" 60) |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
344 |
assumes A: "IL4(A)" |
15696 | 345 |
shows "(x::i) $ y $ z $ w = y $ x $ w $ z" |
346 |
proof - |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
347 |
from A interpret A: IL4 ["A"] by (auto intro: IL4.axioms) |
15696 | 348 |
show ?thesis by (simp only: A.OP.AC) |
349 |
qed |
|
350 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
351 |
|
16736
1e792b32abef
Preparations for interpretation of locales in locales.
ballarin
parents:
16620
diff
changeset
|
352 |
section {* Interpretation in Locales *} |
1e792b32abef
Preparations for interpretation of locales in locales.
ballarin
parents:
16620
diff
changeset
|
353 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
354 |
text {* Naming convention for global objects: prefixes R and r *} |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
355 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
356 |
locale (open) Rsemi = var prod (infixl "**" 65) + |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
357 |
assumes assoc: "(x ** y) ** z = x ** (y ** z)" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
358 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
359 |
locale (open) Rlgrp = Rsemi + var one + var inv + |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
360 |
assumes lone: "one ** x = x" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
361 |
and linv: "inv(x) ** x = one" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
362 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
363 |
lemma (in Rlgrp) lcancel: |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
364 |
"x ** y = x ** z <-> y = z" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
365 |
proof |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
366 |
assume "x ** y = x ** z" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
367 |
then have "inv(x) ** x ** y = inv(x) ** x ** z" by (simp add: assoc) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
368 |
then show "y = z" by (simp add: lone linv) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
369 |
qed simp |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
370 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
371 |
locale (open) Rrgrp = Rsemi + var one + var inv + |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
372 |
assumes rone: "x ** one = x" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
373 |
and rinv: "x ** inv(x) = one" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
374 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
375 |
lemma (in Rrgrp) rcancel: |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
376 |
"y ** x = z ** x <-> y = z" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
377 |
proof |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
378 |
assume "y ** x = z ** x" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
379 |
then have "y ** (x ** inv(x)) = z ** (x ** inv(x))" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
380 |
by (simp add: assoc [symmetric]) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
381 |
then show "y = z" by (simp add: rone rinv) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
382 |
qed simp |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
383 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
384 |
interpretation Rlgrp < Rrgrp |
17033 | 385 |
proof - |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
386 |
{ |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
387 |
fix x |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
388 |
have "inv(x) ** x ** one = inv(x) ** x" by (simp add: linv lone) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
389 |
then show "x ** one = x" by (simp add: assoc lcancel) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
390 |
} |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
391 |
note rone = this |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
392 |
{ |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
393 |
fix x |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
394 |
have "inv(x) ** x ** inv(x) = inv(x) ** one" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
395 |
by (simp add: linv lone rone) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
396 |
then show "x ** inv(x) = one" by (simp add: assoc lcancel) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
397 |
} |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
398 |
qed |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
399 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
400 |
(* effect on printed locale *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
401 |
|
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
402 |
print_locale! Rlgrp |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
403 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
404 |
(* use of derived theorem *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
405 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
406 |
lemma (in Rlgrp) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
407 |
"y ** x = z ** x <-> y = z" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
408 |
apply (rule rcancel) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
409 |
print_interps Rrgrp thm lcancel rcancel |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
410 |
done |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
411 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
412 |
(* circular interpretation *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
413 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
414 |
interpretation Rrgrp < Rlgrp |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
415 |
proof - |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
416 |
{ |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
417 |
fix x |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
418 |
have "one ** (x ** inv(x)) = x ** inv(x)" by (simp add: rinv rone) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
419 |
then show "one ** x = x" by (simp add: assoc [symmetric] rcancel) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
420 |
} |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
421 |
note lone = this |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
422 |
{ |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
423 |
fix x |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
424 |
have "inv(x) ** (x ** inv(x)) = one ** inv(x)" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
425 |
by (simp add: rinv lone rone) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
426 |
then show "inv(x) ** x = one" by (simp add: assoc [symmetric] rcancel) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
427 |
} |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
428 |
qed |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
429 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
430 |
(* effect on printed locale *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
431 |
|
17228 | 432 |
print_locale! Rrgrp |
433 |
print_locale! Rlgrp |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
434 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
435 |
(* locale with many parameters --- |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
436 |
interpretations generate alternating group A5 *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
437 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
438 |
locale RA5 = var A + var B + var C + var D + var E + |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
439 |
assumes eq: "A <-> B <-> C <-> D <-> E" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
440 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
441 |
interpretation RA5 < RA5 _ _ D E C |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
442 |
print_facts |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
443 |
print_interps RA5 |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
444 |
using A_B_C_D_E.eq apply (blast intro: RA5.intro) done |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
445 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
446 |
interpretation RA5 < RA5 C _ E _ A |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
447 |
print_facts |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
448 |
print_interps RA5 |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
449 |
using A_B_C_D_E.eq apply (blast intro: RA5.intro) done |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
450 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
451 |
interpretation RA5 < RA5 B C A _ _ |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
452 |
print_facts |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
453 |
print_interps RA5 |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
454 |
using A_B_C_D_E.eq apply (blast intro: RA5.intro) done |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
455 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
456 |
interpretation RA5 < RA5 _ C D B _ . |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
457 |
(* Any even permutation of parameters is subsumed by the above. *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
458 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
459 |
(* circle of three locales, forward direction *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
460 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
461 |
locale (open) RA1 = var A + var B + assumes p: "A <-> B" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
462 |
locale (open) RA2 = var A + var B + assumes q: "A & B | ~ A & ~ B" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
463 |
locale (open) RA3 = var A + var B + assumes r: "(A --> B) & (B --> A)" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
464 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
465 |
interpretation RA1 < RA2 |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
466 |
print_facts |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
467 |
using p apply fast done |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
468 |
interpretation RA2 < RA3 |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
469 |
print_facts |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
470 |
using q apply fast done |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
471 |
interpretation RA3 < RA1 |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
472 |
print_facts |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
473 |
using r apply fast done |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
474 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
475 |
(* circle of three locales, backward direction *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
476 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
477 |
locale (open) RB1 = var A + var B + assumes p: "A <-> B" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
478 |
locale (open) RB2 = var A + var B + assumes q: "A & B | ~ A & ~ B" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
479 |
locale (open) RB3 = var A + var B + assumes r: "(A --> B) & (B --> A)" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
480 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
481 |
interpretation RB1 < RB2 |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
482 |
print_facts |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
483 |
using p apply fast done |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
484 |
interpretation RB3 < RB1 |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
485 |
print_facts |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
486 |
using r apply fast done |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
487 |
interpretation RB2 < RB3 |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
488 |
print_facts |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
489 |
using q apply fast done |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
490 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
491 |
lemma (in RB1) True |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
492 |
print_facts |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
493 |
.. |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
494 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
495 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
496 |
(* Group example revisited, with predicates *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
497 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
498 |
locale Rpsemi = var prod (infixl "**" 65) + |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
499 |
assumes assoc: "(x ** y) ** z = x ** (y ** z)" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
500 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
501 |
locale Rplgrp = Rpsemi + var one + var inv + |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
502 |
assumes lone: "one ** x = x" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
503 |
and linv: "inv(x) ** x = one" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
504 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
505 |
lemma (in Rplgrp) lcancel: |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
506 |
"x ** y = x ** z <-> y = z" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
507 |
proof |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
508 |
assume "x ** y = x ** z" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
509 |
then have "inv(x) ** x ** y = inv(x) ** x ** z" by (simp add: assoc) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
510 |
then show "y = z" by (simp add: lone linv) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
511 |
qed simp |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
512 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
513 |
locale Rprgrp = Rpsemi + var one + var inv + |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
514 |
assumes rone: "x ** one = x" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
515 |
and rinv: "x ** inv(x) = one" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
516 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
517 |
lemma (in Rprgrp) rcancel: |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
518 |
"y ** x = z ** x <-> y = z" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
519 |
proof |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
520 |
assume "y ** x = z ** x" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
521 |
then have "y ** (x ** inv(x)) = z ** (x ** inv(x))" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
522 |
by (simp add: assoc [symmetric]) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
523 |
then show "y = z" by (simp add: rone rinv) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
524 |
qed simp |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
525 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
526 |
interpretation Rplgrp < Rprgrp |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
527 |
proof unfold_locales |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
528 |
{ |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
529 |
fix x |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
530 |
have "inv(x) ** x ** one = inv(x) ** x" by (simp add: linv lone) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
531 |
then show "x ** one = x" by (simp add: assoc lcancel) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
532 |
} |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
533 |
note rone = this |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
534 |
{ |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
535 |
fix x |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
536 |
have "inv(x) ** x ** inv(x) = inv(x) ** one" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
537 |
by (simp add: linv lone rone) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
538 |
then show "x ** inv(x) = one" by (simp add: assoc lcancel) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
539 |
} |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
540 |
qed |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
541 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
542 |
(* effect on printed locale *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
543 |
|
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
544 |
print_locale! Rplgrp |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
545 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
546 |
(* use of derived theorem *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
547 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
548 |
lemma (in Rplgrp) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
549 |
"y ** x = z ** x <-> y = z" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
550 |
apply (rule rcancel) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
551 |
print_interps Rprgrp thm lcancel rcancel |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
552 |
done |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
553 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
554 |
(* circular interpretation *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
555 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
556 |
interpretation Rprgrp < Rplgrp |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
557 |
proof unfold_locales |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
558 |
{ |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
559 |
fix x |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
560 |
have "one ** (x ** inv(x)) = x ** inv(x)" by (simp add: rinv rone) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
561 |
then show "one ** x = x" by (simp add: assoc [symmetric] rcancel) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
562 |
} |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
563 |
note lone = this |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
564 |
{ |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
565 |
fix x |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
566 |
have "inv(x) ** (x ** inv(x)) = one ** inv(x)" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
567 |
by (simp add: rinv lone rone) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
568 |
then show "inv(x) ** x = one" by (simp add: assoc [symmetric] rcancel) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
569 |
} |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
570 |
qed |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
571 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
572 |
(* effect on printed locale *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
573 |
|
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
574 |
print_locale! Rprgrp |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
575 |
print_locale! Rplgrp |
16736
1e792b32abef
Preparations for interpretation of locales in locales.
ballarin
parents:
16620
diff
changeset
|
576 |
|
17033 | 577 |
subsection {* Interaction of Interpretation in Theories and Locales: |
17096
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
578 |
in Locale, then in Theory *} |
17033 | 579 |
|
580 |
consts |
|
581 |
rone :: i |
|
582 |
rinv :: "i => i" |
|
583 |
||
584 |
axioms |
|
585 |
r_one : "rone # x = x" |
|
586 |
r_inv : "rinv(x) # x = rone" |
|
587 |
||
588 |
interpretation Rbool: Rlgrp ["op #" "rone" "rinv"] |
|
589 |
proof - |
|
590 |
fix x y z |
|
591 |
{ |
|
592 |
show "(x # y) # z = x # (y # z)" by (rule i_assoc) |
|
593 |
next |
|
594 |
show "rone # x = x" by (rule r_one) |
|
595 |
next |
|
596 |
show "rinv(x) # x = rone" by (rule r_inv) |
|
597 |
} |
|
598 |
qed |
|
599 |
||
600 |
(* derived elements *) |
|
601 |
||
602 |
print_interps Rrgrp |
|
603 |
print_interps Rlgrp |
|
604 |
||
605 |
lemma "y # x = z # x <-> y = z" by (rule Rbool.rcancel) |
|
606 |
||
607 |
(* adding lemma to derived element *) |
|
608 |
||
609 |
lemma (in Rrgrp) new_cancel: |
|
610 |
"b ** a = c ** a <-> b = c" |
|
611 |
by (rule rcancel) |
|
612 |
||
613 |
thm Rbool.new_cancel (* additional prems discharged!! *) |
|
614 |
||
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
615 |
ML {* check_thm "Rbool.new_cancel" *} |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
616 |
|
17033 | 617 |
lemma "b # a = c # a <-> b = c" by (rule Rbool.new_cancel) |
618 |
||
619 |
||
620 |
subsection {* Interaction of Interpretation in Theories and Locales: |
|
17096
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
621 |
in Theory, then in Locale *} |
17033 | 622 |
|
623 |
(* Another copy of the group example *) |
|
624 |
||
625 |
locale Rqsemi = var prod (infixl "**" 65) + |
|
626 |
assumes assoc: "(x ** y) ** z = x ** (y ** z)" |
|
627 |
||
628 |
locale Rqlgrp = Rqsemi + var one + var inv + |
|
629 |
assumes lone: "one ** x = x" |
|
630 |
and linv: "inv(x) ** x = one" |
|
631 |
||
632 |
lemma (in Rqlgrp) lcancel: |
|
633 |
"x ** y = x ** z <-> y = z" |
|
634 |
proof |
|
635 |
assume "x ** y = x ** z" |
|
636 |
then have "inv(x) ** x ** y = inv(x) ** x ** z" by (simp add: assoc) |
|
637 |
then show "y = z" by (simp add: lone linv) |
|
638 |
qed simp |
|
639 |
||
640 |
locale Rqrgrp = Rqsemi + var one + var inv + |
|
641 |
assumes rone: "x ** one = x" |
|
642 |
and rinv: "x ** inv(x) = one" |
|
643 |
||
644 |
lemma (in Rqrgrp) rcancel: |
|
645 |
"y ** x = z ** x <-> y = z" |
|
646 |
proof |
|
647 |
assume "y ** x = z ** x" |
|
648 |
then have "y ** (x ** inv(x)) = z ** (x ** inv(x))" |
|
649 |
by (simp add: assoc [symmetric]) |
|
650 |
then show "y = z" by (simp add: rone rinv) |
|
651 |
qed simp |
|
652 |
||
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
653 |
interpretation Rqrgrp < Rprgrp |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
654 |
apply unfold_locales |
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
655 |
apply (rule assoc) |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
656 |
apply (rule rone) |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
657 |
apply (rule rinv) |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
658 |
done |
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
659 |
|
17033 | 660 |
interpretation R2: Rqlgrp ["op #" "rone" "rinv"] |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
661 |
apply unfold_locales (* FIXME: unfold_locales is too eager and shouldn't |
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
662 |
solve this. *) |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
663 |
done |
17033 | 664 |
|
665 |
print_interps Rqsemi |
|
666 |
print_interps Rqlgrp |
|
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
667 |
print_interps Rplgrp (* no interpretations yet *) |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
668 |
|
17033 | 669 |
|
670 |
interpretation Rqlgrp < Rqrgrp |
|
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
671 |
proof unfold_locales |
17033 | 672 |
{ |
673 |
fix x |
|
674 |
have "inv(x) ** x ** one = inv(x) ** x" by (simp add: linv lone) |
|
675 |
then show "x ** one = x" by (simp add: assoc lcancel) |
|
676 |
} |
|
677 |
note rone = this |
|
678 |
{ |
|
679 |
fix x |
|
680 |
have "inv(x) ** x ** inv(x) = inv(x) ** one" |
|
681 |
by (simp add: linv lone rone) |
|
682 |
then show "x ** inv(x) = one" by (simp add: assoc lcancel) |
|
683 |
} |
|
684 |
qed |
|
685 |
||
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
686 |
print_interps! Rqrgrp |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
687 |
print_interps! Rpsemi (* witness must not have meta hyps *) |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
688 |
print_interps! Rprgrp (* witness must not have meta hyps *) |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
689 |
print_interps! Rplgrp (* witness must not have meta hyps *) |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
690 |
thm R2.rcancel |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
691 |
thm R2.lcancel |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
692 |
|
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
693 |
ML {* check_thm "R2.rcancel"; check_thm "R2.lcancel" *} |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
694 |
|
17096
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
695 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
696 |
subsection {* Generation of Witness Theorems for Transitive Interpretations *} |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
697 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
698 |
locale Rtriv = var x + |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
699 |
assumes x: "x = x" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
700 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
701 |
locale Rtriv2 = var x + var y + |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
702 |
assumes x: "x = x" and y: "y = y" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
703 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
704 |
interpretation Rtriv2 < Rtriv x |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
705 |
apply unfold_locales |
17096
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
706 |
apply (rule x) |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
707 |
done |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
708 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
709 |
interpretation Rtriv2 < Rtriv y |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
710 |
apply unfold_locales |
17096
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
711 |
apply (rule y) |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
712 |
done |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
713 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
714 |
print_locale Rtriv2 |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
715 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
716 |
locale Rtriv3 = var x + var y + var z + |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
717 |
assumes x: "x = x" and y: "y = y" and z: "z = z" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
718 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
719 |
interpretation Rtriv3 < Rtriv2 x y |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
720 |
apply unfold_locales |
17096
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
721 |
apply (rule x) |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
722 |
apply (rule y) |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
723 |
done |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
724 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
725 |
print_locale Rtriv3 |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
726 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
727 |
interpretation Rtriv3 < Rtriv2 x z |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
728 |
apply unfold_locales |
17096
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
729 |
apply (rule x_y_z.x) |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
730 |
apply (rule z) |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
731 |
done |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
732 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
733 |
ML {* set show_types *} |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
734 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
735 |
print_locale Rtriv3 |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
736 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
737 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
738 |
subsection {* Normalisation Replaces Assumed Element by Derived Element *} |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
739 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
740 |
typedecl ('a, 'b) pair |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
741 |
arities pair :: ("term", "term") "term" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
742 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
743 |
consts |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
744 |
pair :: "['a, 'b] => ('a, 'b) pair" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
745 |
fst :: "('a, 'b) pair => 'a" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
746 |
snd :: "('a, 'b) pair => 'b" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
747 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
748 |
axioms |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
749 |
fst [simp]: "fst(pair(x, y)) = x" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
750 |
snd [simp]: "snd(pair(x, y)) = y" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
751 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
752 |
locale Rpair = var prod (infixl "**" 65) + var prodP (infixl "***" 65) + |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
753 |
defines P_def: "x *** y == pair(fst(x) ** fst(y), snd(x) ** snd(y))" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
754 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
755 |
locale Rpair_semi = Rpair + Rpsemi |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
756 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
757 |
interpretation Rpair_semi < Rpsemi prodP (infixl "***" 65) |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
758 |
proof (rule Rpsemi.intro) |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
759 |
fix x y z |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
760 |
show "(x *** y) *** z = x *** (y *** z)" |
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
761 |
apply (simp only: P_def) apply (simp add: assoc) (* FIXME: unfold P_def fails *) |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
762 |
done |
17096
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
763 |
qed |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
764 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
765 |
locale Rsemi_rev = Rpsemi + var rprod (infixl "++" 65) + |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
766 |
defines r_def: "x ++ y == y ** x" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
767 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
768 |
lemma (in Rsemi_rev) r_assoc: |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
769 |
"(x ++ y) ++ z = x ++ (y ++ z)" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
770 |
by (simp add: r_def assoc) |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
771 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
772 |
lemma (in Rpair_semi) |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
773 |
includes Rsemi_rev prodP (infixl "***" 65) rprodP (infixl "+++" 65) |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
774 |
constrains prod :: "['a, 'a] => 'a" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
775 |
and rprodP :: "[('a, 'a) pair, ('a, 'a) pair] => ('a, 'a) pair" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
776 |
shows "(x +++ y) +++ z = x +++ (y +++ z)" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
777 |
apply (rule r_assoc) done |
17033 | 778 |
|
20469 | 779 |
|
780 |
subsection {* Import of Locales with Predicates as Interpretation *} |
|
781 |
||
782 |
locale Ra = |
|
783 |
assumes Ra: "True" |
|
784 |
||
785 |
locale Rb = Ra + |
|
786 |
assumes Rb: "True" |
|
787 |
||
788 |
locale Rc = Rb + |
|
789 |
assumes Rc: "True" |
|
790 |
||
791 |
print_locale! Rc |
|
792 |
||
22659
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
793 |
|
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
794 |
section {* Interpretation of Defined Concepts *} |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
795 |
|
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
796 |
text {* Naming convention for global objects: prefixes D and d *} |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
797 |
|
23919
af871d13e320
interpretation: equations are propositions not pairs of terms;
ballarin
parents:
22931
diff
changeset
|
798 |
|
af871d13e320
interpretation: equations are propositions not pairs of terms;
ballarin
parents:
22931
diff
changeset
|
799 |
subsection {* Simple examples *} |
af871d13e320
interpretation: equations are propositions not pairs of terms;
ballarin
parents:
22931
diff
changeset
|
800 |
|
22659
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
801 |
locale Da = fixes a :: o |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
802 |
assumes true: a |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
803 |
|
22757 | 804 |
text {* In the following examples, @{term "~ a"} is the defined concept. *} |
805 |
||
22659
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
806 |
lemma (in Da) not_false: "~ a <-> False" |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
807 |
apply simp apply (rule true) done |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
808 |
|
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
809 |
interpretation D1: Da ["True"] |
23919
af871d13e320
interpretation: equations are propositions not pairs of terms;
ballarin
parents:
22931
diff
changeset
|
810 |
where "~ True == False" |
22659
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
811 |
apply - |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
812 |
apply unfold_locales [1] apply rule |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
813 |
by simp |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
814 |
|
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
815 |
thm D1.not_false |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
816 |
lemma "False <-> False" apply (rule D1.not_false) done |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
817 |
|
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
818 |
interpretation D2: Da ["x | ~ x"] |
23919
af871d13e320
interpretation: equations are propositions not pairs of terms;
ballarin
parents:
22931
diff
changeset
|
819 |
where "~ (x | ~ x) <-> ~ x & x" |
22659
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
820 |
apply - |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
821 |
apply unfold_locales [1] apply fast |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
822 |
by simp |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
823 |
|
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
824 |
thm D2.not_false |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
825 |
lemma "~ x & x <-> False" apply (rule D2.not_false) done |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
826 |
|
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
827 |
print_interps! Da |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
828 |
|
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
829 |
(* Subscriptions of interpretations *) |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
830 |
|
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
831 |
lemma (in Da) not_false2: "~a <-> False" |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
832 |
apply simp apply (rule true) done |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
833 |
|
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
834 |
thm D1.not_false2 D2.not_false2 |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
835 |
lemma "False <-> False" apply (rule D1.not_false2) done |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
836 |
lemma "~x & x <-> False" apply (rule D2.not_false2) done |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
837 |
|
22757 | 838 |
(* Unfolding in attributes *) |
839 |
||
840 |
locale Db = Da + |
|
841 |
fixes b :: o |
|
842 |
assumes a_iff_b: "~a <-> b" |
|
843 |
||
844 |
lemmas (in Db) not_false_b = not_false [unfolded a_iff_b] |
|
845 |
||
846 |
interpretation D2: Db ["x | ~ x" "~ (x <-> x)"] |
|
847 |
apply unfold_locales apply fast done |
|
848 |
||
849 |
thm D2.not_false_b |
|
850 |
lemma "~(x <-> x) <-> False" apply (rule D2.not_false_b) done |
|
851 |
||
852 |
(* Subscription and attributes *) |
|
853 |
||
854 |
lemmas (in Db) not_false_b2 = not_false [unfolded a_iff_b] |
|
855 |
||
856 |
thm D2.not_false_b2 |
|
857 |
lemma "~(x <-> x) <-> False" apply (rule D2.not_false_b2) done |
|
858 |
||
15596 | 859 |
end |