| author | nipkow | 
| Sun, 10 Mar 2013 14:36:03 +0100 | |
| changeset 51387 | dbc4a77488b2 | 
| parent 51377 | 7da251a6c16e | 
| child 51956 | a4d81cdebf8b | 
| permissions | -rw-r--r-- | 
| 47455 | 1 | (* Title: HOL/Library/Quotient_Option.thy | 
| 47624 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
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 | 4 | |
| 5 | header {* Quotient infrastructure for the option type *}
 | |
| 6 | ||
| 35222 
4f1fba00f66d
Initial version of HOL quotient package.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: diff
changeset | 7 | theory Quotient_Option | 
| 
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: 
47455diff
changeset | 11 | subsection {* Relator for option type *}
 | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
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: 
40464diff
changeset | 14 |   option_rel :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a option \<Rightarrow> 'b option \<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 | "option_rel R None None = True" | 
| 
4f1fba00f66d
Initial version of HOL quotient package.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: diff
changeset | 17 | | "option_rel R (Some x) None = False" | 
| 
4f1fba00f66d
Initial version of HOL quotient package.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: diff
changeset | 18 | | "option_rel R None (Some x) = False" | 
| 
4f1fba00f66d
Initial version of HOL quotient package.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: diff
changeset | 19 | | "option_rel R (Some x) (Some y) = R x y" | 
| 
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: 
40542diff
changeset | 21 | lemma option_rel_unfold: | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 22 | "option_rel R x y = (case (x, y) of (None, None) \<Rightarrow> True | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 23 | | (Some x, Some y) \<Rightarrow> R x y | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 24 | | _ \<Rightarrow> False)" | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 25 | by (cases x) (cases y, simp_all)+ | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 26 | |
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 27 | lemma option_rel_map1: | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 28 | "option_rel R (Option.map f x) y \<longleftrightarrow> option_rel (\<lambda>x. R (f x)) x y" | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 29 | by (simp add: option_rel_unfold split: option.split) | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 30 | |
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 31 | lemma option_rel_map2: | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 32 | "option_rel R x (Option.map f y) \<longleftrightarrow> option_rel (\<lambda>x y. R x (f y)) x y" | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 33 | by (simp add: option_rel_unfold split: option.split) | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 34 | |
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 35 | lemma option_map_id [id_simps]: | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 36 | "Option.map id = id" | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 37 | by (simp add: id_def Option.map.identity fun_eq_iff) | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 38 | |
| 47624 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 39 | lemma option_rel_eq [id_simps, relator_eq]: | 
| 40820 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 40 | "option_rel (op =) = (op =)" | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 41 | by (simp add: option_rel_unfold fun_eq_iff split: option.split) | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 42 | |
| 47624 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 43 | lemma split_option_all: "(\<forall>x. P x) \<longleftrightarrow> P None \<and> (\<forall>x. P (Some x))" | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 44 | by (metis option.exhaust) (* TODO: move to Option.thy *) | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 45 | |
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 46 | lemma split_option_ex: "(\<exists>x. P x) \<longleftrightarrow> P None \<or> (\<exists>x. P (Some x))" | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 47 | by (metis option.exhaust) (* TODO: move to Option.thy *) | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 48 | |
| 51377 | 49 | lemma option_rel_mono[relator_mono]: | 
| 50 | assumes "A \<le> B" | |
| 51 | shows "(option_rel A) \<le> (option_rel B)" | |
| 52 | using assms by (auto simp: option_rel_unfold split: option.splits) | |
| 53 | ||
| 54 | lemma option_rel_OO[relator_distr]: | |
| 55 | "(option_rel A) OO (option_rel B) = option_rel (A OO B)" | |
| 56 | by (rule ext)+ (auto simp: option_rel_unfold OO_def split: option.split) | |
| 57 | ||
| 47982 
7aa35601ff65
prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
 kuncar parents: 
47936diff
changeset | 58 | lemma option_reflp[reflexivity_rule]: | 
| 40820 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 59 | "reflp R \<Longrightarrow> reflp (option_rel R)" | 
| 47624 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 60 | unfolding reflp_def split_option_all by simp | 
| 40820 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 61 | |
| 47982 
7aa35601ff65
prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
 kuncar parents: 
47936diff
changeset | 62 | lemma option_left_total[reflexivity_rule]: | 
| 
7aa35601ff65
prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
 kuncar parents: 
47936diff
changeset | 63 | "left_total R \<Longrightarrow> left_total (option_rel R)" | 
| 
7aa35601ff65
prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
 kuncar parents: 
47936diff
changeset | 64 | apply (intro left_totalI) | 
| 
7aa35601ff65
prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
 kuncar parents: 
47936diff
changeset | 65 | unfolding split_option_ex | 
| 
7aa35601ff65
prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
 kuncar parents: 
47936diff
changeset | 66 | 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: 
47936diff
changeset | 67 | |
| 40820 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 68 | lemma option_symp: | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 69 | "symp R \<Longrightarrow> symp (option_rel R)" | 
| 47624 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 70 | unfolding symp_def split_option_all option_rel.simps by fast | 
| 40820 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 71 | |
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 72 | lemma option_transp: | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 73 | "transp R \<Longrightarrow> transp (option_rel R)" | 
| 47624 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 74 | unfolding transp_def split_option_all option_rel.simps by fast | 
| 40820 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 75 | |
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 76 | lemma option_equivp [quot_equiv]: | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 77 | "equivp R \<Longrightarrow> equivp (option_rel R)" | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 78 | by (blast intro: equivpI option_reflp option_symp option_transp elim: equivpE) | 
| 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 79 | |
| 47624 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 80 | lemma right_total_option_rel [transfer_rule]: | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 81 | "right_total R \<Longrightarrow> right_total (option_rel R)" | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 82 | unfolding right_total_def split_option_all split_option_ex by simp | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 83 | |
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 84 | lemma right_unique_option_rel [transfer_rule]: | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 85 | "right_unique R \<Longrightarrow> right_unique (option_rel R)" | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 86 | unfolding right_unique_def split_option_all by simp | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 87 | |
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 88 | lemma bi_total_option_rel [transfer_rule]: | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 89 | "bi_total R \<Longrightarrow> bi_total (option_rel R)" | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 90 | unfolding bi_total_def split_option_all split_option_ex by simp | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 91 | |
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 92 | lemma bi_unique_option_rel [transfer_rule]: | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 93 | "bi_unique R \<Longrightarrow> bi_unique (option_rel R)" | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 94 | unfolding bi_unique_def split_option_all by simp | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 95 | |
| 47635 
ebb79474262c
rename 'correspondence' method to 'transfer_prover'
 huffman parents: 
47634diff
changeset | 96 | subsection {* Transfer rules for transfer package *}
 | 
| 47624 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 97 | |
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 98 | lemma None_transfer [transfer_rule]: "(option_rel A) None None" | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 99 | by simp | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 100 | |
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 101 | lemma Some_transfer [transfer_rule]: "(A ===> option_rel A) Some Some" | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 102 | unfolding fun_rel_def by simp | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 103 | |
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 104 | lemma option_case_transfer [transfer_rule]: | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 105 | "(B ===> (A ===> B) ===> option_rel A ===> B) option_case option_case" | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 106 | unfolding fun_rel_def split_option_all by simp | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 107 | |
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 108 | lemma option_map_transfer [transfer_rule]: | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 109 | "((A ===> B) ===> option_rel A ===> option_rel B) Option.map Option.map" | 
| 47635 
ebb79474262c
rename 'correspondence' method to 'transfer_prover'
 huffman parents: 
47634diff
changeset | 110 | unfolding Option.map_def by transfer_prover | 
| 47624 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 111 | |
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 112 | lemma option_bind_transfer [transfer_rule]: | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 113 | "(option_rel A ===> (A ===> option_rel B) ===> option_rel B) | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 114 | Option.bind Option.bind" | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 115 | unfolding fun_rel_def split_option_all by simp | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 116 | |
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 117 | subsection {* Setup for lifting package *}
 | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 118 | |
| 47777 
f29e7dcd7c40
use a quot_map theorem attribute instead of the complicated map attribute
 kuncar parents: 
47635diff
changeset | 119 | lemma Quotient_option[quot_map]: | 
| 47624 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 120 | assumes "Quotient R Abs Rep T" | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 121 | shows "Quotient (option_rel R) (Option.map Abs) | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 122 | (Option.map Rep) (option_rel T)" | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 123 | using assms unfolding Quotient_alt_def option_rel_unfold | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 124 | by (simp split: option.split) | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 125 | |
| 47634 
091bcd569441
hide the invariant constant for relators: invariant_commute infrastracture
 kuncar parents: 
47624diff
changeset | 126 | fun option_pred :: "('a \<Rightarrow> bool) \<Rightarrow> 'a option \<Rightarrow> bool"
 | 
| 
091bcd569441
hide the invariant constant for relators: invariant_commute infrastracture
 kuncar parents: 
47624diff
changeset | 127 | where | 
| 
091bcd569441
hide the invariant constant for relators: invariant_commute infrastracture
 kuncar parents: 
47624diff
changeset | 128 | "option_pred R None = True" | 
| 
091bcd569441
hide the invariant constant for relators: invariant_commute infrastracture
 kuncar parents: 
47624diff
changeset | 129 | | "option_pred R (Some x) = R x" | 
| 
091bcd569441
hide the invariant constant for relators: invariant_commute infrastracture
 kuncar parents: 
47624diff
changeset | 130 | |
| 
091bcd569441
hide the invariant constant for relators: invariant_commute infrastracture
 kuncar parents: 
47624diff
changeset | 131 | lemma option_invariant_commute [invariant_commute]: | 
| 
091bcd569441
hide the invariant constant for relators: invariant_commute infrastracture
 kuncar parents: 
47624diff
changeset | 132 | "option_rel (Lifting.invariant P) = Lifting.invariant (option_pred P)" | 
| 
091bcd569441
hide the invariant constant for relators: invariant_commute infrastracture
 kuncar parents: 
47624diff
changeset | 133 | apply (simp add: fun_eq_iff Lifting.invariant_def) | 
| 
091bcd569441
hide the invariant constant for relators: invariant_commute infrastracture
 kuncar parents: 
47624diff
changeset | 134 | apply (intro allI) | 
| 
091bcd569441
hide the invariant constant for relators: invariant_commute infrastracture
 kuncar parents: 
47624diff
changeset | 135 | apply (case_tac x rule: option.exhaust) | 
| 
091bcd569441
hide the invariant constant for relators: invariant_commute infrastracture
 kuncar parents: 
47624diff
changeset | 136 | apply (case_tac xa rule: option.exhaust) | 
| 
091bcd569441
hide the invariant constant for relators: invariant_commute infrastracture
 kuncar parents: 
47624diff
changeset | 137 | apply auto[2] | 
| 
091bcd569441
hide the invariant constant for relators: invariant_commute infrastracture
 kuncar parents: 
47624diff
changeset | 138 | apply (case_tac xa rule: option.exhaust) | 
| 
091bcd569441
hide the invariant constant for relators: invariant_commute infrastracture
 kuncar parents: 
47624diff
changeset | 139 | apply auto | 
| 
091bcd569441
hide the invariant constant for relators: invariant_commute infrastracture
 kuncar parents: 
47624diff
changeset | 140 | done | 
| 
091bcd569441
hide the invariant constant for relators: invariant_commute infrastracture
 kuncar parents: 
47624diff
changeset | 141 | |
| 47624 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 142 | subsection {* Rules for quotient package *}
 | 
| 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 143 | |
| 40820 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 144 | lemma option_quotient [quot_thm]: | 
| 47308 | 145 | assumes "Quotient3 R Abs Rep" | 
| 146 | shows "Quotient3 (option_rel R) (Option.map Abs) (Option.map Rep)" | |
| 147 | apply (rule Quotient3I) | |
| 148 | apply (simp_all add: Option.map.compositionality comp_def Option.map.identity option_rel_eq option_rel_map1 option_rel_map2 Quotient3_abs_rep [OF assms] Quotient3_rel_rep [OF assms]) | |
| 149 | using Quotient3_rel [OF assms] | |
| 40820 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 150 | apply (simp add: option_rel_unfold split: option.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 | 153 | declare [[mapQ3 option = (option_rel, option_quotient)]] | 
| 47094 | 154 | |
| 40820 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 155 | lemma option_None_rsp [quot_respect]: | 
| 47308 | 156 | assumes q: "Quotient3 R Abs Rep" | 
| 35222 
4f1fba00f66d
Initial version of HOL quotient package.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: diff
changeset | 157 | shows "option_rel R None None" | 
| 47624 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 158 | by (rule None_transfer) | 
| 35222 
4f1fba00f66d
Initial version of HOL quotient package.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: diff
changeset | 159 | |
| 40820 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 160 | lemma option_Some_rsp [quot_respect]: | 
| 47308 | 161 | assumes q: "Quotient3 R Abs Rep" | 
| 35222 
4f1fba00f66d
Initial version of HOL quotient package.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: diff
changeset | 162 | shows "(R ===> option_rel R) Some Some" | 
| 47624 
16d433895d2e
add new transfer rules and setup for lifting package
 huffman parents: 
47455diff
changeset | 163 | by (rule Some_transfer) | 
| 35222 
4f1fba00f66d
Initial version of HOL quotient package.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: diff
changeset | 164 | |
| 40820 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 165 | lemma option_None_prs [quot_preserve]: | 
| 47308 | 166 | assumes q: "Quotient3 R Abs Rep" | 
| 35222 
4f1fba00f66d
Initial version of HOL quotient package.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: diff
changeset | 167 | shows "Option.map Abs None = None" | 
| 
4f1fba00f66d
Initial version of HOL quotient package.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: diff
changeset | 168 | by simp | 
| 
4f1fba00f66d
Initial version of HOL quotient package.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: diff
changeset | 169 | |
| 40820 
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
 haftmann parents: 
40542diff
changeset | 170 | lemma option_Some_prs [quot_preserve]: | 
| 47308 | 171 | assumes q: "Quotient3 R Abs Rep" | 
| 35222 
4f1fba00f66d
Initial version of HOL quotient package.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: diff
changeset | 172 | shows "(Rep ---> Option.map Abs) Some = Some" | 
| 39302 
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
 nipkow parents: 
39198diff
changeset | 173 | apply(simp add: fun_eq_iff) | 
| 47308 | 174 | apply(simp add: Quotient3_abs_rep[OF q]) | 
| 35222 
4f1fba00f66d
Initial version of HOL quotient package.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: diff
changeset | 175 | done | 
| 
4f1fba00f66d
Initial version of HOL quotient package.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: diff
changeset | 176 | |
| 
4f1fba00f66d
Initial version of HOL quotient package.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: diff
changeset | 177 | end |