60 (Args.src (("style", []), Position.none)) ctxt |>> (fn f => f ctxt)))); |
60 (Args.src (("style", []), Position.none)) ctxt |>> (fn f => f ctxt)))); |
61 |
61 |
62 |
62 |
63 (* predefined styles *) |
63 (* predefined styles *) |
64 |
64 |
65 fun style_binargs proj = Scan.succeed (fn ctxt => fn t => |
65 fun style_lhs_rhs proj = Scan.succeed (fn ctxt => fn t => |
66 let |
66 let |
67 val concl = ObjectLogic.drop_judgment (ProofContext.theory_of ctxt) |
67 val concl = ObjectLogic.drop_judgment (ProofContext.theory_of ctxt) |
68 (Logic.strip_imp_concl t) |
68 (Logic.strip_imp_concl t) |
69 in |
69 in |
70 case concl of (_ $ l $ r) => proj (l, r) |
70 case concl of (_ $ l $ r) => proj (l, r) |
71 | _ => error ("Binary operator expected in term: " ^ Syntax.string_of_term ctxt concl) |
71 | _ => error ("Binary operator expected in term: " ^ Syntax.string_of_term ctxt concl) |
72 end); |
72 end); |
73 |
73 |
|
74 val style_prem = Args.name >> (fn raw_i => fn ctxt => fn t => |
|
75 let |
|
76 val i = (the o Int.fromString) raw_i; |
|
77 val prems = Logic.strip_imp_prems t; |
|
78 in |
|
79 if i <= length prems then nth prems (i - 1) |
|
80 else error ("Not enough premises for prem " ^ string_of_int i ^ |
|
81 " in propositon: " ^ Syntax.string_of_term ctxt t) |
|
82 end); |
|
83 |
74 fun style_parm_premise i = Scan.succeed (fn ctxt => fn t => |
84 fun style_parm_premise i = Scan.succeed (fn ctxt => fn t => |
75 let val prems = Logic.strip_imp_prems t in |
85 let |
|
86 val i_str = string_of_int i; |
|
87 val prems = Logic.strip_imp_prems t; |
|
88 in |
76 if i <= length prems then nth prems (i - 1) |
89 if i <= length prems then nth prems (i - 1) |
77 else error ("Not enough premises for prem" ^ string_of_int i ^ |
90 else error ("Not enough premises for prem" ^ string_of_int i ^ |
78 " in propositon: " ^ Syntax.string_of_term ctxt t) |
91 " in propositon: " ^ Syntax.string_of_term ctxt t) |
79 end); |
92 end); |
80 |
93 |
81 val _ = Context.>> (Context.map_theory |
94 val _ = Context.>> (Context.map_theory |
82 (setup "lhs" (style_binargs fst) #> |
95 (setup "lhs" (style_lhs_rhs fst) #> |
83 setup "rhs" (style_binargs snd) #> |
96 setup "rhs" (style_lhs_rhs snd) #> |
|
97 setup "prem" style_prem #> |
|
98 setup "concl" (Scan.succeed (K Logic.strip_imp_concl)) #> |
84 setup "prem1" (style_parm_premise 1) #> |
99 setup "prem1" (style_parm_premise 1) #> |
85 setup "prem2" (style_parm_premise 2) #> |
100 setup "prem2" (style_parm_premise 2) #> |
86 setup "prem3" (style_parm_premise 3) #> |
101 setup "prem3" (style_parm_premise 3) #> |
87 setup "prem4" (style_parm_premise 4) #> |
102 setup "prem4" (style_parm_premise 4) #> |
88 setup "prem5" (style_parm_premise 5) #> |
103 setup "prem5" (style_parm_premise 5) #> |
97 setup "prem14" (style_parm_premise 14) #> |
112 setup "prem14" (style_parm_premise 14) #> |
98 setup "prem15" (style_parm_premise 15) #> |
113 setup "prem15" (style_parm_premise 15) #> |
99 setup "prem16" (style_parm_premise 16) #> |
114 setup "prem16" (style_parm_premise 16) #> |
100 setup "prem17" (style_parm_premise 17) #> |
115 setup "prem17" (style_parm_premise 17) #> |
101 setup "prem18" (style_parm_premise 18) #> |
116 setup "prem18" (style_parm_premise 18) #> |
102 setup "prem19" (style_parm_premise 19) #> |
117 setup "prem19" (style_parm_premise 19))); |
103 setup "concl" (Scan.succeed (K Logic.strip_imp_concl)))); |
|
104 |
118 |
105 end; |
119 end; |