src/FOL/ex/NewLocaleTest.thy
author ballarin
Wed, 10 Dec 2008 14:21:42 +0100
changeset 29035 b0a0843dfd99
parent 29031 e74341997a48
child 29206 62dc8762ec00
permissions -rw-r--r--
Satisfy a_axioms.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28873
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
     1
(*  Title:      FOL/ex/NewLocaleTest.thy
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
     2
    Author:     Clemens Ballarin, TU Muenchen
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
     3
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
     4
Testing environment for locale expressions --- experimental.
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
     5
*)
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
     6
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
     7
theory NewLocaleTest
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
     8
imports NewLocaleSetup
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
     9
begin
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    10
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    11
ML_val {* set new_locales *}
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    12
ML_val {* set Toplevel.debug *}
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    13
ML_val {* set show_hyps *}
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    14
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    15
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    16
typedecl int arities int :: "term"
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    17
consts plus :: "int => int => int" (infixl "+" 60)
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    18
  zero :: int ("0")
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    19
  minus :: "int => int" ("- _")
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    20
28993
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
    21
axioms
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
    22
  int_assoc: "(x + y::int) + z = x + (y + z)"
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
    23
  int_zero: "0 + x = x"
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
    24
  int_minus: "(-x) + x = 0"
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
    25
  int_minus2: "-(-x) = x"
28873
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    26
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    27
text {* Inference of parameter types *}
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    28
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    29
locale param1 = fixes p
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    30
print_locale! param1
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    31
28881
df2525ad10c6 Some regression tests for theorem statements.
ballarin
parents: 28873
diff changeset
    32
locale param2 = fixes p :: 'b
28873
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    33
print_locale! param2
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    34
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    35
(*
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    36
locale param_top = param2 r for r :: "'b :: {}"
28993
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
    37
  Fails, cannot generalise parameter.
28873
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    38
*)
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    39
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    40
locale param3 = fixes p (infix ".." 50)
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    41
print_locale! param3
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    42
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    43
locale param4 = fixes p :: "'a => 'a => 'a" (infix ".." 50)
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    44
print_locale! param4
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    45
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    46
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    47
text {* Incremental type constraints *}
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    48
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    49
locale constraint1 =
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    50
  fixes  prod (infixl "**" 65)
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    51
  assumes l_id: "x ** y = x"
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    52
  assumes assoc: "(x ** y) ** z = x ** (y ** z)"
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    53
print_locale! constraint1
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    54
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    55
locale constraint2 =
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    56
  fixes p and q
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    57
  assumes "p = q"
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    58
print_locale! constraint2
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    59
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    60
28881
df2525ad10c6 Some regression tests for theorem statements.
ballarin
parents: 28873
diff changeset
    61
text {* Inheritance *}
28873
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    62
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    63
locale semi =
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    64
  fixes prod (infixl "**" 65)
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    65
  assumes assoc: "(x ** y) ** z = x ** (y ** z)"
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    66
print_locale! semi thm semi_def
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    67
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    68
locale lgrp = semi +
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    69
  fixes one and inv
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    70
  assumes lone: "one ** x = x"
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    71
    and linv: "inv(x) ** x = one"
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    72
print_locale! lgrp thm lgrp_def lgrp_axioms_def
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    73
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    74
locale add_lgrp = semi "op ++" for sum (infixl "++" 60) +
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    75
  fixes zero and neg
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    76
  assumes lzero: "zero ++ x = x"
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    77
    and lneg: "neg(x) ++ x = zero"
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    78
print_locale! add_lgrp thm add_lgrp_def add_lgrp_axioms_def
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    79
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    80
locale rev_lgrp = semi "%x y. y ++ x" for sum (infixl "++" 60)
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    81
print_locale! rev_lgrp thm rev_lgrp_def
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    82
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    83
locale hom = f: semi f + g: semi g for f and g
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    84
print_locale! hom thm hom_def
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    85
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    86
locale perturbation = semi + d: semi "%x y. delta(x) ** delta(y)" for delta
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    87
print_locale! perturbation thm perturbation_def
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    88
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    89
locale pert_hom = d1: perturbation f d1 + d2: perturbation f d2 for f d1 d2
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    90
print_locale! pert_hom thm pert_hom_def
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    91
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    92
text {* Alternative expression, obtaining nicer names in @{text "semi f"}. *}
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    93
locale pert_hom' = semi f + d1: perturbation f d1 + d2: perturbation f d2 for f d1 d2
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    94
print_locale! pert_hom' thm pert_hom'_def
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    95
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    96
28881
df2525ad10c6 Some regression tests for theorem statements.
ballarin
parents: 28873
diff changeset
    97
