src/HOL/ex/rel.ML
author berghofe
Fri, 21 Jun 1996 12:18:50 +0200
changeset 1820 e381e1c51689
parent 1465 5d7a7e439cec
child 4089 96fba19bcbe2
permissions -rw-r--r--
Classical tactics now use default claset.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1465
5d7a7e439cec expanded tabs
clasohm
parents: 972
diff changeset
     1
(*  Title:      HOL/ex/rel
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1465
5d7a7e439cec expanded tabs
clasohm
parents: 972
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1991  University of Cambridge
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     5
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     6
Domain, range of a relation or function -- NOT YET WORKING
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     7
*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     8
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     9
structure Rel =
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    10
struct
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    11
val thy = extend_theory Univ.thy "Rel"
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    12
([], [], [], [],
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    13
 [ 
1465
5d7a7e439cec expanded tabs
clasohm
parents: 972
diff changeset
    14
  (["domain"],  "('a * 'b)set => 'a set"),
5d7a7e439cec expanded tabs
clasohm
parents: 972
diff changeset
    15
  (["range2"],  "('a * 'b)set => 'b set"),
5d7a7e439cec expanded tabs
clasohm
parents: 972
diff changeset
    16
  (["field"],   "('a * 'a)set => 'a set")
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    17
 ],
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    18
 None)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    19
 [
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 969
diff changeset
    20
  ("domain_def",     "domain(r) == {a. ? b. (a,b) : r}" ),
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 969
diff changeset
    21
  ("range2_def",     "range2(r) == {b. ? a. (a,b) : r}" ),
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    22
  ("field_def",      "field(r)  == domain(r) Un range2(r)" )
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    23
 ];
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    24
end;
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    25
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    26
local val ax = get_axiom Rel.thy
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    27
in
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    28
val domain_def = ax"domain_def";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    29
val range2_def = ax"range2_def";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    30
val field_def = ax"field_def";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    31
end;
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    32
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    33
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    34
(*** domain ***)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    35
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 969
diff changeset
    36
val [prem] = goalw Rel.thy [domain_def,Pair_def] "(a,b): r ==> a : domain(r)";
1820
e381e1c51689 Classical tactics now use default claset.
berghofe
parents: 1465
diff changeset
    37
by (fast_tac (!claset addIs [prem]) 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    38
qed "domainI";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    39
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    40
val major::prems = goalw Rel.thy [domain_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 969
diff changeset
    41
    "[| a : domain(r);  !!y. (a,y): r ==> P |] ==> P";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    42
by (rtac (major RS CollectE) 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    43
by (etac exE 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    44
by (REPEAT (ares_tac prems 1));
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    45
qed "domainE";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    46
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    47
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    48
(*** range2 ***)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    49
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 969
diff changeset
    50
val [prem] = goalw Rel.thy [range2_def,Pair_def] "(a,b): r ==> b : range2(r)";
1820
e381e1c51689 Classical tactics now use default claset.
berghofe
parents: 1465
diff changeset
    51
by (fast_tac (!claset addIs [prem]) 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    52
qed "range2I";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    53
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    54
val major::prems = goalw Rel.thy [range2_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 969
diff changeset
    55
    "[| b : range2(r);  !!x. (x,b): r ==> P |] ==> P";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    56
by (rtac (major RS CollectE) 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    57
by (etac exE 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    58
by (REPEAT (ares_tac prems 1));
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    59
qed "range2E";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    60
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    61
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    62
(*** field ***)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    63
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 969
diff changeset
    64
val [prem] = goalw Rel.thy [field_def] "(a,b): r ==> a : field(r)";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    65
by (rtac (prem RS domainI RS UnI1) 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    66
qed "fieldI1";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    67
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 969
diff changeset
    68
val [prem] = goalw Rel.thy [field_def] "(a,b): r ==> b : field(r)";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    69
by (rtac (prem RS range2I RS UnI2) 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    70
qed "fieldI2";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    71
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    72
val [prem] = goalw Rel.thy [field_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 969
diff changeset
    73
    "(~ (c,a):r ==> (a,b): r) ==> a : field(r)";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    74
by (rtac (prem RS domainI RS UnCI) 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    75
by (swap_res_tac [range2I] 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    76
by (etac notnotD 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    77
qed "fieldCI";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    78
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    79
val major::prems = goalw Rel.thy [field_def]
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    80
     "[| a : field(r);  \
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 969
diff changeset
    81
\        !!x. (a,x): r ==> P;  \
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 969
diff changeset
    82
\        !!x. (x,a): r ==> P        |] ==> P";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    83
by (rtac (major RS UnE) 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    84
by (REPEAT (eresolve_tac (prems@[domainE,range2E]) 1));
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    85
qed "fieldE";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    86
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    87
goalw Rel.thy [field_def] "domain(r) <= field(r)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    88
by (rtac Un_upper1 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    89
qed "domain_in_field";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    90
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    91
goalw Rel.thy [field_def] "range2(r) <= field(r)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    92
by (rtac Un_upper2 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    93
qed "range2_in_field";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    94
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    95
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    96
????????????????????????????????????????????????????????????????;
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    97
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    98
(*If r allows well-founded induction then wf(r)*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    99
val [prem1,prem2] = goalw Rel.thy [wf_def] 
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   100
    "[| field(r)<=A;  \
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 969
diff changeset
   101
\       !!P u. ! x:A. (! y. (y,x): r --> P(y)) --> P(x) ==> P(u) |]  \
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   102
\    ==>  wf(r)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   103
by (rtac (prem1 RS wfI) 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   104
by (res_inst_tac [ ("B", "A-Z") ] (prem2 RS subsetCE) 1);
1820
e381e1c51689 Classical tactics now use default claset.
berghofe
parents: 1465
diff changeset
   105
by (Fast_tac 3);
e381e1c51689 Classical tactics now use default claset.
berghofe
parents: 1465
diff changeset
   106
by (Fast_tac 2);
e381e1c51689 Classical tactics now use default claset.
berghofe
parents: 1465
diff changeset
   107
by (Fast_tac 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   108
qed "wfI2";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   109