src/Pure/Isar/calculation.ML
changeset 18678 dd0c569fa43d
parent 18637 33a6f6caa617
child 18708 4b3dadb4fe33
equal deleted inserted replaced
18677:01265301db7f 18678:dd0c569fa43d
   107 
   107 
   108 
   108 
   109 
   109 
   110 (** proof commands **)
   110 (** proof commands **)
   111 
   111 
   112 fun err_if state b msg = if b then raise Proof.STATE (msg, state) else ();
   112 fun err_if b msg = if b then error msg else ();
   113 
   113 
   114 fun assert_sane final =
   114 fun assert_sane final =
   115   if final then Proof.assert_forward else Proof.assert_forward_or_chain;
   115   if final then Proof.assert_forward else Proof.assert_forward_or_chain;
   116 
   116 
   117 fun maintain_calculation false calc = put_calculation (SOME calc)
   117 fun maintain_calculation false calc = put_calculation (SOME calc)
   145     val (initial, calculations) =
   145     val (initial, calculations) =
   146       (case get_calculation state of
   146       (case get_calculation state of
   147         NONE => (true, Seq.single facts)
   147         NONE => (true, Seq.single facts)
   148       | SOME calc => (false, Seq.map single (combine (calc @ facts))));
   148       | SOME calc => (false, Seq.map single (combine (calc @ facts))));
   149   in
   149   in
   150     err_if state (initial andalso final) "No calculation yet";
   150     err_if (initial andalso final) "No calculation yet";
   151     err_if state (initial andalso is_some opt_rules) "Initial calculation -- no rules to be given";
   151     err_if (initial andalso is_some opt_rules) "Initial calculation -- no rules to be given";
   152     calculations |> Seq.map (fn calc => (print_calculation int (Proof.context_of state) calc;
   152     calculations |> Seq.map (fn calc => (print_calculation int (Proof.context_of state) calc;
   153         state |> maintain_calculation final calc))
   153         state |> maintain_calculation final calc))
   154   end;
   154   end;
   155 
   155 
   156 val also = calculate Proof.get_thmss false;
   156 val also = calculate Proof.get_thmss false;
   168       (case get_calculation state of
   168       (case get_calculation state of
   169         NONE => (true, [])
   169         NONE => (true, [])
   170       | SOME thms => (false, thms));
   170       | SOME thms => (false, thms));
   171     val calc = thms @ facts;
   171     val calc = thms @ facts;
   172   in
   172   in
   173     err_if state (initial andalso final) "No calculation yet";
   173     err_if (initial andalso final) "No calculation yet";
   174     print_calculation int (Proof.context_of state) calc;
   174     print_calculation int (Proof.context_of state) calc;
   175     state |> maintain_calculation final calc
   175     state |> maintain_calculation final calc
   176   end;
   176   end;
   177 
   177 
   178 val moreover = collect false;
   178 val moreover = collect false;