src/HOL/Nominal/nominal_package.ML
changeset 18302 577e5d19b33c
parent 18280 45e139675daf
child 18350 66cda85ea3ab
equal deleted inserted replaced
18301:0c5c3b1a700e 18302:577e5d19b33c
  1022       else map (fn T => Sign.intern_class thy8 ("fs_" ^
  1022       else map (fn T => Sign.intern_class thy8 ("fs_" ^
  1023         Sign.base_name (fst (dest_Type T)))) dt_atomTs;
  1023         Sign.base_name (fst (dest_Type T)))) dt_atomTs;
  1024     val fsT = TFree ("'n", ind_sort);
  1024     val fsT = TFree ("'n", ind_sort);
  1025 
  1025 
  1026     fun make_pred i T =
  1026     fun make_pred i T =
  1027       Free (List.nth (pnames, i), T --> fsT --> HOLogic.boolT);
  1027       Free (List.nth (pnames, i), fsT --> T --> HOLogic.boolT);
  1028 
  1028 
  1029     fun make_ind_prem k T ((cname, cargs), idxs) =
  1029     fun make_ind_prem k T ((cname, cargs), idxs) =
  1030       let
  1030       let
  1031         val recs = List.filter is_rec_type cargs;
  1031         val recs = List.filter is_rec_type cargs;
  1032         val Ts = map (typ_of_dtyp descr'' sorts') cargs;
  1032         val Ts = map (typ_of_dtyp descr'' sorts') cargs;
  1039         fun mk_prem ((dt, s), T) =
  1039         fun mk_prem ((dt, s), T) =
  1040           let
  1040           let
  1041             val (Us, U) = strip_type T;
  1041             val (Us, U) = strip_type T;
  1042             val l = length Us
  1042             val l = length Us
  1043           in list_all (z :: map (pair "x") Us, HOLogic.mk_Trueprop
  1043           in list_all (z :: map (pair "x") Us, HOLogic.mk_Trueprop
  1044             (make_pred (body_index dt) U $ app_bnds (Free (s, T)) l $ Bound l))
  1044             (make_pred (body_index dt) U $ Bound l $ app_bnds (Free (s, T)) l))
  1045           end;
  1045           end;
  1046 
  1046 
  1047         val prems = map mk_prem (recs ~~ rec_tnames ~~ recTs');
  1047         val prems = map mk_prem (recs ~~ rec_tnames ~~ recTs');
  1048         val prems' = map (fn p as (_, T) => HOLogic.mk_Trueprop
  1048         val prems' = map (fn p as (_, T) => HOLogic.mk_Trueprop
  1049             (Const ("nominal.fresh", T --> fsT --> HOLogic.boolT) $
  1049             (Const ("nominal.fresh", T --> fsT --> HOLogic.boolT) $
  1050               Free p $ Free z))
  1050               Free p $ Free z))
  1051           (map (curry List.nth frees) (List.concat (map (fn (m, n) =>
  1051           (map (curry List.nth frees) (List.concat (map (fn (m, n) =>
  1052              m upto m + n - 1) idxs)))
  1052              m upto m + n - 1) idxs)))
  1053 
  1053 
  1054       in list_all_free (z :: frees, Logic.list_implies (prems' @ prems,
  1054       in list_all_free (frees @ [z], Logic.list_implies (prems' @ prems,
  1055         HOLogic.mk_Trueprop (make_pred k T $ 
  1055         HOLogic.mk_Trueprop (make_pred k T $ Free z $
  1056           list_comb (Const (cname, Ts ---> T), map Free frees) $ Free z)))
  1056           list_comb (Const (cname, Ts ---> T), map Free frees))))
  1057       end;
  1057       end;
  1058 
  1058 
  1059     val ind_prems = List.concat (map (fn (((i, (_, _, constrs)), (_, idxss)), T) =>
  1059     val ind_prems = List.concat (map (fn (((i, (_, _, constrs)), (_, idxss)), T) =>
  1060       map (make_ind_prem i T) (constrs ~~ idxss)) (descr'' ~~ ndescr ~~ recTs));
  1060       map (make_ind_prem i T) (constrs ~~ idxss)) (descr'' ~~ ndescr ~~ recTs));
  1061     val tnames = DatatypeProp.make_tnames recTs;
  1061     val tnames = DatatypeProp.make_tnames recTs;
  1062     val z = (variant tnames "z", fsT);
  1062     val z = (variant tnames "z", fsT);
  1063     val ind_concl = HOLogic.mk_Trueprop (foldr1 (HOLogic.mk_binop "op &")
  1063     val ind_concl = HOLogic.mk_Trueprop (foldr1 (HOLogic.mk_binop "op &")
  1064       (map (fn (((i, _), T), tname) => make_pred i T $ Free (tname, T) $ Free z)
  1064       (map (fn (((i, _), T), tname) => make_pred i T $ Free z $ Free (tname, T))
  1065         (descr'' ~~ recTs ~~ tnames)));
  1065         (descr'' ~~ recTs ~~ tnames)));
  1066     val induct = Logic.list_implies (ind_prems, ind_concl);
  1066     val induct = Logic.list_implies (ind_prems, ind_concl);
  1067 
  1067 
  1068     val simp_atts = replicate (length new_type_names) [Simplifier.simp_add_global];
  1068     val simp_atts = replicate (length new_type_names) [Simplifier.simp_add_global];
  1069 
  1069