src/HOL/Library/Quotient_Sum.thy
author kuncar
Mon, 13 May 2013 13:59:04 +0200
changeset 51956 a4d81cdebf8b
parent 51377 7da251a6c16e
child 51994 82cc2aeb7d13
permissions -rw-r--r--
better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47455
26315a545e26 updated headers;
wenzelm
parents: 47308
diff changeset
     1
(*  Title:      HOL/Library/Quotient_Sum.thy
47624
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
     2
    Author:     Cezary Kaliszyk, Christian Urban and Brian Huffman
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     3
*)
35788
f1deaca15ca3 observe standard header format;
wenzelm
parents: 35243
diff changeset
     4
f1deaca15ca3 observe standard header format;
wenzelm
parents: 35243
diff changeset
     5
header {* Quotient infrastructure for the sum type *}
f1deaca15ca3 observe standard header format;
wenzelm
parents: 35243
diff changeset
     6
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
theory Quotient_Sum
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
imports Main Quotient_Syntax
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
begin
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
47624
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
    11
subsection {* Relator for sum type *}
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
    12
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
fun
40542
9a173a22771c re-generalized type of option_rel and sum_rel (accident from 2989f9f3aa10)
haftmann
parents: 40465
diff changeset
    14
  sum_rel :: "('a \<Rightarrow> 'c \<Rightarrow> bool) \<Rightarrow> ('b \<Rightarrow> 'd \<Rightarrow> bool) \<Rightarrow> 'a + 'b \<Rightarrow> 'c + 'd \<Rightarrow> bool"
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    15
where
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
  "sum_rel R1 R2 (Inl a1) (Inl b1) = R1 a1 b1"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
| "sum_rel R1 R2 (Inl a1) (Inr b2) = False"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
| "sum_rel R1 R2 (Inr a2) (Inl b1) = False"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
| "sum_rel R1 R2 (Inr a2) (Inr b2) = R2 a2 b2"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
40820
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    21
lemma sum_rel_unfold:
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    22
  "sum_rel R1 R2 x y = (case (x, y) of (Inl x, Inl y) \<Rightarrow> R1 x y
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    23
    | (Inr x, Inr y) \<Rightarrow> R2 x y
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    24
    | _ \<Rightarrow> False)"
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    25
  by (cases x) (cases y, simp_all)+
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
51956
a4d81cdebf8b better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
kuncar
parents: 51377
diff changeset
    27
fun sum_pred :: "('a \<Rightarrow> bool) \<Rightarrow> ('b \<Rightarrow> bool) \<Rightarrow> 'a + 'b \<Rightarrow> bool"
a4d81cdebf8b better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
kuncar
parents: 51377
diff changeset
    28
where
a4d81cdebf8b better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
kuncar
parents: 51377
diff changeset
    29
  "sum_pred P1 P2 (Inl a) = P1 a"
a4d81cdebf8b better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
kuncar
parents: 51377
diff changeset
    30
| "sum_pred P1 P2 (Inr a) = P2 a"
a4d81cdebf8b better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
kuncar
parents: 51377
diff changeset
    31
a4d81cdebf8b better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
kuncar
parents: 51377
diff changeset
    32
lemma sum_pred_unfold:
a4d81cdebf8b better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
kuncar
parents: 51377
diff changeset
    33
  "sum_pred P1 P2 x = (case x of Inl x \<Rightarrow> P1 x
a4d81cdebf8b better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
kuncar
parents: 51377
diff changeset
    34
    | Inr x \<Rightarrow> P2 x)"
a4d81cdebf8b better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
kuncar
parents: 51377
diff changeset
    35
by (cases x) simp_all
a4d81cdebf8b better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
kuncar
parents: 51377
diff changeset
    36
40820
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    37
lemma sum_rel_map1:
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    38
  "sum_rel R1 R2 (sum_map f1 f2 x) y \<longleftrightarrow> sum_rel (\<lambda>x. R1 (f1 x)) (\<lambda>x. R2 (f2 x)) x y"
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    39
  by (simp add: sum_rel_unfold split: sum.split)
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    40
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    41
lemma sum_rel_map2:
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    42
  "sum_rel R1 R2 x (sum_map f1 f2 y) \<longleftrightarrow> sum_rel (\<lambda>x y. R1 x (f1 y)) (\<lambda>x y. R2 x (f2 y)) x y"
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    43
  by (simp add: sum_rel_unfold split: sum.split)
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    44
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    45
lemma sum_map_id [id_simps]:
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    46
  "sum_map id id = id"
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    47
  by (simp add: id_def sum_map.identity fun_eq_iff)
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    48
47624
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
    49
