src/Provers/clasimp.ML
author wenzelm
Tue Mar 05 20:55:20 2002 +0100 (2002-03-05)
changeset 13026 e45ebbb2e18e
parent 12375 539a32568db3
child 13603 57f364d1d3b2
permissions -rw-r--r--
iff: conditional rules declared as ``unsafe'';
wenzelm@9772
     1
(*  Title:      Provers/clasimp.ML
oheimb@4652
     2
    ID:         $Id$
oheimb@4652
     3
    Author:     David von Oheimb, TU Muenchen
wenzelm@12375
     4
    License:    GPL (GNU GENERAL PUBLIC LICENSE)
oheimb@4652
     5
wenzelm@5219
     6
Combination of classical reasoner and simplifier (depends on
wenzelm@8469
     7
simplifier.ML, splitter.ML classical.ML, blast.ML).
oheimb@4652
     8
*)
oheimb@4652
     9
wenzelm@9860
    10
infix 4 addSIs2 addSEs2 addSDs2 addIs2 addEs2 addDs2 addsimps2 delsimps2
wenzelm@9860
    11
  addSss addss addIffs delIffs;
oheimb@4652
    12
wenzelm@5219
    13
signature CLASIMP_DATA =
wenzelm@5219
    14
sig
wenzelm@5219
    15
  structure Simplifier: SIMPLIFIER
wenzelm@8469
    16
  structure Splitter: SPLITTER
wenzelm@5219
    17
  structure Classical: CLASSICAL
wenzelm@5219
    18
  structure Blast: BLAST
wenzelm@5219
    19
  sharing type Classical.claset = Blast.claset
wenzelm@9860
    20
  val notE: thm
wenzelm@9860
    21
  val iffD1: thm
wenzelm@9860
    22
  val iffD2: thm
wenzelm@9860
    23
  val cla_make_elim: thm -> thm
wenzelm@5219
    24
end
wenzelm@5219
    25
oheimb@4652
    26
signature CLASIMP =
oheimb@4652
    27
sig
wenzelm@5219
    28
  include CLASIMP_DATA
wenzelm@5219
    29
  type claset
wenzelm@5219
    30
  type simpset
wenzelm@5219
    31
  type clasimpset
wenzelm@10317
    32
  val clasimpset: unit -> clasimpset
wenzelm@9860
    33
  val addSIs2: clasimpset * thm list -> clasimpset
wenzelm@9860
    34
  val addSEs2: clasimpset * thm list -> clasimpset
wenzelm@9860
    35
  val addSDs2: clasimpset * thm list -> clasimpset
wenzelm@9860
    36
  val addIs2: clasimpset * thm list -> clasimpset
wenzelm@9860
    37
  val addEs2: clasimpset * thm list -> clasimpset
wenzelm@9860
    38
  val addDs2: clasimpset * thm list -> clasimpset
wenzelm@9860
    39
  val addsimps2: clasimpset * thm list -> clasimpset
wenzelm@9860
    40
  val delsimps2: clasimpset * thm list -> clasimpset
wenzelm@9860
    41
  val addSss: claset * simpset -> claset
wenzelm@9860
    42
  val addss: claset * simpset -> claset
wenzelm@9860
    43
  val addIffs: clasimpset * thm list -> clasimpset
wenzelm@9860
    44
  val delIffs: clasimpset * thm list -> clasimpset
wenzelm@9860
    45
  val AddIffs: thm list -> unit
wenzelm@9860
    46
  val DelIffs: thm list -> unit
wenzelm@9860
    47
  val CLASIMPSET: (clasimpset -> tactic) -> tactic
wenzelm@9860
    48
  val CLASIMPSET': (clasimpset -> 'a -> tactic) -> 'a -> tactic
oheimb@5483
    49
  val clarsimp_tac: clasimpset -> int -> tactic
wenzelm@9860
    50
  val Clarsimp_tac: int -> tactic
wenzelm@9860
    51
  val mk_auto_tac: clasimpset -> int -> int -> tactic
wenzelm@9860
    52
  val auto_tac: clasimpset -> tactic
wenzelm@9860
    53
  val Auto_tac: tactic
wenzelm@9860
    54
  val auto: unit -> unit
wenzelm@9860
    55
  val force_tac: clasimpset  -> int -> tactic
