indrule.ML
changeset 140 f745ff8bdb91
parent 136 0a43cf458998
child 151 c0e62be6ef04
equal deleted inserted replaced
139:96c68fd7ed46 140:f745ff8bdb91
    66   in list_all_free (quantfrees, list_implies (iprems,concl)) end
    66   in list_all_free (quantfrees, list_implies (iprems,concl)) end
    67   handle Bind => error"Recursion term not found in conclusion";
    67   handle Bind => error"Recursion term not found in conclusion";
    68 
    68 
    69 (*Avoids backtracking by delivering the correct premise to each goal*)
    69 (*Avoids backtracking by delivering the correct premise to each goal*)
    70 fun ind_tac [] 0 = all_tac
    70 fun ind_tac [] 0 = all_tac
    71   | ind_tac(prem::prems) i = REPEAT (ares_tac [Part_eqI,prem] i) THEN
    71   | ind_tac(prem::prems) i = REPEAT (ares_tac [Part_eqI, prem, refl] i) THEN
    72 			     ind_tac prems (i-1);
    72 			     ind_tac prems (i-1);
    73 
    73 
    74 val pred = Free(pred_name, elem_type --> boolT);
    74 val pred = Free(pred_name, elem_type --> boolT);
    75 
    75 
    76 val ind_prems = map (induct_prem (map (rpair pred) rec_tms)) intr_tms;
    76 val ind_prems = map (induct_prem (map (rpair pred) rec_tms)) intr_tms;
    80       (cterm_of sign (list_implies (ind_prems, 
    80       (cterm_of sign (list_implies (ind_prems, 
    81 				    mk_tprop (mk_all_imp(big_rec_tm,pred)))))
    81 				    mk_tprop (mk_all_imp(big_rec_tm,pred)))))
    82       (fn prems =>
    82       (fn prems =>
    83        [rtac (impI RS allI) 1,
    83        [rtac (impI RS allI) 1,
    84 	etac raw_induct 1,
    84 	etac raw_induct 1,
    85 	REPEAT (FIRSTGOAL (eresolve_tac [IntE, CollectE, exE, conjE, disjE, 
    85 	REPEAT (FIRSTGOAL (eresolve_tac [IntE, CollectE, exE, conjE, disjE] 
    86 					 ssubst])),
    86 			   ORELSE' hyp_subst_tac)),
    87 	REPEAT (FIRSTGOAL (eresolve_tac [PartE, CollectE])),
    87 	REPEAT (FIRSTGOAL (eresolve_tac [PartE, CollectE])),
    88 	ind_tac (rev prems) (length prems)])
    88 	ind_tac (rev prems) (length prems)])
    89     handle e => print_sign_exn sign e;
    89     handle e => print_sign_exn sign e;
    90 
    90 
    91 (*** Prove the simultaneous induction rule ***)
    91 (*** Prove the simultaneous induction rule ***)
   126     prove_goalw_cterm part_rec_defs 
   126     prove_goalw_cterm part_rec_defs 
   127 	  (cterm_of sign (mk_implies (induct_concl,mutual_induct_concl)))
   127 	  (cterm_of sign (mk_implies (induct_concl,mutual_induct_concl)))
   128 	  (fn prems =>
   128 	  (fn prems =>
   129 	   [cut_facts_tac prems 1,
   129 	   [cut_facts_tac prems 1,
   130 	    REPEAT (eresolve_tac [asm_rl, conjE, PartE, mp] 1
   130 	    REPEAT (eresolve_tac [asm_rl, conjE, PartE, mp] 1
   131 	     ORELSE resolve_tac [allI, impI, conjI, Part_eqI] 1
   131 	     ORELSE resolve_tac [allI, impI, conjI, Part_eqI, refl] 1
   132 	     ORELSE dresolve_tac [spec, mp, splitD] 1)])
   132 	     ORELSE dresolve_tac [spec, mp, splitD] 1)])
   133     handle e => print_sign_exn sign e;
   133     handle e => print_sign_exn sign e;
   134 
   134 
   135 (*Mutual induction follows by freeness of Inl/Inr.*)
   135 (*Mutual induction follows by freeness of Inl/Inr.*)
   136 
   136