mirror of
				https://github.com/Z3Prover/z3
				synced 2025-10-31 19:52:29 +00:00 
			
		
		
		
	update pd-maxres
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
		
							parent
							
								
									0bc45ca250
								
							
						
					
					
						commit
						e4ce6b6d74
					
				
					 2 changed files with 48 additions and 36 deletions
				
			
		|  | @ -41,6 +41,7 @@ namespace sat { | ||||||
|         m_mus.append(m_core); |         m_mus.append(m_core); | ||||||
|         s.m_core.reset(); |         s.m_core.reset(); | ||||||
|         s.m_core.append(m_mus); |         s.m_core.append(m_mus); | ||||||
|  |         TRACE("sat", tout << "new core: " << s.m_core << "\n";); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     void mus::update_model() { |     void mus::update_model() { | ||||||
|  | @ -61,7 +62,7 @@ namespace sat { | ||||||
|         flet<bool> _disable_min_partial(s.m_config.m_minimize_core_partial, false); |         flet<bool> _disable_min_partial(s.m_config.m_minimize_core_partial, false); | ||||||
|         flet<bool> _disable_opt(s.m_config.m_optimize_model, false); |         flet<bool> _disable_opt(s.m_config.m_optimize_model, false); | ||||||
|         flet<bool> _is_active(m_is_active, true); |         flet<bool> _is_active(m_is_active, true); | ||||||
|         IF_VERBOSE(2, verbose_stream() << "(sat.mus " << s.get_core() << ")\n";); |         IF_VERBOSE(3, verbose_stream() << "(sat.mus " << s.get_core() << ")\n";); | ||||||
|         reset(); |         reset(); | ||||||
|         return mus1(); |         return mus1(); | ||||||
|     } |     } | ||||||
|  | @ -77,7 +78,7 @@ namespace sat { | ||||||
|         unsigned delta_time  = 0; |         unsigned delta_time  = 0; | ||||||
|         unsigned core_miss = 0; |         unsigned core_miss = 0; | ||||||
|         while (!core.empty()) { |         while (!core.empty()) { | ||||||
|             IF_VERBOSE(2, verbose_stream() << "(opt.mus reducing core: " << core.size() << " new core: " << mus.size() << ")\n";); |             IF_VERBOSE(3, verbose_stream() << "(opt.mus reducing core: " << core.size() << " mus: " << mus.size() << ")\n";); | ||||||
|             TRACE("sat",  |             TRACE("sat",  | ||||||
|                   tout << "core: " << core << "\n"; |                   tout << "core: " << core << "\n"; | ||||||
|                   tout << "mus:  " << mus  << "\n";); |                   tout << "mus:  " << mus  << "\n";); | ||||||
|  | @ -121,12 +122,12 @@ namespace sat { | ||||||
|             case l_false: |             case l_false: | ||||||
|                 literal_vector const& new_core = s.get_core(); |                 literal_vector const& new_core = s.get_core(); | ||||||
|                 if (new_core.contains(~lit)) { |                 if (new_core.contains(~lit)) { | ||||||
|                     IF_VERBOSE(2, verbose_stream() << "miss core " << lit << "\n";); |                     IF_VERBOSE(3, verbose_stream() << "miss core " << lit << "\n";); | ||||||
|                     ++core_miss; |                     ++core_miss; | ||||||
|                 } |                 } | ||||||
|                 else { |                 else { | ||||||
|                     core_miss = 0; |                     core_miss = 0; | ||||||
|                     TRACE("sat", tout << "new core: " << new_core << "\n";); |                     TRACE("sat", tout << "core: " << new_core << " mus: " << mus << "\n";); | ||||||
|                     core.reset(); |                     core.reset(); | ||||||
|                     for (unsigned i = 0; i < new_core.size(); ++i) { |                     for (unsigned i = 0; i < new_core.size(); ++i) { | ||||||
|                         literal lit = new_core[i]; |                         literal lit = new_core[i]; | ||||||
|  | @ -146,9 +147,8 @@ namespace sat { | ||||||
|                 delta_time = 0; |                 delta_time = 0; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         TRACE("sat", tout << "new core: " << mus << "\n";); |  | ||||||
|         set_core(); |         set_core(); | ||||||
|         IF_VERBOSE(2, verbose_stream() << "(sat.mus.new " << s.m_core << ")\n";); |         IF_VERBOSE(3, verbose_stream() << "(sat.mus.new " << s.m_core << ")\n";); | ||||||
|         return l_true; |         return l_true; | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  | @ -160,7 +160,7 @@ namespace sat { | ||||||
|         lbool is_sat = qx(core, support, false); |         lbool is_sat = qx(core, support, false); | ||||||
|         s.m_core.reset(); |         s.m_core.reset(); | ||||||
|         s.m_core.append(core.to_vector()); |         s.m_core.append(core.to_vector()); | ||||||
|         IF_VERBOSE(2, verbose_stream() << "(sat.mus.new " << s.m_core << ")\n";); |         IF_VERBOSE(3, verbose_stream() << "(sat.mus.new " << s.m_core << ")\n";); | ||||||
|         return is_sat; |         return is_sat; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -269,11 +269,11 @@ namespace sat { | ||||||
|             if (is_sat == l_true) { |             if (is_sat == l_true) { | ||||||
|                 m_mus.push_back(tabu[i]); |                 m_mus.push_back(tabu[i]); | ||||||
|                 m_core.erase(tabu[i]); |                 m_core.erase(tabu[i]); | ||||||
|                 IF_VERBOSE(2, verbose_stream() << "in core " << tabu[i] << "\n";); |                 IF_VERBOSE(3, verbose_stream() << "in core " << tabu[i] << "\n";); | ||||||
|                 reuse_model = true; |                 reuse_model = true; | ||||||
|             } |             } | ||||||
|             else { |             else { | ||||||
|                 IF_VERBOSE(2, verbose_stream() << "NOT in core " << tabu[i] << "\n";); |                 IF_VERBOSE(3, verbose_stream() << "NOT in core " << tabu[i] << "\n";); | ||||||
|                 reuse_model = false; |                 reuse_model = false; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -943,23 +943,25 @@ namespace sat { | ||||||
|         flet<bool> _min2(m_config.m_minimize_core_partial, false); |         flet<bool> _min2(m_config.m_minimize_core_partial, false); | ||||||
|         m_weight = 0; |         m_weight = 0; | ||||||
|         m_blocker.reset(); |         m_blocker.reset(); | ||||||
|         m_min_core_valid = false; |         svector<lbool> values; | ||||||
|         m_min_core.reset(); |         unsigned num_cores = 0; | ||||||
|         for (unsigned i = 0; !inconsistent() && i < num_lits; ++i) { |         for (unsigned i = 0; !inconsistent() && i < num_lits; ++i) { | ||||||
|             literal lit = lits[i]; |             literal lit = lits[i]; | ||||||
|             SASSERT(is_external(lit.var()));   |             SASSERT(is_external(lit.var()));   | ||||||
|             TRACE("sat", tout << "propagate: " << lit << " " << value(lit) << "\n";); |             TRACE("sat", tout << "propagate: " << lit << " " << value(lit) << "\n";); | ||||||
|             SASSERT(m_scope_lvl == 1); |             SASSERT(m_scope_lvl == 1); | ||||||
| 
 |             add_assumption(lit);   | ||||||
|             switch(value(lit)) { |             switch(value(lit)) { | ||||||
|             case l_undef: |             case l_undef: | ||||||
|                 add_assumption(lit);   |                 values.push_back(l_true); | ||||||
|                 assign(lit, justification()); |                 assign(lit, justification()); | ||||||
|                 propagate(false); |                 if (num_cores*2 >= num_lits) { | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|  |                 propagate(false);                 | ||||||
|                 if (inconsistent()) { |                 if (inconsistent()) { | ||||||
|                     pop_assumption(); |  | ||||||
|                     flet<bool> _init(m_initializing_preferred, true); |                     flet<bool> _init(m_initializing_preferred, true); | ||||||
|                     while (inconsistent()) { |                     while (inconsistent()) {                         | ||||||
|                         if (!resolve_conflict()) { |                         if (!resolve_conflict()) { | ||||||
|                             return true; |                             return true; | ||||||
|                         } |                         } | ||||||
|  | @ -968,23 +970,33 @@ namespace sat { | ||||||
|                     if (m_scope_lvl == 0) { |                     if (m_scope_lvl == 0) { | ||||||
|                         return false; |                         return false; | ||||||
|                     } |                     } | ||||||
|                     for (; i < num_lits; ++i) { |                     // backjump to last consistent assumption:
 | ||||||
|                         literal lit = lits[i]; |                     unsigned j; | ||||||
|                         if (value(lit) == l_undef) { |                     for (j = 0; j < i && value(lits[j]) == values[j]; ++j); | ||||||
|                             assign(lit, justification()); |                     SASSERT(value(lits[j]) != values[j]); | ||||||
|                             add_assumption(lit);   |                     SASSERT(j <= i); | ||||||
|  |                     SASSERT(j == 0 || value(lits[j-1]) == values[j-1]); | ||||||
|  |                     for (unsigned k = i; k >= j; --k)  { | ||||||
|  |                         if (is_assumption(lits[k])) { | ||||||
|  |                             pop_assumption(); | ||||||
|                         }                         |                         }                         | ||||||
|                     } |                     } | ||||||
|                     return true; |                     values.resize(j); | ||||||
|  |                     TRACE("sat", tout << "backjump " << (i - j + 1) << " steps " << num_cores << "\n";); | ||||||
|  |                     i = j - 1; | ||||||
|                 } |                 } | ||||||
|                 break;                 |                 break;                 | ||||||
|                  |                  | ||||||
|             case l_false:  |             case l_false:  | ||||||
|                 add_assumption(lit);   |                 ++num_cores; | ||||||
|  |                 values.push_back(l_false); | ||||||
|                 SASSERT(!inconsistent()); |                 SASSERT(!inconsistent()); | ||||||
|                 set_conflict(justification(), ~lit); |                 set_conflict(justification(), ~lit); | ||||||
|                 m_conflict_lvl = m_scope_lvl; |                 m_conflict_lvl = scope_lvl(); | ||||||
|                 resolve_conflict_for_unsat_core(); |                 resolve_conflict_for_unsat_core(); | ||||||
|  |                 IF_VERBOSE(3, verbose_stream() << "core: " << m_core << "\n";); | ||||||
|  |                 update_min_core(); | ||||||
|  |                 SASSERT(m_min_core_valid); | ||||||
|                 m_weight += weights[i]; |                 m_weight += weights[i]; | ||||||
|                 if (m_weight <= max_weight) { |                 if (m_weight <= max_weight) { | ||||||
|                     m_blocker.push_back(lit); |                     m_blocker.push_back(lit); | ||||||
|  | @ -998,26 +1010,18 @@ namespace sat { | ||||||
|                     IF_VERBOSE(11, verbose_stream() << "small core: " << m_core << "\n";); |                     IF_VERBOSE(11, verbose_stream() << "small core: " << m_core << "\n";); | ||||||
|                     return true; |                     return true; | ||||||
|                 } |                 } | ||||||
|                 update_min_core(); |  | ||||||
|                 SASSERT(m_min_core_valid); |  | ||||||
|                 pop_assumption(); |                 pop_assumption(); | ||||||
|                 m_inconsistent = false;  |                 m_inconsistent = false;  | ||||||
|                 break; |                 break; | ||||||
|             case l_true: { |             case l_true:  | ||||||
|                 justification j = m_justification[lit.var()]; |                 values.push_back(l_true); | ||||||
|                 if (j.get_kind() == justification::NONE) { |                 SASSERT(m_justification[lit.var()].get_kind() != justification::NONE || lvl(lit) == 0); | ||||||
|                     add_assumption(lit); |  | ||||||
|                 }             |  | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
|             } |  | ||||||
|         } |         } | ||||||
|         TRACE("sat", tout << "initialized\n";); |         TRACE("sat", tout << "initialized\n";); | ||||||
|         IF_VERBOSE(11, verbose_stream() << "Blocker: " << m_blocker << "\nCore: " << m_min_core << "\n";); |         IF_VERBOSE(11, verbose_stream() << "Blocker: " << m_blocker << "\nCore: " << m_min_core << "\n";); | ||||||
|         if (m_min_core_valid && m_blocker.size() >= m_min_core.size()) { |         if (m_weight >= max_weight) { | ||||||
|             reassert_min_core(); |  | ||||||
|         } |  | ||||||
|         else if (m_weight >= max_weight) { |  | ||||||
|             // block the current correction set candidate.
 |             // block the current correction set candidate.
 | ||||||
|             ++m_stats.m_blocked_corr_sets; |             ++m_stats.m_blocked_corr_sets; | ||||||
|             TRACE("opt", tout << "blocking soft correction set: " << m_blocker << "\n";);  |             TRACE("opt", tout << "blocking soft correction set: " << m_blocker << "\n";);  | ||||||
|  | @ -1103,6 +1107,8 @@ namespace sat { | ||||||
|         m_stopwatch.reset(); |         m_stopwatch.reset(); | ||||||
|         m_stopwatch.start(); |         m_stopwatch.start(); | ||||||
|         m_core.reset(); |         m_core.reset(); | ||||||
|  |         m_min_core_valid = false; | ||||||
|  |         m_min_core.reset(); | ||||||
|         TRACE("sat", display(tout);); |         TRACE("sat", display(tout);); | ||||||
|          |          | ||||||
|         if (m_config.m_bcd) { |         if (m_config.m_bcd) { | ||||||
|  | @ -2005,11 +2011,17 @@ namespace sat { | ||||||
|         }         |         }         | ||||||
|         reset_unmark(old_size); |         reset_unmark(old_size); | ||||||
|         if (m_config.m_minimize_core || m_config.m_minimize_core_partial) { |         if (m_config.m_minimize_core || m_config.m_minimize_core_partial) { | ||||||
|  |             if (m_min_core_valid && m_min_core.size() < m_core.size()) { | ||||||
|  |                 IF_VERBOSE(1, verbose_stream() << "(sat.updating core " << m_min_core.size() << " " << m_core.size() << ")\n";); | ||||||
|  |                 m_core.reset(); | ||||||
|  |                 m_core.append(m_min_core); | ||||||
|  |             } | ||||||
|             // TBD: 
 |             // TBD: 
 | ||||||
|             // apply optional clause minimization by detecting subsumed literals.
 |             // apply optional clause minimization by detecting subsumed literals.
 | ||||||
|             // initial experiment suggests it has no effect.
 |             // initial experiment suggests it has no effect.
 | ||||||
|             m_mus(); // ignore return value on cancelation.
 |             m_mus(); // ignore return value on cancelation.
 | ||||||
|             set_model(m_mus.get_model()); |             set_model(m_mus.get_model()); | ||||||
|  |             IF_VERBOSE(2, verbose_stream() << "(sat.core: " << m_core << ")\n";); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue