src/HOL/HOL.thy
changeset 24035 74c032aea9ed
parent 23948 261bd4678076
child 24166 7b28dc69bdbb
equal deleted inserted replaced
24034:ef0789aa7cbe 24035:74c032aea9ed
    22   "~~/src/Provers/blast.ML"
    22   "~~/src/Provers/blast.ML"
    23   "~~/src/Provers/clasimp.ML"
    23   "~~/src/Provers/clasimp.ML"
    24   "~~/src/Provers/eqsubst.ML"
    24   "~~/src/Provers/eqsubst.ML"
    25   "~~/src/Provers/quantifier1.ML"
    25   "~~/src/Provers/quantifier1.ML"
    26   ("simpdata.ML")
    26   ("simpdata.ML")
    27   "Tools/res_atpset.ML"
       
    28   ("~~/src/HOL/Tools/recfun_codegen.ML")
    27   ("~~/src/HOL/Tools/recfun_codegen.ML")
    29 begin
    28 begin
    30 
    29 
    31 subsection {* Primitive logic *}
    30 subsection {* Primitive logic *}
    32 
    31 
   926 structure BasicClassical: BASIC_CLASSICAL = Classical; 
   925 structure BasicClassical: BASIC_CLASSICAL = Classical; 
   927 open BasicClassical;
   926 open BasicClassical;
   928 
   927 
   929 ML_Context.value_antiq "claset"
   928 ML_Context.value_antiq "claset"
   930   (Scan.succeed ("claset", "Classical.local_claset_of (ML_Context.the_local_context ())"));
   929   (Scan.succeed ("claset", "Classical.local_claset_of (ML_Context.the_local_context ())"));
       
   930 
       
   931 structure ResAtpset = NamedThmsFun(val name = "atp" val description = "ATP rules");
   931 *}
   932 *}
   932 
   933 
   933 setup {*
   934 setup {*
   934 let
   935 let
   935   (*prevent substitution on bool*)
   936   (*prevent substitution on bool*)
  1281   #> (fn thy => (change_simpset_of thy (fn _ => Simpdata.simpset_simprocs); thy))
  1282   #> (fn thy => (change_simpset_of thy (fn _ => Simpdata.simpset_simprocs); thy))
  1282   #> Splitter.setup
  1283   #> Splitter.setup
  1283   #> Clasimp.setup
  1284   #> Clasimp.setup
  1284   #> EqSubst.setup
  1285   #> EqSubst.setup
  1285 *}
  1286 *}
       
  1287 
       
  1288 text {* Simproc for proving @{text "(y = x) == False"} from premise @{text "~(x = y)"}: *}
       
  1289 
       
  1290 simproc_setup neq ("x = y") = {* fn _ =>
       
  1291 let
       
  1292   val neq_to_EQ_False = @{thm not_sym} RS @{thm Eq_FalseI};
       
  1293   fun is_neq eq lhs rhs thm =
       
  1294     (case Thm.prop_of thm of
       
  1295       _ $ (Not $ (eq' $ l' $ r')) =>
       
  1296         Not = HOLogic.Not andalso eq' = eq andalso
       
  1297         r' aconv lhs andalso l' aconv rhs
       
  1298     | _ => false);
       
  1299   fun proc ss ct =
       
  1300     (case Thm.term_of ct of
       
  1301       eq $ lhs $ rhs =>
       
  1302         (case find_first (is_neq eq lhs rhs) (Simplifier.prems_of_ss ss) of
       
  1303           SOME thm => SOME (thm RS neq_to_EQ_False)
       
  1304         | NONE => NONE)
       
  1305      | _ => NONE);
       
  1306 in proc end;
       
  1307 *}
       
  1308 
       
  1309 simproc_setup let_simp ("Let x f") = {*
       
  1310 let
       
  1311   val (f_Let_unfold, x_Let_unfold) =
       
  1312     let val [(_$(f$x)$_)] = prems_of @{thm Let_unfold}
       
  1313     in (cterm_of @{theory} f, cterm_of @{theory} x) end
       
  1314   val (f_Let_folded, x_Let_folded) =
       
  1315     let val [(_$(f$x)$_)] = prems_of @{thm Let_folded}
       
  1316     in (cterm_of @{theory} f, cterm_of @{theory} x) end;
       
  1317   val g_Let_folded =
       
  1318     let val [(_$_$(g$_))] = prems_of @{thm Let_folded} in cterm_of @{theory} g end;
       
  1319 
       
  1320   fun proc _ ss ct =
       
  1321     let
       
  1322       val ctxt = Simplifier.the_context ss;
       
  1323       val thy = ProofContext.theory_of ctxt;
       
  1324       val t = Thm.term_of ct;
       
  1325       val ([t'], ctxt') = Variable.import_terms false [t] ctxt;
       
  1326     in Option.map (hd o Variable.export ctxt' ctxt o single)
       
  1327       (case t' of Const ("Let",_) $ x $ f => (* x and f are already in normal form *)
       
  1328         if is_Free x orelse is_Bound x orelse is_Const x
       
  1329         then SOME @{thm Let_def}
       
  1330         else
       
  1331           let
       
  1332             val n = case f of (Abs (x,_,_)) => x | _ => "x";
       
  1333             val cx = cterm_of thy x;
       
  1334             val {T=xT,...} = rep_cterm cx;
       
  1335             val cf = cterm_of thy f;
       
  1336             val fx_g = Simplifier.rewrite ss (Thm.capply cf cx);
       
  1337             val (_$_$g) = prop_of fx_g;
       
  1338             val g' = abstract_over (x,g);
       
  1339           in (if (g aconv g')
       
  1340                then
       
  1341                   let
       
  1342                     val rl =
       
  1343                       cterm_instantiate [(f_Let_unfold,cf),(x_Let_unfold,cx)] @{thm Let_unfold};
       
  1344                   in SOME (rl OF [fx_g]) end
       
  1345                else if Term.betapply (f,x) aconv g then NONE (*avoid identity conversion*)
       
  1346                else let
       
  1347                      val abs_g'= Abs (n,xT,g');
       
  1348                      val g'x = abs_g'$x;
       
  1349                      val g_g'x = symmetric (beta_conversion false (cterm_of thy g'x));
       
  1350                      val rl = cterm_instantiate
       
  1351                                [(f_Let_folded,cterm_of thy f),(x_Let_folded,cx),
       
  1352                                 (g_Let_folded,cterm_of thy abs_g')]
       
  1353                                @{thm Let_folded};
       
  1354                    in SOME (rl OF [transitive fx_g g_g'x])
       
  1355                    end)
       
  1356           end
       
  1357       | _ => NONE)
       
  1358     end
       
  1359 in proc end *}
       
  1360 
  1286 
  1361 
  1287 lemma True_implies_equals: "(True \<Longrightarrow> PROP P) \<equiv> PROP P"
  1362 lemma True_implies_equals: "(True \<Longrightarrow> PROP P) \<equiv> PROP P"
  1288 proof
  1363 proof
  1289   assume "True \<Longrightarrow> PROP P"
  1364   assume "True \<Longrightarrow> PROP P"
  1290   from this [OF TrueI] show "PROP P" .
  1365   from this [OF TrueI] show "PROP P" .