author | paulson |
Thu, 25 Jun 1998 13:57:34 +0200 | |
changeset 5078 | 7b5ea59c0275 |
parent 5069 | 3ea049f7979d |
permissions | -rw-r--r-- |
3417 | 1 |
(* Title: HOL/ex/Recdef.ML |
2 |
ID: $Id$ |
|
3 |
Author: Konrad Lawrence C Paulson |
|
4 |
Copyright 1997 University of Cambridge |
|
5 |
||
6 |
A few proofs to demonstrate the functions defined in Recdef.thy |
|
7 |
Lemma statements from Konrad Slind's Web site |
|
8 |
*) |
|
9 |
||
10 |
open Recdef; |
|
11 |
||
12 |
Addsimps qsort.rules; |
|
13 |
||
5069 | 14 |
Goal "(x mem qsort (ord,l)) = (x mem l)"; |
3417 | 15 |
by (res_inst_tac [("u","ord"),("v","l")] qsort.induct 1); |
4686 | 16 |
by (ALLGOALS Asm_simp_tac); |
3417 | 17 |
by (Blast_tac 1); |
18 |
qed "qsort_mem_stable"; |
|
19 |
||
20 |
||
21 |
(** The silly g function: example of nested recursion **) |
|
22 |
||
23 |
Addsimps g.rules; |
|
24 |
||
5069 | 25 |
Goal "g x < Suc x"; |
3417 | 26 |
by (res_inst_tac [("u","x")] g.induct 1); |
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4423
diff
changeset
|
27 |
by Auto_tac; |
3417 | 28 |
by (trans_tac 1); |
29 |
qed "g_terminates"; |
|
30 |
||
5069 | 31 |
Goal "g x = 0"; |
3417 | 32 |
by (res_inst_tac [("u","x")] g.induct 1); |
4089 | 33 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [g_terminates]))); |
3417 | 34 |
qed "g_zero"; |
35 |
||
3590
4d307341d0af
Added example mapf which requires a special congruence rule.
nipkow
parents:
3417
diff
changeset
|
36 |
(*** the contrived `mapf' ***) |
4d307341d0af
Added example mapf which requires a special congruence rule.
nipkow
parents:
3417
diff
changeset
|
37 |
|
4d307341d0af
Added example mapf which requires a special congruence rule.
nipkow
parents:
3417
diff
changeset
|
38 |
(* proving the termination condition: *) |
4d307341d0af
Added example mapf which requires a special congruence rule.
nipkow
parents:
3417
diff
changeset
|
39 |
val [tc] = mapf.tcs; |
4d307341d0af
Added example mapf which requires a special congruence rule.
nipkow
parents:
3417
diff
changeset
|
40 |
goalw_cterm [] (cterm_of (sign_of thy) (HOLogic.mk_Trueprop tc)); |
4423 | 41 |
by (rtac allI 1); |
42 |
by (case_tac "n=0" 1); |
|
43 |
by (ALLGOALS Asm_simp_tac); |
|
3590
4d307341d0af
Added example mapf which requires a special congruence rule.
nipkow
parents:
3417
diff
changeset
|
44 |
val lemma = result(); |
4d307341d0af
Added example mapf which requires a special congruence rule.
nipkow
parents:
3417
diff
changeset
|
45 |
|
4d307341d0af
Added example mapf which requires a special congruence rule.
nipkow
parents:
3417
diff
changeset
|
46 |
(* removing the termination condition from the generated thms: *) |
4d307341d0af
Added example mapf which requires a special congruence rule.
nipkow
parents:
3417
diff
changeset
|
47 |
val [mapf_0,mapf_Suc] = mapf.rules; |
4d307341d0af
Added example mapf which requires a special congruence rule.
nipkow
parents:
3417
diff
changeset
|
48 |
val mapf_Suc = lemma RS mapf_Suc; |
4d307341d0af
Added example mapf which requires a special congruence rule.
nipkow
parents:
3417
diff
changeset
|
49 |
|
4d307341d0af
Added example mapf which requires a special congruence rule.
nipkow
parents:
3417
diff
changeset
|
50 |
val mapf_induct = lemma RS mapf.induct; |