lemma sum_rel_eq [id_simps, relator_eq]:
40820
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    50
  "sum_rel (op =) (op =) = (op =)"
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    51
  by (simp add: sum_rel_unfold fun_eq_iff split: sum.split)
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    52
47624
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
    53
lemma split_sum_all: "(\<forall>x. P x) \<longleftrightarrow> (\<forall>x. P (Inl x)) \<and> (\<forall>x. P (Inr x))"
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
    54
  by (metis sum.exhaust) (* TODO: move to Sum_Type.thy *)
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
    55
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
    56
lemma split_sum_ex: "(\<exists>x. P x) \<longleftrightarrow> (\<exists>x. P (Inl x)) \<or> (\<exists>x. P (Inr x))"
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
    57
  by (metis sum.exhaust) (* TODO: move to Sum_Type.thy *)
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
    58
51377
7da251a6c16e add [relator_mono] and [relator_distr] rules
kuncar
parents: 47982
diff changeset
    59
lemma sum_rel_mono[relator_mono]:
7da251a6c16e add [relator_mono] and [relator_distr] rules
kuncar
parents: 47982
diff changeset
    60
  assumes "A \<le> C"
7da251a6c16e add [relator_mono] and [relator_distr] rules
kuncar
parents: 47982
diff changeset
    61
  assumes "B \<le> D"
7da251a6c16e add [relator_mono] and [relator_distr] rules
kuncar
parents: 47982
diff changeset
    62
  shows "(sum_rel A B) \<le> (sum_rel C D)"
7da251a6c16e add [relator_mono] and [relator_distr] rules
kuncar
parents: 47982
diff changeset
    63
using assms by (auto simp: sum_rel_unfold split: sum.splits)
7da251a6c16e add [relator_mono] and [relator_distr] rules
kuncar
parents: 47982
diff changeset
    64
7da251a6c16e add [relator_mono] and [relator_distr] rules
kuncar
parents: 47982
diff changeset
    65
lemma sum_rel_OO[relator_distr]:
7da251a6c16e add [relator_mono] and [relator_distr] rules
kuncar
parents: 47982
diff changeset
    66
  "(sum_rel A B) OO (sum_rel C D) = sum_rel (A OO C) (B OO D)"
7da251a6c16e add [relator_mono] and [relator_distr] rules
kuncar
parents: 47982
diff changeset
    67
by (rule ext)+ (auto simp add: sum_rel_unfold OO_def split_sum_ex split: sum.split)
7da251a6c16e add [relator_mono] and [relator_distr] rules
kuncar
parents: 47982
diff changeset
    68
51956
a4d81cdebf8b better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
kuncar
parents: 51377
diff changeset
    69
lemma Domainp_sum[relator_domain]:
a4d81cdebf8b better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
kuncar
parents: 51377
diff changeset
    70
  assumes "Domainp R1 = P1"
a4d81cdebf8b better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
kuncar
parents: 51377
diff changeset
    71
  assumes "Domainp R2 = P2"
a4d81cdebf8b better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
kuncar
parents: 51377
diff changeset
    72
  shows "Domainp (sum_rel R1 R2) = (sum_pred P1 P2)"
a4d81cdebf8b better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
kuncar
parents: 51377
diff changeset
    73
using assms
a4d81cdebf8b better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
kuncar
parents: 51377
diff changeset
    74
by (auto simp add: Domainp_iff split_sum_ex sum_pred_unfold iff: fun_eq_iff split: sum.split)
a4d81cdebf8b better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
kuncar
parents: 51377
diff changeset
    75
47982
7aa35601ff65 prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents: 47936
diff changeset
    76
lemma sum_reflp[reflexivity_rule]:
40820
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    77
  "reflp R1 \<Longrightarrow> reflp R2 \<Longrightarrow> reflp (sum_rel R1 R2)"
47624
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
    78
  unfolding reflp_def split_sum_all sum_rel.simps by fast
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    79
47982
7aa35601ff65 prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents: 47936
diff changeset
    80
lemma sum_left_total[reflexivity_rule]:
7aa35601ff65 prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents: 47936
diff changeset
    81
  "left_total R1 \<Longrightarrow> left_total R2 \<Longrightarrow> left_total (sum_rel R1 R2)"
