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 |
|
|
14 |
goal thy "(x mem qsort (ord,l)) = (x mem l)";
|
|
15 |
by (res_inst_tac [("u","ord"),("v","l")] qsort.induct 1);
|
|
16 |
by (ALLGOALS (asm_simp_tac (!simpset setloop split_tac[expand_if])));
|
|
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 |
|
|
25 |
goal thy "g x < Suc x";
|
|
26 |
by (res_inst_tac [("u","x")] g.induct 1);
|
|
27 |
by (Auto_tac());
|
|
28 |
by (trans_tac 1);
|
|
29 |
qed "g_terminates";
|
|
30 |
|
|
31 |
goal thy "g x = 0";
|
|
32 |
by (res_inst_tac [("u","x")] g.induct 1);
|
|
33 |
by (ALLGOALS (asm_simp_tac (!simpset addsimps [g_terminates])));
|
|
34 |
qed "g_zero";
|
|
35 |
|