src/HOL/Tools/record.ML
changeset 46215 0da9433f959e
parent 46186 9ae331a1d8c5
child 46218 ecf6375e2abb
equal deleted inserted replaced
46214:8534f949548e 46215:0da9433f959e
   241 
   241 
   242 
   242 
   243 (* syntax *)
   243 (* syntax *)
   244 
   244 
   245 val Trueprop = HOLogic.mk_Trueprop;
   245 val Trueprop = HOLogic.mk_Trueprop;
   246 fun All xs t = Term.list_all_free (xs, t);
       
   247 
   246 
   248 infix 0 :== ===;
   247 infix 0 :== ===;
   249 infixr 0 ==>;
   248 infixr 0 ==>;
   250 
   249 
   251 val op :== = Misc_Legacy.mk_defpair;
   250 val op :== = Misc_Legacy.mk_defpair;
  1583         ===
  1582         ===
  1584         foldr1 HOLogic.mk_conj
  1583         foldr1 HOLogic.mk_conj
  1585           (map HOLogic.mk_eq (vars_more ~~ vars_more') @ [@{term True}])
  1584           (map HOLogic.mk_eq (vars_more ~~ vars_more') @ [@{term True}])
  1586       end;
  1585       end;
  1587 
  1586 
  1588     val induct_prop =
  1587     val induct_prop = (fold_rev Logic.all vars_more (Trueprop (P $ ext)), Trueprop (P $ s));
  1589       (All (map dest_Free vars_more) (Trueprop (P $ ext)), Trueprop (P $ s));
       
  1590 
  1588 
  1591     val split_meta_prop =  (* FIXME local P *)
  1589     val split_meta_prop =  (* FIXME local P *)
  1592       let val P = Free (singleton (Name.variant_list variants) "P", extT --> propT) in
  1590       let val P = Free (singleton (Name.variant_list variants) "P", extT --> propT)
  1593         Logic.mk_equals
  1591       in Logic.mk_equals (Logic.all s (P $ s), fold_rev Logic.all vars_more (P $ ext)) end;
  1594          (All [dest_Free s] (P $ s), All (map dest_Free vars_more) (P $ ext))
       
  1595       end;
       
  1596 
  1592 
  1597     val inject = timeit_msg ctxt "record extension inject proof:" (fn () =>
  1593     val inject = timeit_msg ctxt "record extension inject proof:" (fn () =>
  1598       simplify HOL_ss
  1594       simplify HOL_ss
  1599         (Skip_Proof.prove_global defs_thy [] [] inject_prop
  1595         (Skip_Proof.prove_global defs_thy [] [] inject_prop
  1600           (fn _ =>
  1596           (fn _ =>
  2042       in mk_upd updateN c x' r_rec0 === mk_rec args' 0 end;
  2038       in mk_upd updateN c x' r_rec0 === mk_rec args' 0 end;
  2043     val upd_conv_props = map2 mk_upd_prop idxms fields_more;
  2039     val upd_conv_props = map2 mk_upd_prop idxms fields_more;
  2044 
  2040 
  2045     (*induct*)
  2041     (*induct*)
  2046     val induct_scheme_prop =
  2042     val induct_scheme_prop =
  2047       All (map dest_Free all_vars_more) (Trueprop (P $ r_rec0)) ==> Trueprop (P $ r0);
  2043       fold_rev Logic.all all_vars_more (Trueprop (P $ r_rec0)) ==> Trueprop (P $ r0);
  2048     val induct_prop =
  2044     val induct_prop =
  2049       (All (map dest_Free all_vars) (Trueprop (P_unit $ r_rec_unit0)),
  2045       (fold_rev Logic.all all_vars (Trueprop (P_unit $ r_rec_unit0)), Trueprop (P_unit $ r_unit0));
  2050         Trueprop (P_unit $ r_unit0));
       
  2051 
  2046 
  2052     (*surjective*)
  2047     (*surjective*)
  2053     val surjective_prop =
  2048     val surjective_prop =
  2054       let val args = map (fn (c, Free (_, T)) => mk_sel r0 (c, T)) all_named_vars_more
  2049       let val args = map (fn (c, Free (_, T)) => mk_sel r0 (c, T)) all_named_vars_more
  2055       in r0 === mk_rec args 0 end;
  2050       in r0 === mk_rec args 0 end;
  2056 
  2051 
  2057     (*cases*)
  2052     (*cases*)
  2058     val cases_scheme_prop =
  2053     val cases_scheme_prop =
  2059       (All (map dest_Free all_vars_more) ((r0 === r_rec0) ==> Trueprop C), Trueprop C);
  2054       (fold_rev Logic.all all_vars_more ((r0 === r_rec0) ==> Trueprop C), Trueprop C);
  2060 
  2055 
  2061     val cases_prop =
  2056     val cases_prop =
  2062       (All (map dest_Free all_vars) ((r_unit0 === r_rec_unit0) ==> Trueprop C))
  2057       fold_rev Logic.all all_vars ((r_unit0 === r_rec_unit0) ==> Trueprop C) ==> Trueprop C;
  2063          ==> Trueprop C;
       
  2064 
  2058 
  2065     (*split*)
  2059     (*split*)
  2066     val split_meta_prop =
  2060     val split_meta_prop =
  2067       let
  2061       let
  2068         val P = Free (singleton (Name.variant_list all_variants) "P", rec_schemeT0 --> propT);
  2062         val P = Free (singleton (Name.variant_list all_variants) "P", rec_schemeT0 --> propT);
  2069       in
  2063       in
  2070         Logic.mk_equals
  2064         Logic.mk_equals (Logic.all r0 (P $ r0), fold_rev Logic.all all_vars_more (P $ r_rec0))
  2071          (All [dest_Free r0] (P $ r0), All (map dest_Free all_vars_more) (P $ r_rec0))
       
  2072       end;
  2065       end;
  2073 
  2066 
  2074     val split_object_prop =
  2067     val split_object_prop =
  2075       let val ALL = fold_rev (fn (v, T) => fn t => HOLogic.mk_all (v, T, t))
  2068       let val ALL = fold_rev (fn (v, T) => fn t => HOLogic.mk_all (v, T, t))
  2076       in ALL [dest_Free r0] (P $ r0) === ALL (map dest_Free all_vars_more) (P $ r_rec0) end;
  2069       in ALL [dest_Free r0] (P $ r0) === ALL (map dest_Free all_vars_more) (P $ r_rec0) end;
  2083     val equality_prop =
  2076     val equality_prop =
  2084       let
  2077       let
  2085         val s' = Free (rN ^ "'", rec_schemeT0);
  2078         val s' = Free (rN ^ "'", rec_schemeT0);
  2086         fun mk_sel_eq (c, Free (_, T)) = mk_sel r0 (c, T) === mk_sel s' (c, T);
  2079         fun mk_sel_eq (c, Free (_, T)) = mk_sel r0 (c, T) === mk_sel s' (c, T);
  2087         val seleqs = map mk_sel_eq all_named_vars_more;
  2080         val seleqs = map mk_sel_eq all_named_vars_more;
  2088       in All (map dest_Free [r0, s']) (Logic.list_implies (seleqs, r0 === s')) end;
  2081       in Logic.all r0 (Logic.all s' (Logic.list_implies (seleqs, r0 === s'))) end;
  2089 
  2082 
  2090 
  2083 
  2091     (* 3rd stage: thms_thy *)
  2084     (* 3rd stage: thms_thy *)
  2092 
  2085 
  2093     val record_ss = get_simpset defs_thy;
  2086     val record_ss = get_simpset defs_thy;