src/HOL/Nominal/nominal_induct.ML
author blanchet
Wed, 04 Mar 2009 10:45:52 +0100
changeset 30240 5b25fee0362c
parent 29581 b3b33e0298eb
child 30510 4120fc59dd85
permissions -rw-r--r--
Merge.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30240
blanchet
parents: 29581
diff changeset
     1
(*  Author:     Christian Urban and Makarius
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
     2
18288
feb79a6b274b proper treatment of tuple/tuple_fun -- nest to the left!
wenzelm
parents: 18283
diff changeset
     3
The nominal induct proof method.
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
     4
*)
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
     5
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
     6
structure NominalInduct:
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
     7
sig
29581
b3b33e0298eb binding is alias for Binding.T
haftmann
parents: 28965
diff changeset
     8
  val nominal_induct_tac: Proof.context -> (binding option * term) option list list ->
18583
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
     9
    (string * typ) list -> (string * typ) list list -> thm list ->
18297
116fe71fad51 fresh: frees instead of terms, rename corresponding params in rule;
wenzelm
parents: 18288
diff changeset
    10
    thm list -> int -> RuleCases.cases_tactic
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
    11
  val nominal_induct_method: Method.src -> Proof.context -> Method.method
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
    12
end =
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
    13
struct
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
    14
18288
feb79a6b274b proper treatment of tuple/tuple_fun -- nest to the left!
wenzelm
parents: 18283
diff changeset
    15
(* proper tuples -- nested left *)
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
    16
18288
feb79a6b274b proper treatment of tuple/tuple_fun -- nest to the left!
wenzelm
parents: 18283
diff changeset
    17
fun tupleT Ts = HOLogic.unitT |> fold (fn T => fn U => HOLogic.mk_prodT (U, T)) Ts;
feb79a6b274b proper treatment of tuple/tuple_fun -- nest to the left!
wenzelm
parents: 18283
diff changeset
    18
fun tuple ts = HOLogic.unit |> fold (fn t => fn u => HOLogic.mk_prod (u, t)) ts;
feb79a6b274b proper treatment of tuple/tuple_fun -- nest to the left!
wenzelm
parents: 18283
diff changeset
    19
feb79a6b274b proper treatment of tuple/tuple_fun -- nest to the left!
wenzelm
parents: 18283
diff changeset
    20
fun tuple_fun Ts (xi, T) =
feb79a6b274b proper treatment of tuple/tuple_fun -- nest to the left!
wenzelm
parents: 18283
diff changeset
    21
  Library.funpow (length Ts) HOLogic.mk_split
feb79a6b274b proper treatment of tuple/tuple_fun -- nest to the left!
wenzelm
parents: 18283
diff changeset
    22
    (Var (xi, (HOLogic.unitT :: Ts) ---> Term.range_type T));
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
    23
18288
feb79a6b274b proper treatment of tuple/tuple_fun -- nest to the left!
wenzelm
parents: 18283
diff changeset
    24
val split_all_tuples =
feb79a6b274b proper treatment of tuple/tuple_fun -- nest to the left!
wenzelm
parents: 18283
diff changeset
    25
  Simplifier.full_simplify (HOL_basic_ss addsimps
30240
blanchet
parents: 29581
diff changeset
    26
    [split_conv, split_paired_all, unit_all_eq1, @{thm fresh_unit_elim}, @{thm fresh_prod_elim}] @
blanchet
parents: 29581
diff changeset
    27
    @{thms fresh_star_unit_elim} @ @{thms fresh_star_prod_elim});
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
    28
18288
feb79a6b274b proper treatment of tuple/tuple_fun -- nest to the left!
wenzelm
parents: 18283
diff changeset
    29
18297
116fe71fad51 fresh: frees instead of terms, rename corresponding params in rule;
wenzelm
parents: 18288
diff changeset
    30
(* prepare rule *)
18288
feb79a6b274b proper treatment of tuple/tuple_fun -- nest to the left!
wenzelm
parents: 18283
diff changeset
    31
19903
158ea5884966 RuleCases.mutual_rule: ctxt;
wenzelm
parents: 19115
diff changeset
    32
fun inst_mutual_rule ctxt insts avoiding rules =
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
    33
  let
