equal
deleted
inserted
replaced
67 infixr 6 ->> |
67 infixr 6 ->> |
68 infixr -->> |
68 infixr -->> |
69 |
69 |
70 val udomT = @{typ udom} |
70 val udomT = @{typ udom} |
71 val deflT = @{typ "udom defl"} |
71 val deflT = @{typ "udom defl"} |
|
72 val udeflT = @{typ "udom u defl"} |
72 |
73 |
73 fun mk_DEFL T = |
74 fun mk_DEFL T = |
74 Const (@{const_name defl}, Term.itselfT T --> deflT) $ Logic.mk_type T |
75 Const (@{const_name defl}, Term.itselfT T --> deflT) $ Logic.mk_type T |
75 |
76 |
76 fun dest_DEFL (Const (@{const_name defl}, _) $ t) = Logic.dest_type t |
77 fun dest_DEFL (Const (@{const_name defl}, _) $ t) = Logic.dest_type t |
77 | dest_DEFL t = raise TERM ("dest_DEFL", [t]) |
78 | dest_DEFL t = raise TERM ("dest_DEFL", [t]) |
78 |
79 |
79 fun mk_LIFTDEFL T = |
80 fun mk_LIFTDEFL T = |
80 Const (@{const_name liftdefl}, Term.itselfT T --> deflT) $ Logic.mk_type T |
81 Const (@{const_name liftdefl}, Term.itselfT T --> udeflT) $ Logic.mk_type T |
81 |
82 |
82 fun dest_LIFTDEFL (Const (@{const_name liftdefl}, _) $ t) = Logic.dest_type t |
83 fun dest_LIFTDEFL (Const (@{const_name liftdefl}, _) $ t) = Logic.dest_type t |
83 | dest_LIFTDEFL t = raise TERM ("dest_LIFTDEFL", [t]) |
84 | dest_LIFTDEFL t = raise TERM ("dest_LIFTDEFL", [t]) |
84 |
85 |
85 fun mk_u_defl t = mk_capply (@{const "u_defl"}, t) |
86 fun mk_u_defl t = mk_capply (@{const "u_defl"}, t) |
97 fun prj_const T = Const (@{const_name prj}, udomT ->> T) |
98 fun prj_const T = Const (@{const_name prj}, udomT ->> T) |
98 fun coerce_const (T, U) = mk_cfcomp (prj_const U, emb_const T) |
99 fun coerce_const (T, U) = mk_cfcomp (prj_const U, emb_const T) |
99 |
100 |
100 fun isodefl_const T = |
101 fun isodefl_const T = |
101 Const (@{const_name isodefl}, (T ->> T) --> deflT --> HOLogic.boolT) |
102 Const (@{const_name isodefl}, (T ->> T) --> deflT --> HOLogic.boolT) |
|
103 |
|
104 fun isodefl'_const T = |
|
105 Const (@{const_name isodefl'}, (T ->> T) --> udeflT --> HOLogic.boolT) |
102 |
106 |
103 fun mk_deflation t = |
107 fun mk_deflation t = |
104 Const (@{const_name deflation}, Term.fastype_of t --> boolT) $ t |
108 Const (@{const_name deflation}, Term.fastype_of t --> boolT) $ t |
105 |
109 |
106 (* splits a cterm into the right and lefthand sides of equality *) |
110 (* splits a cterm into the right and lefthand sides of equality *) |
216 (case dest_DEFL t of |
220 (case dest_DEFL t of |
217 TFree (a, _) => SOME (Free ("d" ^ Library.unprefix "'" a, deflT)) |
221 TFree (a, _) => SOME (Free ("d" ^ Library.unprefix "'" a, deflT)) |
218 | _ => NONE) handle TERM _ => NONE |
222 | _ => NONE) handle TERM _ => NONE |
219 fun proc2 t = |
223 fun proc2 t = |
220 (case dest_LIFTDEFL t of |
224 (case dest_LIFTDEFL t of |
221 TFree (a, _) => SOME (Free ("p" ^ Library.unprefix "'" a, deflT)) |
225 TFree (a, _) => SOME (Free ("p" ^ Library.unprefix "'" a, udeflT)) |
222 | _ => NONE) handle TERM _ => NONE |
226 | _ => NONE) handle TERM _ => NONE |
223 in |
227 in |
224 Pattern.rewrite_term thy (rules @ rules') [proc1, proc2] (mk_DEFL T) |
228 Pattern.rewrite_term thy (rules @ rules') [proc1, proc2] (mk_DEFL T) |
225 end |
229 end |
226 |
230 |
490 (* declare deflation combinator constants *) |
494 (* declare deflation combinator constants *) |
491 fun declare_defl_const ((typeTs, defl_args), (_, tbind, _, _, _)) thy = |
495 fun declare_defl_const ((typeTs, defl_args), (_, tbind, _, _, _)) thy = |
492 let |
496 let |
493 val defl_bind = Binding.suffix_name "_defl" tbind |
497 val defl_bind = Binding.suffix_name "_defl" tbind |
494 val defl_type = |
498 val defl_type = |
495 map Term.itselfT typeTs ---> map (K deflT) defl_args -->> deflT |
499 map Term.itselfT typeTs ---> map fastype_of defl_args -->> deflT |
496 in |
500 in |
497 Sign.declare_const ((defl_bind, defl_type), NoSyn) thy |
501 Sign.declare_const ((defl_bind, defl_type), NoSyn) thy |
498 end |
502 end |
499 val (defl_consts, thy) = |
503 val (defl_consts, thy) = |
500 fold_map declare_defl_const (defl_flagss ~~ doms) thy |
504 fold_map declare_defl_const (defl_flagss ~~ doms) thy |
612 (* prove isodefl rules for map functions *) |
616 (* prove isodefl rules for map functions *) |
613 val isodefl_thm = |
617 val isodefl_thm = |
614 let |
618 let |
615 fun unprime a = Library.unprefix "'" a |
619 fun unprime a = Library.unprefix "'" a |
616 fun mk_d T = Free ("d" ^ unprime (fst (dest_TFree T)), deflT) |
620 fun mk_d T = Free ("d" ^ unprime (fst (dest_TFree T)), deflT) |
617 fun mk_p T = Free ("p" ^ unprime (fst (dest_TFree T)), deflT) |
621 fun mk_p T = Free ("p" ^ unprime (fst (dest_TFree T)), udeflT) |
618 fun mk_f T = Free ("f" ^ unprime (fst (dest_TFree T)), T ->> T) |
622 fun mk_f T = Free ("f" ^ unprime (fst (dest_TFree T)), T ->> T) |
619 fun mk_assm t = |
623 fun mk_assm t = |
620 case try dest_LIFTDEFL t of |
624 case try dest_LIFTDEFL t of |
621 SOME T => mk_trp (isodefl_const (mk_upT T) $ mk_u_map (mk_f T) $ mk_p T) |
625 SOME T => mk_trp (isodefl'_const T $ mk_f T $ mk_p T) |
622 | NONE => |
626 | NONE => |
623 let val T = dest_DEFL t |
627 let val T = dest_DEFL t |
624 in mk_trp (isodefl_const T $ mk_f T $ mk_d T) end |
628 in mk_trp (isodefl_const T $ mk_f T $ mk_d T) end |
625 fun mk_goal (map_const, (T, rhsT)) = |
629 fun mk_goal (map_const, (T, rhsT)) = |
626 let |
630 let |