src/HOL/Option.thy
changeset 9001 93af64f54bf2
parent 5445 3905974ad555
equal deleted inserted replaced
9000:c20d58286a51 9001:93af64f54bf2
     8 
     8 
     9 Option = Datatype +
     9 Option = Datatype +
    10 
    10 
    11 datatype 'a option = None | Some 'a
    11 datatype 'a option = None | Some 'a
    12 
    12 
       
    13 consts
       
    14   the :: "'a option => 'a"
       
    15   o2s :: "'a option => 'a set"
       
    16 
       
    17 primrec
       
    18  "the (Some x) = x"
       
    19 
       
    20 primrec
       
    21  "o2s  None    = {}"
       
    22  "o2s (Some x) = {x}"
       
    23 
    13 constdefs
    24 constdefs
    14 
       
    15   the		:: "'a option => 'a"
       
    16  "the == %y. case y of None => arbitrary | Some x => x"
       
    17 
       
    18   option_map	:: "('a => 'b) => ('a option => 'b option)"
    25   option_map	:: "('a => 'b) => ('a option => 'b option)"
    19  "option_map == %f y. case y of None => None | Some x => Some (f x)"
    26  "option_map == %f y. case y of None => None | Some x => Some (f x)"
    20 
    27 
    21 consts
       
    22 
       
    23   o2s	   :: "'a option => 'a set"
       
    24 
       
    25 primrec
       
    26 
       
    27  "o2s  None    = {}"
       
    28  "o2s (Some x) = {x}"
       
    29 
       
    30 end
    28 end