22072
aabbf8c4de80 added capabilities to handle mutual inductions
urbanc
parents: 21879
diff changeset
    34
    val (nconcls, joined_rule) = RuleCases.strict_mutual_rule ctxt rules;
aabbf8c4de80 added capabilities to handle mutual inductions
urbanc
parents: 21879
diff changeset
    35
    val concls = Logic.dest_conjunctions (Thm.concl_of joined_rule);
aabbf8c4de80 added capabilities to handle mutual inductions
urbanc
parents: 21879
diff changeset
    36
    val (cases, consumes) = RuleCases.get joined_rule;
18583
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
    37
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
    38
    val l = length rules;
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
    39
    val _ =
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
    40
      if length insts = l then ()
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
    41
      else error ("Bad number of instantiations for " ^ string_of_int l ^ " rules");
18288
feb79a6b274b proper treatment of tuple/tuple_fun -- nest to the left!
wenzelm
parents: 18283
diff changeset
    42
22072
aabbf8c4de80 added capabilities to handle mutual inductions
urbanc
parents: 21879
diff changeset
    43
    fun subst inst concl =
18583
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
    44
      let
24830
a7b3ab44d993 moved Pure/Isar/induct_attrib.ML and Provers/induct_method.ML to Tools/induct.ML;
wenzelm
parents: 23591
diff changeset
    45
        val vars = Induct.vars_of concl;
