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