src/HOL/ex/Commutative_Ring_Complete.thy
author haftmann
Wed Apr 29 14:20:26 2009 +0200 (2009-04-29)
changeset 31021 53642251a04f
parent 23464 bc2563c37b1a
permissions -rw-r--r--
farewell to class recpower
haftmann@31021
     1
(*  Author:     Bernhard Haeupler
chaieb@17378
     2
wenzelm@17388
     3
This theory is about of the relative completeness of method comm-ring
wenzelm@17388
     4
method.  As long as the reified atomic polynomials of type 'a pol are
wenzelm@17388
     5
in normal form, the cring method is complete.
wenzelm@17388
     6
*)
wenzelm@17388
     7
wenzelm@17388
     8
header {* Proof of the relative completeness of method comm-ring *}
chaieb@17378
     9
chaieb@17378
    10
theory Commutative_Ring_Complete
wenzelm@17508
    11
imports Commutative_Ring
chaieb@17378
    12
begin
haftmann@22742
    13
haftmann@22742
    14
text {* Formalization of normal form *}
haftmann@22742
    15
fun
haftmann@31021
    16
  isnorm :: "('a::{comm_ring}) pol \<Rightarrow> bool"
haftmann@22742
    17
where
haftmann@22742
    18
    "isnorm (Pc c) \<longleftrightarrow> True"
haftmann@22742
    19
  | "isnorm (Pinj i (Pc c)) \<longleftrightarrow> False"
haftmann@22742
    20
  | "isnorm (Pinj i (Pinj j Q)) \<longleftrightarrow> False"
haftmann@22742
    21
  | "isnorm (Pinj 0 P) \<longleftrightarrow> False"
haftmann@22742
    22
  | "isnorm (Pinj i (PX Q1 j Q2)) \<longleftrightarrow> isnorm (PX Q1 j Q2)"
haftmann@22742
    23
  | "isnorm (PX P 0 Q) \<longleftrightarrow> False"
haftmann@22742
    24
  | "isnorm (PX (Pc c) i Q) \<longleftrightarrow> c \<noteq> 0 \<and> isnorm Q"
haftmann@22742
    25
  | "isnorm (PX (PX P1 j (Pc c)) i Q) \<longleftrightarrow> c \<noteq> 0 \<and> isnorm (PX P1 j (Pc c)) \<and> isnorm Q"
haftmann@22742
    26
  | "isnorm (PX P i Q) \<longleftrightarrow> isnorm P \<and> isnorm Q"
chaieb@17378
    27
chaieb@17378
    28
(* Some helpful lemmas *)
chaieb@17378
    29
lemma norm_Pinj_0_False:"isnorm (Pinj 0 P) = False"
chaieb@17378
    30
by(cases P, auto)
chaieb@17378
    31
chaieb@17378
    32
lemma norm_PX_0_False:"isnorm (PX (Pc 0) i Q) = False"
chaieb@17378
    33
by(cases i, auto)
chaieb@17378
    34
chaieb@17378
    35
lemma norm_Pinj:"isnorm (Pinj i Q) \<Longrightarrow> isnorm Q"
chaieb@17378
    36
by(cases i,simp add: norm_Pinj_0_False norm_PX_0_False,cases Q) auto
chaieb@17378
    37
chaieb@17378
    38
lemma norm_PX2:"isnorm (PX P i Q) \<Longrightarrow> isnorm Q"
chaieb@17378
    39
by(cases i, auto, cases P, auto, case_tac pol2, auto)
chaieb@17378
    40
chaieb@17378
    41
lemma norm_PX1:"isnorm (PX P i Q) \<Longrightarrow> isnorm P"
chaieb@17378
    42
by(cases i, auto, cases P, auto, case_tac pol2, auto)
chaieb@17378
    43
chaieb@17378
    44
lemma mkPinj_cn:"\<lbrakk>y~=0; isnorm Q\<rbrakk> \<Longrightarrow> isnorm (mkPinj y Q)" 
chaieb@17378
    45
apply(auto simp add: mkPinj_def norm_Pinj_0_False split: pol.split)
chaieb@17378
    46