18583
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
    46
        val m = length vars and n = length inst;
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
    47
        val _ = if m >= n + 2 then () else error "Too few variables in conclusion of rule";
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
    48
        val P :: x :: ys = vars;
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
    49
        val zs = Library.drop (m - n - 2, ys);
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
    50
      in
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
    51
        (P, tuple_fun (map #2 avoiding) (Term.dest_Var P)) ::
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
    52
        (x, tuple (map Free avoiding)) ::
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
    53
        List.mapPartial (fn (z, SOME t) => SOME (z, t) | _ => NONE) (zs ~~ inst)
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
    54
      end;
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
    55
     val substs =
22072
aabbf8c4de80 added capabilities to handle mutual inductions
urbanc
parents: 21879
diff changeset
    56
       map2 subst insts concls |> List.concat |> distinct (op =)
19903
158ea5884966 RuleCases.mutual_rule: ctxt;
wenzelm
parents: 19115
diff changeset
    57
       |> map (pairself (Thm.cterm_of (ProofContext.theory_of ctxt)));
22072
aabbf8c4de80 added capabilities to handle mutual inductions
urbanc
parents: 21879
diff changeset
    58
  in 
aabbf8c4de80 added capabilities to handle mutual inductions
urbanc
parents: 21879
diff changeset
    59
    (((cases, nconcls), consumes), Drule.cterm_instantiate substs joined_rule) 
aabbf8c4de80 added capabilities to handle mutual inductions
urbanc
parents: 21879
diff changeset
    60
  end;
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
    61
18299
af72dfc4b9f9 added rename_params_rule: recover orginal fresh names in subgoals/cases;
wenzelm
parents: 18297
diff changeset
    62
fun rename_params_rule internal xs rule =
18297
116fe71fad51 fresh: frees instead of terms, rename corresponding params in rule;
wenzelm
parents: 18288
diff changeset
    63
  let
18299
af72dfc4b9f9 added rename_params_rule: recover orginal fresh names in subgoals/cases;
wenzelm
parents: 18297
diff changeset
    64
    val tune =
20072
c4710df2c953 Name.internal;
wenzelm
parents: 19903
diff changeset
    65
      if internal then Name.internal
c4710df2c953 Name.internal;
wenzelm
parents: 19903
diff changeset
    66
      else fn x => the_default x (try Name.dest_internal x);
18299
af72dfc4b9f9 added rename_params_rule: recover orginal fresh names in subgoals/cases;
wenzelm
parents: 18297
diff changeset
    67
    val n = length xs;
af72dfc4b9f9 added rename_params_rule: recover orginal fresh names in subgoals/cases;
wenzelm
parents: 18297
diff changeset
    68
    fun rename prem =
af72dfc4b9f9 added rename_params_rule: recover orginal fresh names in subgoals/cases;
wenzelm
parents: 18297
diff changeset
    69
      let
af72dfc4b9f9 added rename_params_rule: recover orginal fresh names in subgoals/cases;
wenzelm
parents: 18297
diff changeset
    70
        val ps = Logic.strip_params prem;
af72dfc4b9f9 added rename_params_rule: recover orginal fresh names in subgoals/cases;
wenzelm
parents: 18297
diff changeset
    71
        val p = length ps;
af72dfc4b9f9 added rename_params_rule: recover orginal fresh names in subgoals/cases;
wenzelm
parents: 18297
diff changeset
    72
        val ys =
af72dfc4b9f9 added rename_params_rule: recover orginal fresh names in subgoals/cases;
wenzelm
parents: 18297
diff changeset
    73
          if p < n then []
af72dfc4b9f9 added rename_params_rule: recover orginal fresh names in subgoals/cases;
wenzelm
parents: 18297
diff changeset
    74
          else map (tune o #1) (Library.take (p - n, ps)) @ xs;
af72dfc4b9f9 added rename_params_rule: recover orginal fresh names in subgoals/cases;
wenzelm
parents: 18297
diff changeset
    75
      in Logic.list_rename_params (ys, prem) end;
af72dfc4b9f9 added rename_params_rule: recover orginal fresh names in subgoals/cases;
wenzelm
parents: 18297
diff changeset
    76
    fun rename_prems prop =
af72dfc4b9f9 added rename_params_rule: recover orginal fresh names in subgoals/cases;
wenzelm
parents: 18297
diff changeset
    77
      let val (As, C) = Logic.strip_horn (Thm.prop_of rule)
af72dfc4b9f9 added rename_params_rule: recover orginal fresh names in subgoals/cases;
wenzelm
parents: 18297
diff changeset
    78
      in Logic.list_implies (map rename As, C) end;
af72dfc4b9f9 added rename_params_rule: recover orginal fresh names in subgoals/cases;
wenzelm
parents: 18297
diff changeset
    79
  in Thm.equal_elim (Thm.reflexive (Drule.cterm_fun rename_prems (Thm.cprop_of rule))) rule end;
18297
116fe71fad51 fresh: frees instead of terms, rename corresponding params in rule;
wenzelm
parents: 18288
diff changeset
    80
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
    81
18288
feb79a6b274b proper treatment of tuple/tuple_fun -- nest to the left!
wenzelm
parents: 18283
diff changeset
    82
(* nominal_induct_tac *)
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
    83
18583
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
    84
fun nominal_induct_tac ctxt def_insts avoiding fixings rules facts =
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
    85
  let
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
    86
    val thy = ProofContext.theory_of ctxt;
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
    87
    val cert = Thm.cterm_of thy;
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
    88
24830
a7b3ab44d993 moved Pure/Isar/induct_attrib.ML and Provers/induct_method.ML to Tools/induct.ML;
wenzelm
parents: 23591
diff changeset
    89
    val ((insts, defs), defs_ctxt) = fold_map Induct.add_defs def_insts ctxt |>> split_list;
23591
d32a85385e17 simplified ObjectLogic.atomize;
wenzelm
parents: 22072
diff changeset
    90
    val atomized_defs = map (map (Conv.fconv_rule ObjectLogic.atomize)) defs;
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
    91
19115
bc8da9b4a81c distinct (op =);
wenzelm
parents: 19036
diff changeset
    92
    val finish_rule =
18297
116fe71fad51 fresh: frees instead of terms, rename corresponding params in rule;
wenzelm
parents: 18288
diff changeset
    93
      split_all_tuples
26712
e2dcda7b0401 adapted to ProofContext.revert_skolem: extra Name.clean required;
wenzelm
parents: 25985
diff changeset
    94
      #> rename_params_rule true
e2dcda7b0401 adapted to ProofContext.revert_skolem: extra Name.clean required;
wenzelm
parents: 25985
diff changeset
    95
        (map (Name.clean o ProofContext.revert_skolem defs_ctxt o fst) avoiding);
24830
a7b3ab44d993 moved Pure/Isar/induct_attrib.ML and Provers/induct_method.ML to Tools/induct.ML;
wenzelm
parents: 23591
diff changeset
    96
    fun rule_cases r = RuleCases.make_nested true (Thm.prop_of r) (Induct.rulified_term r);
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
    97
  in
18297
116fe71fad51 fresh: frees instead of terms, rename corresponding params in rule;
wenzelm
parents: 18288
diff changeset
    98
    (fn i => fn st =>
18583
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
    99
      rules
19903
158ea5884966 RuleCases.mutual_rule: ctxt;
wenzelm
parents: 19115
diff changeset
   100
      |> inst_mutual_rule ctxt insts avoiding
18583
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
   101
      |> RuleCases.consume (List.concat defs) facts
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
   102
      |> Seq.maps (fn (((cases, concls), (more_consumes, more_facts)), rule) =>
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
   103
        (PRECISE_CONJUNCTS (length concls) (ALLGOALS (fn j =>
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
   104
          (CONJUNCTS (ALLGOALS
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
   105
            (Method.insert_tac (more_facts @ nth_list atomized_defs (j - 1))
24830
a7b3ab44d993 moved Pure/Isar/induct_attrib.ML and Provers/induct_method.ML to Tools/induct.ML;
wenzelm
parents: 23591
diff changeset
   106
              THEN' Induct.fix_tac defs_ctxt
18583
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
   107
                (nth concls (j - 1) + more_consumes)
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
   108
                (nth_list fixings (j - 1))))
24830
a7b3ab44d993 moved Pure/Isar/induct_attrib.ML and Provers/induct_method.ML to Tools/induct.ML;
wenzelm
parents: 23591
diff changeset
   109
          THEN' Induct.inner_atomize_tac) j))
a7b3ab44d993 moved Pure/Isar/induct_attrib.ML and Provers/induct_method.ML to Tools/induct.ML;
wenzelm
parents: 23591
diff changeset
   110
        THEN' Induct.atomize_tac) i st |> Seq.maps (fn st' =>
26940
80df961f7900 guess_instance: proper context;
wenzelm
parents: 26712
diff changeset
   111
            Induct.guess_instance ctxt
24830
a7b3ab44d993 moved Pure/Isar/induct_attrib.ML and Provers/induct_method.ML to Tools/induct.ML;
wenzelm
parents: 23591
diff changeset
   112
              (finish_rule (Induct.internalize more_consumes rule)) i st'
18583
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
   113
            |> Seq.maps (fn rule' =>
19115
bc8da9b4a81c distinct (op =);
wenzelm
parents: 19036
diff changeset
   114
              CASES (rule_cases rule' cases)
18583
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
   115
                (Tactic.rtac (rename_params_rule false [] rule') i THEN
20288
8ff4a0ea49b2 simplified Assumption/ProofContext.export;
wenzelm
parents: 20072
diff changeset
   116
                  PRIMITIVE (singleton (ProofContext.export defs_ctxt ctxt))) st'))))
24830
a7b3ab44d993 moved Pure/Isar/induct_attrib.ML and Provers/induct_method.ML to Tools/induct.ML;
wenzelm
parents: 23591
diff changeset
   117
    THEN_ALL_NEW_CASES Induct.rulify_tac
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
   118
  end;
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
   119
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
   120
18288
feb79a6b274b proper treatment of tuple/tuple_fun -- nest to the left!
wenzelm
parents: 18283
diff changeset
   121
(* concrete syntax *)
17870
c35381811d5c Initial revision.
berghofe
parents:
diff changeset
   122
c35381811d5c Initial revision.
berghofe
parents:
diff changeset
   123
local
c35381811d5c Initial revision.
berghofe
parents:
diff changeset
   124
27809
a1e409db516b unified Args.T with OuterLex.token, renamed some operations;
wenzelm
parents: 27370
diff changeset
   125
structure P = OuterParse;
a1e409db516b unified Args.T with OuterLex.token, renamed some operations;
wenzelm
parents: 27370
diff changeset
   126
18583
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
   127
val avoidingN = "avoiding";
20998
714a08286899 To be consistent with "induct", I renamed "fixing" to "arbitrary".
urbanc
parents: 20288
diff changeset
   128
val fixingN = "arbitrary";  (* to be consistent with induct; hopefully this changes again *)
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
   129
val ruleN = "rule";
17870
c35381811d5c Initial revision.
berghofe
parents:
diff changeset
   130
19036
73782d21e855 Adapted to Context.generic syntax.
berghofe
parents: 18610
diff changeset
   131
val inst = Scan.lift (Args.$$$ "_") >> K NONE || Args.term >> SOME;
17870
c35381811d5c Initial revision.
berghofe
parents:
diff changeset
   132
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
   133
val def_inst =
28083
103d9282a946 explicit type Name.binding for higher-specification elements;
wenzelm
parents: 27809
diff changeset
   134
  ((Scan.lift (Args.binding --| (Args.$$$ "\<equiv>" || Args.$$$ "==")) >> SOME)
19036
73782d21e855 Adapted to Context.generic syntax.
berghofe
parents: 18610
diff changeset
   135
      -- Args.term) >> SOME ||
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
   136
    inst >> Option.map (pair NONE);
18099
e956b04fea22 fixed bug with nominal induct
urbanc
parents: 18052
diff changeset
   137
27370
8e8f96dfaf63 Args.context;
wenzelm
parents: 26940
diff changeset
   138
val free = Args.context -- Args.term >> (fn (_, Free v) => v | (ctxt, t) =>
8e8f96dfaf63 Args.context;
wenzelm
parents: 26940
diff changeset
   139
  error ("Bad free variable: " ^ Syntax.string_of_term ctxt t));
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
   140
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
   141
fun unless_more_args scan = Scan.unless (Scan.lift
18583
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
   142
  ((Args.$$$ avoidingN || Args.$$$ fixingN || Args.$$$ ruleN) -- Args.colon)) scan;
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
   143
17870
c35381811d5c Initial revision.
berghofe
parents:
diff changeset
   144
18583
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
   145
val avoiding = Scan.optional (Scan.lift (Args.$$$ avoidingN -- Args.colon) |--
18297
116fe71fad51 fresh: frees instead of terms, rename corresponding params in rule;
wenzelm
parents: 18288
diff changeset
   146
  Scan.repeat (unless_more_args free)) [];
17870
c35381811d5c Initial revision.
berghofe
parents:
diff changeset
   147
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
   148
val fixing = Scan.optional (Scan.lift (Args.$$$ fixingN -- Args.colon) |--
27809
a1e409db516b unified Args.T with OuterLex.token, renamed some operations;
wenzelm
parents: 27370
diff changeset
   149
  P.and_list' (Scan.repeat (unless_more_args free))) [];
17870
c35381811d5c Initial revision.
berghofe
parents:
diff changeset
   150
19036
73782d21e855 Adapted to Context.generic syntax.
berghofe
parents: 18610
diff changeset
   151
val rule_spec = Scan.lift (Args.$$$ "rule" -- Args.colon) |-- Attrib.thms;
17870
c35381811d5c Initial revision.
berghofe
parents:
diff changeset
   152
c35381811d5c Initial revision.
berghofe
parents:
diff changeset
   153
in
c35381811d5c Initial revision.
berghofe
parents:
diff changeset
   154
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
   155
fun nominal_induct_method src =
18583
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
   156
  Method.syntax
27809
a1e409db516b unified Args.T with OuterLex.token, renamed some operations;
wenzelm
parents: 27370
diff changeset
   157
   (P.and_list' (Scan.repeat (unless_more_args def_inst)) --
18583
96e1ef2f806f proper handling of simultaneous goals and mutual rules;
wenzelm
parents: 18311
diff changeset
   158
    avoiding -- fixing -- rule_spec) src
21879
a3efbae45735 switched argument order in *.syntax lifters
haftmann
parents: 20998
diff changeset
   159
  #> (fn ((((x, y), z), w), ctxt) =>
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
   160
    Method.RAW_METHOD_CASES (fn facts =>
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
   161
      HEADGOAL (nominal_induct_tac ctxt x y z w facts)));
17870
c35381811d5c Initial revision.
berghofe
parents:
diff changeset
   162
c35381811d5c Initial revision.
berghofe
parents:
diff changeset
   163
end;
18283
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
   164
f8a49f09a202 reworked version with proper support for defs, fixes, fresh specification;
wenzelm
parents: 18265
diff changeset
   165
end;