src/Pure/Proof/proof_checker.ML
changeset 59621 291934bac95e
parent 59582 0fbed69ff081
child 60642 48dd1cefb4ae
equal deleted inserted replaced
59620:92d7d8e4f1bf 59621:291934bac95e
    76 
    76 
    77         fun thm_of_atom thm Ts =
    77         fun thm_of_atom thm Ts =
    78           let
    78           let
    79             val tvars = Term.add_tvars (Thm.full_prop_of thm) [] |> rev;
    79             val tvars = Term.add_tvars (Thm.full_prop_of thm) [] |> rev;
    80             val (fmap, thm') = Thm.varifyT_global' [] thm;
    80             val (fmap, thm') = Thm.varifyT_global' [] thm;
    81             val ctye = map (apply2 (Thm.ctyp_of thy))
    81             val ctye = map (apply2 (Thm.global_ctyp_of thy))
    82               (map TVar tvars @ map (fn ((_, S), ixn) => TVar (ixn, S)) fmap ~~ Ts)
    82               (map TVar tvars @ map (fn ((_, S), ixn) => TVar (ixn, S)) fmap ~~ Ts)
    83           in
    83           in
    84             Thm.instantiate (ctye, []) (forall_intr_vars (Thm.forall_intr_frees thm'))
    84             Thm.instantiate (ctye, []) (forall_intr_vars (Thm.forall_intr_frees thm'))
    85           end;
    85           end;
    86 
    86 
   104           | thm_of (vs, names) Hs (Abst (s, SOME T, prf)) =
   104           | thm_of (vs, names) Hs (Abst (s, SOME T, prf)) =
   105               let
   105               let
   106                 val (x, names') = Name.variant s names;
   106                 val (x, names') = Name.variant s names;
   107                 val thm = thm_of ((x, T) :: vs, names') Hs prf
   107                 val thm = thm_of ((x, T) :: vs, names') Hs prf
   108               in
   108               in
   109                 Thm.forall_intr (Thm.cterm_of thy (Free (x, T))) thm
   109                 Thm.forall_intr (Thm.global_cterm_of thy (Free (x, T))) thm
   110               end
   110               end
   111 
   111 
   112           | thm_of (vs, names) Hs (prf % SOME t) =
   112           | thm_of (vs, names) Hs (prf % SOME t) =
   113               let
   113               let
   114                 val thm = thm_of (vs, names) Hs prf;
   114                 val thm = thm_of (vs, names) Hs prf;
   115                 val ct = Thm.cterm_of thy (Term.subst_bounds (map Free vs, t));
   115                 val ct = Thm.global_cterm_of thy (Term.subst_bounds (map Free vs, t));
   116               in
   116               in
   117                 Thm.forall_elim ct thm
   117                 Thm.forall_elim ct thm
   118                 handle THM (s, _, _) => appl_error thy pretty_term vs Hs s prf t
   118                 handle THM (s, _, _) => appl_error thy pretty_term vs Hs s prf t
   119               end
   119               end
   120 
   120 
   121           | thm_of (vs, names) Hs (AbsP (s, SOME t, prf)) =
   121           | thm_of (vs, names) Hs (AbsP (s, SOME t, prf)) =
   122               let
   122               let
   123                 val ct = Thm.cterm_of thy (Term.subst_bounds (map Free vs, t));
   123                 val ct = Thm.global_cterm_of thy (Term.subst_bounds (map Free vs, t));
   124                 val thm = thm_of (vs, names) (Thm.assume ct :: Hs) prf;
   124                 val thm = thm_of (vs, names) (Thm.assume ct :: Hs) prf;
   125               in
   125               in
   126                 Thm.implies_intr ct thm
   126                 Thm.implies_intr ct thm
   127               end
   127               end
   128 
   128 
   133               in
   133               in
   134                 Thm.implies_elim thm thm'
   134                 Thm.implies_elim thm thm'
   135                 handle THM (s, _, _) => appl_error thy pretty_prf (fst vars) Hs s prf prf'
   135                 handle THM (s, _, _) => appl_error thy pretty_prf (fst vars) Hs s prf prf'
   136               end
   136               end
   137 
   137 
   138           | thm_of _ _ (Hyp t) = Thm.assume (Thm.cterm_of thy t)
   138           | thm_of _ _ (Hyp t) = Thm.assume (Thm.global_cterm_of thy t)
   139 
   139 
   140           | thm_of _ _ _ = error "thm_of_proof: partial proof term";
   140           | thm_of _ _ _ = error "thm_of_proof: partial proof term";
   141 
   141 
   142       in beta_eta_convert (thm_of ([], prf_names) [] prf) end
   142       in beta_eta_convert (thm_of ([], prf_names) [] prf) end
   143   end;
   143   end;