src/HOL/WF.ML
author nipkow
Sat, 08 Aug 1998 14:00:56 +0200
changeset 5281 f4d16517b360
parent 5278 a903b66822e2
child 5316 7a8975451a89
permissions -rw-r--r--
List now contains some lexicographic orderings.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
     1
(*  Title:      HOL/wf.ML
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
     3
    Author:     Tobias Nipkow, with minor changes by Konrad Slind
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
     4
    Copyright   1992  University of Cambridge/1995 TU Munich
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     5
3198
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
     6
Wellfoundedness, induction, and  recursion
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     7
*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     8
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     9
open WF;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    10
950
323f8ca4587a Removed superfluous type constraint
nipkow
parents: 923
diff changeset
    11
val H_cong = read_instantiate [("f","H")] (standard(refl RS cong RS cong));
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    12
val H_cong1 = refl RS H_cong;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    13
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    14
(*Restriction to domain A.  If r is well-founded over A then wf(r)*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    15
val [prem1,prem2] = goalw WF.thy [wf_def]
1642
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1618
diff changeset
    16
 "[| r <= A Times A;  \
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 950
diff changeset
    17
\    !!x P. [| ! x. (! y. (y,x) : r --> P(y)) --> P(x);  x:A |] ==> P(x) |]  \
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    18
\ ==>  wf(r)";
3708
56facaebf3e3 Changed some proofs to use Clarify_tac
paulson
parents: 3457
diff changeset
    19
by (Clarify_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    20
by (rtac allE 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    21
by (assume_tac 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
    22
by (best_tac (claset() addSEs [prem1 RS subsetD RS SigmaE2] addIs [prem2]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    23
qed "wfI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    24
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    25
val major::prems = goalw WF.thy [wf_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    26
    "[| wf(r);          \
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 950
diff changeset
    27
\       !!x.[| ! y. (y,x): r --> P(y) |] ==> P(x) \
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    28
\    |]  ==>  P(a)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    29
by (rtac (major RS spec RS mp RS spec) 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
    30
by (blast_tac (claset() addIs prems) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    31
qed "wf_induct";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    32
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    33
(*Perform induction on i, then prove the wf(r) subgoal using prems. *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    34
fun wf_ind_tac a prems i = 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    35
    EVERY [res_inst_tac [("a",a)] wf_induct i,
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1264
diff changeset
    36
           rename_last_tac a ["1"] (i+1),
5d7a7e439cec expanded tabs
clasohm
parents: 1264
diff changeset
    37
           ares_tac prems i];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    38
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 950
diff changeset
    39
val prems = goal WF.thy "[| wf(r);  (a,x):r;  (x,a):r |] ==> P";
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 950
diff changeset
    40
by (subgoal_tac "! x. (a,x):r --> (x,a):r --> P" 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
    41
by (blast_tac (claset() addIs prems) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    42
by (wf_ind_tac "a" prems 1);
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2637
diff changeset
    43
by (Blast_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    44
qed "wf_asym";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    45
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 950
diff changeset
    46
val prems = goal WF.thy "[| wf(r);  (a,a): r |] ==> P";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    47
by (rtac wf_asym 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    48
by (REPEAT (resolve_tac prems 1));
1618
372880456b5b Library changes for mutilated checkerboard
paulson
parents: 1552
diff changeset
    49
qed "wf_irrefl";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    50
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
    51
(*transitive closure of a wf relation is wf! *)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    52
val [prem] = goal WF.thy "wf(r) ==> wf(r^+)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    53
by (rewtac wf_def);
3708
56facaebf3e3 Changed some proofs to use Clarify_tac
paulson
parents: 3457
diff changeset
    54
by (Clarify_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    55
(*must retain the universal formula for later use!*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    56
by (rtac allE 1 THEN assume_tac 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    57
by (etac mp 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    58
by (res_inst_tac [("a","x")] (prem RS wf_induct) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    59
by (rtac (impI RS allI) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    60
by (etac tranclE 1);
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2637
diff changeset
    61
by (Blast_tac 1);
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2637
diff changeset
    62
by (Blast_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    63
qed "wf_trancl";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    64
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    65
4762
afebaa81f148 added wf_converse_trancl, adapted proof of wfrec
oheimb
parents: 4750
diff changeset
    66
val wf_converse_trancl = prove_goal thy 
afebaa81f148 added wf_converse_trancl, adapted proof of wfrec
oheimb
parents: 4750
diff changeset
    67
"!!X. wf (r^-1) ==> wf ((r^+)^-1)" (K [
afebaa81f148 added wf_converse_trancl, adapted proof of wfrec
oheimb
parents: 4750
diff changeset
    68
	stac (trancl_converse RS sym) 1,
afebaa81f148 added wf_converse_trancl, adapted proof of wfrec
oheimb
parents: 4750
diff changeset
    69
	etac wf_trancl 1]);
afebaa81f148 added wf_converse_trancl, adapted proof of wfrec
oheimb
parents: 4750
diff changeset
    70
3198
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
    71
(*----------------------------------------------------------------------------
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
    72
 * Minimal-element characterization of well-foundedness
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
    73
 *---------------------------------------------------------------------------*)
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
    74
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
    75
val wfr::_ = goalw WF.thy [wf_def]
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
    76
    "wf r ==> x:Q --> (? z:Q. ! y. (y,z):r --> y~:Q)";
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
    77
by (rtac (wfr RS spec RS mp RS spec) 1);
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
    78
by (Blast_tac 1);
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
    79
val lemma1 = result();
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
    80
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4821
diff changeset
    81
Goalw [wf_def]
5148
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
    82
    "(! Q x. x:Q --> (? z:Q. ! y. (y,z):r --> y~:Q)) ==> wf r";
3708
56facaebf3e3 Changed some proofs to use Clarify_tac
paulson
parents: 3457
diff changeset
    83
by (Clarify_tac 1);
3198
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
    84
by (dres_inst_tac [("x", "{x. ~ P x}")] spec 1);
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
    85
by (Blast_tac 1);
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
    86
val lemma2 = result();
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
    87
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4821
diff changeset
    88
Goal "wf r = (! Q x. x:Q --> (? z:Q. ! y. (y,z):r --> y~:Q))";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
    89
by (blast_tac (claset() addSIs [lemma1, lemma2]) 1);
3198
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
    90
qed "wf_eq_minimal";
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
    91
3413
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
    92
(*---------------------------------------------------------------------------
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
    93
 * Wellfoundedness of subsets
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
    94
 *---------------------------------------------------------------------------*)
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
    95
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5132
diff changeset
    96
Goal "[| wf(r);  p<=r |] ==> wf(p)";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
    97
by (full_simp_tac (simpset() addsimps [wf_eq_minimal]) 1);
3413
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
    98
by (Fast_tac 1);
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
    99
qed "wf_subset";
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   100
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   101
(*---------------------------------------------------------------------------
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   102
 * Wellfoundedness of the empty relation.
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   103
 *---------------------------------------------------------------------------*)
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   104
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4821
diff changeset
   105
Goal "wf({})";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   106
by (simp_tac (simpset() addsimps [wf_def]) 1);
3413
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   107
qed "wf_empty";
5281
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   108
AddIffs [wf_empty];
3413
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   109
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   110
(*---------------------------------------------------------------------------
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   111
 * Wellfoundedness of `insert'
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   112
 *---------------------------------------------------------------------------*)
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   113
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4821
diff changeset
   114
Goal "wf(insert (y,x) r) = (wf(r) & (x,y) ~: r^*)";
3457
a8ab7c64817c Ran expandshort
paulson
parents: 3439
diff changeset
   115
by (rtac iffI 1);
4350
1983e4054fd8 updated for latest Blast_tac, which treats equality differently
paulson
parents: 4153
diff changeset
   116
 by (blast_tac (claset() addEs [wf_trancl RS wf_irrefl] 
1983e4054fd8 updated for latest Blast_tac, which treats equality differently
paulson
parents: 4153
diff changeset
   117
	addIs [rtrancl_into_trancl1,wf_subset,impOfSubs rtrancl_mono]) 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   118
by (asm_full_simp_tac (simpset() addsimps [wf_eq_minimal]) 1);
4153
e534c4c32d54 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4089
diff changeset
   119
by Safe_tac;
3457
a8ab7c64817c Ran expandshort
paulson
parents: 3439
diff changeset
   120
by (EVERY1[rtac allE, atac, etac impE, Blast_tac]);
a8ab7c64817c Ran expandshort
paulson
parents: 3439
diff changeset
   121
by (etac bexE 1);
a8ab7c64817c Ran expandshort
paulson
parents: 3439
diff changeset
   122
by (rename_tac "a" 1);
a8ab7c64817c Ran expandshort
paulson
parents: 3439
diff changeset
   123
by (case_tac "a = x" 1);
a8ab7c64817c Ran expandshort
paulson
parents: 3439
diff changeset
   124
 by (res_inst_tac [("x","a")]bexI 2);
a8ab7c64817c Ran expandshort
paulson
parents: 3439
diff changeset
   125
  by (assume_tac 3);
a8ab7c64817c Ran expandshort
paulson
parents: 3439
diff changeset
   126
 by (Blast_tac 2);
a8ab7c64817c Ran expandshort
paulson
parents: 3439
diff changeset
   127
by (case_tac "y:Q" 1);
a8ab7c64817c Ran expandshort
paulson
parents: 3439
diff changeset
   128
 by (Blast_tac 2);
4059
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3919
diff changeset
   129
by (res_inst_tac [("x","{z. z:Q & (z,y) : r^*}")] allE 1);
3457
a8ab7c64817c Ran expandshort
paulson
parents: 3439
diff changeset
   130
 by (assume_tac 1);
4059
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3919
diff changeset
   131
by (thin_tac "! Q. (? x. x : Q) --> ?P Q" 1);	(*essential for speed*)
4350
1983e4054fd8 updated for latest Blast_tac, which treats equality differently
paulson
parents: 4153
diff changeset
   132
(*Blast_tac with new substOccur fails*)
1983e4054fd8 updated for latest Blast_tac, which treats equality differently
paulson
parents: 4153
diff changeset
   133
by (best_tac (claset() addIs [rtrancl_into_rtrancl2]) 1);
3413
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   134
qed "wf_insert";
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   135
AddIffs [wf_insert];
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   136
5281
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   137
(*---------------------------------------------------------------------------
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   138
 * Wellfoundedness of `disjoint union'
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   139
 *---------------------------------------------------------------------------*)
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   140
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   141
Goal
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   142
 "[| !i:I. wf(r i); \
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   143
\    !i:I.!j:I. r i ~= r j --> Domain(r i) Int Range(r j) = {} & \
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   144
\                              Domain(r j) Int Range(r i) = {} \
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   145
\ |] ==> wf(UN i:I. r i)";
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   146
by(asm_full_simp_tac (HOL_basic_ss addsimps [wf_eq_minimal]) 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   147
by(Clarify_tac 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   148
by(rename_tac "A a" 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   149
by(case_tac "? i:I. ? a:A. ? b:A. (b,a) : r i" 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   150
 by(Clarify_tac 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   151
 by(EVERY1[dtac bspec, atac,
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   152
           eres_inst_tac[("x","{a. a:A & (? b:A. (b,a) : r i)}")]allE]);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   153
 by(EVERY1[etac allE,etac impE]);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   154
  by(Blast_tac 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   155
 by(Clarify_tac 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   156
 by(rename_tac "z'" 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   157
 by(res_inst_tac [("x","z'")] bexI 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   158
  ba 2;
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   159
 by(Clarify_tac 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   160
 by(rename_tac "j" 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   161
 by(case_tac "r j = r i" 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   162
  by(EVERY1[etac allE,etac impE,atac]);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   163
  by(Asm_full_simp_tac 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   164
  by(Blast_tac 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   165
 by(blast_tac (claset() addEs [equalityE]) 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   166
by(Asm_full_simp_tac 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   167
by(case_tac "? i. i:I" 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   168
 by(Clarify_tac 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   169
 by(EVERY1[dtac bspec, atac, eres_inst_tac[("x","A")]allE]);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   170
 by(Blast_tac 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   171
by(Blast_tac 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   172
qed "wf_UN";
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   173
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   174
Goalw [Union_def]
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   175
 "[| !r:R. wf r; \
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   176
\    !r:R.!s:R. r ~= s --> Domain r Int Range s = {} & \
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   177
\                          Domain s Int Range r = {} \
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   178
\ |] ==> wf(Union R)";
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   179
br wf_UN 1;
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   180
by(Blast_tac 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   181
by(Blast_tac 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   182
qed "wf_Union";
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   183
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   184
Goal
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   185
 "[| wf r; wf s; Domain r Int Range s = {}; Domain s Int Range r = {} \
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   186
\ |] ==> wf(r Un s)";
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   187
br(simplify (simpset()) (read_instantiate[("R","{r,s}")]wf_Union)) 1;
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   188
by(Blast_tac 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   189
by(Blast_tac 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   190
qed "wf_Un";
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   191
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   192
(*---------------------------------------------------------------------------
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   193
 * Wellfoundedness of `image'
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   194
 *---------------------------------------------------------------------------*)
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   195
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   196
Goal "[| wf r; inj f |] ==> wf(prod_fun f f `` r)";
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   197
by(asm_full_simp_tac (HOL_basic_ss addsimps [wf_eq_minimal]) 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   198
by(Clarify_tac 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   199
by(case_tac "? p. f p : Q" 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   200
by(eres_inst_tac [("x","{p. f p : Q}")]allE 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   201
by(fast_tac (claset() addDs [injD]) 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   202
by(Blast_tac 1);
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   203
qed "wf_prod_fun_image";
f4d16517b360 List now contains some lexicographic orderings.
nipkow
parents: 5278
diff changeset
   204
3413
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   205
(*** acyclic ***)
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   206
4750
f83cd6a06676 added acyclicI
oheimb
parents: 4746
diff changeset
   207
val acyclicI = prove_goalw WF.thy [acyclic_def] 
f83cd6a06676 added acyclicI
oheimb
parents: 4746
diff changeset
   208
"!!r. !x. (x, x) ~: r^+ ==> acyclic r" (K [atac 1]);
f83cd6a06676 added acyclicI
oheimb
parents: 4746
diff changeset
   209
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4821
diff changeset
   210
Goalw [acyclic_def]
5148
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
   211
 "wf r ==> acyclic r";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   212
by (blast_tac (claset() addEs [wf_trancl RS wf_irrefl]) 1);
3413
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   213
qed "wf_acyclic";
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   214
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4821
diff changeset
   215
Goalw [acyclic_def]
3413
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   216
  "acyclic(insert (y,x) r) = (acyclic r & (x,y) ~: r^*)";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   217
by (simp_tac (simpset() addsimps [trancl_insert]) 1);
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   218
by (blast_tac (claset() addEs [make_elim rtrancl_trans]) 1);
3413
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   219
qed "acyclic_insert";
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   220
AddIffs [acyclic_insert];
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 3320
diff changeset
   221
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4821
diff changeset
   222
Goalw [acyclic_def] "acyclic(r^-1) = acyclic r";
4746
a5dcd7e4a37d inverse -> converse
paulson
parents: 4686
diff changeset
   223
by (simp_tac (simpset() addsimps [trancl_converse]) 1);
a5dcd7e4a37d inverse -> converse
paulson
parents: 4686
diff changeset
   224
qed "acyclic_converse";
3198
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
   225
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   226
(** cut **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   227
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   228
(*This rewrite rule works upon formulae; thus it requires explicit use of
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   229
  H_cong to expose the equality*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4821
diff changeset
   230
Goalw [cut_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 950
diff changeset
   231
    "(cut f r x = cut g r x) = (!y. (y,x):r --> f(y)=g(y))";
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4350
diff changeset
   232
by (simp_tac (HOL_ss addsimps [expand_fun_eq]) 1);
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   233
qed "cuts_eq";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   234
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5132
diff changeset
   235
Goalw [cut_def] "(x,a):r ==> (cut f r a)(x) = f(x)";
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1485
diff changeset
   236
by (asm_simp_tac HOL_ss 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   237
qed "cut_apply";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   238
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   239
(*** is_recfun ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   240
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4821
diff changeset
   241
Goalw [is_recfun_def,cut_def]
5148
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
   242
    "[| is_recfun r H a f;  ~(b,a):r |] ==> f(b) = arbitrary";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   243
by (etac ssubst 1);
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1485
diff changeset
   244
by (asm_simp_tac HOL_ss 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   245
qed "is_recfun_undef";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   246
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   247
(*** NOTE! some simplifications need a different finish_tac!! ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   248
fun indhyp_tac hyps =
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   249
    (cut_facts_tac hyps THEN'
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   250
       DEPTH_SOLVE_1 o (ares_tac [TrueI] ORELSE'
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1264
diff changeset
   251
                        eresolve_tac [transD, mp, allE]));
2637
e9b203f854ae reflecting my recent changes of the simplifier and classical reasoner
oheimb
parents: 2031
diff changeset
   252
val wf_super_ss = HOL_ss addSolver indhyp_tac;
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   253
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   254
val prems = goalw WF.thy [is_recfun_def,cut_def]
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   255
    "[| wf(r);  trans(r);  is_recfun r H a f;  is_recfun r H b g |] ==> \
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 950
diff changeset
   256
    \ (x,a):r --> (x,b):r --> f(x)=g(x)";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   257
by (cut_facts_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   258
by (etac wf_induct 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   259
by (REPEAT (rtac impI 1 ORELSE etac ssubst 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   260
by (asm_simp_tac (wf_super_ss addcongs [if_cong]) 1);
1485
240cc98b94a7 Added qed_spec_mp to avoid renaming of bound vars in 'th RS spec'
nipkow
parents: 1475
diff changeset
   261
qed_spec_mp "is_recfun_equal";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   262
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   263
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   264
val prems as [wfr,transr,recfa,recgb,_] = goalw WF.thy [cut_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   265
    "[| wf(r);  trans(r); \
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   266
\       is_recfun r H a f;  is_recfun r H b g;  (b,a):r |] ==> \
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   267
\    cut f r b = g";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   268
val gundef = recgb RS is_recfun_undef
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   269
and fisg   = recgb RS (recfa RS (transr RS (wfr RS is_recfun_equal)));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   270
by (cut_facts_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   271
by (rtac ext 1);
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4350
diff changeset
   272
by (asm_simp_tac (wf_super_ss addsimps [gundef,fisg]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   273
qed "is_recfun_cut";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   274
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   275
(*** Main Existence Lemma -- Basic Properties of the_recfun ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   276
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   277
val prems = goalw WF.thy [the_recfun_def]
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   278
    "is_recfun r H a f ==> is_recfun r H a (the_recfun r H a)";
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   279
by (res_inst_tac [("P", "is_recfun r H a")] selectI 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   280
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   281
qed "is_the_recfun";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   282
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   283
val prems = goal WF.thy
4821
bfbaea156f43 Modifications due to improved simplifier.
nipkow
parents: 4762
diff changeset
   284
 "!!r. [| wf(r);  trans(r) |] ==> is_recfun r H a (the_recfun r H a)";
bfbaea156f43 Modifications due to improved simplifier.
nipkow
parents: 4762
diff changeset
   285
by (wf_ind_tac "a" prems 1);
bfbaea156f43 Modifications due to improved simplifier.
nipkow
parents: 4762
diff changeset
   286
by (res_inst_tac [("f","cut (%y. H (the_recfun r H y) y) r a1")]
bfbaea156f43 Modifications due to improved simplifier.
nipkow
parents: 4762
diff changeset
   287
                 is_the_recfun 1);
bfbaea156f43 Modifications due to improved simplifier.
nipkow
parents: 4762
diff changeset
   288
by (rewtac is_recfun_def);
bfbaea156f43 Modifications due to improved simplifier.
nipkow
parents: 4762
diff changeset
   289
by (stac cuts_eq 1);
bfbaea156f43 Modifications due to improved simplifier.
nipkow
parents: 4762
diff changeset
   290
by (Clarify_tac 1);
bfbaea156f43 Modifications due to improved simplifier.
nipkow
parents: 4762
diff changeset
   291
by (rtac (refl RSN (2,H_cong)) 1);
bfbaea156f43 Modifications due to improved simplifier.
nipkow
parents: 4762
diff changeset
   292
by (subgoal_tac
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   293
         "the_recfun r H y = cut(%x. H(cut(the_recfun r H y) r x) x) r y" 1);
4821
bfbaea156f43 Modifications due to improved simplifier.
nipkow
parents: 4762
diff changeset
   294
 by (etac allE 2);
bfbaea156f43 Modifications due to improved simplifier.
nipkow
parents: 4762
diff changeset
   295
 by (dtac impE 2);
bfbaea156f43 Modifications due to improved simplifier.
nipkow
parents: 4762
diff changeset
   296
   by (atac 2);
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   297
  by (atac 3);
4821
bfbaea156f43 Modifications due to improved simplifier.
nipkow
parents: 4762
diff changeset
   298
 by (atac 2);
bfbaea156f43 Modifications due to improved simplifier.
nipkow
parents: 4762
diff changeset
   299
by (etac ssubst 1);
bfbaea156f43 Modifications due to improved simplifier.
nipkow
parents: 4762
diff changeset
   300
by (simp_tac (HOL_ss addsimps [cuts_eq]) 1);
bfbaea156f43 Modifications due to improved simplifier.
nipkow
parents: 4762
diff changeset
   301
by (Clarify_tac 1);
bfbaea156f43 Modifications due to improved simplifier.
nipkow
parents: 4762
diff changeset
   302
by (stac cut_apply 1);
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5069
diff changeset
   303
 by (fast_tac (claset() addDs [transD]) 1);
4821
bfbaea156f43 Modifications due to improved simplifier.
nipkow
parents: 4762
diff changeset
   304
by (rtac (refl RSN (2,H_cong)) 1);
bfbaea156f43 Modifications due to improved simplifier.
nipkow
parents: 4762
diff changeset
   305
by (fold_tac [is_recfun_def]);
bfbaea156f43 Modifications due to improved simplifier.
nipkow
parents: 4762
diff changeset
   306
by (asm_simp_tac (wf_super_ss addsimps[is_recfun_cut]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   307
qed "unfold_the_recfun";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   308
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   309
val unwind1_the_recfun = rewrite_rule[is_recfun_def] unfold_the_recfun;
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   310
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   311
(*--------------Old proof-----------------------------------------------------
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   312
val prems = goal WF.thy
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   313
    "[| wf(r);  trans(r) |] ==> is_recfun r H a (the_recfun r H a)";
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   314
by (cut_facts_tac prems 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   315
by (wf_ind_tac "a" prems 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   316
by (res_inst_tac [("f", "cut (%y. wftrec r H y) r a1")] is_the_recfun 1); 
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   317
by (rewrite_goals_tac [is_recfun_def, wftrec_def]);
2031
03a843f0f447 Ran expandshort
paulson
parents: 1786
diff changeset
   318
by (stac cuts_eq 1);
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   319
(*Applying the substitution: must keep the quantified assumption!!*)
3708
56facaebf3e3 Changed some proofs to use Clarify_tac
paulson
parents: 3457
diff changeset
   320
by (EVERY1 [Clarify_tac, rtac H_cong1, rtac allE, atac,
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   321
            etac (mp RS ssubst), atac]); 
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   322
by (fold_tac [is_recfun_def]);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   323
by (asm_simp_tac (wf_super_ss addsimps[cut_apply,is_recfun_cut,cuts_eq]) 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   324
qed "unfold_the_recfun";
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   325
---------------------------------------------------------------------------*)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   326
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   327
(** Removal of the premise trans(r) **)
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   328
val th = rewrite_rule[is_recfun_def]
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   329
                     (trans_trancl RSN (2,(wf_trancl RS unfold_the_recfun)));
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   330
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4821
diff changeset
   331
Goalw [wfrec_def]
5148
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
   332
    "wf(r) ==> wfrec r H a = H (cut (wfrec r H) r a) a";
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   333
by (rtac H_cong 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   334
by (rtac refl 2);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   335
by (simp_tac (HOL_ss addsimps [cuts_eq]) 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   336
by (rtac allI 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   337
by (rtac impI 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   338
by (simp_tac(HOL_ss addsimps [wfrec_def]) 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   339
by (res_inst_tac [("a1","a")] (th RS ssubst) 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   340
by (atac 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   341
by (forward_tac[wf_trancl] 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   342
by (forward_tac[r_into_trancl] 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   343
by (asm_simp_tac (HOL_ss addsimps [cut_apply]) 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   344
by (rtac H_cong 1);    (*expose the equality of cuts*)
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   345
by (rtac refl 2);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   346
by (simp_tac (HOL_ss addsimps [cuts_eq, cut_apply, r_into_trancl]) 1);
3708
56facaebf3e3 Changed some proofs to use Clarify_tac
paulson
parents: 3457
diff changeset
   347
by (Clarify_tac 1);
1485
240cc98b94a7 Added qed_spec_mp to avoid renaming of bound vars in 'th RS spec'
nipkow
parents: 1475
diff changeset
   348
by (res_inst_tac [("r","r^+")] is_recfun_equal 1);
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   349
by (atac 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   350
by (rtac trans_trancl 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   351
by (rtac unfold_the_recfun 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   352
by (atac 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   353
by (rtac trans_trancl 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   354
by (rtac unfold_the_recfun 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   355
by (atac 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   356
by (rtac trans_trancl 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   357
by (rtac transD 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   358
by (rtac trans_trancl 1);
4762
afebaa81f148 added wf_converse_trancl, adapted proof of wfrec
oheimb
parents: 4750
diff changeset
   359
by (forw_inst_tac [("p","(ya,y)")] r_into_trancl 1);
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   360
by (atac 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   361
by (atac 1);
4762
afebaa81f148 added wf_converse_trancl, adapted proof of wfrec
oheimb
parents: 4750
diff changeset
   362
by (forw_inst_tac [("p","(ya,y)")] r_into_trancl 1);
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   363
by (atac 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   364
qed "wfrec";
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   365
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   366
(*--------------Old proof-----------------------------------------------------
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4821
diff changeset
   367
Goalw [wfrec_def]
5148
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
   368
    "wf(r) ==> wfrec r H a = H (cut (wfrec r H) r a) a";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   369
by (etac (wf_trancl RS wftrec RS ssubst) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   370
by (rtac trans_trancl 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   371
by (rtac (refl RS H_cong) 1);    (*expose the equality of cuts*)
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   372
by (simp_tac (HOL_ss addsimps [cuts_eq, cut_apply, r_into_trancl]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   373
qed "wfrec";
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   374
---------------------------------------------------------------------------*)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   375
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   376
(*---------------------------------------------------------------------------
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   377
 * This form avoids giant explosions in proofs.  NOTE USE OF == 
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   378
 *---------------------------------------------------------------------------*)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   379
val rew::prems = goal WF.thy
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   380
    "[| f==wfrec r H;  wf(r) |] ==> f(a) = H (cut f r a) a";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   381
by (rewtac rew);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   382
by (REPEAT (resolve_tac (prems@[wfrec]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   383
qed "def_wfrec";
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
   384
3198
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
   385
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
   386
(**** TFL variants ****)
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
   387
5278
a903b66822e2 even more tidying of Goal commands
paulson
parents: 5148
diff changeset
   388
Goal "!R. wf R --> (!P. (!x. (!y. (y,x):R --> P y) --> P x) --> (!x. P x))";
3708
56facaebf3e3 Changed some proofs to use Clarify_tac
paulson
parents: 3457
diff changeset
   389
by (Clarify_tac 1);
3198
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
   390
by (res_inst_tac [("r","R"),("P","P"), ("a","x")] wf_induct 1);
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
   391
by (assume_tac 1);
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
   392
by (Blast_tac 1);
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
   393
qed"tfl_wf_induct";
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
   394
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4821
diff changeset
   395
Goal "!f R. (x,a):R --> (cut f R a)(x) = f(x)";
3708
56facaebf3e3 Changed some proofs to use Clarify_tac
paulson
parents: 3457
diff changeset
   396
by (Clarify_tac 1);
3198
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
   397
by (rtac cut_apply 1);
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
   398
by (assume_tac 1);
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
   399
qed"tfl_cut_apply";
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
   400
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4821
diff changeset
   401
Goal "!M R f. (f=wfrec R M) --> wf R --> (!x. f x = M (cut f R x) x)";
3708
56facaebf3e3 Changed some proofs to use Clarify_tac
paulson
parents: 3457
diff changeset
   402
by (Clarify_tac 1);
4153
e534c4c32d54 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4089
diff changeset
   403
by (etac wfrec 1);
3198
295287618e30 New proofs for TFL
paulson
parents: 2935
diff changeset
   404
qed "tfl_wfrec";