34 (*rules*) |
34 (*rules*) |
35 val bal_add1: thm |
35 val bal_add1: thm |
36 val bal_add2: thm |
36 val bal_add2: thm |
37 (*proof tools*) |
37 (*proof tools*) |
38 val prove_conv: tactic list -> Proof.context -> thm list -> term * term -> thm option |
38 val prove_conv: tactic list -> Proof.context -> thm list -> term * term -> thm option |
39 val trans_tac: thm option -> tactic (*applies the initial lemma*) |
39 val trans_tac: Proof.context -> thm option -> tactic (*applies the initial lemma*) |
40 val norm_tac: Proof.context -> tactic (*proves the initial lemma*) |
40 val norm_tac: Proof.context -> tactic (*proves the initial lemma*) |
41 val numeral_simp_tac: Proof.context -> tactic (*proves the final theorem*) |
41 val numeral_simp_tac: Proof.context -> tactic (*proves the final theorem*) |
42 val simplify_meta_eq: Proof.context -> thm -> thm (*simplifies the final theorem*) |
42 val simplify_meta_eq: Proof.context -> thm -> thm (*simplifies the final theorem*) |
43 end; |
43 end; |
44 |
44 |
90 (t', Data.mk_bal (newshape(n1,terms1'), newshape(n2,terms2'))) |
90 (t', Data.mk_bal (newshape(n1,terms1'), newshape(n2,terms2'))) |
91 in |
91 in |
92 Option.map (export o Data.simplify_meta_eq ctxt) |
92 Option.map (export o Data.simplify_meta_eq ctxt) |
93 (if n2 <= n1 then |
93 (if n2 <= n1 then |
94 Data.prove_conv |
94 Data.prove_conv |
95 [Data.trans_tac reshape, resolve_tac ctxt [Data.bal_add1] 1, |
95 [Data.trans_tac ctxt reshape, resolve_tac ctxt [Data.bal_add1] 1, |
96 Data.numeral_simp_tac ctxt] ctxt prems |
96 Data.numeral_simp_tac ctxt] ctxt prems |
97 (t', Data.mk_bal (newshape(n1-n2,terms1'), Data.mk_sum T terms2')) |
97 (t', Data.mk_bal (newshape(n1-n2,terms1'), Data.mk_sum T terms2')) |
98 else |
98 else |
99 Data.prove_conv |
99 Data.prove_conv |
100 [Data.trans_tac reshape, resolve_tac ctxt [Data.bal_add2] 1, |
100 [Data.trans_tac ctxt reshape, resolve_tac ctxt [Data.bal_add2] 1, |
101 Data.numeral_simp_tac ctxt] ctxt prems |
101 Data.numeral_simp_tac ctxt] ctxt prems |
102 (t', Data.mk_bal (Data.mk_sum T terms1', newshape(n2-n1,terms2')))) |
102 (t', Data.mk_bal (Data.mk_sum T terms1', newshape(n2-n1,terms2')))) |
103 end |
103 end |
104 (* FIXME avoid handling of generic exceptions *) |
104 (* FIXME avoid handling of generic exceptions *) |
105 handle TERM _ => NONE |
105 handle TERM _ => NONE |