src/HOL/Groebner_Basis.thy
author haftmann
Thu Oct 23 19:40:39 2014 +0200 (2014-10-23)
changeset 58777 6ba2f1fa243b
parent 57951 7896762b638b
child 58889 5b7a9633cfa8
permissions -rw-r--r--
further downshift of theory Parity in the hierarchy
wenzelm@23252
     1
(*  Title:      HOL/Groebner_Basis.thy
wenzelm@23252
     2
    Author:     Amine Chaieb, TU Muenchen
wenzelm@23252
     3
*)
wenzelm@23252
     4
haftmann@36751
     5
header {* Groebner bases *}
haftmann@28402
     6
wenzelm@23252
     7
theory Groebner_Basis
haftmann@58777
     8
imports Semiring_Normalization Parity
haftmann@55509
     9
keywords "try0" :: diag
wenzelm@23252
    10
begin
wenzelm@23252
    11
haftmann@36712
    12
subsection {* Groebner Bases *}
haftmann@36712
    13
haftmann@54251
    14
lemmas bool_simps = simp_thms(1-34) -- {* FIXME move to @{theory HOL} *}
haftmann@54251
    15
haftmann@54251
    16
lemma nnf_simps: -- {* FIXME shadows fact binding in @{theory HOL} *}
haftmann@54251
    17
  "(\<not>(P \<and> Q)) = (\<not>P \<or> \<not>Q)" "(\<not>(P \<or> Q)) = (\<not>P \<and> \<not>Q)"
haftmann@54251
    18
  "(P \<longrightarrow> Q) = (\<not>P \<or> Q)"
haftmann@54251
    19
  "(P = Q) = ((P \<and> Q) \<or> (\<not>P \<and> \<not> Q))" "(\<not> \<not>(P)) = P"
haftmann@54251
    20
  by blast+
haftmann@36712
    21
haftmann@36712
    22
lemma dnf:
haftmann@54251
    23
  "(P & (Q | R)) = ((P&Q) | (P&R))"
haftmann@54251
    24
  "((Q | R) & P) = ((Q&P) | (R&P))"
haftmann@54251
    25
  "(P \<and> Q) = (Q \<and> P)"
haftmann@54251
    26
  "(P \<or> Q) = (Q \<or> P)"
haftmann@36712
    27
  by blast+
haftmann@36712
    28
haftmann@36712
    29
lemmas weak_dnf_simps = dnf bool_simps
haftmann@36712
    30
haftmann@36712
    31
lemma PFalse:
haftmann@36712
    32
    "P \<equiv> False \<Longrightarrow> \<not> P"
haftmann@36712
    33
    "\<not> P \<Longrightarrow> (P \<equiv> False)"
haftmann@36712
    34
  by auto
haftmann@36712
    35
wenzelm@57951
    36
named_theorems algebra "pre-simplification rules for algebraic methods"
wenzelm@48891
    37
ML_file "Tools/groebner.ML"
haftmann@36751
    38
wenzelm@47432
    39
method_setup algebra = {*
wenzelm@47432
    40
  let
wenzelm@47432
    41
    fun keyword k = Scan.lift (Args.$$$ k -- Args.colon) >> K ()
wenzelm@47432
    42
    val addN = "add"
wenzelm@47432
    43
    val delN = "del"
wenzelm@47432
    44
    val any_keyword = keyword addN || keyword delN
wenzelm@47432
    45
    val thms = Scan.repeat (Scan.unless any_keyword Attrib.multi_thm) >> flat;
wenzelm@47432
    46
  in
wenzelm@47432
    47
    Scan.optional (keyword addN |-- thms) [] --
wenzelm@47432
    48
     Scan.optional (keyword delN |-- thms) [] >>
wenzelm@47432
    49
    (fn (add_ths, del_ths) => fn ctxt =>
wenzelm@47432
    50
      SIMPLE_METHOD' (Groebner.algebra_tac add_ths del_ths ctxt))
wenzelm@47432
    51
  end
wenzelm@47432
    52
*} "solve polynomial equations over (semi)rings and ideal membership problems using Groebner bases"
haftmann@36751
    53
haftmann@36712
    54
declare dvd_def[algebra]
haftmann@36712
    55
declare dvd_eq_mod_eq_0[symmetric, algebra]
haftmann@36712
    56
declare mod_div_trivial[algebra]
haftmann@36712
    57
declare mod_mod_trivial[algebra]
huffman@47142
    58
declare div_by_0[algebra]
huffman@47142
    59
declare mod_by_0[algebra]
haftmann@36712
    60
declare zmod_zdiv_equality[symmetric,algebra]
huffman@47165
    61
declare div_mod_equality2[symmetric, algebra]
huffman@47159
    62
declare div_minus_minus[algebra]
huffman@47159
    63
declare mod_minus_minus[algebra]
huffman@47159
    64
declare div_minus_right[algebra]
huffman@47159
    65
declare mod_minus_right[algebra]
huffman@47142
    66
declare div_0[algebra]
huffman@47142
    67
declare mod_0[algebra]
haftmann@36712
    68
declare mod_by_1[algebra]
haftmann@36712
    69
declare div_by_1[algebra]
huffman@47160
    70
declare mod_minus1_right[algebra]
huffman@47160
    71
declare div_minus1_right[algebra]
haftmann@36712
    72
declare mod_mult_self2_is_0[algebra]
haftmann@36712
    73
declare mod_mult_self1_is_0[algebra]
haftmann@36712
    74
declare zmod_eq_0_iff[algebra]
haftmann@36712
    75
declare dvd_0_left_iff[algebra]
haftmann@36712
    76
declare zdvd1_eq[algebra]
haftmann@36712
    77
declare zmod_eq_dvd_iff[algebra]
haftmann@36712
    78
declare nat_mod_eq_iff[algebra]
haftmann@36712
    79
haftmann@58777
    80
context semiring_parity
haftmann@58777
    81
begin
haftmann@58777
    82
haftmann@58777
    83
declare even_times_iff [algebra]
haftmann@58777
    84
declare even_power [algebra]
haftmann@58777
    85
haftmann@28402
    86
end
haftmann@58777
    87
haftmann@58777
    88
context ring_parity
haftmann@58777
    89
begin
haftmann@58777
    90
haftmann@58777
    91
declare even_minus [algebra]
haftmann@58777
    92
haftmann@58777
    93
end
haftmann@58777
    94
haftmann@58777
    95
declare even_Suc [algebra]
haftmann@58777
    96
declare even_diff_nat [algebra]
haftmann@58777
    97
haftmann@58777
    98
end