text {* Syntax declarations *}
28873
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    98
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
    99
locale logic =
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   100
  fixes land (infixl "&&" 55)
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   101
    and lnot ("-- _" [60] 60)
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   102
  assumes assoc: "(x && y) && z = x && (y && z)"
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   103
    and notnot: "-- (-- x) = x"
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   104
begin
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   105
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   106
definition lor (infixl "||" 50) where
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   107
  "x || y = --(-- x && -- y)"
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   108
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   109
end
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   110
print_locale! logic
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   111
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   112
locale use_decl = logic + semi "op ||"
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   113
print_locale! use_decl thm use_decl_def
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   114
28881
df2525ad10c6 Some regression tests for theorem statements.
ballarin
parents: 28873
diff changeset
   115
29028
b5dad96c755a When adding locales, delay notes until local theory is built.
ballarin
parents: 29022
diff changeset
   116
text {* Foundational versions of theorems *}
b5dad96c755a When adding locales, delay notes until local theory is built.
ballarin
parents: 29022
diff changeset
   117
b5dad96c755a When adding locales, delay notes until local theory is built.
ballarin
parents: 29022
diff changeset
   118
thm logic.assoc
b5dad96c755a When adding locales, delay notes until local theory is built.
ballarin
parents: 29022
diff changeset
   119
thm logic.lor_def
b5dad96c755a When adding locales, delay notes until local theory is built.
ballarin
parents: 29022
diff changeset
   120
b5dad96c755a When adding locales, delay notes until local theory is built.
ballarin
parents: 29022
diff changeset
   121
29019
8e7d6f959bd7 Explicitly close up defines.
ballarin
parents: 29018
diff changeset
   122
text {* Defines *}
8e7d6f959bd7 Explicitly close up defines.
ballarin
parents: 29018
diff changeset
   123
8e7d6f959bd7 Explicitly close up defines.
ballarin
parents: 29018
diff changeset
   124
locale logic_def =
8e7d6f959bd7 Explicitly close up defines.
ballarin
parents: 29018
diff changeset
   125
  fixes land (infixl "&&" 55)
8e7d6f959bd7 Explicitly close up defines.
ballarin
parents: 29018
diff changeset
   126
    and lor (infixl "||" 50)
8e7d6f959bd7 Explicitly close up defines.
ballarin
parents: 29018
diff changeset
   127
    and lnot ("-- _" [60] 60)
8e7d6f959bd7 Explicitly close up defines.
ballarin
parents: 29018
diff changeset
   128
  assumes assoc: "(x && y) && z = x && (y && z)"
8e7d6f959bd7 Explicitly close up defines.
ballarin
parents: 29018
diff changeset
   129
    and notnot: "-- (-- x) = x"
29022
54d3a31ca0f6 Default names for definitions.
ballarin
parents: 29021
diff changeset
   130
  defines "x || y == --(-- x && -- y)"
29021
ce100fbc3c8e Proper shape of assumptions generated from Defines elements.
ballarin
parents: 29019
diff changeset
   131
begin
29019
8e7d6f959bd7 Explicitly close up defines.
ballarin
parents: 29018
diff changeset
   132
29031
e74341997a48 Pass on defines in inheritance; reject illicit defines created by instantiation.
ballarin
parents: 29028
diff changeset
   133
