src/HOL/Datatype.ML
author wenzelm
Thu Jun 22 23:04:34 2000 +0200 (2000-06-22)
changeset 9108 9fff97d29837
parent 7293 959e060f4a2f
child 11954 3d1780208bf3
permissions -rw-r--r--
bind_thm(s);
berghofe@7293
     1
(*  Title:      HOL/Datatype.ML
berghofe@7293
     2
    ID:         $Id$
berghofe@7293
     3
    Author:     Stefan Berghofer
berghofe@7293
     4
    Copyright   1999  TU Muenchen
berghofe@7293
     5
*)
berghofe@7293
     6
berghofe@7293
     7
(** sum_case -- the selection operator for sums **)
berghofe@7293
     8
berghofe@7293
     9
(*compatibility*)
berghofe@7293
    10
val [sum_case_Inl, sum_case_Inr] = sum.cases;
wenzelm@9108
    11
bind_thm ("sum_case_Inl", sum_case_Inl);
wenzelm@9108
    12
bind_thm ("sum_case_Inr", sum_case_Inr);
berghofe@7293
    13
berghofe@7293
    14
Goal "sum_case (%x::'a. f(Inl x)) (%y::'b. f(Inr y)) s = f(s)";
berghofe@7293
    15
by (EVERY1 [res_inst_tac [("s","s")] sumE, 
berghofe@7293
    16
            etac ssubst, rtac sum_case_Inl,
berghofe@7293
    17
            etac ssubst, rtac sum_case_Inr]);
berghofe@7293
    18
qed "surjective_sum";
berghofe@7293
    19
berghofe@7293
    20
(*Prevents simplification of f and g: much faster*)
berghofe@7293
    21
Goal "s=t ==> sum_case f g s = sum_case f g t";
berghofe@7293
    22
by (etac arg_cong 1);
berghofe@7293
    23
qed "sum_case_weak_cong";
berghofe@7293
    24
berghofe@7293
    25
val [p1,p2] = Goal
berghofe@7293
    26
  "[| sum_case f1 f2 = sum_case g1 g2;  \
berghofe@7293
    27
\     [| f1 = g1; f2 = g2 |] ==> P |] \
berghofe@7293
    28
\  ==> P";
berghofe@7293
    29
by (rtac p2 1);
berghofe@7293
    30
by (rtac ext 1);
berghofe@7293
    31
by (cut_inst_tac [("x","Inl x")] (p1 RS fun_cong) 1);
berghofe@7293
    32
by (Asm_full_simp_tac 1);
berghofe@7293
    33
by (rtac ext 1);
berghofe@7293
    34
by (cut_inst_tac [("x","Inr x")] (p1 RS fun_cong) 1);
berghofe@7293
    35
by (Asm_full_simp_tac 1);
berghofe@7293
    36
qed "sum_case_inject";