src/HOL/Tools/Metis/metis_reconstruct.ML
changeset 70508 23168cbe0ef8
parent 70506 3f5d7fbaa1ea
child 70512 06425eaa9cd7
equal deleted inserted replaced
70507:06a62b29085e 70508:23168cbe0ef8
    99 val axiom_inference = Thm.incr_indexes 1 oo lookth
    99 val axiom_inference = Thm.incr_indexes 1 oo lookth
   100 
   100 
   101 
   101 
   102 (* INFERENCE RULE: ASSUME *)
   102 (* INFERENCE RULE: ASSUME *)
   103 
   103 
   104 val EXCLUDED_MIDDLE = @{lemma "P \<Longrightarrow> \<not> P \<Longrightarrow> False" by (rule notE)}
   104 fun inst_excluded_middle i_atom =
   105 
   105   @{lemma "P \<Longrightarrow> \<not> P \<Longrightarrow> False" by (rule notE)}
   106 fun inst_excluded_middle ctxt i_atom =
   106   |> instantiate_normalize ([], [((("P", 0), \<^typ>\<open>bool\<close>), i_atom)])
   107   let val [vx] = Term.add_vars (Thm.prop_of EXCLUDED_MIDDLE) []
       
   108   in infer_instantiate_types ctxt [(vx, Thm.cterm_of ctxt i_atom)] EXCLUDED_MIDDLE end
       
   109 
   107 
   110 fun assume_inference ctxt type_enc concealed sym_tab atom =
   108 fun assume_inference ctxt type_enc concealed sym_tab atom =
   111   inst_excluded_middle ctxt
   109   singleton (hol_terms_of_metis ctxt type_enc concealed sym_tab) (Metis_Term.Fn atom)
   112     (singleton (hol_terms_of_metis ctxt type_enc concealed sym_tab) (Metis_Term.Fn atom))
   110   |> Thm.cterm_of ctxt |> inst_excluded_middle
   113 
   111 
   114 (* INFERENCE RULE: INSTANTIATE (SUBST). Type instantiations are ignored. Trying
   112 
   115    to reconstruct them admits new possibilities of errors, e.g. concerning
   113 (* INFERENCE RULE: INSTANTIATE (SUBST). *)
   116    sorts. Instead we try to arrange that new TVars are distinct and that types
   114 
   117    can be inferred from terms. *)
   115 (*Type instantiations are ignored. Trying to reconstruct them admits new
       
   116   possibilities of errors, e.g. concerning sorts. Instead we try to arrange
       
   117   hat new TVars are distinct and that types can be inferred from terms.*)
   118 
   118 
   119 fun inst_inference ctxt type_enc concealed sym_tab th_pairs fsubst th =
   119 fun inst_inference ctxt type_enc concealed sym_tab th_pairs fsubst th =
   120   let
   120   let
   121     val i_th = lookth th_pairs th
   121     val i_th = lookth th_pairs th
   122     val i_th_vars = Term.add_vars (Thm.prop_of i_th) []
   122     val i_th_vars = Term.add_vars (Thm.prop_of i_th) []
   296   end
   296   end
   297 
   297 
   298 
   298 
   299 (* INFERENCE RULE: REFL *)
   299 (* INFERENCE RULE: REFL *)
   300 
   300 
   301 val REFL_THM = Thm.incr_indexes 2 @{lemma "t \<noteq> t \<Longrightarrow> False" by (drule notE) (rule refl)}
   301 val REFL_THM = Thm.incr_indexes 2 @{lemma "x \<noteq> x \<Longrightarrow> False" by (drule notE) (rule refl)}
   302 
   302 
   303 val [refl_x] = Term.add_vars (Thm.prop_of REFL_THM) [];
   303 val [refl_x] = Term.add_vars (Thm.prop_of REFL_THM) [];
   304 val refl_idx = 1 + Thm.maxidx_of REFL_THM;
   304 val refl_idx = 1 + Thm.maxidx_of REFL_THM;
   305 
   305 
   306 fun refl_inference ctxt type_enc concealed sym_tab t =
   306 fun refl_inference ctxt type_enc concealed sym_tab t =