src/HOL/arith_data.ML
changeset 15185 8c43ffe2bb32
parent 15184 d2c19aea17bc
child 15195 197e00ce3f20
equal deleted inserted replaced
15184:d2c19aea17bc 15185:8c43ffe2bb32
   203 (* arith theory data *)
   203 (* arith theory data *)
   204 
   204 
   205 structure ArithTheoryDataArgs =
   205 structure ArithTheoryDataArgs =
   206 struct
   206 struct
   207   val name = "HOL/arith";
   207   val name = "HOL/arith";
   208   type T = {splits: thm list, inj_consts: (string * typ)list, discrete: (string * bool) list, presburger: (int -> tactic) option};
   208   type T = {splits: thm list, inj_consts: (string * typ)list, discrete: string  list, presburger: (int -> tactic) option};
   209 
   209 
   210   val empty = {splits = [], inj_consts = [], discrete = [], presburger = None};
   210   val empty = {splits = [], inj_consts = [], discrete = [], presburger = None};
   211   val copy = I;
   211   val copy = I;
   212   val prep_ext = I;
   212   val prep_ext = I;
   213   fun merge ({splits= splits1, inj_consts= inj_consts1, discrete= discrete1, presburger= presburger1},
   213   fun merge ({splits= splits1, inj_consts= inj_consts1, discrete= discrete1, presburger= presburger1},
   214              {splits= splits2, inj_consts= inj_consts2, discrete= discrete2, presburger= presburger2}) =
   214              {splits= splits2, inj_consts= inj_consts2, discrete= discrete2, presburger= presburger2}) =
   215    {splits = Drule.merge_rules (splits1, splits2),
   215    {splits = Drule.merge_rules (splits1, splits2),
   216     inj_consts = merge_lists inj_consts1 inj_consts2,
   216     inj_consts = merge_lists inj_consts1 inj_consts2,
   217     discrete = merge_alists discrete1 discrete2,
   217     discrete = merge_lists discrete1 discrete2,
   218     presburger = (case presburger1 of None => presburger2 | p => p)};
   218     presburger = (case presburger1 of None => presburger2 | p => p)};
   219   fun print _ _ = ();
   219   fun print _ _ = ();
   220 end;
   220 end;
   221 
   221 
   222 structure ArithTheoryData = TheoryDataFun(ArithTheoryDataArgs);
   222 structure ArithTheoryData = TheoryDataFun(ArithTheoryDataArgs);
   337   | negate None = None;
   337   | negate None = None;
   338 
   338 
   339 fun of_lin_arith_sort sg U =
   339 fun of_lin_arith_sort sg U =
   340   Type.of_sort (Sign.tsig_of sg) (U,["Ring_and_Field.ordered_idom"])
   340   Type.of_sort (Sign.tsig_of sg) (U,["Ring_and_Field.ordered_idom"])
   341 
   341 
   342 (* FIXME: "discrete" should only contain discrete types *)
       
   343 fun allows_lin_arith sg discrete (U as Type(D,[])) =
   342 fun allows_lin_arith sg discrete (U as Type(D,[])) =
   344       if of_lin_arith_sort sg U
   343       if of_lin_arith_sort sg U
   345       then (true, case assoc(discrete,D) of None => false
   344       then (true, D mem discrete)
   346                   | Some d => d)
       
   347       else (* special cases *)
   345       else (* special cases *)
   348            (case assoc(discrete,D) of None => (false,false)
   346            if D mem discrete then (true,true) else (false,false)
   349             | Some d => (true,d))
       
   350   | allows_lin_arith sg discrete U = (of_lin_arith_sort sg U, false);
   347   | allows_lin_arith sg discrete U = (of_lin_arith_sort sg U, false);
   351 
   348 
   352 fun decomp1 (sg,discrete,inj_consts) (T,xxx) =
   349 fun decomp1 (sg,discrete,inj_consts) (T,xxx) =
   353   (case T of
   350   (case T of
   354      Type("fun",[U,_]) =>
   351      Type("fun",[U,_]) =>
   426     add_mono_thms_ordered_semiring @ add_mono_thms_ordered_field,
   423     add_mono_thms_ordered_semiring @ add_mono_thms_ordered_field,
   427     mult_mono_thms = mult_mono_thms,
   424     mult_mono_thms = mult_mono_thms,
   428     inj_thms = inj_thms,
   425     inj_thms = inj_thms,
   429     lessD = lessD @ [Suc_leI],
   426     lessD = lessD @ [Suc_leI],
   430     simpset = HOL_basic_ss addsimps add_rules addsimprocs nat_cancel_sums_add}),
   427     simpset = HOL_basic_ss addsimps add_rules addsimprocs nat_cancel_sums_add}),
   431   ArithTheoryData.init, arith_discrete ("nat", true)];
   428   ArithTheoryData.init, arith_discrete "nat"];
   432 
   429 
   433 end;
   430 end;
   434 
   431 
   435 val fast_nat_arith_simproc =
   432 val fast_nat_arith_simproc =
   436   Simplifier.simproc (Theory.sign_of (the_context ())) "fast_nat_arith"
   433   Simplifier.simproc (Theory.sign_of (the_context ())) "fast_nat_arith"