thm lor_def
e74341997a48 Pass on defines in inheritance; reject illicit defines created by instantiation.
ballarin
parents: 29028
diff changeset
   134
(* Can we get rid the the additional hypothesis, caused by LocalTheory.notes? *)
e74341997a48 Pass on defines in inheritance; reject illicit defines created by instantiation.
ballarin
parents: 29028
diff changeset
   135
29021
ce100fbc3c8e Proper shape of assumptions generated from Defines elements.
ballarin
parents: 29019
diff changeset
   136
lemma "x || y = --(-- x && --y)"
ce100fbc3c8e Proper shape of assumptions generated from Defines elements.
ballarin
parents: 29019
diff changeset
   137
  by (unfold lor_def) (rule refl)
ce100fbc3c8e Proper shape of assumptions generated from Defines elements.
ballarin
parents: 29019
diff changeset
   138
ce100fbc3c8e Proper shape of assumptions generated from Defines elements.
ballarin
parents: 29019
diff changeset
   139
end
ce100fbc3c8e Proper shape of assumptions generated from Defines elements.
ballarin
parents: 29019
diff changeset
   140
29031
e74341997a48 Pass on defines in inheritance; reject illicit defines created by instantiation.
ballarin
parents: 29028
diff changeset
   141
(* Inheritance of defines *)
e74341997a48 Pass on defines in inheritance; reject illicit defines created by instantiation.
ballarin
parents: 29028
diff changeset
   142
e74341997a48 Pass on defines in inheritance; reject illicit defines created by instantiation.
ballarin
parents: 29028
diff changeset
   143
locale logic_def2 = logic_def
e74341997a48 Pass on defines in inheritance; reject illicit defines created by instantiation.
ballarin
parents: 29028
diff changeset
   144
begin
e74341997a48 Pass on defines in inheritance; reject illicit defines created by instantiation.
ballarin
parents: 29028
diff changeset
   145
e74341997a48 Pass on defines in inheritance; reject illicit defines created by instantiation.
ballarin
parents: 29028
diff changeset
   146
lemma "x || y = --(-- x && --y)"
e74341997a48 Pass on defines in inheritance; reject illicit defines created by instantiation.
ballarin
parents: 29028
diff changeset
   147
  by (unfold lor_def) (rule refl)
e74341997a48 Pass on defines in inheritance; reject illicit defines created by instantiation.
ballarin
parents: 29028
diff changeset
   148
e74341997a48 Pass on defines in inheritance; reject illicit defines created by instantiation.
ballarin
parents: 29028
diff changeset
   149
end
29019
8e7d6f959bd7 Explicitly close up defines.
ballarin
parents: 29018
diff changeset
   150
29035
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   151
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   152
text {* Notes *}
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   153
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   154
(* A somewhat arcane homomorphism example *)
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   155
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   156
definition semi_hom where
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   157
  "semi_hom(prod, sum, h) <-> (ALL x y. h(prod(x, y)) = sum(h(x), h(y)))"
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   158
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   159
lemma semi_hom_mult:
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   160
  "semi_hom(prod, sum, h) ==> h(prod(x, y)) = sum(h(x), h(y))"
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   161
  by (simp add: semi_hom_def)
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   162
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   163
locale semi_hom_loc = prod: semi prod + sum: semi sum
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   164
  for prod and sum and h +
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   165
  assumes semi_homh: "semi_hom(prod, sum, h)"
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   166
  notes semi_hom_mult = semi_hom_mult [OF semi_homh]
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   167
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   168
lemma (in semi_hom_loc) "h(prod(x, y)) = sum(h(x), h(y))"
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   169
  by (rule semi_hom_mult)
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   170
b0a0843dfd99 Satisfy a_axioms.
ballarin
parents: 29031
diff changeset
   171
28881
df2525ad10c6 Some regression tests for theorem statements.
ballarin
parents: 28873
diff changeset
   172
