equal
deleted
inserted
replaced
151 val (postproc, ct') = sandwich ctxt ct; |
151 val (postproc, ct') = sandwich ctxt ct; |
152 in postproc (conv ctxt (Thm.term_of ct') ct') end; |
152 in postproc (conv ctxt (Thm.term_of ct') ct') end; |
153 |
153 |
154 fun evaluation sandwich lift_postproc eval ctxt t = |
154 fun evaluation sandwich lift_postproc eval ctxt t = |
155 let |
155 let |
156 val cert = Thm.cterm_of (Proof_Context.theory_of ctxt); |
156 val cert = Thm.global_cterm_of (Proof_Context.theory_of ctxt); |
157 val (postproc, ct') = sandwich ctxt (cert t); |
157 val (postproc, ct') = sandwich ctxt (cert t); |
158 in |
158 in |
159 Thm.term_of ct' |
159 Thm.term_of ct' |
160 |> eval ctxt |
160 |> eval ctxt |
161 |> lift_postproc (Thm.term_of o Thm.rhs_of o postproc o Thm.reflexive o cert) |
161 |> lift_postproc (Thm.term_of o Thm.rhs_of o postproc o Thm.reflexive o cert) |
166 |
166 |
167 (* post- and preprocessing *) |
167 (* post- and preprocessing *) |
168 |
168 |
169 fun normalized_tfrees_sandwich ctxt ct = |
169 fun normalized_tfrees_sandwich ctxt ct = |
170 let |
170 let |
171 val cert = Thm.cterm_of (Proof_Context.theory_of ctxt); |
171 val cert = Thm.global_cterm_of (Proof_Context.theory_of ctxt); |
172 val t = Thm.term_of ct; |
172 val t = Thm.term_of ct; |
173 val vs_original = fold_term_types (K (fold_atyps (insert (eq_fst op =) |
173 val vs_original = fold_term_types (K (fold_atyps (insert (eq_fst op =) |
174 o dest_TFree))) t []; |
174 o dest_TFree))) t []; |
175 val vs_normalized = Name.invent_names Name.context Name.aT (map snd vs_original); |
175 val vs_normalized = Name.invent_names Name.context Name.aT (map snd vs_original); |
176 val normalize = map_type_tfree (TFree o the o AList.lookup (op =) (vs_original ~~ vs_normalized)); |
176 val normalize = map_type_tfree (TFree o the o AList.lookup (op =) (vs_original ~~ vs_normalized)); |
183 end; |
183 end; |
184 |
184 |
185 fun no_variables_sandwich ctxt ct = |
185 fun no_variables_sandwich ctxt ct = |
186 let |
186 let |
187 val thy = Proof_Context.theory_of ctxt; |
187 val thy = Proof_Context.theory_of ctxt; |
188 val cert = Thm.cterm_of thy; |
188 val cert = Thm.global_cterm_of thy; |
189 val all_vars = fold_aterms (fn t as Free _ => insert (op aconvc) (cert t) |
189 val all_vars = fold_aterms (fn t as Free _ => insert (op aconvc) (cert t) |
190 | t as Var _ => insert (op aconvc) (cert t) |
190 | t as Var _ => insert (op aconvc) (cert t) |
191 | _ => I) (Thm.term_of ct) []; |
191 | _ => I) (Thm.term_of ct) []; |
192 fun apply_beta var thm = Thm.combination thm (Thm.reflexive var) |
192 fun apply_beta var thm = Thm.combination thm (Thm.reflexive var) |
193 |> Conv.fconv_rule (Conv.arg_conv (Conv.try_conv (Thm.beta_conversion false))) |
193 |> Conv.fconv_rule (Conv.arg_conv (Conv.try_conv (Thm.beta_conversion false))) |