src/ZF/ex/Integ.ML
author paulson
Fri, 18 Sep 1998 15:15:40 +0200
changeset 5507 2fd99b2d41e1
parent 5268 59ef39008514
child 5525 896f8234b864
permissions -rw-r--r--
simpler definition of zmagnitude, and new thms for it
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
     1
(*  Title:      ZF/ex/integ.ML
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
1614
c9f0fc335b12 Rewriting changes due to new arith_ss
paulson
parents: 1461
diff changeset
     6
The integers as equivalence classes over nat*nat.
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
Could also prove...
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
"znegative(z) ==> $# zmagnitude(z) = $~ z"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
"~ znegative(z) ==> $# zmagnitude(z) = z"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
$< is a linear ordering
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
$+ and $* are monotonic wrt $<
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
5507
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
    15
AddSEs [quotientE];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    16
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
(*** Proving that intrel is an equivalence relation ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
(*By luck, requires no typing premises for y1, y2,y3*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
val eqa::eqb::prems = goal Arith.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    21
    "[| x1 #+ y2 = x2 #+ y1; x2 #+ y3 = x3 #+ y2;  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
\       x1: nat; x2: nat; x3: nat |]    ==>    x1 #+ y3 = x3 #+ y1";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
by (res_inst_tac [("k","x2")] add_left_cancel 1);
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    24
by (resolve_tac prems 2);
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    25
by (rtac (add_left_commute RS trans) 1 THEN typechk_tac prems);
2034
5079fdf938dd Ran expandshort; used stac instead of ssubst
paulson
parents: 1677
diff changeset
    26
by (stac eqb 1);
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    27
by (rtac (add_left_commute RS trans) 1 THEN typechk_tac prems);
2034
5079fdf938dd Ran expandshort; used stac instead of ssubst
paulson
parents: 1677
diff changeset
    28
by (stac eqa 1);
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    29
by (rtac (add_left_commute) 1 THEN typechk_tac prems);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    30
qed "integ_trans_lemma";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    31
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
(** Natural deduction for intrel **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    33
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
    34
Goalw [intrel_def]
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    35
    "<<x1,y1>,<x2,y2>>: intrel <-> \
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    36
\    x1: nat & y1: nat & x2: nat & y2: nat & x1#+y2 = x2#+y1";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
    37
by (Fast_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
    38
qed "intrel_iff";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    39
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
    40
Goalw [intrel_def]
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
    41
    "[| x1#+y2 = x2#+y1; x1: nat; y1: nat; x2: nat; y2: nat |] ==> \
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    42
\             <<x1,y1>,<x2,y2>>: intrel";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
    43
by (fast_tac (claset() addIs prems) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
    44
qed "intrelI";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    45
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    46
(*intrelE is hard to derive because fast_tac tries hyp_subst_tac so soon*)
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
    47
Goalw [intrel_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    48
  "p: intrel --> (EX x1 y1 x2 y2. \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
\                  p = <<x1,y1>,<x2,y2>> & x1#+y2 = x2#+y1 & \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    50
\                  x1: nat & y1: nat & x2: nat & y2: nat)";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
    51
by (Fast_tac 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    52
qed "intrelE_lemma";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    54
val [major,minor] = goal Integ.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    55
  "[| p: intrel;  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    56
\     !!x1 y1 x2 y2. [| p = <<x1,y1>,<x2,y2>>;  x1#+y2 = x2#+y1; \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    57
\                       x1: nat; y1: nat; x2: nat; y2: nat |] ==> Q |] \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    58
\  ==> Q";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    59
by (cut_facts_tac [major RS (intrelE_lemma RS mp)] 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
by (REPEAT (eresolve_tac [asm_rl,exE,conjE,minor] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
    61
qed "intrelE";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    62
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
    63
AddSIs [intrelI];
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
    64
AddSEs [intrelE];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    65
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
    66
Goalw [equiv_def, refl_def, sym_def, trans_def]
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    67
    "equiv(nat*nat, intrel)";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
    68
by (fast_tac (claset() addSEs [sym, integ_trans_lemma]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
    69
qed "equiv_intrel";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    70
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
    72
Addsimps [equiv_intrel RS eq_equiv_class_iff, intrel_iff,
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
    73
	  add_0_right, add_succ_right];
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
    74
Addcongs [conj_cong];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    75
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    76
val eq_intrelD = equiv_intrel RSN (2,eq_equiv_class);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    77
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    78
(** znat: the injection from nat to integ **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    79
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
    80
Goalw [integ_def,quotient_def,znat_def]
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
    81
    "m : nat ==> $#m : integ";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
    82
by (fast_tac (claset() addSIs [nat_0I]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
    83
qed "znat_type";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    84
5507
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
    85
Addsimps [znat_type];
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
    86
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
    87
Goalw [znat_def] "[| $#m = $#n;  m: nat |] ==> m=n";
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
    88
by (dtac (sym RS eq_intrelD) 1);
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    89
by (typechk_tac [nat_0I, SigmaI]);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
    90
by (Asm_full_simp_tac 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    91
qed "znat_inject";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    92
5507
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
    93
AddSDs [znat_inject];
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
    94
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
    95
Goal "m: nat ==> ($# m = $# n) <-> (m = n)"; 
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
    96
by (Blast_tac 1); 
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
    97
qed "znat_znat_eq"; 
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
    98
Addsimps [znat_znat_eq]; 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    99
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   100
(**** zminus: unary negation on integ ****)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   101
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   102
Goalw [congruent_def] "congruent(intrel, %<x,y>. intrel``{<y,x>})";
4152
451104c223e2 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4091
diff changeset
   103
by Safe_tac;
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   104
by (asm_full_simp_tac (simpset() addsimps add_ac) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   105
qed "zminus_congruent";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   106
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   107
(*Resolve th against the corresponding facts for zminus*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   108
val zminus_ize = RSLIST [equiv_intrel, zminus_congruent];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   109
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   110
Goalw [integ_def,zminus_def] "z : integ ==> $~z : integ";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   111
by (typechk_tac [split_type, SigmaI, zminus_ize UN_equiv_class_type,
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   112
                 quotientI]);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   113
qed "zminus_type";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   114
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   115
Goalw [integ_def,zminus_def] "[| $~z = $~w;  z: integ;  w: integ |] ==> z=w";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   116
by (etac (zminus_ize UN_equiv_class_inject) 1);
4152
451104c223e2 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4091
diff changeset
   117
by Safe_tac;
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   118
(*The setloop is only needed because assumptions are in the wrong order!*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   119
by (asm_full_simp_tac (simpset() addsimps add_ac
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   120
                       setloop dtac eq_intrelD) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   121
qed "zminus_inject";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   122
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
   123
Goalw [zminus_def]
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   124
    "[| x: nat;  y: nat |] ==> $~ (intrel``{<x,y>}) = intrel `` {<y,x>}";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   125
by (asm_simp_tac (simpset() addsimps [zminus_ize UN_equiv_class, SigmaI]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   126
qed "zminus";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   127
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   128
Goalw [integ_def] "z : integ ==> $~ ($~ z) = z";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   129
by (REPEAT (eresolve_tac [quotientE,SigmaE,ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   130
by (asm_simp_tac (simpset() addsimps [zminus]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   131
qed "zminus_zminus";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   132
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
   133
Goalw [integ_def, znat_def] "$~ ($#0) = $#0";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   134
by (simp_tac (simpset() addsimps [zminus]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   135
qed "zminus_0";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   136
5507
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   137
Addsimps [zminus_zminus, zminus_0];
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   138
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   139
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   140
(**** znegative: the test for negative integers ****)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   141
1021
9aa52d5d614f Modified proofs for new hyp_subst_tac.
lcp
parents: 904
diff changeset
   142
(*No natural number is negative!*)
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
   143
Goalw [znegative_def, znat_def]  "~ znegative($# n)";
4152
451104c223e2 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4091
diff changeset
   144
by Safe_tac;
1021
9aa52d5d614f Modified proofs for new hyp_subst_tac.
lcp
parents: 904
diff changeset
   145
by (dres_inst_tac [("psi", "?lhs=?rhs")] asm_rl 1);
9aa52d5d614f Modified proofs for new hyp_subst_tac.
lcp
parents: 904
diff changeset
   146
by (dres_inst_tac [("psi", "?lhs<?rhs")] asm_rl 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   147
by (fast_tac (claset() addss
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   148
              (simpset() addsimps [add_le_self2 RS le_imp_not_lt])) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   149
qed "not_znegative_znat";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   150
5507
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   151
Addsimps [not_znegative_znat];
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   152
AddSEs   [not_znegative_znat RS notE];
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   153
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   154
Goalw [znegative_def, znat_def] "n: nat ==> znegative($~ $# succ(n))";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   155
by (asm_simp_tac (simpset() addsimps [zminus]) 1);
5168
adafef6eb295 isatool expandshort;
wenzelm
parents: 5137
diff changeset
   156
by (blast_tac (claset() addIs [nat_0_le]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   157
qed "znegative_zminus_znat";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   158
5507
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   159
Addsimps [znegative_zminus_znat];
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   160
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   161
Goalw [znegative_def, znat_def] "[| n: nat; ~ znegative($~ $# n) |] ==> n=0";
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   162
by (asm_full_simp_tac (simpset() addsimps [zminus, image_singleton_iff]) 1);
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   163
be natE 1;
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   164
by (dres_inst_tac [("x","0")] spec 2);
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   165
by Auto_tac;
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   166
qed "not_znegative_imp_zero";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   167
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   168
(**** zmagnitude: magnitide of an integer, as a natural number ****)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   169
5507
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   170
Goalw [zmagnitude_def] "n: nat ==> zmagnitude($# n) = n";
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   171
by Auto_tac;
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   172
qed "zmagnitude_znat";
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   173
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   174
Goalw [zmagnitude_def] "n: nat ==> zmagnitude($~ $# n) = n";
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   175
by (auto_tac(claset() addDs [not_znegative_imp_zero], simpset()));
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   176
qed "zmagnitude_zminus_znat";
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   177
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   178
Addsimps [zmagnitude_znat, zmagnitude_zminus_znat];
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   179
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   180
Goalw [zmagnitude_def] "zmagnitude(z) : nat";
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   181
br theI2 1;
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   182
by Auto_tac;
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   183
qed "zmagnitude_type";
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   184
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   185
Goalw [integ_def, znegative_def, znat_def]
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   186
     "[| z: integ; ~ znegative(z) |] ==> EX n:nat. z = $# n"; 
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   187
by (auto_tac(claset() , simpset() addsimps [image_singleton_iff]));
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   188
by (rename_tac "i j" 1);
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   189
by (dres_inst_tac [("x", "i")] spec 1);
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   190
by (dres_inst_tac [("x", "j")] spec 1);
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   191
br bexI 1;
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   192
br (add_diff_inverse2 RS sym) 1;
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   193
by Auto_tac;
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   194
by (asm_full_simp_tac (simpset() addsimps [nat_into_Ord, not_lt_iff_le]) 1);
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   195
qed "not_zneg_znat";
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   196
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   197
Goal "[| z: integ; ~ znegative(z) |] ==> $# (zmagnitude(z)) = z"; 
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   198
bd not_zneg_znat 1;
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   199
by Auto_tac;
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   200
qed "not_zneg_mag"; 
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   201
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   202
Addsimps [not_zneg_mag];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   203
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   204
5507
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   205
Goalw [integ_def, znegative_def, znat_def]
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   206
     "[| z: integ; znegative(z) |] ==> EX n:nat. z = $~ ($# succ(n))"; 
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   207
by (auto_tac(claset() addSDs [less_imp_Suc_add], 
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   208
	     simpset() addsimps [zminus, image_singleton_iff]));
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   209
by (rename_tac "m n j k" 1);
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   210
by (subgoal_tac "j #+ succ(m #+ k) = j #+ n" 1);
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   211
by (rotate_tac ~2 2);
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   212
by (asm_full_simp_tac (simpset() addsimps add_ac) 2);
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   213
by (blast_tac (claset() addSDs [add_left_cancel]) 1);
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   214
qed "zneg_znat";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   215
5507
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   216
Goal "[| z: integ; znegative(z) |] ==> $# (zmagnitude(z)) = $~ z"; 
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   217
bd zneg_znat 1;
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   218
by Auto_tac;
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   219
qed "zneg_mag"; 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   220
5507
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   221
Addsimps [zneg_mag];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   222
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   223
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   224
(**** zadd: addition on integ ****)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   225
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   226
(** Congruence property for addition **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   227
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
   228
Goalw [congruent2_def]
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   229
    "congruent2(intrel, %z1 z2.                      \
1110
756aa2e81f6e Changed some definitions and proofs to use pattern-matching.
lcp
parents: 1021
diff changeset
   230
\         let <x1,y1>=z1; <x2,y2>=z2                 \
756aa2e81f6e Changed some definitions and proofs to use pattern-matching.
lcp
parents: 1021
diff changeset
   231
\                           in intrel``{<x1#+x2, y1#+y2>})";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   232
(*Proof via congruent2_commuteI seems longer*)
4152
451104c223e2 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4091
diff changeset
   233
by Safe_tac;
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   234
by (asm_simp_tac (simpset() addsimps [add_assoc, Let_def]) 1);
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   235
(*The rest should be trivial, but rearranging terms is hard;
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   236
  add_ac does not help rewriting with the assumptions.*)
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   237
by (res_inst_tac [("m1","x1a")] (add_left_commute RS ssubst) 1);
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   238
by (res_inst_tac [("m1","x2a")] (add_left_commute RS ssubst) 3);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   239
by (typechk_tac [add_type]);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   240
by (asm_simp_tac (simpset() addsimps [add_assoc RS sym]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   241
qed "zadd_congruent2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   242
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   243
(*Resolve th against the corresponding facts for zadd*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   244
val zadd_ize = RSLIST [equiv_intrel, zadd_congruent2];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   245
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   246
Goalw [integ_def,zadd_def] "[| z: integ;  w: integ |] ==> z $+ w : integ";
1110
756aa2e81f6e Changed some definitions and proofs to use pattern-matching.
lcp
parents: 1021
diff changeset
   247
by (rtac (zadd_ize UN_equiv_class_type2) 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   248
by (simp_tac (simpset() addsimps [Let_def]) 3);
1110
756aa2e81f6e Changed some definitions and proofs to use pattern-matching.
lcp
parents: 1021
diff changeset
   249
by (REPEAT (ares_tac [split_type, add_type, quotientI, SigmaI] 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   250
qed "zadd_type";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   251
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
   252
Goalw [zadd_def]
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   253
  "[| x1: nat; y1: nat;  x2: nat; y2: nat |] ==>       \
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   254
\           (intrel``{<x1,y1>}) $+ (intrel``{<x2,y2>}) =        \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   255
\           intrel `` {<x1#+x2, y1#+y2>}";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   256
by (asm_simp_tac (simpset() addsimps [zadd_ize UN_equiv_class2, SigmaI]) 1);
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   257
by (simp_tac (simpset() addsimps [Let_def]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   258
qed "zadd";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   259
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   260
Goalw [integ_def,znat_def] "z : integ ==> $#0 $+ z = z";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   261
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   262
by (asm_simp_tac (simpset() addsimps [zadd]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   263
qed "zadd_0";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   264
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   265
Goalw [integ_def] "[| z: integ;  w: integ |] ==> $~ (z $+ w) = $~ z $+ $~ w";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   266
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   267
by (asm_simp_tac (simpset() addsimps [zminus,zadd]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   268
qed "zminus_zadd_distrib";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   269
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   270
Goalw [integ_def] "[| z: integ;  w: integ |] ==> z $+ w = w $+ z";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   271
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   272
by (asm_simp_tac (simpset() addsimps (add_ac @ [zadd])) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   273
qed "zadd_commute";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   274
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
   275
Goalw [integ_def]
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   276
    "[| z1: integ;  z2: integ;  z3: integ |]   \
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   277
\    ==> (z1 $+ z2) $+ z3 = z1 $+ (z2 $+ z3)";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   278
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   279
(*rewriting is much faster without intrel_iff, etc.*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   280
by (asm_simp_tac (simpset() addsimps [zadd, add_assoc]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   281
qed "zadd_assoc";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   282
904
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   283
(*For AC rewriting*)
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   284
Goal "[| z1:integ;  z2:integ;  z3: integ |] ==> z1$+(z2$+z3) = z2$+(z1$+z3)";
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   285
by (asm_simp_tac (simpset() addsimps [zadd_assoc RS sym, zadd_commute]) 1);
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   286
qed "zadd_left_commute";
904
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   287
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   288
(*Integer addition is an AC operator*)
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   289
val zadd_ac = [zadd_assoc, zadd_commute, zadd_left_commute];
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   290
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
   291
Goalw [znat_def]
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   292
    "[| m: nat;  n: nat |] ==> $# (m #+ n) = ($#m) $+ ($#n)";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   293
by (asm_simp_tac (simpset() addsimps [zadd]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   294
qed "znat_add";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   295
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   296
Goalw [integ_def,znat_def] "z : integ ==> z $+ ($~ z) = $#0";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   297
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   298
by (asm_simp_tac (simpset() addsimps [zminus, zadd, add_commute]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   299
qed "zadd_zminus_inverse";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   300
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   301
Goal "z : integ ==> ($~ z) $+ z = $#0";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   302
by (asm_simp_tac
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   303
    (simpset() addsimps [zadd_commute, zminus_type, zadd_zminus_inverse]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   304
qed "zadd_zminus_inverse2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   305
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   306
Goal "z:integ ==> z $+ $#0 = z";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   307
by (rtac (zadd_commute RS trans) 1);
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   308
by (REPEAT (ares_tac [znat_type, nat_0I, zadd_0] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   309
qed "zadd_0_right";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   310
5507
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   311
Addsimps [zadd_0, zadd_0_right, zadd_zminus_inverse, zadd_zminus_inverse2];
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   312
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   313
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   314
(*Need properties of $- ???  Or use $- just as an abbreviation?
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   315
     [| m: nat;  n: nat;  m>=n |] ==> $# (m #- n) = ($#m) $- ($#n)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   316
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   317
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   318
(**** zmult: multiplication on integ ****)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   319
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   320
(** Congruence property for multiplication **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   321
5268
59ef39008514 even more tidying of Goal commands
paulson
parents: 5168
diff changeset
   322
Goal "congruent2(intrel, %p1 p2.                 \
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   323
\               split(%x1 y1. split(%x2 y2.     \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   324
\                   intrel``{<x1#*x2 #+ y1#*y2, x1#*y2 #+ y1#*x2>}, p2), p1))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   325
by (rtac (equiv_intrel RS congruent2_commuteI) 1);
4152
451104c223e2 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4091
diff changeset
   326
by Safe_tac;
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
   327
by (ALLGOALS Asm_simp_tac);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   328
(*Proof that zmult is congruent in one argument*)
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   329
by (asm_simp_tac 
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   330
    (simpset() addsimps (add_ac @ [add_mult_distrib_left RS sym])) 2);
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   331
by (asm_simp_tac
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   332
    (simpset() addsimps ([add_assoc RS sym, add_mult_distrib_left RS sym])) 2);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   333
(*Proof that zmult is commutative on representatives*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   334
by (asm_simp_tac (simpset() addsimps (mult_ac@add_ac)) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   335
qed "zmult_congruent2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   336
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   337
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   338
(*Resolve th against the corresponding facts for zmult*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   339
val zmult_ize = RSLIST [equiv_intrel, zmult_congruent2];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   340
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   341
Goalw [integ_def,zmult_def] "[| z: integ;  w: integ |] ==> z $* w : integ";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   342
by (REPEAT (ares_tac [zmult_ize UN_equiv_class_type2,
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   343
                      split_type, add_type, mult_type, 
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   344
                      quotientI, SigmaI] 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   345
qed "zmult_type";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   346
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
   347
Goalw [zmult_def]
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   348
     "[| x1: nat; y1: nat;  x2: nat; y2: nat |] ==>    \
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   349
\              (intrel``{<x1,y1>}) $* (intrel``{<x2,y2>}) =     \
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   350
\              intrel `` {<x1#*x2 #+ y1#*y2, x1#*y2 #+ y1#*x2>}";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   351
by (asm_simp_tac (simpset() addsimps [zmult_ize UN_equiv_class2, SigmaI]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   352
qed "zmult";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   353
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   354
Goalw [integ_def,znat_def] "z : integ ==> $#0 $* z = $#0";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   355
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   356
by (asm_simp_tac (simpset() addsimps [zmult]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   357
qed "zmult_0";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   358
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   359
Goalw [integ_def,znat_def] "z : integ ==> $#1 $* z = z";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   360
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   361
by (asm_simp_tac (simpset() addsimps [zmult, add_0_right]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   362
qed "zmult_1";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   363
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   364
Goalw [integ_def] "[| z: integ;  w: integ |] ==> ($~ z) $* w = $~ (z $* w)";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   365
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   366
by (asm_simp_tac (simpset() addsimps ([zminus, zmult] @ add_ac)) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   367
qed "zmult_zminus";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   368
5507
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   369
Addsimps [zmult_0, zmult_1, zmult_zminus];
2fd99b2d41e1 simpler definition of zmagnitude, and new thms for it
paulson
parents: 5268
diff changeset
   370
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   371
Goalw [integ_def] "[| z: integ;  w: integ |] ==> ($~ z) $* ($~ w) = (z $* w)";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   372
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   373
by (asm_simp_tac (simpset() addsimps ([zminus, zmult] @ add_ac)) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   374
qed "zmult_zminus_zminus";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   375
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   376
Goalw [integ_def] "[| z: integ;  w: integ |] ==> z $* w = w $* z";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   377
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   378
by (asm_simp_tac (simpset() addsimps ([zmult] @ add_ac @ mult_ac)) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   379
qed "zmult_commute";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   380
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
   381
Goalw [integ_def]
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   382
    "[| z1: integ;  z2: integ;  z3: integ |]     \
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   383
\    ==> (z1 $* z2) $* z3 = z1 $* (z2 $* z3)";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   384
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   385
by (asm_simp_tac 
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   386
    (simpset() addsimps ([zmult, add_mult_distrib_left, 
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   387
                          add_mult_distrib] @ add_ac @ mult_ac)) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   388
qed "zmult_assoc";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   389
904
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   390
(*For AC rewriting*)
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   391
Goal "[| z1:integ;  z2:integ;  z3: integ |] ==> z1$*(z2$*z3) = z2$*(z1$*z3)";
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   392
by (asm_simp_tac (simpset() addsimps [zmult_assoc RS sym, zmult_commute]) 1);
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   393
qed "zmult_left_commute";
904
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   394
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   395
(*Integer multiplication is an AC operator*)
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   396
val zmult_ac = [zmult_assoc, zmult_commute, zmult_left_commute];
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   397
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
   398
Goalw [integ_def]
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   399
    "[| z1: integ;  z2: integ;  w: integ |] ==> \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   400
\                (z1 $+ z2) $* w = (z1 $* w) $+ (z2 $* w)";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   401
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   402
by (asm_simp_tac (simpset() addsimps [zadd, zmult, add_mult_distrib]) 1);
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   403
by (asm_simp_tac (simpset() addsimps (add_ac @ mult_ac)) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   404
qed "zadd_zmult_distrib";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   405
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   406
val integ_typechecks =
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   407
    [znat_type, zminus_type, zmagnitude_type, zadd_type, zmult_type];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   408
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
   409
Addsimps integ_typechecks;
904
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   410
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   411
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
   412