21 val get_mode: Proof.context -> mode |
21 val get_mode: Proof.context -> mode |
22 val restore_mode: Proof.context -> Proof.context -> Proof.context |
22 val restore_mode: Proof.context -> Proof.context -> Proof.context |
23 val abbrev_mode: Proof.context -> bool |
23 val abbrev_mode: Proof.context -> bool |
24 val set_stmt: bool -> Proof.context -> Proof.context |
24 val set_stmt: bool -> Proof.context -> Proof.context |
25 val naming_of: Proof.context -> NameSpace.naming |
25 val naming_of: Proof.context -> NameSpace.naming |
26 val full_name: Proof.context -> bstring -> string |
26 val full_name: Proof.context -> Binding.T -> string |
27 val full_binding: Proof.context -> Name.binding -> string |
27 val full_bname: Proof.context -> bstring -> string |
28 val consts_of: Proof.context -> Consts.T |
28 val consts_of: Proof.context -> Consts.T |
29 val const_syntax_name: Proof.context -> string -> string |
29 val const_syntax_name: Proof.context -> string -> string |
30 val the_const_constraint: Proof.context -> string -> typ |
30 val the_const_constraint: Proof.context -> string -> typ |
31 val mk_const: Proof.context -> string * typ list -> term |
31 val mk_const: Proof.context -> string * typ list -> term |
32 val set_syntax_mode: Syntax.mode -> Proof.context -> Proof.context |
32 val set_syntax_mode: Syntax.mode -> Proof.context -> Proof.context |
103 val qualified_names: Proof.context -> Proof.context |
103 val qualified_names: Proof.context -> Proof.context |
104 val sticky_prefix: string -> Proof.context -> Proof.context |
104 val sticky_prefix: string -> Proof.context -> Proof.context |
105 val restore_naming: Proof.context -> Proof.context -> Proof.context |
105 val restore_naming: Proof.context -> Proof.context -> Proof.context |
106 val reset_naming: Proof.context -> Proof.context |
106 val reset_naming: Proof.context -> Proof.context |
107 val note_thmss: string -> |
107 val note_thmss: string -> |
108 ((Name.binding * attribute list) * (Facts.ref * attribute list) list) list -> |
108 ((Binding.T * attribute list) * (Facts.ref * attribute list) list) list -> |
109 Proof.context -> (string * thm list) list * Proof.context |
109 Proof.context -> (string * thm list) list * Proof.context |
110 val note_thmss_i: string -> |
110 val note_thmss_i: string -> |
111 ((Name.binding * attribute list) * (thm list * attribute list) list) list -> |
111 ((Binding.T * attribute list) * (thm list * attribute list) list) list -> |
112 Proof.context -> (string * thm list) list * Proof.context |
112 Proof.context -> (string * thm list) list * Proof.context |
113 val put_thms: bool -> string * thm list option -> Proof.context -> Proof.context |
113 val put_thms: bool -> string * thm list option -> Proof.context -> Proof.context |
114 val read_vars: (Name.binding * string option * mixfix) list -> Proof.context -> |
114 val read_vars: (Binding.T * string option * mixfix) list -> Proof.context -> |
115 (Name.binding * typ option * mixfix) list * Proof.context |
115 (Binding.T * typ option * mixfix) list * Proof.context |
116 val cert_vars: (Name.binding * typ option * mixfix) list -> Proof.context -> |
116 val cert_vars: (Binding.T * typ option * mixfix) list -> Proof.context -> |
117 (Name.binding * typ option * mixfix) list * Proof.context |
117 (Binding.T * typ option * mixfix) list * Proof.context |
118 val add_fixes: (Name.binding * string option * mixfix) list -> |
118 val add_fixes: (Binding.T * string option * mixfix) list -> |
119 Proof.context -> string list * Proof.context |
119 Proof.context -> string list * Proof.context |
120 val add_fixes_i: (Name.binding * typ option * mixfix) list -> |
120 val add_fixes_i: (Binding.T * typ option * mixfix) list -> |
121 Proof.context -> string list * Proof.context |
121 Proof.context -> string list * Proof.context |
122 val auto_fixes: Proof.context * (term list list * 'a) -> Proof.context * (term list list * 'a) |
122 val auto_fixes: Proof.context * (term list list * 'a) -> Proof.context * (term list list * 'a) |
123 val bind_fixes: string list -> Proof.context -> (term -> term) * Proof.context |
123 val bind_fixes: string list -> Proof.context -> (term -> term) * Proof.context |
124 val add_assms: Assumption.export -> |
124 val add_assms: Assumption.export -> |
125 ((Name.binding * attribute list) * (string * string list) list) list -> |
125 ((Binding.T * attribute list) * (string * string list) list) list -> |
126 Proof.context -> (string * thm list) list * Proof.context |
126 Proof.context -> (string * thm list) list * Proof.context |
127 val add_assms_i: Assumption.export -> |
127 val add_assms_i: Assumption.export -> |
128 ((Name.binding * attribute list) * (term * term list) list) list -> |
128 ((Binding.T * attribute list) * (term * term list) list) list -> |
129 Proof.context -> (string * thm list) list * Proof.context |
129 Proof.context -> (string * thm list) list * Proof.context |
130 val add_cases: bool -> (string * RuleCases.T option) list -> Proof.context -> Proof.context |
130 val add_cases: bool -> (string * RuleCases.T option) list -> Proof.context -> Proof.context |
131 val apply_case: RuleCases.T -> Proof.context -> (string * term list) list * Proof.context |
131 val apply_case: RuleCases.T -> Proof.context -> (string * term list) list * Proof.context |
132 val get_case: Proof.context -> string -> string option list -> RuleCases.T |
132 val get_case: Proof.context -> string -> string option list -> RuleCases.T |
133 val notation: bool -> Syntax.mode -> (term * mixfix) list -> Proof.context -> Proof.context |
133 val notation: bool -> Syntax.mode -> (term * mixfix) list -> Proof.context -> Proof.context |
134 val target_notation: bool -> Syntax.mode -> (term * mixfix) list -> morphism -> |
134 val target_notation: bool -> Syntax.mode -> (term * mixfix) list -> morphism -> |
135 Context.generic -> Context.generic |
135 Context.generic -> Context.generic |
136 val add_const_constraint: string * typ option -> Proof.context -> Proof.context |
136 val add_const_constraint: string * typ option -> Proof.context -> Proof.context |
137 val add_abbrev: string -> Properties.T -> |
137 val add_abbrev: string -> Properties.T -> |
138 Name.binding * term -> Proof.context -> (term * term) * Proof.context |
138 Binding.T * term -> Proof.context -> (term * term) * Proof.context |
139 val revert_abbrev: string -> string -> Proof.context -> Proof.context |
139 val revert_abbrev: string -> string -> Proof.context -> Proof.context |
140 val verbose: bool ref |
140 val verbose: bool ref |
141 val setmp_verbose: ('a -> 'b) -> 'a -> 'b |
141 val setmp_verbose: ('a -> 'b) -> 'a -> 'b |
142 val print_syntax: Proof.context -> unit |
142 val print_syntax: Proof.context -> unit |
143 val print_abbrevs: Proof.context -> unit |
143 val print_abbrevs: Proof.context -> unit |
245 fun set_stmt stmt = |
245 fun set_stmt stmt = |
246 map_mode (fn (_, pattern, schematic, abbrev) => (stmt, pattern, schematic, abbrev)); |
246 map_mode (fn (_, pattern, schematic, abbrev) => (stmt, pattern, schematic, abbrev)); |
247 |
247 |
248 val naming_of = #naming o rep_context; |
248 val naming_of = #naming o rep_context; |
249 |
249 |
250 val full_name = NameSpace.full o naming_of; |
250 val full_name = NameSpace.full_name o naming_of; |
251 val full_binding = NameSpace.full_binding o naming_of; |
251 fun full_bname thy = NameSpace.full_name (naming_of thy) o Binding.name; |
252 |
252 |
253 val syntax_of = #syntax o rep_context; |
253 val syntax_of = #syntax o rep_context; |
254 val syn_of = LocalSyntax.syn_of o syntax_of; |
254 val syn_of = LocalSyntax.syn_of o syntax_of; |
255 val set_syntax_mode = map_syntax o LocalSyntax.set_mode; |
255 val set_syntax_mode = map_syntax o LocalSyntax.set_mode; |
256 val restore_syntax_mode = map_syntax o LocalSyntax.restore_mode o syntax_of; |
256 val restore_syntax_mode = map_syntax o LocalSyntax.restore_mode o syntax_of; |
963 |
963 |
964 (* facts *) |
964 (* facts *) |
965 |
965 |
966 local |
966 local |
967 |
967 |
968 fun update_thms _ (b, NONE) ctxt = ctxt |> map_facts (Facts.del (full_binding ctxt b)) |
968 fun update_thms _ (b, NONE) ctxt = ctxt |> map_facts (Facts.del (full_name ctxt b)) |
969 | update_thms do_props (b, SOME ths) ctxt = ctxt |> map_facts |
969 | update_thms do_props (b, SOME ths) ctxt = ctxt |> map_facts |
970 (Facts.add_local do_props (naming_of ctxt) (b, ths) #> snd); |
970 (Facts.add_local do_props (naming_of ctxt) (b, ths) #> snd); |
971 |
971 |
972 fun gen_note_thmss get k = fold_map (fn ((b, more_attrs), raw_facts) => fn ctxt => |
972 fun gen_note_thmss get k = fold_map (fn ((b, more_attrs), raw_facts) => fn ctxt => |
973 let |
973 let |
974 val pos = Binding.pos_of b; |
974 val pos = Binding.pos_of b; |
975 val name = full_binding ctxt b; |
975 val name = full_name ctxt b; |
976 val _ = ContextPosition.report_visible ctxt (Markup.local_fact_decl name) pos; |
976 val _ = ContextPosition.report_visible ctxt (Markup.local_fact_decl name) pos; |
977 |
977 |
978 val facts = PureThy.name_thmss false pos name (map (apfst (get ctxt)) raw_facts); |
978 val facts = PureThy.name_thmss false pos name (map (apfst (get ctxt)) raw_facts); |
979 fun app (th, attrs) x = |
979 fun app (th, attrs) x = |
980 swap (foldl_map (Thm.proof_attributes (surround (Thm.kind k) (attrs @ more_attrs))) (x, th)); |
980 swap (foldl_map (Thm.proof_attributes (surround (Thm.kind k) (attrs @ more_attrs))) (x, th)); |
1093 in ctxt |> (map_consts o apfst) (Consts.constrain (c, Option.map prepT opt_T)) end; |
1093 in ctxt |> (map_consts o apfst) (Consts.constrain (c, Option.map prepT opt_T)) end; |
1094 |
1094 |
1095 fun add_abbrev mode tags (b, raw_t) ctxt = |
1095 fun add_abbrev mode tags (b, raw_t) ctxt = |
1096 let |
1096 let |
1097 val t0 = cert_term (ctxt |> set_mode mode_abbrev) raw_t |
1097 val t0 = cert_term (ctxt |> set_mode mode_abbrev) raw_t |
1098 handle ERROR msg => cat_error msg ("in constant abbreviation " ^ quote (Name.display b)); |
1098 handle ERROR msg => cat_error msg ("in constant abbreviation " ^ quote (Binding.display b)); |
1099 val [t] = Variable.exportT_terms (Variable.declare_term t0 ctxt) ctxt [t0]; |
1099 val [t] = Variable.exportT_terms (Variable.declare_term t0 ctxt) ctxt [t0]; |
1100 val ((lhs, rhs), consts') = consts_of ctxt |
1100 val ((lhs, rhs), consts') = consts_of ctxt |
1101 |> Consts.abbreviate (Syntax.pp ctxt) (tsig_of ctxt) (naming_of ctxt) mode tags (b, t); |
1101 |> Consts.abbreviate (Syntax.pp ctxt) (tsig_of ctxt) (naming_of ctxt) mode tags (b, t); |
1102 in |
1102 in |
1103 ctxt |
1103 ctxt |
1144 fun auto_fixes (arg as (ctxt, (propss, x))) = |
1144 fun auto_fixes (arg as (ctxt, (propss, x))) = |
1145 ((fold o fold) Variable.auto_fixes propss ctxt, (propss, x)); |
1145 ((fold o fold) Variable.auto_fixes propss ctxt, (propss, x)); |
1146 |
1146 |
1147 fun bind_fixes xs ctxt = |
1147 fun bind_fixes xs ctxt = |
1148 let |
1148 let |
1149 val (_, ctxt') = ctxt |> add_fixes_i (map (fn x => (Name.binding x, NONE, NoSyn)) xs); |
1149 val (_, ctxt') = ctxt |> add_fixes_i (map (fn x => (Binding.name x, NONE, NoSyn)) xs); |
1150 fun bind (t as Free (x, T)) = |
1150 fun bind (t as Free (x, T)) = |
1151 if member (op =) xs x then |
1151 if member (op =) xs x then |
1152 (case lookup_skolem ctxt' x of SOME x' => Free (x', T) | NONE => t) |
1152 (case lookup_skolem ctxt' x of SOME x' => Free (x', T) | NONE => t) |
1153 else t |
1153 else t |
1154 | bind (t $ u) = bind t $ bind u |
1154 | bind (t $ u) = bind t $ bind u |