Quot/QuotSum.thy
author Christian Urban <urbanc@in.tum.de>
Tue, 26 Jan 2010 10:53:44 +0100
changeset 936 da5e4b8317c7
parent 934 0b15b83ded4a
parent 929 e812f58fd128
child 937 60dd70913b44
permissions -rw-r--r--
merged
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
934
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
     1
(*  Title:      QuotSum.thy
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
     2
    Author:     Cezary Kaliszyk and Christian Urban
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
     3
*)
698
ed44eaaea63e Option and Sum quotients.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 613
diff changeset
     4
theory QuotSum
ed44eaaea63e Option and Sum quotients.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 613
diff changeset
     5
imports QuotMain
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
begin
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
fun
545
95371a8b17e1 Cleaning the Quotients file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 538
diff changeset
     9
  sum_rel
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
where
545
95371a8b17e1 Cleaning the Quotients file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 538
diff changeset
    11
  "sum_rel R1 R2 (Inl a1) (Inl b1) = R1 a1 b1"
95371a8b17e1 Cleaning the Quotients file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 538
diff changeset
    12
| "sum_rel R1 R2 (Inl a1) (Inr b2) = False"
95371a8b17e1 Cleaning the Quotients file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 538
diff changeset
    13
| "sum_rel R1 R2 (Inr a2) (Inl b1) = False"
95371a8b17e1 Cleaning the Quotients file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 538
diff changeset
    14
| "sum_rel R1 R2 (Inr a2) (Inr b2) = R2 a2 b2"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
fun
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
  sum_map
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
where
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
  "sum_map f1 f2 (Inl a) = Inl (f1 a)"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
| "sum_map f1 f2 (Inr a) = Inr (f2 a)"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
779
3b21b24a5fb6 corrected map declarations for Sum and Prod; moved absrep_fun examples in separate file
Christian Urban <urbanc@in.tum.de>
parents: 698
diff changeset
    22
declare [[map "+" = (sum_map, sum_rel)]]
3b21b24a5fb6 corrected map declarations for Sum and Prod; moved absrep_fun examples in separate file
Christian Urban <urbanc@in.tum.de>
parents: 698
diff changeset
    23
545
95371a8b17e1 Cleaning the Quotients file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 538
diff changeset
    24
934
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    25
text {* should probably be in Sum_Type.thy *}
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    26
lemma split_sum_all: 
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    27
  shows "(\<forall>x. P x) \<longleftrightarrow> (\<forall>x. P (Inl x)) \<and> (\<forall>x. P (Inr x))"
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    28
apply(auto)
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    29
apply(case_tac x)
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    30
apply(simp_all)
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    31
done
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    32
698
ed44eaaea63e Option and Sum quotients.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 613
diff changeset
    33
lemma sum_equivp[quot_equiv]:
ed44eaaea63e Option and Sum quotients.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 613
diff changeset
    34
  assumes a: "equivp R1"
ed44eaaea63e Option and Sum quotients.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 613
diff changeset
    35
  assumes b: "equivp R2"
ed44eaaea63e Option and Sum quotients.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 613
diff changeset
    36
  shows "equivp (sum_rel R1 R2)"
924
5455b19ef138 re-inserted lemma in QuotList
Christian Urban <urbanc@in.tum.de>
parents: 829
diff changeset
    37
  apply(rule equivpI)
5455b19ef138 re-inserted lemma in QuotList
Christian Urban <urbanc@in.tum.de>
parents: 829
diff changeset
    38
  unfolding reflp_def symp_def transp_def
934
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    39
  apply(simp_all add: split_sum_all)
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    40
  apply(blast intro: equivp_reflp[OF a] equivp_reflp[OF b])
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    41
  apply(blast intro: equivp_symp[OF a] equivp_symp[OF b])
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    42
  apply(blast intro: equivp_transp[OF a] equivp_transp[OF b])
924
5455b19ef138 re-inserted lemma in QuotList
Christian Urban <urbanc@in.tum.de>
parents: 829
diff changeset
    43
  done
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
698
ed44eaaea63e Option and Sum quotients.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 613
diff changeset
    45
lemma sum_quotient[quot_thm]:
ed44eaaea63e Option and Sum quotients.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 613
diff changeset
    46
  assumes q1: "Quotient R1 Abs1 Rep1"
ed44eaaea63e Option and Sum quotients.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 613
diff changeset
    47
  assumes q2: "Quotient R2 Abs2 Rep2"
ed44eaaea63e Option and Sum quotients.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 613
diff changeset
    48
  shows "Quotient (sum_rel R1 R2) (sum_map Abs1 Abs2) (sum_map Rep1 Rep2)"
