src/HOL/Fun.thy
author paulson
Wed Feb 03 13:26:07 1999 +0100 (1999-02-03)
changeset 6171 cd237a10cbf8
parent 5852 4d7320490be4
child 7374 dec7b838f5cb
permissions -rw-r--r--
inj is now a translation of inj_on
     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 nonterminals
    14   updbinds  updbind
    15 
    16 consts
    17   fun_upd  :: "('a => 'b) => 'a => 'b => ('a => 'b)"
    18 
    19 syntax
    20 
    21   (* Let expressions *)
    22 
    23   "_updbind"       :: ['a, 'a] => updbind             ("(2_ :=/ _)")
    24   ""               :: updbind => updbinds             ("_")
    25   "_updbinds"      :: [updbind, updbinds] => updbinds ("_,/ _")
    26   "_Update"        :: ['a, updbinds] => 'a            ("_/'((_)')" [900,0] 900)
    27 
    28 translations
    29   "_Update f (_updbinds b bs)"  == "_Update (_Update f b) bs"
    30   "f(x:=y)"                     == "fun_upd f x y"
    31 
    32 defs
    33   fun_upd_def "f(a:=b) == % x. if x=a then b else f x"
    34 
    35   
    36 constdefs
    37   id ::  'a => 'a
    38     "id == %x. x"
    39 
    40   o  :: ['b => 'c, 'a => 'b, 'a] => 'c   (infixl 55)
    41     "f o g == %x. f(g(x))"
    42 
    43   inj_on :: ['a => 'b, 'a set] => bool
    44     "inj_on f A == ! x:A. ! y:A. f(x)=f(y) --> x=y"
    45 
    46   surj :: ('a => 'b) => bool                   (*surjective*)
    47     "surj f == ! y. ? x. y=f(x)"
    48   
    49   inv :: ('a => 'b) => ('b => 'a)
    50     "inv(f::'a=>'b) == % y. @x. f(x)=y"
    51   
    52 
    53 
    54 syntax
    55   inj   :: ('a => 'b) => bool                   (*injective*)
    56 
    57 translations
    58   "inj f" == "inj_on f UNIV"
    59 
    60 (*The Pi-operator, by Florian Kammueller*)
    61   
    62 constdefs
    63   Pi      :: "['a set, 'a => 'b set] => ('a => 'b) set"
    64     "Pi A B == {f. ! x. if x:A then f(x) : B(x) else f(x) = (@ y. True)}"
    65 
    66   restrict :: "['a => 'b, 'a set] => ('a => 'b)"
    67     "restrict f A == (%x. if x : A then f x else (@ y. True))"
    68 
    69 syntax
    70   "@Pi"  :: "[idt, 'a set, 'b set] => ('a => 'b) set"  ("(3PI _:_./ _)" 10)
    71   funcset :: "['a set, 'b set] => ('a => 'b) set"      (infixr 60) 
    72   "@lam" :: "[pttrn, 'a set, 'a => 'b] => ('a => 'b)"  ("(3lam _:_./ _)" 10)
    73 
    74   (*Giving funcset the nice arrow syntax -> clashes with existing theories*)
    75 
    76 translations
    77   "PI x:A. B" => "Pi A (%x. B)"
    78   "A funcset B"    => "Pi A (_K B)"
    79   "lam x:A. f"  == "restrict (%x. f) A"
    80 
    81 constdefs
    82   Applyall :: "[('a => 'b) set, 'a]=> 'b set"
    83     "Applyall F a == (%f. f a) `` F"
    84 
    85   compose :: "['a set, 'a => 'b, 'b => 'c] => ('a => 'c)"
    86     "compose A g f == lam x : A. g(f x)"
    87 
    88   Inv    :: "['a set, 'a => 'b] => ('b => 'a)"
    89     "Inv A f == (% x. (@ y. y : A & f y = x))"
    90 
    91   
    92 end
    93 
    94 ML
    95 val print_translation = [("Pi", dependent_tr' ("@Pi", "op funcset"))];