src/HOL/ex/Specifications_with_bundle_mixins.thy
author wenzelm
Tue, 10 Nov 2020 12:48:56 +0100
changeset 72571 ab4a0b19648a
parent 72536 589645894305
child 72739 e7c2848b78e8
permissions -rw-r--r--
tuned signature;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
72536
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
     1
theory Specifications_with_bundle_mixins
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
     2
  imports "HOL-Library.Perm"
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
     3
begin
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
     4
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
     5
locale involutory =
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
     6
  includes permutation_syntax
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
     7
  fixes f :: \<open>'a perm\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
     8
  assumes involutory: \<open>\<And>x. f \<langle>$\<rangle> (f \<langle>$\<rangle> x) = x\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
     9
begin
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    10
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    11
lemma
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    12
  \<open>f * f = 1\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    13
  using involutory
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    14
  by (simp add: perm_eq_iff apply_sequence)
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    15
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    16
end
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    17
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    18
context involutory
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    19
begin
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    20
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    21
thm involutory (*syntax from permutation_syntax only present in locale specification and initial block*)
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    22
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    23
end
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    24
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    25
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    26
class at_most_two_elems =
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    27
  includes permutation_syntax
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    28
  assumes swap_distinct: \<open>a \<noteq> b \<Longrightarrow> \<langle>a \<leftrightarrow> b\<rangle> \<langle>$\<rangle> c \<noteq> c\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    29
begin
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    30
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    31
lemma
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    32
  \<open>card (UNIV :: 'a set) \<le> 2\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    33
proof (rule ccontr)
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    34
  fix a :: 'a
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    35
  assume \<open>\<not> card (UNIV :: 'a set) \<le> 2\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    36
  then have c0: \<open>card (UNIV :: 'a set) \<ge> 3\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    37
    by simp
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    38
  then have [simp]: \<open>finite (UNIV :: 'a set)\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    39
    using card.infinite by fastforce
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    40
  from c0 card_Diff1_le [of UNIV a]
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    41
  have ca: \<open>card (UNIV - {a}) \<ge> 2\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    42
    by simp
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    43
  then obtain b where \<open>b \<in> (UNIV - {a})\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    44
    by (metis all_not_in_conv card.empty card_2_iff' le_zero_eq)
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    45
  with ca card_Diff1_le [of \<open>UNIV - {a}\<close> b]
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    46
  have cb: \<open>card (UNIV - {a, b}) \<ge> 1\<close> and \<open>a \<noteq> b\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    47
    by simp_all
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    48
  then obtain c where \<open>c \<in> (UNIV - {a, b})\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    49
    by (metis One_nat_def all_not_in_conv card.empty le_zero_eq nat.simps(3))
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    50
  then have \<open>a \<noteq> c\<close> \<open>b \<noteq> c\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    51
    by auto
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    52
  with swap_distinct [of a b c] show False
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    53
    by (simp add: \<open>a \<noteq> b\<close>) 
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    54
qed
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    55
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    56
end
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    57
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    58
thm swap_distinct (*syntax from permutation_syntax only present in class specification and initial block*)
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    59
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    60
end