Theory SortConstants
text‹Constants for encoding class/sort constraints in term language›
theory SortConstants
imports Sorts
begin
fun dest_type :: "term ⇒ typ option" where
"dest_type (Ct nc (Ty nt [ty])) =
(if nc = STR ''Pure.type'' ∧ nt = STR ''Pure.type'' then Some ty else None)"
| "dest_type t = None"
definition "type_map f t = map_option (λty. mk_type (f ty)) (dest_type t)"
consts unsuffix :: "name ⇒ name ⇒ name option"
abbreviation "class_of_const c ≡ (unsuffix classN c)"
fun dest_of_class :: "term ⇒ (typ * class) option" where
"dest_of_class (Ct c_class _ $ ty) = lift2_option Pair (dest_type ty) (class_of_const c_class)"
| "dest_of_class _ = None"
definition "mk_of_sort ty S == map (λc . mk_of_class ty c) S"
end