100 | tapp_ast_tr asts = raise Ast.AST ("tapp_ast_tr", asts); |
100 | tapp_ast_tr asts = raise Ast.AST ("tapp_ast_tr", asts); |
101 |
101 |
102 fun tappl_ast_tr [ty, tys, c] = Ast.mk_appl c (ty :: Ast.unfold_ast "_types" tys) |
102 fun tappl_ast_tr [ty, tys, c] = Ast.mk_appl c (ty :: Ast.unfold_ast "_types" tys) |
103 | tappl_ast_tr asts = raise Ast.AST ("tappl_ast_tr", asts); |
103 | tappl_ast_tr asts = raise Ast.AST ("tappl_ast_tr", asts); |
104 |
104 |
105 fun bracket_ast_tr [dom, cod] = Ast.fold_ast_p "\\<^type>fun" (Ast.unfold_ast "_types" dom, cod) |
105 fun bracket_ast_tr [dom, cod] = Ast.fold_ast_p "\<^type>fun" (Ast.unfold_ast "_types" dom, cod) |
106 | bracket_ast_tr asts = raise Ast.AST ("bracket_ast_tr", asts); |
106 | bracket_ast_tr asts = raise Ast.AST ("bracket_ast_tr", asts); |
107 |
107 |
108 |
108 |
109 (* application *) |
109 (* application *) |
110 |
110 |
150 |
150 |
151 (* type propositions *) |
151 (* type propositions *) |
152 |
152 |
153 fun mk_type ty = |
153 fun mk_type ty = |
154 Syntax.const "_constrain" $ |
154 Syntax.const "_constrain" $ |
155 Syntax.const "\\<^const>Pure.type" $ (Syntax.const "\\<^type>itself" $ ty); |
155 Syntax.const "\<^const>Pure.type" $ (Syntax.const "\<^type>itself" $ ty); |
156 |
156 |
157 fun ofclass_tr [ty, cls] = cls $ mk_type ty |
157 fun ofclass_tr [ty, cls] = cls $ mk_type ty |
158 | ofclass_tr ts = raise TERM ("ofclass_tr", ts); |
158 | ofclass_tr ts = raise TERM ("ofclass_tr", ts); |
159 |
159 |
160 fun sort_constraint_tr [ty] = Syntax.const "\\<^const>Pure.sort_constraint" $ mk_type ty |
160 fun sort_constraint_tr [ty] = Syntax.const "\<^const>Pure.sort_constraint" $ mk_type ty |
161 | sort_constraint_tr ts = raise TERM ("sort_constraint_tr", ts); |
161 | sort_constraint_tr ts = raise TERM ("sort_constraint_tr", ts); |
162 |
162 |
163 |
163 |
164 (* meta propositions *) |
164 (* meta propositions *) |
165 |
165 |
166 fun aprop_tr [t] = Syntax.const "_constrain" $ t $ Syntax.const "\\<^type>prop" |
166 fun aprop_tr [t] = Syntax.const "_constrain" $ t $ Syntax.const "\<^type>prop" |
167 | aprop_tr ts = raise TERM ("aprop_tr", ts); |
167 | aprop_tr ts = raise TERM ("aprop_tr", ts); |
168 |
168 |
169 |
169 |
170 (* meta implication *) |
170 (* meta implication *) |
171 |
171 |
172 fun bigimpl_ast_tr (asts as [asms, concl]) = |
172 fun bigimpl_ast_tr (asts as [asms, concl]) = |
173 let val prems = |
173 let val prems = |
174 (case Ast.unfold_ast_p "_asms" asms of |
174 (case Ast.unfold_ast_p "_asms" asms of |
175 (asms', Ast.Appl [Ast.Constant "_asm", asm']) => asms' @ [asm'] |
175 (asms', Ast.Appl [Ast.Constant "_asm", asm']) => asms' @ [asm'] |
176 | _ => raise Ast.AST ("bigimpl_ast_tr", asts)) |
176 | _ => raise Ast.AST ("bigimpl_ast_tr", asts)) |
177 in Ast.fold_ast_p "\\<^const>Pure.imp" (prems, concl) end |
177 in Ast.fold_ast_p "\<^const>Pure.imp" (prems, concl) end |
178 | bigimpl_ast_tr asts = raise Ast.AST ("bigimpl_ast_tr", asts); |
178 | bigimpl_ast_tr asts = raise Ast.AST ("bigimpl_ast_tr", asts); |
179 |
179 |
180 |
180 |
181 (* type/term reflection *) |
181 (* type/term reflection *) |
182 |
182 |
271 Ast.Appl [Ast.Constant "_tappl", ty, Ast.fold_ast "_types" tys, f]; |
271 Ast.Appl [Ast.Constant "_tappl", ty, Ast.fold_ast "_types" tys, f]; |
272 |
272 |
273 fun fun_ast_tr' asts = |
273 fun fun_ast_tr' asts = |
274 if no_brackets () orelse no_type_brackets () then raise Match |
274 if no_brackets () orelse no_type_brackets () then raise Match |
275 else |
275 else |
276 (case Ast.unfold_ast_p "\\<^type>fun" (Ast.Appl (Ast.Constant "\\<^type>fun" :: asts)) of |
276 (case Ast.unfold_ast_p "\<^type>fun" (Ast.Appl (Ast.Constant "\<^type>fun" :: asts)) of |
277 (dom as _ :: _ :: _, cod) |
277 (dom as _ :: _ :: _, cod) |
278 => Ast.Appl [Ast.Constant "_bracket", Ast.fold_ast "_types" dom, cod] |
278 => Ast.Appl [Ast.Constant "_bracket", Ast.fold_ast "_types" dom, cod] |
279 | _ => raise Match); |
279 | _ => raise Match); |
280 |
280 |
281 |
281 |
387 (* meta implication *) |
387 (* meta implication *) |
388 |
388 |
389 fun impl_ast_tr' asts = |
389 fun impl_ast_tr' asts = |
390 if no_brackets () then raise Match |
390 if no_brackets () then raise Match |
391 else |
391 else |
392 (case Ast.unfold_ast_p "\\<^const>Pure.imp" |
392 (case Ast.unfold_ast_p "\<^const>Pure.imp" |
393 (Ast.Appl (Ast.Constant "\\<^const>Pure.imp" :: asts)) of |
393 (Ast.Appl (Ast.Constant "\<^const>Pure.imp" :: asts)) of |
394 (prems as _ :: _ :: _, concl) => |
394 (prems as _ :: _ :: _, concl) => |
395 let |
395 let |
396 val (asms, asm) = split_last prems; |
396 val (asms, asm) = split_last prems; |
397 val asms' = Ast.fold_ast_p "_asms" (asms, Ast.Appl [Ast.Constant "_asm", asm]); |
397 val asms' = Ast.fold_ast_p "_asms" (asms, Ast.Appl [Ast.Constant "_asm", asm]); |
398 in Ast.Appl [Ast.Constant "_bigimpl", asms', concl] end |
398 in Ast.Appl [Ast.Constant "_bigimpl", asms', concl] end |
499 ("_update_name", fn _ => update_name_tr), |
499 ("_update_name", fn _ => update_name_tr), |
500 ("_index", fn _ => index_tr), |
500 ("_index", fn _ => index_tr), |
501 ("_struct", struct_tr)]; |
501 ("_struct", struct_tr)]; |
502 |
502 |
503 val pure_print_ast_translation = |
503 val pure_print_ast_translation = |
504 [("\\<^type>fun", fn _ => fun_ast_tr'), |
504 [("\<^type>fun", fn _ => fun_ast_tr'), |
505 ("_abs", fn _ => abs_ast_tr'), |
505 ("_abs", fn _ => abs_ast_tr'), |
506 ("_idts", fn _ => idtyp_ast_tr' "_idts"), |
506 ("_idts", fn _ => idtyp_ast_tr' "_idts"), |
507 ("_pttrns", fn _ => idtyp_ast_tr' "_pttrns"), |
507 ("_pttrns", fn _ => idtyp_ast_tr' "_pttrns"), |
508 ("\\<^const>Pure.imp", fn _ => impl_ast_tr'), |
508 ("\<^const>Pure.imp", fn _ => impl_ast_tr'), |
509 ("_index", fn _ => index_ast_tr'), |
509 ("_index", fn _ => index_ast_tr'), |
510 ("_struct", struct_ast_tr')]; |
510 ("_struct", struct_ast_tr')]; |
511 |
511 |
512 end; |
512 end; |
513 |
513 |