121 "iso_tuple_surjective_proof_assist x y f \<longleftrightarrow> f x = y" |
121 "iso_tuple_surjective_proof_assist x y f \<longleftrightarrow> f x = y" |
122 |
122 |
123 definition |
123 definition |
124 iso_tuple_update_accessor_cong_assist :: |
124 iso_tuple_update_accessor_cong_assist :: |
125 "(('b \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'a)) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> bool" where |
125 "(('b \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'a)) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> bool" where |
126 "iso_tuple_update_accessor_cong_assist upd acc \<longleftrightarrow> |
126 "iso_tuple_update_accessor_cong_assist upd ac \<longleftrightarrow> |
127 (\<forall>f v. upd (\<lambda>x. f (acc v)) v = upd f v) \<and> (\<forall>v. upd id v = v)" |
127 (\<forall>f v. upd (\<lambda>x. f (ac v)) v = upd f v) \<and> (\<forall>v. upd id v = v)" |
128 |
128 |
129 definition |
129 definition |
130 iso_tuple_update_accessor_eq_assist :: |
130 iso_tuple_update_accessor_eq_assist :: |
131 "(('b \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'a)) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> ('b \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool" where |
131 "(('b \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'a)) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> ('b \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool" where |
132 "iso_tuple_update_accessor_eq_assist upd acc v f v' x \<longleftrightarrow> |
132 "iso_tuple_update_accessor_eq_assist upd ac v f v' x \<longleftrightarrow> |
133 upd f v = v' \<and> acc v = x \<and> iso_tuple_update_accessor_cong_assist upd acc" |
133 upd f v = v' \<and> ac v = x \<and> iso_tuple_update_accessor_cong_assist upd ac" |
134 |
134 |
135 lemma update_accessor_congruence_foldE: |
135 lemma update_accessor_congruence_foldE: |
136 assumes uac: "iso_tuple_update_accessor_cong_assist upd acc" |
136 assumes uac: "iso_tuple_update_accessor_cong_assist upd ac" |
137 and r: "r = r'" and v: "acc r' = v'" |
137 and r: "r = r'" and v: "ac r' = v'" |
138 and f: "\<And>v. v' = v \<Longrightarrow> f v = f' v" |
138 and f: "\<And>v. v' = v \<Longrightarrow> f v = f' v" |
139 shows "upd f r = upd f' r'" |
139 shows "upd f r = upd f' r'" |
140 using uac r v [symmetric] |
140 using uac r v [symmetric] |
141 apply (subgoal_tac "upd (\<lambda>x. f (acc r')) r' = upd (\<lambda>x. f' (acc r')) r'") |
141 apply (subgoal_tac "upd (\<lambda>x. f (ac r')) r' = upd (\<lambda>x. f' (ac r')) r'") |
142 apply (simp add: iso_tuple_update_accessor_cong_assist_def) |
142 apply (simp add: iso_tuple_update_accessor_cong_assist_def) |
143 apply (simp add: f) |
143 apply (simp add: f) |
144 done |
144 done |
145 |
145 |
146 lemma update_accessor_congruence_unfoldE: |
146 lemma update_accessor_congruence_unfoldE: |
147 "iso_tuple_update_accessor_cong_assist upd acc \<Longrightarrow> |
147 "iso_tuple_update_accessor_cong_assist upd ac \<Longrightarrow> |
148 r = r' \<Longrightarrow> acc r' = v' \<Longrightarrow> (\<And>v. v = v' \<Longrightarrow> f v = f' v) \<Longrightarrow> |
148 r = r' \<Longrightarrow> ac r' = v' \<Longrightarrow> (\<And>v. v = v' \<Longrightarrow> f v = f' v) \<Longrightarrow> |
149 upd f r = upd f' r'" |
149 upd f r = upd f' r'" |
150 apply (erule(2) update_accessor_congruence_foldE) |
150 apply (erule(2) update_accessor_congruence_foldE) |
151 apply simp |
151 apply simp |
152 done |
152 done |
153 |
153 |
154 lemma iso_tuple_update_accessor_cong_assist_id: |
154 lemma iso_tuple_update_accessor_cong_assist_id: |
155 "iso_tuple_update_accessor_cong_assist upd acc \<Longrightarrow> upd id = id" |
155 "iso_tuple_update_accessor_cong_assist upd ac \<Longrightarrow> upd id = id" |
156 by rule (simp add: iso_tuple_update_accessor_cong_assist_def) |
156 by rule (simp add: iso_tuple_update_accessor_cong_assist_def) |
157 |
157 |
158 lemma update_accessor_noopE: |
158 lemma update_accessor_noopE: |
159 assumes uac: "iso_tuple_update_accessor_cong_assist upd acc" |
159 assumes uac: "iso_tuple_update_accessor_cong_assist upd ac" |
160 and acc: "f (acc x) = acc x" |
160 and ac: "f (ac x) = ac x" |
161 shows "upd f x = x" |
161 shows "upd f x = x" |
162 using uac |
162 using uac |
163 by (simp add: acc iso_tuple_update_accessor_cong_assist_id [OF uac, unfolded id_def] |
163 by (simp add: ac iso_tuple_update_accessor_cong_assist_id [OF uac, unfolded id_def] |
164 cong: update_accessor_congruence_unfoldE [OF uac]) |
164 cong: update_accessor_congruence_unfoldE [OF uac]) |
165 |
165 |
166 lemma update_accessor_noop_compE: |
166 lemma update_accessor_noop_compE: |
167 assumes uac: "iso_tuple_update_accessor_cong_assist upd acc" |
167 assumes uac: "iso_tuple_update_accessor_cong_assist upd ac" |
168 and acc: "f (acc x) = acc x" |
168 and ac: "f (ac x) = ac x" |
169 shows "upd (g \<circ> f) x = upd g x" |
169 shows "upd (g \<circ> f) x = upd g x" |
170 by (simp add: acc cong: update_accessor_congruence_unfoldE[OF uac]) |
170 by (simp add: ac cong: update_accessor_congruence_unfoldE[OF uac]) |
171 |
171 |
172 lemma update_accessor_cong_assist_idI: |
172 lemma update_accessor_cong_assist_idI: |
173 "iso_tuple_update_accessor_cong_assist id id" |
173 "iso_tuple_update_accessor_cong_assist id id" |
174 by (simp add: iso_tuple_update_accessor_cong_assist_def) |
174 by (simp add: iso_tuple_update_accessor_cong_assist_def) |
175 |
175 |
176 lemma update_accessor_cong_assist_triv: |
176 lemma update_accessor_cong_assist_triv: |
177 "iso_tuple_update_accessor_cong_assist upd acc \<Longrightarrow> |
177 "iso_tuple_update_accessor_cong_assist upd ac \<Longrightarrow> |
178 iso_tuple_update_accessor_cong_assist upd acc" |
178 iso_tuple_update_accessor_cong_assist upd ac" |
179 by assumption |
179 by assumption |
180 |
180 |
181 lemma update_accessor_accessor_eqE: |
181 lemma update_accessor_accessor_eqE: |
182 "iso_tuple_update_accessor_eq_assist upd acc v f v' x \<Longrightarrow> acc v = x" |
182 "iso_tuple_update_accessor_eq_assist upd ac v f v' x \<Longrightarrow> ac v = x" |
183 by (simp add: iso_tuple_update_accessor_eq_assist_def) |
183 by (simp add: iso_tuple_update_accessor_eq_assist_def) |
184 |
184 |
185 lemma update_accessor_updator_eqE: |
185 lemma update_accessor_updator_eqE: |
186 "iso_tuple_update_accessor_eq_assist upd acc v f v' x \<Longrightarrow> upd f v = v'" |
186 "iso_tuple_update_accessor_eq_assist upd ac v f v' x \<Longrightarrow> upd f v = v'" |
187 by (simp add: iso_tuple_update_accessor_eq_assist_def) |
187 by (simp add: iso_tuple_update_accessor_eq_assist_def) |
188 |
188 |
189 lemma iso_tuple_update_accessor_eq_assist_idI: |
189 lemma iso_tuple_update_accessor_eq_assist_idI: |
190 "v' = f v \<Longrightarrow> iso_tuple_update_accessor_eq_assist id id v f v' v" |
190 "v' = f v \<Longrightarrow> iso_tuple_update_accessor_eq_assist id id v f v' v" |
191 by (simp add: iso_tuple_update_accessor_eq_assist_def update_accessor_cong_assist_idI) |
191 by (simp add: iso_tuple_update_accessor_eq_assist_def update_accessor_cong_assist_idI) |
192 |
192 |
193 lemma iso_tuple_update_accessor_eq_assist_triv: |
193 lemma iso_tuple_update_accessor_eq_assist_triv: |
194 "iso_tuple_update_accessor_eq_assist upd acc v f v' x \<Longrightarrow> |
194 "iso_tuple_update_accessor_eq_assist upd ac v f v' x \<Longrightarrow> |
195 iso_tuple_update_accessor_eq_assist upd acc v f v' x" |
195 iso_tuple_update_accessor_eq_assist upd ac v f v' x" |
196 by assumption |
196 by assumption |
197 |
197 |
198 lemma iso_tuple_update_accessor_cong_from_eq: |
198 lemma iso_tuple_update_accessor_cong_from_eq: |
199 "iso_tuple_update_accessor_eq_assist upd acc v f v' x \<Longrightarrow> |
199 "iso_tuple_update_accessor_eq_assist upd ac v f v' x \<Longrightarrow> |
200 iso_tuple_update_accessor_cong_assist upd acc" |
200 iso_tuple_update_accessor_cong_assist upd ac" |
201 by (simp add: iso_tuple_update_accessor_eq_assist_def) |
201 by (simp add: iso_tuple_update_accessor_eq_assist_def) |
202 |
202 |
203 lemma iso_tuple_surjective_proof_assistI: |
203 lemma iso_tuple_surjective_proof_assistI: |
204 "f x = y \<Longrightarrow> iso_tuple_surjective_proof_assist x y f" |
204 "f x = y \<Longrightarrow> iso_tuple_surjective_proof_assist x y f" |
205 by (simp add: iso_tuple_surjective_proof_assist_def) |
205 by (simp add: iso_tuple_surjective_proof_assist_def) |