src/HOL/Groebner_Basis.thy
changeset 23330 01c09922ce59
parent 23327 1654013ec97c
child 23332 b91295432e6d
equal deleted inserted replaced
23329:0dbb30302259 23330:01c09922ce59
   207       Rat.rat_of_int (snd
   207       Rat.rat_of_int (snd
   208         (HOLogic.dest_number (Thm.term_of ct)
   208         (HOLogic.dest_number (Thm.term_of ct)
   209           handle TERM _ => error "ring_dest_const")),
   209           handle TERM _ => error "ring_dest_const")),
   210     mk_const = fn phi => fn cT => fn x =>
   210     mk_const = fn phi => fn cT => fn x =>
   211       Thm.cterm_of (Thm.theory_of_ctyp cT) (HOLogic.mk_number (typ_of cT) (int_of_rat x)),
   211       Thm.cterm_of (Thm.theory_of_ctyp cT) (HOLogic.mk_number (typ_of cT) (int_of_rat x)),
   212     conv = fn phi => numeral_conv}
   212     conv = fn phi => K numeral_conv}
   213 *}
   213 *}
   214 
   214 
   215 
   215 
   216 locale gb_ring = gb_semiring +
   216 locale gb_ring = gb_semiring +
   217   fixes sub :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"
   217   fixes sub :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"
   248       Rat.rat_of_int (snd
   248       Rat.rat_of_int (snd
   249         (HOLogic.dest_number (Thm.term_of ct)
   249         (HOLogic.dest_number (Thm.term_of ct)
   250           handle TERM _ => error "ring_dest_const")),
   250           handle TERM _ => error "ring_dest_const")),
   251     mk_const = fn phi => fn cT => fn x =>
   251     mk_const = fn phi => fn cT => fn x =>
   252       Thm.cterm_of (Thm.theory_of_ctyp cT) (HOLogic.mk_number (typ_of cT) (int_of_rat x)),
   252       Thm.cterm_of (Thm.theory_of_ctyp cT) (HOLogic.mk_number (typ_of cT) (int_of_rat x)),
   253     conv = fn phi => numeral_conv}
   253     conv = fn phi => K numeral_conv}
   254 *}
   254 *}
   255 
   255 
   256 use "Tools/Groebner_Basis/normalizer.ML"
   256 use "Tools/Groebner_Basis/normalizer.ML"
   257 
   257 
   258 method_setup sring_norm = {*
   258 method_setup sring_norm = {*
   360       Rat.rat_of_int (snd
   360       Rat.rat_of_int (snd
   361         (HOLogic.dest_number (Thm.term_of ct)
   361         (HOLogic.dest_number (Thm.term_of ct)
   362           handle TERM _ => error "ring_dest_const")),
   362           handle TERM _ => error "ring_dest_const")),
   363     mk_const = fn phi => fn cT => fn x =>
   363     mk_const = fn phi => fn cT => fn x =>
   364       Thm.cterm_of (Thm.theory_of_ctyp cT) (HOLogic.mk_number (typ_of cT) (int_of_rat x)),
   364       Thm.cterm_of (Thm.theory_of_ctyp cT) (HOLogic.mk_number (typ_of cT) (int_of_rat x)),
   365     conv = fn phi => numeral_conv}
   365     conv = fn phi => K numeral_conv}
   366 *}
   366 *}
   367 
   367 
   368 
   368 
   369 interpretation natgb: semiringb
   369 interpretation natgb: semiringb
   370   ["op +" "op *" "op ^" "0::nat" "1"]
   370   ["op +" "op *" "op ^" "0::nat" "1"]
   395       Rat.rat_of_int (snd
   395       Rat.rat_of_int (snd
   396         (HOLogic.dest_number (Thm.term_of ct)
   396         (HOLogic.dest_number (Thm.term_of ct)
   397           handle TERM _ => error "ring_dest_const")),
   397           handle TERM _ => error "ring_dest_const")),
   398     mk_const = fn phi => fn cT => fn x =>
   398     mk_const = fn phi => fn cT => fn x =>
   399       Thm.cterm_of (Thm.theory_of_ctyp cT) (HOLogic.mk_number (typ_of cT) (int_of_rat x)),
   399       Thm.cterm_of (Thm.theory_of_ctyp cT) (HOLogic.mk_number (typ_of cT) (int_of_rat x)),
   400     conv = fn phi => numeral_conv}
   400     conv = fn phi => K numeral_conv}
   401 *}
   401 *}
   402 
   402 
   403 locale fieldgb = ringb + gb_field
   403 locale fieldgb = ringb + gb_field
   404 begin
   404 begin
   405 
   405 
   435   by auto
   435   by auto
   436 
   436 
   437 use "Tools/Groebner_Basis/groebner.ML"
   437 use "Tools/Groebner_Basis/groebner.ML"
   438 
   438 
   439 ML {*
   439 ML {*
   440   fun algebra_tac ctxt i = ObjectLogic.full_atomize_tac i THEN (fn st =>
   440   fun algebra_tac ctxt i = ObjectLogic.full_atomize_tac i 
   441   rtac (Groebner.ring_conv ctxt (Thm.dest_arg (nth (cprems_of st) (i - 1)))) i st);
   441   THEN (fn st =>
       
   442    case try (nth (cprems_of st)) (i - 1) of
       
   443     NONE => no_tac st
       
   444   | SOME p => let val th = Groebner.ring_conv ctxt (Thm.dest_arg p)
       
   445               in rtac th i st end
       
   446               handle TERM _ => no_tac st
       
   447               handle THM _ => no_tac st
       
   448               handle ERROR _ => no_tac st
       
   449               handle CTERM _ => no_tac st);
   442 *}
   450 *}
   443 
   451 
   444 method_setup algebra = {*
   452 method_setup algebra = {*
   445   Method.ctxt_args (Method.SIMPLE_METHOD' o algebra_tac)
   453   Method.ctxt_args (Method.SIMPLE_METHOD' o algebra_tac)
   446 *} ""
   454 *} ""