apply(case_tac nat, auto simp add: norm_Pinj_0_False)
chaieb@17378
    47
by(case_tac pol, auto) (case_tac y, auto)
chaieb@17378
    48
chaieb@17378
    49
lemma norm_PXtrans: 
chaieb@17378
    50
  assumes A:"isnorm (PX P x Q)" and "isnorm Q2" 
chaieb@17378
    51
  shows "isnorm (PX P x Q2)"
chaieb@17378
    52
proof(cases P)
chaieb@17378
    53
  case (PX p1 y p2) from prems show ?thesis by(cases x, auto, cases p2, auto)
chaieb@17378
    54
next
chaieb@17378
    55
  case Pc from prems show ?thesis by(cases x, auto)
chaieb@17378
    56
next
chaieb@17378
    57
  case Pinj from prems show ?thesis by(cases x, auto)
chaieb@17378
    58
qed
chaieb@17378
    59
 
chaieb@17378
    60
lemma norm_PXtrans2: assumes A:"isnorm (PX P x Q)" and "isnorm Q2" shows "isnorm (PX P (Suc (n+x)) Q2)"
chaieb@17378
    61
proof(cases P)
chaieb@17378
    62
  case (PX p1 y p2)
chaieb@17378
    63
  from prems show ?thesis by(cases x, auto, cases p2, auto)
chaieb@17378
    64
next
chaieb@17378
    65
  case Pc
chaieb@17378
    66
  from prems show ?thesis by(cases x, auto)
chaieb@17378
    67
next
chaieb@17378
    68
  case Pinj
chaieb@17378
    69
  from prems show ?thesis by(cases x, auto)
chaieb@17378
    70
qed
chaieb@17378
    71
wenzelm@23266
    72
text {* mkPX conserves normalizedness (@{text "_cn"}) *}
chaieb@17378
    73
lemma mkPX_cn: 
chaieb@17378
    74
  assumes "x \<noteq> 0" and "isnorm P" and "isnorm Q" 
chaieb@17378
    75
  shows "isnorm (mkPX P x Q)"
chaieb@17378
    76
proof(cases P)
chaieb@17378
    77
  case (Pc c)
chaieb@17378
    78
  from prems show ?thesis by (cases x) (auto simp add: mkPinj_cn mkPX_def)
chaieb@17378
    79
next
chaieb@17378
    80
  case (Pinj i Q)
chaieb@17378
    81
  from prems show ?thesis by (cases x) (auto simp add: mkPinj_cn mkPX_def)
chaieb@17378
    82
next
chaieb@17378
    83
  case (PX P1 y P2)
chaieb@17378
    84
  from prems have Y0:"y>0" by(cases y, auto)
chaieb@17378
    85
  from prems have "isnorm P1" "isnorm P2" by (auto simp add: norm_PX1[of P1 y P2] norm_PX2[of P1 y P2])
chaieb@17378
    86
  with prems Y0 show ?thesis by (cases x, auto simp add: mkPX_def norm_PXtrans2[of P1 y _ Q _], cases P2, auto)
chaieb@17378
    87
qed
chaieb@17378
    88
haftmann@22742
    89
text {* add conserves normalizedness *}
haftmann@22742
    90
lemma add_cn:"isnorm P \<Longrightarrow> isnorm Q \<Longrightarrow> isnorm (P \<oplus> Q)"
chaieb@17378
    91
proof(induct P Q rule: add.induct)
chaieb@17378
    92
  case (2 c i P2) thus ?case by (cases P2, simp_all, cases i, simp_all)
chaieb@17378
    93
next
chaieb@17378
    94
  case (3 i P2 c) thus ?case by (cases P2, simp_all, cases i, simp_all)
chaieb@17378
    95
next
chaieb@17378
    96
  case (4 c P2 i Q2)
chaieb@17378
    97
  from prems have "isnorm P2" "isnorm Q2" by (auto simp only: norm_PX1[of P2 i Q2] norm_PX2[of P2 i Q2])
chaieb@17378
    98
  with prems show ?case by(cases i, simp, cases P2, auto, case_tac pol2, auto)
chaieb@17378
    99
next
chaieb@17378
   100
  case (5 P2 i Q2 c)
chaieb@17378
   101
  from prems have "isnorm P2" "isnorm Q2" by (auto simp only: norm_PX1[of P2 i Q2] norm_PX2[of P2 i Q2])
chaieb@17378
   102
  with prems show ?case by(cases i, simp, cases P2, auto, case_tac pol2, auto)
chaieb@17378
   103
next
chaieb@17378
   104
  case (6 x P2 y Q2)
chaieb@17378
   105
  from prems have Y0:"y>0" by (cases y, auto simp add: norm_Pinj_0_False) 
chaieb@17378
   106
  from prems have X0:"x>0" by (cases x, auto simp add: norm_Pinj_0_False) 
chaieb@17378
   107
  have "x < y \<or> x = y \<or> x > y" by arith
chaieb@17378
   108
  moreover
chaieb@17378
   109
  { assume "x<y" hence "EX d. y=d+x" by arith
chaieb@17378
   110
    then obtain d where "y=d+x"..
chaieb@17378
   111
    moreover
chaieb@17378
   112
    note prems X0
chaieb@17378
   113
    moreover
chaieb@17378
   114
    from prems have "isnorm P2" "isnorm Q2" by (auto simp add: norm_Pinj[of _ P2] norm_Pinj[of _ Q2])
chaieb@17378
   115
    moreover
chaieb@17378
   116
    with prems have "isnorm (Pinj d Q2)" by (cases d, simp, cases Q2, auto)
chaieb@17378
   117
    ultimately have ?case by (simp add: mkPinj_cn)}
chaieb@17378
   118
  moreover
chaieb@17378
   119
  { assume "x=y"
chaieb@17378
   120
    moreover
chaieb@17378
   121
    from prems have "isnorm P2" "isnorm Q2" by(auto simp add: norm_Pinj[of _ P2] norm_Pinj[of _ Q2])
chaieb@17378
   122
    moreover
chaieb@17378
   123
    note prems Y0
chaieb@17378
   124
    moreover
chaieb@17378
   125
    ultimately have ?case by (simp add: mkPinj_cn) }
chaieb@17378
   126
  moreover
chaieb@17378
   127
  { assume "x>y" hence "EX d. x=d+y" by arith
chaieb@17378
   128
    then obtain d where "x=d+y"..
chaieb@17378
   129
    moreover
chaieb@17378
   130
    note prems Y0
chaieb@17378
   131
    moreover
chaieb@17378
   132
    from prems have "isnorm P2" "isnorm Q2" by (auto simp add: norm_Pinj[of _ P2] norm_Pinj[of _ Q2])
chaieb@17378
   133
    moreover
chaieb@17378
   134
    with prems have "isnorm (Pinj d P2)" by (cases d, simp, cases P2, auto)
chaieb@17378
   135
    ultimately have ?case by (simp add: mkPinj_cn)}
chaieb@17378
   136
  ultimately show ?case by blast
chaieb@17378
   137
next
chaieb@17378
   138
  case (7 x P2 Q2 y R)
chaieb@17378
   139
  have "x=0 \<or> (x = 1) \<or> (x > 1)" by arith
chaieb@17378
   140
  moreover
chaieb@17378
   141
  { assume "x=0" with prems have ?case by (auto simp add: norm_Pinj_0_False)}
chaieb@17378
   142
  moreover
chaieb@17378
   143
  { assume "x=1"
chaieb@17378
   144
    from prems have "isnorm R" "isnorm P2" by (auto simp add: norm_Pinj[of _ P2] norm_PX2[of Q2 y R])
haftmann@22742
   145
    with prems have "isnorm (R \<oplus> P2)" by simp
chaieb@17378
   146
    with prems have ?case by (simp add: norm_PXtrans[of Q2 y _]) }
chaieb@17378
   147
  moreover
chaieb@17378
   148
  { assume "x > 1" hence "EX d. x=Suc (Suc d)" by arith
chaieb@17378
   149
    then obtain d where X:"x=Suc (Suc d)" ..
chaieb@17378
   150
    from prems have NR:"isnorm R" "isnorm P2" by (auto simp add: norm_Pinj[of _ P2] norm_PX2[of Q2 y R])
chaieb@17378
   151
    with prems have "isnorm (Pinj (x - 1) P2)" by(cases P2, auto)
wenzelm@23464
   152
    with prems NR have "isnorm (R \<oplus> Pinj (x - 1) P2)" "isnorm (PX Q2 y R)" by simp fact
chaieb@17378
   153
    with X have ?case by (simp add: norm_PXtrans[of Q2 y _]) }
chaieb@17378
   154
  ultimately show ?case by blast
chaieb@17378
   155
next
chaieb@17378
   156
  case (8 Q2 y R x P2)
haftmann@22742
   157
  have "x = 0 \<or> x = 1 \<or> x > 1" by arith
chaieb@17378
   158
  moreover
chaieb@17378
   159
  { assume "x=0" with prems have ?case by (auto simp add: norm_Pinj_0_False)}
chaieb@17378
   160
  moreover
chaieb@17378
   161
  { assume "x=1"
chaieb@17378
   162
    from prems have "isnorm R" "isnorm P2" by (auto simp add: norm_Pinj[of _ P2] norm_PX2[of Q2 y R])
haftmann@22742
   163
    with prems have "isnorm (R \<oplus> P2)" by simp
chaieb@17378
   164
    with prems have ?case by (simp add: norm_PXtrans[of Q2 y _]) }
chaieb@17378
   165
  moreover
chaieb@17378
   166
  { assume "x > 1" hence "EX d. x=Suc (Suc d)" by arith
chaieb@17378
   167
    then obtain d where X:"x=Suc (Suc d)" ..
chaieb@17378
   168
    from prems have NR:"isnorm R" "isnorm P2" by (auto simp add: norm_Pinj[of _ P2] norm_PX2[of Q2 y R])
chaieb@17378
   169
    with prems have "isnorm (Pinj (x - 1) P2)" by(cases P2, auto)
wenzelm@23464
   170
    with prems NR have "isnorm (R \<oplus> Pinj (x - 1) P2)" "isnorm (PX Q2 y R)" by simp fact
chaieb@17378
   171
    with X have ?case by (simp add: norm_PXtrans[of Q2 y _]) }
chaieb@17378
   172
  ultimately show ?case by blast
chaieb@17378
   173
next
chaieb@17378
   174
  case (9 P1 x P2 Q1 y Q2)
chaieb@17378
   175
  from prems have Y0:"y>0" by(cases y, auto)
chaieb@17378
   176
  from prems have X0:"x>0" by(cases x, auto)
chaieb@17378
   177
  from prems have NP1:"isnorm P1" and NP2:"isnorm P2" by (auto simp add: norm_PX1[of P1 _ P2] norm_PX2[of P1 _ P2])
chaieb@17378
   178
  from prems have NQ1:"isnorm Q1" and NQ2:"isnorm Q2" by (auto simp add: norm_PX1[of Q1 _ Q2] norm_PX2[of Q1 _ Q2])
chaieb@17378
   179
  have "y < x \<or> x = y \<or> x < y" by arith
chaieb@17378
   180
  moreover
chaieb@17378
   181
  {assume sm1:"y < x" hence "EX d. x=d+y" by arith
chaieb@17378
   182
    then obtain d where sm2:"x=d+y"..
chaieb@17378
   183
    note prems NQ1 NP1 NP2 NQ2 sm1 sm2
chaieb@17378
   184
    moreover
chaieb@17378
   185
    have "isnorm (PX P1 d (Pc 0))" 
chaieb@17378
   186
    proof(cases P1)
chaieb@17378
   187
      case (PX p1 y p2)
chaieb@17378
   188
      with prems show ?thesis by(cases d, simp,cases p2, auto)
chaieb@17378
   189
    next case Pc   from prems show ?thesis by(cases d, auto)
chaieb@17378
   190
    next case Pinj from prems show ?thesis by(cases d, auto)
chaieb@17378
   191
    qed
haftmann@22742
   192
    ultimately have "isnorm (P2 \<oplus> Q2)" "isnorm (PX P1 (x - y) (Pc 0) \<oplus> Q1)" by auto
chaieb@17378
   193
    with Y0 sm1 sm2 have ?case by (simp add: mkPX_cn)}
