src/Pure/Isar/calculation.ML
changeset 8562 ce0e2b8e8844
parent 8461 2693a3a9fcc1
child 8588 b7c3f264f8ac
equal deleted inserted replaced
8561:2675e2f4dc61 8562:ce0e2b8e8844
    13   val trans_del_global: theory attribute
    13   val trans_del_global: theory attribute
    14   val trans_add_local: Proof.context attribute
    14   val trans_add_local: Proof.context attribute
    15   val trans_del_local: Proof.context attribute
    15   val trans_del_local: Proof.context attribute
    16   val also: thm list option -> (thm list -> unit) -> Proof.state -> Proof.state Seq.seq
    16   val also: thm list option -> (thm list -> unit) -> Proof.state -> Proof.state Seq.seq
    17   val finally: thm list option -> (thm list -> unit) -> Proof.state -> Proof.state Seq.seq
    17   val finally: thm list option -> (thm list -> unit) -> Proof.state -> Proof.state Seq.seq
       
    18   val moreover: (thm list -> unit) -> Proof.state -> Proof.state
    18   val setup: (theory -> theory) list
    19   val setup: (theory -> theory) list
    19 end;
    20 end;
    20 
    21 
    21 structure Calculation: CALCULATION =
    22 structure Calculation: CALCULATION =
    22 struct
    23 struct
   101 
   102 
   102 
   103 
   103 
   104 
   104 (** proof commands **)
   105 (** proof commands **)
   105 
   106 
       
   107 (* maintain calculation *)
       
   108 
   106 val calculationN = "calculation";
   109 val calculationN = "calculation";
       
   110 
       
   111 fun maintain_calculation calc state =
       
   112   state
       
   113   |> put_calculation calc
       
   114   |> Proof.simple_have_thms calculationN calc
       
   115   |> Proof.reset_facts;
       
   116 
       
   117 
       
   118 (* 'also' and 'finally' *)
   107 
   119 
   108 fun calculate final opt_rules print state =
   120 fun calculate final opt_rules print state =
   109   let
   121   let
   110     fun err_if b msg = if b then raise Proof.STATE (msg, state) else ();
   122     fun err_if b msg = if b then raise Proof.STATE (msg, state) else ();
   111     val facts = Proof.the_facts state;
   123     val facts = Proof.the_facts state;
   138           |> Proof.reset_thms calculationN
   150           |> Proof.reset_thms calculationN
   139           |> Proof.simple_have_thms "" calc
   151           |> Proof.simple_have_thms "" calc
   140           |> Proof.chain
   152           |> Proof.chain
   141         else
   153         else
   142           state
   154           state
   143           |> put_calculation calc
   155           |> maintain_calculation calc)))
   144           |> Proof.simple_have_thms calculationN calc
       
   145           |> Proof.reset_facts)))
       
   146   end;
   156   end;
   147 
   157 
   148 fun also print = calculate false print;
   158 fun also print = calculate false print;
   149 fun finally print = calculate true print;
   159 fun finally print = calculate true print;
       
   160 
       
   161 
       
   162 (* 'moreover' *)
       
   163 
       
   164 fun moreover print state =
       
   165   let val calc = if_none (get_calculation state) [] @ Proof.the_facts state
       
   166   in print calc; state |> maintain_calculation calc end;
   150 
   167 
   151 
   168 
   152 
   169 
   153 (** theory setup **)
   170 (** theory setup **)
   154 
   171