src/HOL/Fun.thy
author wenzelm
Thu Jul 13 23:08:42 2000 +0200 (2000-07-13)
changeset 9309 4078d5e8b293
parent 9141 49f6e45e7199
child 9340 9666f78ecfab
permissions -rw-r--r--
fixed compose decl;
     1 (*  Title:      HOL/Fun.thy
     2     ID:         $Id$
     3     Author:     Tobias Nipkow, Cambridge University Computer Laboratory
     4     Copyright   1994  University of Cambridge
     5 
     6 Notions about functions.
     7 *)
     8 
     9 Fun = Vimage + equalities + 
    10 
    11 instance set :: (term) order
    12                        (subset_refl,subset_trans,subset_antisym,psubset_eq)
    13 consts
    14   fun_upd  :: "('a => 'b) => 'a => 'b => ('a => 'b)"
    15 
    16 nonterminals
    17   updbinds updbind
    18 syntax
    19   "_updbind"       :: ['a, 'a] => updbind             ("(2_ :=/ _)")
    20   ""               :: updbind => updbinds             ("_")
    21   "_updbinds"      :: [updbind, updbinds] => updbinds ("_,/ _")
    22   "_Update"        :: ['a, updbinds] => 'a            ("_/'((_)')" [1000,0] 900)
    23 
    24 translations
    25   "_Update f (_updbinds b bs)"  == "_Update (_Update f b) bs"
    26   "f(x:=y)"                     == "fun_upd f x y"
    27 
    28 defs
    29   fun_upd_def "f(a:=b) == % x. if x=a then b else f x"
    30 
    31   
    32 constdefs
    33   id ::  'a => 'a
    34     "id == %x. x"
    35 
    36   o  :: ['b => 'c, 'a => 'b, 'a] => 'c   (infixl 55)
    37     "f o g == %x. f(g(x))"
    38   
    39   inv :: ('a => 'b) => ('b => 'a)
    40     "inv(f::'a=>'b) == % y. @x. f(x)=y"
    41 
    42   inj_on :: ['a => 'b, 'a set] => bool
    43     "inj_on f A == ! x:A. ! y:A. f(x)=f(y) --> x=y"
    44 
    45 syntax
    46   inj   :: ('a => 'b) => bool                   (*injective*)
    47 
    48 translations
    49   "inj f" == "inj_on f UNIV"
    50 
    51 constdefs
    52   surj :: ('a => 'b) => bool                   (*surjective*)
    53     "surj f == ! y. ? x. y=f(x)"
    54   
    55   bij :: ('a => 'b) => bool                    (*bijective*)
    56     "bij f == inj f & surj f"
    57   
    58 
    59 (*The Pi-operator, by Florian Kammueller*)
    60   
    61 constdefs
    62   Pi      :: "['a set, 'a => 'b set] => ('a => 'b) set"
    63     "Pi A B == {f. ! x. if x:A then f(x) : B(x) else f(x) = (@ y. True)}"
    64 
    65   restrict :: "['a => 'b, 'a set] => ('a => 'b)"
    66     "restrict f A == (%x. if x : A then f x else (@ y. True))"
    67 
    68 syntax
    69   "@Pi"  :: "[idt, 'a set, 'b set] => ('a => 'b) set"  ("(3PI _:_./ _)" 10)
    70   funcset :: "['a set, 'b set] => ('a => 'b) set"      (infixr 60) 
    71   "@lam" :: "[pttrn, 'a set, 'a => 'b] => ('a => 'b)"  ("(3lam _:_./ _)" 10)
    72 
    73   (*Giving funcset the nice arrow syntax -> clashes with existing theories*)
    74 
    75 translations
    76   "PI x:A. B" => "Pi A (%x. B)"
    77   "A funcset B"    => "Pi A (_K B)"
    78   "lam x:A. f"  == "restrict (%x. f) A"
    79 
    80 constdefs
    81   Applyall :: "[('a => 'b) set, 'a]=> 'b set"
    82     "Applyall F a == (%f. f a) `` F"
    83 
    84   compose :: "['a set, 'b => 'c, 'a => 'b] => ('a => 'c)"
    85     "compose A g f == lam x : A. g(f x)"
    86 
    87   Inv    :: "['a set, 'a => 'b] => ('b => 'a)"
    88     "Inv A f == (% x. (@ y. y : A & f y = x))"
    89 
    90   
    91 end
    92 
    93 ML
    94 val print_translation = [("Pi", dependent_tr' ("@Pi", "op funcset"))];