167 |
167 |
168 fun init ctxt = |
168 fun init ctxt = |
169 State (Stack.init (make_node (init_context ctxt, NONE, Forward, NONE))); |
169 State (Stack.init (make_node (init_context ctxt, NONE, Forward, NONE))); |
170 |
170 |
171 fun top (State st) = Stack.top st |> (fn Node node => node); |
171 fun top (State st) = Stack.top st |> (fn Node node => node); |
172 fun bottom (State st) = Stack.bottom st |> (fn Node node => node); |
|
173 |
|
174 fun map_top f (State st) = State (Stack.map_top (map_node f) st); |
172 fun map_top f (State st) = State (Stack.map_top (map_node f) st); |
175 fun map_bottom f (State st) = State (Stack.map_bottom (map_node f) st); |
|
176 fun map_all f (State st) = State (Stack.map_all (map_node f) st); |
173 fun map_all f (State st) = State (Stack.map_all (map_node f) st); |
177 |
174 |
178 |
175 |
179 |
176 |
180 (** basic proof state operations **) |
177 (** basic proof state operations **) |
207 fun map_context f = |
204 fun map_context f = |
208 map_top (fn (ctxt, facts, mode, goal) => (f ctxt, facts, mode, goal)); |
205 map_top (fn (ctxt, facts, mode, goal) => (f ctxt, facts, mode, goal)); |
209 |
206 |
210 fun map_context_result f state = |
207 fun map_context_result f state = |
211 f (context_of state) ||> (fn ctxt => map_context (K ctxt) state); |
208 f (context_of state) ||> (fn ctxt => map_context (K ctxt) state); |
212 |
|
213 fun map_context_bottom f = |
|
214 map_bottom (fn (ctxt, facts, mode, goal) => (f ctxt, facts, mode, goal)); |
|
215 |
209 |
216 fun map_contexts f = map_all (fn (ctxt, facts, mode, goal) => (f ctxt, facts, mode, goal)); |
210 fun map_contexts f = map_all (fn (ctxt, facts, mode, goal) => (f ctxt, facts, mode, goal)); |
217 |
211 |
218 fun propagate_ml_env state = map_contexts |
212 fun propagate_ml_env state = map_contexts |
219 (Context.proof_map (ML_Env.inherit (Context.Proof (context_of state)))) state; |
213 (Context.proof_map (ML_Env.inherit (Context.Proof (context_of state)))) state; |