src/HOL/Typedef.thy
author wenzelm
Wed Jul 24 22:15:55 2002 +0200 (2002-07-24)
changeset 13421 8fcdf4a26468
parent 13412 666137b488a4
child 15131 c69542757a4d
permissions -rw-r--r--
simplified locale predicates;
     1 (*  Title:      HOL/Typedef.thy
     2     ID:         $Id$
     3     Author:     Markus Wenzel, TU Munich
     4 *)
     5 
     6 header {* HOL type definitions *}
     7 
     8 theory Typedef = Set
     9 files ("Tools/typedef_package.ML"):
    10 
    11 locale type_definition =
    12   fixes Rep and Abs and A
    13   assumes Rep: "Rep x \<in> A"
    14     and Rep_inverse: "Abs (Rep x) = x"
    15     and Abs_inverse: "y \<in> A ==> Rep (Abs y) = y"
    16   -- {* This will be axiomatized for each typedef! *}
    17 
    18 lemma (in type_definition) Rep_inject:
    19   "(Rep x = Rep y) = (x = y)"
    20 proof
    21   assume "Rep x = Rep y"
    22   hence "Abs (Rep x) = Abs (Rep y)" by (simp only:)
    23   also have "Abs (Rep x) = x" by (rule Rep_inverse)
    24   also have "Abs (Rep y) = y" by (rule Rep_inverse)
    25   finally show "x = y" .
    26 next
    27   assume "x = y"
    28   thus "Rep x = Rep y" by (simp only:)
    29 qed
    30 
    31 lemma (in type_definition) Abs_inject:
    32   assumes x: "x \<in> A" and y: "y \<in> A"
    33   shows "(Abs x = Abs y) = (x = y)"
    34 proof
    35   assume "Abs x = Abs y"
    36   hence "Rep (Abs x) = Rep (Abs y)" by (simp only:)
    37   also from x have "Rep (Abs x) = x" by (rule Abs_inverse)
    38   also from y have "Rep (Abs y) = y" by (rule Abs_inverse)
    39   finally show "x = y" .
    40 next
    41   assume "x = y"
    42   thus "Abs x = Abs y" by (simp only:)
    43 qed
    44 
    45 lemma (in type_definition) Rep_cases [cases set]:
    46   assumes y: "y \<in> A"
    47     and hyp: "!!x. y = Rep x ==> P"
    48   shows P
    49 proof (rule hyp)
    50   from y have "Rep (Abs y) = y" by (rule Abs_inverse)
    51   thus "y = Rep (Abs y)" ..
    52 qed
    53 
    54 lemma (in type_definition) Abs_cases [cases type]:
    55   assumes r: "!!y. x = Abs y ==> y \<in> A ==> P"
    56   shows P
    57 proof (rule r)
    58   have "Abs (Rep x) = x" by (rule Rep_inverse)
    59   thus "x = Abs (Rep x)" ..
    60   show "Rep x \<in> A" by (rule Rep)
    61 qed
    62 
    63 lemma (in type_definition) Rep_induct [induct set]:
    64   assumes y: "y \<in> A"
    65     and hyp: "!!x. P (Rep x)"
    66   shows "P y"
    67 proof -
    68   have "P (Rep (Abs y))" by (rule hyp)
    69   also from y have "Rep (Abs y) = y" by (rule Abs_inverse)
    70   finally show "P y" .
    71 qed
    72 
    73 lemma (in type_definition) Abs_induct [induct type]:
    74   assumes r: "!!y. y \<in> A ==> P (Abs y)"
    75   shows "P x"
    76 proof -
    77   have "Rep x \<in> A" by (rule Rep)
    78   hence "P (Abs (Rep x))" by (rule r)
    79   also have "Abs (Rep x) = x" by (rule Rep_inverse)
    80   finally show "P x" .
    81 qed
    82 
    83 use "Tools/typedef_package.ML"
    84 
    85 end