author | ballarin |
Wed, 06 Aug 2008 16:41:40 +0200 | |
changeset 27761 | b95e9ba0ca1d |
parent 27718 | 3a85bc6bfd73 |
child 28085 | 914183e229e9 |
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 |
|
27681 | 40 |
locale 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 |
|
27681 | 98 |
locale 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 ID) True .. |
15596 | 106 |
|
107 |
typedecl i |
|
108 |
arities i :: "term" |
|
109 |
||
15598
4ab52355bb53
Registrations of global locale interpretations: improved, better naming.
ballarin
parents:
15596
diff
changeset
|
110 |
|
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
111 |
interpretation i1: IC ["X::i" "Y::i"] by unfold_locales auto |
15596 | 112 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
113 |
print_interps IA (* output: i1 *) |
15596 | 114 |
|
15696 | 115 |
(* possible accesses *) |
26645
e114be97befe
Changed naming scheme for theorems generated by interpretations.
ballarin
parents:
26343
diff
changeset
|
116 |
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
|
117 |
thm i1.asm_A thm LocaleTest.i1.asm_A |
15696 | 118 |
|
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
119 |
ML {* check_thm "i1.a.asm_A" *} |
15624
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset
|
120 |
|
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset
|
121 |
(* without prefix *) |
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset
|
122 |
|
27761
b95e9ba0ca1d
Interpretation command (theory/proof context) no longer simplifies goal.
ballarin
parents:
27718
diff
changeset
|
123 |
interpretation IC ["W::i" "Z::i"] by intro_locales (* subsumed by i1: IC *) |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
124 |
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
|
125 |
(* subsumes i1: IA and i1: IC *) |
15696 | 126 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
127 |
print_interps IA (* output: <no prefix>, i1 *) |
15596 | 128 |
|
15837 | 129 |
(* possible accesses *) |
26645
e114be97befe
Changed naming scheme for theorems generated by interpretations.
ballarin
parents:
26343
diff
changeset
|
130 |
thm asm_C thm a_b.asm_C thm LocaleTest.IC_locale.a_b.asm_C thm IC_locale.a_b.asm_C |
15696 | 131 |
|
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
132 |
ML {* check_thm "asm_C" *} |
15596 | 133 |
|
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
134 |
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
|
135 |
by (simp add: eq_commute) unfold_locales |
15837 | 136 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
137 |
print_interps IA (* output: <no prefix>, i1 *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
138 |
print_interps ID (* output: i2 *) |
15837 | 139 |
|
140 |
||
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
141 |
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
|
142 |
|
17436 | 143 |
(* duplicate: thm not added *) |
15696 | 144 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
145 |
(* thm i3.a.asm_A *) |
15696 | 146 |
|
15596 | 147 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
148 |
print_interps IA (* output: <no prefix>, i1 *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
149 |
print_interps IB (* output: i1 *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
150 |
print_interps IC (* output: <no prefix, i1 *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
151 |
print_interps ID (* output: i2, i3 *) |
15596 | 152 |
|
153 |
||
27761
b95e9ba0ca1d
Interpretation command (theory/proof context) no longer simplifies goal.
ballarin
parents:
27718
diff
changeset
|
154 |
interpretation i10: ID + ID a' b' d' [X "Y::i" _ u "v::i" _] by intro_locales |
15696 | 155 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
156 |
corollary (in ID) th_x: True .. |
15696 | 157 |
|
158 |
(* possible accesses: for each registration *) |
|
159 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
160 |
thm i2.th_x thm i3.th_x |
15696 | 161 |
|
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
162 |
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
|
163 |
|
26199 | 164 |
lemma (in ID) th_y: "d == (a = b)" by (rule d_def) |
15696 | 165 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
166 |
thm i2.th_y thm i3.th_y |
15696 | 167 |
|
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
168 |
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
|
169 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
170 |
lemmas (in ID) th_z = th_y |
15696 | 171 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
172 |
thm i2.th_z |
15696 | 173 |
|
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
174 |
ML {* check_thm "i2.th_z" *} |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
175 |
|
15596 | 176 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
177 |
subsection {* Interpretation in Proof Contexts *} |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
178 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
179 |
locale IF = fixes f assumes asm_F: "f & f --> f" |
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
180 |
|
25282 | 181 |
consts default :: "'a" |
182 |
||
15624
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset
|
183 |
theorem True |
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset
|
184 |
proof - |
25282 | 185 |
fix alpha::i and beta |
186 |
have alpha_A: "IA(alpha)" by unfold_locales |
|
27761
b95e9ba0ca1d
Interpretation command (theory/proof context) no longer simplifies goal.
ballarin
parents:
27718
diff
changeset
|
187 |
interpret i5: IA [alpha] by intro_locales (* subsumed *) |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
188 |
print_interps IA (* output: <no prefix>, i1 *) |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
189 |
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
|
190 |
print_interps IA (* output: <no prefix>, i1 *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
191 |
print_interps IC (* output: <no prefix>, i1, i6 *) |
25282 | 192 |
interpret i11: IF ["default = default"] by (fast intro: IF.intro) |
193 |
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
|
194 |
qed rule |
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset
|
195 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
196 |
theorem (in IA) True |
15696 | 197 |
proof - |
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
198 |
print_interps! IA |
15696 | 199 |
fix beta and gamma |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
200 |
interpret i9: ID [a beta _] |
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
201 |
apply - apply assumption |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
202 |
apply unfold_locales |
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
203 |
apply (rule refl) done |
15696 | 204 |
qed rule |
15624
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset
|
205 |
|
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset
|
206 |
|
15696 | 207 |
(* Definition involving free variable *) |
208 |
||
209 |
ML {* reset show_sorts *} |
|
210 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
211 |
locale IE = fixes e defines e_def: "e(x) == x & x" |
15696 | 212 |
notes e_def2 = e_def |
213 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
214 |
lemma (in IE) True thm e_def by fast |
15696 | 215 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
216 |
interpretation i7: IE ["%x. x"] by simp |
15696 | 217 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
218 |
thm i7.e_def2 (* has no premise *) |
15696 | 219 |
|
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
220 |
ML {* check_thm "i7.e_def2" *} |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
221 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
222 |
locale IE' = fixes e defines e_def: "e == (%x. x & x)" |
15696 | 223 |
notes e_def2 = e_def |
224 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
225 |
interpretation i7': IE' ["(%x. x)"] by simp |
15696 | 226 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
227 |
thm i7'.e_def2 |
15696 | 228 |
|
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
229 |
ML {* check_thm "i7'.e_def2" *} |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
230 |
|
15696 | 231 |
(* Definition involving free variable in assm *) |
232 |
||
27681 | 233 |
locale IG = fixes g assumes asm_G: "g --> x" |
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
15837
diff
changeset
|
234 |
notes asm_G2 = asm_G |
15696 | 235 |
|
27718 | 236 |
interpretation i8: IG ["False"] by unfold_locales fast |
15696 | 237 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
238 |
thm i8.asm_G2 |
15696 | 239 |
|
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
240 |
ML {* check_thm "i8.asm_G2" *} |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
241 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
242 |
text {* Locale without assumptions *} |
15696 | 243 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
244 |
locale IL1 = notes rev_conjI [intro] = conjI [THEN iffD1 [OF conj_commute]] |
15696 | 245 |
|
246 |
lemma "[| P; Q |] ==> P & Q" |
|
247 |
proof - |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
248 |
interpret my: IL1 . txt {* No chained fact required. *} |
15696 | 249 |
assume Q and P txt {* order reversed *} |
250 |
then show "P & Q" .. txt {* Applies @{thm my.rev_conjI}. *} |
|
251 |
qed |
|
252 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
253 |
locale IL11 = notes rev_conjI = conjI [THEN iffD1 [OF conj_commute]] |
15696 | 254 |
|
255 |
lemma "[| P; Q |] ==> P & Q" |
|
256 |
proof - |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
257 |
interpret [intro]: IL11 . txt {* Attribute supplied at instantiation. *} |
15696 | 258 |
assume Q and P |
259 |
then show "P & Q" .. |
|
260 |
qed |
|
261 |
||
262 |
subsection {* Simple locale with assumptions *} |
|
263 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
264 |
consts ibin :: "[i, i] => i" (infixl "#" 60) |
15696 | 265 |
|
266 |
axioms i_assoc: "(x # y) # z = x # (y # z)" |
|
267 |
i_comm: "x # y = y # x" |
|
268 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
269 |
locale IL2 = |
15696 | 270 |
fixes OP (infixl "+" 60) |
271 |
assumes assoc: "(x + y) + z = x + (y + z)" |
|
272 |
and comm: "x + y = y + x" |
|
273 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
274 |
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
|
275 |
proof - |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
276 |
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
|
277 |
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
|
278 |
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
|
279 |
finally show ?thesis . |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
280 |
qed |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
281 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
282 |
lemmas (in IL2) AC = comm assoc lcomm |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
283 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
284 |
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
|
285 |
proof - |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
286 |
interpret my: IL2 ["op #"] by (rule IL2.intro [of "op #", OF i_assoc i_comm]) |
17033 | 287 |
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
|
288 |
qed |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
289 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
290 |
subsection {* Nested locale with assumptions *} |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
291 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
292 |
locale IL3 = |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
293 |
fixes OP (infixl "+" 60) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
294 |
assumes assoc: "(x + y) + z = x + (y + z)" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
295 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
296 |
locale IL4 = IL3 + |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
297 |
assumes comm: "x + y = y + x" |
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 |
lemma (in IL4) lcomm: "x + (y + z) = y + (x + z)" |
15696 | 300 |
proof - |
301 |
have "x + (y + z) = (x + y) + z" by (simp add: assoc) |
|
302 |
also have "... = (y + x) + z" by (simp add: comm) |
|
303 |
also have "... = y + (x + z)" by (simp add: assoc) |
|
304 |
finally show ?thesis . |
|
305 |
qed |
|
306 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
307 |
lemmas (in IL4) AC = comm assoc lcomm |
15696 | 308 |
|
309 |
lemma "(x::i) # y # z # w = y # x # w # z" |
|
310 |
proof - |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
311 |
interpret my: IL4 ["op #"] |
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
312 |
by (auto intro: IL4.intro IL3.intro IL4_axioms.intro i_assoc i_comm) |
15696 | 313 |
show ?thesis by (simp only: my.OP.AC) (* or simply AC *) |
314 |
qed |
|
315 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
316 |
text {* Locale with definition *} |
15696 | 317 |
|
318 |
text {* This example is admittedly not very creative :-) *} |
|
319 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
320 |
locale IL5 = IL4 + var A + |
15696 | 321 |
defines A_def: "A == True" |
322 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
323 |
lemma (in IL5) lem: A |
15696 | 324 |
by (unfold A_def) rule |
325 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
326 |
lemma "IL5(op #) ==> True" |
15696 | 327 |
proof - |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
328 |
assume "IL5(op #)" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
329 |
then interpret IL5 ["op #"] by (auto intro: IL5.axioms) |
15696 | 330 |
show ?thesis by (rule lem) (* lem instantiated to True *) |
331 |
qed |
|
332 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
333 |
text {* Interpretation in a context with target *} |
15696 | 334 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
335 |
lemma (in IL4) |
15696 | 336 |
fixes A (infixl "$" 60) |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
337 |
assumes A: "IL4(A)" |
15696 | 338 |
shows "(x::i) $ y $ z $ w = y $ x $ w $ z" |
339 |
proof - |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
340 |
from A interpret A: IL4 ["A"] by (auto intro: IL4.axioms) |
15696 | 341 |
show ?thesis by (simp only: A.OP.AC) |
342 |
qed |
|
343 |
||
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
344 |
|
16736
1e792b32abef
Preparations for interpretation of locales in locales.
ballarin
parents:
16620
diff
changeset
|
345 |
section {* Interpretation in Locales *} |
1e792b32abef
Preparations for interpretation of locales in locales.
ballarin
parents:
16620
diff
changeset
|
346 |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
347 |
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
|
348 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
349 |
(* locale with many parameters --- |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
350 |
interpretations generate alternating group A5 *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
351 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
352 |
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
|
353 |
assumes eq: "A <-> B <-> C <-> D <-> E" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
354 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
355 |
interpretation RA5 < RA5 _ _ D E C |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
356 |
print_facts |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
357 |
print_interps RA5 |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
358 |
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
|
359 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
360 |
interpretation RA5 < RA5 C _ E _ A |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
361 |
print_facts |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
362 |
print_interps RA5 |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
363 |
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
|
364 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
365 |
interpretation RA5 < RA5 B C A _ _ |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
366 |
print_facts |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
367 |
print_interps RA5 |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
368 |
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
|
369 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
370 |
interpretation RA5 < RA5 _ C D B _ . |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
371 |
(* 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
|
372 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
373 |
(* circle of three locales, forward direction *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
374 |
|
27681 | 375 |
locale RA1 = var A + var B + assumes p: "A <-> B" |
376 |
locale RA2 = var A + var B + assumes q: "A & B | ~ A & ~ B" |
|
377 |
locale RA3 = var A + var B + assumes r: "(A --> B) & (B --> A)" |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
378 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
379 |
interpretation RA1 < RA2 |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
380 |
print_facts |
27681 | 381 |
using p apply unfold_locales apply fast done |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
382 |
interpretation RA2 < RA3 |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
383 |
print_facts |
27681 | 384 |
using q apply unfold_locales apply fast done |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
385 |
interpretation RA3 < RA1 |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
386 |
print_facts |
27681 | 387 |
using r apply unfold_locales apply fast done |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
388 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
389 |
(* circle of three locales, backward direction *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
390 |
|
27681 | 391 |
locale RB1 = var A + var B + assumes p: "A <-> B" |
392 |
locale RB2 = var A + var B + assumes q: "A & B | ~ A & ~ B" |
|
393 |
locale RB3 = var A + var B + assumes r: "(A --> B) & (B --> A)" |
|
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
394 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
395 |
interpretation RB1 < RB2 |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
396 |
print_facts |
27681 | 397 |
using p apply unfold_locales apply fast done |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
398 |
interpretation RB3 < RB1 |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
399 |
print_facts |
27681 | 400 |
using r apply unfold_locales apply fast done |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
401 |
interpretation RB2 < RB3 |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
402 |
print_facts |
27681 | 403 |
using q apply unfold_locales apply fast done |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
404 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
405 |
lemma (in RB1) True |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
406 |
print_facts |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
407 |
.. |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
408 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
409 |
|
27718 | 410 |
(* Group example *) |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
411 |
|
27718 | 412 |
locale Rsemi = var prod (infixl "**" 65) + |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
413 |
assumes assoc: "(x ** y) ** z = x ** (y ** z)" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
414 |
|
27718 | 415 |
locale Rlgrp = Rsemi + var one + var inv + |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
416 |
assumes lone: "one ** x = x" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
417 |
and linv: "inv(x) ** x = one" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
418 |
|
27718 | 419 |
lemma (in Rlgrp) lcancel: |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
420 |
"x ** y = x ** z <-> y = z" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
421 |
proof |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
422 |
assume "x ** y = x ** z" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
423 |
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
|
424 |
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
|
425 |
qed simp |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
426 |
|
27718 | 427 |
locale Rrgrp = Rsemi + var one + var inv + |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
428 |
assumes rone: "x ** one = x" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
429 |
and rinv: "x ** inv(x) = one" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
430 |
|
27718 | 431 |
lemma (in Rrgrp) rcancel: |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
432 |
"y ** x = z ** x <-> y = z" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
433 |
proof |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
434 |
assume "y ** x = z ** x" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
435 |
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
|
436 |
by (simp add: assoc [symmetric]) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
437 |
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
|
438 |
qed simp |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
439 |
|
27718 | 440 |
interpretation Rlgrp < Rrgrp |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
441 |
proof unfold_locales |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
442 |
{ |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
443 |
fix x |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
444 |
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
|
445 |
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
|
446 |
} |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
447 |
note rone = this |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
448 |
{ |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
449 |
fix x |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
450 |
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
|
451 |
by (simp add: linv lone rone) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
452 |
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
|
453 |
} |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
454 |
qed |
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 |
(* effect on printed locale *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
457 |
|
27718 | 458 |
print_locale! Rlgrp |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
459 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
460 |
(* use of derived theorem *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
461 |
|
27718 | 462 |
lemma (in Rlgrp) |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
463 |
"y ** x = z ** x <-> y = z" |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
464 |
apply (rule rcancel) |
27718 | 465 |
print_interps Rrgrp thm lcancel rcancel |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
466 |
done |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
467 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
468 |
(* circular interpretation *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
469 |
|
27718 | 470 |
interpretation Rrgrp < Rlgrp |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
471 |
proof unfold_locales |
17000
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
472 |
{ |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
473 |
fix x |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
474 |
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
|
475 |
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
|
476 |
} |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
477 |
note lone = this |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
478 |
{ |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
479 |
fix x |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
480 |
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
|
481 |
by (simp add: rinv lone rone) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
482 |
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
|
483 |
} |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
484 |
qed |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
485 |
|
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
486 |
(* effect on printed locale *) |
552df70f52c2
First version of interpretation in locales. Not yet fully functional.
ballarin
parents:
16736
diff
changeset
|
487 |
|
27718 | 488 |
print_locale! Rrgrp |
489 |
print_locale! Rlgrp |
|
16736
1e792b32abef
Preparations for interpretation of locales in locales.
ballarin
parents:
16620
diff
changeset
|
490 |
|
17033 | 491 |
subsection {* Interaction of Interpretation in Theories and Locales: |
17096
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
492 |
in Locale, then in Theory *} |
17033 | 493 |
|
494 |
consts |
|
495 |
rone :: i |
|
496 |
rinv :: "i => i" |
|
497 |
||
498 |
axioms |
|
499 |
r_one : "rone # x = x" |
|
500 |
r_inv : "rinv(x) # x = rone" |
|
501 |
||
502 |
interpretation Rbool: Rlgrp ["op #" "rone" "rinv"] |
|
27681 | 503 |
proof |
17033 | 504 |
fix x y z |
505 |
{ |
|
506 |
show "(x # y) # z = x # (y # z)" by (rule i_assoc) |
|
507 |
next |
|
508 |
show "rone # x = x" by (rule r_one) |
|
509 |
next |
|
510 |
show "rinv(x) # x = rone" by (rule r_inv) |
|
511 |
} |
|
512 |
qed |
|
513 |
||
514 |
(* derived elements *) |
|
515 |
||
516 |
print_interps Rrgrp |
|
517 |
print_interps Rlgrp |
|
518 |
||
519 |
lemma "y # x = z # x <-> y = z" by (rule Rbool.rcancel) |
|
520 |
||
521 |
(* adding lemma to derived element *) |
|
522 |
||
523 |
lemma (in Rrgrp) new_cancel: |
|
524 |
"b ** a = c ** a <-> b = c" |
|
525 |
by (rule rcancel) |
|
526 |
||
527 |
thm Rbool.new_cancel (* additional prems discharged!! *) |
|
528 |
||
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
529 |
ML {* check_thm "Rbool.new_cancel" *} |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
530 |
|
17033 | 531 |
lemma "b # a = c # a <-> b = c" by (rule Rbool.new_cancel) |
532 |
||
533 |
||
534 |
subsection {* Interaction of Interpretation in Theories and Locales: |
|
17096
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
535 |
in Theory, then in Locale *} |
17033 | 536 |
|
537 |
(* Another copy of the group example *) |
|
538 |
||
539 |
locale Rqsemi = var prod (infixl "**" 65) + |
|
540 |
assumes assoc: "(x ** y) ** z = x ** (y ** z)" |
|
541 |
||
542 |
locale Rqlgrp = Rqsemi + var one + var inv + |
|
543 |
assumes lone: "one ** x = x" |
|
544 |
and linv: "inv(x) ** x = one" |
|
545 |
||
546 |
lemma (in Rqlgrp) lcancel: |
|
547 |
"x ** y = x ** z <-> y = z" |
|
548 |
proof |
|
549 |
assume "x ** y = x ** z" |
|
550 |
then have "inv(x) ** x ** y = inv(x) ** x ** z" by (simp add: assoc) |
|
551 |
then show "y = z" by (simp add: lone linv) |
|
552 |
qed simp |
|
553 |
||
554 |
locale Rqrgrp = Rqsemi + var one + var inv + |
|
555 |
assumes rone: "x ** one = x" |
|
556 |
and rinv: "x ** inv(x) = one" |
|
557 |
||
558 |
lemma (in Rqrgrp) rcancel: |
|
559 |
"y ** x = z ** x <-> y = z" |
|
560 |
proof |
|
561 |
assume "y ** x = z ** x" |
|
562 |
then have "y ** (x ** inv(x)) = z ** (x ** inv(x))" |
|
563 |
by (simp add: assoc [symmetric]) |
|
564 |
then show "y = z" by (simp add: rone rinv) |
|
565 |
qed simp |
|
566 |
||
27718 | 567 |
interpretation Rqrgrp < Rrgrp |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
568 |
apply unfold_locales |
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
569 |
apply (rule assoc) |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
570 |
apply (rule rone) |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
571 |
apply (rule rinv) |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
572 |
done |
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
573 |
|
17033 | 574 |
interpretation R2: Rqlgrp ["op #" "rone" "rinv"] |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
575 |
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
|
576 |
solve this. *) |
27681 | 577 |
apply (rule i_assoc) |
578 |
apply (rule r_one) |
|
579 |
apply (rule r_inv) |
|
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
580 |
done |
17033 | 581 |
|
582 |
print_interps Rqsemi |
|
583 |
print_interps Rqlgrp |
|
27718 | 584 |
print_interps Rlgrp (* no interpretations yet *) |
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
585 |
|
17033 | 586 |
|
587 |
interpretation Rqlgrp < Rqrgrp |
|
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
588 |
proof unfold_locales |
17033 | 589 |
{ |
590 |
fix x |
|
591 |
have "inv(x) ** x ** one = inv(x) ** x" by (simp add: linv lone) |
|
592 |
then show "x ** one = x" by (simp add: assoc lcancel) |
|
593 |
} |
|
594 |
note rone = this |
|
595 |
{ |
|
596 |
fix x |
|
597 |
have "inv(x) ** x ** inv(x) = inv(x) ** one" |
|
598 |
by (simp add: linv lone rone) |
|
599 |
then show "x ** inv(x) = one" by (simp add: assoc lcancel) |
|
600 |
} |
|
601 |
qed |
|
602 |
||
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
603 |
print_interps! Rqrgrp |
27718 | 604 |
print_interps! Rsemi (* witness must not have meta hyps *) |
605 |
print_interps! Rrgrp (* witness must not have meta hyps *) |
|
606 |
print_interps! Rlgrp (* witness must not have meta hyps *) |
|
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
607 |
thm R2.rcancel |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
608 |
thm R2.lcancel |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
609 |
|
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
610 |
ML {* check_thm "R2.rcancel"; check_thm "R2.lcancel" *} |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17096
diff
changeset
|
611 |
|
17096
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
612 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
613 |
subsection {* Generation of Witness Theorems for Transitive Interpretations *} |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
614 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
615 |
locale Rtriv = var x + |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
616 |
assumes x: "x = x" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
617 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
618 |
locale Rtriv2 = var x + var y + |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
619 |
assumes x: "x = x" and y: "y = y" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
620 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
621 |
interpretation Rtriv2 < Rtriv x |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
622 |
apply unfold_locales |
17096
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
623 |
apply (rule x) |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
624 |
done |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
625 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
626 |
interpretation Rtriv2 < Rtriv y |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
627 |
apply unfold_locales |
17096
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
628 |
apply (rule y) |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
629 |
done |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
630 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
631 |
print_locale Rtriv2 |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
632 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
633 |
locale Rtriv3 = var x + var y + var z + |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
634 |
assumes x: "x = x" and y: "y = y" and z: "z = z" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
635 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
636 |
interpretation Rtriv3 < Rtriv2 x y |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
637 |
apply unfold_locales |
17096
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
638 |
apply (rule x) |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
639 |
apply (rule y) |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
640 |
done |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
641 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
642 |
print_locale Rtriv3 |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
643 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
644 |
interpretation Rtriv3 < Rtriv2 x z |
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
645 |
apply unfold_locales |
17096
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
646 |
apply (rule x_y_z.x) |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
647 |
apply (rule z) |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
648 |
done |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
649 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
650 |
ML {* set show_types *} |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
651 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
652 |
print_locale Rtriv3 |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
653 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
654 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
655 |
subsection {* Normalisation Replaces Assumed Element by Derived Element *} |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
656 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
657 |
typedecl ('a, 'b) pair |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
658 |
arities pair :: ("term", "term") "term" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
659 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
660 |
consts |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
661 |
pair :: "['a, 'b] => ('a, 'b) pair" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
662 |
fst :: "('a, 'b) pair => 'a" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
663 |
snd :: "('a, 'b) pair => 'b" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
664 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
665 |
axioms |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
666 |
fst [simp]: "fst(pair(x, y)) = x" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
667 |
snd [simp]: "snd(pair(x, y)) = y" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
668 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
669 |
locale Rpair = var prod (infixl "**" 65) + var prodP (infixl "***" 65) + |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
670 |
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
|
671 |
|
27718 | 672 |
locale Rpair_semi = Rpair + Rsemi |
17096
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
673 |
|
27718 | 674 |
interpretation Rpair_semi < Rsemi prodP (infixl "***" 65) |
675 |
proof unfold_locales |
|
17096
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
676 |
fix x y z |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
677 |
show "(x *** y) *** z = x *** (y *** z)" |
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19783
diff
changeset
|
678 |
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
|
679 |
done |
17096
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
680 |
qed |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
681 |
|
27718 | 682 |
locale Rsemi_rev = Rsemi + var rprod (infixl "++" 65) + |
17096
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
683 |
defines r_def: "x ++ y == y ** x" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
684 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
685 |
lemma (in Rsemi_rev) r_assoc: |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
686 |
"(x ++ y) ++ z = x ++ (y ++ z)" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
687 |
by (simp add: r_def assoc) |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
688 |
|
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
689 |
lemma (in Rpair_semi) |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
690 |
includes Rsemi_rev prodP (infixl "***" 65) rprodP (infixl "+++" 65) |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
691 |
constrains prod :: "['a, 'a] => 'a" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
692 |
and rprodP :: "[('a, 'a) pair, ('a, 'a) pair] => ('a, 'a) pair" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
693 |
shows "(x +++ y) +++ z = x +++ (y +++ z)" |
8327b71282ce
Improved generation of witnesses in interpretation.
ballarin
parents:
17033
diff
changeset
|
694 |
apply (rule r_assoc) done |
17033 | 695 |
|
20469 | 696 |
|
697 |
subsection {* Import of Locales with Predicates as Interpretation *} |
|
698 |
||
699 |
locale Ra = |
|
700 |
assumes Ra: "True" |
|
701 |
||
702 |
locale Rb = Ra + |
|
703 |
assumes Rb: "True" |
|
704 |
||
705 |
locale Rc = Rb + |
|
706 |
assumes Rc: "True" |
|
707 |
||
708 |
print_locale! Rc |
|
709 |
||
22659
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
710 |
|
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
711 |
section {* Interpretation of Defined Concepts *} |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
712 |
|
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
713 |
text {* Naming convention for global objects: prefixes D and d *} |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
714 |
|
23919
af871d13e320
interpretation: equations are propositions not pairs of terms;
ballarin
parents:
22931
diff
changeset
|
715 |
|
af871d13e320
interpretation: equations are propositions not pairs of terms;
ballarin
parents:
22931
diff
changeset
|
716 |
subsection {* Simple examples *} |
af871d13e320
interpretation: equations are propositions not pairs of terms;
ballarin
parents:
22931
diff
changeset
|
717 |
|
22659
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
718 |
locale Da = fixes a :: o |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
719 |
assumes true: a |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
720 |
|
22757 | 721 |
text {* In the following examples, @{term "~ a"} is the defined concept. *} |
722 |
||
22659
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
723 |
lemma (in Da) not_false: "~ a <-> False" |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
724 |
apply simp apply (rule true) done |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
725 |
|
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
726 |
interpretation D1: Da ["True"] |
23919
af871d13e320
interpretation: equations are propositions not pairs of terms;
ballarin
parents:
22931
diff
changeset
|
727 |
where "~ True == False" |
22659
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
728 |
apply - |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
729 |
apply unfold_locales [1] apply rule |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
730 |
by simp |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
731 |
|
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
732 |
thm D1.not_false |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
733 |
lemma "False <-> False" apply (rule D1.not_false) done |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
734 |
|
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
735 |
interpretation D2: Da ["x | ~ x"] |
23919
af871d13e320
interpretation: equations are propositions not pairs of terms;
ballarin
parents:
22931
diff
changeset
|
736 |
where "~ (x | ~ x) <-> ~ x & x" |
22659
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
737 |
apply - |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
738 |
apply unfold_locales [1] apply fast |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
739 |
by simp |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
740 |
|
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
741 |
thm D2.not_false |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
742 |
lemma "~ x & x <-> False" apply (rule D2.not_false) done |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
743 |
|
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
744 |
print_interps! Da |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
745 |
|
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
746 |
(* Subscriptions of interpretations *) |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
747 |
|
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
748 |
lemma (in Da) not_false2: "~a <-> False" |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
749 |
apply simp apply (rule true) done |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
750 |
|
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
751 |
thm D1.not_false2 D2.not_false2 |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
752 |
lemma "False <-> False" apply (rule D1.not_false2) done |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
753 |
lemma "~x & x <-> False" apply (rule D2.not_false2) done |
f792579b6e59
Experimental code for the interpretation of definitions.
ballarin
parents:
20469
diff
changeset
|
754 |
|
22757 | 755 |
(* Unfolding in attributes *) |
756 |
||
757 |
locale Db = Da + |
|
758 |
fixes b :: o |
|
759 |
assumes a_iff_b: "~a <-> b" |
|
760 |
||
761 |
lemmas (in Db) not_false_b = not_false [unfolded a_iff_b] |
|
762 |
||
763 |
interpretation D2: Db ["x | ~ x" "~ (x <-> x)"] |
|
764 |
apply unfold_locales apply fast done |
|
765 |
||
766 |
thm D2.not_false_b |
|
767 |
lemma "~(x <-> x) <-> False" apply (rule D2.not_false_b) done |
|
768 |
||
769 |
(* Subscription and attributes *) |
|
770 |
||
771 |
lemmas (in Db) not_false_b2 = not_false [unfolded a_iff_b] |
|
772 |
||
773 |
thm D2.not_false_b2 |
|
774 |
lemma "~(x <-> x) <-> False" apply (rule D2.not_false_b2) done |
|
775 |
||
15596 | 776 |
end |