equal
deleted
inserted
replaced
182 fun add_quot_map rel_quot_thm context = |
182 fun add_quot_map rel_quot_thm context = |
183 let |
183 let |
184 val _ = Context.cases (K ()) (quot_map_thm_sanity_check rel_quot_thm) context |
184 val _ = Context.cases (K ()) (quot_map_thm_sanity_check rel_quot_thm) context |
185 val rel_quot_thm_concl = Logic.strip_imp_concl (Thm.prop_of rel_quot_thm) |
185 val rel_quot_thm_concl = Logic.strip_imp_concl (Thm.prop_of rel_quot_thm) |
186 val (_, abs, _, _) = dest_Quotient (HOLogic.dest_Trueprop rel_quot_thm_concl) |
186 val (_, abs, _, _) = dest_Quotient (HOLogic.dest_Trueprop rel_quot_thm_concl) |
187 val relatorT_name = fst (dest_Type (fst (dest_funT (fastype_of abs)))) |
187 val relatorT_name = dest_Type_name (fst (dest_funT (fastype_of abs))) |
188 val minfo = {rel_quot_thm = Thm.trim_context rel_quot_thm} |
188 val minfo = {rel_quot_thm = Thm.trim_context rel_quot_thm} |
189 in (Data.map o map_quot_maps) (Symtab.update (relatorT_name, minfo)) context end |
189 in (Data.map o map_quot_maps) (Symtab.update (relatorT_name, minfo)) context end |
190 |
190 |
191 val _ = |
191 val _ = |
192 Theory.setup |
192 Theory.setup |
221 |> Option.map (transform_quotient (Morphism.transfer_morphism' ctxt)) |
221 |> Option.map (transform_quotient (Morphism.transfer_morphism' ctxt)) |
222 |
222 |
223 fun lookup_quot_thm_quotients ctxt quot_thm = |
223 fun lookup_quot_thm_quotients ctxt quot_thm = |
224 let |
224 let |
225 val (_, qtyp) = quot_thm_rty_qty quot_thm |
225 val (_, qtyp) = quot_thm_rty_qty quot_thm |
226 val qty_full_name = fst (dest_Type qtyp) |
226 val qty_full_name = dest_Type_name qtyp |
227 fun compare_data (data:quotient) = Thm.eq_thm_prop (#quot_thm data, quot_thm) |
227 fun compare_data (data:quotient) = Thm.eq_thm_prop (#quot_thm data, quot_thm) |
228 in |
228 in |
229 case lookup_quotients ctxt qty_full_name of |
229 case lookup_quotients ctxt qty_full_name of |
230 SOME quotient => if compare_data quotient then SOME quotient else NONE |
230 SOME quotient => if compare_data quotient then SOME quotient else NONE |
231 | NONE => NONE |
231 | NONE => NONE |
236 in (Data.map o map_quotients) (Symtab.update (type_name, qinfo')) context end |
236 in (Data.map o map_quotients) (Symtab.update (type_name, qinfo')) context end |
237 |
237 |
238 fun delete_quotients quot_thm context = |
238 fun delete_quotients quot_thm context = |
239 let |
239 let |
240 val (_, qtyp) = quot_thm_rty_qty quot_thm |
240 val (_, qtyp) = quot_thm_rty_qty quot_thm |
241 val qty_full_name = fst (dest_Type qtyp) |
241 val qty_full_name = dest_Type_name qtyp |
242 in |
242 in |
243 if is_some (lookup_quot_thm_quotients (Context.proof_of context) quot_thm) |
243 if is_some (lookup_quot_thm_quotients (Context.proof_of context) quot_thm) |
244 then (Data.map o map_quotients) (Symtab.delete qty_full_name) context |
244 then (Data.map o map_quotients) (Symtab.delete qty_full_name) context |
245 else context |
245 else context |
246 end |
246 end |
389 |
389 |
390 fun add_mono_rule mono_rule context = |
390 fun add_mono_rule mono_rule context = |
391 let |
391 let |
392 val pol_mono_rule = introduce_polarities mono_rule |
392 val pol_mono_rule = introduce_polarities mono_rule |
393 val mono_ruleT_name = |
393 val mono_ruleT_name = |
394 fst (dest_Type (fst (relation_types (fst (relation_types |
394 dest_Type_name (fst (relation_types (fst (relation_types |
395 (snd (dest_Const (head_of (HOLogic.dest_Trueprop (Thm.concl_of pol_mono_rule)))))))))) |
395 (snd (dest_Const (head_of (HOLogic.dest_Trueprop (Thm.concl_of pol_mono_rule))))))))) |
396 in |
396 in |
397 if Symtab.defined (get_relator_distr_data' context) mono_ruleT_name |
397 if Symtab.defined (get_relator_distr_data' context) mono_ruleT_name |
398 then |
398 then |
399 (if Context_Position.is_visible_generic context then |
399 (if Context_Position.is_visible_generic context then |
400 warning ("Monotonicity rule for type " ^ quote mono_ruleT_name ^ " is already_defined.") |
400 warning ("Monotonicity rule for type " ^ quote mono_ruleT_name ^ " is already_defined.") |
416 |
416 |
417 local |
417 local |
418 fun add_distr_rule update_entry distr_rule context = |
418 fun add_distr_rule update_entry distr_rule context = |
419 let |
419 let |
420 val distr_ruleT_name = |
420 val distr_ruleT_name = |
421 fst (dest_Type (fst (relation_types (fst (relation_types |
421 dest_Type_name (fst (relation_types (fst (relation_types |
422 (snd (dest_Const (head_of (HOLogic.dest_Trueprop (Thm.concl_of distr_rule)))))))))) |
422 (snd (dest_Const (head_of (HOLogic.dest_Trueprop (Thm.concl_of distr_rule))))))))) |
423 in |
423 in |
424 if Symtab.defined (get_relator_distr_data' context) distr_ruleT_name then |
424 if Symtab.defined (get_relator_distr_data' context) distr_ruleT_name then |
425 (Data.map o map_relator_distr_data) |
425 (Data.map o map_relator_distr_data) |
426 (Symtab.map_entry distr_ruleT_name (update_entry distr_rule)) context |
426 (Symtab.map_entry distr_ruleT_name (update_entry distr_rule)) context |
427 else error "The monotonicity rule is not defined." |
427 else error "The monotonicity rule is not defined." |