444 |
444 |
445 and mk_ind_def thy gr dep names intrs = |
445 and mk_ind_def thy gr dep names intrs = |
446 let val ids = map (mk_const_id (sign_of thy)) names |
446 let val ids = map (mk_const_id (sign_of thy)) names |
447 in Graph.add_edge (hd ids, dep) gr handle Graph.UNDEF _ => |
447 in Graph.add_edge (hd ids, dep) gr handle Graph.UNDEF _ => |
448 let |
448 let |
449 fun dest_prem factors (_ $ (Const ("op :", _) $ t $ u)) = |
449 fun dest_prem factors (_ $ (p as (Const ("op :", _) $ t $ u))) = |
450 (case head_of u of |
450 (case head_of u of |
451 Const (name, _) => Prem (split_prod [] |
451 Const (name, _) => (case assoc (factors, name) of |
452 (the (assoc (factors, name))) t, u) |
452 None => Sidecond p |
|
453 | Some f => Prem (split_prod [] f t, u)) |
453 | Var ((name, _), _) => Prem (split_prod [] |
454 | Var ((name, _), _) => Prem (split_prod [] |
454 (the (assoc (factors, name))) t, u)) |
455 (the (assoc (factors, name))) t, u)) |
455 | dest_prem factors (_ $ ((eq as Const ("op =", _)) $ t $ u)) = |
456 | dest_prem factors (_ $ ((eq as Const ("op =", _)) $ t $ u)) = |
456 Prem ([t, u], eq) |
457 Prem ([t, u], eq) |
457 | dest_prem factors (_ $ t) = Sidecond t; |
458 | dest_prem factors (_ $ t) = Sidecond t; |
465 (overwrite (clauses, (name, if_none (assoc (clauses, name)) [] @ |
466 (overwrite (clauses, (name, if_none (assoc (clauses, name)) [] @ |
466 [(split_prod [] (the (assoc (factors, name))) t, prems)]))) |
467 [(split_prod [] (the (assoc (factors, name))) t, prems)]))) |
467 end; |
468 end; |
468 |
469 |
469 fun add_prod_factors extra_fs (fs, _ $ (Const ("op :", _) $ t $ u)) = |
470 fun add_prod_factors extra_fs (fs, _ $ (Const ("op :", _) $ t $ u)) = |
470 infer_factors (sign_of thy) extra_fs |
471 (case apsome (get_clauses thy o fst) (try dest_Const (head_of u)) of |
471 (fs, (Some (FVar (prod_factors [] t)), u)) |
472 Some None => fs |
|
473 | _ => infer_factors (sign_of thy) extra_fs |
|
474 (fs, (Some (FVar (prod_factors [] t)), u))) |
472 | add_prod_factors _ (fs, _) = fs; |
475 | add_prod_factors _ (fs, _) = fs; |
473 |
476 |
474 val intrs' = map (rename_term o #prop o rep_thm o standard) intrs; |
477 val intrs' = map (rename_term o #prop o rep_thm o standard) intrs; |
475 val _ $ (_ $ _ $ u) = Logic.strip_imp_concl (hd intrs'); |
478 val _ $ (_ $ _ $ u) = Logic.strip_imp_concl (hd intrs'); |
476 val (_, args) = strip_comb u; |
479 val (_, args) = strip_comb u; |