src/Tools/Code/code_thingol.ML
changeset 46616 cd0e6841ab9c
parent 46614 165886a4fe64
child 46665 919dfcdf6d8a
equal deleted inserted replaced
46610:0c3a5e28f425 46616:cd0e6841ab9c
   906 
   906 
   907 fun consts_program thy permissive consts =
   907 fun consts_program thy permissive consts =
   908   let
   908   let
   909     fun project_consts consts (naming, program) =
   909     fun project_consts consts (naming, program) =
   910       if permissive then (consts, (naming, program))
   910       if permissive then (consts, (naming, program))
   911       else (consts, (naming, Graph.subgraph
   911       else (consts, (naming, Graph.restrict
   912         (member (op =) (Graph.all_succs program consts)) program));
   912         (member (op =) (Graph.all_succs program consts)) program));
   913     fun generate_consts thy algebra eqngr =
   913     fun generate_consts thy algebra eqngr =
   914       fold_map (ensure_const thy algebra eqngr permissive);
   914       fold_map (ensure_const thy algebra eqngr permissive);
   915   in
   915   in
   916     invoke_generation permissive thy (Code_Preproc.obtain false thy consts [])
   916     invoke_generation permissive thy (Code_Preproc.obtain false thy consts [])
   938         val Fun (_, ((vs_ty, [(([], t), _)]), _)) =
   938         val Fun (_, ((vs_ty, [(([], t), _)]), _)) =
   939           Graph.get_node program1 Term.dummy_patternN;
   939           Graph.get_node program1 Term.dummy_patternN;
   940         val deps = Graph.immediate_succs program1 Term.dummy_patternN;
   940         val deps = Graph.immediate_succs program1 Term.dummy_patternN;
   941         val program2 = Graph.del_nodes [Term.dummy_patternN] program1;
   941         val program2 = Graph.del_nodes [Term.dummy_patternN] program1;
   942         val deps_all = Graph.all_succs program2 deps;
   942         val deps_all = Graph.all_succs program2 deps;
   943         val program3 = Graph.subgraph (member (op =) deps_all) program2;
   943         val program3 = Graph.restrict (member (op =) deps_all) program2;
   944       in (((naming, program3), ((vs_ty, t), deps)), (dep, (naming, program2))) end;
   944       in (((naming, program3), ((vs_ty, t), deps)), (dep, (naming, program2))) end;
   945   in
   945   in
   946     ensure_stmt ((K o K) NONE) pair stmt_value Term.dummy_patternN
   946     ensure_stmt ((K o K) NONE) pair stmt_value Term.dummy_patternN
   947     #> snd
   947     #> snd
   948     #> term_value
   948     #> term_value
  1013 
  1013 
  1014 fun code_depgr thy consts =
  1014 fun code_depgr thy consts =
  1015   let
  1015   let
  1016     val (_, eqngr) = Code_Preproc.obtain true thy consts [];
  1016     val (_, eqngr) = Code_Preproc.obtain true thy consts [];
  1017     val all_consts = Graph.all_succs eqngr consts;
  1017     val all_consts = Graph.all_succs eqngr consts;
  1018   in Graph.subgraph (member (op =) all_consts) eqngr end;
  1018   in Graph.restrict (member (op =) all_consts) eqngr end;
  1019 
  1019 
  1020 fun code_thms thy = Pretty.writeln o Code_Preproc.pretty thy o code_depgr thy;
  1020 fun code_thms thy = Pretty.writeln o Code_Preproc.pretty thy o code_depgr thy;
  1021 
  1021 
  1022 fun code_deps thy consts =
  1022 fun code_deps thy consts =
  1023   let
  1023   let