src/HOL/Tools/lin_arith.ML
changeset 35230 be006fbcfb96
parent 35092 cfe605c54e50
child 35232 f588e1169c8b
equal deleted inserted replaced
35221:5cb63cb4213f 35230:be006fbcfb96
     4 HOL setup for linear arithmetic (see Provers/Arith/fast_lin_arith.ML).
     4 HOL setup for linear arithmetic (see Provers/Arith/fast_lin_arith.ML).
     5 *)
     5 *)
     6 
     6 
     7 signature LIN_ARITH =
     7 signature LIN_ARITH =
     8 sig
     8 sig
     9   val pre_tac: Proof.context -> int -> tactic
     9   val pre_tac: simpset -> int -> tactic
    10   val simple_tac: Proof.context -> int -> tactic
    10   val simple_tac: Proof.context -> int -> tactic
    11   val tac: Proof.context -> int -> tactic
    11   val tac: Proof.context -> int -> tactic
    12   val simproc: simpset -> term -> thm option
    12   val simproc: simpset -> term -> thm option
    13   val add_inj_thms: thm list -> Context.generic -> Context.generic
    13   val add_inj_thms: thm list -> Context.generic -> Context.generic
    14   val add_lessD: thm -> Context.generic -> Context.generic
    14   val add_lessD: thm -> Context.generic -> Context.generic
   703   val nnf_simpset =
   703   val nnf_simpset =
   704     empty_ss setmkeqTrue mk_eq_True
   704     empty_ss setmkeqTrue mk_eq_True
   705     setmksimps (mksimps mksimps_pairs)
   705     setmksimps (mksimps mksimps_pairs)
   706     addsimps [imp_conv_disj, iff_conv_conj_imp, de_Morgan_disj, de_Morgan_conj,
   706     addsimps [imp_conv_disj, iff_conv_conj_imp, de_Morgan_disj, de_Morgan_conj,
   707       not_all, not_ex, not_not]
   707       not_all, not_ex, not_not]
   708   fun prem_nnf_tac i st =
   708   fun prem_nnf_tac ss = full_simp_tac (Simplifier.inherit_context ss nnf_simpset)
   709     full_simp_tac (Simplifier.theory_context (Thm.theory_of_thm st) nnf_simpset)
       
   710       i st
       
   711 in
   709 in
   712 
   710 
   713 fun split_once_tac ctxt split_thms =
   711 fun split_once_tac ss split_thms =
   714   let
   712   let
       
   713     val ctxt = Simplifier.the_context ss
   715     val thy = ProofContext.theory_of ctxt
   714     val thy = ProofContext.theory_of ctxt
   716     val cond_split_tac = SUBGOAL (fn (subgoal, i) =>
   715     val cond_split_tac = SUBGOAL (fn (subgoal, i) =>
   717       let
   716       let
   718         val Ts = rev (map snd (Logic.strip_params subgoal))
   717         val Ts = rev (map snd (Logic.strip_params subgoal))
   719         val concl = HOLogic.dest_Trueprop (Logic.strip_assums_concl subgoal)
   718         val concl = HOLogic.dest_Trueprop (Logic.strip_assums_concl subgoal)
   732   in
   731   in
   733     EVERY' [
   732     EVERY' [
   734       REPEAT_DETERM o etac rev_mp,
   733       REPEAT_DETERM o etac rev_mp,
   735       cond_split_tac,
   734       cond_split_tac,
   736       rtac ccontr,
   735       rtac ccontr,
   737       prem_nnf_tac,
   736       prem_nnf_tac ss,
   738       TRY o REPEAT_ALL_NEW (DETERM o (eresolve_tac [conjE, exE] ORELSE' etac disjE))
   737       TRY o REPEAT_ALL_NEW (DETERM o (eresolve_tac [conjE, exE] ORELSE' etac disjE))
   739     ]
   738     ]
   740   end;
   739   end;
   741 
   740 
   742 end;  (* local *)
   741 end;  (* local *)
   744 (* remove irrelevant premises, then split the i-th subgoal (and all new      *)
   743 (* remove irrelevant premises, then split the i-th subgoal (and all new      *)
   745 (* subgoals) by using 'split_once_tac' repeatedly.  Beta-eta-normalize new   *)
   744 (* subgoals) by using 'split_once_tac' repeatedly.  Beta-eta-normalize new   *)
   746 (* subgoals and finally attempt to solve them by finding an immediate        *)
   745 (* subgoals and finally attempt to solve them by finding an immediate        *)
   747 (* contradiction (i.e., a term and its negation) in their premises.          *)
   746 (* contradiction (i.e., a term and its negation) in their premises.          *)
   748 
   747 
   749 fun pre_tac ctxt i =
   748 fun pre_tac ss i =
   750 let
   749 let
       
   750   val ctxt = Simplifier.the_context ss;
   751   val split_thms = filter is_split_thm (#splits (get_arith_data ctxt))
   751   val split_thms = filter is_split_thm (#splits (get_arith_data ctxt))
   752   fun is_relevant t = is_some (decomp ctxt t)
   752   fun is_relevant t = is_some (decomp ctxt t)
   753 in
   753 in
   754   DETERM (
   754   DETERM (
   755     TRY (filter_prems_tac is_relevant i)
   755     TRY (filter_prems_tac is_relevant i)
   756       THEN (
   756       THEN (
   757         (TRY o REPEAT_ALL_NEW (split_once_tac ctxt split_thms))
   757         (TRY o REPEAT_ALL_NEW (split_once_tac ss split_thms))
   758           THEN_ALL_NEW
   758           THEN_ALL_NEW
   759             (CONVERSION Drule.beta_eta_conversion
   759             (CONVERSION Drule.beta_eta_conversion
   760               THEN'
   760               THEN'
   761             (TRY o (etac notE THEN' eq_assume_tac)))
   761             (TRY o (etac notE THEN' eq_assume_tac)))
   762       ) i
   762       ) i