src/HOL/Tools/Groebner_Basis/normalizer.ML
changeset 23330 01c09922ce59
parent 23259 ccee01b8d1c5
child 23407 0e4452fcbeb8
equal deleted inserted replaced
23329:0dbb30302259 23330:01c09922ce59
     7 sig
     7 sig
     8  val mk_cnumber : ctyp -> integer -> cterm
     8  val mk_cnumber : ctyp -> integer -> cterm
     9  val mk_cnumeral : integer -> cterm
     9  val mk_cnumeral : integer -> cterm
    10  val semiring_normalize_conv : Proof.context -> Conv.conv
    10  val semiring_normalize_conv : Proof.context -> Conv.conv
    11  val semiring_normalize_tac : Proof.context -> int -> tactic
    11  val semiring_normalize_tac : Proof.context -> int -> tactic
    12  val semiring_normalize_wrapper :  NormalizerData.entry -> Conv.conv
    12  val semiring_normalize_wrapper :  Proof.context -> NormalizerData.entry -> Conv.conv
    13  val semiring_normalizers_conv :
    13  val semiring_normalizers_conv :
    14      cterm list -> cterm list * thm list -> cterm list * thm list ->
    14      cterm list -> cterm list * thm list -> cterm list * thm list ->
    15      (cterm -> bool) * Conv.conv * Conv.conv * Conv.conv -> (cterm -> Thm.cterm -> bool) ->
    15      (cterm -> bool) * Conv.conv * Conv.conv * Conv.conv -> (cterm -> Thm.cterm -> bool) ->
    16        {add: Conv.conv, mul: Conv.conv, neg: Conv.conv, main: Conv.conv, 
    16        {add: Conv.conv, mul: Conv.conv, neg: Conv.conv, main: Conv.conv, 
    17         pow: Conv.conv, sub: Conv.conv}
    17         pow: Conv.conv, sub: Conv.conv}
   620 
   620 
   621 val nat_arith = @{thms "nat_arith"};
   621 val nat_arith = @{thms "nat_arith"};
   622 val nat_exp_ss = HOL_basic_ss addsimps (nat_number @ nat_arith @ arith_simps @ rel_simps)
   622 val nat_exp_ss = HOL_basic_ss addsimps (nat_number @ nat_arith @ arith_simps @ rel_simps)
   623                               addsimps [Let_def, if_False, if_True, add_0, add_Suc];
   623                               addsimps [Let_def, if_False, if_True, add_0, add_Suc];
   624 
   624 
   625 fun semiring_normalize_wrapper ({vars, semiring, ring, idom}, 
   625 fun semiring_normalize_wrapper ctxt ({vars, semiring, ring, idom}, 
   626                                      {conv, dest_const, mk_const, is_const}) =
   626                                      {conv, dest_const, mk_const, is_const}) =
   627   let
   627   let
   628     fun ord t u = Term.term_ord (term_of t, term_of u) = LESS
   628     fun ord t u = Term.term_ord (term_of t, term_of u) = LESS
   629 
   629 
   630     val pow_conv =
   630     val pow_conv =
   631       arg_conv (Simplifier.rewrite nat_exp_ss)
   631       arg_conv (Simplifier.rewrite nat_exp_ss)
   632       then_conv Simplifier.rewrite
   632       then_conv Simplifier.rewrite
   633         (HOL_basic_ss addsimps [nth (snd semiring) 31, nth (snd semiring) 34])
   633         (HOL_basic_ss addsimps [nth (snd semiring) 31, nth (snd semiring) 34])
   634       then_conv conv
   634       then_conv conv ctxt
   635     val dat = (is_const, conv, conv, pow_conv)
   635     val dat = (is_const, conv ctxt, conv ctxt, pow_conv)
   636     val {main, ...} = semiring_normalizers_conv vars semiring ring dat ord
   636     val {main, ...} = semiring_normalizers_conv vars semiring ring dat ord
   637   in main end;
   637   in main end;
   638 
   638 
   639 fun semiring_normalize_conv ctxt tm =
   639 fun semiring_normalize_conv ctxt tm =
   640   (case NormalizerData.match ctxt tm of
   640   (case NormalizerData.match ctxt tm of
   641     NONE => reflexive tm
   641     NONE => reflexive tm
   642   | SOME res => semiring_normalize_wrapper res tm);
   642   | SOME res => semiring_normalize_wrapper ctxt res tm);
   643 
   643 
   644 
   644 
   645 fun semiring_normalize_tac ctxt = SUBGOAL (fn (goal, i) =>
   645 fun semiring_normalize_tac ctxt = SUBGOAL (fn (goal, i) =>
   646   rtac (semiring_normalize_conv ctxt
   646   rtac (semiring_normalize_conv ctxt
   647     (cterm_of (ProofContext.theory_of ctxt) (fst (Logic.dest_equals goal)))) i);
   647     (cterm_of (ProofContext.theory_of ctxt) (fst (Logic.dest_equals goal)))) i);