wenzelm@9860
    56
  val Force_tac: int -> tactic
wenzelm@9860
    57
  val force: int -> unit
wenzelm@9860
    58
  val fast_simp_tac: clasimpset -> int -> tactic
wenzelm@9860
    59
  val slow_simp_tac: clasimpset -> int -> tactic
wenzelm@9860
    60
  val best_simp_tac: clasimpset -> int -> tactic
wenzelm@8639
    61
  val change_global_css: (clasimpset * thm list -> clasimpset) -> theory attribute
wenzelm@8639
    62
  val change_local_css: (clasimpset * thm list -> clasimpset) -> Proof.context attribute
wenzelm@9506
    63
  val get_local_clasimpset: Proof.context -> clasimpset
wenzelm@9860
    64
  val iff_add_global: theory attribute
wenzelm@10033
    65
  val iff_add_global': theory attribute
wenzelm@9860
    66
  val iff_del_global: theory attribute
wenzelm@9860
    67
  val iff_add_local: Proof.context attribute
wenzelm@10033
    68
  val iff_add_local': Proof.context attribute
wenzelm@9860
    69
  val iff_del_local: Proof.context attribute
wenzelm@9860
    70
  val iff_modifiers: (Args.T list -> (Method.modifier * Args.T list)) list
wenzelm@9506
    71
  val clasimp_modifiers: (Args.T list -> (Method.modifier * Args.T list)) list
wenzelm@9860
    72
  val setup: (theory -> theory) list
oheimb@4652
    73
end;
oheimb@4652
    74
wenzelm@5219
    75
functor ClasimpFun(Data: CLASIMP_DATA): CLASIMP =
oheimb@4652
    76
struct
oheimb@4652
    77
wenzelm@5219
    78
open Data;
wenzelm@5219
    79
wenzelm@5219
    80
type claset = Classical.claset;
wenzelm@5219
    81
type simpset = Simplifier.simpset;
wenzelm@5219
    82
type clasimpset = claset * simpset;
wenzelm@5219
    83
wenzelm@10317
    84
fun clasimpset () = (Classical.claset (), Simplifier.simpset ());
wenzelm@10317
    85
wenzelm@5219
    86
wenzelm@5219
    87
(* clasimpset operations *)
wenzelm@5219
    88
wenzelm@5219
    89
(*this interface for updating a clasimpset is rudimentary and just for
wenzelm@5219
    90
  convenience for the most common cases*)
wenzelm@5219
    91
wenzelm@5219
    92
fun pair_upd1 f ((a,b),x) = (f(a,x), b);
wenzelm@5219
    93
fun pair_upd2 f ((a,b),x) = (a, f(b,x));
wenzelm@5219
    94
wenzelm@5219
    95
fun op addSIs2   arg = pair_upd1 Classical.addSIs arg;
wenzelm@5219
    96
fun op addSEs2   arg = pair_upd1 Classical.addSEs arg;
wenzelm@5219
    97
fun op addSDs2   arg = pair_upd1 Classical.addSDs arg;
wenzelm@5219
    98
fun op addIs2    arg = pair_upd1 Classical.addIs arg;
wenzelm@5219
    99
fun op addEs2    arg = pair_upd1 Classical.addEs arg;
wenzelm@5219
   100
fun op addDs2    arg = pair_upd1 Classical.addDs arg;
wenzelm@5219
   101
fun op addsimps2 arg = pair_upd2 Simplifier.addsimps arg;
wenzelm@5219
   102
fun op delsimps2 arg = pair_upd2 Simplifier.delsimps arg;
oheimb@4652
   103
oheimb@9402
   104
(*not totally safe: may instantiate unknowns that appear also in other subgoals*)
oheimb@9402
   105
val safe_asm_full_simp_tac = Simplifier.generic_simp_tac true (true,true,true);
oheimb@9402
   106
oheimb@4652
   107
(*Add a simpset to a classical set!*)
oheimb@4652
   108
(*Caution: only one simpset added can be added by each of addSss and addss*)
oheimb@11181
   109
fun cs addSss ss = Classical.addSafter (cs, ("safe_asm_full_simp_tac",
wenzelm@9772
   110
                            CHANGED o safe_asm_full_simp_tac ss));
wenzelm@9772
   111
fun cs addss  ss = Classical.addbefore  (cs, ("asm_full_simp_tac",
wenzelm@9772
   112
                            CHANGED o Simplifier.asm_full_simp_tac ss));
oheimb@4652
   113
wenzelm@9860
   114
wenzelm@9860
   115
(* iffs: addition of rules to simpsets and clasets simultaneously *)
wenzelm@9860
   116
oheimb@11344
   117
(*Takes (possibly conditional) theorems of the form A<->B to
wenzelm@9860
   118
        the Safe Intr     rule B==>A and
wenzelm@9860
   119
        the Safe Destruct rule A==>B.
wenzelm@9860
   120
  Also ~A goes to the Safe Elim rule A ==> ?R
paulson@11462
   121
  Failing other cases, A is added as a Safe Intr rule*)
wenzelm@9860
   122
local
wenzelm@9860
   123
wenzelm@13026
   124
fun addIff decls1 decls2 simp ((cs, ss), th) =
wenzelm@13026
   125
  let
wenzelm@13026
   126
    val n = nprems_of th;
wenzelm@13026
   127
    val (dest, elim, intro) = if n = 0 then decls1 else decls2;
wenzelm@13026
   128
    val zero_rotate = zero_var_indexes o rotate_prems n;
wenzelm@13026
   129
  in
wenzelm@11902
   130
    (dest (intro (cs, [zero_rotate (th RS Data.iffD2)]), [zero_rotate (th RS Data.iffD1)])
wenzelm@11902
   131
      handle THM _ => (elim (cs, [zero_rotate (th RS Data.notE)])
wenzelm@11902
   132
        handle THM _ => intro (cs, [th])),
wenzelm@11902
   133
     simp (ss, [th]))
wenzelm@11902
   134
  end;
wenzelm@9860
   135
wenzelm@12375
   136
fun delIff delcs delss ((cs, ss), th) =
wenzelm@11902
   137
  let val zero_rotate = zero_var_indexes o rotate_prems (nprems_of th) in
wenzelm@12375
   138
    (delcs (cs, [zero_rotate (th RS Data.iffD2),
wenzelm@11902
   139
        Data.cla_make_elim (zero_rotate (th RS Data.iffD1))])
wenzelm@12375
   140
      handle THM _ => (delcs (cs, [zero_rotate (th RS Data.notE)])
wenzelm@12375
   141
        handle THM _ => delcs (cs, [th])),
wenzelm@12375
   142
     delss (ss, [th]))
wenzelm@11902
   143
  end;
wenzelm@9860
   144
wenzelm@10033
   145
fun store_clasimp (cs, ss) =
wenzelm@10033
   146
  (Classical.claset_ref () := cs; Simplifier.simpset_ref () := ss);
wenzelm@9860
   147
wenzelm@9860
   148
in
wenzelm@9860
   149
wenzelm@10033
   150
val op addIffs =
wenzelm@13026
   151
  foldl (addIff (Classical.addSDs, Classical.addSEs, Classical.addSIs)
wenzelm@13026
   152
    (Classical.addDs, Classical.addEs, Classical.addIs) Simplifier.addsimps);
wenzelm@12375
   153
val op delIffs = foldl (delIff Classical.delrules Simplifier.delsimps);
wenzelm@10033
   154
wenzelm@10317
   155
fun AddIffs thms = store_clasimp (clasimpset () addIffs thms);
wenzelm@10317
   156
fun DelIffs thms = store_clasimp (clasimpset () delIffs thms);
wenzelm@9860
   157
wenzelm@12375
   158
fun addIffs_global (thy, ths) =
wenzelm@13026
   159
  foldl (addIff
wenzelm@13026
   160
    (ContextRules.addXDs_global, ContextRules.addXEs_global, ContextRules.addXIs_global)
wenzelm@13026
   161
    (ContextRules.addXDs_global, ContextRules.addXEs_global, ContextRules.addXIs_global) #1)
wenzelm@13026
   162
  ((thy, ()), ths) |> #1;
wenzelm@12375
   163
wenzelm@12375
   164
fun addIffs_local (ctxt, ths) =
wenzelm@13026
   165
  foldl (addIff
wenzelm@13026
   166
    (ContextRules.addXDs_local, ContextRules.addXEs_local, ContextRules.addXIs_local)
wenzelm@13026
   167
    (ContextRules.addXDs_local, ContextRules.addXEs_local, ContextRules.addXIs_local) #1)
wenzelm@13026
   168
  ((ctxt, ()), ths) |> #1;
wenzelm@12375
   169
wenzelm@12375
   170
fun delIffs_global (thy, ths) =
wenzelm@12375
   171
  foldl (delIff ContextRules.delrules_global #1) ((thy, ()), ths) |> #1;
wenzelm@12375
   172
wenzelm@12375
   173
fun delIffs_local (ctxt, ths) =
wenzelm@12375
   174
  foldl (delIff ContextRules.delrules_local #1) ((ctxt, ()), ths) |> #1;
wenzelm@12375
   175
wenzelm@9860
   176
end;
wenzelm@9860
   177
wenzelm@9860
   178
wenzelm@5219
   179
(* tacticals *)
wenzelm@5219
   180
wenzelm@5219
   181
fun CLASIMPSET tacf state =
wenzelm@5219
   182
  Classical.CLASET (fn cs => Simplifier.SIMPSET (fn ss => tacf (cs, ss))) state;
wenzelm@5219
   183
wenzelm@5219
   184
fun CLASIMPSET' tacf i state =
wenzelm@5219
   185
  Classical.CLASET (fn cs => Simplifier.SIMPSET (fn ss => tacf (cs, ss) i)) state;
wenzelm@4888
   186
wenzelm@4888
   187
wenzelm@12375
   188
fun clarsimp_tac (cs, ss) =
wenzelm@12375
   189
  safe_asm_full_simp_tac ss THEN_ALL_NEW
wenzelm@12375
   190
  Classical.clarify_tac (cs addSss ss);
wenzelm@12375
   191
wenzelm@10317
   192
fun Clarsimp_tac i = clarsimp_tac (clasimpset ()) i;
oheimb@5483
   193
oheimb@5483
   194
wenzelm@5219
   195
(* auto_tac *)
oheimb@4652
   196
wenzelm@5219
   197
fun blast_depth_tac cs m i thm =
wenzelm@9772
   198
    Blast.depth_tac cs m i thm
oheimb@5554
   199
      handle Blast.TRANS s => (warning ("Blast_tac: " ^ s); Seq.empty);
wenzelm@9772
   200
wenzelm@9772
   201
(* a variant of depth_tac that avoids interference of the simplifier
wenzelm@5219
   202
   with dup_step_tac when they are combined by auto_tac *)
oheimb@5756
   203
local
wenzelm@9772
   204
fun slow_step_tac' cs = Classical.appWrappers cs
wenzelm@9772
   205
        (Classical.instp_step_tac cs APPEND' Classical.haz_step_tac cs);
wenzelm@9772
   206
in fun nodup_depth_tac cs m i state = SELECT_GOAL
wenzelm@9772
   207
   (Classical.safe_steps_tac cs 1 THEN_ELSE
wenzelm@9772
   208
        (DEPTH_SOLVE (nodup_depth_tac cs m 1),
wenzelm@9772
   209
         Classical.inst0_step_tac cs 1 APPEND COND (K (m=0)) no_tac
wenzelm@9772
   210
             (slow_step_tac' cs 1 THEN DEPTH_SOLVE (nodup_depth_tac cs (m-1) 1))
oheimb@5756
   211
        )) i state;
oheimb@5756
   212
end;
oheimb@4652
   213
oheimb@9402
   214
(*Designed to be idempotent, except if blast_depth_tac instantiates variables
oheimb@4652
   215
  in some of the subgoals*)
oheimb@4652
   216
fun mk_auto_tac (cs, ss) m n =
wenzelm@5219
   217
    let val cs' = cs addss ss
wenzelm@9772
   218
        val maintac =
wenzelm@9772
   219
          blast_depth_tac cs m               (* fast but can't use wrappers *)
oheimb@4652
   220
          ORELSE'
oheimb@5756
   221
          (CHANGED o nodup_depth_tac cs' n); (* slower but more general *)
wenzelm@5219
   222
    in  EVERY [ALLGOALS (Simplifier.asm_full_simp_tac ss),
wenzelm@9772
   223
               TRY (Classical.safe_tac cs),
wenzelm@9772
   224
               REPEAT (FIRSTGOAL maintac),
wenzelm@5219
   225
               TRY (Classical.safe_tac (cs addSss ss)),
wenzelm@9772
   226
               prune_params_tac]
oheimb@4652
   227
    end;
oheimb@4652
   228
wenzelm@9772
   229
fun auto_tac css = mk_auto_tac css 4 2;
wenzelm@10317
   230
fun Auto_tac st = auto_tac (clasimpset ()) st;
oheimb@4652
   231
fun auto () = by Auto_tac;
oheimb@4652
   232
wenzelm@9772
   233
wenzelm@5219
   234
(* force_tac *)
wenzelm@5219
   235
oheimb@4659
   236
(* aimed to solve the given subgoal totally, using whatever tools possible *)
oheimb@4717
   237
fun force_tac (cs,ss) = let val cs' = cs addss ss in SELECT_GOAL (EVERY [
wenzelm@9772
   238
        Classical.clarify_tac cs' 1,
wenzelm@9772
   239
        IF_UNSOLVED (Simplifier.asm_full_simp_tac ss 1),
wenzelm@9772
   240
        ALLGOALS (Classical.first_best_tac cs')]) end;
wenzelm@10317
   241
fun Force_tac i = force_tac (clasimpset ()) i;
oheimb@4717
   242
fun force i = by (Force_tac i);
oheimb@4659
   243
wenzelm@5219
   244
wenzelm@9805
   245
(* basic combinations *)
wenzelm@9805
   246
wenzelm@9805
   247
fun ADDSS tac (cs, ss) = let val cs' = cs addss ss in tac cs' end;
wenzelm@9591
   248
wenzelm@9805
   249
val fast_simp_tac = ADDSS Classical.fast_tac;
wenzelm@9805
   250
val slow_simp_tac = ADDSS Classical.slow_tac;
wenzelm@9805
   251
val best_simp_tac = ADDSS Classical.best_tac;
wenzelm@9591
   252
wenzelm@9591
   253
wenzelm@9860
   254
(* access clasimpset *)
wenzelm@8639
   255
wenzelm@8639
   256
fun change_global_css f (thy, th) =
wenzelm@8639
   257
  let
wenzelm@8639
   258
    val cs_ref = Classical.claset_ref_of thy;
wenzelm@8639
   259
    val ss_ref = Simplifier.simpset_ref_of thy;
wenzelm@8639
   260
    val (cs', ss') = f ((! cs_ref, ! ss_ref), [th]);
wenzelm@8639
   261
  in cs_ref := cs'; ss_ref := ss'; (thy, th) end;
wenzelm@8639
   262
wenzelm@8639
   263
fun change_local_css f (ctxt, th) =
wenzelm@8639
   264
  let
wenzelm@8639
   265
    val cs = Classical.get_local_claset ctxt;
wenzelm@8639
   266
    val ss = Simplifier.get_local_simpset ctxt;
wenzelm@8639
   267
    val (cs', ss') = f ((cs, ss), [th]);
wenzelm@8639
   268
    val ctxt' =
wenzelm@8639
   269
      ctxt
wenzelm@8639
   270
      |> Classical.put_local_claset cs'
wenzelm@8639
   271
      |> Simplifier.put_local_simpset ss';
wenzelm@8639
   272
  in (ctxt', th) end;
wenzelm@8639
   273
wenzelm@7153
   274
fun get_local_clasimpset ctxt =
wenzelm@7153
   275
  (Classical.get_local_claset ctxt, Simplifier.get_local_simpset ctxt);
wenzelm@5926
   276
wenzelm@9860
   277
wenzelm@9860
   278
(* attributes *)
wenzelm@9860
   279
wenzelm@12375
   280
fun change_rules f (x, th) = (f (x, [th]), th);
wenzelm@12375
   281
wenzelm@9860
   282
val iff_add_global = change_global_css (op addIffs);
wenzelm@12375
   283
val iff_add_global' = change_rules addIffs_global;
wenzelm@12375
   284
val iff_del_global = change_global_css (op delIffs) o change_rules delIffs_global;
wenzelm@9860
   285
val iff_add_local = change_local_css (op addIffs);
wenzelm@12375
   286
val iff_add_local' = change_rules addIffs_local;
wenzelm@12375
   287
val iff_del_local = change_local_css (op delIffs) o change_rules delIffs_local;
wenzelm@9860
   288
wenzelm@10033
   289
fun iff_att add add' del = Attrib.syntax (Scan.lift
wenzelm@10033
   290
 (Args.del >> K del ||
wenzelm@10033
   291
  Scan.option Args.add -- Args.query >> K add' ||
wenzelm@10033
   292
  Scan.option Args.add >> K add));
wenzelm@10033
   293
wenzelm@9860
   294
val iff_attr =
wenzelm@10033
   295
 (iff_att iff_add_global iff_add_global' iff_del_global,
wenzelm@10033
   296
  iff_att iff_add_local iff_add_local' iff_del_local);
wenzelm@9860
   297
wenzelm@9860
   298
wenzelm@9860
   299
(* method modifiers *)
wenzelm@9860
   300
wenzelm@9860
   301
val iffN = "iff";
wenzelm@9860
   302
wenzelm@9860
   303
val iff_modifiers =
wenzelm@10033
   304
 [Args.$$$ iffN -- Scan.option Args.add -- Args.colon >> K ((I, iff_add_local): Method.modifier),
wenzelm@10033
   305
  Args.$$$ iffN -- Scan.option Args.add -- Args.query_colon >> K (I, iff_add_local'),
wenzelm@10033
   306
  Args.$$$ iffN -- Args.del -- Args.colon >> K (I, iff_del_local)];
wenzelm@9860
   307
wenzelm@8469
   308
val clasimp_modifiers =
wenzelm@9860
   309
  Simplifier.simp_modifiers @ Splitter.split_modifiers @
wenzelm@9860
   310
  Classical.cla_modifiers @ iff_modifiers;
wenzelm@9860
   311
wenzelm@9860
   312
wenzelm@9860
   313
(* methods *)
wenzelm@5926
   314
wenzelm@7559
   315
fun clasimp_meth tac prems ctxt = Method.METHOD (fn facts =>
wenzelm@7559
   316
  ALLGOALS (Method.insert_tac (prems @ facts)) THEN tac (get_local_clasimpset ctxt));
wenzelm@7132
   317
wenzelm@7559
   318
fun clasimp_meth' tac prems ctxt = Method.METHOD (fn facts =>
wenzelm@8168
   319
  HEADGOAL (Method.insert_tac (prems @ facts) THEN' tac (get_local_clasimpset ctxt)));
wenzelm@5926
   320
wenzelm@7559
   321
val clasimp_method = Method.bang_sectioned_args clasimp_modifiers o clasimp_meth;
wenzelm@7559
   322
val clasimp_method' = Method.bang_sectioned_args clasimp_modifiers o clasimp_meth';
wenzelm@5926
   323
wenzelm@5926
   324
wenzelm@9772
   325
fun auto_args m =
wenzelm@9772
   326
  Method.bang_sectioned_args' clasimp_modifiers (Scan.lift (Scan.option (Args.nat -- Args.nat))) m;
wenzelm@9772
   327
wenzelm@10821
   328
fun auto_meth None = clasimp_meth (CHANGED_PROP o auto_tac)
wenzelm@10821
   329
  | auto_meth (Some (m, n)) = clasimp_meth (CHANGED_PROP o (fn css => mk_auto_tac css m n));
wenzelm@9772
   330
wenzelm@9772
   331
wenzelm@9772
   332
(* theory setup *)
wenzelm@9772
   333
wenzelm@5926
   334
val setup =
wenzelm@9860
   335
 [Attrib.add_attributes
wenzelm@9893
   336
  [("iff", iff_attr, "declaration of Simplifier / Classical rules")],
wenzelm@9860
   337
  Method.add_methods
wenzelm@9591
   338
   [("fastsimp", clasimp_method' fast_simp_tac, "combined fast and simp"),
wenzelm@9805
   339
    ("slowsimp", clasimp_method' slow_simp_tac, "combined slow and simp"),
wenzelm@9805
   340
    ("bestsimp", clasimp_method' best_simp_tac, "combined best and simp"),
wenzelm@9591
   341
    ("force", clasimp_method' force_tac, "force"),
wenzelm@9772
   342
    ("auto", auto_args auto_meth, "auto"),
wenzelm@10821
   343
    ("clarsimp", clasimp_method' (CHANGED_PROP oo clarsimp_tac), "clarify simplified goal")]];
wenzelm@5926
   344
oheimb@4652
   345
end;