src/ZF/Tools/inductive_package.ML
changeset 20046 9c8909fc5865
parent 18728 6790126ab5f6
child 20071 8f3e1ddb50e6
equal deleted inserted replaced
20045:e66efbafbf1f 20046:9c8909fc5865
   192 
   192 
   193   (********)
   193   (********)
   194   val dummy = writeln "  Proving monotonicity...";
   194   val dummy = writeln "  Proving monotonicity...";
   195 
   195 
   196   val bnd_mono =
   196   val bnd_mono =
   197     standard (Goal.prove sign1 [] [] (FOLogic.mk_Trueprop (Fp.bnd_mono $ dom_sum $ fp_abs))
   197     Goal.prove_global sign1 [] [] (FOLogic.mk_Trueprop (Fp.bnd_mono $ dom_sum $ fp_abs))
   198       (fn _ => EVERY
   198       (fn _ => EVERY
   199         [rtac (Collect_subset RS bnd_monoI) 1,
   199         [rtac (Collect_subset RS bnd_monoI) 1,
   200          REPEAT (ares_tac (basic_monos @ monos) 1)]));
   200          REPEAT (ares_tac (basic_monos @ monos) 1)]);
   201 
   201 
   202   val dom_subset = standard (big_rec_def RS Fp.subs);
   202   val dom_subset = standard (big_rec_def RS Fp.subs);
   203 
   203 
   204   val unfold = standard ([big_rec_def, bnd_mono] MRS Fp.Tarski);
   204   val unfold = standard ([big_rec_def, bnd_mono] MRS Fp.Tarski);
   205 
   205 
   250       in  accesses_bal(f, g, asm_rl)  end;
   250       in  accesses_bal(f, g, asm_rl)  end;
   251 
   251 
   252   val intrs =
   252   val intrs =
   253     (intr_tms, map intro_tacsf (mk_disj_rls (length intr_tms)))
   253     (intr_tms, map intro_tacsf (mk_disj_rls (length intr_tms)))
   254     |> ListPair.map (fn (t, tacs) =>
   254     |> ListPair.map (fn (t, tacs) =>
   255       standard (Goal.prove sign1 [] [] t
   255       Goal.prove_global sign1 [] [] t
   256         (fn _ => EVERY (rewrite_goals_tac part_rec_defs :: tacs))))
   256         (fn _ => EVERY (rewrite_goals_tac part_rec_defs :: tacs)))
   257     handle MetaSimplifier.SIMPLIFIER (msg, thm) => (print_thm thm; error msg);
   257     handle MetaSimplifier.SIMPLIFIER (msg, thm) => (print_thm thm; error msg);
   258 
   258 
   259   (********)
   259   (********)
   260   val dummy = writeln "  Proving the elimination rule...";
   260   val dummy = writeln "  Proving the elimination rule...";
   261 
   261 
   341                       (fn prems => resolve_tac (triv_rls@prems)
   341                       (fn prems => resolve_tac (triv_rls@prems)
   342                                    ORELSE' assume_tac
   342                                    ORELSE' assume_tac
   343                                    ORELSE' etac FalseE));
   343                                    ORELSE' etac FalseE));
   344 
   344 
   345      val quant_induct =
   345      val quant_induct =
   346        standard (Goal.prove sign1 [] ind_prems
   346        Goal.prove_global sign1 [] ind_prems
   347          (FOLogic.mk_Trueprop (Ind_Syntax.mk_all_imp (big_rec_tm, pred)))
   347          (FOLogic.mk_Trueprop (Ind_Syntax.mk_all_imp (big_rec_tm, pred)))
   348          (fn prems => EVERY
   348          (fn prems => EVERY
   349            [rewrite_goals_tac part_rec_defs,
   349            [rewrite_goals_tac part_rec_defs,
   350             rtac (impI RS allI) 1,
   350             rtac (impI RS allI) 1,
   351             DETERM (etac raw_induct 1),
   351             DETERM (etac raw_induct 1),
   355             REPEAT (FIRSTGOAL (eresolve_tac [CollectE, disjE])),
   355             REPEAT (FIRSTGOAL (eresolve_tac [CollectE, disjE])),
   356             (*Now break down the individual cases.  No disjE here in case
   356             (*Now break down the individual cases.  No disjE here in case
   357               some premise involves disjunction.*)
   357               some premise involves disjunction.*)
   358             REPEAT (FIRSTGOAL (eresolve_tac [CollectE, exE, conjE]
   358             REPEAT (FIRSTGOAL (eresolve_tac [CollectE, exE, conjE]
   359                                ORELSE' bound_hyp_subst_tac)),
   359                                ORELSE' bound_hyp_subst_tac)),
   360             ind_tac (rev (map (rewrite_rule part_rec_defs) prems)) (length prems)]));
   360             ind_tac (rev (map (rewrite_rule part_rec_defs) prems)) (length prems)]);
   361 
   361 
   362      val dummy = if !Ind_Syntax.trace then
   362      val dummy = if !Ind_Syntax.trace then
   363                  (writeln "quant_induct = "; print_thm quant_induct)
   363                  (writeln "quant_induct = "; print_thm quant_induct)
   364              else ();
   364              else ();
   365 
   365 
   425      val need_mutual = length rec_names > 1;
   425      val need_mutual = length rec_names > 1;
   426 
   426 
   427      val lemma = (*makes the link between the two induction rules*)
   427      val lemma = (*makes the link between the two induction rules*)
   428        if need_mutual then
   428        if need_mutual then
   429           (writeln "  Proving the mutual induction rule...";
   429           (writeln "  Proving the mutual induction rule...";
   430            standard (Goal.prove sign1 [] []
   430            Goal.prove_global sign1 [] []
   431              (Logic.mk_implies (induct_concl, mutual_induct_concl))
   431              (Logic.mk_implies (induct_concl, mutual_induct_concl))
   432              (fn _ => EVERY
   432              (fn _ => EVERY
   433                [rewrite_goals_tac part_rec_defs,
   433                [rewrite_goals_tac part_rec_defs,
   434                 REPEAT (rewrite_goals_tac [Pr.split_eq] THEN lemma_tac 1)])))
   434                 REPEAT (rewrite_goals_tac [Pr.split_eq] THEN lemma_tac 1)]))
   435        else (writeln "  [ No mutual induction rule needed ]"; TrueI);
   435        else (writeln "  [ No mutual induction rule needed ]"; TrueI);
   436 
   436 
   437      val dummy = if !Ind_Syntax.trace then
   437      val dummy = if !Ind_Syntax.trace then
   438                  (writeln "lemma = "; print_thm lemma)
   438                  (writeln "lemma = "; print_thm lemma)
   439              else ();
   439              else ();
   484                ) i)
   484                ) i)
   485             THEN mutual_ind_tac prems (i-1);
   485             THEN mutual_ind_tac prems (i-1);
   486 
   486 
   487      val mutual_induct_fsplit =
   487      val mutual_induct_fsplit =
   488        if need_mutual then
   488        if need_mutual then
   489          standard (Goal.prove sign1 [] (map (induct_prem (rec_tms~~preds)) intr_tms)
   489          Goal.prove_global sign1 [] (map (induct_prem (rec_tms~~preds)) intr_tms)
   490            mutual_induct_concl
   490            mutual_induct_concl
   491            (fn prems => EVERY
   491            (fn prems => EVERY
   492              [rtac (quant_induct RS lemma) 1,
   492              [rtac (quant_induct RS lemma) 1,
   493               mutual_ind_tac (rev prems) (length prems)]))
   493               mutual_ind_tac (rev prems) (length prems)])
   494        else TrueI;
   494        else TrueI;
   495 
   495 
   496      (** Uncurrying the predicate in the ordinary induction rule **)
   496      (** Uncurrying the predicate in the ordinary induction rule **)
   497 
   497 
   498      (*instantiate the variable to a tuple, if it is non-trivial, in order to
   498      (*instantiate the variable to a tuple, if it is non-trivial, in order to