src/Pure/Isar/element.ML
changeset 19808 396dd23c54ef
parent 19777 77929c3d2b74
child 19843 67cb97e856ff
equal deleted inserted replaced
19807:79161b339691 19808:396dd23c54ef
    24   val map_ctxt: {name: string -> string,
    24   val map_ctxt: {name: string -> string,
    25     var: string * mixfix -> string * mixfix,
    25     var: string * mixfix -> string * mixfix,
    26     typ: 'typ -> 'a, term: 'term -> 'b, fact: 'fact -> 'c,
    26     typ: 'typ -> 'a, term: 'term -> 'b, fact: 'fact -> 'c,
    27     attrib: Attrib.src -> Attrib.src} -> ('typ, 'term, 'fact) ctxt -> ('a, 'b, 'c) ctxt
    27     attrib: Attrib.src -> Attrib.src} -> ('typ, 'term, 'fact) ctxt -> ('a, 'b, 'c) ctxt
    28   val map_ctxt_values: (typ -> typ) -> (term -> term) -> (thm -> thm) -> context_i -> context_i
    28   val map_ctxt_values: (typ -> typ) -> (term -> term) -> (thm -> thm) -> context_i -> context_i
    29   val params_of: ('typ, 'term, 'fact) ctxt -> (string * 'typ) list
    29   val params_of: context_i -> (string * typ) list
    30   val prems_of: ('typ, 'term, 'fact) ctxt -> 'term list
    30   val prems_of: context_i -> term list
       
    31   val facts_of: theory -> context_i ->
       
    32     ((string * Attrib.src list) * (thm list * Attrib.src list) list) list
    31   val pretty_stmt: Proof.context -> statement_i -> Pretty.T list
    33   val pretty_stmt: Proof.context -> statement_i -> Pretty.T list
    32   val pretty_ctxt: Proof.context -> context_i -> Pretty.T list
    34   val pretty_ctxt: Proof.context -> context_i -> Pretty.T list
    33   val pretty_statement: Proof.context -> string -> thm -> Pretty.T
    35   val pretty_statement: Proof.context -> string -> thm -> Pretty.T
    34 
       
    35   type witness
    36   type witness
    36   val map_witness: (term * thm -> term * thm) -> witness -> witness
    37   val map_witness: (term * thm -> term * thm) -> witness -> witness
    37   val witness_prop: witness -> term
    38   val witness_prop: witness -> term
    38   val witness_hyps: witness -> term list
    39   val witness_hyps: witness -> term list
    39   val assume_witness: theory -> term -> witness
    40   val assume_witness: theory -> term -> witness
    40   val prove_witness: theory -> term -> tactic -> witness
    41   val prove_witness: theory -> term -> tactic -> witness
    41   val conclude_witness: witness -> thm
    42   val conclude_witness: witness -> thm
    42   val mark_witness: term -> term
    43   val mark_witness: term -> term
    43   val make_witness: term -> thm -> witness
    44   val make_witness: term -> thm -> witness
    44   val refine_witness: Proof.state -> Proof.state
    45   val refine_witness: Proof.state -> Proof.state Seq.seq
    45 
       
    46   val rename: (string * (string * mixfix option)) list -> string -> string
    46   val rename: (string * (string * mixfix option)) list -> string -> string
    47   val rename_var: (string * (string * mixfix option)) list -> string * mixfix -> string * mixfix
    47   val rename_var: (string * (string * mixfix option)) list -> string * mixfix -> string * mixfix
    48   val rename_term: (string * (string * mixfix option)) list -> term -> term
    48   val rename_term: (string * (string * mixfix option)) list -> term -> term
    49   val rename_thm: (string * (string * mixfix option)) list -> thm -> thm
    49   val rename_thm: (string * (string * mixfix option)) list -> thm -> thm
    50   val rename_witness: (string * (string * mixfix option)) list -> witness -> witness
    50   val rename_witness: (string * (string * mixfix option)) list -> witness -> witness
   103 
   103 
   104 fun map_ctxt_values typ term thm = map_ctxt
   104 fun map_ctxt_values typ term thm = map_ctxt
   105   {name = I, var = I, typ = typ, term = term, fact = map thm,
   105   {name = I, var = I, typ = typ, term = term, fact = map thm,
   106     attrib = Args.map_values I typ term thm};
   106     attrib = Args.map_values I typ term thm};
   107 
   107 
       
   108 
       
   109 (* logical content *)
       
   110 
   108 fun params_of (Fixes fixes) = fixes |> map
   111 fun params_of (Fixes fixes) = fixes |> map
   109     (fn (x, SOME T, _) => (x, T)
   112     (fn (x, SOME T, _) => (x, T)
   110       | (x, _, _) => raise TERM ("Untyped context element parameter " ^ quote x, []))
   113       | (x, _, _) => raise TERM ("Untyped context element parameter " ^ quote x, []))
   111   | params_of _ = [];
   114   | params_of _ = [];
   112 
   115 
   113 fun prems_of (Assumes asms) = maps (map fst o snd) asms
   116 fun prems_of (Assumes asms) = maps (map fst o snd) asms
   114   | prems_of (Defines defs) = map (fst o snd) defs
   117   | prems_of (Defines defs) = map (fst o snd) defs
   115   | prems_of _ = [];
   118   | prems_of _ = [];
       
   119 
       
   120 fun assume thy t = Goal.norm_hhf (Thm.assume (Thm.cterm_of thy t));
       
   121 
       
   122 fun facts_of thy (Assumes asms) = map (apsnd (map (fn (t, _) => ([assume thy t], [])))) asms
       
   123   | facts_of thy (Defines defs) = map (apsnd (fn (t, _) => [([assume thy t], [])])) defs
       
   124   | facts_of _ (Notes facts) = facts
       
   125   | facts_of _ _ = [];
   116 
   126 
   117 
   127 
   118 
   128 
   119 (** pretty printing **)
   129 (** pretty printing **)
   120 
   130 
   274 
   284 
   275 val refine_witness =
   285 val refine_witness =
   276   Proof.refine (Method.Basic (K (Method.RAW_METHOD
   286   Proof.refine (Method.Basic (K (Method.RAW_METHOD
   277     (K (ALLGOALS
   287     (K (ALLGOALS
   278       (PRECISE_CONJUNCTS ~1 (ALLGOALS
   288       (PRECISE_CONJUNCTS ~1 (ALLGOALS
   279         (PRECISE_CONJUNCTS ~1 (TRYALL (Tactic.rtac Drule.protectI))))))))))
   289         (PRECISE_CONJUNCTS ~1 (TRYALL (Tactic.rtac Drule.protectI))))))))));
   280   #> Seq.hd;
       
   281 
   290 
   282 
   291 
   283 (* derived rules *)
   292 (* derived rules *)
   284 
   293 
   285 fun instantiate_tfrees thy subst =
   294 fun instantiate_tfrees thy subst =