mirror of
				https://github.com/Z3Prover/z3
				synced 2025-11-03 21:09:11 +00:00 
			
		
		
		
	Bugfix for distinct of floats.
This commit is contained in:
		
							parent
							
								
									f84d6bf5bb
								
							
						
					
					
						commit
						6980fb3035
					
				
					 3 changed files with 24 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -93,6 +93,20 @@ void fpa2bv_converter::mk_ite(expr * c, expr * t, expr * f, expr_ref & result) {
 | 
			
		|||
    mk_fp(sgn, e, s, result);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void fpa2bv_converter::mk_distinct(func_decl * f, unsigned num, expr * const * args, expr_ref & result) {
 | 
			
		||||
    // Note: in SMT there is only one NaN, so multiple of them are considered 
 | 
			
		||||
    // equal, thus (distinct NaN NaN) is false, even if the two NaNs have 
 | 
			
		||||
    // different bitwise representations (see also mk_eq).
 | 
			
		||||
    result = m.mk_true();
 | 
			
		||||
    for (unsigned i = 0; i < num; i++) {
 | 
			
		||||
        for (unsigned j = i+1; j < num; j++) {
 | 
			
		||||
            expr_ref eq(m);
 | 
			
		||||
            mk_eq(args[i], args[j], eq);
 | 
			
		||||
            m_simp.mk_and(result, m.mk_not(eq), result);
 | 
			
		||||
        }
 | 
			
		||||
    }    
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void fpa2bv_converter::mk_numeral(func_decl * f, unsigned num, expr * const * args, expr_ref & result) { 
 | 
			
		||||
    SASSERT(num == 0);
 | 
			
		||||
    SASSERT(f->get_num_parameters() == 1);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -80,6 +80,7 @@ public:
 | 
			
		|||
 | 
			
		||||
    void mk_eq(expr * a, expr * b, expr_ref & result);
 | 
			
		||||
    void mk_ite(expr * c, expr * t, expr * f, expr_ref & result);
 | 
			
		||||
    void mk_distinct(func_decl * f, unsigned num, expr * const * args, expr_ref & result);
 | 
			
		||||
 | 
			
		||||
    void mk_rounding_mode(func_decl * f, expr_ref & result);
 | 
			
		||||
    void mk_numeral(func_decl * f, unsigned num, expr * const * args, expr_ref & result);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -103,8 +103,7 @@ struct fpa2bv_rewriter_cfg : public default_rewriter_cfg {
 | 
			
		|||
            }
 | 
			
		||||
            return BR_FAILED;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (m().is_ite(f)) {
 | 
			
		||||
        else if (m().is_ite(f)) {
 | 
			
		||||
            SASSERT(num == 3);
 | 
			
		||||
            if (m_conv.is_float(args[1])) {
 | 
			
		||||
                m_conv.mk_ite(args[0], args[1], args[2], result);
 | 
			
		||||
| 
						 | 
				
			
			@ -112,6 +111,14 @@ struct fpa2bv_rewriter_cfg : public default_rewriter_cfg {
 | 
			
		|||
            }
 | 
			
		||||
            return BR_FAILED;
 | 
			
		||||
        }
 | 
			
		||||
        else if (m().is_distinct(f)) {
 | 
			
		||||
            sort * ds = f->get_domain()[0];
 | 
			
		||||
            if (m_conv.is_float(ds) || m_conv.is_rm(ds)) {
 | 
			
		||||
                m_conv.mk_distinct(f, num, args, result);
 | 
			
		||||
                return BR_DONE;
 | 
			
		||||
            }
 | 
			
		||||
            return BR_FAILED;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (m_conv.is_float_family(f)) {
 | 
			
		||||
            switch (f->get_decl_kind()) {            
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue