QuotMain.thy
changeset 168 c1e76f09db70
parent 165 2c83d04262f9
child 170 22cd68da9ae4
equal deleted inserted replaced
167:3413aa899aa7 168:c1e76f09db70
     1 theory QuotMain
     1 theory QuotMain
     2 imports QuotScript QuotList Prove
     2 imports QuotScript QuotList Prove
     3 uses ("quotient.ML")
     3 uses ("quotient.ML")
     4 begin
     4 begin
     5 
     5 
     6 definition 
     6 ML {* Pretty.writeln *}
     7   EQ_TRUE 
     7 ML {*  LocalTheory.theory_result *}
     8 where
       
     9   "EQ_TRUE X \<equiv> (X = True)"
       
    10 
       
    11 lemma test: "EQ_TRUE ?X"
       
    12   unfolding EQ_TRUE_def
       
    13   by (rule refl)
       
    14 
       
    15 thm test
       
    16 
     8 
    17 locale QUOT_TYPE =
     9 locale QUOT_TYPE =
    18   fixes R :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
    10   fixes R :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
    19   and   Abs :: "('a \<Rightarrow> bool) \<Rightarrow> 'b"
    11   and   Abs :: "('a \<Rightarrow> bool) \<Rightarrow> 'b"
    20   and   Rep :: "'b \<Rightarrow> ('a \<Rightarrow> bool)"
    12   and   Rep :: "'b \<Rightarrow> ('a \<Rightarrow> bool)"
   156 section {* type definition for the quotient type *}
   148 section {* type definition for the quotient type *}
   157 
   149 
   158 use "quotient.ML"
   150 use "quotient.ML"
   159 
   151 
   160 (* mapfuns for some standard types *)
   152 (* mapfuns for some standard types *)
   161 
   153 setup {*
   162 ML {* quotdata_lookup @{theory} *}
   154   maps_update @{type_name "list"} {mapfun = @{const_name "map"},      relfun = @{const_name "LIST_REL"}} #>
   163 setup {* quotdata_update_thy (@{typ nat}, @{typ bool}, @{term "True"})*}
   155   maps_update @{type_name "*"}    {mapfun = @{const_name "prod_fun"}, relfun = @{const_name "prod_rel"}} #>
   164 ML {* quotdata_lookup @{theory} *}
   156   maps_update @{type_name "fun"}  {mapfun = @{const_name "fun_map"},  relfun = @{const_name "FUN_REL"}}
   165 
   157 *}
   166 ML {* print_quotdata @{context} *}
   158 
   167 
   159 
   168 ML {* maps_lookup @{theory} @{type_name list} *}
   160 ML {* maps_lookup @{theory} @{type_name list} *}
   169 
   161 
   170 ML {*
   162 ML {*
   171 val no_vars = Thm.rule_attribute (fn context => fn th =>
   163 val no_vars = Thm.rule_attribute (fn context => fn th =>
   214     val ftys = map (op -->) tys
   206     val ftys = map (op -->) tys
   215   in
   207   in
   216     (list_comb (Const (@{const_name "fun_map"}, ftys ---> oty --> nty), fs), (oty, nty))
   208     (list_comb (Const (@{const_name "fun_map"}, ftys ---> oty --> nty), fs), (oty, nty))
   217   end
   209   end
   218 
   210 
   219   val thy = ProofContext.theory_of lthy
   211   fun get_const absF = (Const ("FSet.ABS_" ^ qty_name, rty --> qty), (rty, qty))
   220 
   212     | get_const repF = (Const ("FSet.REP_" ^ qty_name, qty --> rty), (qty, rty))
   221   fun get_const absF = (Const (Sign.full_bname thy ("ABS_" ^ qty_name), rty --> qty), (rty, qty))
       
   222     | get_const repF = (Const (Sign.full_bname thy ("REP_" ^ qty_name), qty --> rty), (qty, rty))
       
   223 
   213 
   224   fun mk_identity ty = Abs ("", ty, Bound 0)
   214   fun mk_identity ty = Abs ("", ty, Bound 0)
   225 
   215 
   226 in
   216 in
   227   if ty = qty
   217   if ty = qty