chaieb@17378
   194
  moreover
chaieb@17378
   195
  {assume "x=y"
haftmann@22742
   196
    from prems NP1 NP2 NQ1 NQ2 have "isnorm (P2 \<oplus> Q2)" "isnorm (P1 \<oplus> Q1)" by auto
chaieb@17378
   197
    with Y0 prems have ?case by (simp add: mkPX_cn) }
chaieb@17378
   198
  moreover
chaieb@17378
   199
  {assume sm1:"x<y" hence "EX d. y=d+x" by arith
chaieb@17378
   200
    then obtain d where sm2:"y=d+x"..
chaieb@17378
   201
    note prems NQ1 NP1 NP2 NQ2 sm1 sm2
chaieb@17378
   202
    moreover
chaieb@17378
   203
    have "isnorm (PX Q1 d (Pc 0))" 
chaieb@17378
   204
    proof(cases Q1)
chaieb@17378
   205
      case (PX p1 y p2)
chaieb@17378
   206
      with prems show ?thesis by(cases d, simp,cases p2, auto)
chaieb@17378
   207
    next case Pc   from prems show ?thesis by(cases d, auto)
chaieb@17378
   208
    next case Pinj from prems show ?thesis by(cases d, auto)
chaieb@17378
   209
    qed
haftmann@22742
   210
    ultimately have "isnorm (P2 \<oplus> Q2)" "isnorm (PX Q1 (y - x) (Pc 0) \<oplus> P1)" by auto
chaieb@17378
   211
    with X0 sm1 sm2 have ?case by (simp add: mkPX_cn)}
chaieb@17378
   212
  ultimately show ?case by blast
haftmann@22742
   213
qed simp
chaieb@17378
   214
haftmann@22742
   215
text {* mul concerves normalizedness *}
haftmann@22742
   216
lemma mul_cn :"isnorm P \<Longrightarrow> isnorm Q \<Longrightarrow> isnorm (P \<otimes> Q)"
chaieb@17378
   217
proof(induct P Q rule: mul.induct)
chaieb@17378
   218
  case (2 c i P2) thus ?case 
chaieb@17378
   219
    by (cases P2, simp_all) (cases "i",simp_all add: mkPinj_cn)
chaieb@17378
   220
next
chaieb@17378
   221
  case (3 i P2 c) thus ?case 
chaieb@17378
   222
    by (cases P2, simp_all) (cases "i",simp_all add: mkPinj_cn)
chaieb@17378
   223
next
chaieb@17378
   224
  case (4 c P2 i Q2)
chaieb@17378
   225
  from prems have "isnorm P2" "isnorm Q2" by (auto simp only: norm_PX1[of P2 i Q2] norm_PX2[of P2 i Q2])
chaieb@17378
   226
  with prems show ?case 
chaieb@17378
   227
    by - (case_tac "c=0",simp_all,case_tac "i=0",simp_all add: mkPX_cn)
chaieb@17378
   228
next
chaieb@17378
   229
  case (5 P2 i Q2 c)
chaieb@17378
   230
  from prems have "isnorm P2" "isnorm Q2" by (auto simp only: norm_PX1[of P2 i Q2] norm_PX2[of P2 i Q2])
chaieb@17378
   231
  with prems show ?case
chaieb@17378
   232
    by - (case_tac "c=0",simp_all,case_tac "i=0",simp_all add: mkPX_cn)
chaieb@17378
   233
next
chaieb@17378
   234
  case (6 x P2 y Q2)
chaieb@17378
   235
  have "x < y \<or> x = y \<or> x > y" by arith
chaieb@17378
   236
  moreover
chaieb@17378
   237
  { assume "x<y" hence "EX d. y=d+x" by arith
chaieb@17378
   238
    then obtain d where "y=d+x"..
chaieb@17378
   239
    moreover
chaieb@17378
   240
    note prems
chaieb@17378
   241
    moreover
chaieb@17378
   242
    from prems have "x>0" by (cases x, auto simp add: norm_Pinj_0_False) 
chaieb@17378
   243
    moreover
chaieb@17378
   244
    from prems have "isnorm P2" "isnorm Q2" by (auto simp add: norm_Pinj[of _ P2] norm_Pinj[of _ Q2])
chaieb@17378
   245
    moreover
chaieb@17378
   246
    with prems have "isnorm (Pinj d Q2)" by (cases d, simp, cases Q2, auto) 
chaieb@17378
   247
    ultimately have ?case by (simp add: mkPinj_cn)}
chaieb@17378
   248
  moreover
chaieb@17378
   249
  { assume "x=y"
chaieb@17378
   250
    moreover
chaieb@17378
   251
    from prems have "isnorm P2" "isnorm Q2" by(auto simp add: norm_Pinj[of _ P2] norm_Pinj[of _ Q2])
chaieb@17378
   252
    moreover
chaieb@17378
   253
    with prems have "y>0" by (cases y, auto simp add: norm_Pinj_0_False)
chaieb@17378
   254
    moreover
chaieb@17378
   255
    note prems
chaieb@17378
   256
    moreover
chaieb@17378
   257
    ultimately have ?case by (simp add: mkPinj_cn) }
chaieb@17378
   258
  moreover
chaieb@17378
   259
  { assume "x>y" hence "EX d. x=d+y" by arith
chaieb@17378
   260
    then obtain d where "x=d+y"..
chaieb@17378
   261
    moreover
chaieb@17378
   262
    note prems
chaieb@17378
   263
    moreover
chaieb@17378
   264
    from prems have "y>0" by (cases y, auto simp add: norm_Pinj_0_False) 
chaieb@17378
   265
    moreover
chaieb@17378
   266
    from prems have "isnorm P2" "isnorm Q2" by (auto simp add: norm_Pinj[of _ P2] norm_Pinj[of _ Q2])
chaieb@17378
   267
    moreover
chaieb@17378
   268
    with prems have "isnorm (Pinj d P2)"  by (cases d, simp, cases P2, auto)
chaieb@17378
   269
    ultimately have ?case by (simp add: mkPinj_cn) }
chaieb@17378
   270
  ultimately show ?case by blast
chaieb@17378
   271
next
chaieb@17378
   272
  case (7 x P2 Q2 y R)
chaieb@17378
   273
  from prems have Y0:"y>0" by(cases y, auto)
chaieb@17378
   274
  have "x=0 \<or> (x = 1) \<or> (x > 1)" by arith
chaieb@17378
   275
  moreover
chaieb@17378
   276
  { assume "x=0" with prems have ?case by (auto simp add: norm_Pinj_0_False)}
chaieb@17378
   277
  moreover
chaieb@17378
   278
  { assume "x=1"
chaieb@17378
   279
    from prems have "isnorm R" "isnorm P2" by (auto simp add: norm_Pinj[of _ P2] norm_PX2[of Q2 y R])
haftmann@22742
   280
    with prems have "isnorm (R \<otimes> P2)" "isnorm Q2" by (auto simp add: norm_PX1[of Q2 y R])
chaieb@17378
   281
    with Y0 prems have ?case by (simp add: mkPX_cn)}
chaieb@17378
   282
  moreover
chaieb@17378
   283
  { assume "x > 1" hence "EX d. x=Suc (Suc d)" by arith
chaieb@17378
   284
    then obtain d where X:"x=Suc (Suc d)" ..
chaieb@17378
   285
    from prems have NR:"isnorm R" "isnorm Q2" by (auto simp add: norm_PX2[of Q2 y R] norm_PX1[of Q2 y R])
chaieb@17378
   286
    moreover
chaieb@17378
   287
    from prems have "isnorm (Pinj (x - 1) P2)" by(cases P2, auto)
chaieb@17378
   288
    moreover
chaieb@17378
   289
    from prems have "isnorm (Pinj x P2)" by(cases P2, auto)
chaieb@17378
   290
    moreover
chaieb@17378
   291
    note prems
haftmann@22742
   292
    ultimately have "isnorm (R \<otimes> Pinj (x - 1) P2)" "isnorm (Pinj x P2 \<otimes> Q2)" by auto
chaieb@17378
   293
    with Y0 X have ?case by (simp add: mkPX_cn)}
chaieb@17378
   294
  ultimately show ?case by blast
chaieb@17378
   295
next
chaieb@17378
   296
  case (8 Q2 y R x P2)
chaieb@17378
   297
  from prems have Y0:"y>0" by(cases y, auto)
chaieb@17378
   298
  have "x=0 \<or> (x = 1) \<or> (x > 1)" by arith
chaieb@17378
   299
  moreover
chaieb@17378
   300
  { assume "x=0" with prems have ?case by (auto simp add: norm_Pinj_0_False)}
chaieb@17378
   301
  moreover
chaieb@17378
   302
  { assume "x=1"
chaieb@17378
   303
    from prems have "isnorm R" "isnorm P2" by (auto simp add: norm_Pinj[of _ P2] norm_PX2[of Q2 y R])
haftmann@22742
   304
    with prems have "isnorm (R \<otimes> P2)" "isnorm Q2" by (auto simp add: norm_PX1[of Q2 y R])
chaieb@17378
   305
    with Y0 prems have ?case by (simp add: mkPX_cn) }
chaieb@17378
   306
  moreover
chaieb@17378
   307
  { assume "x > 1" hence "EX d. x=Suc (Suc d)" by arith
chaieb@17378
   308
    then obtain d where X:"x=Suc (Suc d)" ..
chaieb@17378
   309
    from prems have NR:"isnorm R" "isnorm Q2" by (auto simp add: norm_PX2[of Q2 y R] norm_PX1[of Q2 y R])
chaieb@17378
   310
    moreover
chaieb@17378
   311
    from prems have "isnorm (Pinj (x - 1) P2)" by(cases P2, auto)
chaieb@17378
   312
    moreover
chaieb@17378
   313
    from prems have "isnorm (Pinj x P2)" by(cases P2, auto)
chaieb@17378
   314
    moreover
chaieb@17378
   315
    note prems
haftmann@22742
   316
    ultimately have "isnorm (R \<otimes> Pinj (x - 1) P2)" "isnorm (Pinj x P2 \<otimes> Q2)" by auto
chaieb@17378
   317
    with Y0 X have ?case by (simp add: mkPX_cn) }
chaieb@17378
   318
  ultimately show ?case by blast
chaieb@17378
   319
next
chaieb@17378
   320
  case (9 P1 x P2 Q1 y Q2)
chaieb@17378
   321
  from prems have X0:"x>0" by(cases x, auto)
chaieb@17378
   322
  from prems have Y0:"y>0" by(cases y, auto)
chaieb@17378
   323
  note prems
chaieb@17378
   324
  moreover
chaieb@17378
   325
  from prems have "isnorm P1" "isnorm P2" by (auto simp add: norm_PX1[of P1 x P2] norm_PX2[of P1 x P2])
chaieb@17378
   326
  moreover 
chaieb@17378
   327
  from prems have "isnorm Q1" "isnorm Q2" by (auto simp add: norm_PX1[of Q1 y Q2] norm_PX2[of Q1 y Q2])
haftmann@22742
   328
  ultimately have "isnorm (P1 \<otimes> Q1)" "isnorm (P2 \<otimes> Q2)"
haftmann@22742
   329
    "isnorm (P1 \<otimes> mkPinj 1 Q2)" "isnorm (Q1 \<otimes> mkPinj 1 P2)" 
chaieb@17378
   330
    by (auto simp add: mkPinj_cn)
haftmann@22742
   331
  with prems X0 Y0 have
haftmann@22742
   332
    "isnorm (mkPX (P1 \<otimes> Q1) (x + y) (P2 \<otimes> Q2))"
haftmann@22742
   333
    "isnorm (mkPX (P1 \<otimes> mkPinj (Suc 0) Q2) x (Pc 0))"  
haftmann@22742
   334
    "isnorm (mkPX (Q1 \<otimes> mkPinj (Suc 0) P2) y (Pc 0))" 
chaieb@17378
   335
    by (auto simp add: mkPX_cn)
chaieb@17378
   336
  thus ?case by (simp add: add_cn)
chaieb@17378
   337
qed(simp)
chaieb@17378
   338
haftmann@22742
   339
text {* neg conserves normalizedness *}
chaieb@17378
   340
lemma neg_cn: "isnorm P \<Longrightarrow> isnorm (neg P)"
haftmann@22742
   341
proof (induct P)
chaieb@17378
   342
  case (Pinj i P2)
chaieb@17378
   343
  from prems have "isnorm P2" by (simp add: norm_Pinj[of i P2])
chaieb@17378
   344
  with prems show ?case by(cases P2, auto, cases i, auto)
chaieb@17378
   345
next
chaieb@17378
   346
  case (PX P1 x P2)
chaieb@17378
   347
  from prems have "isnorm P2" "isnorm P1" by (auto simp add: norm_PX1[of P1 x P2] norm_PX2[of P1 x P2])
chaieb@17378
   348
  with prems show ?case
chaieb@17378
   349
  proof(cases P1)
chaieb@17378
   350
    case (PX p1 y p2)
chaieb@17378
   351
    with prems show ?thesis by(cases x, auto, cases p2, auto)
chaieb@17378
   352
  next
chaieb@17378
   353
    case Pinj
chaieb@17378
   354
    with prems show ?thesis by(cases x, auto)
chaieb@17378
   355
  qed(cases x, auto)
chaieb@17378
   356
qed(simp)
chaieb@17378
   357
haftmann@22742
   358
text {* sub conserves normalizedness *}
haftmann@22742
   359
lemma sub_cn:"isnorm p \<Longrightarrow> isnorm q \<Longrightarrow> isnorm (p \<ominus> q)"
chaieb@17378
   360
by (simp add: sub_def add_cn neg_cn)
chaieb@17378
   361
haftmann@22742
   362
text {* sqr conserves normalizizedness *}
chaieb@17378
   363
lemma sqr_cn:"isnorm P \<Longrightarrow> isnorm (sqr P)"
chaieb@17378
   364
proof(induct P)
chaieb@17378
   365
  case (Pinj i Q)
chaieb@17378
   366
  from prems show ?case by(cases Q, auto simp add: mkPX_cn mkPinj_cn, cases i, auto simp add: mkPX_cn mkPinj_cn)
chaieb@17378
   367
next 
chaieb@17378
   368
  case (PX P1 x P2)
chaieb@17378
   369
  from prems have "x+x~=0" "isnorm P2" "isnorm P1" by (cases x,  auto simp add: norm_PX1[of P1 x P2] norm_PX2[of P1 x P2])
haftmann@22742
   370
  with prems have
haftmann@22742
   371
    "isnorm (mkPX (Pc (1 + 1) \<otimes> P1 \<otimes> mkPinj (Suc 0) P2) x (Pc 0))"
haftmann@22742
   372
    and "isnorm (mkPX (sqr P1) (x + x) (sqr P2))"
haftmann@22742
   373
   by (auto simp add: add_cn mkPX_cn mkPinj_cn mul_cn)
haftmann@22742
   374
  thus ?case by (auto simp add: add_cn mkPX_cn mkPinj_cn mul_cn)
haftmann@22742
   375
qed simp
chaieb@17378
   376
haftmann@22742
   377
text {* pow conserves normalizedness *}
haftmann@22742
   378
lemma pow_cn:"isnorm P \<Longrightarrow> isnorm (pow n P)"
haftmann@22742
   379
proof (induct n arbitrary: P rule: nat_less_induct)
chaieb@17378
   380
  case (1 k)
chaieb@17378
   381
  show ?case 
haftmann@22742
   382
  proof (cases "k=0")
chaieb@17378
   383
    case False
haftmann@22742
   384
    then have K2:"k div 2 < k" by (cases k, auto)
chaieb@17378
   385
    from prems have "isnorm (sqr P)" by (simp add: sqr_cn)
haftmann@22742
   386
    with prems K2 show ?thesis
haftmann@22742
   387
    by (simp add: allE[of _ "(k div 2)" _] allE[of _ "(sqr P)" _], cases k, auto simp add: mul_cn)
haftmann@22742
   388
  qed simp
chaieb@17378
   389
qed
chaieb@17378
   390
wenzelm@17388
   391
end