src/Pure/Isar/proof.ML
changeset 7924 5fee69b1f5fe
parent 7669 fcd9c2050836
child 7928 06a11f8cf573
equal deleted inserted replaced
7923:895d31b54da5 7924:5fee69b1f5fe
    13   val check_result: string -> state -> 'a Seq.seq -> 'a Seq.seq
    13   val check_result: string -> state -> 'a Seq.seq -> 'a Seq.seq
    14   val init_state: theory -> state
    14   val init_state: theory -> state
    15   val context_of: state -> context
    15   val context_of: state -> context
    16   val theory_of: state -> theory
    16   val theory_of: state -> theory
    17   val sign_of: state -> Sign.sg
    17   val sign_of: state -> Sign.sg
       
    18   val warn_extra_tfrees: state -> state -> state
    18   val reset_thms: string -> state -> state
    19   val reset_thms: string -> state -> state
    19   val the_facts: state -> thm list
    20   val the_facts: state -> thm list
    20   val get_goal: state -> term * (thm list * thm)
    21   val get_goal: state -> term * (thm list * thm)
    21   val goal_facts: (state -> thm list) -> state -> state
    22   val goal_facts: (state -> thm list) -> state -> state
    22   val use_facts: state -> state
    23   val use_facts: state -> state
    33   type method
    34   type method
    34   val method: (thm list -> tactic) -> method
    35   val method: (thm list -> tactic) -> method
    35   val refine: (context -> method) -> state -> state Seq.seq
    36   val refine: (context -> method) -> state -> state Seq.seq
    36   val find_free: term -> string -> term option
    37   val find_free: term -> string -> term option
    37   val export_thm: context -> thm -> thm
    38   val export_thm: context -> thm -> thm
    38   val bind: (indexname * string) list -> state -> state
       
    39   val bind_i: (indexname * term) list -> state -> state
       
    40   val match_bind: (string list * string) list -> state -> state
    39   val match_bind: (string list * string) list -> state -> state
    41   val match_bind_i: (term list * term) list -> state -> state
    40   val match_bind_i: (term list * term) list -> state -> state
    42   val have_thmss: thm list -> string -> context attribute list ->
    41   val have_thmss: thm list -> string -> context attribute list ->
    43     (thm list * context attribute list) list -> state -> state
    42     (thm list * context attribute list) list -> state -> state
    44   val simple_have_thms: string -> thm list -> state -> state
    43   val simple_have_thms: string -> thm list -> state -> state
   177   let val (context', result) = f context
   176   let val (context', result) = f context
   178   in (State (make_node (context', facts, mode, goal), nodes), result) end;
   177   in (State (make_node (context', facts, mode, goal), nodes), result) end;
   179 
   178 
   180 
   179 
   181 fun put_data kind f = map_context o ProofContext.put_data kind f;
   180 fun put_data kind f = map_context o ProofContext.put_data kind f;
   182 val declare_term = map_context o ProofContext.declare_term;
   181 val warn_extra_tfrees = map_context o ProofContext.warn_extra_tfrees o context_of;
   183 val add_binds = map_context o ProofContext.add_binds_i;
       
   184 val auto_bind_goal = map_context o ProofContext.auto_bind_goal;
   182 val auto_bind_goal = map_context o ProofContext.auto_bind_goal;
   185 val auto_bind_facts = map_context oo ProofContext.auto_bind_facts;
   183 val auto_bind_facts = map_context oo ProofContext.auto_bind_facts;
   186 val put_thms = map_context o ProofContext.put_thms;
   184 val put_thms = map_context o ProofContext.put_thms;
   187 val put_thmss = map_context o ProofContext.put_thmss;
   185 val put_thmss = map_context o ProofContext.put_thmss;
   188 val reset_thms = map_context o ProofContext.reset_thms;
   186 val reset_thms = map_context o ProofContext.reset_thms;
   491   state
   489   state
   492   |> assert_forward
   490   |> assert_forward
   493   |> map_context (f x)
   491   |> map_context (f x)
   494   |> reset_facts;
   492   |> reset_facts;
   495 
   493 
   496 val bind = gen_bind (ProofContext.add_binds o map (apsnd Some))
       
   497 val bind_i = gen_bind (ProofContext.add_binds_i o map (apsnd Some))
       
   498 
       
   499 val match_bind = gen_bind ProofContext.match_binds;
   494 val match_bind = gen_bind ProofContext.match_binds;
   500 val match_bind_i = gen_bind ProofContext.match_binds_i;
   495 val match_bind_i = gen_bind ProofContext.match_binds_i;
   501 
   496 
   502 
   497 
   503 (* have_thmss *)
   498 (* have_thmss *)
   576 
   571 
   577 (* setup goals *)
   572 (* setup goals *)
   578 
   573 
   579 fun setup_goal opt_block prepp kind after_qed name atts raw_propp state =
   574 fun setup_goal opt_block prepp kind after_qed name atts raw_propp state =
   580   let
   575   let
   581     val (state', prop) =
   576     val (state', [prop]) =
   582       state
   577       state
   583       |> assert_forward_or_chain
   578       |> assert_forward_or_chain
   584       |> enter_forward
   579       |> enter_forward
   585       |> map_context_result (fn c => prepp (c, raw_propp));
   580       |> map_context_result (prepp [raw_propp]);
   586     val cprop = Thm.cterm_of (sign_of state') prop;
   581     val cprop = Thm.cterm_of (sign_of state') prop;
   587     val goal = Drule.mk_triv_goal cprop;
   582     val goal = Drule.mk_triv_goal cprop;
   588   in
   583   in
   589     state'
   584     state'
   590     |> opt_block
   585     |> opt_block
   596   end;
   591   end;
   597 
   592 
   598 
   593 
   599 (*global goals*)
   594 (*global goals*)
   600 fun global_goal prep kind name atts x thy =
   595 fun global_goal prep kind name atts x thy =
   601   setup_goal I prep kind Seq.single name atts x (init_state thy);
   596   setup_goal I (prep false) kind Seq.single name atts x (init_state thy);
   602 
   597 
   603 val theorem = global_goal ProofContext.bind_propp Theorem;
   598 val theorem = global_goal ProofContext.bind_propps Theorem;
   604 val theorem_i = global_goal ProofContext.bind_propp_i Theorem;
   599 val theorem_i = global_goal ProofContext.bind_propps_i Theorem;
   605 val lemma = global_goal ProofContext.bind_propp Lemma;
   600 val lemma = global_goal ProofContext.bind_propps Lemma;
   606 val lemma_i = global_goal ProofContext.bind_propp_i Lemma;
   601 val lemma_i = global_goal ProofContext.bind_propps_i Lemma;
   607 
   602 
   608 
   603 
   609 (*local goals*)
   604 (*local goals*)
   610 fun local_goal prep kind f name atts x =
   605 fun local_goal prep kind f name atts x =
   611   setup_goal open_block prep kind f name atts x;
   606   setup_goal open_block (prep true) kind f name atts x;
   612 
   607 
   613 val show   = local_goal ProofContext.bind_propp Goal;
   608 val show   = local_goal ProofContext.bind_propps Goal;
   614 val show_i = local_goal ProofContext.bind_propp_i Goal;
   609 val show_i = local_goal ProofContext.bind_propps_i Goal;
   615 val have   = local_goal ProofContext.bind_propp Aux;
   610 val have   = local_goal ProofContext.bind_propps Aux;
   616 val have_i = local_goal ProofContext.bind_propp_i Aux;
   611 val have_i = local_goal ProofContext.bind_propps_i Aux;
   617 
   612 
   618 
   613 
   619 
   614 
   620 (** conclusions **)
   615 (** conclusions **)
   621 
   616