text {* Theorem statements *}
df2525ad10c6 Some regression tests for theorem statements.
ballarin
parents: 28873
diff changeset
   173
28873
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   174
lemma (in lgrp) lcancel:
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   175
  "x ** y = x ** z <-> y = z"
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   176
proof
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   177
  assume "x ** y = x ** z"
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   178
  then have "inv(x) ** x ** y = inv(x) ** x ** z" by (simp add: assoc)
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   179
  then show "y = z" by (simp add: lone linv)
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   180
qed simp
28881
df2525ad10c6 Some regression tests for theorem statements.
ballarin
parents: 28873
diff changeset
   181
print_locale! lgrp
df2525ad10c6 Some regression tests for theorem statements.
ballarin
parents: 28873
diff changeset
   182
28873
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   183
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   184
locale rgrp = semi +
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   185
  fixes one and inv
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   186
  assumes rone: "x ** one = x"
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   187
    and rinv: "x ** inv(x) = one"
28881
df2525ad10c6 Some regression tests for theorem statements.
ballarin
parents: 28873
diff changeset
   188
begin
28873
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   189
28881
df2525ad10c6 Some regression tests for theorem statements.
ballarin
parents: 28873
diff changeset
   190
lemma rcancel:
28873
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   191
  "y ** x = z ** x <-> y = z"
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   192
proof
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   193
  assume "y ** x = z ** x"
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   194
  then have "y ** (x ** inv(x)) = z ** (x ** inv(x))"
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   195
    by (simp add: assoc [symmetric])
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   196
  then show "y = z" by (simp add: rone rinv)
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   197
qed simp
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   198
2058a6b0eb20 Regression tests for new locale implementation.
ballarin
parents:
diff changeset
   199
end
28881
df2525ad10c6 Some regression tests for theorem statements.
ballarin
parents: 28873
diff changeset
   200
print_locale! rgrp
df2525ad10c6 Some regression tests for theorem statements.
ballarin
parents: 28873
diff changeset
   201
28886
9cb1297b6f13 Test for term patterns added.
ballarin
parents: 28881
diff changeset
   202
9cb1297b6f13 Test for term patterns added.
ballarin
parents: 28881
diff changeset
   203
text {* Patterns *}
9cb1297b6f13 Test for term patterns added.
ballarin
parents: 28881
diff changeset
   204
9cb1297b6f13 Test for term patterns added.
ballarin
parents: 28881
diff changeset
   205
lemma (in rgrp)
9cb1297b6f13 Test for term patterns added.
ballarin
parents: 28881
diff changeset
   206
  assumes "y ** x = z ** x" (is ?a)
9cb1297b6f13 Test for term patterns added.
ballarin
parents: 28881
diff changeset
   207
  shows "y = z" (is ?t)
9cb1297b6f13 Test for term patterns added.
ballarin
parents: 28881
diff changeset
   208
proof -
9cb1297b6f13 Test for term patterns added.
ballarin
parents: 28881
diff changeset
   209
  txt {* Weird proof involving patterns from context element and conclusion. *}
9cb1297b6f13 Test for term patterns added.
ballarin
parents: 28881
diff changeset
   210
  {
9cb1297b6f13 Test for term patterns added.
ballarin
parents: 28881
diff changeset
   211
    assume ?a
9cb1297b6f13 Test for term patterns added.
ballarin
parents: 28881
diff changeset
   212
    then have "y ** (x ** inv(x)) = z ** (x ** inv(x))"
9cb1297b6f13 Test for term patterns added.
ballarin
parents: 28881
diff changeset
   213
      by (simp add: assoc [symmetric])
9cb1297b6f13 Test for term patterns added.
ballarin
parents: 28881
diff changeset
   214
    then have ?t by (simp add: rone rinv)
9cb1297b6f13 Test for term patterns added.
ballarin
parents: 28881
diff changeset
   215
  }
9cb1297b6f13 Test for term patterns added.
ballarin
parents: 28881
diff changeset
   216
  note x = this
