src/HOL/Tools/Quotient/quotient_type.ML
changeset 46727 0162a0d284ac
parent 45835 14bf7ca4ef3a
child 46909 3c73a121a387
equal deleted inserted replaced
46726:49cbc06af3e5 46727:0162a0d284ac
    43 fun typedef_make (vs, qty_name, mx, rel, rty) equiv_thm lthy =
    43 fun typedef_make (vs, qty_name, mx, rel, rty) equiv_thm lthy =
    44   let
    44   let
    45     val typedef_tac =
    45     val typedef_tac =
    46       EVERY1 (map rtac [@{thm part_equivp_typedef}, equiv_thm])
    46       EVERY1 (map rtac [@{thm part_equivp_typedef}, equiv_thm])
    47   in
    47   in
    48   (* FIXME: purely local typedef causes at the moment
    48     Typedef.add_typedef false NONE (qty_name, map (rpair dummyS) vs, mx)
    49      problems with type variables
       
    50 
       
    51     Typedef.add_typedef false NONE (qty_name, vs, mx)
       
    52       (typedef_term rel rty lthy) NONE typedef_tac lthy
    49       (typedef_term rel rty lthy) NONE typedef_tac lthy
    53   *)
       
    54   (* FIXME should really use local typedef here *)
       
    55     Local_Theory.background_theory_result
       
    56      (Typedef.add_typedef_global false NONE
       
    57        (qty_name, map (rpair dummyS) vs, mx)
       
    58          (typedef_term rel rty lthy)
       
    59            NONE typedef_tac) lthy
       
    60   end
    50   end
    61 
    51 
    62 
    52 
    63 (* tactic to prove the quot_type theorem for the new type *)
    53 (* tactic to prove the quot_type theorem for the new type *)
    64 fun typedef_quot_type_tac equiv_thm ((_, typedef_info): Typedef.info) =
    54 fun typedef_quot_type_tac equiv_thm ((_, typedef_info): Typedef.info) =
   255 fun quotient_type_cmd specs lthy =
   245 fun quotient_type_cmd specs lthy =
   256   let
   246   let
   257     fun parse_spec (((((vs, qty_name), mx), rty_str), (partial, rel_str)), opt_morphs) lthy =
   247     fun parse_spec (((((vs, qty_name), mx), rty_str), (partial, rel_str)), opt_morphs) lthy =
   258       let
   248       let
   259         val rty = Syntax.read_typ lthy rty_str
   249         val rty = Syntax.read_typ lthy rty_str
   260         val lthy1 = Variable.declare_typ rty lthy
   250         val tmp_lthy1 = Variable.declare_typ rty lthy
   261         val rel =
   251         val rel =
   262           Syntax.parse_term lthy1 rel_str
   252           Syntax.parse_term tmp_lthy1 rel_str
   263           |> Type.constraint (rty --> rty --> @{typ bool})
   253           |> Type.constraint (rty --> rty --> @{typ bool})
   264           |> Syntax.check_term lthy1
   254           |> Syntax.check_term tmp_lthy1
   265         val lthy2 = Variable.declare_term rel lthy1
   255         val tmp_lthy2 = Variable.declare_term rel tmp_lthy1
   266       in
   256       in
   267         (((vs, qty_name, mx), (rty, rel, partial), opt_morphs), lthy2)
   257         (((vs, qty_name, mx), (rty, rel, partial), opt_morphs), tmp_lthy2)
   268       end
   258       end
   269 
   259 
   270     val (spec', lthy') = fold_map parse_spec specs lthy
   260     val (spec', _) = fold_map parse_spec specs lthy
   271   in
   261   in
   272     quotient_type spec' lthy'
   262     quotient_type spec' lthy
   273   end
   263   end
   274 
   264 
   275 val partial = Scan.optional (Parse.reserved "partial" -- Parse.$$$ ":" >> K true) false
   265 val partial = Scan.optional (Parse.reserved "partial" -- Parse.$$$ ":" >> K true) false
   276 
   266 
   277 val quotspec_parser =
   267 val quotspec_parser =