Doxygen Generated Documentation of Ben-Jose Trainable SAT Solver Library
skeleton.h
1 
2 
3 /*************************************************************
4 
5 This file is part of ben-jose.
6 
7 ben-jose is free software: you can redistribute it and/or modify
8 it under the terms of the version 3 of the GNU General Public
9 License as published by the Free Software Foundation.
10 
11 ben-jose is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with ben-jose. If not, see <http://www.gnu.org/licenses/>.
18 
19 ------------------------------------------------------------
20 
21 Copyright (C) 2007-2012, 2014-2016. QUIROGA BELTRAN, Jose Luis.
22 Id (cedula): 79523732 de Bogota - Colombia.
23 See https://github.com/joseluisquiroga/ben-jose
24 
25 ben-jose is free software thanks to The Glory of Our Lord
26  Yashua Melej Hamashiaj.
27 Our Resurrected and Living, both in Body and Spirit,
28  Prince of Peace.
29 
30 ------------------------------------------------------------
31 
32 skeleton.h
33 
34 Classes for skeleton and directory management in canon_cnf DIMACS format.
35 
36 --------------------------------------------------------------*/
37 
38 
39 #ifndef SKELETON_H
40 #define SKELETON_H
41 
42 #include "bj_stream.h"
43 #include "tools.h"
44 #include "file_funcs.h"
45 #include "dimacs.h"
46 #include "sha2.h"
47 #include "print_macros.h"
48 #include "dbg_prt.h"
49 #include "str_set.h"
50 
51 enum charge_t {
52  cg_negative = -1,
53  cg_neutral = 0,
54  cg_positive = 1
55 };
56 
57 class instance_info;
58 
59 class solver;
60 class brain;
61 class neuron;
62 class canon_clause;
63 class variant;
64 class canon_cnf;
65 class skeleton_glb;
66 
67 
68 #define SKELETON_DBG(prm) DBG(prm)
69 #define SKELETON_CK(prm) DBG_BJ_LIB_CK(prm)
70 #define SKELETON_CK_PRT(prm, comms1) DBG_CK_2(prm, comms1)
71 
72 
73 //=================================================================
74 // defines
75 
76 #define SKG_NUM_DIGITS_IN_DIRNAM_OF_NUMBER_PATH 1
77 #define SKG_MAX_SAMPLE_NUM_LITS 1000
78 #define SKG_MAX_SAMPLE_NUM_CCLS 10
79 
80 #ifdef FULL_DEBUG
81 #define SKG_MAX_NUM_VARIANT 10
82 #else
83 #define SKG_MAX_NUM_VARIANT 10
84 #endif
85 
86 #define SKG_LOCK_SEP_STR "%"
87 #define SKG_LOCK_SEP '%'
88 #define SKG_VARIANT_DIR "vv/"
89 
90 #define SKG_CANON_PATH_ENDING "oo"
91 
92 #define SKG_CANON_HEADER_STR \
93  "c Yashua Melej Hamashiaj. \n" \
94  "c ben-jose dimacs unsat cnf generated file.\n" \
95  "c Any modification will make it useless for ben-jose. \n" \
96 
97 //--end_of_def
98 
99 
100 //=================================================================
101 // skeleton defines
102 
103 //define SKG_APROX_SHA_PTH_SZ 70
104 
105 #define SKG_INVALID_PTH "skg_invalid_pth"
106 #define SKG_SKELETON_DIR "/SKELETON"
107 #define SKG_CNF_DIR "/SKELETON/CNF"
108 #define SKG_REF_DIR "/SKELETON/REF"
109 #define SKG_LCK_DIR "/SKELETON/LCK"
110 #define SKG_TMP_PROOF_DIR "/SKELETON/TMP/PROOF"
111 #define SKG_JS_DIR "/SKELETON/JS"
112 #define SKG_COLLISIONS_DIR "/SKELETON/ERR/COLLISIONS"
113 #define SKG_MISSING_DIR "/SKELETON/ERR/MISSING"
114 #define SKG_CORRUPTED_DIR "/SKELETON/ERR/CORRUPTED"
115 #define SKG_OVERLAPED_DIR "/SKELETON/ERR/OVERLAPED"
116 #define SKG_DEAD_DIR "/SKELETON/ERR/DEAD"
117 #define SKG_BROKEN_DIR "/SKELETON/ERR/BROKEN"
118 
119 #define SKG_REF_SUF ".ref"
120 
121 #define SKG_CANON_NAME "canon.skl"
122 #define SKG_DIFF_NAME "diff.skl"
123 #define SKG_GUIDE_NAME "guide.skl"
124 #define SKG_GUIDE_SHA_NAME "guide_sha.skl"
125 #define SKG_COMMENT_NAME "comment.skl"
126 #define SKG_ELAPSED_NAME "elapsed.skl"
127 #define SKG_NUM_VNT_NAME "numvariants.skl"
128 
129 #define SKG_ERR_COUNT_NAME "err_count.skl"
130 #define SKG_READY_NAME "ready"
131 
132 #define SKG_VERIFY_NAME "/SKELETON/verify.skl"
133 
134 #define SKG_DBG_COLLI_DIFF "/dbg_colli_diff.skl"
135 #define SKG_DBG_COLLI_NEW "/dbg_colli_new.skl"
136 
137 #define SKG_PROOF_SUBDIR "proof"
138 #define SKG_UNIRONS_SUBDIR "unirons"
139 #define SKG_UNIRONS_REF_FNAM "unirons_ref.txt"
140 #define SKG_SHOW_PROOF_JS_SUBDIR "show_proof_js_lib"
141 #define SKG_SHOW_PROOF_TOP_HTM_NAME "Show_Proof.htm"
142 #define SKG_END_JSN_NAME "cnf_proof.jsn"
143 
144 //=================================================================
145 // funtion declarations
146 
147 DECLARE_PRINT_FUNCS(canon_clause)
148 DECLARE_PRINT_FUNCS(variant)
149 DECLARE_PRINT_FUNCS(canon_cnf)
150 
151 //=================================================================
152 // path funcs
153 
154 bool print_str_long_map(bj_ostream& os, string_long_map_t& pmp);
155 
156 bool not_skl_path(ch_string pth);
157 
158 ch_string nam_subset_resp(cmp_is_sub rr);
159 void string_replace_char(ch_string& src_str, char orig, char repl);
160 
161 bool path_is_dead_lock(ch_string the_pth);
162 //bool path_is_diff_file(ch_string the_pth);
163 
164 ch_string& slice_str_to_path(ch_string& sha_txt);
165 //ch_string long_to_path(long nn, long d_per_dir);
166 bool all_digits(ch_string& the_str);
167 //ch_string cnf_dims_to_path(const dima_dims& dims);
168 
169 void delete_sha_skeleton(ch_string& sha_pth);
170 
171 bool canon_save(skeleton_glb& skg, ch_string& the_pth, row<char>& cnn,
172  bool write_once = true);
173 bool canon_load(skeleton_glb& skg, ch_string& the_pth, row<char>& cnn);
174 bool canon_equal(skeleton_glb& skg, ch_string& the_pth, row<char>& cnn);
175 
176 //ch_string canon_hash_path(const dima_dims& dims, ch_string sha_str);
177 //ch_string canon_lock_name(const dima_dims& dims, ch_string sha_str);
178 
179 void canon_print(bj_ostream& os, row<char>& cnn);
180 void canon_sha(row<char>& cnn, ch_string& sha_txt, ch_string& minisha_txt);
181 
182 ch_string canon_header(ch_string& hd_str, long ccls, long vars);
183 void canon_long_append(row<char>& cnn, long nn);
184 void canon_string_append(row<char>& cnn, ch_string ss);
185 long canon_purge_clauses(skeleton_glb& skg, row<canon_clause*>& all_ccl, long& tot_lits, long& tot_twolits);
186 
187 void canon_count_tots(row<canon_clause*>& all_ccls, long& tot_vars, long& tot_lits, long& tot_twolits);
188 
189 
190 //======================================================================
191 // skeleton_exception
192 
193 class skeleton_exception : public top_exception {
194 public:
195  skeleton_exception(long the_id = 0) : top_exception(the_id)
196  {}
197 };
198 
199 //=================================================================
200 // canon_clause
201 
202 //define MAX_CLAUSE_SZ 100
203 
204 class canon_clause : private row_long_t {
205 public:
206  SKELETON_DBG(
207  brain* cc_pt_brn;
208  bool cc_can_release;
209  bool cc_in_free;
210  );
211 
212  void* cc_me;
213  bool cc_spot;
214 
215  canon_clause();
216  ~canon_clause();
217 
218  brain* get_dbg_brn(){
219  brain* the_brn = NULL;
220  SKELETON_DBG(the_brn = cc_pt_brn);
221  return the_brn;
222  }
223 
224  solver* get_dbg_slv();
225 
226  void set_dbg_brn(brain* pt_brn){
227  SKELETON_DBG(cc_pt_brn = pt_brn);
228  }
229 
230  bool is_cc_virgin(){
231  bool c1 = is_empty();
232  return c1;
233  }
234 
235  void init_canon_clause(bool free_mem){
236  SKELETON_DBG(
237  cc_pt_brn = NULL;
238  cc_in_free = false;
239  )
240 
241  cc_me = NULL_PT;
242  cc_spot = false;
243  clear(free_mem, free_mem);
244  }
245 
246  template<class obj_t1>
247  obj_t1&
248  me_as(){
249  SKELETON_CK(cc_me != NULL_PT);
250  obj_t1& obj = *((obj_t1*)(cc_me));
251  SKELETON_CK(obj.get_cls_name() == obj_t1::CL_NAME);
252  return obj;
253  }
254 
255  bool cc_is_empty(){
256  SKELETON_CK(! cc_in_free);
257  return is_empty();
258  }
259 
260  long cc_size(){
261  SKELETON_CK(! cc_in_free);
262  return size();
263  }
264 
265  long cc_last_idx(){
266  SKELETON_CK(! cc_in_free);
267  return last_idx();
268  }
269 
270  void cc_push(long the_lit){
271  SKELETON_CK(! cc_in_free);
272  push(the_lit);
273  }
274 
275  void cc_mix_sort(cmp_func_t cmp_fn){
276  SKELETON_CK(! cc_in_free);
277  mix_sort(cmp_fn);
278  }
279 
280  bool cc_is_sorted(cmp_func_t cmp_fn){
281  SKELETON_CK(! cc_in_free);
282  return is_sorted(cmp_fn);
283  }
284 
285  long cc_pos(long the_idx){
286  SKELETON_CK(! cc_in_free);
287  SKELETON_CK(is_valid_idx(the_idx));
288  return pos(the_idx);
289  }
290 
291  void cc_copy_to(canon_clause& dest,
292  row_index first_ii = 0, row_index last_ii = -1,
293  bool inv = false)
294  {
295  copy_to(dest, first_ii, last_ii, inv);
296  }
297 
298  void cc_clear(bool free_mem);
299 
300  charge_t cc_is_full();
301 
302  void add_chars_to(row<char>& cnn);
303 
304  bj_ostream& print_canon_clause(bj_ostream& os, bool from_pt = false);
305 };
306 
307 comparison
308 cmp_canon_ids(const long& id1, const long& id2);
309 
310 comparison
311 cmp_lit_rows(row_long_t& trl1, row_long_t& trl2);
312 
313 //comparison
314 //cmp_trails(row_long_t& trl1, row_long_t& trl2);
315 
316 comparison
317 cmp_clauses(canon_clause* const& srt1, canon_clause* const& srt2);
318 
319 template<class obj_t1>
320 void
321 ccl_row_as(row<canon_clause*>& rr1, row<obj_t1*>& rr2, bool only_spotted = false){
322  rr2.clear();
323  rr2.set_cap(rr1.size());
324  for(long ii = 0; ii < rr1.size(); ii++){
325  SKELETON_CK(rr1[ii] != NULL_PT);
326  canon_clause& the_ccl = *(rr1[ii]);
327 
328  bool add_it = true;
329  if(only_spotted){ add_it = the_ccl.cc_spot; }
330 
331  if(add_it){
332  obj_t1& obj_1 = the_ccl.me_as<obj_t1>();
333  rr2.push(&obj_1);
334  }
335  }
336 }
337 
338 //=================================================================
339 // variant
340 
341 class variant {
342 public:
343  ch_string vn_real_path;
344  average vn_elap;
345 
346  variant(){
347  init_variant();
348  }
349 
350  ~variant(){
351  }
352 
353  void init_variant(){
354  vn_real_path = "";
355  vn_elap.init_average();
356  }
357 
358  bj_ostream& print_variant(bj_ostream& os, bool from_pt = false){
359  os << "vn[" << vn_real_path << " " << vn_elap << "]" << bj_eol;
360  return os;
361  }
362 };
363 
364 long choose_variant(row<variant>& all_vnt,
365  bj_big_float_t& avg_szs, bool in_dbg = false);
366 
367 comparison
368 cmp_variant(variant const & vnt1, variant const & vnt2);
369 
370 //=================================================================
379 enum cnf_kind_t {
380  fk_invalid = 10,
381  fk_guide,
382  fk_diff,
383  fk_canon
384 };
385 
386 class canon_cnf {
387 public:
388  SKELETON_DBG(brain* cf_pt_brn;)
389 
390  cnf_kind_t cf_kind;
391 
392  bool cf_sorted;
393 
394  dima_dims cf_dims;
395 
396  row<canon_clause*> cf_clauses;
397 
398  ch_string cf_sha_str;
399  ch_string cf_minisha_str;
400  ch_string cf_diff_minisha_str;
401 
402  row<char> cf_chars;
403  row<char> cf_comment_chars;
404  long cf_num_cls_in_chars;
405 
406  ch_string cf_phase_str;
407 
408  ch_string cf_unique_path;
409 
410  long cf_num_purged;
411 
412  canon_cnf* cf_guide_cnf;
413  canon_cnf* cf_tauto_cnf;
414  ch_string cf_quick_find_ref;
415  row_str_t cf_dbg_shas;
416 
417  instance_info* cf_inst_inf;
418 
419  ch_string cf_tmp_sv_dir;
420  ch_string cf_tmp_pth1;
421  ch_string cf_tmp_pth2;
422 
423  SKELETON_DBG(
424  void* cf_dbg_orig_nmp;
425  bool cf_dbg_file_existed;
426  );
427 
428  canon_cnf(){
429  init_canon_cnf();
430  }
431 
432  ~canon_cnf(){
433  }
434 
435  brain* get_dbg_brn(){
436  brain* the_brn = NULL;
437  SKELETON_DBG(the_brn = cf_pt_brn);
438  return the_brn;
439  }
440 
441  solver* get_dbg_slv();
442 
443  void set_dbg_brn(brain* pt_brn){
444  SKELETON_DBG(cf_pt_brn = pt_brn);
445  }
446 
447  void init_canon_cnf(bool free_mem = false){
448  SKELETON_DBG(cf_pt_brn = NULL);
449 
450  cf_kind = fk_invalid;
451 
452  cf_sorted = true;
453 
454  cf_dims.init_dima_dims(INVALID_NATURAL);
455  cf_dims.dd_tot_twolits = 0;
456 
457  SKELETON_CK(cf_clauses.is_empty());
458 
459  cf_sha_str = "";
460  cf_minisha_str = "";
461  cf_diff_minisha_str = "";
462 
463  cf_chars.clear(free_mem, free_mem);
464  cf_comment_chars.clear(free_mem, free_mem);
465  cf_num_cls_in_chars = -1;
466 
467  cf_phase_str = "";
468 
469  cf_unique_path = "";
470 
471  cf_num_purged = 0;
472 
473  cf_guide_cnf = NULL_PT;
474  cf_tauto_cnf = NULL_PT;
475  cf_quick_find_ref = "";
476  cf_dbg_shas.clear(free_mem, free_mem);
477 
478  cf_inst_inf = NULL_PT;
479 
480  cf_tmp_sv_dir = "";
481  cf_tmp_pth1 = "";
482  cf_tmp_pth2 = "";
483 
484  SKELETON_DBG(
485  cf_dbg_orig_nmp = NULL_PT;
486  cf_dbg_file_existed = false;
487  );
488 
489  SKELETON_CK(cf_unique_path.size() == 0);
490  }
491 
492  void init_with_ccls(skeleton_glb& skg, row<canon_clause*>& all_ccls,
493  long tot_vars = INVALID_NATURAL,
494  long tot_lits = INVALID_NATURAL,
495  long tot_twolits = INVALID_NATURAL,
496  bool sorted_cnf = true);
497 
498  void release_and_init(skeleton_glb& skg, bool free_mem = false){
499  release_all_clauses(skg, free_mem);
500  brain* old_dbg_brn = get_dbg_brn();
501  init_canon_cnf(free_mem);
502  set_dbg_brn(old_dbg_brn);
503  }
504 
505  void clear_all_spots();
506 
507  bool ck_full_dir(ch_string sv_dir){
508  SKELETON_CK(! sv_dir.empty());
509  SKELETON_CK(*(sv_dir.begin()) == '/');
510  SKELETON_CK(*(sv_dir.rbegin()) == '/');
511  return true;
512  }
513 
514  bool ck_all_can_release(row<canon_clause*>& rr, bool can_val){
515  for(long aa = 0; aa < rr.size(); aa++){
516  SKELETON_CK(rr[aa] != NULL_PT);
517  canon_clause& ccl = *(rr[aa]);
518  MARK_USED(ccl);
519  SKELETON_CK(ccl.cc_can_release == can_val);
520  }
521  return true;
522  }
523 
524  void clear_cnf(){
525  SKELETON_CK(ck_all_can_release(cf_clauses, false));
526  cf_clauses.clear();
527 
528  brain* old_dbg_brn = get_dbg_brn();
529  init_canon_cnf(false);
530  set_dbg_brn(old_dbg_brn);
531  }
532 
533  canon_clause& add_clause(skeleton_glb& skg);
534 
535  bool is_empty(){
536  SKELETON_CK(cf_dims.dd_tot_ccls == cf_clauses.size());
537  bool is_e = cf_clauses.is_empty();
538  return is_e;
539  }
540 
541  ch_string get_id_str();
542  void get_extreme_lits(row<long>& lits);
543 
544  ch_string get_num_variants_file_name(skeleton_glb& skg);
545 
546  void release_all_clauses(skeleton_glb& skg, bool free_mem = false);
547 
548  bool has_phase_path(){
549  return has_cnfs();
550  }
551 
552  bool has_cnfs(){
553  bool c1 = (cf_guide_cnf != NULL_PT);
554  bool c2 = (cf_tauto_cnf != NULL_PT);
555  bool c_ok = (c1 && c2);
556  SKELETON_CK(is_diff() == c_ok);
557  return c_ok;
558  }
559 
560  canon_cnf& get_guide_cnf(){
561  SKELETON_CK(cf_guide_cnf != NULL_PT);
562  return *cf_guide_cnf;
563  }
564 
565  canon_cnf& get_tauto_cnf(){
566  SKELETON_CK(cf_tauto_cnf != NULL_PT);
567  return *cf_tauto_cnf;
568  }
569 
570  ch_string get_ref1_nam(){
571  SKELETON_CK(has_cnfs());
572  SKELETON_CK(is_diff());
573  return cf_guide_cnf->get_ref_path();
574  }
575 
576  ch_string get_ref2_nam(){
577  SKELETON_CK(has_cnfs());
578  SKELETON_CK(is_diff());
579  return cf_guide_cnf->get_lck_path();
580  }
581 
582  ch_string get_ref3_nam(){
583  SKELETON_CK(has_cnfs());
584  SKELETON_CK(is_diff());
585  return cf_quick_find_ref;
586  }
587 
588  ch_string get_vnt_nam(){
589  return get_ref1_nam();
590  }
591 
592  ch_string get_lck_nam(){
593  return get_ref2_nam();
594  }
595 
596  bool is_canon(){
597  return (cf_kind == fk_canon);
598  }
599 
600  bool is_diff(){
601  return (cf_kind == fk_diff);
602  }
603 
604  bool is_guide(){
605  return (cf_kind == fk_guide);
606  }
607 
608  void update_diff_refs(skeleton_glb& skg, ch_string sv_vpth);
609  void update_mng_verif_sys(skeleton_glb& skg, ch_string sv_vpth);
610 
611  void set_kind_from(ch_string the_pth){
612  SKELETON_CK(cf_kind == fk_invalid);
613 
614  ch_string nm = path_get_name(the_pth);
615  if(nm == SKG_GUIDE_NAME){
616  cf_kind = fk_guide;
617  } else
618  if(nm == SKG_DIFF_NAME){
619  cf_kind = fk_diff;
620  } else
621  if(nm == SKG_CANON_NAME){
622  cf_kind = fk_canon;
623  }
624  SKELETON_CK(cf_kind != fk_invalid);
625  }
626 
627  ch_string get_kind_name(){
628  ch_string fnm = "";
629  SKELETON_CK(cf_kind != fk_invalid);
630  switch(cf_kind){
631  case fk_guide:
632  fnm = SKG_GUIDE_NAME;
633  break;
634  case fk_diff:
635  fnm = SKG_DIFF_NAME;
636  break;
637  case fk_canon:
638  fnm = SKG_CANON_NAME;
639  break;
640  default:
641  break;
642  }
643  SKELETON_CK(fnm != "");
644  return fnm;
645  }
646 
647  ch_string get_all_variant_dir_name();
648  ch_string get_variant_ref_fname(long num_vnt);
649  ch_string get_variant_path(skeleton_glb& skg, long num_vnt, bool skip_report = false);
650 
651  bool i_am_sub_of(canon_cnf& the_cnf, bool& are_eq);
652  bool i_am_super_of(canon_cnf& the_cnf, bool& are_eq);
653  bool i_sub_of_vnt(skeleton_glb& skg, ch_string& vpth, bool& are_eq);
654  bool i_super_of_vnt(skeleton_glb& skg, ch_string& vpth);
655  bool i_equal_to_vnt(skeleton_glb& skg, ch_string& vpth);
656  bool i_exact_found(skeleton_glb& skg);
657 
658  bj_big_int_t get_num_variants(skeleton_glb& skg);
659  void set_num_variants(skeleton_glb& skg, bj_big_int_t num_vnts);
660 
661  bool all_nxt_vnt(skeleton_glb& skg, row<variant>& all_next, row<ch_string>& all_del);
662 
663  ch_string first_vnt_i_super_of(skeleton_glb& skg, row<neuron*>& all_found,
664  instance_info* iinfo = NULL);
665 
666  bool ck_vnts(skeleton_glb& skg);
667 
668  ch_string get_cnf_path();
669 
670  ch_string get_ref_path(){
671  SKELETON_CK(cf_unique_path.size() > 0);
672  ch_string ref_pth = SKG_REF_DIR + cf_unique_path;
673  return ref_pth;
674  }
675 
676  ch_string get_lck_path(){
677  SKELETON_CK(cf_unique_path.size() > 0);
678  ch_string ref_pth = SKG_LCK_DIR + cf_unique_path;
679  return ref_pth;
680  }
681 
682  bool is_new(skeleton_glb& skg);
683 
684  ch_string prepare_cnf(skeleton_glb& skg, ch_string sv_base_pth);
685 
686  bool save_canon_cnf(ch_string& the_pth, row<char>& cnn, bool write_once = true);
687  bool save_cnf(skeleton_glb& skg, ch_string pth);
688  void update_parent_variants(skeleton_glb& skg, ch_string sv_dir);
689 
690  void update_chars_to_write();
691 
692  void load_lits(skeleton_glb& skg, row_long_t& all_lits, long& tot_lits,
693  long& tot_twolits);
694  void calc_sha_in(ch_string& sha_str, ch_string& minisha_str);
695 
696  long purge_clauses(skeleton_glb& skg);
697  bool ck_all_sup_leaf(row_str_t& all_pth);
698 
699  void calc_sha(){
700  calc_sha_in(cf_sha_str, cf_minisha_str);
701  }
702 
703  void init_skl_paths(skeleton_glb& skg);
704 
705  //void fill_with(skeleton_glb& skg, row<long>& all_lits, long num_cla, long num_var);
706  bool load_from(skeleton_glb& skg, ch_string& f_nam);
707 
708  bool has_instance_info(){
709  return (cf_inst_inf != NULL);
710  }
711 
712  instance_info& get_info(){
713  SKELETON_CK(has_instance_info());
714  return (*cf_inst_inf);
715  }
716 
717  //void get_first_full(long& idx_all_pos, long& idx_all_neg);
718 
719  //bj_ostream& print_canon_cnf(bj_ostream& os);
720  bj_ostream& print_canon_cnf(bj_ostream& os, bool from_pt = false);
721 
722  bj_ostream& print_attrs_canon_cnf(bj_ostream& os){
723  os << cf_dims << bj_eol;
724  /*
725  os << "cf_tot_vars=" << cf_tot_vars << bj_eol;
726  os << "cf_tot_ccls=" << cf_tot_ccls << bj_eol;
727  os << "cf_tot_lits=" << cf_tot_lits << bj_eol;
728  */
729  os << "cf_sha_str=" << cf_sha_str << bj_eol;
730  os << "cf_minisha_str=" << cf_minisha_str << bj_eol;
731  os << "cf_num_purged=" << cf_num_purged << bj_eol;
732  return os;
733  }
734 };
735 
736 //=================================================================
737 // skeleton_glb
762 public:
763  SKELETON_DBG(brain* kg_pt_brn;)
764 
765  solver* kg_pt_slv;
766 
767  k_row<canon_clause> kg_clauses;
768  row<canon_clause*> kg_free_clauses;
769 
770  bool kg_dbg_only_save;
771  bool kg_dbg_verifying_skeleton_tree;
772  bool kg_dbg_local_verifying;
773 
774  bool kg_dbg_save_canon;
775  bool kg_keep_skeleton;
776  bool kg_find_cnn_pth;
777 
778  SKELETON_DBG(string_long_map_t kg_dbg_all_wrt_paths);
779 
780  string_set_t kg_cnf_new_paths;
781  string_set_t kg_cnf_paths_found;
782 
783  ch_string kg_root_path;
784  ch_string kg_running_path;
785 
786  ch_string kg_instance_file_nam;
787 
788  ch_string kg_tmp_proof_path;
789 
790  ch_string kg_cnfs_path;
791  ch_string kg_collisions_path;
792  ch_string kg_missing_path;
793  ch_string kg_corrupted_path;
794  ch_string kg_overlaped_path;
795  ch_string kg_dead_path;
796  ch_string kg_broken_path;
797  ch_string kg_show_proof_js_path;
798 
799  ch_string kg_verify_path;
800  time_t kg_verify_mtime;
801 
802  bool kg_last_cnn_eq;
803 
804  row<long> kg_tmp_lits;
805  canon_cnf kg_tmp_cnf;
806  row<variant> kg_tmp_all_nxt_vnts;
807  row<ch_string> kg_tmp_all_del_paths;
808 
809  //skeleton_glb() : kg_cnf_paths_found(cmp_string) {
810  skeleton_glb() {
811  init_skeleton_glb();
812  }
813 
814  ~skeleton_glb(){
815  }
816 
817  brain* get_dbg_brn(){
818  brain* the_brn = NULL;
819  SKELETON_DBG(the_brn = kg_pt_brn);
820  return the_brn;
821  }
822 
823  solver* get_dbg_slv();
824 
825  solver& get_solver();
826 
827  void set_dbg_brn(brain* pt_brn){
828  SKELETON_DBG(
829  kg_pt_brn = pt_brn;
830  kg_tmp_cnf.set_dbg_brn(pt_brn);
831  );
832  }
833 
834  ch_string as_full_path(ch_string sklroute){
835  SKELETON_CK(kg_root_path != "");
836  SKELETON_CK(path_begins_with(sklroute, SKG_SKELETON_DIR));
837  return kg_root_path + sklroute;
838  }
839 
840  void start_local();
841  void clear_all();
842 
843  bool in_dbg_verif(){
844  return (kg_dbg_verifying_skeleton_tree || kg_dbg_local_verifying);
845  }
846 
847  canon_clause& get_new_clause();
848  void release_clause(canon_clause& ccl, bool free_mem);
849 
850  void init_skeleton_glb();
851  void init_paths();
852  void report_err(ch_string pth, ch_string err_pth);
853 
854  void reset_proof_path();
855 
856  bool find_skl_path(ch_string the_pth, instance_info* iinfo = NULL);
857 
858  bool in_skl(ch_string a_dir){
859  ch_string skl_pth = as_full_path(SKG_SKELETON_DIR);
860  return path_begins_with(a_dir, skl_pth);
861  }
862 
863  bool ref_in_skl(ch_string a_ref){
864  return path_begins_with(a_ref, SKG_SKELETON_DIR);
865  }
866 
867  bool ref_exists(ch_string a_ref);
868 
869  bool ref_create(ch_string a_ref);
870 
871  bool ref_find(ch_string a_ref){
872  ch_string f_pth = as_full_path(a_ref);
873  return find_skl_path(f_pth);
874  }
875 
876  bool ref_touch(ch_string a_ref);
877 
878  void ref_remove(ch_string a_ref){
879  ch_string f_pth = as_full_path(a_ref);
880  unlink(f_pth.c_str());
881  }
882 
883  void ref_write(ch_string nam_ref, ch_string val_ref);
884  ch_string ref_read(ch_string nam_ref);
885 
886  ch_string ref_vnt_name(ch_string vpth, ch_string sub_nm);
887 
888  long num_new_paths(){
889  return strset_size(kg_cnf_new_paths);
890  }
891 
892  void add_comment_chars_to(brain& brn, canon_cnf& diff_cnf,
893  ch_string sv_ref_pth, row<char>& cnn);
894 
895  int get_write_lock(ch_string lk_dir);
896  void drop_write_lock(ch_string lk_dir, int fd_lock);
897 
898  ch_string read_guide_sha_str(ch_string vpth);
899  void write_guide_sha_str(ch_string vpth, ch_string sha_str);
900 
901  bj_ostream& print_paths(bj_ostream& os);
902 };
903 
904 
905 //=================================================================
906 // printing operators
907 
908 DEFINE_PRINT_FUNCS(canon_clause);
909 DEFINE_PRINT_FUNCS(variant);
910 DEFINE_PRINT_FUNCS(canon_cnf);
911 
912 
913 #endif // SKELETON_H
914 
915 
916 
A canon_cnf is a BCFF. An stabilized sub-formula.
Definition: skeleton.h:386
Class that holds all data used to solve a particular CNF instance.
Definition: brain.h:3085
Class that holds an instance data.
Definition: instance_info.h:96
A skeleton_glb is a directory holding a database.
Definition: skeleton.h:761
Class for CNF clause behavior. So there is one neuron per clause.
Definition: brain.h:1211