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