9cb1297b6f13 Test for term patterns added.
ballarin
parents: 28881
diff changeset
   217
  show ?t by (rule x [OF `?a`])
9cb1297b6f13 Test for term patterns added.
ballarin
parents: 28881
diff changeset
   218
qed
9cb1297b6f13 Test for term patterns added.
ballarin
parents: 28881
diff changeset
   219
28896
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   220
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   221
text {* Interpretation between locales: sublocales *}
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   222
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   223
sublocale lgrp < right: rgrp
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   224
print_facts
28927
7e631979922f Methods intro_locales and unfold_locales apply to both old and new locales.
ballarin
parents: 28903
diff changeset
   225
proof unfold_locales
28896
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   226
  {
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   227
    fix x
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   228
    have "inv(x) ** x ** one = inv(x) ** x" by (simp add: linv lone)
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   229
    then show "x ** one = x" by (simp add: assoc lcancel)
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   230
  }
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   231
  note rone = this
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   232
  {
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   233
    fix x
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   234
    have "inv(x) ** x ** inv(x) = inv(x) ** one"
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   235
      by (simp add: linv lone rone)
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   236
    then show "x ** inv(x) = one" by (simp add: assoc lcancel)
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   237
  }
28903
b3fc3a62247a Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents: 28899
diff changeset
   238
qed
28896
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   239
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   240
(* effect on printed locale *)
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   241
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   242
print_locale! lgrp
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   243
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   244
(* use of derived theorem *)
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   245
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   246
lemma (in lgrp)
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   247
  "y ** x = z ** x <-> y = z"
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   248
  apply (rule rcancel)
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   249
  done
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   250
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   251
(* circular interpretation *)
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   252
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   253
sublocale rgrp < left: lgrp
28927
7e631979922f Methods intro_locales and unfold_locales apply to both old and new locales.
ballarin
parents: 28903
diff changeset
   254
proof unfold_locales
28903
b3fc3a62247a Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents: 28899
diff changeset
   255
  {
b3fc3a62247a Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents: 28899
diff changeset
   256
    fix x
b3fc3a62247a Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents: 28899
diff changeset
   257
    have "one ** (x ** inv(x)) = x ** inv(x)" by (simp add: rinv rone)
b3fc3a62247a Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents: 28899
diff changeset
   258
    then show "one ** x = x" by (simp add: assoc [symmetric] rcancel)
b3fc3a62247a Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents: 28899
diff changeset
   259
  }
b3fc3a62247a Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents: 28899
diff changeset
   260
  note lone = this
b3fc3a62247a Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents: 28899
diff changeset
   261
  {
b3fc3a62247a Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents: 28899
diff changeset
   262
    fix x
b3fc3a62247a Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents: 28899
diff changeset
   263
    have "inv(x) ** (x ** inv(x)) = one ** inv(x)"
b3fc3a62247a Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents: 28899
diff changeset
   264
      by (simp add: rinv lone rone)
b3fc3a62247a Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents: 28899
diff changeset
   265
    then show "inv(x) ** x = one" by (simp add: assoc [symmetric] rcancel)
b3fc3a62247a Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents: 28899
diff changeset
   266
  }
b3fc3a62247a Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents: 28899
diff changeset
   267
qed
28896
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   268
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   269
(* effect on printed locale *)
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   270
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   271
print_locale! rgrp
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   272
print_locale! lgrp
f30016592375 Tests for sublocale command.
ballarin
parents: 28886
diff changeset
   273
28898
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   274
28899
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   275
(* Duality *)
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   276
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   277
locale order =
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   278
  fixes less :: "'a => 'a => o" (infix "<<" 50)
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   279
  assumes refl: "x << x"
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   280
    and trans: "[| x << y; y << z |] ==> x << z"
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   281
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   282
sublocale order < dual: order "%x y. y << x"
28927
7e631979922f Methods intro_locales and unfold_locales apply to both old and new locales.
ballarin
parents: 28903
diff changeset
   283
  apply unfold_locales apply (rule refl) apply (blast intro: trans)
