src/FOL/ex/LocaleTest.thy
author ballarin
Tue, 02 Aug 2005 16:52:21 +0200
changeset 17000 552df70f52c2
parent 16736 1e792b32abef
child 17033 f4c1ce91aa3c
permissions -rw-r--r--
First version of interpretation in locales. Not yet fully functional.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
     1
(*  Title:      FOL/ex/LocaleTest.thy
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
     2
    ID:         $Id$
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
     3
    Author:     Clemens Ballarin
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
     4
    Copyright (c) 2005 by Clemens Ballarin
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
     5
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
     6
Collection of regression tests for locales.
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
     7
*)
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
     8
16102
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 15837
diff changeset
     9
header {* Test of Locale Interpretation *}
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
    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
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
    14
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
    15
ML {* set quick_and_dirty *}    (* allow for thm command in batch mode *)
16168
adb83939177f Locales: new element constrains, parameter renaming with syntax,
ballarin
parents: 16102
diff changeset
    16
ML {* set Toplevel.debug *}
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
    17
ML {* set show_hyps *}
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
    18
ML {* set show_sorts *}
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
    19
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    20
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    21
section {* Context Elements and Locale Expressions *}
16102
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 15837
diff changeset
    22
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    23
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
    24
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    25
subsection {* Renaming with Syntax *}
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    26
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    27
locale (open) LS = var mult +
16102
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 15837
diff changeset
    28
  assumes "mult(x, y) = mult(y, x)"
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 15837
diff changeset
    29
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    30
print_locale LS
16168
adb83939177f Locales: new element constrains, parameter renaming with syntax,
ballarin
parents: 16102
diff changeset
    31
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    32
locale LS' = LS mult (infixl "**" 60)
16102
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 15837
diff changeset
    33
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    34
print_locale LS'
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
locale LT = var mult (infixl "**" 60) +
16102
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 15837
diff changeset
    37
  assumes "x ** y = y ** x"
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 15837
diff changeset
    38
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    39
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
    40
  assumes hom: "h(x ** y) = h(x) ++ h(y)"
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 15837
diff changeset
    41
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    42
locale LV = LU _ add
16102
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 15837
diff changeset
    43
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
subsection {* Constrains *}
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
locale LZ = fixes a (structure)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    48
locale LZ' = LZ +
16168
adb83939177f Locales: new element constrains, parameter renaming with syntax,
ballarin
parents: 16102
diff changeset
    49
  constrains a :: "'a => 'b"
adb83939177f Locales: new element constrains, parameter renaming with syntax,
ballarin
parents: 16102
diff changeset
    50
  assumes "a (x :: 'a) = a (y)"
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    51
print_locale LZ'
16102
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 15837
diff changeset
    52
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 15837
diff changeset
    53
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 15837
diff changeset
    54
