mirror of
https://github.com/Z3Prover/z3
synced 2026-06-02 15:17:54 +00:00
Refactor theory_seq::find_fst_non_empty_var to use std::optional (#8315)
* Initial plan * Refactor find_fst_non_empty_var to use std::optional Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Use value_or() for more idiomatic std::optional usage Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
parent
b4b0512f8d
commit
835ac1bb6d
2 changed files with 9 additions and 6 deletions
|
|
@ -1216,9 +1216,11 @@ bool theory_seq::find_better_rep(expr_ref_vector const& ls, expr_ref_vector cons
|
||||||
|
|
||||||
if (ls.empty() || rs.empty())
|
if (ls.empty() || rs.empty())
|
||||||
return false;
|
return false;
|
||||||
expr* l_fst = find_fst_non_empty_var(ls);
|
auto opt_l_fst = find_fst_non_empty_var(ls);
|
||||||
expr* r_fst = find_fst_non_empty_var(rs);
|
auto opt_r_fst = find_fst_non_empty_var(rs);
|
||||||
if (!r_fst) return false;
|
if (!opt_r_fst) return false;
|
||||||
|
expr* l_fst = opt_l_fst.value_or(nullptr);
|
||||||
|
expr* r_fst = *opt_r_fst;
|
||||||
expr_ref len_r_fst = mk_len(r_fst);
|
expr_ref len_r_fst = mk_len(r_fst);
|
||||||
expr_ref len_l_fst(m);
|
expr_ref len_l_fst(m);
|
||||||
enode * root2;
|
enode * root2;
|
||||||
|
|
@ -1303,11 +1305,11 @@ int theory_seq::find_fst_non_empty_idx(expr_ref_vector const& xs) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
expr* theory_seq::find_fst_non_empty_var(expr_ref_vector const& x) {
|
std::optional<expr*> theory_seq::find_fst_non_empty_var(expr_ref_vector const& x) {
|
||||||
int i = find_fst_non_empty_idx(x);
|
int i = find_fst_non_empty_idx(x);
|
||||||
if (i >= 0)
|
if (i >= 0)
|
||||||
return x[i];
|
return x[i];
|
||||||
return nullptr;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ Revision History:
|
||||||
--*/
|
--*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
#include "ast/seq_decl_plugin.h"
|
#include "ast/seq_decl_plugin.h"
|
||||||
#include "ast/rewriter/th_rewriter.h"
|
#include "ast/rewriter/th_rewriter.h"
|
||||||
#include "ast/rewriter/seq_skolem.h"
|
#include "ast/rewriter/seq_skolem.h"
|
||||||
|
|
@ -414,7 +415,7 @@ namespace smt {
|
||||||
void get_ite_concat(ptr_vector<expr>& head, ptr_vector<expr>& tail);
|
void get_ite_concat(ptr_vector<expr>& head, ptr_vector<expr>& tail);
|
||||||
|
|
||||||
int find_fst_non_empty_idx(expr_ref_vector const& x);
|
int find_fst_non_empty_idx(expr_ref_vector const& x);
|
||||||
expr* find_fst_non_empty_var(expr_ref_vector const& x);
|
std::optional<expr*> find_fst_non_empty_var(expr_ref_vector const& x);
|
||||||
bool has_len_offset(expr_ref_vector const& ls, expr_ref_vector const& rs, int & diff);
|
bool has_len_offset(expr_ref_vector const& ls, expr_ref_vector const& rs, int & diff);
|
||||||
|
|
||||||
// final check
|
// final check
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue