257 spec typeN Args.tyname >> add_type || |
257 spec typeN Args.tyname >> add_type || |
258 spec predN Args.const >> add_pred || |
258 spec predN Args.const >> add_pred || |
259 spec setN Args.const >> add_pred || |
259 spec setN Args.const >> add_pred || |
260 Scan.lift Args.del >> K del; |
260 Scan.lift Args.del >> K del; |
261 |
261 |
262 val cases_att = attrib cases_type cases_pred cases_del; |
|
263 val induct_att = attrib induct_type induct_pred induct_del; |
|
264 val coinduct_att = attrib coinduct_type coinduct_pred coinduct_del; |
|
265 |
|
266 in |
262 in |
267 |
263 |
268 val attrib_setup = |
264 val attrib_setup = |
269 Attrib.setup @{binding cases} cases_att "declaration of cases rule" #> |
265 Attrib.setup @{binding cases} (attrib cases_type cases_pred cases_del) |
270 Attrib.setup @{binding induct} induct_att "declaration of induction rule" #> |
266 "declaration of cases rule" #> |
271 Attrib.setup @{binding coinduct} coinduct_att "declaration of coinduction rule"; |
267 Attrib.setup @{binding induct} (attrib induct_type induct_pred induct_del) |
|
268 "declaration of induction rule" #> |
|
269 Attrib.setup @{binding coinduct} (attrib coinduct_type coinduct_pred coinduct_del) |
|
270 "declaration of coinduction rule"; |
272 |
271 |
273 end; |
272 end; |
274 |
273 |
275 |
274 |
276 |
275 |
733 val taking = Scan.optional (Scan.lift (Args.$$$ takingN -- Args.colon) |-- |
732 val taking = Scan.optional (Scan.lift (Args.$$$ takingN -- Args.colon) |-- |
734 Scan.repeat1 (unless_more_args inst)) []; |
733 Scan.repeat1 (unless_more_args inst)) []; |
735 |
734 |
736 in |
735 in |
737 |
736 |
738 val cases_meth = |
737 val cases_setup = |
739 P.and_list' (Scan.repeat (unless_more_args inst)) -- Scan.option cases_rule >> |
738 Method.setup @{binding cases} |
740 (fn (insts, opt_rule) => fn ctxt => |
739 (P.and_list' (Scan.repeat (unless_more_args inst)) -- Scan.option cases_rule >> |
741 METHOD_CASES (fn facts => Seq.DETERM (HEADGOAL (cases_tac ctxt insts opt_rule facts)))); |
740 (fn (insts, opt_rule) => fn ctxt => |
742 |
741 METHOD_CASES (fn facts => Seq.DETERM (HEADGOAL (cases_tac ctxt insts opt_rule facts))))) |
743 val induct_meth = |
742 "case analysis on types or predicates/sets"; |
744 P.and_list' (Scan.repeat (unless_more_args def_inst)) -- |
743 |
745 (arbitrary -- taking -- Scan.option induct_rule) >> |
744 val induct_setup = |
746 (fn (insts, ((arbitrary, taking), opt_rule)) => fn ctxt => |
745 Method.setup @{binding induct} |
747 RAW_METHOD_CASES (fn facts => |
746 (P.and_list' (Scan.repeat (unless_more_args def_inst)) -- |
748 Seq.DETERM (HEADGOAL (induct_tac ctxt insts arbitrary taking opt_rule facts)))); |
747 (arbitrary -- taking -- Scan.option induct_rule) >> |
749 |
748 (fn (insts, ((arbitrary, taking), opt_rule)) => fn ctxt => |
750 val coinduct_meth = |
749 RAW_METHOD_CASES (fn facts => |
751 Scan.repeat (unless_more_args inst) -- taking -- Scan.option coinduct_rule >> |
750 Seq.DETERM (HEADGOAL (induct_tac ctxt insts arbitrary taking opt_rule facts))))) |
752 (fn ((insts, taking), opt_rule) => fn ctxt => |
751 "induction on types or predicates/sets"; |
753 RAW_METHOD_CASES (fn facts => |
752 |
754 Seq.DETERM (HEADGOAL (coinduct_tac ctxt insts taking opt_rule facts)))); |
753 val coinduct_setup = |
|
754 Method.setup @{binding coinduct} |
|
755 (Scan.repeat (unless_more_args inst) -- taking -- Scan.option coinduct_rule >> |
|
756 (fn ((insts, taking), opt_rule) => fn ctxt => |
|
757 RAW_METHOD_CASES (fn facts => |
|
758 Seq.DETERM (HEADGOAL (coinduct_tac ctxt insts taking opt_rule facts))))) |
|
759 "coinduction on types or predicates/sets"; |
755 |
760 |
756 end; |
761 end; |
757 |
762 |
758 |
763 |
759 |
764 |
760 (** theory setup **) |
765 (** theory setup **) |
761 |
766 |
762 val setup = |
767 val setup = attrib_setup #> cases_setup #> induct_setup #> coinduct_setup; |
763 attrib_setup #> |
768 |
764 Method.setup @{binding cases} cases_meth "case analysis on types or predicates/sets" #> |
769 end; |
765 Method.setup @{binding induct} induct_meth "induction on types or predicates/sets" #> |
|
766 Method.setup @{binding coinduct} coinduct_meth "coinduction on types or predicates/sets"; |
|
767 |
|
768 end; |
|