src/HOL/Library/Disjoint_FSets.thy
author desharna
Mon, 13 Jun 2022 20:02:00 +0200
changeset 75560 aeb797356de0
parent 73477 1d8a79aa2a99
permissions -rw-r--r--
added lemmas image_mset_eq_{image_mset_plus,plus,plus_image_mset}D, and multp_image_mset_image_msetD
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
73477
1d8a79aa2a99 dedicated session for combinatorial material
haftmann
parents: 73326
diff changeset
     1
(*  Author:     Lars Hupel, TU München
73326
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
     2
*)
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
     3
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
     4
section \<open>Disjoint FSets\<close>
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
     5
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
     6
theory Disjoint_FSets
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
     7
  imports
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
     8
    "HOL-Library.Finite_Map"
73477
1d8a79aa2a99 dedicated session for combinatorial material
haftmann
parents: 73326
diff changeset
     9
    Disjoint_Sets
73326
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    10
begin
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    11
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    12
context
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    13
  includes fset.lifting
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    14
begin
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    15
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    16
lift_definition fdisjnt :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" is disjnt .
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    17
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    18
lemma fdisjnt_alt_def: "fdisjnt M N \<longleftrightarrow> (M |\<inter>| N = {||})"
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    19
by transfer (simp add: disjnt_def)
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    20
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    21
lemma fdisjnt_insert: "x |\<notin>| N \<Longrightarrow> fdisjnt M N \<Longrightarrow> fdisjnt (finsert x M) N"
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    22
by transfer' (rule disjnt_insert)
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    23
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    24
lemma fdisjnt_subset_right: "N' |\<subseteq>| N \<Longrightarrow> fdisjnt M N \<Longrightarrow> fdisjnt M N'"
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    25
unfolding fdisjnt_alt_def by auto
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    26
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    27
lemma fdisjnt_subset_left: "N' |\<subseteq>| N \<Longrightarrow> fdisjnt N M \<Longrightarrow> fdisjnt N' M"
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    28
unfolding fdisjnt_alt_def by auto
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    29
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    30
lemma fdisjnt_union_right: "fdisjnt M A \<Longrightarrow> fdisjnt M B \<Longrightarrow> fdisjnt M (A |\<union>| B)"
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    31
unfolding fdisjnt_alt_def by auto
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    32
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    33
lemma fdisjnt_union_left: "fdisjnt A M \<Longrightarrow> fdisjnt B M \<Longrightarrow> fdisjnt (A |\<union>| B) M"
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    34
unfolding fdisjnt_alt_def by auto
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    35
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    36
lemma fdisjnt_swap: "fdisjnt M N \<Longrightarrow> fdisjnt N M"
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    37
including fset.lifting by transfer' (auto simp: disjnt_def)
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    38
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    39
lemma distinct_append_fset:
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    40
  assumes "distinct xs" "distinct ys" "fdisjnt (fset_of_list xs) (fset_of_list ys)"
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    41
  shows "distinct (xs @ ys)"
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    42
using assms
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    43
by transfer' (simp add: disjnt_def)
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    44
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    45
lemma fdisjnt_contrI:
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    46
  assumes "\<And>x. x |\<in>| M \<Longrightarrow> x |\<in>| N \<Longrightarrow> False"
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    47
  shows "fdisjnt M N"
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    48
using assms
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    49
by transfer' (auto simp: disjnt_def)
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    50
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    51
lemma fdisjnt_Union_left: "fdisjnt (ffUnion S) T \<longleftrightarrow> fBall S (\<lambda>S. fdisjnt S T)"
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    52
by transfer' (auto simp: disjnt_def)
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    53
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    54
lemma fdisjnt_Union_right: "fdisjnt T (ffUnion S) \<longleftrightarrow> fBall S (\<lambda>S. fdisjnt T S)"
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    55
by transfer' (auto simp: disjnt_def)
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    56
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    57
lemma fdisjnt_ge_max: "fBall X (\<lambda>x. x > fMax Y) \<Longrightarrow> fdisjnt X Y"
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    58
by transfer (auto intro: disjnt_ge_max)
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    59
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    60
end
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    61
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    62
(* FIXME should be provable without lifting *)
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    63
lemma fmadd_disjnt: "fdisjnt (fmdom m) (fmdom n) \<Longrightarrow> m ++\<^sub>f n = n ++\<^sub>f m"
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    64
unfolding fdisjnt_alt_def
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    65
including fset.lifting fmap.lifting
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    66
apply transfer
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    67
apply (rule ext)
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    68
apply (auto simp: map_add_def split: option.splits)
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    69
done
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    70
7a88313895d5 dissolve theory with duplicated name from afp
haftmann
parents:
diff changeset
    71
end