src/HOL/Real/PRat.ML
author paulson
Wed, 23 Sep 1998 10:03:32 +0200
changeset 5535 678999604ee9
parent 5459 1dbaf888f4e7
child 7077 60b098bb8b8a
permissions -rw-r--r--
deleted needless parentheses
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
     1
(*  Title       : PRat.ML
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
     2
    Author      : Jacques D. Fleuriot
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
     3
    Copyright   : 1998  University of Cambridge
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
     4
    Description : The positive rationals
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
     5
*) 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
     6
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
     7
open PRat;
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
     8
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
     9
Delrules [equalityI];
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    10
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    11
(*** Many theorems similar to those in Integ.thy ***)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    12
(*** Proving that ratrel is an equivalence relation ***)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    13
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    14
Goal
5148
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
    15
    "[| (x1::pnat) * y2 = x2 * y1; x2 * y3 = x3 * y2 |] \
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    16
\            ==> x1 * y3 = x3 * y1";        
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    17
by (res_inst_tac [("k1","y2")] (pnat_mult_cancel1 RS iffD1) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    18
by (auto_tac (claset(), simpset() addsimps [pnat_mult_assoc RS sym]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    19
by (auto_tac (claset(),simpset() addsimps [pnat_mult_commute]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    20
by (dres_inst_tac [("s","x2 * y3")] sym 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    21
by (asm_simp_tac (simpset() addsimps [pnat_mult_left_commute,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    22
    pnat_mult_commute]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    23
qed "prat_trans_lemma";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    24
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    25
(** Natural deduction for ratrel **)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    26
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    27
Goalw [ratrel_def]
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    28
    "(((x1,y1),(x2,y2)): ratrel) = (x1 * y2 = x2 * y1)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    29
by (Fast_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    30
qed "ratrel_iff";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    31
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    32
Goalw [ratrel_def]
5148
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
    33
    "[| x1 * y2 = x2 * y1 |] ==> ((x1,y1),(x2,y2)): ratrel";
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    34
by (Fast_tac  1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    35
qed "ratrelI";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    36
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    37
Goalw [ratrel_def]
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    38
  "p: ratrel --> (EX x1 y1 x2 y2. \
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    39
\                  p = ((x1,y1),(x2,y2)) & x1 *y2 = x2 *y1)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    40
by (Fast_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    41
qed "ratrelE_lemma";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    42
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    43
val [major,minor] = goal thy
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    44
  "[| p: ratrel;  \
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    45
\     !!x1 y1 x2 y2. [| p = ((x1,y1),(x2,y2));  x1*y2 = x2*y1 \
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    46
\                    |] ==> Q |] ==> Q";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    47
by (cut_facts_tac [major RS (ratrelE_lemma RS mp)] 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    48
by (REPEAT (eresolve_tac [asm_rl,exE,conjE,minor] 1));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    49
qed "ratrelE";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    50
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    51
AddSIs [ratrelI];
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    52
AddSEs [ratrelE];
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    53
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    54
Goal "(x,x): ratrel";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    55
by (stac surjective_pairing 1 THEN rtac (refl RS ratrelI) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    56
qed "ratrel_refl";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    57
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    58
Goalw [equiv_def, refl_def, sym_def, trans_def]
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    59
    "equiv {x::(pnat*pnat).True} ratrel";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    60
by (fast_tac (claset() addSIs [ratrel_refl] 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    61
                      addSEs [sym, prat_trans_lemma]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    62
qed "equiv_ratrel";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    63
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    64
val equiv_ratrel_iff =
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    65
    [TrueI, TrueI] MRS 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    66
    ([CollectI, CollectI] MRS 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    67
    (equiv_ratrel RS eq_equiv_class_iff));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    68
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    69
Goalw  [prat_def,ratrel_def,quotient_def] "ratrel^^{(x,y)}:prat";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    70
by (Blast_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    71
qed "ratrel_in_prat";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    72
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    73
Goal "inj_on Abs_prat prat";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    74
by (rtac inj_on_inverseI 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    75
by (etac Abs_prat_inverse 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    76
qed "inj_on_Abs_prat";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    77
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    78
Addsimps [equiv_ratrel_iff,inj_on_Abs_prat RS inj_on_iff,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    79
          ratrel_iff, ratrel_in_prat, Abs_prat_inverse];
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    80
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    81
Addsimps [equiv_ratrel RS eq_equiv_class_iff];
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    82
val eq_ratrelD = equiv_ratrel RSN (2,eq_equiv_class);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    83
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    84
Goal "inj(Rep_prat)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    85
by (rtac inj_inverseI 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    86
by (rtac Rep_prat_inverse 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    87
qed "inj_Rep_prat";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    88
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    89
(** prat_pnat: the injection from pnat to prat **)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    90
Goal "inj(prat_pnat)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    91
by (rtac injI 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    92
by (rewtac prat_pnat_def);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    93
by (dtac (inj_on_Abs_prat RS inj_onD) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    94
by (REPEAT (rtac ratrel_in_prat 1));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    95
by (dtac eq_equiv_class 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    96
by (rtac equiv_ratrel 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    97
by (Fast_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    98
by Safe_tac;
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
    99
by (Asm_full_simp_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   100
qed "inj_prat_pnat";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   101
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   102
(* lcp's original eq_Abs_Integ *)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   103
val [prem] = goal thy
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   104
    "(!!x y. z = Abs_prat(ratrel^^{(x,y)}) ==> P) ==> P";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   105
by (res_inst_tac [("x1","z")] 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   106
    (rewrite_rule [prat_def] Rep_prat RS quotientE) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   107
by (dres_inst_tac [("f","Abs_prat")] arg_cong 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   108
by (res_inst_tac [("p","x")] PairE 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   109
by (rtac prem 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   110
by (asm_full_simp_tac (simpset() addsimps [Rep_prat_inverse]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   111
qed "eq_Abs_prat";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   112
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   113
(**** qinv: inverse on prat ****)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   114
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   115
Goalw [congruent_def]
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   116
  "congruent ratrel (%p. split (%x y. ratrel^^{(y,x)}) p)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   117
by Safe_tac;
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   118
by (asm_full_simp_tac (simpset() addsimps [pnat_mult_commute]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   119
qed "qinv_congruent";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   120
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   121
(*Resolve th against the corresponding facts for qinv*)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   122
val qinv_ize = RSLIST [equiv_ratrel, qinv_congruent];
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   123
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   124
Goalw [qinv_def]
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   125
      "qinv (Abs_prat(ratrel^^{(x,y)})) = Abs_prat(ratrel ^^ {(y,x)})";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   126
by (res_inst_tac [("f","Abs_prat")] arg_cong 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   127
by (simp_tac (simpset() addsimps 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   128
   [ratrel_in_prat RS Abs_prat_inverse,qinv_ize UN_equiv_class]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   129
qed "qinv";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   130
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   131
Goal "qinv (qinv z) = z";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   132
by (res_inst_tac [("z","z")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   133
by (asm_simp_tac (simpset() addsimps [qinv]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   134
qed "qinv_qinv";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   135
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   136
Goal "inj(qinv)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   137
by (rtac injI 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   138
by (dres_inst_tac [("f","qinv")] arg_cong 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   139
by (asm_full_simp_tac (simpset() addsimps [qinv_qinv]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   140
qed "inj_qinv";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   141
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   142
Goalw [prat_pnat_def] "qinv($# (Abs_pnat 1)) = $#(Abs_pnat 1)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   143
by (simp_tac (simpset() addsimps [qinv]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   144
qed "qinv_1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   145
5148
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
   146
Goal "!!(x1::pnat). [| x1 * y2 = x2 * y1 |] ==> \
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   147
\     (x * y1 + x1 * ya) * (ya * y2) = (x * y2 + x2 * ya) * (ya * y1)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   148
by (auto_tac (claset() addSIs [pnat_same_multI2],
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   149
       simpset() addsimps [pnat_add_mult_distrib,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   150
       pnat_mult_assoc]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   151
by (res_inst_tac [("n1","y2")] (pnat_mult_commute RS subst) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   152
by (auto_tac (claset() addIs [pnat_add_left_cancel RS iffD2],simpset() addsimps pnat_mult_ac));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   153
by (res_inst_tac [("y1","x1")] (pnat_mult_left_commute RS subst) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   154
by (res_inst_tac [("y1","x1")] (pnat_mult_left_commute RS ssubst) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   155
by (auto_tac (claset(),simpset() addsimps [pnat_mult_assoc RS sym]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   156
qed "prat_add_congruent2_lemma";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   157
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   158
Goal 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   159
    "congruent2 ratrel (%p1 p2.                  \
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   160
\         split (%x1 y1. split (%x2 y2. ratrel^^{(x1*y2 + x2*y1, y1*y2)}) p2) p1)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   161
by (rtac (equiv_ratrel RS congruent2_commuteI) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   162
by Safe_tac;
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   163
by (rewtac split_def);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   164
by (asm_simp_tac (simpset() addsimps [pnat_mult_commute,pnat_add_commute]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   165
by (auto_tac (claset(),simpset() addsimps [prat_add_congruent2_lemma]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   166
qed "prat_add_congruent2";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   167
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   168
(*Resolve th against the corresponding facts for prat_add*)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   169
val prat_add_ize = RSLIST [equiv_ratrel, prat_add_congruent2];
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   170
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   171
Goalw [prat_add_def]
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   172
   "Abs_prat((ratrel^^{(x1,y1)})) + Abs_prat((ratrel^^{(x2,y2)})) =   \
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   173
\   Abs_prat(ratrel ^^ {(x1*y2 + x2*y1, y1*y2)})";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   174
by (simp_tac (simpset() addsimps [prat_add_ize UN_equiv_class2]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   175
qed "prat_add";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   176
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   177
Goal "(z::prat) + w = w + z";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   178
by (res_inst_tac [("z","z")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   179
by (res_inst_tac [("z","w")] eq_Abs_prat 1);
5535
678999604ee9 deleted needless parentheses
paulson
parents: 5459
diff changeset
   180
by (asm_simp_tac
678999604ee9 deleted needless parentheses
paulson
parents: 5459
diff changeset
   181
    (simpset() addsimps [prat_add] @ pnat_add_ac @ pnat_mult_ac) 1);
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   182
qed "prat_add_commute";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   183
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   184
Goal "((z1::prat) + z2) + z3 = z1 + (z2 + z3)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   185
by (res_inst_tac [("z","z1")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   186
by (res_inst_tac [("z","z2")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   187
by (res_inst_tac [("z","z3")] eq_Abs_prat 1);
5535
678999604ee9 deleted needless parentheses
paulson
parents: 5459
diff changeset
   188
by (asm_simp_tac (simpset() addsimps [pnat_add_mult_distrib2,prat_add] @ 
678999604ee9 deleted needless parentheses
paulson
parents: 5459
diff changeset
   189
                                     pnat_add_ac @ pnat_mult_ac) 1);
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   190
qed "prat_add_assoc";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   191
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   192
qed_goal "prat_add_left_commute" thy
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   193
    "(z1::prat) + (z2 + z3) = z2 + (z1 + z3)"
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   194
 (fn _ => [rtac (prat_add_commute RS trans) 1, rtac (prat_add_assoc RS trans) 1,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   195
           rtac (prat_add_commute RS arg_cong) 1]);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   196
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   197
(* Positive Rational addition is an AC operator *)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   198
val prat_add_ac = [prat_add_assoc, prat_add_commute, prat_add_left_commute];
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   199
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   200
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   201
(*** Congruence property for multiplication ***)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   202
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   203
Goalw [congruent2_def]
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   204
    "congruent2 ratrel (%p1 p2.                  \
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   205
\         split (%x1 y1. split (%x2 y2. ratrel^^{(x1*x2, y1*y2)}) p2) p1)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   206
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   207
(*Proof via congruent2_commuteI seems longer*)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   208
by Safe_tac;
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   209
by (asm_simp_tac (simpset() addsimps [pnat_mult_assoc]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   210
(*The rest should be trivial, but rearranging terms is hard*)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   211
by (res_inst_tac [("x1","x1a")] (pnat_mult_left_commute RS ssubst) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   212
by (asm_simp_tac (simpset() addsimps [pnat_mult_assoc RS sym]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   213
by (asm_simp_tac (simpset() addsimps pnat_mult_ac) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   214
qed "pnat_mult_congruent2";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   215
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   216
(*Resolve th against the corresponding facts for pnat_mult*)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   217
val prat_mult_ize = RSLIST [equiv_ratrel, pnat_mult_congruent2];
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   218
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   219
Goalw [prat_mult_def]
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   220
  "Abs_prat(ratrel^^{(x1,y1)}) * Abs_prat(ratrel^^{(x2,y2)}) = \
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   221
\  Abs_prat(ratrel^^{(x1*x2, y1*y2)})";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   222
by (asm_simp_tac
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   223
    (simpset() addsimps [prat_mult_ize UN_equiv_class2]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   224
qed "prat_mult";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   225
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   226
Goal "(z::prat) * w = w * z";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   227
by (res_inst_tac [("z","z")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   228
by (res_inst_tac [("z","w")] eq_Abs_prat 1);
5535
678999604ee9 deleted needless parentheses
paulson
parents: 5459
diff changeset
   229
by (asm_simp_tac (simpset() addsimps pnat_mult_ac @ [prat_mult]) 1);
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   230
qed "prat_mult_commute";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   231
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   232
Goal "((z1::prat) * z2) * z3 = z1 * (z2 * z3)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   233
by (res_inst_tac [("z","z1")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   234
by (res_inst_tac [("z","z2")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   235
by (res_inst_tac [("z","z3")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   236
by (asm_simp_tac (simpset() addsimps [prat_mult, pnat_mult_assoc]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   237
qed "prat_mult_assoc";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   238
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   239
(*For AC rewriting*)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   240
Goal "(x::prat)*(y*z)=y*(x*z)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   241
by (rtac (prat_mult_commute RS trans) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   242
by (rtac (prat_mult_assoc RS trans) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   243
by (rtac (prat_mult_commute RS arg_cong) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   244
qed "prat_mult_left_commute";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   245
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   246
(*Positive Rational multiplication is an AC operator*)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   247
val prat_mult_ac = [prat_mult_assoc,prat_mult_commute,prat_mult_left_commute];
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   248
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   249
Goalw [prat_pnat_def] "($#Abs_pnat 1) * z = z";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   250
by (res_inst_tac [("z","z")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   251
by (asm_full_simp_tac (simpset() addsimps [prat_mult] @ pnat_mult_ac) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   252
qed "prat_mult_1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   253
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   254
Goalw [prat_pnat_def] "z * ($#Abs_pnat 1) = z";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   255
by (res_inst_tac [("z","z")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   256
by (asm_full_simp_tac (simpset() addsimps [prat_mult] @ pnat_mult_ac) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   257
qed "prat_mult_1_right";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   258
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   259
Goalw [prat_pnat_def] 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   260
            "$#((z1::pnat) + z2) = $#z1 + $#z2";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   261
by (asm_simp_tac (simpset() addsimps [prat_add,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   262
       pnat_add_mult_distrib,pnat_mult_1]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   263
qed "prat_pnat_add";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   264
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   265
Goalw [prat_pnat_def] 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   266
            "$#((z1::pnat) * z2) = $#z1 * $#z2";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   267
by (asm_simp_tac (simpset() addsimps [prat_mult,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   268
                              pnat_mult_1]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   269
qed "prat_pnat_mult";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   270
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   271
(*** prat_mult and qinv ***)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   272
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   273
Goalw [prat_def,prat_pnat_def] "qinv (q) * q = $# (Abs_pnat 1)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   274
by (res_inst_tac [("z","q")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   275
by (asm_full_simp_tac (simpset() addsimps [qinv,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   276
        prat_mult,pnat_mult_1,pnat_mult_1_left,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   277
                        pnat_mult_commute]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   278
qed "prat_mult_qinv";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   279
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   280
Goal "q * qinv (q) = $# (Abs_pnat 1)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   281
by (rtac (prat_mult_commute RS subst) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   282
by (simp_tac (simpset() addsimps [prat_mult_qinv]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   283
qed "prat_mult_qinv_right";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   284
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   285
Goal "? y. (x::prat) * y = $# Abs_pnat 1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   286
by (fast_tac (claset() addIs [prat_mult_qinv_right]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   287
qed "prat_qinv_ex";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   288
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   289
Goal "?! y. (x::prat) * y = $# Abs_pnat 1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   290
by (auto_tac (claset() addIs [prat_mult_qinv_right],simpset()));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   291
by (dres_inst_tac [("f","%x. ya*x")] arg_cong 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   292
by (asm_full_simp_tac (simpset() addsimps [prat_mult_assoc RS sym]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   293
by (asm_full_simp_tac (simpset() addsimps [prat_mult_commute,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   294
    prat_mult_1,prat_mult_1_right]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   295
qed "prat_qinv_ex1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   296
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   297
Goal "?! y. y * (x::prat) = $# Abs_pnat 1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   298
by (auto_tac (claset() addIs [prat_mult_qinv],simpset()));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   299
by (dres_inst_tac [("f","%x. x*ya")] arg_cong 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   300
by (asm_full_simp_tac (simpset() addsimps [prat_mult_assoc]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   301
by (asm_full_simp_tac (simpset() addsimps [prat_mult_commute,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   302
    prat_mult_1,prat_mult_1_right]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   303
qed "prat_qinv_left_ex1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   304
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5078
diff changeset
   305
Goal "x * y = $# Abs_pnat 1 ==> x = qinv y";
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   306
by (cut_inst_tac [("q","y")] prat_mult_qinv 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   307
by (res_inst_tac [("x1","y")] (prat_qinv_left_ex1 RS ex1E) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   308
by (Blast_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   309
qed "prat_mult_inv_qinv";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   310
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   311
Goal "? y. x = qinv y";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   312
by (cut_inst_tac [("x","x")] prat_qinv_ex 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   313
by (etac exE 1 THEN dtac prat_mult_inv_qinv 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   314
by (Fast_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   315
qed "prat_as_inverse_ex";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   316
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   317
Goal "qinv(x*y) = qinv(x)*qinv(y)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   318
by (res_inst_tac [("z","x")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   319
by (res_inst_tac [("z","y")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   320
by (auto_tac (claset(),simpset() addsimps [qinv,prat_mult]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   321
qed "qinv_mult_eq";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   322
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   323
(** Lemmas **)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   324
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   325
qed_goal "prat_add_assoc_cong" thy
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   326
    "!!z. (z::prat) + v = z' + v' ==> z + (v + w) = z' + (v' + w)"
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   327
 (fn _ => [(asm_simp_tac (simpset() addsimps [prat_add_assoc RS sym]) 1)]);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   328
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   329
qed_goal "prat_add_assoc_swap" thy "(z::prat) + (v + w) = v + (z + w)"
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   330
 (fn _ => [(REPEAT (ares_tac [prat_add_commute RS prat_add_assoc_cong] 1))]);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   331
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   332
Goal "((z1::prat) + z2) * w = (z1 * w) + (z2 * w)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   333
by (res_inst_tac [("z","z1")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   334
by (res_inst_tac [("z","z2")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   335
by (res_inst_tac [("z","w")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   336
by (asm_simp_tac 
5535
678999604ee9 deleted needless parentheses
paulson
parents: 5459
diff changeset
   337
    (simpset() addsimps [pnat_add_mult_distrib2, prat_add, prat_mult] @ 
678999604ee9 deleted needless parentheses
paulson
parents: 5459
diff changeset
   338
                        pnat_add_ac @ pnat_mult_ac) 1);
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   339
qed "prat_add_mult_distrib";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   340
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   341
val prat_mult_commute'= read_instantiate [("z","w")] prat_mult_commute;
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   342
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   343
Goal "(w::prat) * (z1 + z2) = (w * z1) + (w * z2)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   344
by (simp_tac (simpset() addsimps [prat_mult_commute',prat_add_mult_distrib]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   345
qed "prat_add_mult_distrib2";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   346
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   347
val prat_mult_simps = [prat_mult_1, prat_mult_1_right, 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   348
                       prat_mult_qinv, prat_mult_qinv_right];
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   349
Addsimps prat_mult_simps;
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   350
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   351
      (*** theorems for ordering ***)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   352
(* prove introduction and elimination rules for prat_less *)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   353
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   354
Goalw [prat_less_def]
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   355
    "Q1 < (Q2::prat) = (EX Q3. Q1 + Q3 = Q2)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   356
by (Fast_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   357
qed "prat_less_iff";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   358
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   359
Goalw [prat_less_def]
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   360
      "!!(Q1::prat). Q1 + Q3 = Q2 ==> Q1 < Q2";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   361
by (Fast_tac  1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   362
qed "prat_lessI";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   363
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   364
(* ordering on positive fractions in terms of existence of sum *)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   365
Goalw [prat_less_def]
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   366
      "Q1 < (Q2::prat) --> (EX Q3. Q1 + Q3 = Q2)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   367
by (Fast_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   368
qed "prat_lessE_lemma";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   369
5148
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
   370
Goal "!!P. [| Q1 < (Q2::prat); \
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
   371
\             !! (Q3::prat). Q1 + Q3 = Q2 ==> P |] \
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
   372
\          ==> P";
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   373
by (dtac (prat_lessE_lemma RS mp) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   374
by Auto_tac;
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   375
qed "prat_lessE";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   376
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   377
(* qless is a strong order i.e nonreflexive and transitive *)
5148
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
   378
Goal "!!(q1::prat). [| q1 < q2; q2 < q3 |] ==> q1 < q3";
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   379
by (REPEAT(dtac (prat_lessE_lemma RS mp) 1));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   380
by (REPEAT(etac exE 1));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   381
by (hyp_subst_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   382
by (res_inst_tac [("Q3.0","Q3 + Q3a")] prat_lessI 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   383
by (auto_tac (claset(),simpset() addsimps [prat_add_assoc]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   384
qed "prat_less_trans";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   385
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   386
Goal "~q < (q::prat)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   387
by (EVERY1[rtac notI, dtac (prat_lessE_lemma RS mp)]);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   388
by (res_inst_tac [("z","q")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   389
by (res_inst_tac [("z","Q3")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   390
by (etac exE 1 THEN res_inst_tac [("z","Q3a")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   391
by (REPEAT(hyp_subst_tac 1));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   392
by (asm_full_simp_tac (simpset() addsimps [prat_add,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   393
    pnat_no_add_ident,pnat_add_mult_distrib2] @ pnat_mult_ac) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   394
qed "prat_less_not_refl";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   395
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   396
(*** y < y ==> P ***)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   397
bind_thm("prat_less_irrefl",prat_less_not_refl RS notE);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   398
5459
1dbaf888f4e7 well-formed asym rules; misc. tidying
paulson
parents: 5148
diff changeset
   399
Goal "!! (q1::prat). q1 < q2 ==> ~ q2 < q1";
1dbaf888f4e7 well-formed asym rules; misc. tidying
paulson
parents: 5148
diff changeset
   400
by (rtac notI 1);
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   401
by (dtac prat_less_trans 1 THEN assume_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   402
by (asm_full_simp_tac (simpset() addsimps [prat_less_not_refl]) 1);
5459
1dbaf888f4e7 well-formed asym rules; misc. tidying
paulson
parents: 5148
diff changeset
   403
qed "prat_less_not_sym";
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   404
5459
1dbaf888f4e7 well-formed asym rules; misc. tidying
paulson
parents: 5148
diff changeset
   405
(* [| x < y;  ~P ==> y < x |] ==> P *)
1dbaf888f4e7 well-formed asym rules; misc. tidying
paulson
parents: 5148
diff changeset
   406
bind_thm ("prat_less_asym", prat_less_not_sym RS swap);
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   407
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   408
(* half of positive fraction exists- Gleason p. 120- Proposition 9-2.6(i)*)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   409
Goal "!(q::prat). ? x. x + x = q";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   410
by (rtac allI 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   411
by (res_inst_tac [("z","q")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   412
by (res_inst_tac [("x","Abs_prat (ratrel ^^ {(x, y+y)})")] exI 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   413
by (auto_tac (claset(),simpset() addsimps 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   414
              [prat_add,pnat_mult_assoc RS sym,pnat_add_mult_distrib,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   415
               pnat_add_mult_distrib2]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   416
qed "lemma_prat_dense";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   417
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   418
Goal "? (x::prat). x + x = q";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   419
by (res_inst_tac [("z","q")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   420
by (res_inst_tac [("x","Abs_prat (ratrel ^^ {(x, y+y)})")] exI 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   421
by (auto_tac (claset(),simpset() addsimps 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   422
              [prat_add,pnat_mult_assoc RS sym,pnat_add_mult_distrib,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   423
               pnat_add_mult_distrib2]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   424
qed "prat_lemma_dense";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   425
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   426
(* there exists a number between any two positive fractions *)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   427
(* Gleason p. 120- Proposition 9-2.6(iv) *)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   428
Goalw [prat_less_def] 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   429
      "!! (q1::prat). q1 < q2 ==> ? x. q1 < x & x < q2";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   430
by (auto_tac (claset() addIs [lemma_prat_dense],simpset()));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   431
by (res_inst_tac [("x","T")] (lemma_prat_dense RS allE) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   432
by (etac exE 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   433
by (res_inst_tac [("x","q1 + x")] exI 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   434
by (auto_tac (claset() addIs [prat_lemma_dense],
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   435
    simpset() addsimps [prat_add_assoc]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   436
qed "prat_dense";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   437
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   438
(* ordering of addition for positive fractions *)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   439
Goalw [prat_less_def] 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   440
      "!!(q1::prat). q1 < q2 ==> q1 + x < q2 + x";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   441
by (Step_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   442
by (res_inst_tac [("x","T")] exI 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   443
by (auto_tac (claset(),simpset() addsimps prat_add_ac));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   444
qed "prat_add_less2_mono1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   445
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   446
Goal  
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   447
      "!!(q1::prat). q1 < q2 ==> x + q1 < x + q2";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   448
by (auto_tac (claset() addIs [prat_add_less2_mono1],
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   449
    simpset() addsimps [prat_add_commute]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   450
qed "prat_add_less2_mono2";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   451
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   452
(* ordering of multiplication for positive fractions *)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   453
Goalw [prat_less_def] 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   454
      "!!(q1::prat). q1 < q2 ==> q1 * x < q2 * x";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   455
by (Step_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   456
by (res_inst_tac [("x","T*x")] exI 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   457
by (auto_tac (claset(),simpset() addsimps [prat_add_mult_distrib]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   458
qed "prat_mult_less2_mono1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   459
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   460
Goal "!!(q1::prat). q1 < q2  ==> x * q1 < x * q2";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   461
by (auto_tac (claset() addDs [prat_mult_less2_mono1],
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   462
    simpset() addsimps [prat_mult_commute]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   463
qed "prat_mult_left_less2_mono1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   464
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   465
(* there is no smallest positive fraction *)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   466
Goalw [prat_less_def] "? (x::prat). x < y";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   467
by (cut_facts_tac [lemma_prat_dense] 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   468
by (Fast_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   469
qed "qless_Ex";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   470
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   471
(* lemma for proving $< is linear *)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   472
Goalw [prat_def,prat_less_def] 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   473
      "ratrel ^^ {(x, y * ya)} : {p::(pnat*pnat).True}/ratrel";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   474
by (asm_full_simp_tac (simpset() addsimps [ratrel_def,quotient_def]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   475
by (Blast_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   476
qed "lemma_prat_less_linear";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   477
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   478
(* linearity of < -- Gleason p. 120 - Proposition 9-2.6 *)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   479
(*** FIXME Proof long ***)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   480
Goalw [prat_less_def] 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   481
      "(q1::prat) < q2 | q1 = q2 | q2 < q1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   482
by (res_inst_tac [("z","q1")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   483
by (res_inst_tac [("z","q2")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   484
by (Step_tac 1 THEN REPEAT(dtac (not_ex RS iffD1) 1) 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   485
               THEN Auto_tac);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   486
by (cut_inst_tac  [("z1.0","x*ya"),
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   487
   ("z2.0","xa*y")] pnat_linear_Ex_eq 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   488
by (EVERY1[etac disjE,etac exE]);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   489
by (eres_inst_tac 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   490
    [("x","Abs_prat(ratrel^^{(xb,ya*y)})")] allE 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   491
by (asm_full_simp_tac 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   492
    (simpset() addsimps [prat_add, pnat_mult_assoc 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   493
     RS sym,pnat_add_mult_distrib RS sym]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   494
by (EVERY1[asm_full_simp_tac (simpset() addsimps pnat_mult_ac),
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   495
    etac disjE, assume_tac, etac exE]);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   496
by (thin_tac "!T. Abs_prat (ratrel ^^ {(x, y)}) + T ~= \
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   497
\     Abs_prat (ratrel ^^ {(xa, ya)})" 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   498
by (eres_inst_tac [("x","Abs_prat(ratrel^^{(xb,y*ya)})")] allE 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   499
by (asm_full_simp_tac (simpset() addsimps [prat_add,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   500
      pnat_mult_assoc RS sym,pnat_add_mult_distrib RS sym]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   501
by (asm_full_simp_tac (simpset() addsimps pnat_mult_ac) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   502
qed "prat_linear";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   503
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   504
Goal
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   505
    "!!(q1::prat). [| q1 < q2 ==> P;  q1 = q2 ==> P; \
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   506
\          q2 < q1 ==> P |] ==> P";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   507
by (cut_inst_tac [("q1.0","q1"),("q2.0","q2")] prat_linear 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   508
by Auto_tac;
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   509
qed "prat_linear_less2";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   510
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   511
(* Gleason p. 120 -- 9-2.6 (iv) *)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   512
Goal 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   513
 "!!(q1::prat). [| q1 < q2; qinv(q1) = qinv(q2) |] ==> P";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   514
by (cut_inst_tac [("x","qinv (q2)"),("q1.0","q1"),
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   515
   ("q2.0","q2")] prat_mult_less2_mono1 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   516
by (assume_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   517
by (Asm_full_simp_tac 1 THEN dtac sym 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   518
by (auto_tac (claset(),simpset() addsimps [prat_less_not_refl]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   519
qed "lemma1_qinv_prat_less";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   520
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   521
Goal 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   522
 "!!(q1::prat). [| q1 < q2; qinv(q1) < qinv(q2) |] ==> P";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   523
by (cut_inst_tac [("x","qinv (q2)"),("q1.0","q1"),
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   524
   ("q2.0","q2")] prat_mult_less2_mono1 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   525
by (assume_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   526
by (cut_inst_tac [("x","q1"),("q1.0","qinv (q1)"),
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   527
   ("q2.0","qinv (q2)")] prat_mult_left_less2_mono1 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   528
by Auto_tac;
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   529
by (dres_inst_tac [("q2.0","$#Abs_pnat 1")] prat_less_trans 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   530
by (auto_tac (claset(),simpset() addsimps [prat_less_not_refl]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   531
qed "lemma2_qinv_prat_less";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   532
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   533
Goal 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   534
      "!!(q1::prat). q1 < q2  ==> qinv (q2) < qinv (q1)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   535
by (res_inst_tac [("q2.0","qinv q1"),
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   536
         ("q1.0","qinv q2")] prat_linear_less2 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   537
by (auto_tac (claset() addEs [lemma1_qinv_prat_less,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   538
                 lemma2_qinv_prat_less],simpset()));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   539
qed "qinv_prat_less";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   540
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   541
Goal "!!(q1::prat). q1 < $#Abs_pnat 1 ==> $#Abs_pnat 1 < qinv(q1)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   542
by (dtac qinv_prat_less 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   543
by (full_simp_tac (simpset() addsimps [qinv_1]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   544
qed "prat_qinv_gt_1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   545
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   546
Goalw [pnat_one_def] "!!(q1::prat). q1 < $#1p ==> $#1p < qinv(q1)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   547
by (etac prat_qinv_gt_1 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   548
qed "prat_qinv_is_gt_1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   549
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   550
Goalw [prat_less_def] "$#Abs_pnat 1 < $#Abs_pnat 1 + $#Abs_pnat 1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   551
by (Fast_tac 1); 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   552
qed "prat_less_1_2";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   553
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   554
Goal "qinv($#Abs_pnat 1 + $#Abs_pnat 1) < $#Abs_pnat 1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   555
by (cut_facts_tac [prat_less_1_2 RS qinv_prat_less] 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   556
by (asm_full_simp_tac (simpset() addsimps [qinv_1]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   557
qed "prat_less_qinv_2_1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   558
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   559
Goal "!!(x::prat). x < y ==> x*qinv(y) < $#Abs_pnat 1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   560
by (dres_inst_tac [("x","qinv(y)")] prat_mult_less2_mono1 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   561
by (Asm_full_simp_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   562
qed "prat_mult_qinv_less_1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   563
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   564
Goal "(x::prat) < x + x";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   565
by (cut_inst_tac [("x","x")] 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   566
    (prat_less_1_2 RS prat_mult_left_less2_mono1) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   567
by (asm_full_simp_tac (simpset() addsimps 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   568
    [prat_add_mult_distrib2]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   569
qed "prat_self_less_add_self";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   570
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   571
Goalw [prat_less_def] "(x::prat) < y + x";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   572
by (res_inst_tac [("x","y")] exI 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   573
by (simp_tac (simpset() addsimps [prat_add_commute]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   574
qed "prat_self_less_add_right";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   575
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   576
Goal "(x::prat) < x + y";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   577
by (rtac (prat_add_commute RS subst) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   578
by (simp_tac (simpset() addsimps [prat_self_less_add_right]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   579
qed "prat_self_less_add_left";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   580
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5078
diff changeset
   581
Goalw [prat_less_def] "$#1p < y ==> (x::prat) < x * y";
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   582
by (auto_tac (claset(),simpset() addsimps [pnat_one_def,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   583
    prat_add_mult_distrib2]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   584
qed "prat_self_less_mult_right";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   585
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   586
(*** Properties of <= ***)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   587
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5078
diff changeset
   588
Goalw [prat_le_def] "~(w < z) ==> z <= (w::prat)";
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   589
by (assume_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   590
qed "prat_leI";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   591
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5078
diff changeset
   592
Goalw [prat_le_def] "z<=w ==> ~(w<(z::prat))";
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   593
by (assume_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   594
qed "prat_leD";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   595
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   596
val prat_leE = make_elim prat_leD;
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   597
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5078
diff changeset
   598
Goal "(~(w < z)) = (z <= (w::prat))";
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   599
by (fast_tac (claset() addSIs [prat_leI,prat_leD]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   600
qed "prat_less_le_iff";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   601
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5078
diff changeset
   602
Goalw [prat_le_def] "~ z <= w ==> w<(z::prat)";
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   603
by (Fast_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   604
qed "not_prat_leE";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   605
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5078
diff changeset
   606
Goalw [prat_le_def] "z < w ==> z <= (w::prat)";
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   607
by (fast_tac (claset() addEs [prat_less_asym]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   608
qed "prat_less_imp_le";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   609
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   610
Goalw [prat_le_def] "!!(x::prat). x <= y ==> x < y | x = y";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   611
by (cut_facts_tac [prat_linear] 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   612
by (fast_tac (claset() addEs [prat_less_irrefl,prat_less_asym]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   613
qed "prat_le_imp_less_or_eq";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   614
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5078
diff changeset
   615
Goalw [prat_le_def] "z<w | z=w ==> z <=(w::prat)";
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   616
by (cut_facts_tac [prat_linear] 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   617
by (fast_tac (claset() addEs [prat_less_irrefl,prat_less_asym]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   618
qed "prat_less_or_eq_imp_le";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   619
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   620
Goal "(x <= (y::prat)) = (x < y | x=y)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   621
by (REPEAT(ares_tac [iffI, prat_less_or_eq_imp_le, prat_le_imp_less_or_eq] 1));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   622
qed "prat_le_eq_less_or_eq";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   623
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   624
Goal "w <= (w::prat)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   625
by (simp_tac (simpset() addsimps [prat_le_eq_less_or_eq]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   626
qed "prat_le_refl";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   627
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   628
val prems = goal thy "!!i. [| i <= j; j < k |] ==> i < (k::prat)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   629
by (dtac prat_le_imp_less_or_eq 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   630
by (fast_tac (claset() addIs [prat_less_trans]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   631
qed "prat_le_less_trans";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   632
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   633
Goal "!! (i::prat). [| i < j; j <= k |] ==> i < k";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   634
by (dtac prat_le_imp_less_or_eq 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   635
by (fast_tac (claset() addIs [prat_less_trans]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   636
qed "prat_less_le_trans";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   637
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5078
diff changeset
   638
Goal "[| i <= j; j <= k |] ==> i <= (k::prat)";
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   639
by (EVERY1 [dtac prat_le_imp_less_or_eq, dtac prat_le_imp_less_or_eq,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   640
            rtac prat_less_or_eq_imp_le, fast_tac (claset() addIs [prat_less_trans])]);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   641
qed "prat_le_trans";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   642
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5078
diff changeset
   643
Goal "[| z <= w; w <= z |] ==> z = (w::prat)";
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   644
by (EVERY1 [dtac prat_le_imp_less_or_eq, dtac prat_le_imp_less_or_eq,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   645
            fast_tac (claset() addEs [prat_less_irrefl,prat_less_asym])]);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   646
qed "prat_le_anti_sym";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   647
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5078
diff changeset
   648
Goal "[| ~ y < x; y ~= x |] ==> x < (y::prat)";
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   649
by (rtac not_prat_leE 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   650
by (fast_tac (claset() addDs [prat_le_imp_less_or_eq]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   651
qed "not_less_not_eq_prat_less";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   652
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   653
Goalw [prat_less_def] 
5148
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
   654
      "[| x1 < y1; x2 < y2 |] ==> x1 + x2 < y1 + (y2::prat)";
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   655
by (REPEAT(etac exE 1));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   656
by (res_inst_tac [("x","T+Ta")] exI 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   657
by (auto_tac (claset(),simpset() addsimps prat_add_ac));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   658
qed "prat_add_less_mono";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   659
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   660
Goalw [prat_less_def] 
5148
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
   661
      "[| x1 < y1; x2 < y2 |] ==> x1 * x2 < y1 * (y2::prat)";
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   662
by (REPEAT(etac exE 1));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   663
by (res_inst_tac [("x","T*Ta+T*x2+x1*Ta")] exI 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   664
by (auto_tac (claset(),simpset() addsimps prat_add_ac @ 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   665
    [prat_add_mult_distrib,prat_add_mult_distrib2]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   666
qed "prat_mult_less_mono";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   667
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   668
(* more prat_le *)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   669
Goal "!!(q1::prat). q1 <= q2  ==> x * q1 <= x * q2";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   670
by (dtac prat_le_imp_less_or_eq 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   671
by (Step_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   672
by (auto_tac (claset() addSIs [prat_le_refl,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   673
    prat_less_imp_le,prat_mult_left_less2_mono1],simpset()));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   674
qed "prat_mult_left_le2_mono1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   675
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   676
Goal "!!(q1::prat). q1 <= q2  ==> q1 * x <= q2 * x";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   677
by (auto_tac (claset() addDs [prat_mult_left_le2_mono1],
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   678
    simpset() addsimps [prat_mult_commute]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   679
qed "prat_mult_le2_mono1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   680
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   681
Goal 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   682
      "!!(q1::prat). q1 <= q2  ==> qinv (q2) <= qinv (q1)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   683
by (dtac prat_le_imp_less_or_eq 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   684
by (Step_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   685
by (auto_tac (claset() addSIs [prat_le_refl,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   686
    prat_less_imp_le,qinv_prat_less],simpset()));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   687
qed "qinv_prat_le";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   688
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   689
Goal "!!(q1::prat). q1 <= q2  ==> x + q1 <= x + q2";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   690
by (dtac prat_le_imp_less_or_eq 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   691
by (Step_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   692
by (auto_tac (claset() addSIs [prat_le_refl,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   693
    prat_less_imp_le,prat_add_less2_mono1],
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   694
    simpset() addsimps [prat_add_commute]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   695
qed "prat_add_left_le2_mono1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   696
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   697
Goal "!!(q1::prat). q1 <= q2  ==> q1 + x <= q2 + x";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   698
by (auto_tac (claset() addDs [prat_add_left_le2_mono1],
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   699
    simpset() addsimps [prat_add_commute]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   700
qed "prat_add_le2_mono1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   701
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   702
Goal "!!k l::prat. [|i<=j;  k<=l |] ==> i + k <= j + l";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   703
by (etac (prat_add_le2_mono1 RS prat_le_trans) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   704
by (simp_tac (simpset() addsimps [prat_add_commute]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   705
(*j moves to the end because it is free while k, l are bound*)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   706
by (etac prat_add_le2_mono1 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   707
qed "prat_add_le_mono";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   708
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   709
Goal "!!(x::prat). x + y < z + y ==> x < z";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   710
by (rtac ccontr 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   711
by (etac (prat_leI RS prat_le_imp_less_or_eq RS disjE) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   712
by (dres_inst_tac [("x","y"),("q1.0","z")] prat_add_less2_mono1 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   713
by (auto_tac (claset() addIs [prat_less_asym],
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   714
    simpset() addsimps [prat_less_not_refl]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   715
qed "prat_add_right_less_cancel";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   716
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   717
Goal "!!(x::prat). y + x < y + z ==> x < z";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   718
by (res_inst_tac [("y","y")] prat_add_right_less_cancel 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   719
by (asm_full_simp_tac (simpset() addsimps [prat_add_commute]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   720
qed "prat_add_left_less_cancel";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   721
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   722
(*** lemmas required for lemma_gleason9_34 in PReal : w*y > y/z ***)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   723
Goalw [prat_pnat_def] "Abs_prat(ratrel^^{(x,y)}) = $#x*qinv($#y)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   724
by (auto_tac (claset(),simpset() addsimps [prat_mult,qinv,pnat_mult_1_left,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   725
    pnat_mult_1]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   726
qed "Abs_prat_mult_qinv";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   727
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   728
Goal "Abs_prat(ratrel^^{(x,y)}) <= Abs_prat(ratrel^^{(x,Abs_pnat 1)})";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   729
by (simp_tac (simpset() addsimps [Abs_prat_mult_qinv]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   730
by (rtac prat_mult_left_le2_mono1 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   731
by (rtac qinv_prat_le 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   732
by (pnat_ind_tac "y" 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   733
by (dres_inst_tac [("x","$#Abs_pnat 1")] prat_add_le2_mono1 2);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   734
by (cut_facts_tac [prat_less_1_2 RS prat_less_imp_le] 2);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   735
by (auto_tac (claset() addIs [prat_le_trans],
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   736
    simpset() addsimps [prat_le_refl,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   737
    pSuc_is_plus_one,pnat_one_def,prat_pnat_add]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   738
qed "lemma_Abs_prat_le1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   739
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   740
Goal "Abs_prat(ratrel^^{(x,Abs_pnat 1)}) <= Abs_prat(ratrel^^{(x*y,Abs_pnat 1)})";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   741
by (simp_tac (simpset() addsimps [Abs_prat_mult_qinv]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   742
by (rtac prat_mult_le2_mono1 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   743
by (pnat_ind_tac "y" 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   744
by (dres_inst_tac [("x","$#x")] prat_add_le2_mono1 2);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   745
by (cut_inst_tac [("z","$#x")] (prat_self_less_add_self 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   746
    RS prat_less_imp_le) 2);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   747
by (auto_tac (claset() addIs [prat_le_trans],
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   748
    simpset() addsimps [prat_le_refl,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   749
    pSuc_is_plus_one,pnat_one_def,prat_add_mult_distrib2,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   750
    prat_pnat_add,prat_pnat_mult]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   751
qed "lemma_Abs_prat_le2";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   752
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   753
Goal "Abs_prat(ratrel^^{(x,z)}) <= Abs_prat(ratrel^^{(x*y,Abs_pnat 1)})";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   754
by (fast_tac (claset() addIs [prat_le_trans,lemma_Abs_prat_le1,lemma_Abs_prat_le2]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   755
qed "lemma_Abs_prat_le3";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   756
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   757
Goal "Abs_prat(ratrel^^{(x*y,Abs_pnat 1)}) * Abs_prat(ratrel^^{(w,x)}) = \
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   758
\         Abs_prat(ratrel^^{(w*y,Abs_pnat 1)})";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   759
by (full_simp_tac (simpset() addsimps [prat_mult,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   760
    pnat_mult_1,pnat_mult_1_left] @ pnat_mult_ac) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   761
qed "pre_lemma_gleason9_34";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   762
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   763
Goal "Abs_prat(ratrel^^{(y*x,Abs_pnat 1*y)}) = \
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   764
\         Abs_prat(ratrel^^{(x,Abs_pnat 1)})";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   765
by (auto_tac (claset(),simpset() addsimps 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   766
    [pnat_mult_1,pnat_mult_1_left] @ pnat_mult_ac));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   767
qed "pre_lemma_gleason9_34b";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   768
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   769
Goal "($#n < $#m) = (n < m)";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   770
by (auto_tac (claset(),simpset() addsimps [prat_less_def,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   771
    pnat_less_iff,prat_pnat_add]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   772
by (res_inst_tac [("z","T")] eq_Abs_prat 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   773
by (auto_tac (claset() addDs [pnat_eq_lessI],
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   774
    simpset() addsimps [prat_add,pnat_mult_1,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   775
    pnat_mult_1_left,prat_pnat_def,pnat_less_iff RS sym]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   776
qed "prat_pnat_less_iff";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   777
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   778
Addsimps [prat_pnat_less_iff];
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   779
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   780
(***)(***)(***)(***)(***)(***)(***)(***)(***)(***)(***)(***)(***)(***)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   781
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   782
(*** prove witness that will be required to prove non-emptiness ***)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   783
(*** of preal type as defined using Dedekind Sections in PReal ***)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   784
(*** Show that exists positive real `one' ***)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   785
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   786
Goal "? q. q: {x::prat. x < $#Abs_pnat 1}";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   787
by (fast_tac (claset() addIs [prat_less_qinv_2_1]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   788
qed "lemma_prat_less_1_memEx";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   789
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   790
Goal "{x::prat. x < $#Abs_pnat 1} ~= {}";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   791
by (rtac notI 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   792
by (cut_facts_tac [lemma_prat_less_1_memEx] 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   793
by (Asm_full_simp_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   794
qed "lemma_prat_less_1_set_non_empty";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   795
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   796
Goalw [psubset_def] "{} < {x::prat. x < $#Abs_pnat 1}";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   797
by (asm_full_simp_tac (simpset() addsimps 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   798
         [lemma_prat_less_1_set_non_empty RS not_sym]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   799
qed "empty_set_psubset_lemma_prat_less_1_set";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   800
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   801
(*** exists rational not in set --- $#Abs_pnat 1 itself ***)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   802
Goal "? q. q ~: {x::prat. x < $#Abs_pnat 1}";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   803
by (res_inst_tac [("x","$#Abs_pnat 1")] exI 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   804
by (auto_tac (claset(),simpset() addsimps [prat_less_not_refl]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   805
qed "lemma_prat_less_1_not_memEx";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   806
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   807
Goal "{x::prat. x < $#Abs_pnat 1} ~= {q::prat. True}";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   808
by (rtac notI 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   809
by (cut_facts_tac [lemma_prat_less_1_not_memEx] 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   810
by (Asm_full_simp_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   811
qed "lemma_prat_less_1_set_not_rat_set";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   812
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   813
Goalw [psubset_def,subset_def] 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   814
      "{x::prat. x < $#Abs_pnat 1} < {q::prat. True}";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   815
by (asm_full_simp_tac (simpset() addsimps 
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   816
      [lemma_prat_less_1_set_not_rat_set,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   817
       lemma_prat_less_1_not_memEx]) 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   818
qed "lemma_prat_less_1_set_psubset_rat_set";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   819
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   820
(*** prove non_emptiness of type ***)
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   821
Goal "{x::prat. x < $#Abs_pnat 1} : {A. {} < A & A < {q::prat. True} & \
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   822
\                                        (!y: A. ((!z. z < y --> z: A) & \
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   823
\                                        (? u: A. y < u)))}";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   824
by (auto_tac (claset() addDs [prat_less_trans],
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   825
    simpset() addsimps [empty_set_psubset_lemma_prat_less_1_set,
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   826
                       lemma_prat_less_1_set_psubset_rat_set]));
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   827
by (dtac prat_dense 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   828
by (Fast_tac 1);
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   829
qed "preal_1";
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   830
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   831
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   832
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   833
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   834
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   835