src/HOL/Tools/BNF/bnf_fp_def_sugar.ML
changeset 57567 d554b0097ad4
parent 57565 ab7f39114507
child 57568 2c65870c706f
equal deleted inserted replaced
57566:0fb191472e4a 57567:d554b0097ad4
   572           fold_rev Logic.all (map Free (drop (nn + length xs)
   572           fold_rev Logic.all (map Free (drop (nn + length xs)
   573             (rev (Term.add_frees t (map dest_Free xs @ ps'))))) t;
   573             (rev (Term.add_frees t (map dest_Free xs @ ps'))))) t;
   574 
   574 
   575         fun mk_prem_prem xs (xysets, (j, x)) =
   575         fun mk_prem_prem xs (xysets, (j, x)) =
   576           close_prem_prem xs (Logic.list_implies (map (fn (x', (y, set)) =>
   576           close_prem_prem xs (Logic.list_implies (map (fn (x', (y, set)) =>
   577               HOLogic.mk_Trueprop (HOLogic.mk_mem (y, set $ x'))) xysets,
   577               mk_Trueprop_mem (y, set $ x')) xysets,
   578             HOLogic.mk_Trueprop (nth ps (j - 1) $ x)));
   578             HOLogic.mk_Trueprop (nth ps (j - 1) $ x)));
   579 
   579 
   580         fun mk_raw_prem phi ctr ctr_Ts ctrXs_Ts =
   580         fun mk_raw_prem phi ctr ctr_Ts ctrXs_Ts =
   581           let
   581           let
   582             val (xs, names_lthy') = names_lthy |> mk_Frees "x" ctr_Ts;
   582             val (xs, names_lthy') = names_lthy |> mk_Frees "x" ctr_Ts;
  1562                                 let
  1562                                 let
  1563                                   fun seq_assm a set ctxt =
  1563                                   fun seq_assm a set ctxt =
  1564                                     let
  1564                                     let
  1565                                       val X = HOLogic.dest_setT (range_type (fastype_of set));
  1565                                       val X = HOLogic.dest_setT (range_type (fastype_of set));
  1566                                       val (x, ctxt') = yield_singleton (mk_Frees "x") X ctxt;
  1566                                       val (x, ctxt') = yield_singleton (mk_Frees "x") X ctxt;
  1567                                       val assm = HOLogic.mk_Trueprop (HOLogic.mk_mem (x, set $ a));
  1567                                       val assm = mk_Trueprop_mem (x, set $ a);
  1568                                     in
  1568                                     in
  1569                                       travese_nested_types x ctxt'
  1569                                       travese_nested_types x ctxt'
  1570                                       |>> map (Logic.mk_implies o pair assm)
  1570                                       |>> map (Logic.mk_implies o pair assm)
  1571                                     end;
  1571                                     end;
  1572                                 in
  1572                                 in
  1573                                   fold_map (seq_assm t o mk_set xs) (sets_of_bnf bnf) ctxt
  1573                                   fold_map (seq_assm t o mk_set xs) (sets_of_bnf bnf) ctxt
  1574                                   |>> flat
  1574                                   |>> flat
  1575                                 end)
  1575                                 end)
  1576                             | T =>
  1576                             | T =>
  1577                               if T = A then
  1577                               if T = A then
  1578                                 ([HOLogic.mk_Trueprop (HOLogic.mk_mem (t, setA $ ta))], ctxt)
  1578                                 ([mk_Trueprop_mem (t, setA $ ta)], ctxt)
  1579                               else
  1579                               else
  1580                                 ([], ctxt));
  1580                                 ([], ctxt));
  1581 
  1581 
  1582                           val (concls, ctxt') =
  1582                           val (concls, ctxt') =
  1583                             if sel_rangeT = A then
  1583                             if sel_rangeT = A then
  1584                               ([HOLogic.mk_Trueprop (HOLogic.mk_mem (selA $ ta, setA $ ta))], ctxt)
  1584                               ([mk_Trueprop_mem (selA $ ta, setA $ ta)], ctxt)
  1585                             else
  1585                             else
  1586                               travese_nested_types (selA $ ta) names_lthy;
  1586                               travese_nested_types (selA $ ta) names_lthy;
  1587                         in
  1587                         in
  1588                           if exists_subtype_in [A] sel_rangeT then
  1588                           if exists_subtype_in [A] sel_rangeT then
  1589                             if is_refl_bool prem then
  1589                             if is_refl_bool prem then