3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-07-11 17:46:20 +00:00

more unit tests

This commit is contained in:
Margus Veanes 2026-07-02 14:51:16 +03:00
parent d1b0cbee34
commit 0b9b6b5869
13 changed files with 240 additions and 0 deletions

View file

@ -0,0 +1,15 @@
; D0 copy baseline (difficulty: trivial; 1 var, occ 2, coupling none)
; Derived from: duplicate-line matcher (^|\n)(.*)(\n\2)+
; Word equation: x . '#' . x = "ab#ab" (backreference \2 -> variable x repeated twice)
; Expected: sat (unique split forces x = "ab")
(set-logic QF_S)
(set-info :smt-lib-version 2.6)
(set-info :status sat)
(set-info :category "crafted")
(set-info :source |Synthetic word-equation difficulty ladder, grounded in the data/backrefs.json regex corpus (resharp-node). Encoding: a backreference becomes a REPEATED string variable; a lookaround becomes a membership constraint (positive = & = conjoined str.in_re; negative-over-backref = ~ = not str.contains). Statuses verified by brute force + parity/length arguments.|)
(declare-fun x () String)
(assert (= (str.++ x "#" x) "ab#ab"))
(check-sat)

View file

@ -0,0 +1,16 @@
; D1 square with structural domain (difficulty: low; 1 var, occ 2, coupling global-structural &)
; Derived from: duplicate-substring lookahead (.{3,})(?=.*\1)
; Word equation: x . x in (ab)* , x in (a|b)+
; Expected: sat (x = "ab" -> abab ; note x="a" fails, so the (ab)* constraint bites)
(set-logic QF_S)
(set-info :smt-lib-version 2.6)
(set-info :status sat)
(set-info :category "crafted")
(set-info :source |Synthetic word-equation difficulty ladder, grounded in the data/backrefs.json regex corpus (resharp-node). Encoding: a backreference becomes a REPEATED string variable; a lookaround becomes a membership constraint (positive = & = conjoined str.in_re; negative-over-backref = ~ = not str.contains). Statuses verified by brute force + parity/length arguments.|)
(declare-fun x () String)
(assert (str.in_re x (re.+ (re.union (str.to_re "a") (str.to_re "b")))))
(assert (str.in_re (str.++ x x) (re.* (str.to_re "ab"))))
(check-sat)

View file

@ -0,0 +1,22 @@
; D2 tag nesting with complement (difficulty: low; 2 vars, occ 2, coupling complement ~)
; Derived from: HTML/XML body <([a-z]+)((?!</\1).)*</\1>
; Simplified: open marker 'o', close marker 'c'; name x; body B. Match = o . x . B . c . x
; The negative lookahead (?!</\1) -> body must NOT contain the close token 'c'.x :
; ~-coupling rendered as (not (str.contains B (str.++ "c" x))) (variable-coupled -> not a fixed re.comp)
; Expected: sat (x="a", B="" -> "oaca")
(set-logic QF_S)
(set-info :smt-lib-version 2.6)
(set-info :status sat)
(set-info :category "crafted")
(set-info :source |Synthetic word-equation difficulty ladder, grounded in the data/backrefs.json regex corpus (resharp-node). Encoding: a backreference becomes a REPEATED string variable; a lookaround becomes a membership constraint (positive = & = conjoined str.in_re; negative-over-backref = ~ = not str.contains). Statuses verified by brute force + parity/length arguments.|)
(declare-fun x () String)
(declare-fun B () String)
(declare-fun w () String)
(assert (str.in_re x (re.+ (re.union (str.to_re "a") (str.to_re "b")))))
(assert (str.in_re B (re.* (re.union (re.union (str.to_re "a") (str.to_re "b")) (str.to_re "c")))))
(assert (= w (str.++ "o" x B "c" x)))
(assert (not (str.contains B (str.++ "c" x))))
(check-sat)

View file

