src/HOL/Tools/record.ML
changeset 56245 84fc7dfa3cd4
parent 54895 515630483010
child 56249 0fda98dd2c93
equal deleted inserted replaced
56244:3298b7a2795a 56245:84fc7dfa3cd4
  1285 fun split_simproc P =
  1285 fun split_simproc P =
  1286   Simplifier.simproc_global @{theory HOL} "record_split_simp" ["x"]
  1286   Simplifier.simproc_global @{theory HOL} "record_split_simp" ["x"]
  1287     (fn ctxt => fn t =>
  1287     (fn ctxt => fn t =>
  1288       (case t of
  1288       (case t of
  1289         Const (quantifier, Type (_, [Type (_, [T, _]), _])) $ _ =>
  1289         Const (quantifier, Type (_, [Type (_, [T, _]), _])) $ _ =>
  1290           if quantifier = @{const_name all} orelse
  1290           if quantifier = @{const_name Pure.all} orelse
  1291             quantifier = @{const_name All} orelse
  1291             quantifier = @{const_name All} orelse
  1292             quantifier = @{const_name Ex}
  1292             quantifier = @{const_name Ex}
  1293           then
  1293           then
  1294             (case rec_id ~1 T of
  1294             (case rec_id ~1 T of
  1295               "" => NONE
  1295               "" => NONE
  1299                     (case get_splits (Proof_Context.theory_of ctxt) (rec_id split T) of
  1299                     (case get_splits (Proof_Context.theory_of ctxt) (rec_id split T) of
  1300                       NONE => NONE
  1300                       NONE => NONE
  1301                     | SOME (all_thm, All_thm, Ex_thm, _) =>
  1301                     | SOME (all_thm, All_thm, Ex_thm, _) =>
  1302                         SOME
  1302                         SOME
  1303                           (case quantifier of
  1303                           (case quantifier of
  1304                             @{const_name all} => all_thm
  1304                             @{const_name Pure.all} => all_thm
  1305                           | @{const_name All} => All_thm RS @{thm eq_reflection}
  1305                           | @{const_name All} => All_thm RS @{thm eq_reflection}
  1306                           | @{const_name Ex} => Ex_thm RS @{thm eq_reflection}
  1306                           | @{const_name Ex} => Ex_thm RS @{thm eq_reflection}
  1307                           | _ => raise Fail "split_simproc"))
  1307                           | _ => raise Fail "split_simproc"))
  1308                   else NONE
  1308                   else NONE
  1309                 end)
  1309                 end)
  1366     val goal = term_of cgoal;
  1366     val goal = term_of cgoal;
  1367     val frees = filter (is_recT o #2) (Term.add_frees goal []);
  1367     val frees = filter (is_recT o #2) (Term.add_frees goal []);
  1368 
  1368 
  1369     val has_rec = exists_Const
  1369     val has_rec = exists_Const
  1370       (fn (s, Type (_, [Type (_, [T, _]), _])) =>
  1370       (fn (s, Type (_, [Type (_, [T, _]), _])) =>
  1371           (s = @{const_name all} orelse s = @{const_name All} orelse s = @{const_name Ex}) andalso
  1371           (s = @{const_name Pure.all} orelse s = @{const_name All} orelse s = @{const_name Ex})
  1372           is_recT T
  1372             andalso is_recT T
  1373         | _ => false);
  1373         | _ => false);
  1374 
  1374 
  1375     fun mk_split_free_tac free induct_thm i =
  1375     fun mk_split_free_tac free induct_thm i =
  1376       let
  1376       let
  1377         val cfree = cterm_of thy free;
  1377         val cfree = cterm_of thy free;
  1416   let
  1416   let
  1417     val goal = term_of cgoal;
  1417     val goal = term_of cgoal;
  1418 
  1418 
  1419     val has_rec = exists_Const
  1419     val has_rec = exists_Const
  1420       (fn (s, Type (_, [Type (_, [T, _]), _])) =>
  1420       (fn (s, Type (_, [Type (_, [T, _]), _])) =>
  1421           (s = @{const_name all} orelse s = @{const_name All}) andalso is_recT T
  1421           (s = @{const_name Pure.all} orelse s = @{const_name All}) andalso is_recT T
  1422         | _ => false);
  1422         | _ => false);
  1423 
  1423 
  1424     fun is_all (Const (@{const_name all}, _) $ _) = ~1
  1424     fun is_all (Const (@{const_name Pure.all}, _) $ _) = ~1
  1425       | is_all (Const (@{const_name All}, _) $ _) = ~1
  1425       | is_all (Const (@{const_name All}, _) $ _) = ~1
  1426       | is_all _ = 0;
  1426       | is_all _ = 0;
  1427   in
  1427   in
  1428     if has_rec goal then
  1428     if has_rec goal then
  1429       full_simp_tac (put_simpset HOL_basic_ss ctxt addsimprocs [split_simproc is_all]) i
  1429       full_simp_tac (put_simpset HOL_basic_ss ctxt addsimprocs [split_simproc is_all]) i