section {* Interpretation *}
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
    55
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    56
text {* Naming convention for global objects: prefixes I and i *}
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
    57
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    58
text {* interpretation input syntax *}
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
    59
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    60
locale IL
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    61
locale IM = fixes a and b and c
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
    62
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    63
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
    64
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    65
print_interps IL    (* output: test *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    66
print_interps IM    (* output: test *)
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
    67
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    68
interpretation test [simp]: IL print_interps IM .
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
    69
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    70
interpretation IL .
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
    71
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    72
text {* Processing of locale expression *}
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
    73
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    74
locale IA = fixes a assumes asm_A: "a = a"
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
    75
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    76
locale (open) IB = fixes b assumes asm_B [simp]: "b = b"
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
    77
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    78
locale IC = IA + IB + assumes asm_C: "c = c"
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
    79
  (* TODO: independent type var in c, prohibit locale declaration *)
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
    80
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    81
locale ID = IA + IB + fixes d defines def_D: "d == (a = b)"
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
    82
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    83
theorem (in IA)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    84
  includes ID
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
    85
  shows True ..
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
    86
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    87
theorem (in ID) True ..
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
    88
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
    89
typedecl i
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
    90
arities i :: "term"
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
    91
15598
4ab52355bb53 Registrations of global locale interpretations: improved, better naming.
ballarin
parents: 15596
diff changeset
    92
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    93
interpretation i1: IC ["X::i" "Y::i"] by (auto intro: IA.intro IC_axioms.intro)
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
    94
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    95
print_interps IA  (* output: i1 *)
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
    96
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
    97
(* possible accesses *)
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    98
thm i1.a.asm_A thm LocaleTest.i1.a.asm_A
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
    99
thm i1.asm_A thm LocaleTest.i1.asm_A
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   100
15624
484178635bd8 Further work on interpretation commands. New command `interpret' for
ballarin
parents: 15598
diff changeset
   101
484178635bd8 Further work on interpretation commands. New command `interpret' for
ballarin
parents: 15598
diff changeset
   102
(* without prefix *)
484178635bd8 Further work on interpretation commands. New command `interpret' for
ballarin
parents: 15598
diff changeset
   103
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   104
interpretation IC ["W::i" "Z::i"] .  (* subsumed by i1: IC *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   105
interpretation IC ["W::'a" "Z::i"] by (auto intro: IA.intro IC_axioms.intro)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   106
  (* subsumes i1: IA and i1: IC *)
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   107
15598
4ab52355bb53 Registrations of global locale interpretations: improved, better naming.
ballarin
parents: 15596
diff changeset
   108
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   109
print_interps IA  (* output: <no prefix>, i1 *)
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
   110
15837
7a567dcd4cda Subsumption of locale interpretations.
ballarin
parents: 15763
diff changeset
   111
(* possible accesses *)
7a567dcd4cda Subsumption of locale interpretations.
ballarin
parents: 15763
diff changeset
   112
thm asm_C thm a_b.asm_C thm LocaleTest.a_b.asm_C thm LocaleTest.a_b.asm_C
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   113
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
   114
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   115
interpretation i2: ID [X "Y::i" "Y = X"] by (simp add: eq_commute)
15837
7a567dcd4cda Subsumption of locale interpretations.
ballarin
parents: 15763
diff changeset
   116
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   117
print_interps IA  (* output: <no prefix>, i1 *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   118
print_interps ID  (* output: i2 *)
15837
7a567dcd4cda Subsumption of locale interpretations.
ballarin
parents: 15763
diff changeset
   119
7a567dcd4cda Subsumption of locale interpretations.
ballarin
parents: 15763
diff changeset
   120
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   121
interpretation i3: ID [X "Y::i"] .
15598
4ab52355bb53 Registrations of global locale interpretations: improved, better naming.
ballarin
parents: 15596
diff changeset
   122
4ab52355bb53 Registrations of global locale interpretations: improved, better naming.
ballarin
parents: 15596
diff changeset
   123
(* duplicate: not registered *)
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   124
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   125
(* thm i3.a.asm_A *)
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   126
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
   127
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   128
print_interps IA  (* output: <no prefix>, i1 *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   129
print_interps IB  (* output: i1 *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   130
print_interps IC  (* output: <no prefix, i1 *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   131
print_interps ID  (* output: i2, i3 *)
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
   132
15837
7a567dcd4cda Subsumption of locale interpretations.
ballarin
parents: 15763
diff changeset
   133
(* schematic vars in instantiation not permitted *)
7a567dcd4cda Subsumption of locale interpretations.
ballarin
parents: 15763
diff changeset
   134
(*
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   135
interpretation i4: IA ["?x::?'a1"] apply (rule IA.intro) apply rule done
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   136
print_interps IA
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   137
*)
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
   138
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   139
interpretation i10: ID + ID a' b' d' [X "Y::i" _ u "v::i" _] .
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   140
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   141
corollary (in ID) th_x: True ..
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   142
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   143
(* possible accesses: for each registration *)
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   144
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   145
thm i2.th_x thm i3.th_x
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   146
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   147
lemma (in ID) th_y: "d == (a = b)" .
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   148
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   149
thm i2.th_y thm i3.th_y
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   150
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   151
lemmas (in ID) th_z = th_y
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   152
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   153
thm i2.th_z
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   154
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
   155
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   156
subsection {* Interpretation in Proof Contexts *}
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   157
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   158
locale IF = fixes f assumes asm_F: "f & f --> f"
16102
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 15837
diff changeset
   159
15624
484178635bd8 Further work on interpretation commands. New command `interpret' for
ballarin
parents: 15598
diff changeset
   160
theorem True
484178635bd8 Further work on interpretation commands. New command `interpret' for
ballarin
parents: 15598
diff changeset
   161
proof -
16102
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 15837
diff changeset
   162
  fix alpha::i and beta::'a and gamma::o
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   163
  (* FIXME: omitting type of beta leads to error later at interpret i6 *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   164
  have alpha_A: "IA(alpha)" by (auto intro: IA.intro)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   165
  interpret i5: IA [alpha] .  (* subsumed *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   166
  print_interps IA  (* output: <no prefix>, i1 *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   167
  interpret i6: IC [alpha beta] by (auto intro: IC_axioms.intro)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   168
  print_interps IA   (* output: <no prefix>, i1 *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   169
  print_interps IC   (* output: <no prefix>, i1, i6 *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   170
  interpret i11: IF [gamma] by (fast intro: IF.intro)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   171
  thm i11.asm_F      (* gamma is a Free *)
15624
484178635bd8 Further work on interpretation commands. New command `interpret' for
ballarin
parents: 15598
diff changeset
   172
qed rule
484178635bd8 Further work on interpretation commands. New command `interpret' for
ballarin
parents: 15598
diff changeset
   173
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   174
theorem (in IA) True
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   175
proof -
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   176
  print_interps IA
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   177
  fix beta and gamma
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   178
  interpret i9: ID [a beta _]
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   179
    (* no proof obligation for IA !!! *)
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   180
    apply - apply (rule refl) apply assumption done
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   181
qed rule
15624
484178635bd8 Further work on interpretation commands. New command `interpret' for
ballarin
parents: 15598
diff changeset
   182
484178635bd8 Further work on interpretation commands. New command `interpret' for
ballarin
parents: 15598
diff changeset
   183
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   184
(* Definition involving free variable *)
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   185
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   186
ML {* reset show_sorts *}
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   187
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   188
locale IE = fixes e defines e_def: "e(x) == x & x"
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   189
  notes e_def2 = e_def
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   190
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   191
lemma (in IE) True thm e_def by fast
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   192
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   193
interpretation i7: IE ["%x. x"] by simp
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   194
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   195
thm i7.e_def2 (* has no premise *)
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   196
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   197
locale IE' = fixes e defines e_def: "e == (%x. x & x)"
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   198
  notes e_def2 = e_def
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   199
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   200
interpretation i7': IE' ["(%x. x)"] by simp
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   201
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   202
thm i7'.e_def2
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   203
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   204
(* Definition involving free variable in assm *)
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   205
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   206
locale (open) IG = fixes g assumes asm_G: "g --> x"
16102
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 15837
diff changeset
   207
  notes asm_G2 = asm_G
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   208
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   209
interpretation i8: IG ["False"] by fast
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   210
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   211
thm i8.asm_G2
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   212
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   213
text {* Locale without assumptions *}
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   214
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   215
locale IL1 = notes rev_conjI [intro] = conjI [THEN iffD1 [OF conj_commute]]
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   216
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   217
lemma "[| P; Q |] ==> P & Q"
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   218
proof -
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   219
  interpret my: IL1 .          txt {* No chained fact required. *}
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   220
  assume Q and P               txt {* order reversed *}
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   221
  then show "P & Q" ..         txt {* Applies @{thm my.rev_conjI}. *}
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   222
qed
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   223
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   224
locale IL11 = notes rev_conjI = conjI [THEN iffD1 [OF conj_commute]]
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   225
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   226
lemma "[| P; Q |] ==> P & Q"
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   227
proof -
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   228
  interpret [intro]: IL11 .     txt {* Attribute supplied at instantiation. *}
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   229
  assume Q and P
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   230
  then show "P & Q" ..
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   231
qed
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   232
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   233
subsection {* Simple locale with assumptions *}
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   234
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   235
consts ibin :: "[i, i] => i" (infixl "#" 60)
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   236
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   237
axioms i_assoc: "(x # y) # z = x # (y # z)"
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   238
  i_comm: "x # y = y # x"
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   239
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   240
locale IL2 =
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   241
  fixes OP (infixl "+" 60)
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   242
  assumes assoc: "(x + y) + z = x + (y + z)"
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   243
    and comm: "x + y = y + x"
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   244
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   245
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
   246
proof -
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   247
  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
   248
  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
   249
  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
   250
  finally show ?thesis .
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   251
qed
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   252
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   253
lemmas (in IL2) AC = comm assoc lcomm
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   254
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   255
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
   256
proof -
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   257
  interpret my: IL2 ["op #"] by (rule IL2.intro [of "op #", OF i_assoc i_comm])
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   258
    txt {* Chained fact required to discharge assumptions of @{text IL2}
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   259
      and instantiate parameters. *}
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   260
  show ?thesis by (simp only: my.OP.AC)  (* or simply AC *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   261
qed
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   262
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   263
subsection {* Nested locale with assumptions *}
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   264
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   265
locale IL3 =
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   266
  fixes OP (infixl "+" 60)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   267
  assumes assoc: "(x + y) + z = x + (y + z)"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   268
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   269
locale IL4 = IL3 +
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   270
  assumes comm: "x + y = y + x"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   271
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   272
lemma (in IL4) lcomm: "x + (y + z) = y + (x + z)"
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   273
proof -
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   274
  have "x + (y + z) = (x + y) + z" by (simp add: assoc)
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   275
  also have "... = (y + x) + z" by (simp add: comm)
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   276
  also have "... = y + (x + z)" by (simp add: assoc)
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   277
  finally show ?thesis .
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   278
qed
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   279
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   280
lemmas (in IL4) AC = comm assoc lcomm
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   281
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   282
lemma "(x::i) # y # z # w = y # x # w # z"
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   283
proof -
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   284
  interpret my: IL4 ["op #"]
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   285
    by (auto intro: IL3.intro IL4_axioms.intro i_assoc i_comm)
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   286
  show ?thesis by (simp only: my.OP.AC)  (* or simply AC *)
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   287
qed
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   288
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   289
text {* Locale with definition *}
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   290
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   291
text {* This example is admittedly not very creative :-) *}
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   292
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   293
locale IL5 = IL4 + var A +
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   294
  defines A_def: "A == True"
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   295
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   296
lemma (in IL5) lem: A
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   297
  by (unfold A_def) rule
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   298
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   299
lemma "IL5(op #) ==> True"
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   300
proof -
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   301
  assume "IL5(op #)"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   302
  then interpret IL5 ["op #"] by (auto intro: IL5.axioms)
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   303
  show ?thesis by (rule lem)  (* lem instantiated to True *)
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   304
qed
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   305
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   306
text {* Interpretation in a context with target *}
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   307
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   308
lemma (in IL4)
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   309
  fixes A (infixl "$" 60)
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   310
  assumes A: "IL4(A)"
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   311
  shows "(x::i) $ y $ z $ w = y $ x $ w $ z"
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   312
proof -
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   313
  from A interpret A: IL4 ["A"] by (auto intro: IL4.axioms)
15696
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   314
  show ?thesis by (simp only: A.OP.AC)
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   315
qed
1da4ce092c0b First release of interpretation commands.
ballarin
parents: 15624
diff changeset
   316
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   317
16736
1e792b32abef Preparations for interpretation of locales in locales.
ballarin
parents: 16620
diff changeset
   318
section {* Interpretation in Locales *}
1e792b32abef Preparations for interpretation of locales in locales.
ballarin
parents: 16620
diff changeset
   319
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   320
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
   321
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   322
locale (open) Rsemi = var prod (infixl "**" 65) +
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   323
  assumes assoc: "(x ** y) ** z = x ** (y ** z)"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   324
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   325
locale (open) Rlgrp = Rsemi + var one + var inv +
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   326
  assumes lone: "one ** x = x"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   327
    and linv: "inv(x) ** x = one"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   328
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   329
lemma (in Rlgrp) lcancel:
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   330
  "x ** y = x ** z <-> y = z"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   331
proof
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   332
  assume "x ** y = x ** z"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   333
  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
   334
  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
   335
qed simp
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   336
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   337
locale (open) Rrgrp = Rsemi + var one + var inv +
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   338
  assumes rone: "x ** one = x"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   339
    and rinv: "x ** inv(x) = one"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   340
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   341
lemma (in Rrgrp) rcancel:
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   342
  "y ** x = z ** x <-> y = z"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   343
proof
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   344
  assume "y ** x = z ** x"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   345
  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
   346
    by (simp add: assoc [symmetric])
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   347
  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
   348
qed simp
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   349
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   350
interpretation Rlgrp < Rrgrp
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   351
  proof - (* (rule Rrgrp_axioms.intro) *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   352
    {
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   353
      fix x
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   354
      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
   355
      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
   356
    }
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   357
    note rone = this
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
      fix x
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   360
      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
   361
	by (simp add: linv lone rone)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   362
      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
   363
    }
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   364
  qed
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   365
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   366
(* effect on printed locale *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   367
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   368
print_locale Rlgrp
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
(* use of derived theorem *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   371
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   372
lemma (in Rlgrp)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   373
  "y ** x = z ** x <-> y = z"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   374
  apply (rule rcancel)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   375
  print_interps Rrgrp thm lcancel rcancel
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   376
  done
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   377
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   378
(* circular interpretation *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   379
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   380
interpretation Rrgrp < Rlgrp
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   381
  proof -
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   382
    {
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   383
      fix x
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   384
      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
   385
      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
   386
    }
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   387
    note lone = this
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
      fix x
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   390
      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
   391
	by (simp add: rinv lone rone)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   392
      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
   393
    }
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   394
  qed
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   395
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   396
(* effect on printed locale *)
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
print_locale Rrgrp
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   399
print_locale Rlgrp
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   400
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   401
(* locale with many parameters ---
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   402
   interpretations generate alternating group A5 *)
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
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
   405
  assumes eq: "A <-> B <-> C <-> D <-> E"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   406
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   407
interpretation RA5 < RA5 _ _ D E C
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   408
print_facts
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   409
print_interps RA5
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   410
  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
   411
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   412
interpretation RA5 < RA5 C _ E _ A
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   413
print_facts
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   414
print_interps RA5
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   415
  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
   416
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   417
interpretation RA5 < RA5 B C A _ _
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   418
print_facts
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   419
print_interps RA5
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   420
  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
   421
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   422
lemma (in RA5) True
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   423
print_facts
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   424
print_interps RA5
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   425
  ..
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   426
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   427
interpretation RA5 < RA5 _ C D B _ .
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   428
  (* 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
   429
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   430
(* circle of three locales, forward direction *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   431
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   432
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
   433
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
   434
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
   435
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   436
interpretation RA1 < RA2
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   437
  print_facts
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   438
  using p apply fast done
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   439
interpretation RA2 < RA3
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   440
  print_facts
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   441
  using q apply fast done
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   442
interpretation RA3 < RA1
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   443
  print_facts
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   444
  using r apply fast 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
(* circle of three locales, backward direction *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   447
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   448
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
   449
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
   450
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
   451
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   452
interpretation RB1 < RB2
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   453
  print_facts
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   454
  using p apply fast done
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   455
interpretation RB3 < RB1
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   456
  print_facts
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   457
  using r apply fast done
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   458
interpretation RB2 < RB3
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   459
  print_facts
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   460
  using q apply fast done
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   461
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   462
lemma (in RB1) True
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   463
  print_facts
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
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   466
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   467
(* Group example revisited, with predicates *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   468
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   469
locale Rpsemi = var prod (infixl "**" 65) +
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   470
  assumes assoc: "(x ** y) ** z = x ** (y ** z)"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   471
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   472
locale Rplgrp = Rpsemi + var one + var inv +
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   473
  assumes lone: "one ** x = x"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   474
    and linv: "inv(x) ** x = one"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   475
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   476
lemma (in Rplgrp) lcancel:
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   477
  "x ** y = x ** z <-> y = z"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   478
proof
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   479
  assume "x ** y = x ** z"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   480
  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
   481
  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
   482
qed simp
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
locale Rprgrp = Rpsemi + var one + var inv +
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   485
  assumes rone: "x ** one = x"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   486
    and rinv: "x ** inv(x) = one"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   487
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   488
lemma (in Rprgrp) rcancel:
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   489
  "y ** x = z ** x <-> y = z"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   490
proof
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   491
  assume "y ** x = z ** x"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   492
  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
   493
    by (simp add: assoc [symmetric])
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   494
  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
   495
qed simp
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   496
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   497
interpretation Rplgrp < Rprgrp
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   498
  proof (rule Rprgrp_axioms.intro)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   499
    {
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   500
      fix x
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   501
      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
   502
      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
   503
    }
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   504
    note rone = this
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   505
    {
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   506
      fix x
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   507
      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
   508
	by (simp add: linv lone rone)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   509
      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
   510
    }
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   511
  qed
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
(* effect on printed locale *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   514
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   515
print_locale Rplgrp
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
(* use of derived theorem *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   518
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   519
(* doesn't work yet
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   520
lemma (in Rplgrp)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   521
  "y ** x = z ** x <-> y = z"
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   522
  apply (rule rcancel)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   523
  print_interps Rprgrp thm lcancel rcancel
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   524
  done
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
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   527
(* circular interpretation *)
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
interpretation Rprgrp < Rplgrp
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   530
  proof (rule Rplgrp_axioms.intro)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   531
    {
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   532
      fix x
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   533
      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
   534
      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
   535
    }
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   536
    note lone = this
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   537
    {
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   538
      fix x
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   539
      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
   540
	by (simp add: rinv lone rone)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   541
      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
   542
    }
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   543
  qed
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   544
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   545
(* effect on printed locale *)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   546
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   547
print_locale Rprgrp
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   548
print_locale Rplgrp
16736
1e792b32abef Preparations for interpretation of locales in locales.
ballarin
parents: 16620
diff changeset
   549
15596
8665d08085df First version of global registration command.
ballarin
parents:
diff changeset
   550
end
17000
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   551
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   552
(* Known problems:
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   553
- var vs. fixes in locale to be interpreted (interpretation command)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   554
  (possibly caused by early registrations)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   555
- registrations too early -> proper after qed
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   556
- predicate generation in group example, thms have wrong hyps
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   557
- reprocess registrations in theory (after qed)
552df70f52c2 First version of interpretation in locales. Not yet fully functional.
ballarin
parents: 16736
diff changeset
   558
*)