| 1 |
%< |
| 2 |
FILE: zet_fns.ml |
| 3 |
|
| 4 |
DESCRIPTION: tactics for integers |
| 5 |
|
| 6 |
AUTHOR: Ton Kalker |
| 7 |
|
| 8 |
DATE: 22-09-89 |
| 9 |
>% |
| 10 |
|
| 11 |
% BINDER_CONV conv "B x. tm[x]" applies conv to tm[x] % |
| 12 |
let BINDER_CONV conv = (RAND_CONV (ABS_CONV conv));; |
| 13 |
|
| 14 |
% LHS_CONV conv "OP t1 t2" applies conv to t1 % |
| 15 |
let LHS_CONV = RATOR_CONV o RAND_CONV ;; |
| 16 |
|
| 17 |
let ZET_INDUCT0_TAC (A,t) = |
| 18 |
(let th = ZET_INDUCTION0 in |
| 19 |
let x,body = dest_forall t in |
| 20 |
let tyi = snd(match (fst(dest_forall (concl th))) "\^x.T") in |
| 21 |
let spec = SPEC (mk_abs(x,body)) (INST_TYPE tyi th) in |
| 22 |
let spec' = DISCH_ALL (CONV_RULE (GEN_ALPHA_CONV x) (UNDISCH spec)) in |
| 23 |
let thm = CONV_RULE(RAND_CONV(BINDER_CONV BETA_CONV)) spec' in |
| 24 |
let tac = |
| 25 |
(MATCH_MP_TAC thm THEN |
| 26 |
CONJ_TAC THEN |
| 27 |
FIRST[CONV_TAC (BINDER_CONV((RAND_CONV BETA_CONV) THENC |
| 28 |
(LHS_CONV(RAND_CONV BETA_CONV)))); |
| 29 |
CONV_TAC (BINDER_CONV(RAND_CONV BETA_CONV))] )in |
| 30 |
tac (A,t));; |
| 31 |
|
| 32 |
%<The parameter k in the tactic below determines the |
| 33 |
point where induction really starts>% |
| 34 |
|
| 35 |
|
| 36 |
let ZET_INDUCT1_TAC k (A,t) = |
| 37 |
(let th = SPEC k ZET_INDUCTION1 in |
| 38 |
let x,body = dest_forall t in |
| 39 |
let tyi = snd(match (fst(dest_forall (concl th))) "\^x.T") in |
| 40 |
let spec = SPEC (mk_abs(x,body)) (INST_TYPE tyi th) in |
| 41 |
let spec' = DISCH_ALL (CONV_RULE (GEN_ALPHA_CONV x) (UNDISCH spec)) in |
| 42 |
let thm = CONV_RULE(RAND_CONV(BINDER_CONV BETA_CONV)) spec' in |
| 43 |
let PART_MATCH' partfn th = |
| 44 |
(let pth = GSPEC th in |
| 45 |
let pat = partfn(concl pth) in |
| 46 |
let matchfn = match pat in |
| 47 |
\tm. INST_TY_TERM (matchfn tm) pth) in |
| 48 |
let MATCH_MP_TAC' thm:tactic (gl,g) = |
| 49 |
(let imp = ((PART_MATCH' (snd o dest_imp) thm) g) ? |
| 50 |
failwith `MATCH_MP_TAC` in |
| 51 |
|
| 52 |
([gl,(fst(dest_imp(concl imp)))], \thl. MP imp (hd thl))) in |
| 53 |
let tac = |
| 54 |
(MATCH_MP_TAC' thm THEN |
| 55 |
REPEAT CONJ_TAC THEN |
| 56 |
GEN_TAC THENL |
| 57 |
[CONV_TAC (RAND_CONV BETA_CONV); |
| 58 |
CONV_TAC ((RAND_CONV BETA_CONV) THENC |
| 59 |
(LHS_CONV(RAND_CONV BETA_CONV)))] THEN |
| 60 |
REPEAT STRIP_TAC) in |
| 61 |
tac (A,t));; |
| 62 |
|
| 63 |
%<The parameter k in the tactic below determines the |
| 64 |
point where induction really starts>% |
| 65 |
|
| 66 |
let ZET_INDUCT2_TAC k (A,t) = |
| 67 |
(let th = SPEC k ZET_INDUCTION2 in |
| 68 |
let x,body = dest_forall t in |
| 69 |
let tyi = snd(match (fst(dest_forall (concl th))) "\^x.T") in |
| 70 |
let spec = SPEC (mk_abs(x,body)) (INST_TYPE tyi th) in |
| 71 |
let spec' = DISCH_ALL (CONV_RULE (GEN_ALPHA_CONV x) (UNDISCH spec)) in |
| 72 |
let thm = CONV_RULE(RAND_CONV(BINDER_CONV BETA_CONV)) spec' in |
| 73 |
let PART_MATCH' partfn th = |
| 74 |
(let pth = GSPEC th in |
| 75 |
let pat = partfn(concl pth) in |
| 76 |
let matchfn = match pat in |
| 77 |
\tm. INST_TY_TERM (matchfn tm) pth) in |
| 78 |
let MATCH_MP_TAC' thm:tactic (gl,g) = |
| 79 |
(let imp = ((PART_MATCH' (snd o dest_imp) thm) g) ? |
| 80 |
failwith `MATCH_MP_TAC` in |
| 81 |
|
| 82 |
([gl,(fst(dest_imp(concl imp)))], \thl. MP imp (hd thl))) in |
| 83 |
let tac = |
| 84 |
(MATCH_MP_TAC' thm THEN |
| 85 |
REPEAT CONJ_TAC THENL |
| 86 |
[ALL_TAC;GEN_TAC;GEN_TAC] THENL |
| 87 |
[CONV_TAC BETA_CONV; |
| 88 |
CONV_TAC ((RAND_CONV BETA_CONV) THENC |
| 89 |
(LHS_CONV(RAND_CONV BETA_CONV))); |
| 90 |
CONV_TAC ((RAND_CONV BETA_CONV) THENC |
| 91 |
(LHS_CONV(RAND_CONV BETA_CONV)))] THEN |
| 92 |
REPEAT STRIP_TAC) in |
| 93 |
tac (A,t));; |
| 94 |
|