equal
deleted
inserted
replaced
591 |
591 |
592 (* guess rule instantiation -- cannot handle pending goal parameters *) |
592 (* guess rule instantiation -- cannot handle pending goal parameters *) |
593 |
593 |
594 local |
594 local |
595 |
595 |
596 fun dest_env ctxt env = |
596 fun insts_env ctxt env = |
597 let |
597 let |
598 val pairs = Vartab.dest (Envir.term_env env); |
598 val pairs = Vartab.dest (Envir.term_env env); |
599 val types = Vartab.dest (Envir.type_env env); |
599 val types = Vartab.dest (Envir.type_env env); |
600 val ts = map (Thm.cterm_of ctxt o Envir.norm_term env o #2 o #2) pairs; |
600 val ts = map (Thm.cterm_of ctxt o Envir.norm_term env o #2 o #2) pairs; |
601 val xs = map #1 pairs ~~ map Thm.typ_of_cterm ts; |
601 val xs = map #1 pairs ~~ map Thm.typ_of_cterm ts; |
602 in (map (fn (ai, (S, T)) => ((ai, S), Thm.ctyp_of ctxt T)) types, xs ~~ ts) end; |
602 val instT = |
|
603 TVars.build (types |> fold (fn (ai, (S, T)) => TVars.add ((ai, S), Thm.ctyp_of ctxt T))); |
|
604 val inst = Vars.build (fold2 (fn x => fn t => Vars.add (x, t)) xs ts); |
|
605 in (instT, inst) end; |
603 |
606 |
604 in |
607 in |
605 |
608 |
606 fun guess_instance ctxt rule i st = |
609 fun guess_instance ctxt rule i st = |
607 let |
610 let |
618 val rule' = Thm.incr_indexes (maxidx + 1) rule; |
621 val rule' = Thm.incr_indexes (maxidx + 1) rule; |
619 val concl = Logic.strip_assums_concl goal; |
622 val concl = Logic.strip_assums_concl goal; |
620 in |
623 in |
621 Unify.smash_unifiers (Context.Proof ctxt) |
624 Unify.smash_unifiers (Context.Proof ctxt) |
622 [(Thm.concl_of rule', concl)] (Envir.empty (Thm.maxidx_of rule')) |
625 [(Thm.concl_of rule', concl)] (Envir.empty (Thm.maxidx_of rule')) |
623 |> Seq.map (fn env => Drule.instantiate_normalize (dest_env ctxt env) rule') |
626 |> Seq.map (fn env => Drule.instantiate_normalize (insts_env ctxt env) rule') |
624 end |
627 end |
625 end |
628 end |
626 handle General.Subscript => Seq.empty; |
629 handle General.Subscript => Seq.empty; |
627 |
630 |
628 end; |
631 end; |