28899
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   284
  done
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   285
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   286
print_locale! order  (* Only two instances of order. *)
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   287
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   288
locale order' =
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   289
  fixes less :: "'a => 'a => o" (infix "<<" 50)
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   290
  assumes refl: "x << x"
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   291
    and trans: "[| x << y; y << z |] ==> x << z"
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   292
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   293
locale order_with_def = order'
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   294
begin
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   295
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   296
definition greater :: "'a => 'a => o" (infix ">>" 50) where
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   297
  "x >> y <-> y << x"
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   298
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   299
end
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   300
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   301
sublocale order_with_def < dual: order' "op >>"
28927
7e631979922f Methods intro_locales and unfold_locales apply to both old and new locales.
ballarin
parents: 28903
diff changeset
   302
  apply unfold_locales
28899
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   303
  unfolding greater_def
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   304
  apply (rule refl) apply (blast intro: trans)
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   305
  done
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   306
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   307
print_locale! order_with_def
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   308
(* Note that decls come after theorems that make use of them.
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   309
  Appears to be harmless at least in this example. *)
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   310
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   311
28898
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   312
(* locale with many parameters ---
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   313
   interpretations generate alternating group A5 *)
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   314
28899
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   315
28898
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   316
locale A5 =
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   317
  fixes A and B and C and D and E
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   318
  assumes eq: "A <-> B <-> C <-> D <-> E"
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   319
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   320
sublocale A5 < 1: A5 _ _ D E C
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   321
print_facts
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   322
  using eq apply (blast intro: A5.intro) done
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   323
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   324
sublocale A5 < 2: A5 C _ E _ A
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   325
print_facts
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   326
  using eq apply (blast intro: A5.intro) done
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   327
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   328
sublocale A5 < 3: A5 B C A _ _
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   329
print_facts
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   330
  using eq apply (blast intro: A5.intro) done
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   331
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   332
(* Any even permutation of parameters is subsumed by the above. *)
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   333
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   334
print_locale! A5
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   335
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   336
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   337
(* Free arguments of instance *)
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   338
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   339
locale trivial =
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   340
  fixes P and Q :: o
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   341
  assumes Q: "P <-> P <-> Q"
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   342
begin
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   343
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   344
lemma Q_triv: "Q" using Q by fast
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   345
28881
df2525ad10c6 Some regression tests for theorem statements.
ballarin
parents: 28873
diff changeset
   346
end
28898
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   347
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   348
sublocale trivial < x: trivial x _
28927
7e631979922f Methods intro_locales and unfold_locales apply to both old and new locales.
ballarin
parents: 28903
diff changeset
   349
  apply unfold_locales using Q by fast
28898
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   350
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   351
print_locale! trivial
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   352
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   353
context trivial begin thm x.Q [where ?x = True] end
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   354
28899
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   355
sublocale trivial < y: trivial Q Q
28927
7e631979922f Methods intro_locales and unfold_locales apply to both old and new locales.
ballarin
parents: 28903
diff changeset
   356
  by unfold_locales
28903
b3fc3a62247a Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents: 28899
diff changeset
   357
  (* Succeeds since previous interpretation is more general. *)
28899
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   358
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   359
print_locale! trivial  (* No instance for y created (subsumed). *)
7bf5d7f154b8 Perform higher-order pattern matching during round-up.
ballarin
parents: 28898
diff changeset
   360
