text stringlengths 0 601k |
|---|
let event_near_pos md char = let ev_frag , ev = Hashtbl . find events_by_module md in try let pos = find_event ev char in if pos > 0 && char - ( Events . get_pos ev . ( pos - 1 ) ) . Lexing . pos_cnum <= ( Events . get_pos ev . ( pos ) ) . Lexing . pos_cnum - char then { ev_frag ; ev_ev = ev . ( pos - 1 ) } else { ev_f... |
let set_all_events frag = Hashtbl . iter ( fun pc ev -> match ev . ev_kind with Event_pseudo -> ( ) | _ when pc . frag = frag -> set_event pc | _ -> ( ) ) events_by_pc |
let old_pc = ref ( None : pc option ) |
let update_current_event ( ) = match Checkpoints . current_pc ( ) with None -> Events . current_event := None ; old_pc := None | ( Some pc ) as opt_pc when opt_pc <> ! old_pc -> Events . current_event := begin try Some ( event_at_pc pc ) with Not_found -> None end ; old_pc := opt_pc | _ -> ( ) |
type break_hint = Space | No_space |
type symbol_table = { agent_open : string ; agent_close : string ; agent_sep_comma : string * break_hint ; agent_sep_dot : string * break_hint ; agent_sep_plus : string * break_hint ; ghost_agent : string ; show_ghost : bool ; internal_state_symbol : string ; open_internal_state : string ; close_internal_state : string... |
let symbol_table_V3 = { bound = " " ; ! open_binding_state = " " ; close_binding_state = " " ; missing_binding_state = " " ; ? link_to_any = " " ; ? link_to_some = " ! _ " ; internal_state_symbol = " " ; ~ open_internal_state = " " ; close_internal_state = " " ; open_internal_state_mod = " " ; close_internal_state_mod ... |
let lighten symbol_table = { symbol_table with site_sep = " " , snd symbol_table . site_sep } |
let to_dotnet symbol_table = { symbol_table with agent_sep_plus = " " , + snd symbol_table . agent_sep_plus ; agent_sep_dot = " . " , No_space } |
let symbol_table_V4 = { bound = " " ; open_binding_state = " [ " ; close_binding_state = " ] " ; missing_binding_state = " " ; link_to_any = " " ; # link_to_some = " _ " ; internal_state_symbol = " " ; open_internal_state = " { " ; close_internal_state = " } " ; internal_state_any = " { } " ; # open_internal_state_mod ... |
let not_breakable symbol_table = { symbol_table with breakable = false } |
let symbol_table_V3_light = lighten symbol_table_V3 |
let symbol_table_dotnet = to_dotnet symbol_table_V3 |
let unbreakable_symbol_table_V3 = not_breakable symbol_table_V3 |
let unbreakable_symbol_table_V4 = not_breakable symbol_table_V4 |
let unbreakable_symbol_table_V3_light = not_breakable symbol_table_V3_light |
let unbreakable_symbol_table_dotnet = not_breakable symbol_table_dotnet |
let with_dot_and_plus symbol_table = { symbol_table with agent_sep_plus = unbreakable_symbol_table_dotnet . agent_sep_plus ; agent_sep_dot = unbreakable_symbol_table_dotnet . agent_sep_dot ; } |
type equivalence_classes = int Symmetries_sig . site_partition array |
type symmetries = { rules : equivalence_classes ; rules_and_initial_states : equivalence_classes option ; rules_and_alg_expr : equivalence_classes option } |
type reduction = | Ground | Forward of equivalence_classes | Backward of equivalence_classes |
let add_gen add find_option k data map = let old = match find_option k map with | None -> [ ] | Some l -> l in add k ( data :: old ) map |
let partition_gen empty add find_option fold sort empty_range cache hash int_of_hash f list = let map = fst ( Array . fold_left ( fun ( inverse , cache ) site -> let key = site . User_graph . site_name in let data = match site . User_graph . site_type with | User_graph . Counter _ -> failwith " KaSa does not deal with ... |
let partition cache hash int_of_hash f map = partition_gen Mods . IntMap . empty Mods . IntMap . add Mods . IntMap . find_option Mods . IntMap . fold ( List . sort compare ) [ ] cache hash int_of_hash f map |
let partition_pair cache hash int_of_hash f map = partition_gen Mods . Int2Map . empty Mods . Int2Map . add Mods . Int2Map . find_option Mods . Int2Map . fold ( fun ( a , b ) -> List . sort compare a , List . sort compare b ) ( [ ] , [ ] ) cache hash int_of_hash f map |
module State : SetMap . OrderedType with type t = string = struct type t = string let compare = compare let print f s = Format . fprintf f " % s " s end |
module StateList = Hashed_list . Make ( State ) |
module BindingType : SetMap . OrderedType with type t = ( int * int ) * int = struct type t = ( int * int ) * int let compare = compare let print f ( ( ag_line , ag_row ) , s2 ) = Format . fprintf f " % i . % i . % i " ag_line ag_row s2 end |
module BindingTypeList = Hashed_list . Make ( BindingType ) |
let collect_partitioned_contact_map contact_map = Array . fold_left ( Array . fold_left ( fun map -> function | None -> map | Some site_node -> let ag = site_node . User_graph . node_type in let site_list = site_node . User_graph . node_sites in let cache1 = StateList . init ( ) in let cache2 = BindingTypeList . init (... |
let print_partitioned_contact_map_in_lkappa logger env partitioned_contact_map = let signature = Model . signatures env in Array . iteri ( fun agent_id partition -> Symmetries_sig . print logger ( Signature . print_site signature ) ( Signature . print_agent signature ) agent_id partition ) partitioned_contact_map |
let print_contact_map parameters contact_map = let log = Remanent_parameters . get_logger parameters in Array . iter ( Array . iter ( function | None -> ( ) | Some site_node -> let agent = site_node . User_graph . node_type in let interface = site_node . User_graph . node_sites in let ( ) = Loggers . fprintf log " agen... |
let translate_to_lkappa_representation env partitioned_contact_map = let signature = Model . signatures env in let nagents = Signature . size signature in let array = Array . make nagents Symmetries_sig . empty in let ( ) = Mods . StringMap . iter ( fun agent_string partition -> let ag_id = Signature . num_of_agent ( L... |
let partition_pair cache p l = let rec part cache yes no = function | [ ] -> cache , ( List . rev yes , List . rev no ) | x :: l -> let cache , b = p cache x in if b then part cache ( x :: yes ) no l else part cache yes ( x :: no ) l in part cache [ ] [ ] l |
let refine_class cache p l result = let rec aux cache to_do classes = match to_do with | [ ] -> cache , classes | h :: tail -> let cache , ( newclass , others ) = partition_pair cache ( fun cache -> p cache h ) tail in aux cache others ( ( h :: newclass ) :: classes ) in aux cache l result |
let refine_class cache p l = if l <> [ ] then List . fold_left ( fun ( cache , result ) l -> let cache , result = refine_class cache p l result in cache , result ) ( cache , [ ] ) l else ( cache , [ ] ) |
let refine_partitioned_contact_map_in_lkappa_representation cache p_internal_state p_binding_state p_both partitioned_contact_map = Tools . array_fold_lefti ( fun agent_type cache partition -> let over_binding_states = partition . Symmetries_sig . over_binding_states in let over_internal_states = partition . Symmetries... |
let max_hash h1 h2 = if compare h1 h2 >= 0 then h1 else h2 |
let max_hashes hash_list = let rec aux tail best = match tail with | [ ] -> best | head :: tail -> aux tail ( max_hash best head ) in aux hash_list LKappa_auto . RuleCache . empty |
let build_array_for_symmetries hashed_list = let max_hash = max_hashes hashed_list in let size_hash_plus_1 = ( LKappa_auto . RuleCache . int_of_hashed_list max_hash ) + 1 in let to_be_checked = Array . make size_hash_plus_1 false in let counter = Array . make size_hash_plus_1 0 in let correct = Array . make size_hash_p... |
let divide_rule_rate_by rule_cache env rate_convention rule lkappa_rule_init = match rate_convention with | Remanent_parameters_sig . Common -> assert false | Remanent_parameters_sig . No_correction -> rule_cache , 1 , 1 | Remanent_parameters_sig . Biochemist | Remanent_parameters_sig . Divide_by_nbr_of_autos_in_lhs ->... |
let rate rule ( _ , arity , _ ) = match arity with | Rule_modes . Usual -> Some rule . Primitives . rate | Rule_modes . Unary_refinement | Rule_modes . Unary -> Option_util . map fst rule . Primitives . unary_rate |
let valid_modes rule id = let add x y list = match y with | None -> list | Some _ -> x :: list in let mode = Rule_modes . Direct in List . rev_map ( fun x -> id , x , mode ) ( List . rev ( Rule_modes . Usual :: ( add Rule_modes . Unary rule . Primitives . unary_rate [ ] ) ) ) |
let cannonic_form_from_syntactic_rule rule_cache env rule lkappa_rule_init = let rule_id = rule . Primitives . syntactic_rule in let lkappa_rule = Model . get_ast_rule env rule_id in let rule_cache , hashed_list = LKappa_auto . cannonic_form rule_cache lkappa_rule in let i = LKappa_auto . RuleCache . int_of_hashed_list... |
let cannonic_form_from_syntactic_rules rule_cache env rate_convention lkappa_rule_list get_rules = let rule_cache , cannonic_list , hashed_lists = List . fold_left ( fun ( rule_cache , current_list , hashed_lists ) rule -> List . fold_left ( fun ( rule_cache , current_list , hashed_lists ) lkappa_rule_init -> let rule_... |
let check_invariance_gen p ? trace ? fmt ? fmt_err ? sigs ~ to_be_checked ~ counter ~ correct ~ rates ( hash_and_rule_list : ( LKappa_auto . RuleCache . hashed_list * LKappa . rule ) list ) cache agent_type site1 site2 = let rec aux hash_and_rule_list ( cache , to_be_checked , counter ) = match hash_and_rule_list with ... |
let check_invariance_internal_states ~ correct ~ rates ? trace ? fmt ? fmt_err ? sigs ( hash_and_rule_list : ( LKappa_auto . RuleCache . hashed_list * LKappa . rule ) list ) ( cache , to_be_checked , counter ) agent_type site1 site2 = check_invariance_gen LKappa_group_action . check_orbit_internal_state_permutation ? t... |
let check_invariance_binding_states ~ correct ~ rates ? trace ? fmt ? fmt_err ? sigs hash_and_rule_list ( cache , to_be_checked , counter ) agent_type site1 site2 = check_invariance_gen LKappa_group_action . check_orbit_binding_state_permutation ? trace ? fmt ? fmt_err ? sigs ~ to_be_checked ~ counter ~ correct ~ rates... |
let check_invariance_both ~ correct ~ rates ? trace ? fmt ? fmt_err ? sigs hash_and_rule_list ( cache , to_be_checked , counter ) agent_type site1 site2 = check_invariance_gen LKappa_group_action . check_orbit_full_permutation ? trace ? fmt ? fmt_err ? sigs ~ to_be_checked ~ counter ~ correct ~ rates hash_and_rule_list... |
let print_symmetries_gen parameters env contact_map partitioned_contact_map partitioned_contact_map_in_lkappa refined_partitioned_contact_map refined_partitioned_contact_map_init refined_partitioned_contact_map_alg_expr = let ( ) = if Remanent_parameters . get_trace parameters then let logger = Remanent_parameters . ge... |
let detect_symmetries ( parameters : Remanent_parameters_sig . parameters ) env cache rate_convention chemical_species get_rules contact_map = let trace = Some ( Remanent_parameters . get_trace parameters ) in let fmt = Loggers . formatter_of_logger ( Remanent_parameters . get_logger parameters ) in let fmt_err = Logge... |
module Cc = struct type t = Pattern . cc let compare = compare let print _ _ = ( ) end |
module CcId = struct type t = Pattern . id let compare = compare let print _ _ = ( ) end |
type cache = { rep : Pattern . cc CcMap . t ; equiv_class : ( int * ( Pattern . id * int ) list ) CcIdMap . t ; } |
let empty_cache ( ) = { rep = CcMap . empty ; equiv_class = CcIdMap . empty } |
let representative ? parameters ~ sigs cache rule_cache preenv_cache symmetries species = match symmetries with | Ground -> cache , rule_cache , preenv_cache , species | Forward sym | Backward sym -> begin match CcMap . find_option species cache . rep with | Some species -> cache , rule_cache , preenv_cache , species |... |
let equiv_class ? parameters env array cache rule_cache preenv_cache symmetries pattern = match symmetries with | Ground -> cache , rule_cache , preenv_cache , array , ( 1 , [ pattern , 1 ] ) | Forward partitions | Backward partitions -> begin match CcIdMap . find_option pattern cache . equiv_class with | Some equiv_cl... |
let print_symmetries parameters env symmetries = let log = Remanent_parameters . get_logger parameters in let ( ) = Loggers . fprintf log " Symmetries " : in let ( ) = Loggers . print_newline log in let ( ) = Loggers . fprintf log " In rules " : in let ( ) = Loggers . print_newline log in let ( ) = print_partitioned_co... |
type ' a site_partition = { over_binding_states : ' a list list ; over_internal_states : ' a list list ; over_full_states : ' a list list ; } |
let empty = { over_binding_states = [ ] ; over_internal_states = [ ] ; over_full_states = [ ] ; } |
let map_list_list f list = List . rev_map ( fun list -> List . rev_map f ( List . rev list ) ) ( List . rev list ) |
let map f site_partition = { over_binding_states = map_list_list f site_partition . over_binding_states ; over_internal_states = map_list_list f site_partition . over_internal_states ; over_full_states = map_list_list f site_partition . over_full_states } |
let at_least_two = function | [ ] | [ _ ] -> false | _ -> true |
let clean site_partition = { over_binding_states = List . filter at_least_two site_partition . over_binding_states ; over_internal_states = List . filter at_least_two site_partition . over_internal_states ; over_full_states = List . filter at_least_two site_partition . over_full_states ; } |
let print_l print_site logger fmt agent s l = if l = [ ] then ( ) else let ( ) = Loggers . fprintf logger " % s " s in let ( ) = Loggers . print_newline logger in List . iter ( fun equ_class -> let ( ) = Loggers . fprintf logger " { " in let _ = List . fold_left ( fun b site -> let ( ) = if b then Loggers . fprintf log... |
let print logger print_site print_agent agent partition = if partition = empty then ( ) else begin let fmt = Loggers . formatter_of_logger logger in match fmt with | None -> ( ) | Some fmt -> let ( ) = Loggers . fprintf logger " " ************ in let ( ) = Loggers . print_newline logger in let ( ) = Loggers . fprintf l... |
type init = ( Primitives . alg_expr * rule ) list |
type compil = { debugMode : bool ; contact_map : Contact_map . t ; environment : Model . t ; init : init ; rule_rate_convention : Remanent_parameters_sig . rate_convention ; reaction_rate_convention : Remanent_parameters_sig . rate_convention option ; show_reactions : bool ; count : Ode_args . count ; internal_meaning ... |
let debug_mode compil = compil . debugMode |
let do_we_allow_empty_lhs compil = compil . allow_empty_lhs |
let to_dotnet compil = { compil with symbol_table = Symbol_table . unbreakable_symbol_table_dotnet } |
let with_dot_and_plus compil = { compil with symbol_table = Symbol_table . with_dot_and_plus compil . symbol_table } |
let dont_allow_empty_lhs compil = { compil with allow_empty_lhs = false } |
type seen_cache = bool Mods . DynArray . t |
type rule_weight = int option Mods . DynArray . t |
type cache = { cc_cache : cc_cache ; rule_cache : nauto_in_rules_cache ; representative_cache : sym_cache ; seen_rule : seen_cache ; seen_pattern : seen_cache ; seen_species : seen_cache ; correcting_coef : rule_weight ; n_cc : rule_weight ; } |
let get_cc_cache cache = cache . cc_cache |
let set_cc_cache cc_cache cache = { cache with cc_cache = cc_cache } |
let get_rule_cache cache = cache . rule_cache |
let set_rule_cache rule_cache cache = { cache with rule_cache = rule_cache } |
let get_sym_cache cache = cache . representative_cache |
let set_sym_cache sym_cache cache = { cache with representative_cache = sym_cache } |
let hash_rule_weight get set f cache compil rule = match get cache rule with | Some n -> cache , n | None -> let cache , n = f cache compil rule in let cache = set cache rule n in cache , n |
let get_representative parameters compil cache symmetries species = let sigs = Model . signatures compil . environment in let rep_cache , rule_cache , cc_cache , species = Symmetries . representative ~ parameters ~ sigs ( get_sym_cache cache ) ( get_rule_cache cache ) ( get_cc_cache cache ) symmetries species in let ca... |
let equiv_class_of_pattern parameters compil cache symmetries pattern = let env = compil . environment in let rep_cache , rule_cache , cc_cache , seen_pattern , equiv_class = Symmetries . equiv_class ~ parameters env cache . seen_pattern ( get_sym_cache cache ) ( get_rule_cache cache ) ( get_cc_cache cache ) symmetries... |
let lift_opt f compil_opt = match compil_opt with | None -> None | Some a -> Some ( f a ) |
let contact_map compil = compil . contact_map |
let environment compil = compil . environment |
let domain compil = Model . domain ( environment compil ) |
let domain_opt = lift_opt domain |
let environment_opt = lift_opt environment |
let symbol_table compil = compil . symbol_table |
let symbol_table_opt a = match a with | None -> Symbol_table . symbol_table_V4 | Some compil -> symbol_table compil |
type pattern = Pattern . id array |
let dummy_chemical_species compil = Pattern . empty_cc ( Pattern . Env . signatures ( domain compil ) ) |
let rule_rate_convention compil = compil . rule_rate_convention |
let reaction_rate_convention compil = compil . reaction_rate_convention |
let what_do_we_count compil = compil . count |
let do_we_count_in_embeddings compil = match what_do_we_count compil with | Ode_args . Occurrences -> false | Ode_args . Embeddings -> true |
let internal_meaning_is_nembeddings compil = match compil . internal_meaning with | Ode_args . Occurrences -> false | Ode_args . Embeddings -> true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.