src/HOL/Algebra/poly/UnivPoly.ML
author ballarin
Sat, 10 Feb 2001 08:52:41 +0100
changeset 11093 62c2e0af1d30
parent 8707 5de763446504
child 13735 7de9342aca7a
permissions -rw-r--r--
Changes to HOL/Algebra: - Axclasses consolidated (axiom one_not_zero). - Now uses summation operator setsum; SUM has been removed. - Priority of infix assoc changed to 50, in accordance to dvd.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
     1
(*
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
     2
    Univariate Polynomials
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
     3
    $Id$
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
     4
    Author: Clemens Ballarin, started 9 December 1996
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
     5
TODO: monom is *mono*morphism (probably induction needed)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
     6
*)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
     7
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
     8
(* Closure of UP under +, *s, monom, const and * *)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
     9
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    10
Goalw [UP_def]
8707
paulson
parents: 8006
diff changeset
    11
  "[| f : UP; g : UP |] ==> (%n. (f n + g n::'a::ring)) : UP";
paulson
parents: 8006
diff changeset
    12
by Auto_tac;
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    13
(* instantiate bound for the sum and do case split *)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    14
by (res_inst_tac [("x", "if n<=na then na else n")] exI 1);
8707
paulson
parents: 8006
diff changeset
    15
by Auto_tac;
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    16
(* first case, bound of g higher *)
8707
paulson
parents: 8006
diff changeset
    17
by (dtac le_bound 1 THEN assume_tac 1);
paulson
parents: 8006
diff changeset
    18
by (Force_tac 1);
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    19
(* second case is identical,
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    20
  apart from we have to massage the inequality *)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    21
by (dtac (not_leE RS less_imp_le) 1);
8707
paulson
parents: 8006
diff changeset
    22
by (dtac le_bound 1 THEN assume_tac 1);
paulson
parents: 8006
diff changeset
    23
by (Force_tac 1);
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    24
qed "UP_closed_add";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    25
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    26
Goalw [UP_def]
8707
paulson
parents: 8006
diff changeset
    27
  "f : UP ==> (%n. (a * f n::'a::ring)) : UP";
paulson
parents: 8006
diff changeset
    28
by (Force_tac 1);
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    29
qed "UP_closed_smult";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    30
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    31
Goalw [UP_def]
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
    32
  "(%n. if m = n then <1> else 0) : UP";
8707
paulson
parents: 8006
diff changeset
    33
by Auto_tac;
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    34
qed "UP_closed_monom";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    35
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
    36
Goalw [UP_def] "(%n. if n = 0 then a else 0) : UP";
8707
paulson
parents: 8006
diff changeset
    37
by Auto_tac;
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    38
qed "UP_closed_const";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    39
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    40
Goal
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    41
  "!! f::nat=>'a::ring. \
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
    42