@ -0,0 +1,24 @@
; D3 two-variable existence coupling (difficulty: medium; 2 vars, occ 2 each; richest REAL shape)
; Derived from: VB block matcher ^([\t ]*)(\w+).*?\n\1End\2 (couples indent \1 AND name \2)
; Simplified: indent i over {s,t}; name x over {a,b}; End marker 'e'; body M.
; Match = i . x . M . i . e . x (i repeated twice, x repeated twice = two coupled backreferences)
; Non-greedy body .*? -> (not (str.contains M (str.++ i "e" x)))
; Expected: sat (i="", x="a", M="" -> "aea")
(set-logic QF_S)
(set-info :smt-lib-version 2.6)
(set-info :status sat)
(set-info :category "crafted")
(set-info :source |Synthetic word-equation difficulty ladder, grounded in the data/backrefs.json regex corpus (resharp-node). Encoding: a backreference becomes a REPEATED string variable; a lookaround becomes a membership constraint (positive = & = conjoined str.in_re; negative-over-backref = ~ = not str.contains). Statuses verified by brute force + parity/length arguments.|)
(declare-fun i () String)
(declare-fun x () String)
(declare-fun M () String)
(declare-fun w () String)
(assert (str.in_re i (re.* (re.union (str.to_re "s") (str.to_re "t")))))
(assert (str.in_re x (re.+ (re.union (str.to_re "a") (str.to_re "b")))))
(assert (str.in_re M (re.* (re.union (re.union (str.to_re "a") (str.to_re "b")) (re.union (str.to_re "e") (re.union (str.to_re "s") (str.to_re "t")))))))
(assert (= w (str.++ i x M i "e" x)))
(assert (not (str.contains M (str.++ i "e" x))))
(check-sat)

View file

@ -0,0 +1,16 @@
; D4 global structural, parity-TUNABLE (difficulty: medium; 1 var, occ 2, coupling global-structural &)
; Derived from: D1 generalized with a fixed middle delimiter d of tunable length.
; Word equation: x . eps . x in (ab)* , x in (a|b)*
; This instance: d = eps -> SAT (even length 2|x|; x=ab -> abab)
(set-logic QF_S)
(set-info :smt-lib-version 2.6)
(set-info :status sat)
(set-info :category "crafted")
(set-info :source |Synthetic word-equation difficulty ladder, grounded in the data/backrefs.json regex corpus (resharp-node). Encoding: a backreference becomes a REPEATED string variable; a lookaround becomes a membership constraint (positive = & = conjoined str.in_re; negative-over-backref = ~ = not str.contains). Statuses verified by brute force + parity/length arguments.|)
(declare-fun x () String)
(assert (str.in_re x (re.* (re.union (str.to_re "a") (str.to_re "b")))))
(assert (str.in_re (str.++ x x) (re.* (str.to_re "ab"))))
(check-sat)

View file

@ -0,0 +1,16 @@
; D4 global structural, parity-TUNABLE (difficulty: medium; 1 var, occ 2, coupling global-structural &)
; Derived from: D1 generalized with a fixed middle delimiter d of tunable length.
; Word equation: x . "ab" . x in (ab)* , x in (a|b)*
; This instance: d = "ab" -> SAT (even length; x=eps -> ab, or x=ab -> ababab)
(set-logic QF_S)
(set-info :smt-lib-version 2.6)
(set-info :status sat)
(set-info :category "crafted")
(set-info :source |Synthetic word-equation difficulty ladder, grounded in the data/backrefs.json regex corpus (resharp-node). Encoding: a backreference becomes a REPEATED string variable; a lookaround becomes a membership constraint (positive = & = conjoined str.in_re; negative-over-backref = ~ = not str.contains). Statuses verified by brute force + parity/length arguments.|)
(declare-fun x () String)
(assert (str.in_re x (re.* (re.union (str.to_re "a") (str.to_re "b")))))
(assert (str.in_re (str.++ x "ab" x) (re.* (str.to_re "ab"))))
(check-sat)

View file

@ -0,0 +1,16 @@
; D4 global structural, parity-TUNABLE (difficulty: medium; 1 var, occ 2, coupling global-structural &)
; Derived from: D1 generalized with a fixed middle delimiter d of tunable length.
; Word equation: x . "a" . x in (ab)* , x in (a|b)*
; This instance: d = "a" -> UNSAT (length 2|x|+1 is ODD; (ab)* is even-length only)
(set-logic QF_S)
(set-info :smt-lib-version 2.6)
(set-info :status unsat)
(set-info :category "crafted")
(set-info :source |Synthetic word-equation difficulty ladder, grounded in the data/backrefs.json regex corpus (resharp-node). Encoding: a backreference becomes a REPEATED string variable; a lookaround becomes a membership constraint (positive = & = conjoined str.in_re; negative-over-backref = ~ = not str.contains). Statuses verified by brute force + parity/length arguments.|)
(declare-fun x () String)
(assert (str.in_re x (re.* (re.union (str.to_re "a") (str.to_re "b")))))
(assert (str.in_re (str.++ x "a" x) (re.* (str.to_re "ab"))))
(check-sat)

