src/Pure/Isar/method.ML
author wenzelm
Tue, 07 Sep 1999 16:57:28 +0200
changeset 7504 0fec51813079
parent 7439 a1b3310b4985
child 7506 08a88d4ebd54
permissions -rw-r--r--
then_tac = refine;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/Isar/method.ML
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
     3
    Author:     Markus Wenzel, TU Muenchen
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
     4
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
     5
Proof methods.
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
     6
*)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
     7
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
     8
signature BASIC_METHOD =
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
     9
sig
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    10
  val print_methods: theory -> unit
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    11
  val Method: bstring -> (Args.src -> Proof.context -> Proof.method) -> string -> unit
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    12
end;
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    13
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    14
signature METHOD =
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    15
sig
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    16
  include BASIC_METHOD
6091
e3cdbd929a24 eliminated tthm type and Attribute structure;
wenzelm
parents: 5921
diff changeset
    17
  val METHOD: (thm list -> tactic) -> Proof.method
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    18
  val METHOD0: tactic -> Proof.method
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    19
  val fail: Proof.method
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    20
  val succeed: Proof.method
7419
wenzelm
parents: 7367
diff changeset
    21
  val insert_tac: thm list -> int -> tactic
wenzelm
parents: 7367
diff changeset
    22
  val insert: Proof.method
wenzelm
parents: 7367
diff changeset
    23
  val fold: thm list -> Proof.method
wenzelm
parents: 7367
diff changeset
    24
  val unfold: thm list -> Proof.method
wenzelm
parents: 7367
diff changeset
    25
  val multi_resolve: thm list -> thm -> thm Seq.seq
wenzelm
parents: 7367
diff changeset
    26
  val multi_resolves: thm list -> thm list -> thm Seq.seq
6091
e3cdbd929a24 eliminated tthm type and Attribute structure;
wenzelm
parents: 5921
diff changeset
    27
  val rule_tac: thm list -> thm list -> int -> tactic
7130
a17f7b5ac40f added erule;
wenzelm
parents: 6981
diff changeset
    28
  val erule_tac: thm list -> thm list -> int -> tactic
6091
e3cdbd929a24 eliminated tthm type and Attribute structure;
wenzelm
parents: 5921
diff changeset
    29
  val rule: thm list -> Proof.method
7130
a17f7b5ac40f added erule;
wenzelm
parents: 6981
diff changeset
    30
  val erule: thm list -> Proof.method
7419
wenzelm
parents: 7367
diff changeset
    31
  val assumption: Proof.method
5916
4039395e29ce exception METHOD_FAIL;
wenzelm
parents: 5884
diff changeset
    32
  exception METHOD_FAIL of (string * Position.T) * exn
7419
wenzelm
parents: 7367
diff changeset
    33
  val help_methods: theory -> unit
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    34
  val method: theory -> Args.src -> Proof.context -> Proof.method
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    35
  val add_methods: (bstring * (Args.src -> Proof.context -> Proof.method) * string) list
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    36
    -> theory -> theory
