7 (* over the term t. *) |
7 (* over the term t. *) |
8 (* E.g tuple_lambda [] t produces %x . t where x is a dummy Variable *) |
8 (* E.g tuple_lambda [] t produces %x . t where x is a dummy Variable *) |
9 (* tuple_lambda [a] t produces %a . t *) |
9 (* tuple_lambda [a] t produces %a . t *) |
10 (* tuple_lambda [a,b,c] t produces %(a,b,c). t *) |
10 (* tuple_lambda [a,b,c] t produces %(a,b,c). t *) |
11 |
11 |
12 fun tuple_lambda [] t = Abs ("x", HOLogic.unitT, t) |
12 fun tuple_lambda [] t = Abs ("x", HOLogic.unitT, t) |
13 | tuple_lambda [x] t = lambda x t |
13 | tuple_lambda [x] t = lambda x t |
14 | tuple_lambda (x::xs) t = |
14 | tuple_lambda (x::xs) t = |
15 let |
15 let |
16 val t' = tuple_lambda xs t; |
16 val t' = tuple_lambda xs t; |
17 val Type ("fun", [T,U]) = fastype_of t'; |
17 val Type ("fun", [T,U]) = fastype_of t'; |
18 in |
18 in |
19 HOLogic.split_const (fastype_of x,T,U) $ lambda x t' |
19 HOLogic.split_const (fastype_of x,T,U) $ lambda x t' |
20 end; |
20 end; |
21 |
21 |
22 fun find_var frees name = |
22 fun find_var frees name = |
23 (case Library.find_first (equal name o fst o dest_Free) frees of |
23 (case Library.find_first (equal name o fst o dest_Free) frees of |
24 NONE => error ("No such Variable in term: " ^ quote name) |
24 NONE => error ("No such Variable in term: " ^ quote name) |
25 | SOME v => v); |
25 | SOME v => v); |
26 |
26 |
|
27 (* - names specifies the variables that are involved in the *) |
|
28 (* induction *) |
|
29 (* - rule is the induction rule to be applied *) |
27 fun nominal_induct_tac (names, rule) facts state = |
30 fun nominal_induct_tac (names, rule) facts state = |
28 let |
31 let |
29 val sg = Thm.sign_of_thm state; |
32 val sg = Thm.sign_of_thm state; |
30 val cert = Thm.cterm_of sg; |
33 val cert = Thm.cterm_of sg; |
31 val goal :: _ = Thm.prems_of state; (*exception Subscript*) |
34 val goal :: _ = Thm.prems_of state; (*exception Subscript*) |
36 fun inst_rule rule = |
39 fun inst_rule rule = |
37 let |
40 let |
38 val concl_vars = map Var (rev (Term.add_vars (Thm.concl_of rule) [])); |
41 val concl_vars = map Var (rev (Term.add_vars (Thm.concl_of rule) [])); |
39 val (P :: ts, x) = split_last concl_vars |
42 val (P :: ts, x) = split_last concl_vars |
40 handle Empty => error "Malformed conclusion of induction rule" |
43 handle Empty => error "Malformed conclusion of induction rule" |
41 | Bind => error "Malformed conclusion of induction rule"; |
44 | Bind => error "Malformed conclusion of induction rule"; |
42 in |
45 in |
43 cterm_instantiate |
46 cterm_instantiate |
44 ((cert P, cert (fold_rev lambda vars (tuple_lambda frees' (HOLogic.dest_Trueprop goal)))) :: |
47 ((cert P, cert (fold_rev lambda vars (tuple_lambda frees' (HOLogic.dest_Trueprop goal)))) :: |
45 (cert x, cert (if null frees' then HOLogic.unit else foldr1 HOLogic.mk_prod frees')) :: |
48 (cert x, cert (if null frees' then HOLogic.unit else foldr1 HOLogic.mk_prod frees')) :: |
46 (map cert ts ~~ map cert vars)) rule |
49 (map cert ts ~~ map cert vars)) rule |