src/HOL/Quotient_Examples/Lift_Set.thy
author bulwahn
Fri, 18 Nov 2011 13:42:07 +0100
changeset 46447 6ea2bba2694a
parent 46407 5b0b1dc2e40f
child 46480 2c0c8ce96f4a
permissions -rw-r--r--
improving header
     1 (*  Title:      HOL/Quotient_Examples/Lift_Set.thy
     2     Author:     Lukas Bulwahn and Ondrey Kuncar
     3 *)
     4 
     5 header {* Example of lifting definitions with the quotient infrastructure *}
     6 
     7 theory Lift_Set
     8 imports Main
     9 begin
    10 
    11 typedef 'a set = "(UNIV :: ('a => bool) => bool)"
    12 morphisms member Set by auto
    13 
    14 text {* Here is some ML setup that should eventually be incorporated in the typedef command. *}
    15 
    16 local_setup {* fn lthy =>
    17 let
    18   val quotients = {qtyp = @{typ "'a set"}, rtyp = @{typ "'a => bool"}, equiv_rel = @{term "dummy"}, equiv_thm = @{thm refl}}
    19   val qty_full_name = @{type_name "set"}
    20 
    21   fun qinfo phi = Quotient_Info.transform_quotients phi quotients
    22   in lthy
    23     |> Local_Theory.declaration {syntax = false, pervasive = true}
    24         (fn phi => Quotient_Info.update_quotients qty_full_name (qinfo phi)
    25        #> Quotient_Info.update_abs_rep qty_full_name (Quotient_Info.transform_abs_rep phi {abs = @{term "Set"}, rep = @{term "member"}}))
    26   end
    27 *}
    28 
    29 text {* Now, we can employ quotient_definition to lift definitions. *}
    30 
    31 quotient_definition empty where "empty :: 'a set"
    32 is "Set.empty"
    33 
    34 term "Lift_Set.empty"
    35 thm Lift_Set.empty_def
    36 
    37 quotient_definition insert where "insert :: 'a => 'a set => 'a set"
    38 is "Set.insert"
    39 
    40 term "Lift_Set.insert"
    41 thm Lift_Set.insert_def
    42 
    43 end