5884
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
    37
  val syntax: (Proof.context * Args.T list -> 'a * (Proof.context * Args.T list)) ->
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
    38
    Proof.context -> Args.src -> Proof.context * 'a
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
    39
  val no_args: Proof.method -> Args.src -> Proof.context -> Proof.method
7268
315655dc361b sectioned_args etc.: more general modifier;
wenzelm
parents: 7130
diff changeset
    40
  type modifier
315655dc361b sectioned_args etc.: more general modifier;
wenzelm
parents: 7130
diff changeset
    41
  val sectioned_args: ((Args.T list -> modifier * Args.T list) list ->
5884
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
    42
      Proof.context * Args.T list -> 'a * (Proof.context * Args.T list)) ->
7268
315655dc361b sectioned_args etc.: more general modifier;
wenzelm
parents: 7130
diff changeset
    43
    (Args.T list -> modifier * Args.T list) list ->
5884
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
    44
    ('a -> Proof.context -> Proof.method) -> Args.src -> Proof.context -> Proof.method
7268
315655dc361b sectioned_args etc.: more general modifier;
wenzelm
parents: 7130
diff changeset
    45
  val default_sectioned_args: modifier ->
315655dc361b sectioned_args etc.: more general modifier;
wenzelm
parents: 7130
diff changeset
    46
    (Args.T list -> modifier * Args.T list) list ->
5884
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
    47
    (Proof.context -> Proof.method) -> Args.src -> Proof.context -> Proof.method
7268
315655dc361b sectioned_args etc.: more general modifier;
wenzelm
parents: 7130
diff changeset
    48
  val only_sectioned_args: (Args.T list -> modifier * Args.T list) list ->
5884
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
    49
    (Proof.context -> Proof.method) -> Args.src -> Proof.context -> Proof.method
6091
e3cdbd929a24 eliminated tthm type and Attribute structure;
wenzelm
parents: 5921
diff changeset
    50
  val thms_args: (thm list -> Proof.method) -> Args.src -> Proof.context -> Proof.method
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    51
  datatype text =
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    52
    Basic of (Proof.context -> Proof.method) |
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    53
    Source of Args.src |
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    54
    Then of text list |
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    55
    Orelse of text list |
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    56
    Try of text |
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    57
    Repeat1 of text
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    58
  val refine: text -> Proof.state -> Proof.state Seq.seq
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    59
  val tac: text -> Proof.state -> Proof.state Seq.seq
5884
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
    60
  val then_tac: text -> Proof.state -> Proof.state Seq.seq
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    61
  val proof: text option -> Proof.state -> Proof.state Seq.seq
6981
eaade7e398a7 export assumption_tac;
wenzelm
parents: 6951
diff changeset
    62
  val local_qed: text option
eaade7e398a7 export assumption_tac;
wenzelm
parents: 6951
diff changeset
    63
    -> ({kind: string, name: string, thm: thm} -> unit) * (thm -> unit)
6736
a0b2cfa12d0d local_qed: print_result;
wenzelm
parents: 6683
diff changeset
    64
    -> Proof.state -> Proof.state Seq.seq
6981
eaade7e398a7 export assumption_tac;
wenzelm
parents: 6951
diff changeset
    65
  val local_terminal_proof: text * text option
eaade7e398a7 export assumption_tac;
wenzelm
parents: 6951
diff changeset
    66
    -> ({kind: string, name: string, thm: thm} -> unit) * (thm -> unit)
6736
a0b2cfa12d0d local_qed: print_result;
wenzelm
parents: 6683
diff changeset
    67
    -> Proof.state -> Proof.state Seq.seq
6981
eaade7e398a7 export assumption_tac;
wenzelm
parents: 6951
diff changeset
    68
  val local_immediate_proof: ({kind: string, name: string, thm: thm} -> unit) * (thm -> unit)
eaade7e398a7 export assumption_tac;
wenzelm
parents: 6951
diff changeset
    69
    -> Proof.state -> Proof.state Seq.seq
eaade7e398a7 export assumption_tac;
wenzelm
parents: 6951
diff changeset
    70
  val local_default_proof: ({kind: string, name: string, thm: thm} -> unit) * (thm -> unit)
6736
a0b2cfa12d0d local_qed: print_result;
wenzelm
parents: 6683
diff changeset
    71
    -> Proof.state -> Proof.state Seq.seq
6951
13399b560e4e global_qed: removed alt_name, alt_att;
wenzelm
parents: 6934
diff changeset
    72
  val global_qed: text option -> Proof.state -> theory * {kind: string, name: string, thm: thm}
6934
04d051190a5f terminal_proof: 2nd method;
wenzelm
parents: 6872
diff changeset
    73
  val global_terminal_proof: text * text option
04d051190a5f terminal_proof: 2nd method;
wenzelm
parents: 6872
diff changeset
    74
    -> Proof.state -> theory * {kind: string, name: string, thm: thm}
6532
9d79a304aecc fold / unfold methods;
wenzelm
parents: 6500
diff changeset
    75
  val global_immediate_proof: Proof.state -> theory * {kind: string, name: string, thm: thm}
9d79a304aecc fold / unfold methods;
wenzelm
parents: 6500
diff changeset
    76
  val global_default_proof: Proof.state -> theory * {kind: string, name: string, thm: thm}
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    77
  val setup: (theory -> theory) list
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    78
end;
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    79
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    80
structure Method: METHOD =
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    81
struct
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    82
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    83
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    84
(** proof methods **)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    85
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    86
(* method from tactic *)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    87
6849
0b660860c0ad cond_extern_table;
wenzelm
parents: 6775
diff changeset
    88
val METHOD = Proof.method;
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    89
fun METHOD0 tac = METHOD (fn [] => tac | _ => error "Method may not be used with facts");
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    90
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    91
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    92
(* primitive *)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    93
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    94
val fail = METHOD (K no_tac);
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    95
val succeed = METHOD (K all_tac);
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    96
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
    97
7419
wenzelm
parents: 7367
diff changeset
    98
(* insert *)
wenzelm
parents: 7367
diff changeset
    99
wenzelm
parents: 7367
diff changeset
   100
local
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   101
6981
eaade7e398a7 export assumption_tac;
wenzelm
parents: 6951
diff changeset
   102
fun cut_rule_tac raw_rule =
eaade7e398a7 export assumption_tac;
wenzelm
parents: 6951
diff changeset
   103
  let
eaade7e398a7 export assumption_tac;
wenzelm
parents: 6951
diff changeset
   104
    val rule = Drule.forall_intr_vars raw_rule;
eaade7e398a7 export assumption_tac;
wenzelm
parents: 6951
diff changeset
   105
    val revcut_rl = Drule.incr_indexes_wrt [] [] [] [rule] Drule.revcut_rl;
eaade7e398a7 export assumption_tac;
wenzelm
parents: 6951
diff changeset
   106
  in Tactic.rtac (rule COMP revcut_rl) THEN' Tactic.rotate_tac ~1 end;
eaade7e398a7 export assumption_tac;
wenzelm
parents: 6951
diff changeset
   107
7419
wenzelm
parents: 7367
diff changeset
   108
in
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   109
7419
wenzelm
parents: 7367
diff changeset
   110
fun insert_tac [] i = all_tac
wenzelm
parents: 7367
diff changeset
   111
  | insert_tac facts i = EVERY (map (fn th => cut_rule_tac th i) facts);
6981
eaade7e398a7 export assumption_tac;
wenzelm
parents: 6951
diff changeset
   112
7419
wenzelm
parents: 7367
diff changeset
   113
val insert = METHOD (ALLGOALS o insert_tac);
wenzelm
parents: 7367
diff changeset
   114
wenzelm
parents: 7367
diff changeset
   115
end;
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   116
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   117
6532
9d79a304aecc fold / unfold methods;
wenzelm
parents: 6500
diff changeset
   118
(* fold / unfold definitions *)
9d79a304aecc fold / unfold methods;
wenzelm
parents: 6500
diff changeset
   119
9d79a304aecc fold / unfold methods;
wenzelm
parents: 6500
diff changeset
   120
val fold = METHOD0 o fold_goals_tac;
9d79a304aecc fold / unfold methods;
wenzelm
parents: 6500
diff changeset
   121
val unfold = METHOD0 o rewrite_goals_tac;
9d79a304aecc fold / unfold methods;
wenzelm
parents: 6500
diff changeset
   122
9d79a304aecc fold / unfold methods;
wenzelm
parents: 6500
diff changeset
   123
7419
wenzelm
parents: 7367
diff changeset
   124
(* multi_resolve *)
wenzelm
parents: 7367
diff changeset
   125
wenzelm
parents: 7367
diff changeset
   126
local
wenzelm
parents: 7367
diff changeset
   127
wenzelm
parents: 7367
diff changeset
   128
fun res th i rule =
wenzelm
parents: 7367
diff changeset
   129
  Thm.biresolution false [(false, th)] i rule handle THM _ => Seq.empty;
wenzelm
parents: 7367
diff changeset
   130
wenzelm
parents: 7367
diff changeset
   131
fun multi_res _ [] rule = Seq.single rule
wenzelm
parents: 7367
diff changeset
   132
  | multi_res i (th :: ths) rule = Seq.flat (Seq.map (res th i) (multi_res (i + 1) ths rule));
wenzelm
parents: 7367
diff changeset
   133
wenzelm
parents: 7367
diff changeset
   134
in
wenzelm
parents: 7367
diff changeset
   135
wenzelm
parents: 7367
diff changeset
   136
val multi_resolve = multi_res 1;
wenzelm
parents: 7367
diff changeset
   137
fun multi_resolves facts rules = Seq.flat (Seq.map (multi_resolve facts) (Seq.of_list rules));
wenzelm
parents: 7367
diff changeset
   138
wenzelm
parents: 7367
diff changeset
   139
end;
wenzelm
parents: 7367
diff changeset
   140
wenzelm
parents: 7367
diff changeset
   141
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   142
(* rule *)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   143
7419
wenzelm
parents: 7367
diff changeset
   144
local
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   145
7130
a17f7b5ac40f added erule;
wenzelm
parents: 6981
diff changeset
   146
fun gen_rule_tac tac rules [] = tac rules
a17f7b5ac40f added erule;
wenzelm
parents: 6981
diff changeset
   147
  | gen_rule_tac tac erules facts =
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   148
      let
7419
wenzelm
parents: 7367
diff changeset
   149
        val rules = multi_resolves facts erules;
7130
a17f7b5ac40f added erule;
wenzelm
parents: 6981
diff changeset
   150
        fun tactic i state = Seq.flat (Seq.map (fn rule => tac [rule] i state) rules);
a17f7b5ac40f added erule;
wenzelm
parents: 6981
diff changeset
   151
      in tactic end;
a17f7b5ac40f added erule;
wenzelm
parents: 6981
diff changeset
   152
7419
wenzelm
parents: 7367
diff changeset
   153
in
wenzelm
parents: 7367
diff changeset
   154
7130
a17f7b5ac40f added erule;
wenzelm
parents: 6981
diff changeset
   155
val rule_tac = gen_rule_tac Tactic.resolve_tac;
a17f7b5ac40f added erule;
wenzelm
parents: 6981
diff changeset
   156
val erule_tac = gen_rule_tac Tactic.eresolve_tac;
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   157
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   158
fun rule rules = METHOD (FIRSTGOAL o rule_tac rules);
7130
a17f7b5ac40f added erule;
wenzelm
parents: 6981
diff changeset
   159
fun erule rules = METHOD (FIRSTGOAL o erule_tac rules);
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   160
7419
wenzelm
parents: 7367
diff changeset
   161
end;
wenzelm
parents: 7367
diff changeset
   162
wenzelm
parents: 7367
diff changeset
   163
wenzelm
parents: 7367
diff changeset
   164
(* assumption *)
wenzelm
parents: 7367
diff changeset
   165
wenzelm
parents: 7367
diff changeset
   166
fun assumption_tac [] = assume_tac
wenzelm
parents: 7367
diff changeset
   167
  | assumption_tac [fact] = resolve_tac [fact]
wenzelm
parents: 7367
diff changeset
   168
  | assumption_tac _ = K no_tac;
wenzelm
parents: 7367
diff changeset
   169
wenzelm
parents: 7367
diff changeset
   170
val assumption = METHOD (FIRSTGOAL o assumption_tac);
wenzelm
parents: 7367
diff changeset
   171
wenzelm
parents: 7367
diff changeset
   172
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   173
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   174
(** methods theory data **)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   175
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   176
(* data kind 'Isar/methods' *)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   177
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   178
structure MethodsDataArgs =
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   179
struct
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   180
  val name = "Isar/methods";
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   181
  type T =
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   182
    {space: NameSpace.T,
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   183
     meths: (((Args.src -> Proof.context -> Proof.method) * string) * stamp) Symtab.table};
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   184
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   185
  val empty = {space = NameSpace.empty, meths = Symtab.empty};
6546
995a66249a9b theory data: copy;
wenzelm
parents: 6532
diff changeset
   186
  val copy = I;
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   187
  val prep_ext = I;
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   188
  fun merge ({space = space1, meths = meths1}, {space = space2, meths = meths2}) =
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   189
    {space = NameSpace.merge (space1, space2),
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   190
      meths = Symtab.merge eq_snd (meths1, meths2) handle Symtab.DUPS dups =>
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   191
        error ("Attempt to merge different versions of methods " ^ commas_quote dups)};
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   192
7367
a79d4683fadf print_help;
wenzelm
parents: 7268
diff changeset
   193
  fun print_meths verbose {space, meths} =
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   194
    let
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   195
      fun prt_meth (name, ((_, comment), _)) = Pretty.block
6849
0b660860c0ad cond_extern_table;
wenzelm
parents: 6775
diff changeset
   196
        [Pretty.str (name ^ ":"), Pretty.brk 2, Pretty.str comment];
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   197
    in
7367
a79d4683fadf print_help;
wenzelm
parents: 7268
diff changeset
   198
      if not verbose then ()
a79d4683fadf print_help;
wenzelm
parents: 7268
diff changeset
   199
      else Pretty.writeln (Display.pretty_name_space ("method name space", space));
6849
0b660860c0ad cond_extern_table;
wenzelm
parents: 6775
diff changeset
   200
      Pretty.writeln (Pretty.big_list "methods:"
0b660860c0ad cond_extern_table;
wenzelm
parents: 6775
diff changeset
   201
        (map prt_meth (NameSpace.cond_extern_table space meths)))
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   202
    end;
7367
a79d4683fadf print_help;
wenzelm
parents: 7268
diff changeset
   203
a79d4683fadf print_help;
wenzelm
parents: 7268
diff changeset
   204
  fun print _ = print_meths true;
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   205
end;
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   206
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   207
structure MethodsData = TheoryDataFun(MethodsDataArgs);
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   208
val print_methods = MethodsData.print;
7367
a79d4683fadf print_help;
wenzelm
parents: 7268
diff changeset
   209
val help_methods = MethodsDataArgs.print_meths false o MethodsData.get;
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   210
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   211
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   212
(* get methods *)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   213
5916
4039395e29ce exception METHOD_FAIL;
wenzelm
parents: 5884
diff changeset
   214
exception METHOD_FAIL of (string * Position.T) * exn;
4039395e29ce exception METHOD_FAIL;
wenzelm
parents: 5884
diff changeset
   215
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   216
fun method thy =
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   217
  let
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   218
    val {space, meths} = MethodsData.get thy;
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   219
5884
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   220
    fun meth src =
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   221
      let
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   222
        val ((raw_name, _), pos) = Args.dest_src src;
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   223
        val name = NameSpace.intern space raw_name;
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   224
      in
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   225
        (case Symtab.lookup (meths, name) of
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   226
          None => error ("Unknown proof method: " ^ quote name ^ Position.str_of pos)
5916
4039395e29ce exception METHOD_FAIL;
wenzelm
parents: 5884
diff changeset
   227
        | Some ((mth, _), _) => transform_failure (curry METHOD_FAIL (name, pos)) (mth src))
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   228
      end;
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   229
  in meth end;
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   230
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   231
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   232
(* add_methods *)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   233
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   234
fun add_methods raw_meths thy =
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   235
  let
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   236
    val full = Sign.full_name (Theory.sign_of thy);
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   237
    val new_meths =
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   238
      map (fn (name, f, comment) => (full name, ((f, comment), stamp ()))) raw_meths;
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   239
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   240
    val {space, meths} = MethodsData.get thy;
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   241
    val space' = NameSpace.extend (space, map fst new_meths);
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   242
    val meths' = Symtab.extend (meths, new_meths) handle Symtab.DUPS dups =>
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   243
      error ("Duplicate declaration of method(s) " ^ commas_quote dups);
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   244
  in
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   245
    thy |> MethodsData.put {space = space', meths = meths'}
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   246
  end;
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   247
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   248
(*implicit version*)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   249
fun Method name meth cmt = Context.>> (add_methods [(name, meth, cmt)]);
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   250
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   251
5884
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   252
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   253
(** method syntax **)
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   254
5884
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   255
(* basic *)
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   256
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   257
fun syntax (scan: (Proof.context * Args.T list -> 'a * (Proof.context * Args.T list))) =
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   258
  Args.syntax "method" scan;
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   259
5884
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   260
fun no_args (x: Proof.method) src ctxt = #2 (syntax (Scan.succeed x) ctxt src);
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   261
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   262
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   263
(* sections *)
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   264
7268
315655dc361b sectioned_args etc.: more general modifier;
wenzelm
parents: 7130
diff changeset
   265
type modifier = (Proof.context -> Proof.context) * Proof.context attribute;
315655dc361b sectioned_args etc.: more general modifier;
wenzelm
parents: 7130
diff changeset
   266
315655dc361b sectioned_args etc.: more general modifier;
wenzelm
parents: 7130
diff changeset
   267
local
315655dc361b sectioned_args etc.: more general modifier;
wenzelm
parents: 7130
diff changeset
   268
5884
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   269
fun sect ss = Scan.first (map (fn s => Scan.lift (s --| Args.$$$ ":")) ss);
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   270
fun thms ss = Scan.unless (sect ss) Attrib.local_thms;
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   271
fun thmss ss = Scan.repeat (thms ss) >> flat;
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   272
7268
315655dc361b sectioned_args etc.: more general modifier;
wenzelm
parents: 7130
diff changeset
   273
fun apply (f, att) (ctxt, ths) = Thm.applys_attributes ((f ctxt, ths), [att]);
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   274
7268
315655dc361b sectioned_args etc.: more general modifier;
wenzelm
parents: 7130
diff changeset
   275
fun section ss = (sect ss -- thmss ss) :-- (fn (m, ths) => Scan.depend (fn ctxt =>
315655dc361b sectioned_args etc.: more general modifier;
wenzelm
parents: 7130
diff changeset
   276
  Scan.succeed (apply m (ctxt, ths)))) >> #2;
5884
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   277
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   278
fun sectioned args ss = args ss -- Scan.repeat (section ss);
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   279
7268
315655dc361b sectioned_args etc.: more general modifier;
wenzelm
parents: 7130
diff changeset
   280
in
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   281
5884
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   282
fun sectioned_args args ss f src ctxt =
5921
50005d6ba609 removed trace;
wenzelm
parents: 5916
diff changeset
   283
  let val (ctxt', (x, _)) = syntax (sectioned args ss) ctxt src
50005d6ba609 removed trace;
wenzelm
parents: 5916
diff changeset
   284
  in f x ctxt' end;
5884
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   285
7268
315655dc361b sectioned_args etc.: more general modifier;
wenzelm
parents: 7130
diff changeset
   286
fun default_sectioned_args m ss f src ctxt =
315655dc361b sectioned_args etc.: more general modifier;
wenzelm
parents: 7130
diff changeset
   287
  sectioned_args thmss ss (fn ths => fn ctxt' => f (#1 (apply m (ctxt', ths)))) src ctxt;
5884
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   288
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   289
fun only_sectioned_args ss f = sectioned_args (K (Scan.succeed ())) ss (fn () => f);
7268
315655dc361b sectioned_args etc.: more general modifier;
wenzelm
parents: 7130
diff changeset
   290
5884
113badd4dae5 several args parsers;
wenzelm
parents: 5824
diff changeset
   291
fun thms_args f = sectioned_args thmss [] (fn ths => fn _ => f ths);
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   292
7268
315655dc361b sectioned_args etc.: more general modifier;
wenzelm
parents: 7130
diff changeset
   293
end;
315655dc361b sectioned_args etc.: more general modifier;
wenzelm
parents: 7130
diff changeset
   294
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   295
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   296
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   297
(** method text **)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   298
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   299
(* datatype text *)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   300
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   301
datatype text =
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   302
  Basic of (Proof.context -> Proof.method) |
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   303
  Source of Args.src |
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   304
  Then of text list |
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   305
  Orelse of text list |
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   306
  Try of text |
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   307
  Repeat1 of text;
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   308
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   309
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   310
(* refine *)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   311
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   312
fun refine text state =
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   313
  let
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   314
    val thy = Proof.theory_of state;
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   315
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   316
    fun eval (Basic mth) = Proof.refine mth
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   317
      | eval (Source src) = Proof.refine (method thy src)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   318
      | eval (Then txts) = Seq.EVERY (map eval txts)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   319
      | eval (Orelse txts) = Seq.FIRST (map eval txts)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   320
      | eval (Try txt) = Seq.TRY (eval txt)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   321
      | eval (Repeat1 txt) = Seq.REPEAT1 (eval txt);
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   322
  in eval text state end;
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   323
6404
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6108
diff changeset
   324
fun named_method name = Source (Args.src ((name, []), Position.none));
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6108
diff changeset
   325
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   326
7439
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   327
(* finish *)
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   328
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   329
local
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   330
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   331
val FINISHED = FILTER (equal 0 o Thm.nprems_of);
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   332
val finish = METHOD (K (FINISHED (ALLGOALS assume_tac)));
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   333
val basic_finish = Basic (K finish);
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   334
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   335
in
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   336
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   337
fun finish_text None = basic_finish
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   338
  | finish_text (Some txt) = Then [txt, basic_finish];
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   339
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   340
end;
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   341
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   342
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   343
(* unstructured steps *)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   344
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   345
fun tac text state =
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   346
  state
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   347
  |> Proof.goal_facts (K [])
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   348
  |> refine text;
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   349
7504
0fec51813079 then_tac = refine;
wenzelm
parents: 7439
diff changeset
   350
val then_tac = refine;
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   351
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   352
6404
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6108
diff changeset
   353
(* structured proof steps *)
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   354
6404
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6108
diff changeset
   355
val default_text = named_method "default";
7439
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   356
val assumption_text = Basic (K assumption);
6872
b250da153b1e fixed backtracking of global_qed;
wenzelm
parents: 6849
diff changeset
   357
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   358
fun proof opt_text state =
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   359
  state
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   360
  |> Proof.assert_backward
6404
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6108
diff changeset
   361
  |> refine (if_none opt_text default_text)
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   362
  |> Seq.map Proof.enter_forward;
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   363
7439
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   364
fun local_qed opt_text = Proof.local_qed (refine (finish_text opt_text));
6934
04d051190a5f terminal_proof: 2nd method;
wenzelm
parents: 6872
diff changeset
   365
fun local_terminal_proof (text, opt_text) pr = Seq.THEN (proof (Some text), local_qed opt_text pr);
7439
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   366
val local_immediate_proof = local_terminal_proof (assumption_text, None);
6934
04d051190a5f terminal_proof: 2nd method;
wenzelm
parents: 6872
diff changeset
   367
val local_default_proof = local_terminal_proof (default_text, None);
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   368
6872
b250da153b1e fixed backtracking of global_qed;
wenzelm
parents: 6849
diff changeset
   369
7439
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   370
fun global_qeds opt_text = Proof.global_qed (refine (finish_text opt_text));
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   371
6951
13399b560e4e global_qed: removed alt_name, alt_att;
wenzelm
parents: 6934
diff changeset
   372
fun global_qed opt_text state =
6872
b250da153b1e fixed backtracking of global_qed;
wenzelm
parents: 6849
diff changeset
   373
  state
6951
13399b560e4e global_qed: removed alt_name, alt_att;
wenzelm
parents: 6934
diff changeset
   374
  |> global_qeds opt_text
6872
b250da153b1e fixed backtracking of global_qed;
wenzelm
parents: 6849
diff changeset
   375
  |> Proof.check_result "Failed to finish proof" state
b250da153b1e fixed backtracking of global_qed;
wenzelm
parents: 6849
diff changeset
   376
  |> Seq.hd;
b250da153b1e fixed backtracking of global_qed;
wenzelm
parents: 6849
diff changeset
   377
6934
04d051190a5f terminal_proof: 2nd method;
wenzelm
parents: 6872
diff changeset
   378
fun global_terminal_proof (text, opt_text) state =
6872
b250da153b1e fixed backtracking of global_qed;
wenzelm
parents: 6849
diff changeset
   379
  state
b250da153b1e fixed backtracking of global_qed;
wenzelm
parents: 6849
diff changeset
   380
  |> proof (Some text)
b250da153b1e fixed backtracking of global_qed;
wenzelm
parents: 6849
diff changeset
   381
  |> Proof.check_result "Terminal proof method failed" state
6951
13399b560e4e global_qed: removed alt_name, alt_att;
wenzelm
parents: 6934
diff changeset
   382
  |> (Seq.flat o Seq.map (global_qeds opt_text))
6872
b250da153b1e fixed backtracking of global_qed;
wenzelm
parents: 6849
diff changeset
   383
  |> Proof.check_result "Failed to finish proof (after successful terminal method)" state
b250da153b1e fixed backtracking of global_qed;
wenzelm
parents: 6849
diff changeset
   384
  |> Seq.hd;
b250da153b1e fixed backtracking of global_qed;
wenzelm
parents: 6849
diff changeset
   385
7439
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   386
val global_immediate_proof = global_terminal_proof (assumption_text, None);
6934
04d051190a5f terminal_proof: 2nd method;
wenzelm
parents: 6872
diff changeset
   387
val global_default_proof = global_terminal_proof (default_text, None);
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   388
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   389
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   390
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   391
(** theory setup **)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   392
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   393
(* pure_methods *)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   394
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   395
val pure_methods =
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   396
 [("fail", no_args fail, "force failure"),
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   397
  ("succeed", no_args succeed, "succeed"),
7419
wenzelm
parents: 7367
diff changeset
   398
  ("-", no_args insert, "insert facts, nothing else"),
6532
9d79a304aecc fold / unfold methods;
wenzelm
parents: 6500
diff changeset
   399
  ("fold", thms_args fold, "fold definitions"),
9d79a304aecc fold / unfold methods;
wenzelm
parents: 6500
diff changeset
   400
  ("unfold", thms_args unfold, "unfold definitions"),
7130
a17f7b5ac40f added erule;
wenzelm
parents: 6981
diff changeset
   401
  ("rule", thms_args rule, "apply some rule"),
7419
wenzelm
parents: 7367
diff changeset
   402
  ("erule", thms_args erule, "apply some erule (improper!)"),
7439
a1b3310b4985 terminal method: always involve finish;
wenzelm
parents: 7419
diff changeset
   403
  ("assumption", no_args assumption, "proof by assumption")];
5824
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   404
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   405
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   406
(* setup *)
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   407
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   408
val setup = [MethodsData.init, add_methods pure_methods];
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   409
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   410
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   411
end;
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   412
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   413
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   414
structure BasicMethod: BASIC_METHOD = Method;
91113aa09371 Proof methods.
wenzelm
parents:
diff changeset
   415
open BasicMethod;