View file

@ -0,0 +1,16 @@
; D4 global structural, parity-TUNABLE (difficulty: medium; 1 var, occ 2, coupling global-structural &)
; Derived from: D1 generalized with a fixed middle delimiter d of tunable length.
; Word equation: x . "b" . x in (ab)* , x in (a|b)*
; This instance: d = "b" -> UNSAT (same parity argument as d4c)
(set-logic QF_S)
(set-info :smt-lib-version 2.6)
(set-info :status unsat)
(set-info :category "crafted")
(set-info :source |Synthetic word-equation difficulty ladder, grounded in the data/backrefs.json regex corpus (resharp-node). Encoding: a backreference becomes a REPEATED string variable; a lookaround becomes a membership constraint (positive = & = conjoined str.in_re; negative-over-backref = ~ = not str.contains). Statuses verified by brute force + parity/length arguments.|)
(declare-fun x () String)
(assert (str.in_re x (re.* (re.union (str.to_re "a") (str.to_re "b")))))
(assert (str.in_re (str.++ x "b" x) (re.* (str.to_re "ab"))))
(check-sat)

View file

@ -0,0 +1,18 @@
; D5 two variables, global structural (SAT variant of user seed) (difficulty: medium; 2 vars, occ 2 each)
; Derived from: user seed (?:(?=^(ab)*$))(a*)(b*)(a|b)\2\1, middle char removed (even-length cousin)
; Word equation: x . y . x . y in (ab)* , x in a+ , y in b+
; Expected: sat (x="a", y="b" -> abab ; alternation forces exactly this for nonempty x,y)
(set-logic QF_S)
(set-info :smt-lib-version 2.6)
(set-info :status sat)
(set-info :category "crafted")
(set-info :source |Synthetic word-equation difficulty ladder, grounded in the data/backrefs.json regex corpus (resharp-node). Encoding: a backreference becomes a REPEATED string variable; a lookaround becomes a membership constraint (positive = & = conjoined str.in_re; negative-over-backref = ~ = not str.contains). Statuses verified by brute force + parity/length arguments.|)
(declare-fun x () String)
(declare-fun y () String)
(assert (str.in_re x (re.+ (str.to_re "a"))))
(assert (str.in_re y (re.+ (str.to_re "b"))))
(assert (str.in_re (str.++ x y x y) (re.* (str.to_re "ab"))))
(check-sat)

View file

@ -0,0 +1,24 @@
; D6 USER SEED, UNSAT by parity (difficulty: hard; 2 vars, occ 2 each, coupling global-structural &)
; Derived from EXACTLY: (?:(?=^(ab)*$))(a*)(b*)(a|b)\2\1 with the (a|b) alternative fixed to 'a'.
; Body (a*)(b*)(a|b)\2\1 -> x . y . a . y . x ; x in a* , y in b*
; Lookahead (?=^(ab)*$) -> & : the whole word in (ab)* [BINDING constraint]
; Body language a*b*(a|b)b*a* -> & : second membership (auto-satisfied by the term shape; shown for fidelity)
; Expected: UNSAT. |x.y.a.y.x| = 2|x|+2|y|+1 is ALWAYS odd, but (ab)* has only even-length words.
; Consequence: the user's seed regex matches NO string (empty language).
(set-logic QF_S)
(set-info :smt-lib-version 2.6)
(set-info :status unsat)
(set-info :category "crafted")
(set-info :source |Synthetic word-equation difficulty ladder, grounded in the data/backrefs.json regex corpus (resharp-node). Encoding: a backreference becomes a REPEATED string variable; a lookaround becomes a membership constraint (positive = & = conjoined str.in_re; negative-over-backref = ~ = not str.contains). Statuses verified by brute force + parity/length arguments.|)
(declare-fun x () String)
(declare-fun y () String)
(declare-fun w () String)
(assert (str.in_re x (re.* (str.to_re "a"))))
(assert (str.in_re y (re.* (str.to_re "b"))))
(assert (= w (str.++ x y "a" y x)))
(assert (str.in_re w (re.* (str.to_re "ab"))))
(assert (str.in_re w (re.++ (re.* (str.to_re "a")) (re.* (str.to_re "b")) (re.union (str.to_re "a") (str.to_re "b")) (re.* (str.to_re "b")) (re.* (str.to_re "a")))))
(check-sat)

View file

@ -0,0 +1,16 @@
; D7 cube / high multiplicity (difficulty: medium-hard; 1 var, occ 3, coupling global-structural &)
; Derived from: nested-tag matchers where the tag-name backreference \1 occurs 4x.
; Word equation: x . x . x in (ab)* , x in (a|b)+
; Expected: sat (x="ab" -> ababab). Stresses repeated-variable multiplicity.
(set-logic QF_S)
(set-info :smt-lib-version 2.6)
(set-info :status sat)
(set-info :category "crafted")
(set-info :source |Synthetic word-equation difficulty ladder, grounded in the data/backrefs.json regex corpus (resharp-node). Encoding: a backreference becomes a REPEATED string variable; a lookaround becomes a membership constraint (positive = & = conjoined str.in_re; negative-over-backref = ~ = not str.contains). Statuses verified by brute force + parity/length arguments.|)
(declare-fun x () String)
(assert (str.in_re x (re.+ (re.union (str.to_re "a") (str.to_re "b")))))
(assert (str.in_re (str.++ x x x) (re.* (str.to_re "ab"))))
(check-sat)

View file

@ -0,0 +1,22 @@
; D8 counting / Parikh coupling (difficulty axis: LENGTH not content; 2 vars)
; Derived from: Rust raw string b?r(#*)"..."\1 and markdown fence (`+)...\1 (run lengths must match).
; Simplified: opening #-run x (backref \1 forces closing run = x, same variable); content M; quotes 'q'.
; Match = r . x . q . M . q . x with a linear length coupling |M| = 3*|x| (Parikh-style).
; Expected: sat (x="#", M="aaa" -> |M|=3=3*1). Add stronger length constraints to scale to Presburger-hard.
(set-logic QF_SLIA)
(set-info :smt-lib-version 2.6)
(set-info :status sat)
(set-info :category "crafted")
(set-info :source |Synthetic word-equation difficulty ladder, grounded in the data/backrefs.json regex corpus (resharp-node). Encoding: a backreference becomes a REPEATED string variable; a lookaround becomes a membership constraint (positive = & = conjoined str.in_re; negative-over-backref = ~ = not str.contains). Statuses verified by brute force + parity/length arguments.|)
(declare-fun x () String)
(declare-fun M () String)
(declare-fun w () String)
(assert (str.in_re x (re.* (str.to_re "#"))))
(assert (str.in_re M (re.* (re.union (str.to_re "a") (str.to_re "b")))))
(assert (= w (str.++ "r" x "q" M "q" x)))
(assert (>= (str.len x) 1))
(assert (= (str.len M) (* 3 (str.len x))))
(check-sat)

View file

@ -0,0 +1,19 @@
; D9 classic commutation equation, UNSAT (difficulty: hard; 2 vars; calibration point)
; Not from the corpus: a canonical word-equation hardness reference (two-sided equation).
; Word equation: x . y = y . x , x in a+ , y in b+
; Expected: UNSAT. xy=yx holds iff x,y are powers of a common word; x is all-a, y is all-b,
; both nonempty -> no common word -> unsatisfiable.
(set-logic QF_S)
(set-info :smt-lib-version 2.6)
(set-info :status unsat)
(set-info :category "crafted")
(set-info :source |Synthetic word-equation difficulty ladder, grounded in the data/backrefs.json regex corpus (resharp-node). Encoding: a backreference becomes a REPEATED string variable; a lookaround becomes a membership constraint (positive = & = conjoined str.in_re; negative-over-backref = ~ = not str.contains). Statuses verified by brute force + parity/length arguments.|)
(declare-fun x () String)
(declare-fun y () String)
(assert (str.in_re x (re.+ (str.to_re "a"))))
(assert (str.in_re y (re.+ (str.to_re "b"))))
(assert (= (str.++ x y) (str.++ y x)))
(check-sat)