7aa35601ff65 prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents: 47936
diff changeset
    82
  apply (intro left_totalI)
7aa35601ff65 prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents: 47936
diff changeset
    83
  unfolding split_sum_ex 
7aa35601ff65 prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents: 47936
diff changeset
    84
  by (case_tac x) (auto elim: left_totalE)
7aa35601ff65 prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents: 47936
diff changeset
    85
40820
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    86
lemma sum_symp:
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    87
  "symp R1 \<Longrightarrow> symp R2 \<Longrightarrow> symp (sum_rel R1 R2)"
47624
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
    88
  unfolding symp_def split_sum_all sum_rel.simps by fast
40820
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    89
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    90
lemma sum_transp:
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    91
  "transp R1 \<Longrightarrow> transp R2 \<Longrightarrow> transp (sum_rel R1 R2)"
47624
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
    92
  unfolding transp_def split_sum_all sum_rel.simps by fast
40820
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    93
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    94
lemma sum_equivp [quot_equiv]:
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    95
  "equivp R1 \<Longrightarrow> equivp R2 \<Longrightarrow> equivp (sum_rel R1 R2)"
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
    96
  by (blast intro: equivpI sum_reflp sum_symp sum_transp elim: equivpE)
47624
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
    97
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
    98
lemma right_total_sum_rel [transfer_rule]:
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
    99
  "right_total R1 \<Longrightarrow> right_total R2 \<Longrightarrow> right_total (sum_rel R1 R2)"
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   100
  unfolding right_total_def split_sum_all split_sum_ex by simp
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   101
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   102
lemma right_unique_sum_rel [transfer_rule]:
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   103
  "right_unique R1 \<Longrightarrow> right_unique R2 \<Longrightarrow> right_unique (sum_rel R1 R2)"
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   104
  unfolding right_unique_def split_sum_all by simp
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   105
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   106
lemma bi_total_sum_rel [transfer_rule]:
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   107
  "bi_total R1 \<Longrightarrow> bi_total R2 \<Longrightarrow> bi_total (sum_rel R1 R2)"
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   108
  using assms unfolding bi_total_def split_sum_all split_sum_ex by simp
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   109
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   110
lemma bi_unique_sum_rel [transfer_rule]:
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   111
  "bi_unique R1 \<Longrightarrow> bi_unique R2 \<Longrightarrow> bi_unique (sum_rel R1 R2)"
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   112
  using assms unfolding bi_unique_def split_sum_all by simp
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   113
47635
ebb79474262c rename 'correspondence' method to 'transfer_prover'
huffman
parents: 47634
diff changeset
   114
subsection {* Transfer rules for transfer package *}
47624
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   115
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   116
lemma Inl_transfer [transfer_rule]: "(A ===> sum_rel A B) Inl Inl"
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   117
  unfolding fun_rel_def by simp
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   118
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   119
lemma Inr_transfer [transfer_rule]: "(B ===> sum_rel A B) Inr Inr"
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   120
  unfolding fun_rel_def by simp
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   121
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   122
lemma sum_case_transfer [transfer_rule]:
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   123
  "((A ===> C) ===> (B ===> C) ===> sum_rel A B ===> C) sum_case sum_case"
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   124
  unfolding fun_rel_def sum_rel_unfold by (simp split: sum.split)
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   125
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   126
subsection {* Setup for lifting package *}
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   127
47777
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47635
diff changeset
   128
lemma Quotient_sum[quot_map]:
47624
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   129
  assumes "Quotient R1 Abs1 Rep1 T1"
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   130
  assumes "Quotient R2 Abs2 Rep2 T2"
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   131
  shows "Quotient (sum_rel R1 R2) (sum_map Abs1 Abs2)
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   132
    (sum_map Rep1 Rep2) (sum_rel T1 T2)"
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   133
  using assms unfolding Quotient_alt_def
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   134
  by (simp add: split_sum_all)
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   135
47634
091bcd569441 hide the invariant constant for relators: invariant_commute infrastracture
kuncar
parents: 47624
diff changeset
   136
lemma sum_invariant_commute [invariant_commute]: 
091bcd569441 hide the invariant constant for relators: invariant_commute infrastracture
kuncar
parents: 47624
diff changeset
   137
  "sum_rel (Lifting.invariant P1) (Lifting.invariant P2) = Lifting.invariant (sum_pred P1 P2)"
