equal
deleted
inserted
replaced
38 |
38 |
39 fun find_subterms (Bound i) lev path = |
39 fun find_subterms (Bound i) lev path = |
40 if i = lev then [[(Bound 0, path)]] |
40 if i = lev then [[(Bound 0, path)]] |
41 else [] |
41 else [] |
42 | find_subterms (t as (Abs (_, _, t2))) lev path = |
42 | find_subterms (t as (Abs (_, _, t2))) lev path = |
43 if filter (fn x => x<=lev) |
43 if List.filter (fn x => x<=lev) |
44 (add_loose_bnos (t, 0, [])) = [lev] then |
44 (add_loose_bnos (t, 0, [])) = [lev] then |
45 [(incr_bv (~lev, 0, t), path)]:: |
45 [(incr_bv (~lev, 0, t), path)]:: |
46 (find_subterms t2 (lev+1) (0::path)) |
46 (find_subterms t2 (lev+1) (0::path)) |
47 else find_subterms t2 (lev+1) (0::path) |
47 else find_subterms t2 (lev+1) (0::path) |
48 | find_subterms (t as (t1 $ t2)) lev path = |
48 | find_subterms (t as (t1 $ t2)) lev path = |
50 val ts2 = find_subterms t2 lev (1::path); |
50 val ts2 = find_subterms t2 lev (1::path); |
51 fun combine [] y = [] |
51 fun combine [] y = [] |
52 | combine (x::xs) ys = |
52 | combine (x::xs) ys = |
53 (map (fn z => x @ z) ys) @ (combine xs ys) |
53 (map (fn z => x @ z) ys) @ (combine xs ys) |
54 in |
54 in |
55 (if filter (fn x => x<=lev) |
55 (if List.filter (fn x => x<=lev) |
56 (add_loose_bnos (t, 0, [])) = [lev] then |
56 (add_loose_bnos (t, 0, [])) = [lev] then |
57 [[(incr_bv (~lev, 0, t), path)]] |
57 [[(incr_bv (~lev, 0, t), path)]] |
58 else []) @ |
58 else []) @ |
59 (if ts1 = [] then ts2 |
59 (if ts1 = [] then ts2 |
60 else if ts2 = [] then ts1 |
60 else if ts2 = [] then ts1 |
114 let val {sign, maxidx, ...} = rep_thm state; |
114 let val {sign, maxidx, ...} = rep_thm state; |
115 val j = maxidx+1; |
115 val j = maxidx+1; |
116 val tsig = Sign.tsig_of sign; |
116 val tsig = Sign.tsig_of sign; |
117 val parTs = map snd (rev params); |
117 val parTs = map snd (rev params); |
118 val rule = lift_rule (state, i) adm_subst; |
118 val rule = lift_rule (state, i) adm_subst; |
119 val types = the o (fst (types_sorts rule)); |
119 val types = valOf o (fst (types_sorts rule)); |
120 val tT = types ("t", j); |
120 val tT = types ("t", j); |
121 val PT = types ("P", j); |
121 val PT = types ("P", j); |
122 fun mk_abs [] t = t |
122 fun mk_abs [] t = t |
123 | mk_abs ((a,T)::Ts) t = Abs (a, T, mk_abs Ts t); |
123 | mk_abs ((a,T)::Ts) t = Abs (a, T, mk_abs Ts t); |
124 val tt = cterm_of sign (mk_abs (params @ [(s, T)]) subt); |
124 val tt = cterm_of sign (mk_abs (params @ [(s, T)]) subt); |
133 in rule' end; |
133 in rule' end; |
134 |
134 |
135 |
135 |
136 (*** extract subgoal i from proof state ***) |
136 (*** extract subgoal i from proof state ***) |
137 |
137 |
138 fun nth_subgoal i thm = nth_elem (i-1, prems_of thm); |
138 fun nth_subgoal i thm = List.nth (prems_of thm, i-1); |
139 |
139 |
140 |
140 |
141 (*** the admissibility tactic ***) |
141 (*** the admissibility tactic ***) |
142 |
142 |
143 fun try_dest_adm (Const _ $ (Const (name, _) $ Abs abs)) = |
143 fun try_dest_adm (Const _ $ (Const (name, _) $ Abs abs)) = |
153 let |
153 let |
154 val sign = sign_of_thm state; |
154 val sign = sign_of_thm state; |
155 val prems = Logic.strip_assums_hyp goali; |
155 val prems = Logic.strip_assums_hyp goali; |
156 val params = Logic.strip_params goali; |
156 val params = Logic.strip_params goali; |
157 val ts = find_subterms t 0 []; |
157 val ts = find_subterms t 0 []; |
158 val ts' = filter eq_terms ts; |
158 val ts' = List.filter eq_terms ts; |
159 val ts'' = filter (is_chfin sign T params) ts'; |
159 val ts'' = List.filter (is_chfin sign T params) ts'; |
160 val thms = foldl (prove_cont tac sign s T prems params) ([], ts''); |
160 val thms = Library.foldl (prove_cont tac sign s T prems params) ([], ts''); |
161 in |
161 in |
162 (case thms of |
162 (case thms of |
163 ((ts as ((t', _)::_), cont_thm)::_) => |
163 ((ts as ((t', _)::_), cont_thm)::_) => |
164 let |
164 let |
165 val paths = map snd ts; |
165 val paths = map snd ts; |