equal
deleted
inserted
replaced
2 Author: Makarius |
2 Author: Makarius |
3 |
3 |
4 Miscellaneous ML antiquotations: part 1. |
4 Miscellaneous ML antiquotations: part 1. |
5 *) |
5 *) |
6 |
6 |
7 structure ML_Antiquotations1: sig end = |
7 signature ML_ANTIQUOTATIONS1 = |
|
8 sig |
|
9 val make_judgment: Proof.context -> term -> term |
|
10 val dest_judgment: Proof.context -> term -> term |
|
11 end; |
|
12 |
|
13 structure ML_Antiquotations1: ML_ANTIQUOTATIONS1 = |
8 struct |
14 struct |
9 |
15 |
10 (* ML support *) |
16 (* ML support *) |
11 |
17 |
12 val _ = Theory.setup |
18 val _ = Theory.setup |
186 val _ = length Ts <> n andalso |
192 val _ = length Ts <> n andalso |
187 error ("Constant requires " ^ string_of_int n ^ " type argument(s): " ^ |
193 error ("Constant requires " ^ string_of_int n ^ " type argument(s): " ^ |
188 quote c ^ enclose "(" ")" (commas (replicate n "_")) ^ Position.here pos); |
194 quote c ^ enclose "(" ")" (commas (replicate n "_")) ^ Position.here pos); |
189 val const = Const (c, Consts.instance consts (c, Ts)); |
195 val const = Const (c, Consts.instance consts (c, Ts)); |
190 in ML_Syntax.atomic (ML_Syntax.print_term const) end))); |
196 in ML_Syntax.atomic (ML_Syntax.print_term const) end))); |
|
197 |
|
198 |
|
199 (* object-logic judgment *) |
|
200 |
|
201 fun make_judgment ctxt t = Const (Object_Logic.judgment_const ctxt) $ t; |
|
202 |
|
203 fun dest_judgment ctxt t = |
|
204 if Object_Logic.is_judgment ctxt t |
|
205 then Object_Logic.drop_judgment ctxt t |
|
206 else raise TERM ("dest_judgment", [t]); |
|
207 |
|
208 val _ = Theory.setup |
|
209 (ML_Antiquotation.value \<^binding>\<open>make_judgment\<close> |
|
210 (Scan.succeed "ML_Antiquotations1.make_judgment ML_context") #> |
|
211 ML_Antiquotation.value \<^binding>\<open>dest_judgment\<close> |
|
212 (Scan.succeed "ML_Antiquotations1.dest_judgment ML_context")); |
191 |
213 |
192 |
214 |
193 (* type/term constructors *) |
215 (* type/term constructors *) |
194 |
216 |
195 local |
217 local |