\    [| bound n f; bound m g; n + m < k |] ==> f i * g (k - i) = 0";
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    43
(* Case split: either f i or g (k - i) is zero *)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    44
by (case_tac "n<i" 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    45
(* First case, f i is zero *)
8707
paulson
parents: 8006
diff changeset
    46
by (Force_tac 1);
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    47
(* Second case, we have to derive m < k-i *)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    48
by (subgoal_tac "m < k-i" 1);
8707
paulson
parents: 8006
diff changeset
    49
by (arith_tac 2);
paulson
parents: 8006
diff changeset
    50
by (Force_tac 1);
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    51
qed "bound_mult_zero";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    52
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    53
Goalw [UP_def]
8707
paulson
parents: 8006
diff changeset
    54
  "[| f : UP; g : UP |] ==> \
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
    55
\      (%n. (setsum (%i. f i * g (n-i)) {..n}::'a::ring)) : UP";
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    56
by (Step_tac 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    57
(* Instantiate bound for the product, and remove bound in goal *)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    58
by (res_inst_tac [("x", "n + na")] exI 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    59
by (Step_tac 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    60
(* Show that the sum is 0 *)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    61
by (asm_simp_tac (simpset() addsimps [bound_mult_zero]) 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    62
qed "UP_closed_mult";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    63
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
    64
(* %x. 0 represents a polynomial *)
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    65
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
    66
Goalw [UP_def] "(%x. 0) : UP";
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    67
by (Fast_tac 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    68
qed "UP_zero";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    69
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    70
(* Effect of +, *s, monom, * and the other operations on the coefficients *)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    71
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    72
Goalw [coeff_def, up_add_def]
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    73
  "coeff n (p+q) = (coeff n p + coeff n q::'a::ring)";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    74
by (asm_simp_tac (simpset() addsimps [Abs_UP_inverse, UP_closed_add, Rep_UP]) 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    75
qed "coeff_add";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    76
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    77
Goalw [coeff_def, up_smult_def]
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    78
  "!!a::'a::ring. coeff n (a *s p) = a * coeff n p";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    79
by (asm_simp_tac (simpset() addsimps [Abs_UP_inverse, UP_closed_smult, Rep_UP]) 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    80
qed "coeff_smult";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    81
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    82
Goalw [coeff_def, monom_def]
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
    83
  "coeff n (monom m) = (if m=n then <1> else 0)";
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    84
by (asm_simp_tac (simpset() addsimps [Abs_UP_inverse, UP_closed_monom, Rep_UP]) 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    85
qed "coeff_monom";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    86
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    87
Goalw [coeff_def, const_def]
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
    88
  "coeff n (const a) = (if n=0 then a else 0)";
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    89
by (asm_simp_tac (simpset() addsimps [Abs_UP_inverse, UP_closed_const, Rep_UP]) 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    90
qed "coeff_const";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    91
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    92
Goalw [coeff_def, up_mult_def]
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
    93
  "coeff n (p * q) = (setsum (%i. coeff i p * coeff (n-i) q) {..n}::'a::ring)";
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    94
by (asm_simp_tac (simpset() addsimps [Abs_UP_inverse, UP_closed_mult, Rep_UP]) 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    95
qed "coeff_mult";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    96
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
    97
Goalw [coeff_def, up_zero_def] "coeff n 0 = 0";
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    98
by (asm_simp_tac (simpset() addsimps [Abs_UP_inverse, UP_zero, Rep_UP]) 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    99
qed "coeff_zero";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   100
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   101
Addsimps [coeff_add, coeff_smult, coeff_monom, coeff_const, 
8707
paulson
parents: 8006
diff changeset
   102
	  coeff_mult, coeff_zero];
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   103
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   104
Goalw [up_one_def]
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
   105
  "coeff n <1> = (if n=0 then <1> else 0)";
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   106
by (Simp_tac 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   107
qed "coeff_one";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   108
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   109
Goalw [up_uminus_def] "coeff n (-p) = (-coeff n p::'a::ring)";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   110
by (simp_tac (simpset() addsimps m_minus) 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   111
qed "coeff_uminus";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   112
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   113
Addsimps [coeff_one, coeff_uminus];
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   114
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   115
(* Polynomials form a ring *)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   116
8707
paulson
parents: 8006
diff changeset
   117
val prems = Goalw [coeff_def]
paulson
parents: 8006
diff changeset
   118
  "(!! n. coeff n p = coeff n q) ==> p = q";
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   119
by (res_inst_tac [("t", "p")] (Rep_UP_inverse RS subst) 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   120
by (res_inst_tac [("t", "q")] (Rep_UP_inverse RS subst) 1);
8707
paulson
parents: 8006
diff changeset
   121
by (asm_simp_tac (simpset() addsimps prems) 1);
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   122
qed "up_eqI";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   123
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   124
Goalw [coeff_def]
8707
paulson
parents: 8006
diff changeset
   125
  "coeff n p ~= coeff n q ==> p ~= q";
paulson
parents: 8006
diff changeset
   126
by Auto_tac;
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   127
qed "up_neqI";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   128
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   129
Goal "!! a::('a::ring) up. (a + b) + c = a + (b + c)";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   130
by (rtac up_eqI 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   131
by (Simp_tac 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   132
by (rtac a_assoc 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   133
qed "up_a_assoc";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   134
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
   135
Goal "!! a::('a::ring) up. 0 + a = a";
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   136
by (rtac up_eqI 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   137
by (Simp_tac 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   138
qed "up_l_zero";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   139
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
   140
Goal "!! a::('a::ring) up. (-a) + a = 0";
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   141
by (rtac up_eqI 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   142
by (Simp_tac 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   143
qed "up_l_neg";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   144
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   145
Goal "!! a::('a::ring) up. a + b = b + a";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   146
by (rtac up_eqI 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   147
by (Simp_tac 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   148
by (rtac a_comm 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   149
qed "up_a_comm";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   150
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   151
Goal "!! a::('a::ring) up. (a * b) * c = a * (b * c)";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   152
by (rtac up_eqI 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   153
by (Simp_tac 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   154
by (rtac poly_assoc_lemma 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   155
qed "up_m_assoc";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   156
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   157
Goal "!! a::('a::ring) up. <1> * a = a";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   158
by (rtac up_eqI 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   159
by (Simp_tac 1);
8707
paulson
parents: 8006
diff changeset
   160
by (case_tac "n" 1); 
paulson
parents: 8006
diff changeset
   161
(* 0 case *)
paulson
parents: 8006
diff changeset
   162
by (Asm_simp_tac 1);
paulson
parents: 8006
diff changeset
   163
(* Suc case *)
paulson
parents: 8006
diff changeset
   164
by (asm_simp_tac (simpset() delsimps [SUM_Suc] addsimps [SUM_Suc2]) 1);
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   165
qed "up_l_one";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   166
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   167
Goal "!! a::('a::ring) up. (a + b) * c = a * c + b * c";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   168
by (rtac up_eqI 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   169
by (simp_tac (simpset() addsimps [l_distr, SUM_add]) 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   170
qed "up_l_distr";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   171
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   172
Goal "!! a::('a::ring) up. a * b = b * a";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   173
by (rtac up_eqI 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   174
by (cut_inst_tac [("a", "%i. coeff i a"), ("b", "%i. coeff i b")]
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   175
  poly_comm_lemma 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   176
by (asm_full_simp_tac (simpset() addsimps [m_comm]) 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   177
qed "up_m_comm";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   178
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   179
(* Further algebraic rules *)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   180
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   181
Goal "!! a::'a::ring. const a * p = a *s p";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   182
by (rtac up_eqI 1);
8707
paulson
parents: 8006
diff changeset
   183
by (case_tac "n" 1); 
paulson
parents: 8006
diff changeset
   184
by (Asm_simp_tac 1);
paulson
parents: 8006
diff changeset
   185
by (asm_simp_tac (simpset() delsimps [SUM_Suc] addsimps [SUM_Suc2]) 1);
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   186
qed "const_mult_is_smult";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   187
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   188
Goal "!! a::'a::ring. const (a + b) = const a + const b";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   189
by (rtac up_eqI 1);
8006
paulson
parents: 7998
diff changeset
   190
by (Simp_tac 1);
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   191
qed "const_add";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   192
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   193
Goal "!! a::'a::ring. const (a * b) = const a * const b";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   194
by (simp_tac (simpset() addsimps [const_mult_is_smult]) 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   195
by (rtac up_eqI 1);
8006
paulson
parents: 7998
diff changeset
   196
by (Simp_tac 1);
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   197
qed "const_mult";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   198
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   199
Goal "const (<1>::'a::ring) = <1>";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   200
by (rtac up_eqI 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   201
by (Simp_tac 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   202
qed "const_one";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   203
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
   204
Goal "const (0::'a::ring) = 0";
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   205
by (rtac up_eqI 1);
8006
paulson
parents: 7998
diff changeset
   206
by (Simp_tac 1);
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   207
qed "const_zero";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   208
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   209
Addsimps [const_add, const_mult, const_one, const_zero];
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   210
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   211
Goalw [inj_on_def, UNIV_def, const_def] "inj const";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   212
by (Simp_tac 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   213
by (strip_tac 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   214
by (dres_inst_tac [("f", "Rep_UP")] arg_cong 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   215
by (full_simp_tac (simpset() addsimps [Abs_UP_inverse, UP_closed_const,
8707
paulson
parents: 8006
diff changeset
   216
				       expand_fun_eq]) 1);
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   217
by (dres_inst_tac [("x", "0")] spec 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   218
by (Full_simp_tac 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   219
qed "const_inj";
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   220
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   221
(*Lemma used in PolyHomo*)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   222
Goal
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   223
  "!! f::nat=>'a::ring. [| bound n f; bound m g|] ==> \
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
   224
\    setsum (%k. setsum (%i. f i * g (k-i)) {..k}) {..n + m} = \
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
   225
\    setsum f {..n} * setsum g {..m}";
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   226
by (simp_tac (simpset() addsimps [SUM_ldistr, DiagSum]) 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   227
(* SUM_rdistr must be applied after SUM_ldistr ! *)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   228
by (simp_tac (simpset() addsimps [SUM_rdistr]) 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   229
by (res_inst_tac [("m", "n"), ("n", "n+m")] SUM_extend 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   230
by (rtac le_add1 1);
8707
paulson
parents: 8006
diff changeset
   231
by (Force_tac 1);
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   232
by (rtac SUM_cong 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   233
by (rtac refl 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   234
by (res_inst_tac [("m", "m"), ("n", "n+m-i")] SUM_shrink 1);
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   235
by (asm_simp_tac (simpset() addsimps [le_add_diff]) 1);
8707
paulson
parents: 8006
diff changeset
   236
by Auto_tac;
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   237
qed "CauchySum";
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
   238
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
   239
Goal "<1> ~= (0::('a::domain) up)";
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
   240
by (res_inst_tac [("n", "0")] up_neqI 1);
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
   241
by (Simp_tac 1);
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 8707
diff changeset
   242
qed "up_one_not_zero";