src/ZF/Tools/typechk.ML
changeset 13105 3d1e7a199bdc
parent 12311 ce5f9e61c037
child 15090 970c2668c694
equal deleted inserted replaced
13104:df7aac8543c9 13105:3d1e7a199bdc
    44 datatype tcset =
    44 datatype tcset =
    45     TC of {rules: thm list,     (*the type-checking rules*)
    45     TC of {rules: thm list,     (*the type-checking rules*)
    46            net: thm Net.net};   (*discrimination net of the same rules*)
    46            net: thm Net.net};   (*discrimination net of the same rules*)
    47 
    47 
    48 
    48 
    49 val mem_thm = gen_mem eq_thm
    49 val mem_thm = gen_mem Drule.eq_thm_prop
    50 and rem_thm = gen_rem eq_thm;
    50 and rem_thm = gen_rem Drule.eq_thm_prop;
    51 
    51 
    52 fun addTC (cs as TC{rules, net}, th) =
    52 fun addTC (cs as TC{rules, net}, th) =
    53   if mem_thm (th, rules) then
    53   if mem_thm (th, rules) then
    54          (warning ("Ignoring duplicate type-checking rule\n" ^
    54          (warning ("Ignoring duplicate type-checking rule\n" ^
    55                    string_of_thm th);
    55                    string_of_thm th);
    59          net = Net.insert_term ((concl_of th, th), net, K false)};
    59          net = Net.insert_term ((concl_of th, th), net, K false)};
    60 
    60 
    61 
    61 
    62 fun delTC (cs as TC{rules, net}, th) =
    62 fun delTC (cs as TC{rules, net}, th) =
    63   if mem_thm (th, rules) then
    63   if mem_thm (th, rules) then
    64       TC{net = Net.delete_term ((concl_of th, th), net, eq_thm),
    64       TC{net = Net.delete_term ((concl_of th, th), net, Drule.eq_thm_prop),
    65          rules  = rem_thm (rules,th)}
    65          rules  = rem_thm (rules,th)}
    66   else (warning ("No such type-checking rule\n" ^ (string_of_thm th));
    66   else (warning ("No such type-checking rule\n" ^ (string_of_thm th));
    67         cs);
    67         cs);
    68 
    68 
    69 val op addTCs = foldl addTC;
    69 val op addTCs = foldl addTC;
   108                           APPEND typecheck_step_tac tcset)));
   108                           APPEND typecheck_step_tac tcset)));
   109 
   109 
   110 
   110 
   111 
   111 
   112 fun merge_tc (TC{rules,net}, TC{rules=rules',net=net'}) =
   112 fun merge_tc (TC{rules,net}, TC{rules=rules',net=net'}) =
   113     TC {rules = gen_union eq_thm (rules,rules'),
   113     TC {rules = gen_union Drule.eq_thm_prop (rules,rules'),
   114         net = Net.merge (net, net', eq_thm)};
   114         net = Net.merge (net, net', Drule.eq_thm_prop)};
   115 
   115 
   116 (*print tcsets*)
   116 (*print tcsets*)
   117 fun print_tc (TC{rules,...}) =
   117 fun print_tc (TC{rules,...}) =
   118     Pretty.writeln
   118     Pretty.writeln
   119        (Pretty.big_list "type-checking rules:" (map Display.pretty_thm rules));
   119        (Pretty.big_list "type-checking rules:" (map Display.pretty_thm rules));