Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugs in Z3 regard to String Theory #6658

Closed
Mingyu821 opened this issue Mar 30, 2023 · 1 comment
Closed

Bugs in Z3 regard to String Theory #6658

Mingyu821 opened this issue Mar 30, 2023 · 1 comment

Comments

@Mingyu821
Copy link

Mingyu821 commented Mar 30, 2023

  1. First, I cannot appoint class of ctx.mkToRe(ctx.mkString("")) to Expr<ReSort<SeqSort<CharSort>>>. It will result in an error in ctx.mkConcat. Is there any incompatibles in appointing exact classes?
  2. Second, ctx.mkOption api is not compatible when I want to use this api to perform "?" in Re expressions.

Code seen below:

public static BoolExpr addRegexOrTerms(List<String> regexList, Context ctx, Expr<SeqSort<CharSort>> var) {
        Expr<ReSort<SeqSort<CharSort>>> concat = ctx.mkToRe(ctx.mkString(""));
        Expr res;
        BoolExpr expr = ctx.mkFalse();
        for (String s : regexList) {
            for (int i = 0; i < s.length(); i++) {
                switch (s.charAt(i)) {
                    case '*':
                        res = ctx.mkFullRe(ctx.mkReSort(ctx.mkStringSort()));
                        break;
                    case '?':
                        res = ctx.mkOption(ctx.mkReSort(ctx.mkStringSort()));
                        break;
                    default:
                        res = ctx.mkToRe(ctx.mkString(String.valueOf(s.charAt(i))));
                }
                concat = ctx.mkConcat(concat, res);
            }
            expr = ctx.mkOr(expr, ctx.mkInRe(var, concat.simplify()));
        }
        return expr;
    }
NikolajBjorner added a commit that referenced this issue Mar 31, 2023
@NikolajBjorner
Copy link
Contributor

NikolajBjorner commented Mar 31, 2023


public static BoolExpr addRegexOrTerms(List<String> regexList, Context ctx, Expr<SeqSort<CharSort>> var) {
        ReExpr<SeqSort<CharSort>> concat = ctx.mkToRe(ctx.mkString(""));
        ReExpr<SeqSort<CharSort>> res;
        BoolExpr expr = ctx.mkFalse();
        for (String s : regexList) {
            for (int i = 0; i < s.length(); i++) {
                switch (s.charAt(i)) {
                    case '*':
                        res = ctx.mkFullRe(ctx.mkReSort(ctx.mkStringSort()));
                        break;
                    case '?':
                        res = ctx.mkOption(ctx.mkToRe(ctx.mkString(String.valueOf(s.charAt(i)))));
                        break;
                    default:
                        res = ctx.mkToRe(ctx.mkString(String.valueOf(s.charAt(i))));
                }
                concat = ctx.mkConcat(concat, res);
            }
            expr = ctx.mkOr(expr, ctx.mkInRe(var, concat.simplify()));
        }
        return expr;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants