src/Pure/Isar/calculation.ML
author wenzelm
Sat, 21 Jan 2006 23:02:14 +0100
changeset 18728 6790126ab5f6
parent 18708 4b3dadb4fe33
child 18947 de38ee3654d4
permissions -rw-r--r--
simplified type attribute;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/Isar/calculation.ML
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
     3
    Author:     Markus Wenzel, TU Muenchen
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
     4
17350
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
     5
Generic calculational proofs.
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
     6
*)
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
     7
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
     8
signature CALCULATION =
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
     9
sig
18637
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    10
  val print_rules: Context.generic -> unit
16571
c1f41c98fd3c export get_calculation;
wenzelm
parents: 16424
diff changeset
    11
  val get_calculation: Proof.state -> thm list option
18728
6790126ab5f6 simplified type attribute;
wenzelm
parents: 18708
diff changeset
    12
  val trans_add: attribute
6790126ab5f6 simplified type attribute;
wenzelm
parents: 18708
diff changeset
    13
  val trans_del: attribute
6790126ab5f6 simplified type attribute;
wenzelm
parents: 18708
diff changeset
    14
  val sym_add: attribute
6790126ab5f6 simplified type attribute;
wenzelm
parents: 18708
diff changeset
    15
  val sym_del: attribute
6790126ab5f6 simplified type attribute;
wenzelm
parents: 18708
diff changeset
    16
  val symmetric: attribute
17350
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
    17
  val also: (thmref * Attrib.src list) list option -> bool -> Proof.state -> Proof.state Seq.seq
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
    18
  val also_i: thm list option -> bool -> Proof.state -> Proof.state Seq.seq
18637
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    19
  val finally: (thmref * Attrib.src list) list option -> bool -> Proof.state -> Proof.state Seq.seq
17350
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
    20
  val finally_i: thm list option -> bool -> Proof.state -> Proof.state Seq.seq
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
    21
  val moreover: bool -> Proof.state -> Proof.state
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
    22
  val ultimately: bool -> Proof.state -> Proof.state
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    23
end;
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    24
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    25
structure Calculation: CALCULATION =
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    26
struct
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    27
18637
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    28
(** calculation data **)
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    29
18637
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    30
structure CalculationData = GenericDataFun
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    31
(
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    32
  val name = "Isar/calculation";
12379
c74d160ff0c5 added 'sym' and 'symmetric' atts;
wenzelm
parents: 12311
diff changeset
    33
  type T = (thm NetRules.T * thm list) * (thm list * int) option;
18637
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    34
  val empty = ((NetRules.elim, []), NONE);
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    35
  val extend = I;
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    36
18637
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    37
  fun merge _ (((trans1, sym1), _), ((trans2, sym2), _)) =
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    38
    ((NetRules.merge (trans1, trans2), Drule.merge_rules (sym1, sym2)), NONE);
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    39
18637
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    40
  fun print generic ((trans, sym), _) =
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    41
    let val ctxt = Context.proof_of generic in
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    42
      [Pretty.big_list "transitivity rules:"
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    43
          (map (ProofContext.pretty_thm ctxt) (NetRules.rules trans)),
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    44
        Pretty.big_list "symmetry rules:" (map (ProofContext.pretty_thm ctxt) sym)]
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    45
      |> Pretty.chunks |> Pretty.writeln
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    46
    end;
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    47
);
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    48
18708
4b3dadb4fe33 setup: theory -> theory;
wenzelm
parents: 18678
diff changeset
    49
val _ = Context.add_setup CalculationData.init;
18637
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    50
val print_rules = CalculationData.print;
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    51
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    52
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    53
(* access calculation *)
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    54
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    55
fun get_calculation state =
18637
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    56
  (case #2 (CalculationData.get (Context.Proof (Proof.context_of state))) of
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 14981
diff changeset
    57
    NONE => NONE
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 14981
diff changeset
    58
  | SOME (thms, lev) => if lev = Proof.level state then SOME thms else NONE);
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    59
17350
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
    60
val calculationN = "calculation";
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    61
17350
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
    62
fun put_calculation calc =
18728
6790126ab5f6 simplified type attribute;
wenzelm
parents: 18708
diff changeset
    63
  `Proof.level #-> (fn lev => Proof.map_context (Context.proof_map
6790126ab5f6 simplified type attribute;
wenzelm
parents: 18708
diff changeset
    64
     (CalculationData.map (apsnd (K (Option.map (rpair lev) calc))))))
17350
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
    65
  #> Proof.put_thms (calculationN, calc);
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    66
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    67
18637
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    68
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    69
(** attributes **)
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    70
12379
c74d160ff0c5 added 'sym' and 'symmetric' atts;
wenzelm
parents: 12311
diff changeset
    71
(* add/del rules *)
c74d160ff0c5 added 'sym' and 'symmetric' atts;
wenzelm
parents: 12311
diff changeset
    72
18728
6790126ab5f6 simplified type attribute;
wenzelm
parents: 18708
diff changeset
    73
val trans_add = Thm.declaration_attribute (CalculationData.map o apfst o apfst o NetRules.insert);
6790126ab5f6 simplified type attribute;
wenzelm
parents: 18708
diff changeset
    74
val trans_del = Thm.declaration_attribute (CalculationData.map o apfst o apfst o NetRules.delete);
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    75
18637
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    76
val sym_add =
18728
6790126ab5f6 simplified type attribute;
wenzelm
parents: 18708
diff changeset
    77
  Thm.declaration_attribute (CalculationData.map o apfst o apsnd o Drule.add_rule)
18637
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    78
  #> ContextRules.elim_query NONE;
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    79
val sym_del =
18728
6790126ab5f6 simplified type attribute;
wenzelm
parents: 18708
diff changeset
    80
  Thm.declaration_attribute (CalculationData.map o apfst o apsnd o Drule.del_rule)
18637
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    81
  #> ContextRules.rule_del;
12379
c74d160ff0c5 added 'sym' and 'symmetric' atts;
wenzelm
parents: 12311
diff changeset
    82
c74d160ff0c5 added 'sym' and 'symmetric' atts;
wenzelm
parents: 12311
diff changeset
    83
18637
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    84
(* symmetric *)
12379
c74d160ff0c5 added 'sym' and 'symmetric' atts;
wenzelm
parents: 12311
diff changeset
    85
18728
6790126ab5f6 simplified type attribute;
wenzelm
parents: 18708
diff changeset
    86
val symmetric = Thm.rule_attribute (fn x => fn th =>
18637
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    87
  (case Seq.chop (2, Drule.multi_resolves [th] (#2 (#1 (CalculationData.get x)))) of
12379
c74d160ff0c5 added 'sym' and 'symmetric' atts;
wenzelm
parents: 12311
diff changeset
    88
    ([th'], _) => th'
c74d160ff0c5 added 'sym' and 'symmetric' atts;
wenzelm
parents: 12311
diff changeset
    89
  | ([], _) => raise THM ("symmetric: no unifiers", 1, [th])
c74d160ff0c5 added 'sym' and 'symmetric' atts;
wenzelm
parents: 12311
diff changeset
    90
  | _ => raise THM ("symmetric: multiple unifiers", 1, [th])));
c74d160ff0c5 added 'sym' and 'symmetric' atts;
wenzelm
parents: 12311
diff changeset
    91
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    92
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    93
(* concrete syntax *)
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
    94
18637
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    95
val trans_att = Attrib.add_del_args trans_add trans_del;
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
    96
val sym_att = Attrib.add_del_args sym_add sym_del;
12379
c74d160ff0c5 added 'sym' and 'symmetric' atts;
wenzelm
parents: 12311
diff changeset
    97
15801
d2f5ca3c048d superceded by Pure.thy and CPure.thy;
wenzelm
parents: 15570
diff changeset
    98
val _ = Context.add_setup
18708
4b3dadb4fe33 setup: theory -> theory;
wenzelm
parents: 18678
diff changeset
    99
 (Attrib.add_attributes
18728
6790126ab5f6 simplified type attribute;
wenzelm
parents: 18708
diff changeset
   100
   [("trans", trans_att, "declaration of transitivity rule"),
6790126ab5f6 simplified type attribute;
wenzelm
parents: 18708
diff changeset
   101
    ("sym", sym_att, "declaration of symmetry rule"),
6790126ab5f6 simplified type attribute;
wenzelm
parents: 18708
diff changeset
   102
    ("symmetric", Attrib.no_args symmetric, "resolution with symmetry rule")] #>
18708
4b3dadb4fe33 setup: theory -> theory;
wenzelm
parents: 18678
diff changeset
   103
  PureThy.add_thms
18728
6790126ab5f6 simplified type attribute;
wenzelm
parents: 18708
diff changeset
   104
   [(("", transitive_thm), [trans_add]),
6790126ab5f6 simplified type attribute;
wenzelm
parents: 18708
diff changeset
   105
    (("", symmetric_thm), [sym_add])] #> snd);
15801
d2f5ca3c048d superceded by Pure.thy and CPure.thy;
wenzelm
parents: 15570
diff changeset
   106
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
   107
6787
wenzelm
parents: 6782
diff changeset
   108
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
   109
(** proof commands **)
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
   110
18678
dd0c569fa43d sane ERROR handling;
wenzelm
parents: 18637
diff changeset
   111
fun err_if b msg = if b then error msg else ();
17350
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
   112
14555
341908d6c792 'also'/'moreover': do not interfere with current facts, allow in chain mode;
wenzelm
parents: 14549
diff changeset
   113
fun assert_sane final =
341908d6c792 'also'/'moreover': do not interfere with current facts, allow in chain mode;
wenzelm
parents: 14549
diff changeset
   114
  if final then Proof.assert_forward else Proof.assert_forward_or_chain;
341908d6c792 'also'/'moreover': do not interfere with current facts, allow in chain mode;
wenzelm
parents: 14549
diff changeset
   115
17350
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
   116
fun maintain_calculation false calc = put_calculation (SOME calc)
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
   117
  | maintain_calculation true calc = put_calculation NONE #> Proof.chain_facts calc;
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
   118
17350
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
   119
fun print_calculation false _ _ = ()
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
   120
  | print_calculation true ctxt calc =
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
   121
      Pretty.writeln (ProofContext.pretty_fact ctxt (calculationN, calc));
8562
ce0e2b8e8844 added 'moreover' command;
wenzelm
parents: 8461
diff changeset
   122
ce0e2b8e8844 added 'moreover' command;
wenzelm
parents: 8461
diff changeset
   123
17350
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
   124
(* also and finally *)
8562
ce0e2b8e8844 added 'moreover' command;
wenzelm
parents: 8461
diff changeset
   125
18637
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
   126
val get_rules = #1 o CalculationData.get o Context.Proof o Proof.context_of;
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
   127
17350
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
   128
fun calculate prep_rules final raw_rules int state =
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
   129
  let
12805
3be853cf19cf Thm.prop_of;
wenzelm
parents: 12402
diff changeset
   130
    val strip_assums_concl = Logic.strip_assums_concl o Thm.prop_of;
9322
b5bd2709a2c2 eq_prop: strip_assums_concl;
wenzelm
parents: 9217
diff changeset
   131
    val eq_prop = op aconv o pairself (Pattern.eta_contract o strip_assums_concl);
11097
c1be9f2dff4c more robust selection of calculational rules;
wenzelm
parents: 10478
diff changeset
   132
    fun projection ths th = Library.exists (Library.curry eq_prop th) ths;
8300
4c3f83414de3 use NetRules;
wenzelm
parents: 8150
diff changeset
   133
17350
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
   134
    val opt_rules = Option.map (prep_rules state) raw_rules;
11097
c1be9f2dff4c more robust selection of calculational rules;
wenzelm
parents: 10478
diff changeset
   135
    fun combine ths =
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 14981
diff changeset
   136
      (case opt_rules of SOME rules => rules
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 14981
diff changeset
   137
      | NONE =>
18637
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
   138
          (case ths of [] => NetRules.rules (#1 (get_rules state))
33a6f6caa617 generic data and attributes;
wenzelm
parents: 18377
diff changeset
   139
          | th :: _ => NetRules.retrieve (#1 (get_rules state)) (strip_assums_concl th)))
18223
20830cb4428c Drule.multi_resolves;
wenzelm
parents: 17384
diff changeset
   140
      |> Seq.of_list |> Seq.maps (Drule.multi_resolve ths)
11097
c1be9f2dff4c more robust selection of calculational rules;
wenzelm
parents: 10478
diff changeset
   141
      |> Seq.filter (not o projection ths);
7414
9bc7797d1249 calculation: thm list;
wenzelm
parents: 7197
diff changeset
   142
14555
341908d6c792 'also'/'moreover': do not interfere with current facts, allow in chain mode;
wenzelm
parents: 14549
diff changeset
   143
    val facts = Proof.the_facts (assert_sane final state);
6903
682f8a9ec75d improved errors;
wenzelm
parents: 6877
diff changeset
   144
    val (initial, calculations) =
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
   145
      (case get_calculation state of
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 14981
diff changeset
   146
        NONE => (true, Seq.single facts)
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 14981
diff changeset
   147
      | SOME calc => (false, Seq.map single (combine (calc @ facts))));
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
   148
  in
18678
dd0c569fa43d sane ERROR handling;
wenzelm
parents: 18637
diff changeset
   149
    err_if (initial andalso final) "No calculation yet";
dd0c569fa43d sane ERROR handling;
wenzelm
parents: 18637
diff changeset
   150
    err_if (initial andalso is_some opt_rules) "Initial calculation -- no rules to be given";
17350
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
   151
    calculations |> Seq.map (fn calc => (print_calculation int (Proof.context_of state) calc;
12055
a9c44895cc8c pretty/print functions with context;
wenzelm
parents: 12021
diff changeset
   152
        state |> maintain_calculation final calc))
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
   153
  end;
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
   154
17350
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
   155
val also = calculate Proof.get_thmss false;
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
   156
val also_i = calculate (K I) false;
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
   157
val finally = calculate Proof.get_thmss true;
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
   158
val finally_i = calculate (K I) true;
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
   159
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
   160
17350
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
   161
(* moreover and ultimately *)
8562
ce0e2b8e8844 added 'moreover' command;
wenzelm
parents: 8461
diff changeset
   162
17350
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
   163
fun collect final int state =
8588
b7c3f264f8ac added 'ultimately';
wenzelm
parents: 8562
diff changeset
   164
  let
14555
341908d6c792 'also'/'moreover': do not interfere with current facts, allow in chain mode;
wenzelm
parents: 14549
diff changeset
   165
    val facts = Proof.the_facts (assert_sane final state);
8588
b7c3f264f8ac added 'ultimately';
wenzelm
parents: 8562
diff changeset
   166
    val (initial, thms) =
b7c3f264f8ac added 'ultimately';
wenzelm
parents: 8562
diff changeset
   167
      (case get_calculation state of
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 14981
diff changeset
   168
        NONE => (true, [])
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 14981
diff changeset
   169
      | SOME thms => (false, thms));
8588
b7c3f264f8ac added 'ultimately';
wenzelm
parents: 8562
diff changeset
   170
    val calc = thms @ facts;
b7c3f264f8ac added 'ultimately';
wenzelm
parents: 8562
diff changeset
   171
  in
18678
dd0c569fa43d sane ERROR handling;
wenzelm
parents: 18637
diff changeset
   172
    err_if (initial andalso final) "No calculation yet";
17350
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
   173
    print_calculation int (Proof.context_of state) calc;
8588
b7c3f264f8ac added 'ultimately';
wenzelm
parents: 8562
diff changeset
   174
    state |> maintain_calculation final calc
b7c3f264f8ac added 'ultimately';
wenzelm
parents: 8562
diff changeset
   175
  end;
b7c3f264f8ac added 'ultimately';
wenzelm
parents: 8562
diff changeset
   176
17350
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
   177
val moreover = collect false;
26cd3756377a more self-contained proof elements (material from isar_thy.ML);
wenzelm
parents: 16571
diff changeset
   178
val ultimately = collect true;
8562
ce0e2b8e8844 added 'moreover' command;
wenzelm
parents: 8461
diff changeset
   179
6778
2f66eea8a025 Support for calculational proofs.
wenzelm
parents:
diff changeset
   180
end;