mirror of
				https://github.com/Z3Prover/z3
				synced 2025-10-31 03:32:28 +00:00 
			
		
		
		
	Lemma names
This commit is contained in:
		
							parent
							
								
									0c44391b9e
								
							
						
					
					
						commit
						4aa04fa475
					
				
					 6 changed files with 16 additions and 19 deletions
				
			
		|  | @ -298,26 +298,27 @@ namespace polysat { | |||
|                 m_vars.insert(v); | ||||
|     } | ||||
| 
 | ||||
|     void conflict::add_lemma(std::initializer_list<signed_constraint> cs) { | ||||
|         add_lemma(std::data(cs), cs.size()); | ||||
|     void conflict::add_lemma(char const* name, std::initializer_list<signed_constraint> cs) { | ||||
|         add_lemma(name, std::data(cs), cs.size()); | ||||
|     } | ||||
| 
 | ||||
|     void conflict::add_lemma(signed_constraint const* cs, size_t cs_len) { | ||||
|     void conflict::add_lemma(char const* name, signed_constraint const* cs, size_t cs_len) { | ||||
|         clause_builder cb(s); | ||||
|         for (size_t i = 0; i < cs_len; ++i) | ||||
|             cb.insert_eval(cs[i]); | ||||
|         add_lemma(cb.build()); | ||||
|         add_lemma(name, cb.build()); | ||||
|     } | ||||
| 
 | ||||
|     void conflict::add_lemma(clause_ref lemma) { | ||||
|     void conflict::add_lemma(char const* name, clause_ref lemma) { | ||||
|         LOG_H3("Lemma " << (name ? name : "<unknown>") << ": " << show_deref(lemma)); | ||||
|         SASSERT(lemma); | ||||
|         lemma->set_redundant(true); | ||||
|         LOG_H3("Lemma: " << *lemma); | ||||
|         for (sat::literal lit : *lemma) { | ||||
|             LOG(lit_pp(s, lit)); | ||||
|             SASSERT(s.m_bvars.value(lit) != l_true); | ||||
|         } | ||||
|         m_lemmas.push_back(std::move(lemma)); | ||||
|         // TODO: pass to inference_logger (with name)
 | ||||
|    } | ||||
| 
 | ||||
|     void conflict::remove(signed_constraint c) { | ||||
|  |  | |||
|  | @ -160,9 +160,9 @@ namespace polysat { | |||
|         void insert_eval(signed_constraint c); | ||||
| 
 | ||||
|         /** Add a side lemma to the conflict; to be learned in addition to the main lemma after conflict resolution finishes. */ | ||||
|         void add_lemma(std::initializer_list<signed_constraint> cs); | ||||
|         void add_lemma(signed_constraint const* cs, size_t cs_len); | ||||
|         void add_lemma(clause_ref lemma); | ||||
|         void add_lemma(char const* name, std::initializer_list<signed_constraint> cs); | ||||
|         void add_lemma(char const* name, signed_constraint const* cs, size_t cs_len); | ||||
|         void add_lemma(char const* name, clause_ref lemma); | ||||
| 
 | ||||
|         /** Remove c from core */ | ||||
|         void remove(signed_constraint c); | ||||
|  |  | |||
|  | @ -81,7 +81,7 @@ namespace polysat { | |||
|         SASSERT(c.bvalue(s) != l_true); | ||||
| 
 | ||||
|         m_lemma.insert(c); | ||||
|         core.add_lemma(m_lemma.build());  // TODO: log with name m_rule
 | ||||
|         core.add_lemma(m_rule, m_lemma.build()); | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -72,23 +72,19 @@ namespace polysat { | |||
|             SASSERT(c1.is_currently_true(s)); | ||||
|             SASSERT(c2.is_currently_false(s)); | ||||
|             SASSERT_EQ(c1.bvalue(s), l_true); | ||||
|             SASSERT(c2.bvalue(s) != l_false); | ||||
|             SASSERT_EQ(c2.bvalue(s), l_true); | ||||
| 
 | ||||
|             signed_constraint c = resolve1(v, c1, c2); | ||||
|             if (!c) | ||||
|                 continue; | ||||
|             SASSERT(c.is_currently_false(s)); | ||||
| 
 | ||||
|             // char const* inf_name = "?";
 | ||||
|             switch (c.bvalue(s)) { | ||||
|             case l_false: | ||||
|                 core.add_lemma({c, ~c1, ~c2}); | ||||
|                 // core.log_inference(inference_sup("l_false", v, c2, c1));
 | ||||
|                 core.add_lemma("superposition l_false", {c, ~c1, ~c2}); | ||||
|                 return l_true; | ||||
|             case l_undef: | ||||
|                 // inf_name = "l_undef";
 | ||||
|                 core.add_lemma({c, ~c1, ~c2}); | ||||
|                 // core.log_inference(inference_sup("l_undef lemma", v, c2, c1));
 | ||||
|                 core.add_lemma("superposition l_undef", {c, ~c1, ~c2}); | ||||
|                 break; | ||||
|             case l_true: | ||||
|                 break; | ||||
|  |  | |||
|  | @ -107,7 +107,7 @@ namespace polysat { | |||
|             cb.insert(~c); | ||||
|             cb.insert(~c_target); | ||||
|             cb.insert(c_new); | ||||
|             core.add_lemma(cb.build()); | ||||
|             core.add_lemma("variable elimination", cb.build()); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -726,7 +726,7 @@ namespace polysat { | |||
|         while (e != first); | ||||
| 
 | ||||
|         SASSERT(all_of(lemma, [this](sat::literal lit) { return s.m_bvars.value(lit) == l_false; })); | ||||
|         core.add_lemma(lemma.build()); | ||||
|         core.add_lemma("viable", lemma.build()); | ||||
|         core.logger().log(inf_fi(*this, v)); | ||||
|         return true; | ||||
|     } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue