src/ZF/ex/Integ.ML
author paulson
Tue, 24 Feb 1998 11:35:33 +0100
changeset 4648 f04da668581c
parent 4152 451104c223e2
child 5068 fb28eaa07e01
permissions -rw-r--r--
New theory of the inverse image of a function
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
7
268f93ab3bc4 Installation of new simplifier for ZF/ex. The hom_ss example in misc.ML is
lcp
parents: 0
diff changeset
    15
open Integ;
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
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    34
goalw Integ.thy [intrel_def]
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
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    40
goalw Integ.thy [intrel_def]
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    41
    "!!x1 x2. [| x1#+y2 = x2#+y1; x1: nat; y1: nat; x2: nat; y2: nat |] ==> \
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*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    47
goalw Integ.thy [intrel_def]
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
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    66
goalw Integ.thy [equiv_def, refl_def, sym_def, trans_def]
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
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    80
goalw Integ.thy [integ_def,quotient_def,znat_def]
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    81
    "!!m. 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
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    85
goalw Integ.thy [znat_def]
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    86
    "!!m n. [| $#m = $#n;  n: nat |] ==> m=n";
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    87
by (dtac eq_intrelD 1);
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
    88
by (typechk_tac [nat_0I, SigmaI]);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
    89
by (Asm_full_simp_tac 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    90
qed "znat_inject";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    91
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    92
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    93
(**** zminus: unary negation on integ ****)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    94
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    95
goalw Integ.thy [congruent_def]
1614
c9f0fc335b12 Rewriting changes due to new arith_ss
paulson
parents: 1461
diff changeset
    96
    "congruent(intrel, %<x,y>. intrel``{<y,x>})";
4152
451104c223e2 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4091
diff changeset
    97
by Safe_tac;
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
    98
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
    99
qed "zminus_congruent";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   100
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   101
(*Resolve th against the corresponding facts for zminus*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   102
val zminus_ize = RSLIST [equiv_intrel, zminus_congruent];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   103
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   104
goalw Integ.thy [integ_def,zminus_def]
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   105
    "!!z. z : integ ==> $~z : integ";
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   106
by (typechk_tac [split_type, SigmaI, zminus_ize UN_equiv_class_type,
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   107
                 quotientI]);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   108
qed "zminus_type";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   109
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   110
goalw Integ.thy [integ_def,zminus_def]
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   111
    "!!z w. [| $~z = $~w;  z: integ;  w: integ |] ==> z=w";
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   112
by (etac (zminus_ize UN_equiv_class_inject) 1);
4152
451104c223e2 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4091
diff changeset
   113
by Safe_tac;
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   114
(*The setloop is only needed because assumptions are in the wrong order!*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   115
by (asm_full_simp_tac (simpset() addsimps add_ac
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   116
                       setloop dtac eq_intrelD) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   117
qed "zminus_inject";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   118
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   119
goalw Integ.thy [zminus_def]
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   120
    "!!x y.[| x: nat;  y: nat |] ==> $~ (intrel``{<x,y>}) = intrel `` {<y,x>}";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   121
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
   122
qed "zminus";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   123
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   124
goalw Integ.thy [integ_def] "!!z. z : integ ==> $~ ($~ z) = z";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   125
by (REPEAT (eresolve_tac [quotientE,SigmaE,ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   126
by (asm_simp_tac (simpset() addsimps [zminus]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   127
qed "zminus_zminus";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   128
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   129
goalw Integ.thy [integ_def, znat_def] "$~ ($#0) = $#0";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   130
by (simp_tac (simpset() addsimps [zminus]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   131
qed "zminus_0";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   132
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   133
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   134
(**** znegative: the test for negative integers ****)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   135
1021
9aa52d5d614f Modified proofs for new hyp_subst_tac.
lcp
parents: 904
diff changeset
   136
(*No natural number is negative!*)
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   137
goalw Integ.thy [znegative_def, znat_def]  "~ znegative($# n)";
4152
451104c223e2 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4091
diff changeset
   138
by Safe_tac;
1021
9aa52d5d614f Modified proofs for new hyp_subst_tac.
lcp
parents: 904
diff changeset
   139
by (dres_inst_tac [("psi", "?lhs=?rhs")] asm_rl 1);
9aa52d5d614f Modified proofs for new hyp_subst_tac.
lcp
parents: 904
diff changeset
   140
by (dres_inst_tac [("psi", "?lhs<?rhs")] asm_rl 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   141
by (fast_tac (claset() addss
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   142
              (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
   143
qed "not_znegative_znat";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   144
29
4ec9b266ccd1 Modification of examples for the new operators, < and le.
lcp
parents: 16
diff changeset
   145
goalw Integ.thy [znegative_def, znat_def]
4ec9b266ccd1 Modification of examples for the new operators, < and le.
lcp
parents: 16
diff changeset
   146
    "!!n. n: nat ==> znegative($~ $# succ(n))";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   147
by (asm_simp_tac (simpset() addsimps [zminus]) 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   148
by (REPEAT 
29
4ec9b266ccd1 Modification of examples for the new operators, < and le.
lcp
parents: 16
diff changeset
   149
    (ares_tac [refl, exI, conjI, nat_0_le,
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   150
               refl RS intrelI RS imageI, consI1, nat_0I, nat_succI] 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   151
qed "znegative_zminus_znat";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   152
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   153
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   154
(**** zmagnitude: magnitide of an integer, as a natural number ****)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   155
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   156
goalw Integ.thy [congruent_def]
1614
c9f0fc335b12 Rewriting changes due to new arith_ss
paulson
parents: 1461
diff changeset
   157
    "congruent(intrel, %<x,y>. (y#-x) #+ (x#-y))";
4152
451104c223e2 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4091
diff changeset
   158
by Safe_tac;
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
   159
by (ALLGOALS Asm_simp_tac);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   160
by (etac rev_mp 1);
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   161
by (res_inst_tac [("m","x1"),("n","y1")] diff_induct 1 THEN 
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   162
    REPEAT (assume_tac 1));
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
   163
by (Asm_simp_tac 3);
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   164
by (asm_simp_tac  (*this one's very sensitive to order of rewrites*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   165
    (simpset() delsimps [add_succ_right] 
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
   166
              addsimps [diff_add_inverse,diff_add_0]) 2);
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
   167
by (Asm_simp_tac 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   168
by (rtac impI 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   169
by (etac subst 1);
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   170
by (res_inst_tac [("m1","x")] (add_commute RS ssubst) 1 THEN
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   171
    REPEAT (assume_tac 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   172
by (asm_simp_tac (simpset() addsimps [diff_add_inverse, diff_add_0]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   173
qed "zmagnitude_congruent";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   174
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   175
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   176
(*Resolve th against the corresponding facts for zmagnitude*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   177
val zmagnitude_ize = RSLIST [equiv_intrel, zmagnitude_congruent];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   178
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   179
goalw Integ.thy [integ_def,zmagnitude_def]
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   180
    "!!z. z : integ ==> zmagnitude(z) : nat";
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   181
by (typechk_tac [split_type, zmagnitude_ize UN_equiv_class_type,
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   182
                 add_type, diff_type]);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   183
qed "zmagnitude_type";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   184
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   185
goalw Integ.thy [zmagnitude_def]
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   186
    "!!x y. [| x: nat;  y: nat |] ==> \
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   187
\           zmagnitude (intrel``{<x,y>}) = (y #- x) #+ (x #- y)";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
   188
by (asm_simp_tac
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   189
    (simpset() addsimps [zmagnitude_ize UN_equiv_class, SigmaI]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   190
qed "zmagnitude";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   191
29
4ec9b266ccd1 Modification of examples for the new operators, < and le.
lcp
parents: 16
diff changeset
   192
goalw Integ.thy [znat_def]
4ec9b266ccd1 Modification of examples for the new operators, < and le.
lcp
parents: 16
diff changeset
   193
    "!!n. n: nat ==> zmagnitude($# n) = n";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   194
by (asm_simp_tac (simpset() addsimps [zmagnitude]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   195
qed "zmagnitude_znat";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   196
29
4ec9b266ccd1 Modification of examples for the new operators, < and le.
lcp
parents: 16
diff changeset
   197
goalw Integ.thy [znat_def]
4ec9b266ccd1 Modification of examples for the new operators, < and le.
lcp
parents: 16
diff changeset
   198
    "!!n. n: nat ==> zmagnitude($~ $# n) = n";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   199
by (asm_simp_tac (simpset() addsimps [zmagnitude, zminus]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   200
qed "zmagnitude_zminus_znat";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   201
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   202
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   203
(**** zadd: addition on integ ****)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   204
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   205
(** Congruence property for addition **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   206
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   207
goalw Integ.thy [congruent2_def]
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   208
    "congruent2(intrel, %z1 z2.                      \
1110
756aa2e81f6e Changed some definitions and proofs to use pattern-matching.
lcp
parents: 1021
diff changeset
   209
\         let <x1,y1>=z1; <x2,y2>=z2                 \
756aa2e81f6e Changed some definitions and proofs to use pattern-matching.
lcp
parents: 1021
diff changeset
   210
\                           in intrel``{<x1#+x2, y1#+y2>})";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   211
(*Proof via congruent2_commuteI seems longer*)
4152
451104c223e2 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4091
diff changeset
   212
by Safe_tac;
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   213
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
   214
(*The rest should be trivial, but rearranging terms is hard;
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   215
  add_ac does not help rewriting with the assumptions.*)
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   216
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
   217
by (res_inst_tac [("m1","x2a")] (add_left_commute RS ssubst) 3);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   218
by (typechk_tac [add_type]);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   219
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
   220
qed "zadd_congruent2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   221
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   222
(*Resolve th against the corresponding facts for zadd*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   223
val zadd_ize = RSLIST [equiv_intrel, zadd_congruent2];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   224
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   225
goalw Integ.thy [integ_def,zadd_def]
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   226
    "!!z w. [| z: integ;  w: integ |] ==> z $+ w : integ";
1110
756aa2e81f6e Changed some definitions and proofs to use pattern-matching.
lcp
parents: 1021
diff changeset
   227
by (rtac (zadd_ize UN_equiv_class_type2) 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   228
by (simp_tac (simpset() addsimps [Let_def]) 3);
1110
756aa2e81f6e Changed some definitions and proofs to use pattern-matching.
lcp
parents: 1021
diff changeset
   229
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
   230
qed "zadd_type";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   231
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   232
goalw Integ.thy [zadd_def]
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   233
  "!!x1 y1. [| x1: nat; y1: nat;  x2: nat; y2: nat |] ==>       \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   234
\           (intrel``{<x1,y1>}) $+ (intrel``{<x2,y2>}) =        \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   235
\           intrel `` {<x1#+x2, y1#+y2>}";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   236
by (asm_simp_tac (simpset() addsimps [zadd_ize UN_equiv_class2, SigmaI]) 1);
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   237
by (simp_tac (simpset() addsimps [Let_def]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   238
qed "zadd";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   239
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   240
goalw Integ.thy [integ_def,znat_def] "!!z. z : integ ==> $#0 $+ z = z";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   241
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   242
by (asm_simp_tac (simpset() addsimps [zadd]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   243
qed "zadd_0";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   244
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   245
goalw Integ.thy [integ_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   246
    "!!z w. [| z: integ;  w: integ |] ==> $~ (z $+ w) = $~ z $+ $~ w";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   247
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   248
by (asm_simp_tac (simpset() addsimps [zminus,zadd]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   249
qed "zminus_zadd_distrib";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   250
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   251
goalw Integ.thy [integ_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   252
    "!!z w. [| z: integ;  w: integ |] ==> z $+ w = w $+ z";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   253
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   254
by (asm_simp_tac (simpset() addsimps (add_ac @ [zadd])) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   255
qed "zadd_commute";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   256
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   257
goalw Integ.thy [integ_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   258
    "!!z1 z2 z3. [| z1: integ;  z2: integ;  z3: integ |] ==> \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   259
\                (z1 $+ z2) $+ z3 = z1 $+ (z2 $+ z3)";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   260
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   261
(*rewriting is much faster without intrel_iff, etc.*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   262
by (asm_simp_tac (simpset() addsimps [zadd, add_assoc]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   263
qed "zadd_assoc";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   264
904
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   265
(*For AC rewriting*)
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   266
qed_goal "zadd_left_commute" Integ.thy
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   267
    "!!z1 z2 z3. [| z1:integ;  z2:integ;  z3: integ |] ==> \
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   268
\                z1$+(z2$+z3) = z2$+(z1$+z3)"
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   269
 (fn _ => [asm_simp_tac (simpset() addsimps [zadd_assoc RS sym, zadd_commute]) 1]);
904
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   270
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   271
(*Integer addition is an AC operator*)
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   272
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
   273
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   274
goalw Integ.thy [znat_def]
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   275
    "!!m n. [| m: nat;  n: nat |] ==> $# (m #+ n) = ($#m) $+ ($#n)";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   276
by (asm_simp_tac (simpset() addsimps [zadd]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   277
qed "znat_add";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   278
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   279
goalw Integ.thy [integ_def,znat_def] "!!z. z : integ ==> z $+ ($~ z) = $#0";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   280
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   281
by (asm_simp_tac (simpset() addsimps [zminus, zadd, add_commute]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   282
qed "zadd_zminus_inverse";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   283
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   284
goal Integ.thy "!!z. z : integ ==> ($~ z) $+ z = $#0";
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   285
by (asm_simp_tac
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   286
    (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
   287
qed "zadd_zminus_inverse2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   288
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   289
goal Integ.thy "!!z. z:integ ==> z $+ $#0 = z";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   290
by (rtac (zadd_commute RS trans) 1);
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   291
by (REPEAT (ares_tac [znat_type, nat_0I, zadd_0] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   292
qed "zadd_0_right";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   293
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   294
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   295
(*Need properties of $- ???  Or use $- just as an abbreviation?
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   296
     [| m: nat;  n: nat;  m>=n |] ==> $# (m #- n) = ($#m) $- ($#n)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   297
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   298
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   299
(**** zmult: multiplication on integ ****)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   300
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   301
(** Congruence property for multiplication **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   302
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   303
goal Integ.thy 
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   304
    "congruent2(intrel, %p1 p2.                 \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   305
\               split(%x1 y1. split(%x2 y2.     \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   306
\                   intrel``{<x1#*x2 #+ y1#*y2, x1#*y2 #+ y1#*x2>}, p2), p1))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   307
by (rtac (equiv_intrel RS congruent2_commuteI) 1);
4152
451104c223e2 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4091
diff changeset
   308
by Safe_tac;
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
   309
by (ALLGOALS Asm_simp_tac);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   310
(*Proof that zmult is congruent in one argument*)
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   311
by (asm_simp_tac 
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   312
    (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
   313
by (asm_simp_tac
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   314
    (simpset() addsimps ([add_assoc RS sym, add_mult_distrib_left RS sym])) 2);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   315
(*Proof that zmult is commutative on representatives*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   316
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
   317
qed "zmult_congruent2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   318
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   319
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   320
(*Resolve th against the corresponding facts for zmult*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   321
val zmult_ize = RSLIST [equiv_intrel, zmult_congruent2];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   322
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   323
goalw Integ.thy [integ_def,zmult_def]
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   324
    "!!z w. [| z: integ;  w: integ |] ==> z $* w : integ";
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   325
by (REPEAT (ares_tac [zmult_ize UN_equiv_class_type2,
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   326
                      split_type, add_type, mult_type, 
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   327
                      quotientI, SigmaI] 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   328
qed "zmult_type";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   329
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   330
goalw Integ.thy [zmult_def]
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   331
     "!!x1 x2. [| x1: nat; y1: nat;  x2: nat; y2: nat |] ==>    \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   332
\              (intrel``{<x1,y1>}) $* (intrel``{<x2,y2>}) =     \
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   333
\              intrel `` {<x1#*x2 #+ y1#*y2, x1#*y2 #+ y1#*x2>}";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   334
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
   335
qed "zmult";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   336
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   337
goalw Integ.thy [integ_def,znat_def] "!!z. z : integ ==> $#0 $* z = $#0";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   338
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   339
by (asm_simp_tac (simpset() addsimps [zmult]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   340
qed "zmult_0";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   341
16
0b033d50ca1c ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 7
diff changeset
   342
goalw Integ.thy [integ_def,znat_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   343
    "!!z. z : integ ==> $#1 $* z = z";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   344
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   345
by (asm_simp_tac (simpset() addsimps [zmult, add_0_right]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   346
qed "zmult_1";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   347
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   348
goalw Integ.thy [integ_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   349
    "!!z w. [| z: integ;  w: integ |] ==> ($~ z) $* w = $~ (z $* w)";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   350
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   351
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
   352
qed "zmult_zminus";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   353
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   354
goalw Integ.thy [integ_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   355
    "!!z w. [| z: integ;  w: integ |] ==> ($~ z) $* ($~ w) = (z $* w)";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   356
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   357
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
   358
qed "zmult_zminus_zminus";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   359
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   360
goalw Integ.thy [integ_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   361
    "!!z w. [| z: integ;  w: integ |] ==> z $* w = w $* z";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   362
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   363
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
   364
qed "zmult_commute";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   365
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   366
goalw Integ.thy [integ_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   367
    "!!z1 z2 z3. [| z1: integ;  z2: integ;  z3: integ |] ==> \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   368
\                (z1 $* z2) $* z3 = z1 $* (z2 $* z3)";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   369
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   370
by (asm_simp_tac 
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   371
    (simpset() addsimps ([zmult, add_mult_distrib_left, 
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   372
                          add_mult_distrib] @ add_ac @ mult_ac)) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   373
qed "zmult_assoc";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   374
904
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   375
(*For AC rewriting*)
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   376
qed_goal "zmult_left_commute" Integ.thy
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   377
    "!!z1 z2 z3. [| z1:integ;  z2:integ;  z3: integ |] ==> \
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   378
\                z1$*(z2$*z3) = z2$*(z1$*z3)"
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   379
 (fn _ => [asm_simp_tac (simpset() addsimps [zmult_assoc RS sym, 
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   380
                                         zmult_commute]) 1]);
904
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   381
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   382
(*Integer multiplication is an AC operator*)
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   383
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
   384
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   385
goalw Integ.thy [integ_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   386
    "!!z1 z2 z3. [| z1: integ;  z2: integ;  w: integ |] ==> \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   387
\                (z1 $+ z2) $* w = (z1 $* w) $+ (z2 $* w)";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 29
diff changeset
   388
by (REPEAT (eresolve_tac [quotientE, SigmaE, ssubst] 1));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   389
by (asm_simp_tac (simpset() addsimps [zadd, zmult, add_mult_distrib]) 1);
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
   390
by (asm_simp_tac (simpset() addsimps (add_ac @ mult_ac)) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 438
diff changeset
   391
qed "zadd_zmult_distrib";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   392
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   393
val integ_typechecks =
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   394
    [znat_type, zminus_type, zmagnitude_type, zadd_type, zmult_type];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   395
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
   396
Addsimps integ_typechecks;
904
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   397
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
   398
Addsimps [zadd_0, zadd_0_right, zadd_zminus_inverse, zadd_zminus_inverse2];
904
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   399
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
   400
Addsimps [zminus_zminus, zminus_0];
904
5240dcd12adb Proved zadd_left_commute and zmult_left_commute to define
lcp
parents: 804
diff changeset
   401
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
   402
Addsimps [zmult_0, zmult_1, zmult_zminus];
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
   403
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2034
diff changeset
   404
Addsimps [zmagnitude_znat, zmagnitude_zminus_znat];