ed44eaaea63e Option and Sum quotients.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 613
diff changeset
    49
  unfolding Quotient_def
934
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    50
  apply(simp add: split_sum_all)
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    51
  apply(simp_all add: Quotient_abs_rep[OF q1] Quotient_rel_rep[OF q1])
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    52
  apply(simp_all add: Quotient_abs_rep[OF q2] Quotient_rel_rep[OF q2])
924
5455b19ef138 re-inserted lemma in QuotList
Christian Urban <urbanc@in.tum.de>
parents: 829
diff changeset
    53
  using q1 q2
5455b19ef138 re-inserted lemma in QuotList
Christian Urban <urbanc@in.tum.de>
parents: 829
diff changeset
    54
  unfolding Quotient_def
5455b19ef138 re-inserted lemma in QuotList
Christian Urban <urbanc@in.tum.de>
parents: 829
diff changeset
    55
  apply(blast)+
698
ed44eaaea63e Option and Sum quotients.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 613
diff changeset
    56
  done
ed44eaaea63e Option and Sum quotients.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 613
diff changeset
    57
934
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    58
lemma sum_Inl_rsp[quot_respect]:
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    59
  assumes q1: "Quotient R1 Abs1 Rep1"
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    60
  assumes q2: "Quotient R2 Abs2 Rep2"
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    61
  shows "(R1 ===> sum_rel R1 R2) Inl Inl"
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    62
  by simp
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    63
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    64
lemma sum_Inr_rsp[quot_respect]:
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    65
  assumes q1: "Quotient R1 Abs1 Rep1"
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    66
  assumes q2: "Quotient R2 Abs2 Rep2"
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    67
  shows "(R2 ===> sum_rel R1 R2) Inr Inr"
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    68
  by simp
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    69
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    70
lemma sum_Inl_prs[quot_respect]:
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    71
  assumes q1: "Quotient R1 Abs1 Rep1"
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    72
  assumes q2: "Quotient R2 Abs2 Rep2"
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    73
  shows "(Rep1 ---> sum_map Abs1 Abs2) Inl = Inl"
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    74
  apply(simp add: expand_fun_eq)
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    75
  apply(simp add: Quotient_abs_rep[OF q1])
829
42b90994ac77 map and rel simps for all quotients; needed when changing the relations to aggregate ones.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 779
diff changeset
    76
  done
42b90994ac77 map and rel simps for all quotients; needed when changing the relations to aggregate ones.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 779
diff changeset
    77
934
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    78
lemma sum_Inr_prs[quot_respect]:
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    79
  assumes q1: "Quotient R1 Abs1 Rep1"
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    80
  assumes q2: "Quotient R2 Abs2 Rep2"
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    81
  shows "(Rep2 ---> sum_map Abs1 Abs2) Inr = Inr"
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    82
  apply(simp add: expand_fun_eq)
0b15b83ded4a added prs and rsp lemmas for Inl and Inr
Christian Urban <urbanc@in.tum.de>
parents: 924
diff changeset
    83
  apply(simp add: Quotient_abs_rep[OF q2])
829
42b90994ac77 map and rel simps for all quotients; needed when changing the relations to aggregate ones.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 779
diff changeset
    84
  done
42b90994ac77 map and rel simps for all quotients; needed when changing the relations to aggregate ones.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 779
diff changeset
    85
924
5455b19ef138 re-inserted lemma in QuotList
Christian Urban <urbanc@in.tum.de>
parents: 829
diff changeset
    86
lemma sum_map_id[id_simps]: 
936
Christian Urban <urbanc@in.tum.de>
parents: 934 929
diff changeset
    87
  shows "sum_map id id = id"
Christian Urban <urbanc@in.tum.de>
parents: 934 929
diff changeset
    88
  by (simp add: expand_fun_eq split_sum_all)
829
42b90994ac77 map and rel simps for all quotients; needed when changing the relations to aggregate ones.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 779
diff changeset
    89
924
5455b19ef138 re-inserted lemma in QuotList
Christian Urban <urbanc@in.tum.de>
parents: 829
diff changeset
    90
lemma sum_rel_eq[id_simps]: 
936
Christian Urban <urbanc@in.tum.de>
parents: 934 929
diff changeset
    91
  shows "sum_rel (op =) (op =) = (op =)"
Christian Urban <urbanc@in.tum.de>
parents: 934 929
diff changeset
    92
  by (simp add: expand_fun_eq split_sum_all)
829
42b90994ac77 map and rel simps for all quotients; needed when changing the relations to aggregate ones.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 779
diff changeset
    93
42b90994ac77 map and rel simps for all quotients; needed when changing the relations to aggregate ones.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 779
diff changeset
    94
end