doc-src/Ref/simplifier-eg.txt
author oheimb
Wed, 12 Nov 1997 18:58:50 +0100
changeset 4223 f60e3d2c81d3
parent 359 b5a2e9503a7a
child 4396 d103e5e164f8
permissions -rw-r--r--
added thin_refl to hyp_subst_tac
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
359
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
     1
Pretty.setmargin 70;
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
     2
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     3
> goal Nat.thy "m+0 = m";
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     4
Level 0
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     5
m + 0 = m
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     6
 1. m + 0 = m
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     7
> by (res_inst_tac [("n","m")] induct 1);
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     8
Level 1
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     9
m + 0 = m
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    10
 1. 0 + 0 = 0
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    11
 2. !!x. x + 0 = x ==> Suc(x) + 0 = Suc(x)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    12
> by (simp_tac add_ss 1);
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    13
Level 2
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    14
m + 0 = m
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    15
 1. !!x. x + 0 = x ==> Suc(x) + 0 = Suc(x)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    16
> by (asm_simp_tac add_ss 1);
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    17
Level 3
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    18
m + 0 = m
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    19
No subgoals!
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    20
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    21
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    22
> goal Nat.thy "m+Suc(n) = Suc(m+n)";
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    23
Level 0
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    24
m + Suc(n) = Suc(m + n)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    25
 1. m + Suc(n) = Suc(m + n)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    26
val it = [] : thm list   
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    27
> by (res_inst_tac [("n","m")] induct 1);
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    28
Level 1
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    29
m + Suc(n) = Suc(m + n)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    30
 1. 0 + Suc(n) = Suc(0 + n)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    31
 2. !!x. x + Suc(n) = Suc(x + n) ==> Suc(x) + Suc(n) = Suc(Suc(x) + n)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    32
val it = () : unit   
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    33
> by (simp_tac add_ss 1);
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    34
Level 2
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    35
m + Suc(n) = Suc(m + n)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    36
 1. !!x. x + Suc(n) = Suc(x + n) ==> Suc(x) + Suc(n) = Suc(Suc(x) + n)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    37
val it = () : unit   
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    38
> trace_simp := true;
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    39
val it = () : unit   
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    40
> by (asm_simp_tac add_ss 1);
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    41
Rewriting:
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    42
Suc(x) + Suc(n) == Suc(x + Suc(n))
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    43
Rewriting:
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    44
x + Suc(n) == Suc(x + n)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    45
Rewriting:
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    46
Suc(x) + n == Suc(x + n)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    47
Rewriting:
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    48
Suc(Suc(x + n)) = Suc(Suc(x + n)) == True
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    49
Level 3
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    50
m + Suc(n) = Suc(m + n)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    51
No subgoals!
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    52
val it = () : unit   
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    53
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    54
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    55
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    56
> val prems = goal Nat.thy "(!!n. f(Suc(n)) = Suc(f(n))) ==> f(i+j) = i+f(j)";
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    57
Level 0
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    58
f(i + j) = i + f(j)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    59
 1. f(i + j) = i + f(j)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    60
> prths prems;
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    61
f(Suc(?n)) = Suc(f(?n))  [!!n. f(Suc(n)) = Suc(f(n))]
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    62
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    63
> by (res_inst_tac [("n","i")] induct 1);
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    64
Level 1
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    65
f(i + j) = i + f(j)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    66
 1. f(0 + j) = 0 + f(j)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    67
 2. !!x. f(x + j) = x + f(j) ==> f(Suc(x) + j) = Suc(x) + f(j)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    68
> by (simp_tac f_ss 1);
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    69
Level 2
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    70
f(i + j) = i + f(j)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    71
 1. !!x. f(x + j) = x + f(j) ==> f(Suc(x) + j) = Suc(x) + f(j)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    72
> by (asm_simp_tac (f_ss addrews prems) 1);
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    73
Level 3
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    74
f(i + j) = i + f(j)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    75
No subgoals!
359
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    76
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    77
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    78
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    79
> goal NatSum.thy "Suc(Suc(0))*sum(%i.i,Suc(n)) = n*Suc(n)";
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    80
Level 0
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    81
Suc(Suc(0)) * sum(%i. i, Suc(n)) = n * Suc(n)
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    82
 1. Suc(Suc(0)) * sum(%i. i, Suc(n)) = n * Suc(n)
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    83
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    84
> by (simp_tac natsum_ss 1);
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    85
Level 1
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    86
Suc(Suc(0)) * sum(%i. i, Suc(n)) = n * Suc(n)
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    87
 1. n + (n + (sum(%i. i, n) + sum(%i. i, n))) = n + n * n
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    88
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    89
> by (nat_ind_tac "n" 1);
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    90
Level 2
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    91
Suc(Suc(0)) * sum(%i. i, Suc(n)) = n * Suc(n)
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    92
 1. 0 + (0 + (sum(%i. i, 0) + sum(%i. i, 0))) = 0 + 0 * 0
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    93
 2. !!n1. n1 + (n1 + (sum(%i. i, n1) + sum(%i. i, n1))) =
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    94
          n1 + n1 * n1 ==>
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    95
          Suc(n1) +
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    96
          (Suc(n1) + (sum(%i. i, Suc(n1)) + sum(%i. i, Suc(n1)))) =
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    97
          Suc(n1) + Suc(n1) * Suc(n1)
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    98
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
    99
> by (simp_tac natsum_ss 1);
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
   100
Level 3
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
   101
Suc(Suc(0)) * sum(%i. i, Suc(n)) = n * Suc(n)
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
   102
 1. !!n1. n1 + (n1 + (sum(%i. i, n1) + sum(%i. i, n1))) =
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
   103
          n1 + n1 * n1 ==>
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
   104
          Suc(n1) +
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
   105
          (Suc(n1) + (sum(%i. i, Suc(n1)) + sum(%i. i, Suc(n1)))) =
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
   106
          Suc(n1) + Suc(n1) * Suc(n1)
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
   107
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
   108
> by (asm_simp_tac natsum_ss 1);
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
   109
Level 4
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
   110
Suc(Suc(0)) * sum(%i. i, Suc(n)) = n * Suc(n)
b5a2e9503a7a final Springer version
lcp
parents: 104
diff changeset
   111
No subgoals!