src/FOL/ex/Nat.ML
changeset 755 dfb3894d78e4
parent 132 b5704e45d2d2
child 1459 d12da312eff4
equal deleted inserted replaced
754:521a6f3ff279 755:dfb3894d78e4
    20 by (resolve_tac [notI] 1);
    20 by (resolve_tac [notI] 1);
    21 by (eresolve_tac [Suc_neq_0] 1);
    21 by (eresolve_tac [Suc_neq_0] 1);
    22 by (resolve_tac [notI] 1);
    22 by (resolve_tac [notI] 1);
    23 by (eresolve_tac [notE] 1);
    23 by (eresolve_tac [notE] 1);
    24 by (eresolve_tac [Suc_inject] 1);
    24 by (eresolve_tac [Suc_inject] 1);
    25 val Suc_n_not_n = result();
    25 qed "Suc_n_not_n";
    26 
    26 
    27 
    27 
    28 goal Nat.thy "(k+m)+n = k+(m+n)";
    28 goal Nat.thy "(k+m)+n = k+(m+n)";
    29 prths ([induct] RL [topthm()]);  (*prints all 14 next states!*)
    29 prths ([induct] RL [topthm()]);  (*prints all 14 next states!*)
    30 by (resolve_tac [induct] 1);
    30 by (resolve_tac [induct] 1);
    35 back();
    35 back();
    36 back();
    36 back();
    37 
    37 
    38 goalw Nat.thy [add_def] "0+n = n";
    38 goalw Nat.thy [add_def] "0+n = n";
    39 by (resolve_tac [rec_0] 1);
    39 by (resolve_tac [rec_0] 1);
    40 val add_0 = result();
    40 qed "add_0";
    41 
    41 
    42 goalw Nat.thy [add_def] "Suc(m)+n = Suc(m+n)";
    42 goalw Nat.thy [add_def] "Suc(m)+n = Suc(m+n)";
    43 by (resolve_tac [rec_Suc] 1);
    43 by (resolve_tac [rec_Suc] 1);
    44 val add_Suc = result();
    44 qed "add_Suc";
    45 
    45 
    46 val add_ss = FOL_ss addsimps [add_0, add_Suc];
    46 val add_ss = FOL_ss addsimps [add_0, add_Suc];
    47 
    47 
    48 goal Nat.thy "(k+m)+n = k+(m+n)";
    48 goal Nat.thy "(k+m)+n = k+(m+n)";
    49 by (res_inst_tac [("n","k")] induct 1);
    49 by (res_inst_tac [("n","k")] induct 1);
    50 by (simp_tac add_ss 1);
    50 by (simp_tac add_ss 1);
    51 by (asm_simp_tac add_ss 1);
    51 by (asm_simp_tac add_ss 1);
    52 val add_assoc = result();
    52 qed "add_assoc";
    53 
    53 
    54 goal Nat.thy "m+0 = m";
    54 goal Nat.thy "m+0 = m";
    55 by (res_inst_tac [("n","m")] induct 1);
    55 by (res_inst_tac [("n","m")] induct 1);
    56 by (simp_tac add_ss 1);
    56 by (simp_tac add_ss 1);
    57 by (asm_simp_tac add_ss 1);
    57 by (asm_simp_tac add_ss 1);
    58 val add_0_right = result();
    58 qed "add_0_right";
    59 
    59 
    60 goal Nat.thy "m+Suc(n) = Suc(m+n)";
    60 goal Nat.thy "m+Suc(n) = Suc(m+n)";
    61 by (res_inst_tac [("n","m")] induct 1);
    61 by (res_inst_tac [("n","m")] induct 1);
    62 by (ALLGOALS (asm_simp_tac add_ss));
    62 by (ALLGOALS (asm_simp_tac add_ss));
    63 val add_Suc_right = result();
    63 qed "add_Suc_right";
    64 
    64 
    65 val [prem] = goal Nat.thy "(!!n. f(Suc(n)) = Suc(f(n))) ==> f(i+j) = i+f(j)";
    65 val [prem] = goal Nat.thy "(!!n. f(Suc(n)) = Suc(f(n))) ==> f(i+j) = i+f(j)";
    66 by (res_inst_tac [("n","i")] induct 1);
    66 by (res_inst_tac [("n","i")] induct 1);
    67 by (simp_tac add_ss 1);
    67 by (simp_tac add_ss 1);
    68 by (asm_simp_tac (add_ss addsimps [prem]) 1);
    68 by (asm_simp_tac (add_ss addsimps [prem]) 1);