src/HOL/ex/Specifications_with_bundle_mixins.thy
author wenzelm
Mon, 11 Sep 2023 19:30:48 +0200
changeset 78659 b5f3d1051b13
parent 73622 4dc3baf45d6a
child 80723 ac6a69b0f634
permissions -rw-r--r--
tuned;
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
73622
4dc3baf45d6a more appropriate location
haftmann
parents: 72739
diff changeset
     2
  imports "HOL-Combinatorics.Perm"
72536
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
72739
e7c2848b78e8 refined syntax for bundle mixins for locale and class specifications
haftmann
parents: 72536
diff changeset
     5
locale involutory = opening permutation_syntax +
72536
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
     6
  fixes f :: \<open>'a perm\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
     7
  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
     8
begin
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
     9
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    10
lemma
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    11
  \<open>f * f = 1\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    12
  using involutory
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    13
  by (simp add: perm_eq_iff apply_sequence)
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    14
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    15
end
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    16
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    17
context involutory
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    18
begin
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    19
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    20
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
    21
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    22
end
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    23
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    24
72739
e7c2848b78e8 refined syntax for bundle mixins for locale and class specifications
haftmann
parents: 72536
diff changeset
    25
class at_most_two_elems = opening permutation_syntax +
72536
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    26
  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
    27
begin
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    28
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    29
lemma
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    30
  \<open>card (UNIV :: 'a set) \<le> 2\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    31
proof (rule ccontr)
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    32
  fix a :: 'a
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    33
  assume \<open>\<not> card (UNIV :: 'a set) \<le> 2\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    34
  then have c0: \<open>card (UNIV :: 'a set) \<ge> 3\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    35
    by simp
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    36
  then have [simp]: \<open>finite (UNIV :: 'a set)\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    37
    using card.infinite by fastforce
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    38
  from c0 card_Diff1_le [of UNIV a]
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    39
  have ca: \<open>card (UNIV - {a}) \<ge> 2\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    40
    by simp
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    41
  then obtain b where \<open>b \<in> (UNIV - {a})\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    42
    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
    43
  with ca card_Diff1_le [of \<open>UNIV - {a}\<close> b]
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    44
  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
    45
    by simp_all
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    46
  then obtain c where \<open>c \<in> (UNIV - {a, b})\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    47
    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
    48
  then have \<open>a \<noteq> c\<close> \<open>b \<noteq> c\<close>
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    49
    by auto
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    50
  with swap_distinct [of a b c] show False
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    51
    by (simp add: \<open>a \<noteq> b\<close>) 
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    52
qed
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    53
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    54
end
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
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
    57
589645894305 bundle mixins for locale and class specifications
haftmann
parents:
diff changeset
    58
end