67 |
67 |
68 (*** NOTE: when the following two functions are called, all terms in the list |
68 (*** NOTE: when the following two functions are called, all terms in the list |
69 are equal (only their "paths" differ!) |
69 are equal (only their "paths" differ!) |
70 ***) |
70 ***) |
71 |
71 |
|
72 val HOLCF_sg = sign_of HOLCF.thy; |
|
73 val chfinS = Sign.intern_sort HOLCF_sg ["chfin"]; |
|
74 val pcpoS = Sign.intern_sort HOLCF_sg ["pcpo"]; |
|
75 val cont_name = Sign.intern_const (sign_of HOLCF.thy) "cont"; |
|
76 val adm_name = Sign.intern_const (sign_of HOLCF.thy) "adm"; |
|
77 |
|
78 |
72 (*** check whether type of terms in list is chain finite ***) |
79 (*** check whether type of terms in list is chain finite ***) |
73 |
80 |
74 fun is_chfin sign T params ((t, _)::_) = |
81 fun is_chfin sign T params ((t, _)::_) = |
75 let val {tsig, ...} = Sign.rep_sg sign; |
82 let val {tsig, ...} = Sign.rep_sg sign; |
76 val parTs = map snd (rev params) |
83 val parTs = map snd (rev params) |
77 in Type.of_sort tsig (fastype_of1 (T::parTs, t), ["chfin", "pcpo"]) end; |
84 in Type.of_sort tsig (fastype_of1 (T::parTs, t), [hd chfinS, hd pcpoS]) end; |
78 |
85 |
79 |
86 |
80 (*** try to prove that terms in list are continuous |
87 (*** try to prove that terms in list are continuous |
81 if successful, add continuity theorem to list l ***) |
88 if successful, add continuity theorem to list l ***) |
82 |
89 |
83 fun prove_cont tac sign s T prems params (l, ts as ((t, _)::_)) = |
90 fun prove_cont tac sign s T prems params (l, ts as ((t, _)::_)) = |
84 (let val parTs = map snd (rev params); |
91 (let val parTs = map snd (rev params); |
85 val contT = (T --> (fastype_of1 (T::parTs, t))) --> HOLogic.boolT; |
92 val contT = (T --> (fastype_of1 (T::parTs, t))) --> HOLogic.boolT; |
86 fun mk_all [] t = t |
93 fun mk_all [] t = t |
87 | mk_all ((a,T)::Ts) t = (all T) $ (Abs (a, T, mk_all Ts t)); |
94 | mk_all ((a,T)::Ts) t = (all T) $ (Abs (a, T, mk_all Ts t)); |
88 val t = HOLogic.mk_Trueprop ((Const ("cont", contT)) $ (Abs (s, T, t))); |
95 val t = HOLogic.mk_Trueprop((Const (cont_name, contT)) $ (Abs(s, T, t))); |
89 val t' = mk_all params (Logic.list_implies (prems, t)); |
96 val t' = mk_all params (Logic.list_implies (prems, t)); |
90 val thm = prove_goalw_cterm [] (cterm_of sign t') |
97 val thm = prove_goalw_cterm [] (cterm_of sign t') |
91 (fn ps => [cut_facts_tac ps 1, tac 1]) |
98 (fn ps => [cut_facts_tac ps 1, tac 1]) |
92 in (ts, thm)::l end) handle _ => l; |
99 in (ts, thm)::l end) handle _ => l; |
93 |
100 |
136 fun adm_tac tac i state = |
142 fun adm_tac tac i state = |
137 state |> |
143 state |> |
138 let val goali = nth_subgoal i state |
144 let val goali = nth_subgoal i state |
139 in |
145 in |
140 case Logic.strip_assums_concl goali of |
146 case Logic.strip_assums_concl goali of |
141 ((Const _) $ ((Const ("adm", _)) $ (Abs (s, T, t)))) => |
147 ((Const _) $ ((Const (name, _)) $ (Abs (s, T, t)))) => |
142 let val {sign, ...} = rep_thm state; |
148 let val {sign, ...} = rep_thm state; |
143 val prems = Logic.strip_assums_hyp goali; |
149 val prems = Logic.strip_assums_hyp goali; |
144 val params = Logic.strip_params goali; |
150 val params = Logic.strip_params goali; |
145 val ts = find_subterms t 0 []; |
151 val ts = find_subterms t 0 []; |
146 val ts' = filter eq_terms ts; |
152 val ts' = filter eq_terms ts; |
147 val ts'' = filter (is_chfin sign T params) ts'; |
153 val ts'' = filter (is_chfin sign T params) ts'; |
148 val thms = foldl (prove_cont tac sign s T prems params) ([], ts'') |
154 val thms = foldl (prove_cont tac sign s T prems params) ([], ts'') |
149 in case thms of |
155 in if name = adm_name then case thms of |
150 ((ts as ((t', _)::_), cont_thm)::_) => |
156 ((ts as ((t', _)::_), cont_thm)::_) => |
151 let val paths = map snd ts; |
157 let val paths = map snd ts; |
152 val rule = inst_adm_subst_thm state i params s T t' t paths; |
158 val rule = inst_adm_subst_thm state i params s T t' t paths; |
153 in |
159 in |
154 (compose_tac (false, rule, 2) i) THEN |
160 (compose_tac (false, rule, 2) i) THEN |
155 (rtac cont_thm i) THEN |
161 (rtac cont_thm i) THEN |
156 (REPEAT (assume_tac i)) THEN |
162 (REPEAT (assume_tac i)) THEN |
157 (rtac adm_chain_finite i) |
163 (rtac adm_chain_finite i) |
158 end |
164 end |
159 | [] => no_tac |
165 | [] => no_tac |
|
166 else no_tac |
160 end |
167 end |
161 | _ => no_tac |
168 | _ => no_tac |
162 end; |
169 end; |
163 |
170 |
164 end; |
171 end; |