51956
a4d81cdebf8b better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
kuncar
parents: 51377
diff changeset
   138
  by (auto simp add: fun_eq_iff Lifting.invariant_def sum_rel_unfold sum_pred_unfold split: sum.split)
47634
091bcd569441 hide the invariant constant for relators: invariant_commute infrastracture
kuncar
parents: 47624
diff changeset
   139
47624
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   140
subsection {* Rules for quotient package *}
16d433895d2e add new transfer rules and setup for lifting package
huffman
parents: 47455
diff changeset
   141
40820
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
   142
lemma sum_quotient [quot_thm]:
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47094
diff changeset
   143
  assumes q1: "Quotient3 R1 Abs1 Rep1"
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47094
diff changeset
   144
  assumes q2: "Quotient3 R2 Abs2 Rep2"
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47094
diff changeset
   145
  shows "Quotient3 (sum_rel R1 R2) (sum_map Abs1 Abs2) (sum_map Rep1 Rep2)"
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47094
diff changeset
   146
  apply (rule Quotient3I)
41372
551eb49a6e91 tuned type_lifting declarations
haftmann
parents: 40820
diff changeset
   147
  apply (simp_all add: sum_map.compositionality comp_def sum_map.identity sum_rel_eq sum_rel_map1 sum_rel_map2
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47094
diff changeset
   148
    Quotient3_abs_rep [OF q1] Quotient3_rel_rep [OF q1] Quotient3_abs_rep [OF q2] Quotient3_rel_rep [OF q2])
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47094
diff changeset
   149
  using Quotient3_rel [OF q1] Quotient3_rel [OF q2]
41372
551eb49a6e91 tuned type_lifting declarations
haftmann
parents: 40820
diff changeset
   150
  apply (simp add: sum_rel_unfold comp_def split: sum.split)
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   151
  done
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   152
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47094
diff changeset
   153
declare [[mapQ3 sum = (sum_rel, sum_quotient)]]
47094
1a7ad2601cb5 store the relational theorem for every relator
kuncar
parents: 45802
diff changeset
   154
40820
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
   155
lemma sum_Inl_rsp [quot_respect]:
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47094
diff changeset
   156
  assumes q1: "Quotient3 R1 Abs1 Rep1"
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47094
diff changeset
   157
  assumes q2: "Quotient3 R2 Abs2 Rep2"
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   158
  shows "(R1 ===> sum_rel R1 R2) Inl Inl"
40465
2989f9f3aa10 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 39302
diff changeset
   159
  by auto
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   160
40820
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
   161
lemma sum_Inr_rsp [quot_respect]:
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47094
diff changeset
   162
  assumes q1: "Quotient3 R1 Abs1 Rep1"
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47094
diff changeset
   163
  assumes q2: "Quotient3 R2 Abs2 Rep2"
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   164
  shows "(R2 ===> sum_rel R1 R2) Inr Inr"
40465
2989f9f3aa10 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 39302
diff changeset
   165
  by auto
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   166
40820
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
   167
lemma sum_Inl_prs [quot_preserve]:
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47094
diff changeset
   168
  assumes q1: "Quotient3 R1 Abs1 Rep1"
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47094
diff changeset
   169
  assumes q2: "Quotient3 R2 Abs2 Rep2"
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   170
  shows "(Rep1 ---> sum_map Abs1 Abs2) Inl = Inl"
39302
d7728f65b353 renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents: 39198
diff changeset
   171
  apply(simp add: fun_eq_iff)
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47094
diff changeset
   172
  apply(simp add: Quotient3_abs_rep[OF q1])
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   173
  done
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   174
40820
fd9c98ead9a9 more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents: 40610
diff changeset
   175
lemma sum_Inr_prs [quot_preserve]:
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47094
diff changeset
   176
  assumes q1: "Quotient3 R1 Abs1 Rep1"
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47094
diff changeset
   177
  assumes q2: "Quotient3 R2 Abs2 Rep2"
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   178
  shows "(Rep2 ---> sum_map Abs1 Abs2) Inr = Inr"
39302
d7728f65b353 renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents: 39198
diff changeset
   179
  apply(simp add: fun_eq_iff)
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47094
diff changeset
   180
  apply(simp add: Quotient3_abs_rep[OF q2])
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   181
  done
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   182
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   183
end