src/HOL/Relation.ML
changeset 1454 d0266c81a85e
parent 1264 3eb91524b938
child 1465 5d7a7e439cec
equal deleted inserted replaced
1453:a4896058a47e 1454:d0266c81a85e
    33 
    33 
    34 (** Composition of two relations **)
    34 (** Composition of two relations **)
    35 
    35 
    36 val prems = goalw Relation.thy [comp_def]
    36 val prems = goalw Relation.thy [comp_def]
    37     "[| (a,b):s; (b,c):r |] ==> (a,c) : r O s";
    37     "[| (a,b):s; (b,c):r |] ==> (a,c) : r O s";
    38 by (fast_tac (set_cs addIs prems) 1);
    38 by (fast_tac (prod_cs addIs prems) 1);
    39 qed "compI";
    39 qed "compI";
    40 
    40 
    41 (*proof requires higher-level assumptions or a delaying of hyp_subst_tac*)
    41 (*proof requires higher-level assumptions or a delaying of hyp_subst_tac*)
    42 val prems = goalw Relation.thy [comp_def]
    42 val prems = goalw Relation.thy [comp_def]
    43     "[| xz : r O s;  \
    43     "[| xz : r O s;  \
    44 \       !!x y z. [| xz = (x,z);  (x,y):s;  (y,z):r |] ==> P \
    44 \       !!x y z. [| xz = (x,z);  (x,y):s;  (y,z):r |] ==> P \
    45 \    |] ==> P";
    45 \    |] ==> P";
    46 by (cut_facts_tac prems 1);
    46 by (cut_facts_tac prems 1);
    47 by (REPEAT (eresolve_tac [CollectE, exE, conjE] 1 ORELSE ares_tac prems 1));
    47 by (REPEAT (eresolve_tac [CollectE, splitE, exE, conjE] 1 ORELSE ares_tac prems 1));
    48 qed "compE";
    48 qed "compE";
    49 
    49 
    50 val prems = goal Relation.thy
    50 val prems = goal Relation.thy
    51     "[| (a,c) : r O s;  \
    51     "[| (a,c) : r O s;  \
    52 \       !!y. [| (a,y):s;  (y,c):r |] ==> P \
    52 \       !!y. [| (a,y):s;  (y,c):r |] ==> P \
    82 
    82 
    83 (** Natural deduction for converse(r) **)
    83 (** Natural deduction for converse(r) **)
    84 
    84 
    85 goalw Relation.thy [converse_def] "!!a b r. (a,b):r ==> (b,a):converse(r)";
    85 goalw Relation.thy [converse_def] "!!a b r. (a,b):r ==> (b,a):converse(r)";
    86 by (Simp_tac 1);
    86 by (Simp_tac 1);
    87 by (fast_tac set_cs 1);
       
    88 qed "converseI";
    87 qed "converseI";
    89 
    88 
    90 goalw Relation.thy [converse_def] "!!a b r. (a,b) : converse(r) ==> (b,a) : r";
    89 goalw Relation.thy [converse_def] "!!a b r. (a,b) : converse(r) ==> (b,a) : r";
    91 by (fast_tac comp_cs 1);
    90 by (fast_tac comp_cs 1);
    92 qed "converseD";
    91 qed "converseD";
    95     "[| yx : converse(r);  \
    94     "[| yx : converse(r);  \
    96 \       !!x y. [| yx=(y,x);  (x,y):r |] ==> P \
    95 \       !!x y. [| yx=(y,x);  (x,y):r |] ==> P \
    97 \    |] ==> P"
    96 \    |] ==> P"
    98  (fn [major,minor]=>
    97  (fn [major,minor]=>
    99   [ (rtac (major RS CollectE) 1),
    98   [ (rtac (major RS CollectE) 1),
   100     (REPEAT (eresolve_tac [bexE,exE, conjE, minor] 1)),
    99     (REPEAT (eresolve_tac [splitE, bexE,exE, conjE, minor] 1)),
   101     (hyp_subst_tac 1),
       
   102     (assume_tac 1) ]);
   100     (assume_tac 1) ]);
   103 
   101 
   104 val converse_cs = comp_cs addSIs [converseI] 
   102 val converse_cs = comp_cs addSIs [converseI] 
   105 			  addSEs [converseD,converseE];
   103 			  addSEs [converseD,converseE];
   106 
   104