28993
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   361
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   362
text {* Sublocale, then interpretation in theory *}
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   363
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   364
interpretation int: lgrp "op +" "0" "minus"
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   365
proof unfold_locales
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   366
qed (rule int_assoc int_zero int_minus)+
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   367
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   368
thm int.assoc int.semi_axioms
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   369
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   370
interpretation int2: semi "op +"
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   371
  by unfold_locales  (* subsumed, thm int2.assoc not generated *)
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   372
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   373
thm int.lone int.right.rone
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   374
  (* the latter comes through the sublocale relation *)
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   375
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   376
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   377
text {* Interpretation in theory, then sublocale *}
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   378
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   379
interpretation (* fol: *) logic "op +" "minus"
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   380
(* FIXME declaration of qualified names *)
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   381
  by unfold_locales (rule int_assoc int_minus2)+
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   382
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   383
locale logic2 =
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   384
  fixes land (infixl "&&" 55)
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   385
    and lnot ("-- _" [60] 60)
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   386
  assumes assoc: "(x && y) && z = x && (y && z)"
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   387
    and notnot: "-- (-- x) = x"
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   388
begin
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   389
(* FIXME
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   390
definition lor (infixl "||" 50) where
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   391
  "x || y = --(-- x && -- y)"
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   392
*)
28898
530c7d28a962 Proper treatment of expressions with free arguments.
ballarin
parents: 28896
diff changeset
   393
end
28993
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   394
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   395
sublocale logic < two: logic2
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   396
  by unfold_locales (rule assoc notnot)+
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   397
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   398
thm two.assoc
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   399
29018
17538bdef546 Interpretation in proof contexts.
ballarin
parents: 28993
diff changeset
   400
17538bdef546 Interpretation in proof contexts.
ballarin
parents: 28993
diff changeset
   401
text {* Interpretation in proofs *}
17538bdef546 Interpretation in proof contexts.
ballarin
parents: 28993
diff changeset
   402
17538bdef546 Interpretation in proof contexts.
ballarin
parents: 28993
diff changeset
   403
lemma True
17538bdef546 Interpretation in proof contexts.
ballarin
parents: 28993
diff changeset
   404
proof
17538bdef546 Interpretation in proof contexts.
ballarin
parents: 28993
diff changeset
   405
  interpret "local": lgrp "op +" "0" "minus"
17538bdef546 Interpretation in proof contexts.
ballarin
parents: 28993
diff changeset
   406
    by unfold_locales  (* subsumed *)
17538bdef546 Interpretation in proof contexts.
ballarin
parents: 28993
diff changeset
   407
  {
17538bdef546 Interpretation in proof contexts.
ballarin
parents: 28993
diff changeset
   408
    fix zero :: int
17538bdef546 Interpretation in proof contexts.
ballarin
parents: 28993
diff changeset
   409
    assume "!!x. zero + x = x" "!!x. (-x) + x = zero"
17538bdef546 Interpretation in proof contexts.
ballarin
parents: 28993
diff changeset
   410
    then interpret local_fixed: lgrp "op +" zero "minus"
17538bdef546 Interpretation in proof contexts.
ballarin
parents: 28993
diff changeset
   411
      by unfold_locales
17538bdef546 Interpretation in proof contexts.
ballarin
parents: 28993
diff changeset
   412
    thm local_fixed.lone
17538bdef546 Interpretation in proof contexts.
ballarin
parents: 28993
diff changeset
   413
  }
17538bdef546 Interpretation in proof contexts.
ballarin
parents: 28993
diff changeset
   414
  assume "!!x zero. zero + x = x" "!!x zero. (-x) + x = zero"
17538bdef546 Interpretation in proof contexts.
ballarin
parents: 28993
diff changeset
   415
  then interpret local_free: lgrp "op +" zero "minus" for zero
17538bdef546 Interpretation in proof contexts.
ballarin
parents: 28993
diff changeset
   416
    by unfold_locales
17538bdef546 Interpretation in proof contexts.
ballarin
parents: 28993
diff changeset
   417
  thm local_free.lone [where ?zero = 0]
17538bdef546 Interpretation in proof contexts.
ballarin
parents: 28993
diff changeset
   418
qed
17538bdef546 Interpretation in proof contexts.
ballarin
parents: 28993
diff changeset
   419
28993
829e684b02ef Interpretation in theories including interaction with subclass relation.
ballarin
parents: 28936
diff changeset
   420
end