src/ZF/Integ/Int.thy
author paulson
Mon, 06 Sep 2004 15:57:58 +0200
changeset 15182 5cea84e10f3e
parent 14565 c6dc17aab88a
child 16417 9bc16273c2d4
permissions -rw-r--r--
new "respects" syntax for the congruent operator
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5561
426c1e330903 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
     1
(*  Title:      ZF/Integ/Int.thy
426c1e330903 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
     2
    ID:         $Id$
426c1e330903 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
426c1e330903 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
426c1e330903 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
     5
426c1e330903 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
     6
*)
426c1e330903 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
     7
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
     8
header{*The Integers as Equivalence Classes Over Pairs of Natural Numbers*}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
     9
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    10
theory Int = EquivClass + ArithSimp:
9496
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    11
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    12
constdefs
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    13
  intrel :: i
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    14
    "intrel == {p : (nat*nat)*(nat*nat).                 
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
    15
                \<exists>x1 y1 x2 y2. p=<<x1,y1>,<x2,y2>> & x1#+y2 = x2#+y1}"
5561
426c1e330903 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
    16
9496
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    17
  int :: i
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    18
    "int == (nat*nat)//intrel"  
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    19
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    20
  int_of :: "i=>i" --{*coercion from nat to int*}    ("$# _" [80] 80)
9496
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    21
    "$# m == intrel `` {<natify(m), 0>}"
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    22
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    23
  intify :: "i=>i" --{*coercion from ANYTHING to int*}
9496
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    24
    "intify(m) == if m : int then m else $#0"
5561
426c1e330903 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
    25
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    26
  raw_zminus :: "i=>i"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
    27
    "raw_zminus(z) == \<Union><x,y>\<in>z. intrel``{<y,x>}"
9496
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    28
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    29
  zminus :: "i=>i"                                 ("$- _" [80] 80)
9548
15bee2731e43 instantiated Cancel_Numerals for "nat" in ZF
paulson
parents: 9496
diff changeset
    30
    "$- z == raw_zminus (intify(z))"
5561
426c1e330903 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
    31
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    32
  znegative   ::      "i=>o"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
    33
    "znegative(z) == \<exists>x y. x<y & y\<in>nat & <x,y>\<in>z"
9570
e16e168984e1 installation of cancellation simprocs for the integers
paulson
parents: 9548
diff changeset
    34
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    35
  iszero      ::      "i=>o"
9570
e16e168984e1 installation of cancellation simprocs for the integers
paulson
parents: 9548
diff changeset
    36
    "iszero(z) == z = $# 0"
e16e168984e1 installation of cancellation simprocs for the integers
paulson
parents: 9548
diff changeset
    37
    
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    38
  raw_nat_of  :: "i=>i"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
    39
  "raw_nat_of(z) == natify (\<Union><x,y>\<in>z. x#-y)"
9883
c1c8647af477 a number of new theorems
paulson
parents: 9654
diff changeset
    40
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    41
  nat_of  :: "i=>i"
9883
c1c8647af477 a number of new theorems
paulson
parents: 9654
diff changeset
    42
  "nat_of(z) == raw_nat_of (intify(z))"
c1c8647af477 a number of new theorems
paulson
parents: 9654
diff changeset
    43
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    44
  zmagnitude  ::      "i=>i"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    45
  --{*could be replaced by an absolute value function from int to int?*}
9496
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    46
    "zmagnitude(z) ==
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
    47
     THE m. m\<in>nat & ((~ znegative(z) & z = $# m) |
9548
15bee2731e43 instantiated Cancel_Numerals for "nat" in ZF
paulson
parents: 9496
diff changeset
    48
		       (znegative(z) & $- z = $# m))"
9496
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    49
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    50
  raw_zmult   ::      "[i,i]=>i"
9496
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    51
    (*Cannot use UN<x1,y2> here or in zadd because of the form of congruent2.
5561
426c1e330903 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
    52
      Perhaps a "curried" or even polymorphic congruent predicate would be
426c1e330903 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
    53
      better.*)
9496
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    54
     "raw_zmult(z1,z2) == 
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
    55
       \<Union>p1\<in>z1. \<Union>p2\<in>z2.  split(%x1 y1. split(%x2 y2.        
9496
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    56
                   intrel``{<x1#*x2 #+ y1#*y2, x1#*y2 #+ y1#*x2>}, p2), p1)"
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    57
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    58
  zmult       ::      "[i,i]=>i"      (infixl "$*" 70)
9496
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    59
     "z1 $* z2 == raw_zmult (intify(z1),intify(z2))"
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    60
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    61
  raw_zadd    ::      "[i,i]=>i"
9496
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    62
     "raw_zadd (z1, z2) == 
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
    63
       \<Union>z1\<in>z1. \<Union>z2\<in>z2. let <x1,y1>=z1; <x2,y2>=z2                 
5561
426c1e330903 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
    64
                           in intrel``{<x1#+x2, y1#+y2>}"
9496
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    65
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    66
  zadd        ::      "[i,i]=>i"      (infixl "$+" 65)
9496
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    67
     "z1 $+ z2 == raw_zadd (intify(z1),intify(z2))"
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    68
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    69
  zdiff        ::      "[i,i]=>i"      (infixl "$-" 65)
9496
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    70
     "z1 $- z2 == z1 $+ zminus(z2)"
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    71
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    72
  zless        ::      "[i,i]=>o"      (infixl "$<" 50)
9496
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    73
     "z1 $< z2 == znegative(z1 $- z2)"
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
    74
  
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    75
  zle          ::      "[i,i]=>o"      (infixl "$<=" 50)
9570
e16e168984e1 installation of cancellation simprocs for the integers
paulson
parents: 9548
diff changeset
    76
     "z1 $<= z2 == z1 $< z2 | intify(z1)=intify(z2)"
9548
15bee2731e43 instantiated Cancel_Numerals for "nat" in ZF
paulson
parents: 9496
diff changeset
    77
  
9654
9754ba005b64 X-symbols for ordinal, cardinal, integer arithmetic
paulson
parents: 9578
diff changeset
    78
12114
a8e860c86252 eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents: 11321
diff changeset
    79
syntax (xsymbols)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    80
  zmult :: "[i,i]=>i"          (infixl "$\<times>" 70)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    81
  zle   :: "[i,i]=>o"          (infixl "$\<le>" 50)  --{*less than or equals*}
9654
9754ba005b64 X-symbols for ordinal, cardinal, integer arithmetic
paulson
parents: 9578
diff changeset
    82
9964
7966a2902266 tuned symbols;
wenzelm
parents: 9883
diff changeset
    83
syntax (HTML output)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    84
  zmult :: "[i,i]=>i"          (infixl "$\<times>" 70)
14565
c6dc17aab88a use more symbols in HTML output
kleing
parents: 14511
diff changeset
    85
  zle   :: "[i,i]=>o"          (infixl "$\<le>" 50)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    86
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    87
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    88
declare quotientE [elim!]
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    89
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    90
subsection{*Proving that @{term intrel} is an equivalence relation*}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    91
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    92
(** Natural deduction for intrel **)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    93
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    94
lemma intrel_iff [simp]: 
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    95
    "<<x1,y1>,<x2,y2>>: intrel <->  
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
    96
     x1\<in>nat & y1\<in>nat & x2\<in>nat & y2\<in>nat & x1#+y2 = x2#+y1"
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
    97
by (simp add: intrel_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    98
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
    99
lemma intrelI [intro!]: 
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   100
    "[| x1#+y2 = x2#+y1; x1\<in>nat; y1\<in>nat; x2\<in>nat; y2\<in>nat |]   
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   101
     ==> <<x1,y1>,<x2,y2>>: intrel"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   102
by (simp add: intrel_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   103
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   104
lemma intrelE [elim!]:
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   105
  "[| p: intrel;   
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   106
      !!x1 y1 x2 y2. [| p = <<x1,y1>,<x2,y2>>;  x1#+y2 = x2#+y1;  
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   107
                        x1\<in>nat; y1\<in>nat; x2\<in>nat; y2\<in>nat |] ==> Q |]  
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   108
   ==> Q"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   109
by (simp add: intrel_def, blast) 
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   110
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   111
lemma int_trans_lemma:
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   112
     "[| x1 #+ y2 = x2 #+ y1; x2 #+ y3 = x3 #+ y2 |] ==> x1 #+ y3 = x3 #+ y1"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   113
apply (rule sym)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   114
apply (erule add_left_cancel)+
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   115
apply (simp_all (no_asm_simp))
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   116
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   117
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   118
lemma equiv_intrel: "equiv(nat*nat, intrel)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   119
apply (simp add: equiv_def refl_def sym_def trans_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   120
apply (fast elim!: sym int_trans_lemma)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   121
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   122
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   123
lemma image_intrel_int: "[| m\<in>nat; n\<in>nat |] ==> intrel `` {<m,n>} : int"
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   124
by (simp add: int_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   125
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   126
declare equiv_intrel [THEN eq_equiv_class_iff, simp]
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   127
declare conj_cong [cong]
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   128
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   129
lemmas eq_intrelD = eq_equiv_class [OF _ equiv_intrel]
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   130
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   131
(** int_of: the injection from nat to int **)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   132
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   133
lemma int_of_type [simp,TC]: "$#m : int"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   134
by (simp add: int_def quotient_def int_of_def, auto)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   135
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   136
lemma int_of_eq [iff]: "($# m = $# n) <-> natify(m)=natify(n)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   137
by (simp add: int_of_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   138
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   139
lemma int_of_inject: "[| $#m = $#n;  m\<in>nat;  n\<in>nat |] ==> m=n"
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   140
by (drule int_of_eq [THEN iffD1], auto)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   141
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   142
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   143
(** intify: coercion from anything to int **)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   144
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   145
lemma intify_in_int [iff,TC]: "intify(x) : int"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   146
by (simp add: intify_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   147
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   148
lemma intify_ident [simp]: "n : int ==> intify(n) = n"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   149
by (simp add: intify_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   150
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   151
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   152
subsection{*Collapsing rules: to remove @{term intify}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   153
            from arithmetic expressions*}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   154
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   155
lemma intify_idem [simp]: "intify(intify(x)) = intify(x)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   156
by simp
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   157
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   158
lemma int_of_natify [simp]: "$# (natify(m)) = $# m"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   159
by (simp add: int_of_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   160
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   161
lemma zminus_intify [simp]: "$- (intify(m)) = $- m"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   162
by (simp add: zminus_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   163
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   164
(** Addition **)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   165
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   166
lemma zadd_intify1 [simp]: "intify(x) $+ y = x $+ y"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   167
by (simp add: zadd_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   168
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   169
lemma zadd_intify2 [simp]: "x $+ intify(y) = x $+ y"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   170
by (simp add: zadd_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   171
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   172
(** Subtraction **)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   173
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   174
lemma zdiff_intify1 [simp]:"intify(x) $- y = x $- y"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   175
by (simp add: zdiff_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   176
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   177
lemma zdiff_intify2 [simp]:"x $- intify(y) = x $- y"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   178
by (simp add: zdiff_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   179
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   180
(** Multiplication **)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   181
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   182
lemma zmult_intify1 [simp]:"intify(x) $* y = x $* y"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   183
by (simp add: zmult_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   184
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   185
lemma zmult_intify2 [simp]:"x $* intify(y) = x $* y"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   186
by (simp add: zmult_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   187
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   188
(** Orderings **)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   189
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   190
lemma zless_intify1 [simp]:"intify(x) $< y <-> x $< y"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   191
by (simp add: zless_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   192
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   193
lemma zless_intify2 [simp]:"x $< intify(y) <-> x $< y"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   194
by (simp add: zless_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   195
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   196
lemma zle_intify1 [simp]:"intify(x) $<= y <-> x $<= y"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   197
by (simp add: zle_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   198
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   199
lemma zle_intify2 [simp]:"x $<= intify(y) <-> x $<= y"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   200
by (simp add: zle_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   201
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   202
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   203
subsection{*@{term zminus}: unary negation on @{term int}*}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   204
15182
5cea84e10f3e new "respects" syntax for the congruent operator
paulson
parents: 14565
diff changeset
   205
lemma zminus_congruent: "(%<x,y>. intrel``{<y,x>}) respects intrel"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   206
by (auto simp add: congruent_def add_ac)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   207
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   208
lemma raw_zminus_type: "z : int ==> raw_zminus(z) : int"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   209
apply (simp add: int_def raw_zminus_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   210
apply (typecheck add: UN_equiv_class_type [OF equiv_intrel zminus_congruent])
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   211
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   212
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   213
lemma zminus_type [TC,iff]: "$-z : int"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   214
by (simp add: zminus_def raw_zminus_type)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   215
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   216
lemma raw_zminus_inject: 
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   217
     "[| raw_zminus(z) = raw_zminus(w);  z: int;  w: int |] ==> z=w"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   218
apply (simp add: int_def raw_zminus_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   219
apply (erule UN_equiv_class_inject [OF equiv_intrel zminus_congruent], safe)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   220
apply (auto dest: eq_intrelD simp add: add_ac)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   221
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   222
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   223
lemma zminus_inject_intify [dest!]: "$-z = $-w ==> intify(z) = intify(w)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   224
apply (simp add: zminus_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   225
apply (blast dest!: raw_zminus_inject)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   226
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   227
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   228
lemma zminus_inject: "[| $-z = $-w;  z: int;  w: int |] ==> z=w"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   229
by auto
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   230
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   231
lemma raw_zminus: 
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   232
    "[| x\<in>nat;  y\<in>nat |] ==> raw_zminus(intrel``{<x,y>}) = intrel `` {<y,x>}"
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   233
apply (simp add: raw_zminus_def UN_equiv_class [OF equiv_intrel zminus_congruent])
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   234
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   235
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   236
lemma zminus: 
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   237
    "[| x\<in>nat;  y\<in>nat |]  
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   238
     ==> $- (intrel``{<x,y>}) = intrel `` {<y,x>}"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   239
by (simp add: zminus_def raw_zminus image_intrel_int)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   240
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   241
lemma raw_zminus_zminus: "z : int ==> raw_zminus (raw_zminus(z)) = z"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   242
by (auto simp add: int_def raw_zminus)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   243
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   244
lemma zminus_zminus_intify [simp]: "$- ($- z) = intify(z)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   245
by (simp add: zminus_def raw_zminus_type raw_zminus_zminus)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   246
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   247
lemma zminus_int0 [simp]: "$- ($#0) = $#0"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   248
by (simp add: int_of_def zminus)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   249
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   250
lemma zminus_zminus: "z : int ==> $- ($- z) = z"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   251
by simp
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   252
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   253
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   254
subsection{*@{term znegative}: the test for negative integers*}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   255
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   256
lemma znegative: "[| x\<in>nat; y\<in>nat |] ==> znegative(intrel``{<x,y>}) <-> x<y"
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   257
apply (cases "x<y") 
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   258
apply (auto simp add: znegative_def not_lt_iff_le)
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   259
apply (subgoal_tac "y #+ x2 < x #+ y2", force) 
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   260
apply (rule add_le_lt_mono, auto) 
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   261
done
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   262
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   263
(*No natural number is negative!*)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   264
lemma not_znegative_int_of [iff]: "~ znegative($# n)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   265
by (simp add: znegative int_of_def) 
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   266
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   267
lemma znegative_zminus_int_of [simp]: "znegative($- $# succ(n))"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   268
by (simp add: znegative int_of_def zminus natify_succ)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   269
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   270
lemma not_znegative_imp_zero: "~ znegative($- $# n) ==> natify(n)=0"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   271
by (simp add: znegative int_of_def zminus Ord_0_lt_iff [THEN iff_sym])
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   272
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   273
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   274
subsection{*@{term nat_of}: Coercion of an Integer to a Natural Number*}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   275
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   276
lemma nat_of_intify [simp]: "nat_of(intify(z)) = nat_of(z)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   277
by (simp add: nat_of_def)
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   278
15182
5cea84e10f3e new "respects" syntax for the congruent operator
paulson
parents: 14565
diff changeset
   279
lemma nat_of_congruent: "(\<lambda>x. (\<lambda>\<langle>x,y\<rangle>. x #- y)(x)) respects intrel"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   280
by (auto simp add: congruent_def split add: nat_diff_split)
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   281
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   282
lemma raw_nat_of: 
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   283
    "[| x\<in>nat;  y\<in>nat |] ==> raw_nat_of(intrel``{<x,y>}) = x#-y"
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   284
by (simp add: raw_nat_of_def UN_equiv_class [OF equiv_intrel nat_of_congruent])
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   285
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   286
lemma raw_nat_of_int_of: "raw_nat_of($# n) = natify(n)"
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   287
by (simp add: int_of_def raw_nat_of)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   288
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   289
lemma nat_of_int_of [simp]: "nat_of($# n) = natify(n)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   290
by (simp add: raw_nat_of_int_of nat_of_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   291
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   292
lemma raw_nat_of_type: "raw_nat_of(z) \<in> nat"
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   293
by (simp add: raw_nat_of_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   294
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   295
lemma nat_of_type [iff,TC]: "nat_of(z) \<in> nat"
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   296
by (simp add: nat_of_def raw_nat_of_type)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   297
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   298
subsection{*zmagnitude: magnitide of an integer, as a natural number*}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   299
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   300
lemma zmagnitude_int_of [simp]: "zmagnitude($# n) = natify(n)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   301
by (auto simp add: zmagnitude_def int_of_eq)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   302
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   303
lemma natify_int_of_eq: "natify(x)=n ==> $#x = $# n"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   304
apply (drule sym)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   305
apply (simp (no_asm_simp) add: int_of_eq)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   306
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   307
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   308
lemma zmagnitude_zminus_int_of [simp]: "zmagnitude($- $# n) = natify(n)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   309
apply (simp add: zmagnitude_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   310
apply (rule the_equality)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   311
apply (auto dest!: not_znegative_imp_zero natify_int_of_eq
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   312
            iff del: int_of_eq, auto)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   313
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   314
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   315
lemma zmagnitude_type [iff,TC]: "zmagnitude(z)\<in>nat"
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   316
apply (simp add: zmagnitude_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   317
apply (rule theI2, auto)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   318
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   319
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   320
lemma not_zneg_int_of: 
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   321
     "[| z: int; ~ znegative(z) |] ==> \<exists>n\<in>nat. z = $# n"
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   322
apply (auto simp add: int_def znegative int_of_def not_lt_iff_le)
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   323
apply (rename_tac x y) 
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   324
apply (rule_tac x="x#-y" in bexI) 
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   325
apply (auto simp add: add_diff_inverse2) 
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   326
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   327
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   328
lemma not_zneg_mag [simp]:
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   329
     "[| z: int; ~ znegative(z) |] ==> $# (zmagnitude(z)) = z"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   330
by (drule not_zneg_int_of, auto)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   331
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   332
lemma zneg_int_of: 
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   333
     "[| znegative(z); z: int |] ==> \<exists>n\<in>nat. z = $- ($# succ(n))"
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   334
by (auto simp add: int_def znegative zminus int_of_def dest!: less_imp_succ_add)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   335
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   336
lemma zneg_mag [simp]:
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   337
     "[| znegative(z); z: int |] ==> $# (zmagnitude(z)) = $- z"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   338
by (drule zneg_int_of, auto)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   339
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   340
lemma int_cases: "z : int ==> \<exists>n\<in>nat. z = $# n | z = $- ($# succ(n))"
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   341
apply (case_tac "znegative (z) ")
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   342
prefer 2 apply (blast dest: not_zneg_mag sym)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   343
apply (blast dest: zneg_int_of)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   344
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   345
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   346
lemma not_zneg_raw_nat_of:
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   347
     "[| ~ znegative(z); z: int |] ==> $# (raw_nat_of(z)) = z"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   348
apply (drule not_zneg_int_of)
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   349
apply (auto simp add: raw_nat_of_type raw_nat_of_int_of)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   350
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   351
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   352
lemma not_zneg_nat_of_intify:
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   353
     "~ znegative(intify(z)) ==> $# (nat_of(z)) = intify(z)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   354
by (simp (no_asm_simp) add: nat_of_def not_zneg_raw_nat_of)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   355
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   356
lemma not_zneg_nat_of: "[| ~ znegative(z); z: int |] ==> $# (nat_of(z)) = z"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   357
apply (simp (no_asm_simp) add: not_zneg_nat_of_intify)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   358
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   359
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   360
lemma zneg_nat_of [simp]: "znegative(intify(z)) ==> nat_of(z) = 0"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   361
apply (subgoal_tac "intify(z) \<in> int")
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   362
apply (simp add: int_def) 
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   363
apply (auto simp add: znegative nat_of_def raw_nat_of 
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   364
            split add: nat_diff_split) 
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   365
done
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   366
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   367
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   368
subsection{*@{term zadd}: addition on int*}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   369
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   370
text{*Congruence Property for Addition*}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   371
lemma zadd_congruent2: 
15182
5cea84e10f3e new "respects" syntax for the congruent operator
paulson
parents: 14565
diff changeset
   372
    "(%z1 z2. let <x1,y1>=z1; <x2,y2>=z2                  
5cea84e10f3e new "respects" syntax for the congruent operator
paulson
parents: 14565
diff changeset
   373
                            in intrel``{<x1#+x2, y1#+y2>})
5cea84e10f3e new "respects" syntax for the congruent operator
paulson
parents: 14565
diff changeset
   374
     respects2 intrel"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   375
apply (simp add: congruent2_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   376
(*Proof via congruent2_commuteI seems longer*)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   377
apply safe
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   378
apply (simp (no_asm_simp) add: add_assoc Let_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   379
(*The rest should be trivial, but rearranging terms is hard
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   380
  add_ac does not help rewriting with the assumptions.*)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   381
apply (rule_tac m1 = x1a in add_left_commute [THEN ssubst])
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   382
apply (rule_tac m1 = x2a in add_left_commute [THEN ssubst])
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   383
apply (simp (no_asm_simp) add: add_assoc [symmetric])
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   384
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   385
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   386
lemma raw_zadd_type: "[| z: int;  w: int |] ==> raw_zadd(z,w) : int"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   387
apply (simp add: int_def raw_zadd_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   388
apply (rule UN_equiv_class_type2 [OF equiv_intrel zadd_congruent2], assumption+)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   389
apply (simp add: Let_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   390
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   391
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   392
lemma zadd_type [iff,TC]: "z $+ w : int"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   393
by (simp add: zadd_def raw_zadd_type)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   394
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   395
lemma raw_zadd: 
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   396
  "[| x1\<in>nat; y1\<in>nat;  x2\<in>nat; y2\<in>nat |]               
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   397
   ==> raw_zadd (intrel``{<x1,y1>}, intrel``{<x2,y2>}) =   
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   398
       intrel `` {<x1#+x2, y1#+y2>}"
15182
5cea84e10f3e new "respects" syntax for the congruent operator
paulson
parents: 14565
diff changeset
   399
apply (simp add: raw_zadd_def 
5cea84e10f3e new "respects" syntax for the congruent operator
paulson
parents: 14565
diff changeset
   400
             UN_equiv_class2 [OF equiv_intrel equiv_intrel zadd_congruent2])
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   401
apply (simp add: Let_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   402
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   403
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   404
lemma zadd: 
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   405
  "[| x1\<in>nat; y1\<in>nat;  x2\<in>nat; y2\<in>nat |]          
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   406
   ==> (intrel``{<x1,y1>}) $+ (intrel``{<x2,y2>}) =   
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   407
       intrel `` {<x1#+x2, y1#+y2>}"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   408
by (simp add: zadd_def raw_zadd image_intrel_int)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   409
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   410
lemma raw_zadd_int0: "z : int ==> raw_zadd ($#0,z) = z"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   411
by (auto simp add: int_def int_of_def raw_zadd)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   412
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   413
lemma zadd_int0_intify [simp]: "$#0 $+ z = intify(z)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   414
by (simp add: zadd_def raw_zadd_int0)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   415
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   416
lemma zadd_int0: "z: int ==> $#0 $+ z = z"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   417
by simp
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   418
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   419
lemma raw_zminus_zadd_distrib: 
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   420
     "[| z: int;  w: int |] ==> $- raw_zadd(z,w) = raw_zadd($- z, $- w)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   421
by (auto simp add: zminus raw_zadd int_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   422
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   423
lemma zminus_zadd_distrib [simp]: "$- (z $+ w) = $- z $+ $- w"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   424
by (simp add: zadd_def raw_zminus_zadd_distrib)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   425
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   426
lemma raw_zadd_commute:
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   427
     "[| z: int;  w: int |] ==> raw_zadd(z,w) = raw_zadd(w,z)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   428
by (auto simp add: raw_zadd add_ac int_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   429
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   430
lemma zadd_commute: "z $+ w = w $+ z"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   431
by (simp add: zadd_def raw_zadd_commute)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   432
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   433
lemma raw_zadd_assoc: 
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   434
    "[| z1: int;  z2: int;  z3: int |]    
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   435
     ==> raw_zadd (raw_zadd(z1,z2),z3) = raw_zadd(z1,raw_zadd(z2,z3))"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   436
by (auto simp add: int_def raw_zadd add_assoc)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   437
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   438
lemma zadd_assoc: "(z1 $+ z2) $+ z3 = z1 $+ (z2 $+ z3)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   439
by (simp add: zadd_def raw_zadd_type raw_zadd_assoc)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   440
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   441
(*For AC rewriting*)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   442
lemma zadd_left_commute: "z1$+(z2$+z3) = z2$+(z1$+z3)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   443
apply (simp add: zadd_assoc [symmetric])
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   444
apply (simp add: zadd_commute)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   445
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   446
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   447
(*Integer addition is an AC operator*)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   448
lemmas zadd_ac = zadd_assoc zadd_commute zadd_left_commute
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   449
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   450
lemma int_of_add: "$# (m #+ n) = ($#m) $+ ($#n)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   451
by (simp add: int_of_def zadd)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   452
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   453
lemma int_succ_int_1: "$# succ(m) = $# 1 $+ ($# m)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   454
by (simp add: int_of_add [symmetric] natify_succ)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   455
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   456
lemma int_of_diff: 
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   457
     "[| m\<in>nat;  n le m |] ==> $# (m #- n) = ($#m) $- ($#n)"
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   458
apply (simp add: int_of_def zdiff_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   459
apply (frule lt_nat_in_nat)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   460
apply (simp_all add: zadd zminus add_diff_inverse2)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   461
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   462
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   463
lemma raw_zadd_zminus_inverse: "z : int ==> raw_zadd (z, $- z) = $#0"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   464
by (auto simp add: int_def int_of_def zminus raw_zadd add_commute)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   465
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   466
lemma zadd_zminus_inverse [simp]: "z $+ ($- z) = $#0"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   467
apply (simp add: zadd_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   468
apply (subst zminus_intify [symmetric])
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   469
apply (rule intify_in_int [THEN raw_zadd_zminus_inverse])
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   470
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   471
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   472
lemma zadd_zminus_inverse2 [simp]: "($- z) $+ z = $#0"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   473
by (simp add: zadd_commute zadd_zminus_inverse)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   474
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   475
lemma zadd_int0_right_intify [simp]: "z $+ $#0 = intify(z)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   476
by (rule trans [OF zadd_commute zadd_int0_intify])
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   477
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   478
lemma zadd_int0_right: "z:int ==> z $+ $#0 = z"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   479
by simp
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   480
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   481
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   482
subsection{*@{term zmult}: Integer Multiplication*}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   483
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   484
text{*Congruence property for multiplication*}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   485
lemma zmult_congruent2:
15182
5cea84e10f3e new "respects" syntax for the congruent operator
paulson
parents: 14565
diff changeset
   486
    "(%p1 p2. split(%x1 y1. split(%x2 y2.      
5cea84e10f3e new "respects" syntax for the congruent operator
paulson
parents: 14565
diff changeset
   487
                    intrel``{<x1#*x2 #+ y1#*y2, x1#*y2 #+ y1#*x2>}, p2), p1))
5cea84e10f3e new "respects" syntax for the congruent operator
paulson
parents: 14565
diff changeset
   488
     respects2 intrel"
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   489
apply (rule equiv_intrel [THEN congruent2_commuteI], auto)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   490
(*Proof that zmult is congruent in one argument*)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   491
apply (rename_tac x y)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   492
apply (frule_tac t = "%u. x#*u" in sym [THEN subst_context])
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   493
apply (drule_tac t = "%u. y#*u" in subst_context)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   494
apply (erule add_left_cancel)+
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   495
apply (simp_all add: add_mult_distrib_left)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   496
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   497
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   498
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   499
lemma raw_zmult_type: "[| z: int;  w: int |] ==> raw_zmult(z,w) : int"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   500
apply (simp add: int_def raw_zmult_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   501
apply (rule UN_equiv_class_type2 [OF equiv_intrel zmult_congruent2], assumption+)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   502
apply (simp add: Let_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   503
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   504
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   505
lemma zmult_type [iff,TC]: "z $* w : int"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   506
by (simp add: zmult_def raw_zmult_type)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   507
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   508
lemma raw_zmult: 
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   509
     "[| x1\<in>nat; y1\<in>nat;  x2\<in>nat; y2\<in>nat |]     
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   510
      ==> raw_zmult(intrel``{<x1,y1>}, intrel``{<x2,y2>}) =      
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   511
          intrel `` {<x1#*x2 #+ y1#*y2, x1#*y2 #+ y1#*x2>}"
15182
5cea84e10f3e new "respects" syntax for the congruent operator
paulson
parents: 14565
diff changeset
   512
by (simp add: raw_zmult_def 
5cea84e10f3e new "respects" syntax for the congruent operator
paulson
parents: 14565
diff changeset
   513
           UN_equiv_class2 [OF equiv_intrel equiv_intrel zmult_congruent2])
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   514
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   515
lemma zmult: 
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   516
     "[| x1\<in>nat; y1\<in>nat;  x2\<in>nat; y2\<in>nat |]     
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   517
      ==> (intrel``{<x1,y1>}) $* (intrel``{<x2,y2>}) =      
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   518
          intrel `` {<x1#*x2 #+ y1#*y2, x1#*y2 #+ y1#*x2>}"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   519
by (simp add: zmult_def raw_zmult image_intrel_int)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   520
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   521
lemma raw_zmult_int0: "z : int ==> raw_zmult ($#0,z) = $#0"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   522
by (auto simp add: int_def int_of_def raw_zmult)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   523
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   524
lemma zmult_int0 [simp]: "$#0 $* z = $#0"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   525
by (simp add: zmult_def raw_zmult_int0)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   526
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   527
lemma raw_zmult_int1: "z : int ==> raw_zmult ($#1,z) = z"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   528
by (auto simp add: int_def int_of_def raw_zmult)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   529
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   530
lemma zmult_int1_intify [simp]: "$#1 $* z = intify(z)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   531
by (simp add: zmult_def raw_zmult_int1)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   532
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   533
lemma zmult_int1: "z : int ==> $#1 $* z = z"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   534
by simp
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   535
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   536
lemma raw_zmult_commute:
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   537
     "[| z: int;  w: int |] ==> raw_zmult(z,w) = raw_zmult(w,z)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   538
by (auto simp add: int_def raw_zmult add_ac mult_ac)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   539
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   540
lemma zmult_commute: "z $* w = w $* z"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   541
by (simp add: zmult_def raw_zmult_commute)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   542
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   543
lemma raw_zmult_zminus: 
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   544
     "[| z: int;  w: int |] ==> raw_zmult($- z, w) = $- raw_zmult(z, w)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   545
by (auto simp add: int_def zminus raw_zmult add_ac)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   546
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   547
lemma zmult_zminus [simp]: "($- z) $* w = $- (z $* w)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   548
apply (simp add: zmult_def raw_zmult_zminus)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   549
apply (subst zminus_intify [symmetric], rule raw_zmult_zminus, auto)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   550
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   551
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   552
lemma zmult_zminus_right [simp]: "w $* ($- z) = $- (w $* z)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   553
by (simp add: zmult_commute [of w])
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   554
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   555
lemma raw_zmult_assoc: 
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   556
    "[| z1: int;  z2: int;  z3: int |]    
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   557
     ==> raw_zmult (raw_zmult(z1,z2),z3) = raw_zmult(z1,raw_zmult(z2,z3))"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   558
by (auto simp add: int_def raw_zmult add_mult_distrib_left add_ac mult_ac)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   559
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   560
lemma zmult_assoc: "(z1 $* z2) $* z3 = z1 $* (z2 $* z3)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   561
by (simp add: zmult_def raw_zmult_type raw_zmult_assoc)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   562
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   563
(*For AC rewriting*)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   564
lemma zmult_left_commute: "z1$*(z2$*z3) = z2$*(z1$*z3)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   565
apply (simp add: zmult_assoc [symmetric])
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   566
apply (simp add: zmult_commute)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   567
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   568
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   569
(*Integer multiplication is an AC operator*)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   570
lemmas zmult_ac = zmult_assoc zmult_commute zmult_left_commute
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   571
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   572
lemma raw_zadd_zmult_distrib: 
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   573
    "[| z1: int;  z2: int;  w: int |]   
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   574
     ==> raw_zmult(raw_zadd(z1,z2), w) =  
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   575
         raw_zadd (raw_zmult(z1,w), raw_zmult(z2,w))"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   576
by (auto simp add: int_def raw_zadd raw_zmult add_mult_distrib_left add_ac mult_ac)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   577
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   578
lemma zadd_zmult_distrib: "(z1 $+ z2) $* w = (z1 $* w) $+ (z2 $* w)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   579
by (simp add: zmult_def zadd_def raw_zadd_type raw_zmult_type 
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   580
              raw_zadd_zmult_distrib)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   581
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   582
lemma zadd_zmult_distrib2: "w $* (z1 $+ z2) = (w $* z1) $+ (w $* z2)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   583
by (simp add: zmult_commute [of w] zadd_zmult_distrib)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   584
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   585
lemmas int_typechecks = 
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   586
  int_of_type zminus_type zmagnitude_type zadd_type zmult_type
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   587
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   588
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   589
(*** Subtraction laws ***)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   590
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   591
lemma zdiff_type [iff,TC]: "z $- w : int"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   592
by (simp add: zdiff_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   593
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   594
lemma zminus_zdiff_eq [simp]: "$- (z $- y) = y $- z"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   595
by (simp add: zdiff_def zadd_commute)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   596
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   597
lemma zdiff_zmult_distrib: "(z1 $- z2) $* w = (z1 $* w) $- (z2 $* w)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   598
apply (simp add: zdiff_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   599
apply (subst zadd_zmult_distrib)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   600
apply (simp add: zmult_zminus)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   601
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   602
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   603
lemma zdiff_zmult_distrib2: "w $* (z1 $- z2) = (w $* z1) $- (w $* z2)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   604
by (simp add: zmult_commute [of w] zdiff_zmult_distrib)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   605
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   606
lemma zadd_zdiff_eq: "x $+ (y $- z) = (x $+ y) $- z"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   607
by (simp add: zdiff_def zadd_ac)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   608
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   609
lemma zdiff_zadd_eq: "(x $- y) $+ z = (x $+ z) $- y"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   610
by (simp add: zdiff_def zadd_ac)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   611
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   612
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   613
subsection{*The "Less Than" Relation*}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   614
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   615
(*"Less than" is a linear ordering*)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   616
lemma zless_linear_lemma: 
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   617
     "[| z: int; w: int |] ==> z$<w | z=w | w$<z"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   618
apply (simp add: int_def zless_def znegative_def zdiff_def, auto)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   619
apply (simp add: zadd zminus image_iff Bex_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   620
apply (rule_tac i = "xb#+ya" and j = "xc #+ y" in Ord_linear_lt)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   621
apply (force dest!: spec simp add: add_ac)+
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   622
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   623
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   624
lemma zless_linear: "z$<w | intify(z)=intify(w) | w$<z"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   625
apply (cut_tac z = " intify (z) " and w = " intify (w) " in zless_linear_lemma)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   626
apply auto
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   627
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   628
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   629
lemma zless_not_refl [iff]: "~ (z$<z)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   630
by (auto simp add: zless_def znegative_def int_of_def zdiff_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   631
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   632
lemma neq_iff_zless: "[| x: int; y: int |] ==> (x ~= y) <-> (x $< y | y $< x)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   633
by (cut_tac z = x and w = y in zless_linear, auto)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   634
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   635
lemma zless_imp_intify_neq: "w $< z ==> intify(w) ~= intify(z)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   636
apply auto
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   637
apply (subgoal_tac "~ (intify (w) $< intify (z))")
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   638
apply (erule_tac [2] ssubst)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   639
apply (simp (no_asm_use))
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   640
apply auto
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   641
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   642
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   643
(*This lemma allows direct proofs of other <-properties*)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   644
lemma zless_imp_succ_zadd_lemma: 
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   645
    "[| w $< z; w: int; z: int |] ==> (\<exists>n\<in>nat. z = w $+ $#(succ(n)))"
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   646
apply (simp add: zless_def znegative_def zdiff_def int_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   647
apply (auto dest!: less_imp_succ_add simp add: zadd zminus int_of_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   648
apply (rule_tac x = k in bexI)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   649
apply (erule add_left_cancel, auto)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   650
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   651
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   652
lemma zless_imp_succ_zadd:
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   653
     "w $< z ==> (\<exists>n\<in>nat. w $+ $#(succ(n)) = intify(z))"
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   654
apply (subgoal_tac "intify (w) $< intify (z) ")
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   655
apply (drule_tac w = "intify (w) " in zless_imp_succ_zadd_lemma)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   656
apply auto
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   657
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   658
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   659
lemma zless_succ_zadd_lemma: 
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   660
    "w : int ==> w $< w $+ $# succ(n)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   661
apply (simp add: zless_def znegative_def zdiff_def int_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   662
apply (auto simp add: zadd zminus int_of_def image_iff)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   663
apply (rule_tac x = 0 in exI, auto)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   664
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   665
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   666
lemma zless_succ_zadd: "w $< w $+ $# succ(n)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   667
by (cut_tac intify_in_int [THEN zless_succ_zadd_lemma], auto)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   668
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   669
lemma zless_iff_succ_zadd:
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   670
     "w $< z <-> (\<exists>n\<in>nat. w $+ $#(succ(n)) = intify(z))"
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   671
apply (rule iffI)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   672
apply (erule zless_imp_succ_zadd, auto)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   673
apply (rename_tac "n")
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   674
apply (cut_tac w = w and n = n in zless_succ_zadd, auto)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   675
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   676
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   677
lemma zless_int_of [simp]: "[| m\<in>nat; n\<in>nat |] ==> ($#m $< $#n) <-> (m<n)"
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   678
apply (simp add: less_iff_succ_add zless_iff_succ_zadd int_of_add [symmetric])
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   679
apply (blast intro: sym)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   680
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   681
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   682
lemma zless_trans_lemma: 
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   683
    "[| x $< y; y $< z; x: int; y : int; z: int |] ==> x $< z"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   684
apply (simp add: zless_def znegative_def zdiff_def int_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   685
apply (auto simp add: zadd zminus image_iff)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   686
apply (rename_tac x1 x2 y1 y2)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   687
apply (rule_tac x = "x1#+x2" in exI)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   688
apply (rule_tac x = "y1#+y2" in exI)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   689
apply (auto simp add: add_lt_mono)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   690
apply (rule sym)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   691
apply (erule add_left_cancel)+
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   692
apply auto
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   693
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   694
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   695
lemma zless_trans: "[| x $< y; y $< z |] ==> x $< z"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   696
apply (subgoal_tac "intify (x) $< intify (z) ")
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   697
apply (rule_tac [2] y = "intify (y) " in zless_trans_lemma)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   698
apply auto
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   699
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   700
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   701
lemma zless_not_sym: "z $< w ==> ~ (w $< z)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   702
by (blast dest: zless_trans)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   703
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   704
(* [| z $< w; ~ P ==> w $< z |] ==> P *)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   705
lemmas zless_asym = zless_not_sym [THEN swap, standard]
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   706
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   707
lemma zless_imp_zle: "z $< w ==> z $<= w"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   708
by (simp add: zle_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   709
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   710
lemma zle_linear: "z $<= w | w $<= z"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   711
apply (simp add: zle_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   712
apply (cut_tac zless_linear, blast)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   713
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   714
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   715
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   716
subsection{*Less Than or Equals*}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   717
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   718
lemma zle_refl: "z $<= z"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   719
by (simp add: zle_def)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   720
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   721
lemma zle_eq_refl: "x=y ==> x $<= y"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   722
by (simp add: zle_refl)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   723
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   724
lemma zle_anti_sym_intify: "[| x $<= y; y $<= x |] ==> intify(x) = intify(y)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   725
apply (simp add: zle_def, auto)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   726
apply (blast dest: zless_trans)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   727
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   728
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   729
lemma zle_anti_sym: "[| x $<= y; y $<= x; x: int; y: int |] ==> x=y"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   730
by (drule zle_anti_sym_intify, auto)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   731
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   732
lemma zle_trans_lemma:
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   733
     "[| x: int; y: int; z: int; x $<= y; y $<= z |] ==> x $<= z"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   734
apply (simp add: zle_def, auto)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   735
apply (blast intro: zless_trans)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   736
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   737
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   738
lemma zle_trans: "[| x $<= y; y $<= z |] ==> x $<= z"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   739
apply (subgoal_tac "intify (x) $<= intify (z) ")
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   740
apply (rule_tac [2] y = "intify (y) " in zle_trans_lemma)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   741
apply auto
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   742
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   743
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   744
lemma zle_zless_trans: "[| i $<= j; j $< k |] ==> i $< k"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   745
apply (auto simp add: zle_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   746
apply (blast intro: zless_trans)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   747
apply (simp add: zless_def zdiff_def zadd_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   748
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   749
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   750
lemma zless_zle_trans: "[| i $< j; j $<= k |] ==> i $< k"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   751
apply (auto simp add: zle_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   752
apply (blast intro: zless_trans)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   753
apply (simp add: zless_def zdiff_def zminus_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   754
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   755
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   756
lemma not_zless_iff_zle: "~ (z $< w) <-> (w $<= z)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   757
apply (cut_tac z = z and w = w in zless_linear)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   758
apply (auto dest: zless_trans simp add: zle_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   759
apply (auto dest!: zless_imp_intify_neq)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   760
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   761
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   762
lemma not_zle_iff_zless: "~ (z $<= w) <-> (w $< z)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   763
by (simp add: not_zless_iff_zle [THEN iff_sym])
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   764
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   765
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   766
subsection{*More subtraction laws (for @{text zcompare_rls})*}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   767
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   768
lemma zdiff_zdiff_eq: "(x $- y) $- z = x $- (y $+ z)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   769
by (simp add: zdiff_def zadd_ac)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   770
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   771
lemma zdiff_zdiff_eq2: "x $- (y $- z) = (x $+ z) $- y"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   772
by (simp add: zdiff_def zadd_ac)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   773
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   774
lemma zdiff_zless_iff: "(x$-y $< z) <-> (x $< z $+ y)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   775
by (simp add: zless_def zdiff_def zadd_ac)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   776
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   777
lemma zless_zdiff_iff: "(x $< z$-y) <-> (x $+ y $< z)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   778
by (simp add: zless_def zdiff_def zadd_ac)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   779
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   780
lemma zdiff_eq_iff: "[| x: int; z: int |] ==> (x$-y = z) <-> (x = z $+ y)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   781
by (auto simp add: zdiff_def zadd_assoc)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   782
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   783
lemma eq_zdiff_iff: "[| x: int; z: int |] ==> (x = z$-y) <-> (x $+ y = z)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   784
by (auto simp add: zdiff_def zadd_assoc)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   785
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   786
lemma zdiff_zle_iff_lemma:
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   787
     "[| x: int; z: int |] ==> (x$-y $<= z) <-> (x $<= z $+ y)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   788
by (auto simp add: zle_def zdiff_eq_iff zdiff_zless_iff)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   789
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   790
lemma zdiff_zle_iff: "(x$-y $<= z) <-> (x $<= z $+ y)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   791
by (cut_tac zdiff_zle_iff_lemma [OF intify_in_int intify_in_int], simp)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   792
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   793
lemma zle_zdiff_iff_lemma:
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   794
     "[| x: int; z: int |] ==>(x $<= z$-y) <-> (x $+ y $<= z)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   795
apply (auto simp add: zle_def zdiff_eq_iff zless_zdiff_iff)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   796
apply (auto simp add: zdiff_def zadd_assoc)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   797
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   798
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   799
lemma zle_zdiff_iff: "(x $<= z$-y) <-> (x $+ y $<= z)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   800
by (cut_tac zle_zdiff_iff_lemma [ OF intify_in_int intify_in_int], simp)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   801
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   802
text{*This list of rewrites simplifies (in)equalities by bringing subtractions
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   803
  to the top and then moving negative terms to the other side.  
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   804
  Use with @{text zadd_ac}*}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   805
lemmas zcompare_rls =
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   806
     zdiff_def [symmetric]
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   807
     zadd_zdiff_eq zdiff_zadd_eq zdiff_zdiff_eq zdiff_zdiff_eq2 
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   808
     zdiff_zless_iff zless_zdiff_iff zdiff_zle_iff zle_zdiff_iff 
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   809
     zdiff_eq_iff eq_zdiff_iff
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   810
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   811
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   812
subsection{*Monotonicity and Cancellation Results for Instantiation
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   813
     of the CancelNumerals Simprocs*}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   814
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   815
lemma zadd_left_cancel:
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   816
     "[| w: int; w': int |] ==> (z $+ w' = z $+ w) <-> (w' = w)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   817
apply safe
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   818
apply (drule_tac t = "%x. x $+ ($-z) " in subst_context)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   819
apply (simp add: zadd_ac)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   820
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   821
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   822
lemma zadd_left_cancel_intify [simp]:
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   823
     "(z $+ w' = z $+ w) <-> intify(w') = intify(w)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   824
apply (rule iff_trans)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   825
apply (rule_tac [2] zadd_left_cancel, auto)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   826
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   827
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   828
lemma zadd_right_cancel:
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   829
     "[| w: int; w': int |] ==> (w' $+ z = w $+ z) <-> (w' = w)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   830
apply safe
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   831
apply (drule_tac t = "%x. x $+ ($-z) " in subst_context)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   832
apply (simp add: zadd_ac)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   833
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   834
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   835
lemma zadd_right_cancel_intify [simp]:
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   836
     "(w' $+ z = w $+ z) <-> intify(w') = intify(w)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   837
apply (rule iff_trans)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   838
apply (rule_tac [2] zadd_right_cancel, auto)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   839
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   840
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   841
lemma zadd_right_cancel_zless [simp]: "(w' $+ z $< w $+ z) <-> (w' $< w)"
14511
73493236e97f updated treatment of znegative and nat_of
paulson
parents: 13612
diff changeset
   842
by (simp add: zdiff_zless_iff [THEN iff_sym] zdiff_def zadd_assoc)
13560
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   843
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   844
lemma zadd_left_cancel_zless [simp]: "(z $+ w' $< z $+ w) <-> (w' $< w)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   845
by (simp add: zadd_commute [of z] zadd_right_cancel_zless)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   846
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   847
lemma zadd_right_cancel_zle [simp]: "(w' $+ z $<= w $+ z) <-> w' $<= w"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   848
by (simp add: zle_def)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   849
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   850
lemma zadd_left_cancel_zle [simp]: "(z $+ w' $<= z $+ w) <->  w' $<= w"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   851
by (simp add: zadd_commute [of z]  zadd_right_cancel_zle)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   852
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   853
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   854
(*"v $<= w ==> v$+z $<= w$+z"*)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   855
lemmas zadd_zless_mono1 = zadd_right_cancel_zless [THEN iffD2, standard]
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   856
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   857
(*"v $<= w ==> z$+v $<= z$+w"*)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   858
lemmas zadd_zless_mono2 = zadd_left_cancel_zless [THEN iffD2, standard]
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   859
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   860
(*"v $<= w ==> v$+z $<= w$+z"*)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   861
lemmas zadd_zle_mono1 = zadd_right_cancel_zle [THEN iffD2, standard]
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   862
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   863
(*"v $<= w ==> z$+v $<= z$+w"*)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   864
lemmas zadd_zle_mono2 = zadd_left_cancel_zle [THEN iffD2, standard]
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   865
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   866
lemma zadd_zle_mono: "[| w' $<= w; z' $<= z |] ==> w' $+ z' $<= w $+ z"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   867
by (erule zadd_zle_mono1 [THEN zle_trans], simp)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   868
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   869
lemma zadd_zless_mono: "[| w' $< w; z' $<= z |] ==> w' $+ z' $< w $+ z"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   870
by (erule zadd_zless_mono1 [THEN zless_zle_trans], simp)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   871
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   872
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   873
subsection{*Comparison laws*}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   874
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   875
lemma zminus_zless_zminus [simp]: "($- x $< $- y) <-> (y $< x)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   876
by (simp add: zless_def zdiff_def zadd_ac)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   877
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   878
lemma zminus_zle_zminus [simp]: "($- x $<= $- y) <-> (y $<= x)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   879
by (simp add: not_zless_iff_zle [THEN iff_sym])
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   880
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   881
subsubsection{*More inequality lemmas*}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   882
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   883
lemma equation_zminus: "[| x: int;  y: int |] ==> (x = $- y) <-> (y = $- x)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   884
by auto
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   885
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   886
lemma zminus_equation: "[| x: int;  y: int |] ==> ($- x = y) <-> ($- y = x)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   887
by auto
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   888
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   889
lemma equation_zminus_intify: "(intify(x) = $- y) <-> (intify(y) = $- x)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   890
apply (cut_tac x = "intify (x) " and y = "intify (y) " in equation_zminus)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   891
apply auto
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   892
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   893
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   894
lemma zminus_equation_intify: "($- x = intify(y)) <-> ($- y = intify(x))"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   895
apply (cut_tac x = "intify (x) " and y = "intify (y) " in zminus_equation)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   896
apply auto
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   897
done
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   898
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   899
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   900
subsubsection{*The next several equations are permutative: watch out!*}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   901
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   902
lemma zless_zminus: "(x $< $- y) <-> (y $< $- x)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   903
by (simp add: zless_def zdiff_def zadd_ac)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   904
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   905
lemma zminus_zless: "($- x $< y) <-> ($- y $< x)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   906
by (simp add: zless_def zdiff_def zadd_ac)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   907
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   908
lemma zle_zminus: "(x $<= $- y) <-> (y $<= $- x)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   909
by (simp add: not_zless_iff_zle [THEN iff_sym] zminus_zless)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   910
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   911
lemma zminus_zle: "($- x $<= y) <-> ($- y $<= x)"
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   912
by (simp add: not_zless_iff_zle [THEN iff_sym] zless_zminus)
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   913
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   914
ML
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   915
{*
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   916
val zdiff_def = thm "zdiff_def";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   917
val int_of_type = thm "int_of_type";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   918
val int_of_eq = thm "int_of_eq";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   919
val int_of_inject = thm "int_of_inject";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   920
val intify_in_int = thm "intify_in_int";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   921
val intify_ident = thm "intify_ident";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   922
val intify_idem = thm "intify_idem";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   923
val int_of_natify = thm "int_of_natify";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   924
val zminus_intify = thm "zminus_intify";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   925
val zadd_intify1 = thm "zadd_intify1";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   926
val zadd_intify2 = thm "zadd_intify2";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   927
val zdiff_intify1 = thm "zdiff_intify1";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   928
val zdiff_intify2 = thm "zdiff_intify2";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   929
val zmult_intify1 = thm "zmult_intify1";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   930
val zmult_intify2 = thm "zmult_intify2";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   931
val zless_intify1 = thm "zless_intify1";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   932
val zless_intify2 = thm "zless_intify2";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   933
val zle_intify1 = thm "zle_intify1";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   934
val zle_intify2 = thm "zle_intify2";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   935
val zminus_congruent = thm "zminus_congruent";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   936
val zminus_type = thm "zminus_type";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   937
val zminus_inject_intify = thm "zminus_inject_intify";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   938
val zminus_inject = thm "zminus_inject";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   939
val zminus = thm "zminus";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   940
val zminus_zminus_intify = thm "zminus_zminus_intify";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   941
val zminus_int0 = thm "zminus_int0";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   942
val zminus_zminus = thm "zminus_zminus";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   943
val not_znegative_int_of = thm "not_znegative_int_of";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   944
val znegative_zminus_int_of = thm "znegative_zminus_int_of";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   945
val not_znegative_imp_zero = thm "not_znegative_imp_zero";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   946
val nat_of_intify = thm "nat_of_intify";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   947
val nat_of_int_of = thm "nat_of_int_of";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   948
val nat_of_type = thm "nat_of_type";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   949
val zmagnitude_int_of = thm "zmagnitude_int_of";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   950
val natify_int_of_eq = thm "natify_int_of_eq";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   951
val zmagnitude_zminus_int_of = thm "zmagnitude_zminus_int_of";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   952
val zmagnitude_type = thm "zmagnitude_type";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   953
val not_zneg_int_of = thm "not_zneg_int_of";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   954
val not_zneg_mag = thm "not_zneg_mag";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   955
val zneg_int_of = thm "zneg_int_of";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   956
val zneg_mag = thm "zneg_mag";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   957
val int_cases = thm "int_cases";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   958
val not_zneg_nat_of_intify = thm "not_zneg_nat_of_intify";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   959
val not_zneg_nat_of = thm "not_zneg_nat_of";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   960
val zneg_nat_of = thm "zneg_nat_of";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   961
val zadd_congruent2 = thm "zadd_congruent2";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   962
val zadd_type = thm "zadd_type";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   963
val zadd = thm "zadd";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   964
val zadd_int0_intify = thm "zadd_int0_intify";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   965
val zadd_int0 = thm "zadd_int0";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   966
val zminus_zadd_distrib = thm "zminus_zadd_distrib";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   967
val zadd_commute = thm "zadd_commute";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   968
val zadd_assoc = thm "zadd_assoc";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   969
val zadd_left_commute = thm "zadd_left_commute";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   970
val zadd_ac = thms "zadd_ac";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   971
val int_of_add = thm "int_of_add";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   972
val int_succ_int_1 = thm "int_succ_int_1";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   973
val int_of_diff = thm "int_of_diff";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   974
val zadd_zminus_inverse = thm "zadd_zminus_inverse";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   975
val zadd_zminus_inverse2 = thm "zadd_zminus_inverse2";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   976
val zadd_int0_right_intify = thm "zadd_int0_right_intify";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   977
val zadd_int0_right = thm "zadd_int0_right";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   978
val zmult_congruent2 = thm "zmult_congruent2";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   979
val zmult_type = thm "zmult_type";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   980
val zmult = thm "zmult";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   981
val zmult_int0 = thm "zmult_int0";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   982
val zmult_int1_intify = thm "zmult_int1_intify";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   983
val zmult_int1 = thm "zmult_int1";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   984
val zmult_commute = thm "zmult_commute";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   985
val zmult_zminus = thm "zmult_zminus";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   986
val zmult_zminus_right = thm "zmult_zminus_right";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   987
val zmult_assoc = thm "zmult_assoc";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   988
val zmult_left_commute = thm "zmult_left_commute";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   989
val zmult_ac = thms "zmult_ac";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   990
val zadd_zmult_distrib = thm "zadd_zmult_distrib";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   991
val zadd_zmult_distrib2 = thm "zadd_zmult_distrib2";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   992
val int_typechecks = thms "int_typechecks";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   993
val zdiff_type = thm "zdiff_type";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   994
val zminus_zdiff_eq = thm "zminus_zdiff_eq";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   995
val zdiff_zmult_distrib = thm "zdiff_zmult_distrib";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   996
val zdiff_zmult_distrib2 = thm "zdiff_zmult_distrib2";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   997
val zadd_zdiff_eq = thm "zadd_zdiff_eq";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   998
val zdiff_zadd_eq = thm "zdiff_zadd_eq";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
   999
val zless_linear = thm "zless_linear";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1000
val zless_not_refl = thm "zless_not_refl";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1001
val neq_iff_zless = thm "neq_iff_zless";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1002
val zless_imp_intify_neq = thm "zless_imp_intify_neq";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1003
val zless_imp_succ_zadd = thm "zless_imp_succ_zadd";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1004
val zless_succ_zadd = thm "zless_succ_zadd";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1005
val zless_iff_succ_zadd = thm "zless_iff_succ_zadd";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1006
val zless_int_of = thm "zless_int_of";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1007
val zless_trans = thm "zless_trans";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1008
val zless_not_sym = thm "zless_not_sym";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1009
val zless_asym = thm "zless_asym";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1010
val zless_imp_zle = thm "zless_imp_zle";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1011
val zle_linear = thm "zle_linear";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1012
val zle_refl = thm "zle_refl";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1013
val zle_eq_refl = thm "zle_eq_refl";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1014
val zle_anti_sym_intify = thm "zle_anti_sym_intify";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1015
val zle_anti_sym = thm "zle_anti_sym";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1016
val zle_trans = thm "zle_trans";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1017
val zle_zless_trans = thm "zle_zless_trans";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1018
val zless_zle_trans = thm "zless_zle_trans";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1019
val not_zless_iff_zle = thm "not_zless_iff_zle";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1020
val not_zle_iff_zless = thm "not_zle_iff_zless";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1021
val zdiff_zdiff_eq = thm "zdiff_zdiff_eq";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1022
val zdiff_zdiff_eq2 = thm "zdiff_zdiff_eq2";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1023
val zdiff_zless_iff = thm "zdiff_zless_iff";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1024
val zless_zdiff_iff = thm "zless_zdiff_iff";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1025
val zdiff_eq_iff = thm "zdiff_eq_iff";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1026
val eq_zdiff_iff = thm "eq_zdiff_iff";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1027
val zdiff_zle_iff = thm "zdiff_zle_iff";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1028
val zle_zdiff_iff = thm "zle_zdiff_iff";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1029
val zcompare_rls = thms "zcompare_rls";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1030
val zadd_left_cancel = thm "zadd_left_cancel";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1031
val zadd_left_cancel_intify = thm "zadd_left_cancel_intify";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1032
val zadd_right_cancel = thm "zadd_right_cancel";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1033
val zadd_right_cancel_intify = thm "zadd_right_cancel_intify";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1034
val zadd_right_cancel_zless = thm "zadd_right_cancel_zless";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1035
val zadd_left_cancel_zless = thm "zadd_left_cancel_zless";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1036
val zadd_right_cancel_zle = thm "zadd_right_cancel_zle";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1037
val zadd_left_cancel_zle = thm "zadd_left_cancel_zle";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1038
val zadd_zless_mono1 = thm "zadd_zless_mono1";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1039
val zadd_zless_mono2 = thm "zadd_zless_mono2";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1040
val zadd_zle_mono1 = thm "zadd_zle_mono1";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1041
val zadd_zle_mono2 = thm "zadd_zle_mono2";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1042
val zadd_zle_mono = thm "zadd_zle_mono";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1043
val zadd_zless_mono = thm "zadd_zless_mono";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1044
val zminus_zless_zminus = thm "zminus_zless_zminus";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1045
val zminus_zle_zminus = thm "zminus_zle_zminus";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1046
val equation_zminus = thm "equation_zminus";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1047
val zminus_equation = thm "zminus_equation";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1048
val equation_zminus_intify = thm "equation_zminus_intify";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1049
val zminus_equation_intify = thm "zminus_equation_intify";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1050
val zless_zminus = thm "zless_zminus";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1051
val zminus_zless = thm "zminus_zless";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1052
val zle_zminus = thm "zle_zminus";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1053
val zminus_zle = thm "zminus_zle";
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1054
*}
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1055
d9651081578b conversion of ZF/Integ/{Int,Bin} to Isar scripts
paulson
parents: 12114
diff changeset
  1056
9496
07e33cac5d9c coercion "intify" to remove type constraints from integer algebraic laws
paulson
parents: 9333
diff changeset
  1057
end