src/HOL/WF.ML
author paulson
Thu, 10 Oct 1996 11:09:03 +0200
changeset 2085 bcc9cbed10b1
parent 2031 03a843f0f447
child 2637 e9b203f854ae
permissions -rw-r--r--
Removed LK since Sequents contains everything in it
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
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
     6
For WF.thy.  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)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    19
by (strip_tac 1);
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);
1786
8a31d85d27b8 best_tac, deepen_tac and safe_tac now also use default claset.
berghofe
parents: 1771
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);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1642
diff changeset
    30
by (fast_tac (!claset addEs 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);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1642
diff changeset
    41
by (fast_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);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1642
diff changeset
    43
by (Fast_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);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    54
by (strip_tac 1);
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);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1642
diff changeset
    61
by (Fast_tac 1);
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1642
diff changeset
    62
by (Fast_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
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    66
(** cut **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    67
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    68
(*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
    69
  H_cong to expose the equality*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    70
goalw WF.thy [cut_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 950
diff changeset
    71
    "(cut f r x = cut g r x) = (!y. (y,x):r --> f(y)=g(y))";
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1485
diff changeset
    72
by (simp_tac (HOL_ss addsimps [expand_fun_eq]
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
    73
                    setloop (split_tac [expand_if])) 1);
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset
    74
qed "cuts_eq";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    75
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 950
diff changeset
    76
goalw WF.thy [cut_def] "!!x. (x,a):r ==> (cut f r a)(x) = f(x)";
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1485
diff changeset
    77
by (asm_simp_tac HOL_ss 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    78
qed "cut_apply";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    79
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    80
(*** is_recfun ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    81
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    82
goalw WF.thy [is_recfun_def,cut_def]
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1465
diff changeset