author | dixon |
Fri, 22 Apr 2005 15:10:42 +0200 | |
changeset 15814 | d65f461c8672 |
parent 15661 | 9ef583b08647 |
child 15915 | b0e8b37642a4 |
permissions | -rw-r--r-- |
15481 | 1 |
(* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- *) |
2 |
(* Title: libs/isa_fterm.ML |
|
3 |
Author: Lucas Dixon, University of Edinburgh |
|
4 |
lucasd@dai.ed.ac.uk |
|
5 |
Date: 16 April 2003 |
|
6 |
*) |
|
7 |
(* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- *) |
|
8 |
(* DESCRIPTION: |
|
9 |
||
10 |
Generic Foucs terms (like Zippers) instantiation for Isabelle terms. |
|
11 |
||
12 |
*) |
|
13 |
(* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- *) |
|
14 |
||
15 |
signature ISA_ENCODE_TERM = |
|
16 |
F_ENCODE_TERM_SIG |
|
17 |
where type term = Term.term type TypeT = Term.typ; |
|
18 |
||
19 |
||
20 |
(* signature BASIC_ISA_FTERM = |
|
21 |
FOCUS_TERM_SIG where type Term = ISA_ENCODE_TERM.Term *) |
|
22 |
||
23 |
signature ISA_FTERM = |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
24 |
sig |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
25 |
type Term = EncodeIsaFTerm.TermT |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
26 |
type Type = Term.typ |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
27 |
type UpTerm |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
28 |
datatype FcTerm = focus of Term * UpTerm |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
29 |
structure MinTermS : F_ENCODE_TERM_SIG |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
30 |
val add_upterm : |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
31 |
UpTerm -> FcTerm -> FcTerm |
15481 | 32 |
val clean_match_ft : |
33 |
Type.tsig -> |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
34 |
Term.term -> |
15481 | 35 |
FcTerm -> |
36 |
( |
|
37 |
((Term.indexname * Term.typ) list * (Term.indexname * Term.term) list) |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
38 |
* (string * Term.typ) list * (string * Term.typ) list * Term.term) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
39 |
option |
15481 | 40 |
val clean_unify_ft : |
41 |
Sign.sg -> |
|
42 |
int -> |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
43 |
Term.term -> |
15481 | 44 |
FcTerm -> |
45 |
( |
|
46 |
((Term.indexname * Term.typ) list * (Term.indexname * Term.term) list) |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
47 |
* (string * Term.typ) list * (string * Term.typ) list * Term.term) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
48 |
Seq.seq |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
49 |
val enc_appl : |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
50 |
EncodeIsaFTerm.term * UpTerm -> UpTerm |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
51 |
val enc_appr : |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
52 |
EncodeIsaFTerm.term * UpTerm -> UpTerm |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
53 |
val fakefree_badbounds : |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
54 |
(string * Term.typ) list -> Term.term -> |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
55 |
(string * Term.typ) list * (string * Term.typ) list * Term.term |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
56 |
val fcterm_of_term : EncodeIsaFTerm.term -> FcTerm |
15481 | 57 |
val find_fcterm_matches : |
58 |
((FcTerm -> 'a) -> FcTerm -> 'b) -> |
|
59 |
(FcTerm -> 'a) -> FcTerm -> 'b |
|
60 |
val find_sg_concl_matches : |
|
61 |
((FcTerm -> 'a) -> FcTerm -> 'b) -> |
|
62 |
(FcTerm -> 'a) -> int -> EncodeIsaFTerm.term -> 'b |
|
63 |
val find_sg_concl_thm_matches : |
|
64 |
((FcTerm -> 'a) -> FcTerm -> 'b) -> |
|
65 |
(FcTerm -> 'a) -> int -> Thm.thm -> 'b |
|
66 |
val find_sg_matches : |
|
67 |
((FcTerm -> 'a) -> FcTerm -> 'b) -> |
|
68 |
(FcTerm -> 'a) -> int -> EncodeIsaFTerm.term -> 'b |
|
69 |
val find_sg_thm_matches : |
|
70 |
((FcTerm -> 'a) -> FcTerm -> 'b) -> |
|
71 |
(FcTerm -> 'a) -> int -> Thm.thm -> 'b |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
72 |
val focus_abs : FcTerm -> FcTerm |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
73 |
val focus_bot_left_leaf : FcTerm -> FcTerm |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
74 |
val focus_bot_left_nonabs_leaf : |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
75 |
FcTerm -> FcTerm |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
76 |
val focus_fake_abs : FcTerm -> FcTerm |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
77 |
val focus_left : FcTerm -> FcTerm |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
78 |
val focus_of_fcterm : FcTerm -> EncodeIsaFTerm.term |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
79 |
val focus_right : FcTerm -> FcTerm |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
80 |
val focus_strict_left : FcTerm -> FcTerm |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
81 |
exception focus_term_exp of string |
15481 | 82 |
val focus_to_concl : FcTerm -> FcTerm |
83 |
val focus_to_concl_of_term : EncodeIsaFTerm.term -> FcTerm |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
84 |
val focus_to_dest_impl : |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
85 |
FcTerm -> FcTerm * FcTerm |
15481 | 86 |
val focus_to_subgoal : |
87 |
int -> FcTerm -> FcTerm |
|
88 |
val focus_to_subgoal_of_term : |
|
89 |
int -> EncodeIsaFTerm.term -> FcTerm |
|
90 |
val focus_to_term_goal_prem : |
|
91 |
int * int -> EncodeIsaFTerm.term -> FcTerm |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
92 |
val focus_to_top : FcTerm -> FcTerm |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
93 |
val focus_up : FcTerm -> FcTerm |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
94 |
val focus_up_abs : FcTerm -> FcTerm option |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
95 |
val focus_up_abs_or_appr : |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
96 |
FcTerm -> FcTerm option |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
97 |
val focus_up_appl : FcTerm -> FcTerm option |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
98 |
val focus_up_appr : FcTerm -> FcTerm option |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
99 |
val focus_up_right : FcTerm -> FcTerm |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
100 |
val focus_up_right1 : FcTerm -> FcTerm |
15481 | 101 |
val focuseq_to_subgoals : |
102 |
FcTerm -> FcTerm Seq.seq |
|
103 |
exception isa_focus_term_exp of string |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
104 |
val leaf_seq_of_fcterm : |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
105 |
FcTerm -> FcTerm Seq.seq |
15481 | 106 |
val mk_foo_match : |
107 |
(Term.term -> Term.term) -> |
|
108 |
('a * Term.typ) list -> Term.term -> Term.term |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
109 |
val mk_term_of_upterm : |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
110 |
EncodeIsaFTerm.term * UpTerm -> EncodeIsaFTerm.term |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
111 |
val mk_termf_of_upterm : |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
112 |
UpTerm -> |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
113 |
(string * Type) list * |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
114 |
(EncodeIsaFTerm.term -> EncodeIsaFTerm.term) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
115 |
val next_leaf_fcterm : FcTerm -> FcTerm |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
116 |
val next_leaf_of_fcterm_seq : |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
117 |
FcTerm -> FcTerm Seq.seq |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
118 |
exception out_of_term_exception of string |
15481 | 119 |
val prepmatch : |
120 |
FcTerm -> |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
121 |
Term.term * |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
122 |
((string * Term.typ) list * (string * Term.typ) list * Term.term) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
123 |
val pretty_fcterm : FcTerm -> Pretty.T |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
124 |
val pure_mk_termf_of_upterm : |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
125 |
(EncodeIsaFTerm.term, Type) UpTermLib.T -> |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
126 |
(string * Type) list * |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
127 |
(EncodeIsaFTerm.term -> EncodeIsaFTerm.term) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
128 |
val search_all_bl_ru_f : |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
129 |
(FcTerm -> 'a Seq.seq) -> |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
130 |
FcTerm -> 'a Seq.seq |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
131 |
val search_all_bl_ur_f : |
15481 | 132 |
(FcTerm -> 'a Seq.seq) -> |
133 |
FcTerm -> 'a Seq.seq |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
134 |
val search_tlr_all_f : |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
135 |
(FcTerm -> 'a Seq.seq) -> |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
136 |
FcTerm -> 'a Seq.seq |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
137 |
val search_tlr_valid_f : |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
138 |
(FcTerm -> 'a Seq.seq) -> |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
139 |
FcTerm -> 'a Seq.seq |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
140 |
val search_valid_bl_ru_f : |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
141 |
(FcTerm -> 'a Seq.seq) -> |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
142 |
FcTerm -> 'a Seq.seq |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
143 |
val search_valid_bl_ur_f : |
15481 | 144 |
(FcTerm -> 'a Seq.seq) -> |
145 |
FcTerm -> 'a Seq.seq |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
146 |
val set_focus_of_fcterm : |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
147 |
FcTerm -> EncodeIsaFTerm.term -> FcTerm |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
148 |
val term_of_fcterm : FcTerm -> EncodeIsaFTerm.term |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
149 |
val tyenv_of_focus : |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
150 |
FcTerm -> (string * Type) list |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
151 |
val tyenv_of_focus' : FcTerm -> Type list |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
152 |
val upsize_of_fcterm : FcTerm -> int |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
153 |
val upterm_of : FcTerm -> UpTerm |
15481 | 154 |
val valid_match_start : FcTerm -> bool |
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
155 |
end |
15481 | 156 |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
157 |
|
15481 | 158 |
|
159 |
structure BasicIsaFTerm = |
|
160 |
FocusTermFUN( structure EncodeTerm = EncodeIsaFTerm); |
|
161 |
||
162 |
(* HOL Dependent *) |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
163 |
structure IsaFTerm : ISA_FTERM= |
15481 | 164 |
struct |
165 |
||
166 |
(* include BasicIsaFTerm *) |
|
167 |
(* open FocusTermFUN( structure EncodeTerm = EncodeIsaFTerm ); *) |
|
168 |
||
169 |
open BasicIsaFTerm; |
|
170 |
||
171 |
||
15661
9ef583b08647
reverted renaming of Some/None in comments and strings;
wenzelm
parents:
15531
diff
changeset
|
172 |
(* Some general search within a focus term... *) |
15481 | 173 |
|
174 |
(* Note: only upterms with a free or constant are going to yeald a |
|
175 |
match, thus if we get anything else (bound or var) skip it! This is |
|
176 |
important if we switch to a unification net! in particular to avoid |
|
177 |
vars. *) |
|
178 |
||
179 |
fun valid_match_start ft = |
|
180 |
(case TermLib.bot_left_leaf_of (focus_of_fcterm ft) of |
|
181 |
Const _ => true |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
182 |
| Free _ => true |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
183 |
| Abs _ => true (* allowed to look inside abs... search decides if we actually consider the abstraction itself *) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
184 |
| _ => false); (* avoid vars - always suceeds uninterestingly. *) |
15481 | 185 |
|
186 |
(* match starting at the bottom left, moving up to top of the term, |
|
187 |
then moving right to the next leaf and up again etc *) |
|
188 |
(* FIXME: make properly lazy! *) |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
189 |
fun search_valid_bl_ur_f f ft = |
15481 | 190 |
let |
191 |
val fts = |
|
192 |
Seq.filter valid_match_start |
|
193 |
(leaf_seq_of_fcterm ft) |
|
194 |
||
195 |
fun mk_match_up_seq ft = |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
196 |
(* avoid abstractions? - possibly infinite unifiers? *) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
197 |
let val hereseq = case (focus_of_fcterm ft) of |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
198 |
Abs _ => Seq.empty |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
199 |
| _ => f ft |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
200 |
in |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
201 |
case focus_up_abs_or_appr ft of |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
202 |
SOME ft' => Seq.append(hereseq, mk_match_up_seq ft') |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
203 |
| NONE => hereseq |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
204 |
end |
15481 | 205 |
in |
206 |
Seq.flat (Seq.map mk_match_up_seq fts) |
|
207 |
end; |
|
208 |
||
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
209 |
fun search_all_bl_ur_f f ft = |
15481 | 210 |
let |
211 |
val fts = (leaf_seq_of_fcterm ft) |
|
212 |
||
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
213 |
fun mk_match_up_seq ft = |
15481 | 214 |
case focus_up_abs_or_appr ft of |
15531 | 215 |
SOME ft' => Seq.append(f ft, mk_match_up_seq ft') |
216 |
| NONE => f ft |
|
15481 | 217 |
in |
218 |
Seq.flat (Seq.map mk_match_up_seq fts) |
|
219 |
end; |
|
220 |
||
221 |
||
222 |
(* FIXME: make properly lazy! *) |
|
223 |
(* FIXME: make faking of bound vars local - for speeeeed *) |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
224 |
fun search_valid_bl_ru_f f ft = |
15481 | 225 |
let |
226 |
fun mauxtop ft = |
|
227 |
if (valid_match_start ft) |
|
228 |
then maux ft else Seq.empty |
|
229 |
and maux ft = |
|
230 |
let val t' = (focus_of_fcterm ft) |
|
231 |
(* val _ = writeln ("Examining: " ^ (TermLib.string_of_term t')) *) |
|
232 |
in |
|
233 |
(case t' of |
|
234 |
(_ $ _) => Seq.append (maux (focus_left ft), |
|
235 |
Seq.append(mauxtop (focus_right ft), |
|
236 |
f ft)) |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
237 |
| (Abs _) => maux (focus_abs ft) |
15481 | 238 |
| leaf => f ft) end |
239 |
in |
|
240 |
mauxtop ft |
|
241 |
end; |
|
242 |
||
243 |
||
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
244 |
fun search_all_bl_ru_f f ft = |
15481 | 245 |
let |
246 |
fun maux ft = |
|
247 |
let val t' = (focus_of_fcterm ft) |
|
248 |
(* val _ = writeln ("Examining: " ^ (TermLib.string_of_term t')) *) |
|
249 |
in |
|
250 |
(case t' of |
|
251 |
(_ $ _) => Seq.append (maux (focus_left ft), |
|
252 |
Seq.append(maux (focus_right ft), |
|
253 |
f ft)) |
|
254 |
| (Abs _) => Seq.append (maux (focus_abs ft), |
|
255 |
f ft) |
|
256 |
| leaf => f ft) end |
|
257 |
in maux ft end; |
|
258 |
||
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
259 |
(* search from top, left to right, then down *) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
260 |
fun search_tlr_all_f f ft = |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
261 |
let |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
262 |
fun maux ft = |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
263 |
let val t' = (focus_of_fcterm ft) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
264 |
(* val _ = |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
265 |
if !trace_subst_search then |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
266 |
(writeln ("Examining: " ^ (TermLib.string_of_term t')); |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
267 |
TermLib.writeterm t'; ()) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
268 |
else (); *) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
269 |
in |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
270 |
(case t' of |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
271 |
(_ $ _) => Seq.append(maux (focus_left ft), |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
272 |
Seq.append(f ft, |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
273 |
maux (focus_right ft))) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
274 |
| (Abs _) => Seq.append(f ft, maux (focus_abs ft)) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
275 |
| leaf => f ft) end |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
276 |
in maux ft end; |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
277 |
|
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
278 |
fun search_tlr_valid_f f ft = |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
279 |
let |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
280 |
fun maux ft = |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
281 |
let |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
282 |
val hereseq = if valid_match_start ft then f ft else Seq.empty |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
283 |
in |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
284 |
(case (focus_of_fcterm ft) of |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
285 |
(_ $ _) => Seq.append(maux (focus_left ft), |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
286 |
Seq.append(hereseq, |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
287 |
maux (focus_right ft))) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
288 |
| (Abs _) => Seq.append(hereseq, maux (focus_abs ft)) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
289 |
| leaf => hereseq) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
290 |
end |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
291 |
in maux ft end; |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
292 |
|
15481 | 293 |
|
294 |
||
295 |
exception isa_focus_term_exp of string; |
|
296 |
||
297 |
||
298 |
fun focus_to_dest_impl ft = |
|
299 |
let val (lhs, rhs) = |
|
300 |
Logic.dest_implies (focus_of_fcterm ft) |
|
301 |
in (focus_left ft, focus_right ft) end |
|
302 |
handle Term.TERM _ => |
|
303 |
raise isa_focus_term_exp |
|
304 |
"focus_to_dest_impl: applied to non implication"; |
|
305 |
||
306 |
||
307 |
(* move focus to the conlusion *) |
|
308 |
fun focus_to_concl ft = |
|
309 |
let val (lhs, rhs) = |
|
310 |
Logic.dest_implies (focus_of_fcterm ft) |
|
311 |
in focus_to_concl (focus_right ft) end |
|
312 |
handle Term.TERM _ => ft; |
|
313 |
||
314 |
val focus_to_concl_of_term = focus_to_concl o fcterm_of_term; |
|
315 |
||
316 |
||
317 |
||
318 |
(* give back sequence of focuses at different subgoals *) |
|
319 |
(* FIXME: make truly lazy *) |
|
320 |
fun focuseq_to_subgoals ft = |
|
321 |
if (Logic.is_implies (focus_of_fcterm ft)) then |
|
322 |
Seq.cons (focus_right (focus_left ft), focuseq_to_subgoals (focus_right ft)) |
|
323 |
else |
|
324 |
Seq.empty; |
|
325 |
||
326 |
(* move focus to a specific subgoal, 0 is first *) |
|
327 |
fun focus_to_subgoal j ft = |
|
328 |
let fun focus_to_subgoal' (ft, 0) = |
|
329 |
let val (lhs, rhs) = Logic.dest_implies (focus_of_fcterm ft) |
|
330 |
in ft |> focus_left |> focus_right end |
|
331 |
| focus_to_subgoal' (ft, i) = |
|
332 |
let val (lhs, rhs) = Logic.dest_implies (focus_of_fcterm ft) |
|
333 |
in focus_to_subgoal' (focus_right ft, i - 1) end |
|
334 |
in focus_to_subgoal' (ft, j - 1) end |
|
335 |
handle Term.TERM _ => |
|
336 |
raise isa_focus_term_exp |
|
337 |
("focus_to_subgoal: No such subgoal: " ^ |
|
338 |
(string_of_int j)); |
|
339 |
||
340 |
fun focus_to_subgoal_of_term i t = |
|
341 |
focus_to_subgoal i (fcterm_of_term t) |
|
342 |
||
343 |
(* move focus to a specific premise *) |
|
344 |
(* fun focus_past_params i ft = |
|
345 |
(focus_to_subgoal (focus_right ft, i)) |
|
346 |
handle isa_focus_term_exp _ => |
|
347 |
raise isa_focus_term_exp |
|
348 |
("focus_to_prmise: No such premise: " ^ (string_of_int i)); *) |
|
349 |
||
350 |
fun focus_to_term_goal_prem (premid,gaolid) t = |
|
351 |
focus_to_subgoal premid (focus_to_subgoal_of_term gaolid t); |
|
352 |
||
353 |
||
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
354 |
(* FIXME: make a sturcture for holding free variable names and making |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
355 |
them distinct --- ? maybe part of the new prooftree datatype ? |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
356 |
Alos: use this to fix below... *) |
15481 | 357 |
|
358 |
(* T is outer bound vars, n is number of locally bound vars *) |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
359 |
(* THINK: is order of Ts correct...? or reversed? *) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
360 |
fun fakefree_badbounds Ts t = |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
361 |
let val (FakeTs,Ts,newnames) = |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
362 |
List.foldr (fn ((n,ty),(FakeTs,Ts,usednames)) => |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
363 |
let val newname = Term.variant usednames n |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
364 |
in ((RWTools.mk_fake_bound_name newname,ty)::FakeTs, |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
365 |
(newname,ty)::Ts, |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
366 |
newname::usednames) end) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
367 |
([],[],[]) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
368 |
Ts |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
369 |
in (FakeTs, Ts, Term.subst_bounds (map Free FakeTs, t)) end; |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
370 |
|
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
371 |
(* fun fakefree_badbounds usednames T n (a $ b) = *) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
372 |
(* let val (usednames', T', a') = fakefree_badbounds usednames T n a *) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
373 |
(* val (usednames'', T'', b') = fakefree_badbounds usednames' T n b in *) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
374 |
(* (usednames'', T'', a' $ b') end *) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
375 |
(* | fakefree_badbounds usednames T n (Abs(s,ty,t)) = *) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
376 |
(* let val (usednames', T', t') = fakefree_badbounds usednames T (n + 1) t in *) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
377 |
(* (usednames', T', Abs(s,ty, t')) *) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
378 |
(* | fakefree_badbounds usednames T n (b as Bound i) = *) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
379 |
(* let fun mkfake_bound j [] = *) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
380 |
(* raise ERROR_MESSAGE "fakefree_badbounds: bound is outside of the known types!" *) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
381 |
(* | mkfake_bound 0 ((s,ty)::Ts) = *) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
382 |
(* let val newname = Term.variant s usednames in *) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
383 |
(* usednames, (newname,ty) :: T, Free (newname,ty) *) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
384 |
(* | mkfake_bound j (d::Ts) = mkfake_bound (j - 1) Ts *) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
385 |
(* in if n <= i then mkfake_bound (i - n) T else b end *) |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
386 |
(* | fakefree_badbounds usednames T t = t; *) |
15481 | 387 |
|
388 |
||
389 |
(* note: outerterm is the taget with the match replaced by a bound |
|
390 |
variable : ie: "P lhs" beocmes "%x. P x" |
|
391 |
insts is the types of instantiations of vars in lhs |
|
392 |
and typinsts is the type instantiations of types in the lhs |
|
393 |
Note: Final rule is the rule lifted into the ontext of the |
|
394 |
taget thm. *) |
|
395 |
fun mk_foo_match mkuptermfunc Ts t = |
|
396 |
let |
|
397 |
val ty = Term.type_of t |
|
398 |
val bigtype = (rev (map snd Ts)) ---> ty |
|
399 |
fun mk_foo 0 t = t |
|
400 |
| mk_foo i t = mk_foo (i - 1) (t $ (Bound (i - 1))) |
|
401 |
val num_of_bnds = (length Ts) |
|
402 |
(* foo_term = "fooabs y0 ... yn" where y's are local bounds *) |
|
403 |
val foo_term = mk_foo num_of_bnds (Bound num_of_bnds) |
|
404 |
in Abs("fooabs", bigtype, mkuptermfunc foo_term) end; |
|
405 |
||
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
406 |
(* before matching we need to fake the bound vars that are missing an |
15481 | 407 |
abstraction. In this function we additionally construct the |
408 |
abstraction environment, and an outer context term (with the focus |
|
409 |
abstracted out) for use in rewriting with RWInst.rw *) |
|
410 |
fun prepmatch ft = |
|
411 |
let |
|
412 |
val t = focus_of_fcterm ft |
|
413 |
val Ts = tyenv_of_focus ft |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
414 |
val (FakeTs', Ts', t') = fakefree_badbounds Ts t |
15481 | 415 |
fun mktermf t = |
416 |
term_of_fcterm (set_focus_of_fcterm ft t) |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
417 |
val absterm = mk_foo_match mktermf Ts' t' |
15481 | 418 |
in |
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
419 |
(t', (FakeTs', Ts', absterm)) |
15481 | 420 |
end; |
421 |
||
422 |
(* matching and unification for a focus term's focus *) |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
423 |
|
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
424 |
(* Note: Ts is a modified version of the original names of the outer |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
425 |
bound variables. New names have been introduced to make sure they are |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
426 |
unique w.r.t all names in the term and each other. usednames' is |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
427 |
oldnames + new names. *) |
15481 | 428 |
fun clean_match_ft tsig pat ft = |
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
429 |
let val (t, (FakeTs,Ts,absterm)) = prepmatch ft in |
15481 | 430 |
case TermLib.clean_match tsig (pat, t) of |
15531 | 431 |
NONE => NONE |
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
432 |
| SOME insts => SOME (insts, FakeTs, Ts, absterm) end; |
15481 | 433 |
(* ix = max var index *) |
434 |
fun clean_unify_ft sgn ix pat ft = |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
435 |
let val (t, (FakeTs, Ts,absterm)) = prepmatch ft in |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
436 |
Seq.map (fn insts => (insts, FakeTs, Ts, absterm)) |
15481 | 437 |
(TermLib.clean_unify sgn ix (t, pat)) end; |
438 |
||
439 |
||
440 |
(* THINK: ? do we not need to incremement bound indices? *) |
|
441 |
(* THINK: it should be the search which localisaes the search to the |
|
442 |
current focus, not this hack in the matcher... ? *) |
|
443 |
(* find matches below this particular focus term *) |
|
444 |
(* The search function is to find a match within a term... *) |
|
445 |
(* the matcher is something that is applied to each node chosen by the |
|
446 |
searchf and the results are flattened to form a lazy list. *) |
|
447 |
fun find_fcterm_matches searchf matcher ft = |
|
448 |
let |
|
449 |
val ftupterm = upterm_of ft |
|
450 |
val focusft = focus_of_fcterm ft |
|
451 |
val add_uptermf = add_upterm ftupterm |
|
452 |
in |
|
453 |
searchf |
|
454 |
(fn ft' => matcher (add_uptermf ft')) |
|
455 |
(fcterm_of_term focusft) |
|
456 |
end; |
|
457 |
||
458 |
(* FIXME: move argument orders for efficiency... |
|
459 |
i.e. wenzel style val foofunc = x o y; |
|
460 |
*) |
|
461 |
||
462 |
(* find the matches inside subgoal i of th *) |
|
463 |
fun find_sg_matches searchf matcher i t = |
|
15814
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
464 |
let |
d65f461c8672
lucas - fixed a big with renaming of bound variables. Other small changes.
dixon
parents:
15661
diff
changeset
|
465 |
val subgoal_fcterm = focus_to_subgoal_of_term i t |
15481 | 466 |
in find_fcterm_matches searchf matcher subgoal_fcterm end; |
467 |
||
468 |
(* find the matches inside subgoal i of th *) |
|
469 |
fun find_sg_thm_matches searchf matcher i th = |
|
470 |
find_sg_matches searchf matcher i (Thm.prop_of th); |
|
471 |
||
472 |
||
473 |
(* find the matches inside subgoal i's conclusion of th *) |
|
474 |
fun find_sg_concl_matches searchf matcher i t = |
|
475 |
let |
|
476 |
val subgoal_fcterm = |
|
477 |
focus_to_concl (focus_to_subgoal_of_term i t) |
|
478 |
in |
|
479 |
find_fcterm_matches searchf matcher subgoal_fcterm |
|
480 |
end; |
|
481 |
||
482 |
(* find the matches inside subgoal i's conclusion of th *) |
|
483 |
fun find_sg_concl_thm_matches searchf matcher i th = |
|
484 |
find_sg_concl_matches searchf matcher i (Thm.prop_of th); |
|
485 |
||
486 |
end; |
|
487 |
||
488 |
(* |
|
489 |
test... |
|
490 |
||
491 |
f_encode_isatermS.encode (read "P a"); |
|
492 |
isafocustermS.fcterm_of_term (read "f a"); |
|
493 |
isafocustermS.term_of_fcterm it; |
|
494 |
||
495 |
Goal "P b ==> P (suc b)"; |
|
496 |
||
497 |
TermLib.string_of_term ((focus_of_fcterm o focus_to_subgoal_of_term 1 o prop_of) (topthm())); |
|
498 |
||
499 |
TermLib.string_of_term ((focus_of_fcterm o focus_to_concl o focus_to_subgoal_of_term 1 o prop_of) (topthm())); |
|
500 |
||
501 |
TermLib.string_of_term ((focus_of_fcterm o focus_to_term_goal_prem (1,1) o prop_of) (topthm())); |
|
502 |
||
503 |
*) |