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