src/HOL/Library/Combine_PER.thy
author haftmann
Mon, 04 Jul 2016 19:46:20 +0200
changeset 63377 64adf4ba9526
child 63415 8f91c2f447a0
permissions -rw-r--r--
combinator to build partial equivalence relations from a predicate and an equivalenc relation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
63377
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
     1
(* Author: Florian Haftmann, TU Muenchen *)
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
     2
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
     3
section \<open>A combinator to build partial equivalence relations from a predicate and an equivalence relation\<close>
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
     4
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
     5
theory Combine_PER
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
     6
imports Main "~~/src/HOL/Library/Lattice_Syntax"
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
     7
begin
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
     8
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
     9
definition combine_per :: "('a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool"
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    10
where
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    11
  "combine_per P R = (\<lambda>x y. P x \<and> P y) \<sqinter> R"
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    12
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    13
lemma combine_per_simp [simp]:
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    14
  fixes R (infixl "\<approx>" 50)
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    15
  shows "combine_per P R x y \<longleftrightarrow> P x \<and> P y \<and> x \<approx> y"
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    16
  by (simp add: combine_per_def)
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    17
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    18
lemma combine_per_top [simp]:
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    19
  "combine_per \<top> R = R"
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    20
  by (simp add: fun_eq_iff)
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    21
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    22
lemma combine_per_eq [simp]:
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    23
  "combine_per P HOL.eq = HOL.eq \<sqinter> (\<lambda>x y. P x)"
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    24
  by (auto simp add: fun_eq_iff)
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    25
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    26
lemma symp_combine_per:
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    27
  "symp R \<Longrightarrow> symp (combine_per P R)"
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    28
  by (auto simp add: symp_def sym_def combine_per_def)
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    29
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    30
lemma transp_combine_per:
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    31
  "transp R \<Longrightarrow> transp (combine_per P R)"
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    32
  by (auto simp add: transp_def trans_def combine_per_def)
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    33
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    34
lemma combine_perI:
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    35
  fixes R (infixl "\<approx>" 50)
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    36
  shows "P x \<Longrightarrow> P y \<Longrightarrow> x \<approx> y \<Longrightarrow> combine_per P R x y"
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    37
  by (simp add: combine_per_def)
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    38
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    39
lemma symp_combine_per_symp:
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    40
  "symp R \<Longrightarrow> symp (combine_per P R)"
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    41
  by (auto intro!: sympI elim: sympE)
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    42
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    43
lemma transp_combine_per_transp:
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    44
  "transp R \<Longrightarrow> transp (combine_per P R)"
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    45
  by (auto intro!: transpI elim: transpE)
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    46
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    47
lemma equivp_combine_per_part_equivp:
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    48
  fixes R (infixl "\<approx>" 50)
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    49
  assumes "\<exists>x. P x" and "equivp R"
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    50
  shows "part_equivp (combine_per P R)"
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    51
proof -
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    52
  from \<open>\<exists>x. P x\<close> obtain x where "P x" ..
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    53
  moreover from \<open>equivp R\<close> have "x \<approx> x" by (rule equivp_reflp)
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    54
  ultimately have "\<exists>x. P x \<and> x \<approx> x" by blast
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    55
  with \<open>equivp R\<close> show ?thesis
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    56
    by (auto intro!: part_equivpI symp_combine_per_symp transp_combine_per_transp
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    57
      elim: equivpE)
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    58
qed
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    59
64adf4ba9526 combinator to build partial equivalence relations from a predicate and an equivalenc relation
haftmann
parents:
diff changeset
    60
end