src/ZF/Integ/Int.ML
changeset 9491 1a36151ee2fc
parent 9333 5cacc383157a
child 9496 07e33cac5d9c
equal deleted inserted replaced
9490:c2606af9922c 9491:1a36151ee2fc
    13 *)
    13 *)
    14 
    14 
    15 AddSEs [quotientE];
    15 AddSEs [quotientE];
    16 
    16 
    17 (*** Proving that intrel is an equivalence relation ***)
    17 (*** Proving that intrel is an equivalence relation ***)
    18 
       
    19 (*By luck, requires no typing premises for y1, y2,y3*)
       
    20 val eqa::eqb::prems = goal Arith.thy 
       
    21     "[| x1 #+ y2 = x2 #+ y1; x2 #+ y3 = x3 #+ y2;  \
       
    22 \       x1: nat; x2: nat; x3: nat |]    ==>    x1 #+ y3 = x3 #+ y1";
       
    23 by (cut_facts_tac prems 1);
       
    24 by (res_inst_tac [("k","x2")] add_left_cancel 1);
       
    25 by (rtac (add_left_commute RS trans) 1);
       
    26 by Auto_tac;
       
    27 by (stac eqb 1);
       
    28 by (rtac (add_left_commute RS trans) 1);
       
    29 by (stac eqa 3);
       
    30 by (ALLGOALS (asm_simp_tac (simpset() addsimps [add_left_commute])));
       
    31 qed "int_trans_lemma";
       
    32 
    18 
    33 (** Natural deduction for intrel **)
    19 (** Natural deduction for intrel **)
    34 
    20 
    35 Goalw [intrel_def]
    21 Goalw [intrel_def]
    36     "<<x1,y1>,<x2,y2>>: intrel <-> \
    22     "<<x1,y1>,<x2,y2>>: intrel <-> \
    61 by (REPEAT (eresolve_tac [asm_rl,exE,conjE,minor] 1));
    47 by (REPEAT (eresolve_tac [asm_rl,exE,conjE,minor] 1));
    62 qed "intrelE";
    48 qed "intrelE";
    63 
    49 
    64 AddSIs [intrelI];
    50 AddSIs [intrelI];
    65 AddSEs [intrelE];
    51 AddSEs [intrelE];
       
    52 
       
    53 val eqa::eqb::prems = goal Arith.thy 
       
    54     "[| x1 #+ y2 = x2 #+ y1; x2 #+ y3 = x3 #+ y2 |] ==> x1 #+ y3 = x3 #+ y1";
       
    55 by (res_inst_tac [("k","x2")] add_left_cancel 1);
       
    56 by (rtac (add_left_commute RS trans) 1);
       
    57 by Auto_tac;
       
    58 by (stac eqb 1);
       
    59 by (rtac (add_left_commute RS trans) 1);
       
    60 by (ALLGOALS (asm_simp_tac (simpset() addsimps [eqa, add_left_commute])));
       
    61 qed "int_trans_lemma";
    66 
    62 
    67 Goalw [equiv_def, refl_def, sym_def, trans_def]
    63 Goalw [equiv_def, refl_def, sym_def, trans_def]
    68     "equiv(nat*nat, intrel)";
    64     "equiv(nat*nat, intrel)";
    69 by (fast_tac (claset() addSEs [sym, int_trans_lemma]) 1);
    65 by (fast_tac (claset() addSEs [sym, int_trans_lemma]) 1);
    70 qed "equiv_intrel";
    66 qed "equiv_intrel";
   237 by Safe_tac;
   233 by Safe_tac;
   238 by (asm_simp_tac (simpset() addsimps [add_assoc, Let_def]) 1);
   234 by (asm_simp_tac (simpset() addsimps [add_assoc, Let_def]) 1);
   239 (*The rest should be trivial, but rearranging terms is hard;
   235 (*The rest should be trivial, but rearranging terms is hard;
   240   add_ac does not help rewriting with the assumptions.*)
   236   add_ac does not help rewriting with the assumptions.*)
   241 by (res_inst_tac [("m1","x1a")] (add_left_commute RS ssubst) 1);
   237 by (res_inst_tac [("m1","x1a")] (add_left_commute RS ssubst) 1);
   242 by (res_inst_tac [("m1","x2a")] (add_left_commute RS ssubst) 3);
   238 by (res_inst_tac [("m1","x2a")] (add_left_commute RS ssubst) 1);
   243 by Auto_tac;
       
   244 by (asm_simp_tac (simpset() addsimps [add_assoc RS sym]) 1);
   239 by (asm_simp_tac (simpset() addsimps [add_assoc RS sym]) 1);
   245 qed "zadd_congruent2";
   240 qed "zadd_congruent2";
   246 
   241 
   247 (*Resolve th against the corresponding facts for zadd*)
   242 (*Resolve th against the corresponding facts for zadd*)
   248 val zadd_ize = RSLIST [equiv_intrel, zadd_congruent2];
   243 val zadd_ize = RSLIST [equiv_intrel, zadd_congruent2];