src/HOL/Tools/Quotient/quotient_typ.ML
changeset 41451 892e67be8304
parent 41444 7f40120cd814
child 42361 23f352990944
equal deleted inserted replaced
41450:3a62f88d9650 41451:892e67be8304
    18 end;
    18 end;
    19 
    19 
    20 structure Quotient_Type: QUOTIENT_TYPE =
    20 structure Quotient_Type: QUOTIENT_TYPE =
    21 struct
    21 struct
    22 
    22 
    23 open Quotient_Info;
    23 (* wrappers for define, note, Attrib.internal and theorem_i *)  (* FIXME !? *)
    24 
    24 
    25 (* wrappers for define, note, Attrib.internal and theorem_i *)
       
    26 fun define (name, mx, rhs) lthy =
    25 fun define (name, mx, rhs) lthy =
    27   let
    26   let
    28     val ((rhs, (_ , thm)), lthy') =
    27     val ((rhs, (_ , thm)), lthy') =
    29       Local_Theory.define ((name, mx), (Attrib.empty_binding, rhs)) lthy
    28       Local_Theory.define ((name, mx), (Attrib.empty_binding, rhs)) lthy
    30   in
    29   in
   158     val equiv_thm_name = Binding.suffix_name "_equivp" qty_name
   157     val equiv_thm_name = Binding.suffix_name "_equivp" qty_name
   159 
   158 
   160     (* storing the quotdata *)
   159     (* storing the quotdata *)
   161     val quotdata = {qtyp = Abs_ty, rtyp = rty, equiv_rel = rel, equiv_thm = equiv_thm}
   160     val quotdata = {qtyp = Abs_ty, rtyp = rty, equiv_rel = rel, equiv_thm = equiv_thm}
   162 
   161 
   163     fun qinfo phi = transform_quotdata phi quotdata
   162     fun qinfo phi = Quotient_Info.transform_quotdata phi quotdata
   164 
   163 
   165     val lthy4 = lthy3
   164     val lthy4 = lthy3
   166       |> Local_Theory.declaration true (fn phi => quotdata_update_gen qty_full_name (qinfo phi))
   165       |> Local_Theory.declaration true
   167       |> note (equiv_thm_name, equiv_thm, if partial then [] else [intern_attr equiv_rules_add])
   166         (fn phi => Quotient_Info.quotdata_update_gen qty_full_name (qinfo phi))
   168       |> note (quotient_thm_name, quotient_thm, [intern_attr quotient_rules_add])
   167       |> note
       
   168         (equiv_thm_name, equiv_thm,
       
   169           if partial then [] else [intern_attr Quotient_Info.equiv_rules_add])
       
   170       |> note (quotient_thm_name, quotient_thm, [intern_attr Quotient_Info.quotient_rules_add])
   169   in
   171   in
   170     (quotdata, lthy4)
   172     (quotdata, lthy4)
   171   end
   173   end
   172 
   174 
   173 
   175 
   216     val thy = ProofContext.theory_of ctxt
   218     val thy = ProofContext.theory_of ctxt
   217 
   219 
   218     fun map_check_aux rty warns =
   220     fun map_check_aux rty warns =
   219       case rty of
   221       case rty of
   220         Type (_, []) => warns
   222         Type (_, []) => warns
   221       | Type (s, _) => if maps_defined thy s then warns else s::warns
   223       | Type (s, _) => if Quotient_Info.maps_defined thy s then warns else s::warns
   222       | _ => warns
   224       | _ => warns
   223 
   225 
   224     val warns = map_check_aux rty []
   226     val warns = map_check_aux rty []
   225   in
   227   in
   226     if null warns then ()
   228     if null warns then ()