From 4de3d3f35d12b0ad0ae36b9cb9c860309ba9fa28 Mon Sep 17 00:00:00 2001 From: "Ruanqianqian (Lisa) Huang" Date: Wed, 27 Jul 2022 15:38:26 -0700 Subject: [PATCH 01/18] change python to z3-python in `programming python/introduction.md` --- .../01 - Introduction.md | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/01 - Introduction.md b/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/01 - Introduction.md index 8372c45b3..137edd676 100644 --- a/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/01 - Introduction.md +++ b/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/01 - Introduction.md @@ -36,7 +36,7 @@ The Python bindings are available from pypi. You can install them using the foll Let us start with the following simple example: -```python +```z3-python x = Int('x') y = Int('y') solve(x > 2, y < 10, x + 2*y == 7) @@ -56,7 +56,7 @@ Z3 can solve and crunch formulas. The next examples show how to use the Z3 formula/expression simplifier. -```python +```z3-python x = Int('x') y = Int('y') print (simplify(x + y + 2*x + 3)) @@ -70,7 +70,7 @@ The command `set_option(html_mode=False)` makes all formulas and expressions to displayed in Z3Py notation. This is also the default mode for the offline version of Z3Py that comes with the Z3 distribution. -```python +```z3-python x = Int('x') y = Int('y') print (x**2 + y**2 >= 1) @@ -81,7 +81,7 @@ print (x**2 + y**2 >= 1) Z3 provides functions for traversing expressions. -```python +```z3-python x = Int('x') y = Int('y') n = x + y >= 3 @@ -96,7 +96,7 @@ print ("op name: ", n.decl().name()) Z3 provides all basic mathematical operations. Z3Py uses the same operator precedence of the Python language. Like Python, `**` is the power operator. Z3 can solve nonlinear _polynomial_ constraints. -```python +```z3-python x = Real('x') y = Real('y') solve(x**2 + y**2 > 3, x**3 + y < 5) @@ -108,7 +108,7 @@ and irrational algebraic numbers. An irrational algebraic number is a root of a Internally, Z3 represents all these numbers precisely. Irrational numbers are displayed in decimal notation for making it easy to read the results. -```python +```z3-python x = Real('x') y = Real('y') solve(x**2 + y**2 == 3, x**3 == 2) @@ -130,7 +130,7 @@ The example also shows different ways to create rational numbers in Z3Py. The pr Z3 rational where `num` is the numerator and `den` is the denominator. The `RealVal(1)` creates a Z3 real number representing the number `1`. -```python +```z3-python print 1/3 print RealVal(1)/3 print Q(1,3) @@ -146,7 +146,7 @@ print (x + 0.25) Rational numbers can also be displayed in decimal notation. -```python +```z3-python x = Real('x') solve(3*x == 1) @@ -160,7 +160,7 @@ solve(3*x == 1) A system of constraints may not have a solution. In this case, we say the system is **unsatisfiable**. -```python +```z3-python x = Real('x') solve(x > 4, x < 0) ``` @@ -169,7 +169,7 @@ solve(x > 4, x < 0) Like in Python, comments begin with the hash character `#` and are terminated by the end of line. Z3Py does not support comments that span more than one line. -```python +```z3-python # This is a comment x = Real('x') # comment: creating x print (x**2 + 2*x + 2) # comment: printing polynomial @@ -182,7 +182,7 @@ Z3 supports Boolean operators: `And`, `Or`, `Not`, `Implies` (implication), `If` (if-then-else). Bi-implications are represented using equality `==`. The following example shows how to solve a simple set of Boolean constraints. -```python +```z3-python p = Bool('p') q = Bool('q') r = Bool('r') @@ -192,7 +192,7 @@ solve(Implies(p, q), r == Not(q), Or(Not(p), r)) The Python Boolean constants `True` and `False` can be used to build Z3 Boolean expressions. -```python +```z3-python p = Bool('p') q = Bool('q') print (And(p, q, True)) @@ -202,7 +202,7 @@ print (simplify(And(p, False))) The following example uses a combination of polynomial and Boolean constraints. -```python +```z3-python p = Bool('p') x = Real('x') solve(Or(x < 5, x > 10), Or(p, x**2 == 2), Not(p)) @@ -214,7 +214,7 @@ Z3 provides different solvers. The command `solve`, used in the previous example The implementation can be found in the file `z3.py` in the Z3 distribution. The following example demonstrates the basic Solver API. -```python +```z3-python x = Int('x') y = Int('y') @@ -256,7 +256,7 @@ The `check` method always operates on the content of solver assertion stack. The following example shows an example that Z3 cannot solve. The solver returns `unknown` in this case. Recall that Z3 can solve nonlinear polynomial constraints, but `2**x` is not a polynomial. -```python +```z3-python x = Real('x') s = Solver() s.add(2**x == 3) @@ -266,7 +266,7 @@ print (s.check()) The following example shows how to traverse the constraints asserted into a solver, and how to collect performance statistics for the `check` method. -```python +```z3-python x = Real('x') y = Real('y') s = Solver() @@ -288,7 +288,7 @@ We say Z3 **satisfied** the set of constraints. We say the solution is a **model constraints. A model is an **interpretation** that makes each asserted constraint **true**. The following example shows the basic methods for inspecting models. -```python +```z3-python x, y, z = Reals('x y z') s = Solver() s.add(x > 1, y > 1, x + y > 3, z - x < 10) @@ -306,7 +306,7 @@ for d in m.decls(): In the example above, the function `Reals('x y z')` creates the variables. `x`, `y` and `z`. It is shorthand for: -```python +```z3-python x = Real('x') y = Real('y') z = Real('z') @@ -326,7 +326,7 @@ Z3 supports real and integer variables. They can be mixed in a single problem. Like most programming languages, Z3Py will automatically add coercions converting integer expressions to real ones when needed. The following example demonstrates different ways to declare integer and real variables. -```python +```z3-python x = Real('x') y = Int('y') a, b, c = Reals('a b c') @@ -339,7 +339,7 @@ The function `ToReal` casts an integer expression into a real expression. Z3Py supports all basic arithmetic operations. -```python +```z3-python a, b, c = Ints('a b c') d, e = Reals('d e') solve(a > b + 2, @@ -350,7 +350,7 @@ solve(a > b + 2, The command `simplify` applies simple transformations on Z3 expressions. -```python +```z3-python x, y = Reals('x y') # Put expression in sum-of-monomials form t = simplify((x + y)**3, som=True) @@ -366,7 +366,7 @@ These options can be used in Z3Py. Z3Py also supports Python-like names, where `:` is suppressed and `-` is replaced with `_`. The following example demonstrates how to use both styles. -```python +```z3-python x, y = Reals('x y') # Using Z3 native option names print (simplify(x == y + 2, ':arith-lhs', True)) @@ -382,7 +382,7 @@ Z3Py only supports [algebraic irrational numbers](http://en.wikipedia.org/wiki/A Z3Py will always display irrational numbers in decimal notation since it is more convenient to read. The internal representation can be extracted using the method `sexpr()`. It displays Z3 internal representation for mathematical formulas and expressions in [s-expression](http://en.wikipedia.org/wiki/S-expression) (Lisp-like) notation. -```python +```z3-python x, y = Reals('x y') solve(x + 10000000000000000000000 == y, y > 20000000000000000) @@ -409,7 +409,7 @@ The function `BitVec('x', 16)` creates a bit-vector variable in Z3 named `x` wit For convenience, integer constants can be used to create bit-vector expressions in Z3Py. The function `BitVecVal(10, 32)` creates a bit-vector of size `32` containing the value `10`. -```python +```z3-python x = BitVec('x', 16) y = BitVec('y', 16) print (x + 2) @@ -440,7 +440,7 @@ In Z3Py, the operators The corresponding unsigned operators are `ULT`, `ULE`, `UGT`, `UGE`, `UDiv`, `URem` and `LShR`. -```python +```z3-python # Create to bit-vectors of size 32 x, y = BitVecs('x y', 32) @@ -462,7 +462,7 @@ solve(ULT(x, 0)) The operator `>>` is the arithmetic shift right, and `<<` is the shift left. The logical shift right is the operator `LShR`. -```python +```z3-python # Create to bit-vectors of size 32 x, y = BitVecs('x y', 32) @@ -497,7 +497,7 @@ and results in an integer value. The example illustrates how one can force an interpretation where `f` applied twice to `x` results in `x` again, but `f` applied once to `x` is different from `x`. -```python +```z3-python x = Int('x') y = Int('y') f = Function('f', IntSort(), IntSort()) @@ -510,7 +510,7 @@ is `1` for all `a` different from `0` and `1`. In Z3, we can also evaluate expressions in the model for a system of constraints. The following example shows how to use the `evaluate` method. -```python +```z3-python x = Int('x') y = Int('y') f = Function('f', IntSort(), IntSort()) @@ -543,7 +543,7 @@ The following example redefines the Z3Py function `prove` that receives a formul This function creates a solver, adds/asserts the negation of the formula, and check if the negation is unsatisfiable. The implementation of this function is a simpler version of the Z3Py command `prove`. -```python +```z3-python p, q = Bools('p q') demorgan = And(p, q) == Not(Or(Not(p), Not(q))) print (demorgan) @@ -566,7 +566,7 @@ Python supports [list comprehensions](http://docs.python.org/tutorial/datastruct List comprehensions provide a concise way to create lists. They can be used to create Z3 expressions and problems in Z3Py. The following example demonstrates how to use Python list comprehensions in Z3Py. -```python +```z3-python # Create list [1, ..., 5] print ([ x + 1 for x in range(5) ]) @@ -598,7 +598,7 @@ The command `pp` is similar to `print`, but it uses Z3Py formatter for lists and Z3Py also provides functions for creating vectors of Boolean, Integer and Real variables. These functions are implemented using list comprehensions. -```python +```z3-python X = IntVector('x', 5) Y = RealVector('y', 5) P = BoolVector('p', 5) @@ -629,7 +629,7 @@ The light turns yellow, and Ima applies the brakes and skids to a stop. If Ima's acceleration is `-8.00` m/s2, then determine the displacement of the car during the skidding process. -```python +```z3-python d, a, t, v_i, v_f = Reals('d a t v__i v__f') equations = [ @@ -658,7 +658,7 @@ solve(equations + problem) Ben Rushin is waiting at a stoplight. When it finally turns green, Ben accelerated from rest at a rate of a `6.00` m/s2 for a time of `4.10` seconds. Determine the displacement of Ben's car during this time period. -```python +```z3-python d, a, t, v_i, v_f = Reals('d a t v__i v__f') equations = [ @@ -693,7 +693,7 @@ This hack is frequently used in C programs (Z3 included) to test whether a machi We can use Z3 to prove it really works. The claim is that `x != 0 && !(x & (x - 1))` is true if and only if `x` is a power of two. -```python +```z3-python x = BitVec('x', 32) powers = [ 2**i for i in range(32) ] fast = And(x != 0, x & (x - 1) == 0) @@ -710,7 +710,7 @@ prove(fast == slow) The following simple hack can be used to test whether two machine integers have opposite signs. -```python +```z3-python x = BitVec('x', 32) y = BitVec('y', 32) @@ -733,7 +733,7 @@ Dogs cost 15 dollars, cats cost 1 dollar, and mice cost 25 cents each. You have to buy at least one of each. How many of each should you buy? -```python +```z3-python # Create 3 integer variables dog, cat, mouse = Ints('dog cat mouse') solve(dog >= 1, # at least one dog @@ -761,7 +761,7 @@ by modifying the matrix `instance`. This example makes heavy use of [list comprehensions](http://docs.python.org/tutorial/datastructures.html#list-comprehensions) available in the Python programming language. -```python +```z3-python # 9x9 matrix of integer variables X = [ [ Int("x_%s_%s" % (i+1, j+1)) for j in range(9) ] for i in range(9) ] @@ -817,7 +817,7 @@ The eight queens puzzle is the problem of placing eight chess queens on an 8x8 c Thus, a solution requires that no two queens share the same row, column, or diagonal. -```python +```z3-python # We know each queen must be in a different row. # So, we represent each queen by a single integer: the column position Q = [ Int('Q_%i' % (i + 1)) for i in range(8) ] @@ -857,7 +857,7 @@ package. This variable is true if the package must be in the system. If package packages `b`, `c` and `z`, we write: -```python +```z3-python DependsOn(a, [b, c, z]) ``` @@ -865,7 +865,7 @@ DependsOn(a, [b, c, z]) depends clause semantics. -```python +```z3-python def DependsOn(pack, deps): return And([ Implies(pack, dep) for dep in deps ]) ``` @@ -896,7 +896,7 @@ def Conflict(p1, p2): With these two functions, we can easily encode the example in the [Opium article](http://cseweb.ucsd.edu/~rjhala/papers/opium.pdf) (Section 2) in Z3Py as: -```python +```z3-python def DependsOn(pack, deps): return And([ Implies(pack, dep) for dep in deps ]) @@ -930,7 +930,7 @@ write a function `install_check` that returns a list of packages that must be in in the system. The function `Conflict` is also modified. It can now receive multiple arguments. -```python +```z3-python def DependsOn(pack, deps): if is_expr(deps): return Implies(pack, deps) From 1fe2a2bec758ccfe3c16c2be20666a535defa9f4 Mon Sep 17 00:00:00 2001 From: "Ruanqianqian (Lisa) Huang" Date: Wed, 27 Jul 2022 15:39:45 -0700 Subject: [PATCH 02/18] change python to z3-python --- .../02 - advanced.md | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/02 - advanced.md b/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/02 - advanced.md index 640f1bebf..b9936504e 100644 --- a/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/02 - advanced.md +++ b/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/02 - advanced.md @@ -10,7 +10,7 @@ In Z3, expressions, sorts and declarations are called _ASTs_. ASTs are directed acyclic graphs. Every expression has a sort (aka type). The method sort() retrieves the sort of an expression. -```python +```z3-python x = Int('x') y = Real('y') print ((x + 1).sort()) @@ -22,7 +22,7 @@ The function eq(n1, n2) returns True if n1 and n2 are the same AST. This is a structural test. -```python +```z3-python x, y = Ints('x y') print (eq(x + y, x + y)) print (eq(x + y, y + x)) @@ -41,7 +41,7 @@ If eq(n1, n2) returns True, then n1.hash() is equal to n2.hash(). -```python +```z3-python x = Int('x') print (x + 1).hash() print (1 + x).hash() @@ -62,7 +62,7 @@ The function is_expr(n) returns True if n is an expression. Similarly is_app(n) (is_func_decl(n)) returns True if n is an application (declaration). -```python +```z3-python x = Int('x') print ("is expression: ", is_expr(x)) n = x + 1 @@ -76,7 +76,7 @@ for i in range(n.num_args()): Declarations have names, they are retrieved using the method name(). A (function) declaration has an arity, a domain and range sorts. -```python +```z3-python x = Int('x') x_d = x.decl() print ("is_expr(x_d): ", is_expr(x_d)) @@ -104,7 +104,7 @@ The built-in declarations are identified using their **kind**. The kind is retrieved using the method kind(). The complete list of built-in declarations can be found in the file z3consts.py (z3_api.h) in the Z3 distribution. -```python +```z3-python x, y = Ints('x y') print ((x + y).decl().kind() == Z3_OP_ADD) print ((x + y).decl().kind() == Z3_OP_SUB) @@ -113,7 +113,7 @@ print ((x + y).decl().kind() == Z3_OP_SUB) The following example demonstrates how to substitute sub-expressions in Z3 expressions. -```python +```z3-python x, y = Ints('x y') f = Function('f', IntSort(), IntSort(), IntSort()) g = Function('g', IntSort(), IntSort()) @@ -127,7 +127,7 @@ The function Const(name, sort) declares a constant (aka variable) of th For example, the functions Int(name) and Real(name) are shorthands for Const(name, IntSort()) and Const(name, RealSort()). -```python +```z3-python x = Const('x', IntSort()) print (eq(x, Int('x'))) @@ -145,7 +145,7 @@ and Store(a, i, v) returns a new array identical to a, but on position i it contains the value v. In Z3Py, we can also write Select(a, i) as a[i]. -```python +```z3-python # Use I as an alias for IntSort() I = IntSort() # A is an array from integer to integer @@ -178,7 +178,7 @@ Arrays in Z3 are used to model unbounded or very large arrays. Arrays should not be used to model small finite collections of values. It is usually much more efficient to create different variables using list comprehensions. -```python +```z3-python # We want an array with 3 elements. # 1. Bad solution X = Array('x', IntSort(), IntSort()) @@ -201,7 +201,7 @@ are satisfiable for an array that contains an index x that maps to and when x == y. We can solve these constraints. -```python +```z3-python A = Array('A', IntSort(), IntSort()) x, y = Ints('x y') solve(A[x] == x, Store(A, x, y) == A) @@ -211,7 +211,7 @@ The interpretation/solution for array variables is very similar to the one used The problem becomes unsatisfiable/infeasible if we add the constraint x != y. -```python +```z3-python A = Array('A', IntSort(), IntSort()) x, y = Ints('x y') solve(A[x] == x, Store(A, x, y) == A, x != y) @@ -226,7 +226,7 @@ The array that maps all indices to some fixed value can be specified in Z3Py usi K(s, v) returns a array that maps any value of s into v. The following example defines a constant array containing only ones. -```python +```z3-python AllOne = K(IntSort(), 1) a, i = Ints('a i') solve(a == AllOne[i]) @@ -262,7 +262,7 @@ After all constructors were declared, we use the method create() to create the actual datatype in Z3. Z3Py makes the new Z3 declarations and constants available as slots of the new object. -```python +```z3-python # Declare a List of integers List = Datatype('List') # Constructor cons: (Int, List) -> List @@ -291,7 +291,7 @@ print (simplify(l1 == nil)) The following example demonstrates how to define a Python function that given a sort creates a list of the given sort. -```python +```z3-python def DeclareList(sort): List = Datatype('List_of_%s' % sort.name()) List.declare('cons', ('car', sort), ('cdr', List)) @@ -323,7 +323,7 @@ As described above enumeration types are a special case of algebraic datatypes. The following example declares an enumeration type consisting of three values: red, green and blue. -```python +```z3-python Color = Datatype('Color') Color.declare('red') Color.declare('green') @@ -345,7 +345,7 @@ prove(Or(c == Color.green, Z3Py also provides the following shorthand for declaring enumeration sorts. -```python +```z3-python Color, (red, green, blue) = EnumSort('Color', ('red', 'green', 'blue')) print (green == blue) @@ -360,7 +360,7 @@ Mutually recursive datatypes can also be declared. The only difference is that w the function CreateDatatypes instead of the method create() to create the mutually recursive datatypes. -```python +```z3-python TreeList = Datatype('TreeList') Tree = Datatype('Tree') Tree.declare('leaf', ('val', IntSort())) @@ -400,7 +400,7 @@ argument of sort A and results in a value of sort A. The example illustrates how one can force an interpretation where f applied twice to x results in x again, but f applied once to x is different from x. -```python +```z3-python A = DeclareSort('A') x, y = Consts('x y', A) f = Function('f', A, A) @@ -431,7 +431,7 @@ that use quantifiers. It is no longer a decision procedure for such formulas in general (and for good reasons, as there can be no decision procedure for first-order logic). -```python +```z3-python f = Function('f', IntSort(), IntSort(), IntSort()) x, y = Ints('x y') f = ForAll([x, y], f(x, y) == 0) @@ -463,7 +463,7 @@ In the resultant formula the bounded variables are free. The function Var(index, sort) creates a bounded/free variable with the given index and sort. -```python +```z3-python f = Function('f', IntSort(), IntSort(), IntSort()) x, y = Ints('x y') f = ForAll([x, y], f(x, y) == 0) @@ -481,7 +481,7 @@ We would need a predicate for sub-typing. Sub-typing should be a partial order, and respect single inheritance. For some built-in type constructors, such as for array_of, sub-typing should be monotone. -```python +```z3-python Type = DeclareSort('Type') subtype = Function('subtype', Type, Type, BoolSort()) array_of = Function('array_of', Type, Type) @@ -531,7 +531,7 @@ We also annotate the quantified formula with the pattern f(g(x)). Since there is no ground instance of this pattern, the quantifier is not instantiated, and Z3 fails to show that the formula is unsatisfiable. -```python +```z3-python f = Function('f', IntSort(), IntSort()) g = Function('g', IntSort(), IntSort()) a, b, c = Ints('a b c') @@ -555,7 +555,7 @@ to be unsatisfiable. More restrive patterns minimize the number of instantiations (and potentially improve performance), but they may also make Z3 "less complete". -```python +```z3-python f = Function('f', IntSort(), IntSort()) g = Function('g', IntSort(), IntSort()) a, b, c = Ints('a b c') @@ -603,7 +603,7 @@ that terms are considered up to congruence and pattern matching takes place modulo ground equalities. We call the matching problem **E-matching**. For example, if we have the following equalities: -```python +```z3-python f = Function('f', IntSort(), IntSort()) g = Function('g', IntSort(), IntSort()) a, b, c = Ints('a b c') @@ -641,7 +641,7 @@ multi-patterns. In the following example, the quantified formula states that f is injective. This quantified formula is annotated with the multi-pattern MultiPattern(f(x), f(y)). -```python +```z3-python A = DeclareSort('A') B = DeclareSort('B') f = Function('f', A, B) @@ -666,7 +666,7 @@ that only a linear number of instantiations is required. The trick is to realize that f is injective if and only if it has a partial inverse. -```python +```z3-python A = DeclareSort('A') B = DeclareSort('B') f = Function('f', A, B) @@ -698,7 +698,7 @@ prefix used to create skolem constants/functions. In Z3Py and Z3 multiple solvers can be simultaneously used. It is also very easy to copy assertions/formulas from one solver to another. -```python +```z3-python x, y = Ints('x y') s1 = Solver() s1.add(x > 10, y > 10) @@ -718,7 +718,7 @@ Assumptions are also available in the Z3 SMT 2.0 frontend, and in other Z3 front They are used to extract unsatisfiable cores. They may be also used to "retract" constraints. Note that, assumptions are not really _soft constraints_, but they can be used to implement them. -```python +```z3-python p1, p2, p3 = Bools('p1 p2 p3') x, y = Ints('x y') # We assert Implies(p, C) to track constraint C using p @@ -750,7 +750,7 @@ Z3 objects. The formatter supports many configuration options. The command set_option(html_mode=False) makes all formulas and expressions to be displayed in Z3Py notation. -```python +```z3-python x = Int('x') y = Int('y') print (x**2 + y**2 >= 1) From 00f2291f1e6677f9abbf2a0ab2c5f91d70cadbdb Mon Sep 17 00:00:00 2001 From: "Ruanqianqian (Lisa) Huang" Date: Wed, 27 Jul 2022 15:40:34 -0700 Subject: [PATCH 03/18] change python to z3-python --- .../03 - Strategies.md | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/03 - Strategies.md b/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/03 - Strategies.md index 30667b4e6..70da76ecc 100644 --- a/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/03 - Strategies.md +++ b/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/03 - Strategies.md @@ -50,7 +50,7 @@ eliminate variables using Gaussian elimination. Actually, solve-eqs is It can also eliminate arbitrary variables. Then, combinator Then applies simplify to the input goal and solve-eqs to each subgoal produced by simplify. In this example, only one subgoal is produced. -```python +```z3-python x, y = Reals('x y') g = Goal() g.add(x > 0, y > 0, x == y + 2) @@ -69,7 +69,7 @@ In Z3, we say a **clause** is any constraint of the form Or(f_1, ..., f_n)split-clause will select a clause Or(f_1, ..., f_n) in the input goal, and split it n subgoals. One for each subformula f_i. -```python +```z3-python x, y = Reals('x y') g = Goal() g.add(Or(x < 0, x > 0), x == y + 1, y < 0) @@ -85,7 +85,7 @@ for g in r: Z3 comes equipped with many built-in tactics. The command describe_tactics() provides a short description of all built-in tactics. -```python +```z3-python describe_tactics() ``` @@ -102,7 +102,7 @@ Z3Py comes equipped with the following tactic combinators (aka tacticals): The following example demonstrate how to use these combinators. -```python +```z3-python x, y, z = Reals('x y z') g = Goal() g.add(Or(x == 0, x == 1), @@ -133,7 +133,7 @@ Note that, this tactic generates one goal: the empty goal which is trivially sat The list of subgoals can be easily traversed using the Python for statement. -```python +```z3-python x, y, z = Reals('x y z') g = Goal() g.add(Or(x == 0, x == 1), @@ -153,7 +153,7 @@ If the tactic produces the empty goal, then the associated solver returns sa If the tactic produces a single goal containing False, then the solver returns unsat. Otherwise, it returns unknown. -```python +```z3-python bv_solver = Then('simplify', 'solve-eqs', 'bit-blast', @@ -174,7 +174,7 @@ In the following example, we use the solver API directly instead of the command We use the combinator With to configure our little solver. We also include the tactic aig which tries to compress Boolean formulas using And-Inverted Graphs. -```python +```z3-python bv_solver = Then(With('simplify', mul2concat=True), 'solve-eqs', 'bit-blast', @@ -192,7 +192,7 @@ print x & y, "==", m.evaluate(x & y) The tactic smt wraps the main solver in Z3 as a tactic. -```python +```z3-python x, y = Ints('x y') s = Tactic('smt').solver() s.add(x > y + 1) @@ -203,7 +203,7 @@ print s.model() Now, we show how to implement a solver for integer arithmetic using SAT. The solver is complete only for problems where every variable has a lower and upper bound. -```python +```z3-python s = Then(With('simplify', arith_lhs=True, som=True), 'normalize-bounds', 'lia2pb', 'pb2bv', 'bit-blast', 'sat').solver() @@ -223,7 +223,7 @@ Tactics can be combined with solvers. For example, we can apply a tactic to a go then select one of the subgoals and solve it using a solver. The next example demonstrates how to do that, and how to use model converters to convert a model for a subgoal into a model for the original goal. -```python +```z3-python t = Then('simplify', 'normalize-bounds', 'solve-eqs') @@ -254,14 +254,14 @@ The tactic FailIf(cond) fails if the given goal does not satisfy the co Many numeric and Boolean measures are available in Z3Py. The command describe_probes() provides the list of all built-in probes. -```python +```z3-python describe_probes() ``` In the following example, we build a simple tactic using FailIf. It also shows that a probe can be applied directly to a goal. -```python +```z3-python x, y, z = Reals('x y z') g = Goal() g.add(x + y + z > 0) @@ -296,7 +296,7 @@ If(p, t, 'skip') The tactic skip just returns the input goal. The following example demonstrates how to use the If combinator. -```python +```z3-python x, y, z = Reals('x y z') g = Goal() g.add(x**2 - y**2 >= 0) From 7aed66085777ae16c29799362282275c30289838 Mon Sep 17 00:00:00 2001 From: "Ruanqianqian (Lisa) Huang" Date: Wed, 27 Jul 2022 15:40:59 -0700 Subject: [PATCH 04/18] change python to z3-python --- .../01 - Using Z3 from Python/04 - Fixedpoints.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/04 - Fixedpoints.md b/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/04 - Fixedpoints.md index 16b5c9a49..b5f9e10ea 100644 --- a/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/04 - Fixedpoints.md +++ b/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/04 - Fixedpoints.md @@ -41,7 +41,7 @@ as hash tables as the default way to represent finite relations. The first example illustrates how to declare relations, rules and how to pose queries. -```python +```z3-python fp = Fixedpoint() a, b, c = Bools('a b c') @@ -114,7 +114,7 @@ provides information of how a fact was derived. The explanation is an expression whose function symbols are Horn rules and facts used in the derivation. -```python +```z3-python fp = Fixedpoint() @@ -135,7 +135,7 @@ print fp.get_answer() Relations can take arguments. We illustrate relations with arguments using edges and paths in a graph. -```python +```z3-python fp = Fixedpoint() fp.set(engine='datalog') @@ -194,7 +194,7 @@ for each procedure and adding an additional output variable to the predicate. Nested calls to procedures within a body can be encoded as a conjunction of relations. -```python +```z3-python mc = Function('mc', IntSort(), IntSort(), BoolSort()) n, m, p = Ints('n m p') @@ -230,7 +230,7 @@ guarded transitions as recursive Horn clauses. But it is fairly easy to write a from guarded transition systems to recursive Horn clauses. We illustrate a translator and Lamport's two process Bakery algorithm in the next example. -```python +```z3-python set_option(relevancy=0,verbose=1) def flatten(l): @@ -364,7 +364,7 @@ evaluator, you should partial evaluate it to help verification). We use algebraic data-types to encode the current closure that is being evaluated. -```python +```z3-python # let max max2 x y z = max2 (max2 x y) z # let f x y = if x > y then x else y From bc2ced9c8d5d21b0b6b77c01459aef6dd60bc920 Mon Sep 17 00:00:00 2001 From: "Ruanqianqian (Lisa) Huang" Date: Wed, 27 Jul 2022 15:41:38 -0700 Subject: [PATCH 05/18] change python to z3-python --- .../05 - Cores and Satisfying Subsets.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/05 - Cores and Satisfying Subsets.md b/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/05 - Cores and Satisfying Subsets.md index 8812d400a..36f4af663 100644 --- a/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/05 - Cores and Satisfying Subsets.md +++ b/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/05 - Cores and Satisfying Subsets.md @@ -68,7 +68,7 @@ then it finds a minimal unsatisfiable subset corresponding to these atoms. If asserting the atoms is consistent with the SubsetSolver, then it extends this set of atoms maximally to a satisfying set. -```python +```z3-python def main(): From bf7864cd8b8f891932f56556407513b21ff156be Mon Sep 17 00:00:00 2001 From: "Ruanqianqian (Lisa) Huang" Date: Wed, 27 Jul 2022 15:41:56 -0700 Subject: [PATCH 06/18] change python to z3-python --- .../06 - User Propagator.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/06 - User Propagator.md b/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/06 - User Propagator.md index e96a8bd83..fbcf4ba70 100644 --- a/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/06 - User Propagator.md +++ b/website/docs-programming/01 - Programming Z3/01 - Using Z3 from Python/06 - User Propagator.md @@ -93,7 +93,7 @@ This declaration instructs z3 to invoke callbacks whenever a new term headed by function is introduced to the solver. It could be a term that is part of the input, or it could be a term that is created dynamically using quantifier instantiation. -```python +```z3-python Sort = DatatypeSort("Sort") leSort = PropagateFunction("<=Sort", Sort, Sort, BoolSort()) @@ -104,7 +104,7 @@ fmls = parse_smt2_string(example, decls={"<=Sort":leSort, "<=SortSyntax":leSortS ## Axiomatizing RTCs -```python +```z3-python [SortInt, SortExp, SortKItem, SortKLabel, SortK] = [Sort.constructor(i) for i in range(Sort.num_constructors())] @@ -144,7 +144,7 @@ def rtc(constructors, bin): We use a simple union find with support for tracking values. -```python +```z3-python class Node: def __init__(self, a): self.term = a @@ -284,7 +284,7 @@ Nested instances are created using a context (and not a solver). -```python +```z3-python class TC(UserPropagateBase): def __init__(self, s=None, ctx=None): UserPropagateBase.__init__(self, s, ctx) @@ -327,7 +327,7 @@ that is checked on final. It is assumed that during final are known between arguments to <=Sort and <=SortSyntax. -```python +```z3-python def _fixed(self, x, v): print("fixed: ", x, " := ", v) if x.decl().eq(leSort): @@ -352,7 +352,7 @@ It allows register `t` and its two arguments with z3. In return for registering invoke `fixed` and `eq` callbacks when z3 infers a fixed value assignment or a new equality between tracked terms. -```python +```z3-python def _created(self, t): print("Created", t) self.add(t) @@ -379,7 +379,7 @@ The number of equality callbacks for _N_ terms that are equal is _N-1_, correspo to a spanning tree. So not all equalities are presented in callbacks and the client can track equivalence classes by using a union-find data-structure as we are doing. -```python +```z3-python def _eq(self, x, y): print(x, " = ", y) @@ -389,7 +389,7 @@ can track equivalence classes by using a union-find data-structure as we are doi ### Final check -```python +```z3-python def _final(self): print("Final") self.check_rtc(self._fixed_le, self._fixed_le_table) @@ -440,7 +440,7 @@ can track equivalence classes by using a union-find data-structure as we are doi ## Using the User Propagator -```python +```z3-python s = Solver() b = TC(s) From f48ddce698f7572a17ba61a0a9008f7bdb6e2889 Mon Sep 17 00:00:00 2001 From: "Ruanqianqian (Lisa) Huang" Date: Wed, 27 Jul 2022 16:32:32 -0700 Subject: [PATCH 07/18] port examples from the unit test; expect build fails --- .../03 - more JS examples.md | 267 ++++++++++++++++++ .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + 63 files changed, 329 insertions(+) create mode 100644 website/docs-programming/02 - Z3 JavaScript/03 - more JS examples.md create mode 100644 website/solutions/z3-js/4.10.1/120348cdd1a33f7a5ea77ced9a49513bd9e42f98/input.json create mode 100644 website/solutions/z3-js/4.10.1/120348cdd1a33f7a5ea77ced9a49513bd9e42f98/output.json create mode 100644 website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json create mode 100644 website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json create mode 100644 website/solutions/z3-js/4.10.1/179dd97050b2837e643e57ae48b71fafb961ded9/input.json create mode 100644 website/solutions/z3-js/4.10.1/179dd97050b2837e643e57ae48b71fafb961ded9/output.json create mode 100644 website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json create mode 100644 website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json create mode 100644 website/solutions/z3-js/4.10.1/22a00a9de953b65e266f7350f17c24335e578f1d/input.json create mode 100644 website/solutions/z3-js/4.10.1/22a00a9de953b65e266f7350f17c24335e578f1d/output.json create mode 100644 website/solutions/z3-js/4.10.1/269fa052599ca1d51942cdfa717c1ffd572545a0/input.json create mode 100644 website/solutions/z3-js/4.10.1/269fa052599ca1d51942cdfa717c1ffd572545a0/output.json create mode 100644 website/solutions/z3-js/4.10.1/39954bcec86de152bbaba4b0c40e7e1449f7edf6/input.json create mode 100644 website/solutions/z3-js/4.10.1/39954bcec86de152bbaba4b0c40e7e1449f7edf6/output.json create mode 100644 website/solutions/z3-js/4.10.1/441eb730296cbbd94ba5e98a26afabab0ec5f8ef/input.json create mode 100644 website/solutions/z3-js/4.10.1/441eb730296cbbd94ba5e98a26afabab0ec5f8ef/output.json create mode 100644 website/solutions/z3-js/4.10.1/46f5403325bb369f1d3bcac2259b52351ed5c904/input.json create mode 100644 website/solutions/z3-js/4.10.1/46f5403325bb369f1d3bcac2259b52351ed5c904/output.json create mode 100644 website/solutions/z3-js/4.10.1/491bdd3231bd6dbc51757fc174481725a845729b/input.json create mode 100644 website/solutions/z3-js/4.10.1/491bdd3231bd6dbc51757fc174481725a845729b/output.json create mode 100644 website/solutions/z3-js/4.10.1/5678f357a9cf1468590dc55d53ebea50d2c9dee9/input.json create mode 100644 website/solutions/z3-js/4.10.1/5678f357a9cf1468590dc55d53ebea50d2c9dee9/output.json create mode 100644 website/solutions/z3-js/4.10.1/5897541f97424f6c569b8e8535c7b14b92ddd4aa/input.json create mode 100644 website/solutions/z3-js/4.10.1/5897541f97424f6c569b8e8535c7b14b92ddd4aa/output.json create mode 100644 website/solutions/z3-js/4.10.1/5b83b77d17625c0b87bf1d40c2f1c0ca124c52fa/input.json create mode 100644 website/solutions/z3-js/4.10.1/5b83b77d17625c0b87bf1d40c2f1c0ca124c52fa/output.json create mode 100644 website/solutions/z3-js/4.10.1/5ecf8c91575f6ccd1d734229e481a083157c5691/input.json create mode 100644 website/solutions/z3-js/4.10.1/5ecf8c91575f6ccd1d734229e481a083157c5691/output.json create mode 100644 website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json create mode 100644 website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/output.json create mode 100644 website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json create mode 100644 website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json create mode 100644 website/solutions/z3-js/4.10.1/6e9d92ab87857e9183644de010f7ef6bdef562b8/input.json create mode 100644 website/solutions/z3-js/4.10.1/6e9d92ab87857e9183644de010f7ef6bdef562b8/output.json create mode 100644 website/solutions/z3-js/4.10.1/788b265b0e86a5cdd0ddcb82a35577b92065289d/input.json create mode 100644 website/solutions/z3-js/4.10.1/788b265b0e86a5cdd0ddcb82a35577b92065289d/output.json create mode 100644 website/solutions/z3-js/4.10.1/999bf5fd0b7cce57b4b5ae6371fd8e4d2e59a44b/input.json create mode 100644 website/solutions/z3-js/4.10.1/999bf5fd0b7cce57b4b5ae6371fd8e4d2e59a44b/output.json create mode 100644 website/solutions/z3-js/4.10.1/9ae9ad60161b8106f420343ef151717ec00ed71d/input.json create mode 100644 website/solutions/z3-js/4.10.1/9ae9ad60161b8106f420343ef151717ec00ed71d/output.json create mode 100644 website/solutions/z3-js/4.10.1/a20a9ec1d64add1d969fa507522cebf35fd152fb/input.json create mode 100644 website/solutions/z3-js/4.10.1/a20a9ec1d64add1d969fa507522cebf35fd152fb/output.json create mode 100644 website/solutions/z3-js/4.10.1/b212b4a0cd87c65163c963e0c2c600db02567663/input.json create mode 100644 website/solutions/z3-js/4.10.1/b212b4a0cd87c65163c963e0c2c600db02567663/output.json create mode 100644 website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json create mode 100644 website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json create mode 100644 website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json create mode 100644 website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/output.json create mode 100644 website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/input.json create mode 100644 website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/output.json create mode 100644 website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json create mode 100644 website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json create mode 100644 website/solutions/z3-js/4.10.1/d4f060a97872ec1a74dca9e62eb920e920270d58/input.json create mode 100644 website/solutions/z3-js/4.10.1/d4f060a97872ec1a74dca9e62eb920e920270d58/output.json create mode 100644 website/solutions/z3-js/4.10.1/e3e11a5ab2dbe41c0b86925b87de881d5160974d/input.json create mode 100644 website/solutions/z3-js/4.10.1/e3e11a5ab2dbe41c0b86925b87de881d5160974d/output.json create mode 100644 website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json create mode 100644 website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json create mode 100644 website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json create mode 100644 website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json create mode 100644 website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json create mode 100644 website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json diff --git a/website/docs-programming/02 - Z3 JavaScript/03 - more JS examples.md b/website/docs-programming/02 - Z3 JavaScript/03 - more JS examples.md new file mode 100644 index 000000000..177de7920 --- /dev/null +++ b/website/docs-programming/02 - Z3 JavaScript/03 - more JS examples.md @@ -0,0 +1,267 @@ +# Examples from the JS bindings unit test + +:::warning +Type checking for Z3-typed function parameters messes up with how we process JS/TS inputs, so for now we don't include any top-level functions that include such parameters. +::: + +```z3-js +// proves x = y implies g(x) = g(y) + +const solver = new Z3.Solver(); +const sort = Z3.Int.sort(); +const x = Z3.Int.const('x'); +const y = Z3.Int.const('y'); +const g = Z3.Function.declare('g', sort, sort); + +const conjecture = Z3.Implies(x.eq(y), g.call(x).eq(g.call(y))); +solver.add(Z3.Not(conjecture)); +await solver.check(); // unsat +``` + +```z3-js +// disproves that x = y implies g(g(x)) = g(y) + +const solver = new Z3.Solver(); +const sort = Z3.Int.sort(); +const x = Z3.Int.const('x'); +const y = Z3.Int.const('y'); +const g = Z3.Function.declare('g', sort, sort); +const conjecture = Z3.Implies(x.eq(y), g.call(g.call(x)).eq(g.call(y))); +solver.add(Z3.Not(conjecture)); +await solver.check(); //sat +``` + +```z3-js +// proves De Morgan's Law +const solver = new Z3.Solver(); +const [x, y] = [Z3.Bool.const('x'), Z3.Bool.const('y')]; +const conjecture = Z3.Eq(Z3.Not(Z3.And(x, y)), Z3.Or(Z3.Not(x), Z3.Not(y))); +solver.add(Z3.Not(conjecture)); +await solver.check(); // unsat +``` + +```z3-js +// finds a model +const solver = new Z3.Solver(); +const x = Z3.Int.const('x'); +const y = Z3.Int.const('y'); + +solver.add(x.ge(1)); // x >= 1 +solver.add(y.lt(x.add(3))); // y < x + 3 + +await solver.check(); // sat + +const model = solver.model(); +await model.sexpr(); +``` + +```z3-js +// solves sudoku +function toSudoku(data: string): (number | null)[][] { + const cells: (number | null)[][] = Array.from({ length: 9 }, () => Array.from({ length: 9 }, () => null)); + + const lines = data.trim().split('\n'); + for (let row = 0; row < 9; row++) { + const line = lines[row].trim(); + for (let col = 0; col < 9; col++) { + const char = line[col]; + if (char !== '.') { + cells[row][col] = Number.parseInt(char); + } + } + } + return cells; +} + +const INSTANCE = toSudoku(` +....94.3. +...51...7 +.89....4. +......2.8 +.6.2.1.5. +1.2...... +.7....52. +9...65... +.4.97.... +`); + +const EXPECTED = toSudoku(` +715894632 +234516897 +689723145 +493657218 +867231954 +152489763 +376148529 +928365471 +541972386 +`); + + +const cells = []; +// 9x9 matrix of integer variables +for (let i = 0; i < 9; i++) { + const row = []; + for (let j = 0; j < 9; j++) { + row.push(Z3.Int.const(`x_${i}_${j}`)); + } + cells.push(row); +} + +const solver = new Z3.Solver(); + +// each cell contains a value 1<=x<=9 +for (let i = 0; i < 9; i++) { + for (let j = 0; j < 9; j++) { + solver.add(cells[i][j].ge(1), cells[i][j].le(9)); + } +} + +// each row contains a digit only once +for (let i = 0; i < 9; i++) { + solver.add(Z3.Distinct(...cells[i])); +} + +// each column contains a digit only once +for (let j = 0; j < 9; j++) { + const column = []; + for (let i = 0; i < 9; i++) { + column.push(cells[i][j]); + } + solver.add(Z3.Distinct(...column)); +} + +// each 3x3 contains a digit at most once +for (let iSquare = 0; iSquare < 3; iSquare++) { + for (let jSquare = 0; jSquare < 3; jSquare++) { + const square = []; + + for (let i = iSquare * 3; i < iSquare * 3 + 3; i++) { + for (let j = jSquare * 3; j < jSquare * 3 + 3; j++) { + square.push(cells[i][j]); + } + } + + solver.add(Z3.Distinct(...square)); + } +} + +for (let i = 0; i < 9; i++) { + for (let j = 0; j < 9; j++) { + const digit = INSTANCE[i][j]; + if (digit !== null) { + solver.add(cells[i][j].eq(digit)); + } + } +} + +await solver.check(); // sat +``` + +```z3-js +// numerals 1 +const n1 = Z3.Real.val('1/2'); +const n2 = Z3.Real.val('0.5'); +const n3 = Z3.Real.val(0.5); + +const conjecture = Z3.And(n1.eq(n2), n1.eq(n3)); + +const solver = new Z3.Solver(); +solver.add(Z3.Not(conjecture)); +await solver.check(); +``` + +```z3-js +// numerals 2 +const n4 = Z3.Real.val('-1/3'); +const n5 = Z3.Real.val('-0.3333333333333333333333333333333333'); + +const conjecture = n4.neq(n5); + +const solver = new Z3.Solver(); +solver.add(Z3.Not(conjecture)); +await solver.check(); +``` + +TODO: setParam doesn't work with how with process JS inputs +```z3-js +// non-linear arithmetic + +Z3.setParam('pp.decimal', true); +Z3.setParam('pp.decimal_precision', 20); + +const x = Z3.Real.const('x'); +const y = Z3.Real.const('y'); +const z = Z3.Real.const('z'); + +const solver = new Z3.Solver(); +solver.add(x.mul(x).add(y.mul(y)).eq(1)); // x^2 + y^2 == 1 +solver.add(x.mul(x).mul(x).add(z.mul(z).mul(z)).lt('1/2')); // x^3 + z^3 < 1/2 + +await solver.check(); // sat +``` + +TODO: seems that we can only get the final output, not intermediate ones +```z3-js +// bitvectors: simple proofs +const x = Z3.BitVec.const('x', 32); + +const sConj = x.sub(10).sle(0).eq(x.sle(10)); +const sSolver = new Z3.Solver(); +sSolver.add(sConj); +await sSolver.check(); // sat + +const sModel = sSolver.model(); +sModel.get(x) // signed + +const uConj = x.sub(10).ule(0).eq(x.ule(10)); +const uSolver = new Z3.Solver(); +uSolver.add(uConj); +await uSolver.check(); // sat + +const uModel = uSolver.model(); +uModel.get(x) // unsigned +``` + + +```z3-js +// solves an equation +const x = Z3.BitVec.const('x', 32); +const y = Z3.BitVec.const('y', 32); + +const solver = new Z3.Solver(); +const conjecture = x.xor(y).sub(103).eq(x.mul(y)); +solver.add(conjecture); +await solver.check(); // sat + +const model = solver.model(); +const xSol = model.get(x); +const ySol = model.get(y); + +Z3.isBitVecVal(xSol) && Z3.isBitVecVal(ySol); // true + +// TODO: fix the remaining lines +const xv = xSol.asSignedValue(); +const yv = ySol.asSignedValue(); + +// this solutions wraps around so we need to check using modulo +(xv ^ yv) - 103n === (xv * yv) % 2n ** 32n; // true +``` + +```z3-js +// AstVector +const solver = new Z3.Solver(); + +// @ts-ignore: skipping typechecking for the following line for now, is there a better solution? +const vector = new Z3.AstVector(); +for (let i = 0; i < 5; i++) { + vector.push(Z3.Int.const(`int__${i}`)); +} + +const length = vector.length(); +for (let i = 0; i < length; i++) { + solver.add(vector.get(i).gt(1)); +} + +await solver.check(); // sat +``` \ No newline at end of file diff --git a/website/solutions/z3-js/4.10.1/120348cdd1a33f7a5ea77ced9a49513bd9e42f98/input.json b/website/solutions/z3-js/4.10.1/120348cdd1a33f7a5ea77ced9a49513bd9e42f98/input.json new file mode 100644 index 000000000..2dbc97897 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/120348cdd1a33f7a5ea77ced9a49513bd9e42f98/input.json @@ -0,0 +1 @@ +{"input":"// proves De Morgan's Law\nconst solver = new Z3.Solver();\nconst [x, y] = [Z3.Bool.const('x'), Z3.Bool.const('y')];\nconst conjecture = Z3.Eq(Z3.Not(Z3.And(x, y)), Z3.Or(Z3.Not(x), Z3.Not(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check();"} diff --git a/website/solutions/z3-js/4.10.1/120348cdd1a33f7a5ea77ced9a49513bd9e42f98/output.json b/website/solutions/z3-js/4.10.1/120348cdd1a33f7a5ea77ced9a49513bd9e42f98/output.json new file mode 100644 index 000000000..dabad07fe --- /dev/null +++ b/website/solutions/z3-js/4.10.1/120348cdd1a33f7a5ea77ced9a49513bd9e42f98/output.json @@ -0,0 +1 @@ +{"output":"unsat","error":"","status":"z3-ran","hash":"120348cdd1a33f7a5ea77ced9a49513bd9e42f98"} diff --git a/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json b/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json new file mode 100644 index 000000000..1c80b9958 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json @@ -0,0 +1 @@ +{"input":"// proves x = y implies g(x) = g(y)\n\nconst solver = new Z3.Solver();\nconst sort = Z3.Int.sort();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\nconst g = Z3.Function.declare('g', sort, sort);\n\nconst conjecture = Z3.Implies(x.eq(y), g.call(x).eq(g.call(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check(); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json b/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json new file mode 100644 index 000000000..7b8842b14 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json @@ -0,0 +1 @@ +{"output":"unsat","error":"","status":"z3-ran","hash":"16a515db3b88471d8f266b464b2344b2a30d00b7"} diff --git a/website/solutions/z3-js/4.10.1/179dd97050b2837e643e57ae48b71fafb961ded9/input.json b/website/solutions/z3-js/4.10.1/179dd97050b2837e643e57ae48b71fafb961ded9/input.json new file mode 100644 index 000000000..4109d72d7 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/179dd97050b2837e643e57ae48b71fafb961ded9/input.json @@ -0,0 +1 @@ +{"input":"// non-linear arithmetic\n// TODO: setParam doesn't work with how with process JS inputs\n\nZ3.setParam('pp.decimal', true);\nZ3.setParam('pp.decimal_precision', 20);\n\nconst x = Z3.Real.const('x');\nconst y = Z3.Real.const('y');\nconst z = Z3.Real.const('z');\n\nconst solver = new Z3.Solver();\nsolver.add(x.mul(x).add(y.mul(y)).eq(1)); // x^2 + y^2 == 1\nsolver.add(x.mul(x).mul(x).add(z.mul(z).mul(z)).lt('1/2')); // x^3 + z^3 < 1/2\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/179dd97050b2837e643e57ae48b71fafb961ded9/output.json b/website/solutions/z3-js/4.10.1/179dd97050b2837e643e57ae48b71fafb961ded9/output.json new file mode 100644 index 000000000..63a12816d --- /dev/null +++ b/website/solutions/z3-js/4.10.1/179dd97050b2837e643e57ae48b71fafb961ded9/output.json @@ -0,0 +1 @@ +{"output":"","error":"Error: main.ts (4,4): Property 'setParam' does not exist on type 'Context<\"main\">'.\nmain.ts (5,4): Property 'setParam' does not exist on type 'Context<\"main\">'.","status":"z3-failed","hash":"179dd97050b2837e643e57ae48b71fafb961ded9"} diff --git a/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json b/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json new file mode 100644 index 000000000..099177988 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json @@ -0,0 +1 @@ +{"input":"// numerals 1\nconst n1 = Z3.Real.val('1/2');\nconst n2 = Z3.Real.val('0.5');\nconst n3 = Z3.Real.val(0.5);\n\nconst conjecture = Z3.And(n1.eq(n2), n1.eq(n3));\n\nconst solver = new Z3.Solver();\nsolver.add(Z3.Not(conjecture));\nawait solver.check();"} diff --git a/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json b/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json new file mode 100644 index 000000000..0414391c4 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json @@ -0,0 +1 @@ +{"output":"unsat","error":"","status":"z3-ran","hash":"18db6515b197b55df72654ada88a28ab104776e0"} diff --git a/website/solutions/z3-js/4.10.1/22a00a9de953b65e266f7350f17c24335e578f1d/input.json b/website/solutions/z3-js/4.10.1/22a00a9de953b65e266f7350f17c24335e578f1d/input.json new file mode 100644 index 000000000..54de8ccf7 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/22a00a9de953b65e266f7350f17c24335e578f1d/input.json @@ -0,0 +1 @@ +{"input":"// solves an equation\nconst x = Z3.BitVec.const('x', 32);\nconst y = Z3.BitVec.const('y', 32);\n\nconst solver = new Z3.Solver();\nconst conjecture = x.xor(y).sub(103).eq(x.mul(y));\nsolver.add(conjecture);\nawait solver.check(); // sat\n\nconst model = solver.model();\nconst xSol = model.get(x);\nconst ySol = model.get(y);\n\nZ3.isBitVecVal(xSol) && Z3.isBitVecVal(ySol); // true\n\nconst xv = xSol.asSignedValue();\nconst yv = ySol.asSignedValue();\n\n// this solutions wraps around so we need to check using modulo\n(xv ^ yv) - 103n === (xv * yv) % 2n ** 32n; // true"} diff --git a/website/solutions/z3-js/4.10.1/22a00a9de953b65e266f7350f17c24335e578f1d/output.json b/website/solutions/z3-js/4.10.1/22a00a9de953b65e266f7350f17c24335e578f1d/output.json new file mode 100644 index 000000000..ab528a44b --- /dev/null +++ b/website/solutions/z3-js/4.10.1/22a00a9de953b65e266f7350f17c24335e578f1d/output.json @@ -0,0 +1 @@ +{"output":"","error":"Error: main.ts (16,17): Property 'asSignedValue' does not exist on type 'Expr<\"main\", AnySort<\"main\">, unknown>'.\nmain.ts (17,17): Property 'asSignedValue' does not exist on type 'Expr<\"main\", AnySort<\"main\">, unknown>'.\nmain.ts (20,1): Operator '-' cannot be applied to types 'number' and 'bigint'.\nmain.ts (20,22): Operator '%' cannot be applied to types 'number' and 'bigint'.","status":"z3-failed","hash":"22a00a9de953b65e266f7350f17c24335e578f1d"} diff --git a/website/solutions/z3-js/4.10.1/269fa052599ca1d51942cdfa717c1ffd572545a0/input.json b/website/solutions/z3-js/4.10.1/269fa052599ca1d51942cdfa717c1ffd572545a0/input.json new file mode 100644 index 000000000..07c9660da --- /dev/null +++ b/website/solutions/z3-js/4.10.1/269fa052599ca1d51942cdfa717c1ffd572545a0/input.json @@ -0,0 +1 @@ +{"input":"// bitvectors\nconst x = Z3.BitVec.const('x', 32);\n\nconst sConj = x.sub(10).sle(0).eq(x.sle(10));\nconst sSolver = new Z3.Solver();\nsSolver.add(sConj);\nawait sSolver.check(); // sat\n\nconst sModel = sSolver.model();\nsModel.get(x) // signed\n\nconst uConj = x.sub(10).ule(0).eq(x.ule(10));\nconst uSolver = new Z3.Solver();\nuSolver.add(uConj);\nawait uSolver.check(); // sat\n\nconst uModel = uSolver.model();\nuModel.get(x) // unsigned"} diff --git a/website/solutions/z3-js/4.10.1/269fa052599ca1d51942cdfa717c1ffd572545a0/output.json b/website/solutions/z3-js/4.10.1/269fa052599ca1d51942cdfa717c1ffd572545a0/output.json new file mode 100644 index 000000000..1e063a252 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/269fa052599ca1d51942cdfa717c1ffd572545a0/output.json @@ -0,0 +1 @@ +{"output":"#x0000000a","error":"","status":"z3-ran","hash":"269fa052599ca1d51942cdfa717c1ffd572545a0"} diff --git a/website/solutions/z3-js/4.10.1/39954bcec86de152bbaba4b0c40e7e1449f7edf6/input.json b/website/solutions/z3-js/4.10.1/39954bcec86de152bbaba4b0c40e7e1449f7edf6/input.json new file mode 100644 index 000000000..73b84ee3e --- /dev/null +++ b/website/solutions/z3-js/4.10.1/39954bcec86de152bbaba4b0c40e7e1449f7edf6/input.json @@ -0,0 +1 @@ +{"input":"// solves sudoku\nfunction toSudoku(data: string): (number | null)[][] {\n const cells: (number | null)[][] = Array.from({ length: 9 }, () => Array.from({ length: 9 }, () => null));\n\n const lines = data.trim().split('\\n');\n for (let row = 0; row < 9; row++) {\n const line = lines[row].trim();\n for (let col = 0; col < 9; col++) {\n const char = line[col];\n if (char !== '.') {\n cells[row][col] = Number.parseInt(char);\n }\n }\n }\n return cells;\n}\n\nconst INSTANCE = toSudoku(`\n....94.3.\n...51...7\n.89....4.\n......2.8\n.6.2.1.5.\n1.2......\n.7....52.\n9...65...\n.4.97....\n`);\n\nconst EXPECTED = toSudoku(`\n715894632\n234516897\n689723145\n493657218\n867231954\n152489763\n376148529\n928365471\n541972386\n`);\n\n\nconst cells: Z3.Arith[][] = [];\n// 9x9 matrix of integer variables\nfor (let i = 0; i < 9; i++) {\n const row = [];\n for (let j = 0; j < 9; j++) {\n row.push(Z3.Int.const(`x_${i}_${j}`));\n }\n cells.push(row);\n}\n\nconst solver = new Z3.Solver();\n\n// each cell contains a value 1<=x<=9\nfor (let i = 0; i < 9; i++) {\n for (let j = 0; j < 9; j++) {\n solver.add(cells[i][j].ge(1), cells[i][j].le(9));\n }\n}\n\n// each row contains a digit only once\nfor (let i = 0; i < 9; i++) {\n solver.add(Z3.Distinct(...cells[i]));\n}\n\n// each column contains a digit only once\nfor (let j = 0; j < 9; j++) {\n const column = [];\n for (let i = 0; i < 9; i++) {\n column.push(cells[i][j]);\n }\n solver.add(Z3.Distinct(...column));\n}\n\n// each 3x3 contains a digit at most once\nfor (let iSquare = 0; iSquare < 3; iSquare++) {\n for (let jSquare = 0; jSquare < 3; jSquare++) {\n const square = [];\n\n for (let i = iSquare * 3; i < iSquare * 3 + 3; i++) {\n for (let j = jSquare * 3; j < jSquare * 3 + 3; j++) {\n square.push(cells[i][j]);\n }\n }\n\n solver.add(Z3.Distinct(...square));\n }\n}\n\nfor (let i = 0; i < 9; i++) {\n for (let j = 0; j < 9; j++) {\n const digit = INSTANCE[i][j];\n if (digit !== null) {\n solver.add(cells[i][j].eq(digit));\n }\n }\n}\n\nawait solver.check(); // sat\n\nconst model = solver.model();\nmodel.sexpr();"} diff --git a/website/solutions/z3-js/4.10.1/39954bcec86de152bbaba4b0c40e7e1449f7edf6/output.json b/website/solutions/z3-js/4.10.1/39954bcec86de152bbaba4b0c40e7e1449f7edf6/output.json new file mode 100644 index 000000000..a429f1ba2 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/39954bcec86de152bbaba4b0c40e7e1449f7edf6/output.json @@ -0,0 +1 @@ +{"output":"","error":"Error: main.ts (43,14): Cannot find namespace 'Z3'.","status":"z3-failed","hash":"39954bcec86de152bbaba4b0c40e7e1449f7edf6"} diff --git a/website/solutions/z3-js/4.10.1/441eb730296cbbd94ba5e98a26afabab0ec5f8ef/input.json b/website/solutions/z3-js/4.10.1/441eb730296cbbd94ba5e98a26afabab0ec5f8ef/input.json new file mode 100644 index 000000000..5aa8903b2 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/441eb730296cbbd94ba5e98a26afabab0ec5f8ef/input.json @@ -0,0 +1 @@ +{"input":"// numerals 2\nconst n4 = Z3.Real.val('-1/3');\nconst n5 = Z3.Real.val('-0.3333333333333333333333333333333333');\n\nconst conjecture = n4.neq(n5);\n\nconst solver = new Z3.solver();\nsolver.add(Z3.Not(conjecture));\nawait solver.check();"} diff --git a/website/solutions/z3-js/4.10.1/441eb730296cbbd94ba5e98a26afabab0ec5f8ef/output.json b/website/solutions/z3-js/4.10.1/441eb730296cbbd94ba5e98a26afabab0ec5f8ef/output.json new file mode 100644 index 000000000..cb9cb6c62 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/441eb730296cbbd94ba5e98a26afabab0ec5f8ef/output.json @@ -0,0 +1 @@ +{"output":"","error":"Error: main.ts (7,23): Property 'solver' does not exist on type 'Context<\"main\">'. Did you mean 'Solver'?","status":"z3-failed","hash":"441eb730296cbbd94ba5e98a26afabab0ec5f8ef"} diff --git a/website/solutions/z3-js/4.10.1/46f5403325bb369f1d3bcac2259b52351ed5c904/input.json b/website/solutions/z3-js/4.10.1/46f5403325bb369f1d3bcac2259b52351ed5c904/input.json new file mode 100644 index 000000000..692f3fd02 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/46f5403325bb369f1d3bcac2259b52351ed5c904/input.json @@ -0,0 +1 @@ +{"input":"// proves De Morgan's Law\nasync function prove(conjecture: Bool): Promise {\n const solver = new conjecture.ctx.Solver();\n const { Not } = solver.ctx;\n solver.add(Not(conjecture));\n await solver.check();\n}\n\nconst [x, y] = [Z3.Bool.const('x'), Z3.Bool.const('y')];\nconst conjecture = Z3.Eq(Z3.Not(Z3.And(x, y)), Z3.Or(Z3.Not(x), Z3.Not(y)));\nawait prove(conjecture); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/46f5403325bb369f1d3bcac2259b52351ed5c904/output.json b/website/solutions/z3-js/4.10.1/46f5403325bb369f1d3bcac2259b52351ed5c904/output.json new file mode 100644 index 000000000..20efc3351 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/46f5403325bb369f1d3bcac2259b52351ed5c904/output.json @@ -0,0 +1 @@ +{"output":"","error":"Error: main.ts (2,34): Cannot find name 'Bool'.","status":"z3-failed","hash":"46f5403325bb369f1d3bcac2259b52351ed5c904"} diff --git a/website/solutions/z3-js/4.10.1/491bdd3231bd6dbc51757fc174481725a845729b/input.json b/website/solutions/z3-js/4.10.1/491bdd3231bd6dbc51757fc174481725a845729b/input.json new file mode 100644 index 000000000..439248a7b --- /dev/null +++ b/website/solutions/z3-js/4.10.1/491bdd3231bd6dbc51757fc174481725a845729b/input.json @@ -0,0 +1 @@ +{"input":"const { Solver, Int, Function, Implies, Not } = Z3.Context('main');\nconst solver = new Solver();\n\nconst sort = Int.sort();\nconst x = Int.const('x');\nconst y = Int.const('y');\nconst g = Function.declare('g', sort, sort);\n\nconst conjecture = Implies(x.eq(y), g.call(x).eq(g.call(y)));\nsolver.add(Not(conjecture));\nawait solver.check(); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/491bdd3231bd6dbc51757fc174481725a845729b/output.json b/website/solutions/z3-js/4.10.1/491bdd3231bd6dbc51757fc174481725a845729b/output.json new file mode 100644 index 000000000..bc555df14 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/491bdd3231bd6dbc51757fc174481725a845729b/output.json @@ -0,0 +1 @@ +{"output":"","error":"Error: main.ts (1,52): Property 'Context' does not exist on type 'Context<\"main\">'.","status":"z3-failed","hash":"491bdd3231bd6dbc51757fc174481725a845729b"} diff --git a/website/solutions/z3-js/4.10.1/5678f357a9cf1468590dc55d53ebea50d2c9dee9/input.json b/website/solutions/z3-js/4.10.1/5678f357a9cf1468590dc55d53ebea50d2c9dee9/input.json new file mode 100644 index 000000000..695be5ab4 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/5678f357a9cf1468590dc55d53ebea50d2c9dee9/input.json @@ -0,0 +1 @@ +{"input":"const solver = new Z3.Solver();\n\nconst sort = Z3.Int.sort();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\nconst g = Z3.Function.declare('g', sort, sort);\n\nconst conjecture = Z3.Implies(x.eq(y), g.call(x).eq(g.call(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check(); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/5678f357a9cf1468590dc55d53ebea50d2c9dee9/output.json b/website/solutions/z3-js/4.10.1/5678f357a9cf1468590dc55d53ebea50d2c9dee9/output.json new file mode 100644 index 000000000..7ad06d296 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/5678f357a9cf1468590dc55d53ebea50d2c9dee9/output.json @@ -0,0 +1 @@ +{"output":"unsat","error":"","status":"z3-ran","hash":"5678f357a9cf1468590dc55d53ebea50d2c9dee9"} diff --git a/website/solutions/z3-js/4.10.1/5897541f97424f6c569b8e8535c7b14b92ddd4aa/input.json b/website/solutions/z3-js/4.10.1/5897541f97424f6c569b8e8535c7b14b92ddd4aa/input.json new file mode 100644 index 000000000..96d3cee55 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/5897541f97424f6c569b8e8535c7b14b92ddd4aa/input.json @@ -0,0 +1 @@ +{"input":"// AstVector\nconst solver = new Z3.Solver();\n\nconst vector = new Z3.AstVector();\nfor (let i = 0; i < 5; i++) {\n vector.push(Int.const(`int__${i}`));\n}\n\nconst length = vector.length();\nfor (let i = 0; i < length; i++) {\n solver.add(vector.get(i).gt(1));\n}\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/5897541f97424f6c569b8e8535c7b14b92ddd4aa/output.json b/website/solutions/z3-js/4.10.1/5897541f97424f6c569b8e8535c7b14b92ddd4aa/output.json new file mode 100644 index 000000000..c3de2ca5d --- /dev/null +++ b/website/solutions/z3-js/4.10.1/5897541f97424f6c569b8e8535c7b14b92ddd4aa/output.json @@ -0,0 +1 @@ +{"output":"","error":"Error: main.ts (4,33): Cannot find namespace 'Z3'.\nmain.ts (6,17): Cannot find name 'Int'. Did you mean 'init'?","status":"z3-failed","hash":"5897541f97424f6c569b8e8535c7b14b92ddd4aa"} diff --git a/website/solutions/z3-js/4.10.1/5b83b77d17625c0b87bf1d40c2f1c0ca124c52fa/input.json b/website/solutions/z3-js/4.10.1/5b83b77d17625c0b87bf1d40c2f1c0ca124c52fa/input.json new file mode 100644 index 000000000..10e05b381 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/5b83b77d17625c0b87bf1d40c2f1c0ca124c52fa/input.json @@ -0,0 +1 @@ +{"input":"const solver = new Z3.Solver();\nconst sort = Z3.Int.sort();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\nconst g = Z3.Function.declare('g', sort, sort);\nconst conjecture = Z3.Implies(x.eq(y), g.call(g.call(x)).eq(g.call(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check(); //sat"} diff --git a/website/solutions/z3-js/4.10.1/5b83b77d17625c0b87bf1d40c2f1c0ca124c52fa/output.json b/website/solutions/z3-js/4.10.1/5b83b77d17625c0b87bf1d40c2f1c0ca124c52fa/output.json new file mode 100644 index 000000000..d4678591a --- /dev/null +++ b/website/solutions/z3-js/4.10.1/5b83b77d17625c0b87bf1d40c2f1c0ca124c52fa/output.json @@ -0,0 +1 @@ +{"output":"sat","error":"","status":"z3-ran","hash":"5b83b77d17625c0b87bf1d40c2f1c0ca124c52fa"} diff --git a/website/solutions/z3-js/4.10.1/5ecf8c91575f6ccd1d734229e481a083157c5691/input.json b/website/solutions/z3-js/4.10.1/5ecf8c91575f6ccd1d734229e481a083157c5691/input.json new file mode 100644 index 000000000..16db6cb7e --- /dev/null +++ b/website/solutions/z3-js/4.10.1/5ecf8c91575f6ccd1d734229e481a083157c5691/input.json @@ -0,0 +1 @@ +{"input":"// solves sudoku\nfunction toSudoku(data: string): (number | null)[][] {\n const cells: (number | null)[][] = Array.from({ length: 9 }, () => Array.from({ length: 9 }, () => null));\n\n const lines = data.trim().split('\\n');\n for (let row = 0; row < 9; row++) {\n const line = lines[row].trim();\n for (let col = 0; col < 9; col++) {\n const char = line[col];\n if (char !== '.') {\n cells[row][col] = Number.parseInt(char);\n }\n }\n }\n return cells;\n}\n\nconst INSTANCE = toSudoku(`\n....94.3.\n...51...7\n.89....4.\n......2.8\n.6.2.1.5.\n1.2......\n.7....52.\n9...65...\n.4.97....\n`);\n\nconst EXPECTED = toSudoku(`\n715894632\n234516897\n689723145\n493657218\n867231954\n152489763\n376148529\n928365471\n541972386\n`);\n\n\nconst cells: Arith[][] = [];\n// 9x9 matrix of integer variables\nfor (let i = 0; i < 9; i++) {\n const row = [];\n for (let j = 0; j < 9; j++) {\n row.push(Z3.Int.const(`x_${i}_${j}`));\n }\n cells.push(row);\n}\n\nconst solver = new Z3.Solver();\n\n// each cell contains a value 1<=x<=9\nfor (let i = 0; i < 9; i++) {\n for (let j = 0; j < 9; j++) {\n solver.add(cells[i][j].ge(1), cells[i][j].le(9));\n }\n}\n\n// each row contains a digit only once\nfor (let i = 0; i < 9; i++) {\n solver.add(Z3.Distinct(...cells[i]));\n}\n\n// each column contains a digit only once\nfor (let j = 0; j < 9; j++) {\n const column = [];\n for (let i = 0; i < 9; i++) {\n column.push(cells[i][j]);\n }\n solver.add(Z3.Distinct(...column));\n}\n\n// each 3x3 contains a digit at most once\nfor (let iSquare = 0; iSquare < 3; iSquare++) {\n for (let jSquare = 0; jSquare < 3; jSquare++) {\n const square = [];\n\n for (let i = iSquare * 3; i < iSquare * 3 + 3; i++) {\n for (let j = jSquare * 3; j < jSquare * 3 + 3; j++) {\n square.push(cells[i][j]);\n }\n }\n\n solver.add(Z3.Distinct(...square));\n }\n}\n\nfor (let i = 0; i < 9; i++) {\n for (let j = 0; j < 9; j++) {\n const digit = INSTANCE[i][j];\n if (digit !== null) {\n solver.add(cells[i][j].eq(digit));\n }\n }\n}\n\nawait solver.check(); // sat\n\nconst model = solver.model();\nmodel.sexpr();"} diff --git a/website/solutions/z3-js/4.10.1/5ecf8c91575f6ccd1d734229e481a083157c5691/output.json b/website/solutions/z3-js/4.10.1/5ecf8c91575f6ccd1d734229e481a083157c5691/output.json new file mode 100644 index 000000000..1b2f700f3 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/5ecf8c91575f6ccd1d734229e481a083157c5691/output.json @@ -0,0 +1 @@ +{"output":"","error":"Error: main.ts (43,14): Cannot find name 'Arith'.","status":"z3-failed","hash":"5ecf8c91575f6ccd1d734229e481a083157c5691"} diff --git a/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json b/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json new file mode 100644 index 000000000..e8242b702 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json @@ -0,0 +1 @@ +{"input":"// solves an equation\nconst x = Z3.BitVec.const('x', 32);\nconst y = Z3.BitVec.const('y', 32);\n\nconst solver = new Z3.Solver();\nconst conjecture = x.xor(y).sub(103).eq(x.mul(y));\nsolver.add(conjecture);\nawait solver.check(); // sat\n\nconst model = solver.model();\nconst xSol = model.get(x);\nconst ySol = model.get(y);\n\nZ3.isBitVecVal(xSol) && Z3.isBitVecVal(ySol); // true\n\n// TODO: fix the remaining lines\nconst xv = xSol.asSignedValue();\nconst yv = ySol.asSignedValue();\n\n// this solutions wraps around so we need to check using modulo\n(xv ^ yv) - 103n === (xv * yv) % 2n ** 32n; // true"} diff --git a/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/output.json b/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/output.json new file mode 100644 index 000000000..bec0415e7 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/output.json @@ -0,0 +1 @@ +{"output":"","error":"Error: main.ts (17,17): Property 'asSignedValue' does not exist on type 'Expr<\"main\", AnySort<\"main\">, unknown>'.\nmain.ts (18,17): Property 'asSignedValue' does not exist on type 'Expr<\"main\", AnySort<\"main\">, unknown>'.\nmain.ts (21,1): Operator '-' cannot be applied to types 'number' and 'bigint'.\nmain.ts (21,22): Operator '%' cannot be applied to types 'number' and 'bigint'.","status":"z3-failed","hash":"672ab86ec9acaee1bb65f6ac564af7990d37ade5"} diff --git a/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json b/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json new file mode 100644 index 000000000..17a56b4bc --- /dev/null +++ b/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json @@ -0,0 +1 @@ +{"input":"// numerals 2\nconst n4 = Z3.Real.val('-1/3');\nconst n5 = Z3.Real.val('-0.3333333333333333333333333333333333');\n\nconst conjecture = n4.neq(n5);\n\nconst solver = new Z3.Solver();\nsolver.add(Z3.Not(conjecture));\nawait solver.check();"} diff --git a/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json b/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json new file mode 100644 index 000000000..0080905d3 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json @@ -0,0 +1 @@ +{"output":"unsat","error":"","status":"z3-ran","hash":"6de42c85389d4407f0925ad8638fbd9b5b071cb4"} diff --git a/website/solutions/z3-js/4.10.1/6e9d92ab87857e9183644de010f7ef6bdef562b8/input.json b/website/solutions/z3-js/4.10.1/6e9d92ab87857e9183644de010f7ef6bdef562b8/input.json new file mode 100644 index 000000000..db0225dd6 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/6e9d92ab87857e9183644de010f7ef6bdef562b8/input.json @@ -0,0 +1 @@ +{"input":"// non-linear arithmetic\nZ3.setParam('pp.decimal', true);\nZ3.setParam('pp.decimal_precision', 20);\n\nconst x = Z3.Real.const('x');\nconst y = Z3.Real.const('y');\nconst z = Z3.Real.const('z');\n\nconst solver = new Z3.Solver();\nsolver.add(x.mul(x).add(y.mul(y)).eq(1)); // x^2 + y^2 == 1\nsolver.add(x.mul(x).mul(x).add(z.mul(z).mul(z)).lt('1/2')); // x^3 + z^3 < 1/2\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/6e9d92ab87857e9183644de010f7ef6bdef562b8/output.json b/website/solutions/z3-js/4.10.1/6e9d92ab87857e9183644de010f7ef6bdef562b8/output.json new file mode 100644 index 000000000..eeee1164c --- /dev/null +++ b/website/solutions/z3-js/4.10.1/6e9d92ab87857e9183644de010f7ef6bdef562b8/output.json @@ -0,0 +1 @@ +{"output":"","error":"Error: main.ts (2,4): Property 'setParam' does not exist on type 'Context<\"main\">'.\nmain.ts (3,4): Property 'setParam' does not exist on type 'Context<\"main\">'.","status":"z3-failed","hash":"6e9d92ab87857e9183644de010f7ef6bdef562b8"} diff --git a/website/solutions/z3-js/4.10.1/788b265b0e86a5cdd0ddcb82a35577b92065289d/input.json b/website/solutions/z3-js/4.10.1/788b265b0e86a5cdd0ddcb82a35577b92065289d/input.json new file mode 100644 index 000000000..558aaea89 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/788b265b0e86a5cdd0ddcb82a35577b92065289d/input.json @@ -0,0 +1 @@ +{"input":"// numerals 1\nconst n1 = Z3.Real.val('1/2');\nconst n2 = Z3.Real.val('0.5');\nconst n3 = Z3.Real.val(0.5);\n\nconst conjecture = Z3.And(n1.eq(n2), n1.eq(n3));\n\nconst solver = new Z3.solver();\nsolver.add(Z3.Not(conjecture));\nawait solver.check();"} diff --git a/website/solutions/z3-js/4.10.1/788b265b0e86a5cdd0ddcb82a35577b92065289d/output.json b/website/solutions/z3-js/4.10.1/788b265b0e86a5cdd0ddcb82a35577b92065289d/output.json new file mode 100644 index 000000000..fbca016ad --- /dev/null +++ b/website/solutions/z3-js/4.10.1/788b265b0e86a5cdd0ddcb82a35577b92065289d/output.json @@ -0,0 +1 @@ +{"output":"","error":"Error: main.ts (8,23): Property 'solver' does not exist on type 'Context<\"main\">'. Did you mean 'Solver'?","status":"z3-failed","hash":"788b265b0e86a5cdd0ddcb82a35577b92065289d"} diff --git a/website/solutions/z3-js/4.10.1/999bf5fd0b7cce57b4b5ae6371fd8e4d2e59a44b/input.json b/website/solutions/z3-js/4.10.1/999bf5fd0b7cce57b4b5ae6371fd8e4d2e59a44b/input.json new file mode 100644 index 000000000..7d44654cb --- /dev/null +++ b/website/solutions/z3-js/4.10.1/999bf5fd0b7cce57b4b5ae6371fd8e4d2e59a44b/input.json @@ -0,0 +1 @@ +{"input":""} diff --git a/website/solutions/z3-js/4.10.1/999bf5fd0b7cce57b4b5ae6371fd8e4d2e59a44b/output.json b/website/solutions/z3-js/4.10.1/999bf5fd0b7cce57b4b5ae6371fd8e4d2e59a44b/output.json new file mode 100644 index 000000000..0ff9c9f6d --- /dev/null +++ b/website/solutions/z3-js/4.10.1/999bf5fd0b7cce57b4b5ae6371fd8e4d2e59a44b/output.json @@ -0,0 +1 @@ +{"output":"undefined","error":"","status":"z3-ran","hash":"999bf5fd0b7cce57b4b5ae6371fd8e4d2e59a44b"} diff --git a/website/solutions/z3-js/4.10.1/9ae9ad60161b8106f420343ef151717ec00ed71d/input.json b/website/solutions/z3-js/4.10.1/9ae9ad60161b8106f420343ef151717ec00ed71d/input.json new file mode 100644 index 000000000..550764d7f --- /dev/null +++ b/website/solutions/z3-js/4.10.1/9ae9ad60161b8106f420343ef151717ec00ed71d/input.json @@ -0,0 +1 @@ +{"input":"// proves De Morgan's Law\nasync function prove(conjecture: Z3.Bool): Promise {\n const solver = new conjecture.ctx.Solver();\n const { Not } = solver.ctx;\n solver.add(Not(conjecture));\n await solver.check();\n}\n\nconst [x, y] = [Z3.Bool.const('x'), Z3.Bool.const('y')];\nconst conjecture = Z3.Eq(Z3.Not(Z3.And(x, y)), Z3.Or(Z3.Not(x), Z3.Not(y)));\nawait prove(conjecture); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/9ae9ad60161b8106f420343ef151717ec00ed71d/output.json b/website/solutions/z3-js/4.10.1/9ae9ad60161b8106f420343ef151717ec00ed71d/output.json new file mode 100644 index 000000000..db5ac2c45 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/9ae9ad60161b8106f420343ef151717ec00ed71d/output.json @@ -0,0 +1 @@ +{"output":"","error":"Error: main.ts (2,34): Cannot find namespace 'Z3'.","status":"z3-failed","hash":"9ae9ad60161b8106f420343ef151717ec00ed71d"} diff --git a/website/solutions/z3-js/4.10.1/a20a9ec1d64add1d969fa507522cebf35fd152fb/input.json b/website/solutions/z3-js/4.10.1/a20a9ec1d64add1d969fa507522cebf35fd152fb/input.json new file mode 100644 index 000000000..40747db2b --- /dev/null +++ b/website/solutions/z3-js/4.10.1/a20a9ec1d64add1d969fa507522cebf35fd152fb/input.json @@ -0,0 +1 @@ +{"input":"const { Solver, Int, Function, Implies, Not } = api.Context('main');\nconst solver = new Solver();\n\nconst sort = Int.sort();\nconst x = Int.const('x');\nconst y = Int.const('y');\nconst g = Function.declare('g', sort, sort);\n\nconst conjecture = Implies(x.eq(y), g.call(x).eq(g.call(y)));\nsolver.add(Not(conjecture));\nawait solver.check(); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/a20a9ec1d64add1d969fa507522cebf35fd152fb/output.json b/website/solutions/z3-js/4.10.1/a20a9ec1d64add1d969fa507522cebf35fd152fb/output.json new file mode 100644 index 000000000..e8755d2d7 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/a20a9ec1d64add1d969fa507522cebf35fd152fb/output.json @@ -0,0 +1 @@ +{"output":"","error":"Error: main.ts (1,49): Cannot find name 'api'.","status":"z3-failed","hash":"a20a9ec1d64add1d969fa507522cebf35fd152fb"} diff --git a/website/solutions/z3-js/4.10.1/b212b4a0cd87c65163c963e0c2c600db02567663/input.json b/website/solutions/z3-js/4.10.1/b212b4a0cd87c65163c963e0c2c600db02567663/input.json new file mode 100644 index 000000000..a026451dd --- /dev/null +++ b/website/solutions/z3-js/4.10.1/b212b4a0cd87c65163c963e0c2c600db02567663/input.json @@ -0,0 +1 @@ +{"input":"const solver = new Z3.Solver();\nconst sort = Z3.Int.sort();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\nconst g = Z3.Function.declare('g', sort, sort);\nconst conjecture = Z3.Implies(x.eq(y), g.call(g.call(x)).eq(g.call(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check()); //sat"} diff --git a/website/solutions/z3-js/4.10.1/b212b4a0cd87c65163c963e0c2c600db02567663/output.json b/website/solutions/z3-js/4.10.1/b212b4a0cd87c65163c963e0c2c600db02567663/output.json new file mode 100644 index 000000000..80cadae50 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/b212b4a0cd87c65163c963e0c2c600db02567663/output.json @@ -0,0 +1 @@ +{"output":"","error":"Error: main.ts (8,21): ';' expected.","status":"z3-failed","hash":"b212b4a0cd87c65163c963e0c2c600db02567663"} diff --git a/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json b/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json new file mode 100644 index 000000000..4abe05b0d --- /dev/null +++ b/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json @@ -0,0 +1 @@ +{"input":"// disproves that x = y implies g(g(x)) = g(y)\n\nconst solver = new Z3.Solver();\nconst sort = Z3.Int.sort();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\nconst g = Z3.Function.declare('g', sort, sort);\nconst conjecture = Z3.Implies(x.eq(y), g.call(g.call(x)).eq(g.call(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check(); //sat"} diff --git a/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json b/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json new file mode 100644 index 000000000..1c5a5ffb3 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json @@ -0,0 +1 @@ +{"output":"sat","error":"","status":"z3-ran","hash":"c55e03a7cc02e5abf176f20763b498f989027b91"} diff --git a/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json b/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json new file mode 100644 index 000000000..5381d600f --- /dev/null +++ b/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json @@ -0,0 +1 @@ +{"input":"// non-linear arithmetic\n\nZ3.setParam('pp.decimal', true);\nZ3.setParam('pp.decimal_precision', 20);\n\nconst x = Z3.Real.const('x');\nconst y = Z3.Real.const('y');\nconst z = Z3.Real.const('z');\n\nconst solver = new Z3.Solver();\nsolver.add(x.mul(x).add(y.mul(y)).eq(1)); // x^2 + y^2 == 1\nsolver.add(x.mul(x).mul(x).add(z.mul(z).mul(z)).lt('1/2')); // x^3 + z^3 < 1/2\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/output.json b/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/output.json new file mode 100644 index 000000000..e16193a6d --- /dev/null +++ b/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/output.json @@ -0,0 +1 @@ +{"output":"","error":"Error: main.ts (3,4): Property 'setParam' does not exist on type 'Context<\"main\">'.\nmain.ts (4,4): Property 'setParam' does not exist on type 'Context<\"main\">'.","status":"z3-failed","hash":"c777e5f62b2783f71dff077e516d20445f5331f3"} diff --git a/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/input.json b/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/input.json new file mode 100644 index 000000000..976fcfb60 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/input.json @@ -0,0 +1 @@ +{"input":"// AstVector\nconst solver = new Z3.Solver();\n\n// @ts-ignore: skipping typechecking for the following line for now, is there a better solution?\nconst vector = new Z3.AstVector();\nfor (let i = 0; i < 5; i++) {\n vector.push(Z3.Int.const(`int__${i}`));\n}\n\nconst length = vector.length();\nfor (let i = 0; i < length; i++) {\n solver.add(vector.get(i).gt(1));\n}\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/output.json b/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/output.json new file mode 100644 index 000000000..1976a3a28 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/output.json @@ -0,0 +1 @@ +{"output":"sat","error":"","status":"z3-ran","hash":"c89957f5908b877b8ca28d23edd51ae55dc0f6bb"} diff --git a/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json b/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json new file mode 100644 index 000000000..4076aabbd --- /dev/null +++ b/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json @@ -0,0 +1 @@ +{"input":"// solves sudoku\nfunction toSudoku(data: string): (number | null)[][] {\n const cells: (number | null)[][] = Array.from({ length: 9 }, () => Array.from({ length: 9 }, () => null));\n\n const lines = data.trim().split('\\n');\n for (let row = 0; row < 9; row++) {\n const line = lines[row].trim();\n for (let col = 0; col < 9; col++) {\n const char = line[col];\n if (char !== '.') {\n cells[row][col] = Number.parseInt(char);\n }\n }\n }\n return cells;\n}\n\nconst INSTANCE = toSudoku(`\n....94.3.\n...51...7\n.89....4.\n......2.8\n.6.2.1.5.\n1.2......\n.7....52.\n9...65...\n.4.97....\n`);\n\nconst EXPECTED = toSudoku(`\n715894632\n234516897\n689723145\n493657218\n867231954\n152489763\n376148529\n928365471\n541972386\n`);\n\n\nconst cells = [];\n// 9x9 matrix of integer variables\nfor (let i = 0; i < 9; i++) {\n const row = [];\n for (let j = 0; j < 9; j++) {\n row.push(Z3.Int.const(`x_${i}_${j}`));\n }\n cells.push(row);\n}\n\nconst solver = new Z3.Solver();\n\n// each cell contains a value 1<=x<=9\nfor (let i = 0; i < 9; i++) {\n for (let j = 0; j < 9; j++) {\n solver.add(cells[i][j].ge(1), cells[i][j].le(9));\n }\n}\n\n// each row contains a digit only once\nfor (let i = 0; i < 9; i++) {\n solver.add(Z3.Distinct(...cells[i]));\n}\n\n// each column contains a digit only once\nfor (let j = 0; j < 9; j++) {\n const column = [];\n for (let i = 0; i < 9; i++) {\n column.push(cells[i][j]);\n }\n solver.add(Z3.Distinct(...column));\n}\n\n// each 3x3 contains a digit at most once\nfor (let iSquare = 0; iSquare < 3; iSquare++) {\n for (let jSquare = 0; jSquare < 3; jSquare++) {\n const square = [];\n\n for (let i = iSquare * 3; i < iSquare * 3 + 3; i++) {\n for (let j = jSquare * 3; j < jSquare * 3 + 3; j++) {\n square.push(cells[i][j]);\n }\n }\n\n solver.add(Z3.Distinct(...square));\n }\n}\n\nfor (let i = 0; i < 9; i++) {\n for (let j = 0; j < 9; j++) {\n const digit = INSTANCE[i][j];\n if (digit !== null) {\n solver.add(cells[i][j].eq(digit));\n }\n }\n}\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json b/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json new file mode 100644 index 000000000..49f9dcd44 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json @@ -0,0 +1 @@ +{"output":"sat","error":"","status":"z3-ran","hash":"d274fcbbef696d7b8023d37cf910015ab7ce9c12"} diff --git a/website/solutions/z3-js/4.10.1/d4f060a97872ec1a74dca9e62eb920e920270d58/input.json b/website/solutions/z3-js/4.10.1/d4f060a97872ec1a74dca9e62eb920e920270d58/input.json new file mode 100644 index 000000000..70469b092 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/d4f060a97872ec1a74dca9e62eb920e920270d58/input.json @@ -0,0 +1 @@ +{"input":"// proves De Morgan's Law\n// @ts-ignore: TODO: how do we type check function arguments?\nasync function prove(conjecture: Z3.Bool): Promise {\n const solver = new conjecture.ctx.Solver();\n const { Not } = solver.ctx;\n solver.add(Not(conjecture));\n await solver.check();\n}\n\nconst [x, y] = [Z3.Bool.const('x'), Z3.Bool.const('y')];\nconst conjecture = Z3.Eq(Z3.Not(Z3.And(x, y)), Z3.Or(Z3.Not(x), Z3.Not(y)));\nawait prove(conjecture); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/d4f060a97872ec1a74dca9e62eb920e920270d58/output.json b/website/solutions/z3-js/4.10.1/d4f060a97872ec1a74dca9e62eb920e920270d58/output.json new file mode 100644 index 000000000..03bd88a34 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/d4f060a97872ec1a74dca9e62eb920e920270d58/output.json @@ -0,0 +1 @@ +{"output":"undefined","error":"","status":"z3-ran","hash":"d4f060a97872ec1a74dca9e62eb920e920270d58"} diff --git a/website/solutions/z3-js/4.10.1/e3e11a5ab2dbe41c0b86925b87de881d5160974d/input.json b/website/solutions/z3-js/4.10.1/e3e11a5ab2dbe41c0b86925b87de881d5160974d/input.json new file mode 100644 index 000000000..313d819fd --- /dev/null +++ b/website/solutions/z3-js/4.10.1/e3e11a5ab2dbe41c0b86925b87de881d5160974d/input.json @@ -0,0 +1 @@ +{"input":"// proves De Morgan's Law\nasync function prove(conjecture): Promise {\n const solver = new conjecture.ctx.Solver();\n const { Not } = solver.ctx;\n solver.add(Not(conjecture));\n await solver.check();\n}\n\nconst [x, y] = [Z3.Bool.const('x'), Z3.Bool.const('y')];\nconst conjecture = Z3.Eq(Z3.Not(Z3.And(x, y)), Z3.Or(Z3.Not(x), Z3.Not(y)));\nawait prove(conjecture); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/e3e11a5ab2dbe41c0b86925b87de881d5160974d/output.json b/website/solutions/z3-js/4.10.1/e3e11a5ab2dbe41c0b86925b87de881d5160974d/output.json new file mode 100644 index 000000000..22aced0bb --- /dev/null +++ b/website/solutions/z3-js/4.10.1/e3e11a5ab2dbe41c0b86925b87de881d5160974d/output.json @@ -0,0 +1 @@ +{"output":"","error":"Error: main.ts (2,22): Parameter 'conjecture' implicitly has an 'any' type.","status":"z3-failed","hash":"e3e11a5ab2dbe41c0b86925b87de881d5160974d"} diff --git a/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json b/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json new file mode 100644 index 000000000..61b54e9ad --- /dev/null +++ b/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json @@ -0,0 +1 @@ +{"input":"// proves De Morgan's Law\nconst solver = new Z3.Solver();\nconst [x, y] = [Z3.Bool.const('x'), Z3.Bool.const('y')];\nconst conjecture = Z3.Eq(Z3.Not(Z3.And(x, y)), Z3.Or(Z3.Not(x), Z3.Not(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check(); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json b/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json new file mode 100644 index 000000000..b3bd6b587 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json @@ -0,0 +1 @@ +{"output":"unsat","error":"","status":"z3-ran","hash":"e54e8215ee8788a22b2dcfca2420107f804c4de2"} diff --git a/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json b/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json new file mode 100644 index 000000000..7d9c2a291 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json @@ -0,0 +1 @@ +{"input":"// bitvectors: simple proofs\nconst x = Z3.BitVec.const('x', 32);\n\nconst sConj = x.sub(10).sle(0).eq(x.sle(10));\nconst sSolver = new Z3.Solver();\nsSolver.add(sConj);\nawait sSolver.check(); // sat\n\nconst sModel = sSolver.model();\nsModel.get(x) // signed\n\nconst uConj = x.sub(10).ule(0).eq(x.ule(10));\nconst uSolver = new Z3.Solver();\nuSolver.add(uConj);\nawait uSolver.check(); // sat\n\nconst uModel = uSolver.model();\nuModel.get(x) // unsigned"} diff --git a/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json b/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json new file mode 100644 index 000000000..758681685 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json @@ -0,0 +1 @@ +{"output":"#x0000000a","error":"","status":"z3-ran","hash":"f3e627e0f970fbc7fa1f6650366db67e71053bbd"} diff --git a/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json b/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json new file mode 100644 index 000000000..4942ccb53 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json @@ -0,0 +1 @@ +{"input":"// finds a model\nconst solver = new Z3.Solver();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\n\nsolver.add(x.ge(1)); // x >= 1\nsolver.add(y.lt(x.add(3))); // y < x + 3\n\nawait solver.check(); // sat\n\nconst model = solver.model();\nawait model.sexpr();"} diff --git a/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json b/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json new file mode 100644 index 000000000..78f01e626 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json @@ -0,0 +1 @@ +{"output":"(define-fun y () Int\n 3)\n(define-fun x () Int\n 1)","error":"","status":"z3-ran","hash":"f9dd66b1e430f36b7e955869f1646e0370ce0641"} From 7cc6ce33493420636d424ad18434413a70cacbbe Mon Sep 17 00:00:00 2001 From: "Ruanqianqian (Lisa) Huang" Date: Wed, 27 Jul 2022 16:47:46 -0700 Subject: [PATCH 08/18] remove output built during hot reloading --- .../4.10.1/120348cdd1a33f7a5ea77ced9a49513bd9e42f98/input.json | 1 - .../4.10.1/120348cdd1a33f7a5ea77ced9a49513bd9e42f98/output.json | 1 - .../4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json | 1 - .../4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json | 1 - .../4.10.1/179dd97050b2837e643e57ae48b71fafb961ded9/input.json | 1 - .../4.10.1/179dd97050b2837e643e57ae48b71fafb961ded9/output.json | 1 - .../4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json | 1 - .../4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json | 1 - .../4.10.1/22a00a9de953b65e266f7350f17c24335e578f1d/input.json | 1 - .../4.10.1/22a00a9de953b65e266f7350f17c24335e578f1d/output.json | 1 - .../4.10.1/269fa052599ca1d51942cdfa717c1ffd572545a0/input.json | 1 - .../4.10.1/269fa052599ca1d51942cdfa717c1ffd572545a0/output.json | 1 - .../4.10.1/39954bcec86de152bbaba4b0c40e7e1449f7edf6/input.json | 1 - .../4.10.1/39954bcec86de152bbaba4b0c40e7e1449f7edf6/output.json | 1 - .../4.10.1/441eb730296cbbd94ba5e98a26afabab0ec5f8ef/input.json | 1 - .../4.10.1/441eb730296cbbd94ba5e98a26afabab0ec5f8ef/output.json | 1 - .../4.10.1/46f5403325bb369f1d3bcac2259b52351ed5c904/input.json | 1 - .../4.10.1/46f5403325bb369f1d3bcac2259b52351ed5c904/output.json | 1 - .../4.10.1/491bdd3231bd6dbc51757fc174481725a845729b/input.json | 1 - .../4.10.1/491bdd3231bd6dbc51757fc174481725a845729b/output.json | 1 - .../4.10.1/5678f357a9cf1468590dc55d53ebea50d2c9dee9/input.json | 1 - .../4.10.1/5678f357a9cf1468590dc55d53ebea50d2c9dee9/output.json | 1 - .../4.10.1/5897541f97424f6c569b8e8535c7b14b92ddd4aa/input.json | 1 - .../4.10.1/5897541f97424f6c569b8e8535c7b14b92ddd4aa/output.json | 1 - .../4.10.1/5b83b77d17625c0b87bf1d40c2f1c0ca124c52fa/input.json | 1 - .../4.10.1/5b83b77d17625c0b87bf1d40c2f1c0ca124c52fa/output.json | 1 - .../4.10.1/5ecf8c91575f6ccd1d734229e481a083157c5691/input.json | 1 - .../4.10.1/5ecf8c91575f6ccd1d734229e481a083157c5691/output.json | 1 - .../4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json | 1 - .../4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/output.json | 1 - .../4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json | 1 - .../4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json | 1 - .../4.10.1/6e9d92ab87857e9183644de010f7ef6bdef562b8/input.json | 1 - .../4.10.1/6e9d92ab87857e9183644de010f7ef6bdef562b8/output.json | 1 - .../4.10.1/788b265b0e86a5cdd0ddcb82a35577b92065289d/input.json | 1 - .../4.10.1/788b265b0e86a5cdd0ddcb82a35577b92065289d/output.json | 1 - .../4.10.1/999bf5fd0b7cce57b4b5ae6371fd8e4d2e59a44b/input.json | 1 - .../4.10.1/999bf5fd0b7cce57b4b5ae6371fd8e4d2e59a44b/output.json | 1 - .../4.10.1/9ae9ad60161b8106f420343ef151717ec00ed71d/input.json | 1 - .../4.10.1/9ae9ad60161b8106f420343ef151717ec00ed71d/output.json | 1 - .../4.10.1/a20a9ec1d64add1d969fa507522cebf35fd152fb/input.json | 1 - .../4.10.1/a20a9ec1d64add1d969fa507522cebf35fd152fb/output.json | 1 - .../4.10.1/b212b4a0cd87c65163c963e0c2c600db02567663/input.json | 1 - .../4.10.1/b212b4a0cd87c65163c963e0c2c600db02567663/output.json | 1 - .../4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json | 1 - .../4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json | 1 - .../4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json | 1 - .../4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/output.json | 1 - .../4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/input.json | 1 - .../4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/output.json | 1 - .../4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json | 1 - .../4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json | 1 - .../4.10.1/d4f060a97872ec1a74dca9e62eb920e920270d58/input.json | 1 - .../4.10.1/d4f060a97872ec1a74dca9e62eb920e920270d58/output.json | 1 - .../4.10.1/e3e11a5ab2dbe41c0b86925b87de881d5160974d/input.json | 1 - .../4.10.1/e3e11a5ab2dbe41c0b86925b87de881d5160974d/output.json | 1 - .../4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json | 1 - .../4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json | 1 - .../4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json | 1 - .../4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json | 1 - .../4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json | 1 - .../4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json | 1 - 62 files changed, 62 deletions(-) delete mode 100644 website/solutions/z3-js/4.10.1/120348cdd1a33f7a5ea77ced9a49513bd9e42f98/input.json delete mode 100644 website/solutions/z3-js/4.10.1/120348cdd1a33f7a5ea77ced9a49513bd9e42f98/output.json delete mode 100644 website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json delete mode 100644 website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json delete mode 100644 website/solutions/z3-js/4.10.1/179dd97050b2837e643e57ae48b71fafb961ded9/input.json delete mode 100644 website/solutions/z3-js/4.10.1/179dd97050b2837e643e57ae48b71fafb961ded9/output.json delete mode 100644 website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json delete mode 100644 website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json delete mode 100644 website/solutions/z3-js/4.10.1/22a00a9de953b65e266f7350f17c24335e578f1d/input.json delete mode 100644 website/solutions/z3-js/4.10.1/22a00a9de953b65e266f7350f17c24335e578f1d/output.json delete mode 100644 website/solutions/z3-js/4.10.1/269fa052599ca1d51942cdfa717c1ffd572545a0/input.json delete mode 100644 website/solutions/z3-js/4.10.1/269fa052599ca1d51942cdfa717c1ffd572545a0/output.json delete mode 100644 website/solutions/z3-js/4.10.1/39954bcec86de152bbaba4b0c40e7e1449f7edf6/input.json delete mode 100644 website/solutions/z3-js/4.10.1/39954bcec86de152bbaba4b0c40e7e1449f7edf6/output.json delete mode 100644 website/solutions/z3-js/4.10.1/441eb730296cbbd94ba5e98a26afabab0ec5f8ef/input.json delete mode 100644 website/solutions/z3-js/4.10.1/441eb730296cbbd94ba5e98a26afabab0ec5f8ef/output.json delete mode 100644 website/solutions/z3-js/4.10.1/46f5403325bb369f1d3bcac2259b52351ed5c904/input.json delete mode 100644 website/solutions/z3-js/4.10.1/46f5403325bb369f1d3bcac2259b52351ed5c904/output.json delete mode 100644 website/solutions/z3-js/4.10.1/491bdd3231bd6dbc51757fc174481725a845729b/input.json delete mode 100644 website/solutions/z3-js/4.10.1/491bdd3231bd6dbc51757fc174481725a845729b/output.json delete mode 100644 website/solutions/z3-js/4.10.1/5678f357a9cf1468590dc55d53ebea50d2c9dee9/input.json delete mode 100644 website/solutions/z3-js/4.10.1/5678f357a9cf1468590dc55d53ebea50d2c9dee9/output.json delete mode 100644 website/solutions/z3-js/4.10.1/5897541f97424f6c569b8e8535c7b14b92ddd4aa/input.json delete mode 100644 website/solutions/z3-js/4.10.1/5897541f97424f6c569b8e8535c7b14b92ddd4aa/output.json delete mode 100644 website/solutions/z3-js/4.10.1/5b83b77d17625c0b87bf1d40c2f1c0ca124c52fa/input.json delete mode 100644 website/solutions/z3-js/4.10.1/5b83b77d17625c0b87bf1d40c2f1c0ca124c52fa/output.json delete mode 100644 website/solutions/z3-js/4.10.1/5ecf8c91575f6ccd1d734229e481a083157c5691/input.json delete mode 100644 website/solutions/z3-js/4.10.1/5ecf8c91575f6ccd1d734229e481a083157c5691/output.json delete mode 100644 website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json delete mode 100644 website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/output.json delete mode 100644 website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json delete mode 100644 website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json delete mode 100644 website/solutions/z3-js/4.10.1/6e9d92ab87857e9183644de010f7ef6bdef562b8/input.json delete mode 100644 website/solutions/z3-js/4.10.1/6e9d92ab87857e9183644de010f7ef6bdef562b8/output.json delete mode 100644 website/solutions/z3-js/4.10.1/788b265b0e86a5cdd0ddcb82a35577b92065289d/input.json delete mode 100644 website/solutions/z3-js/4.10.1/788b265b0e86a5cdd0ddcb82a35577b92065289d/output.json delete mode 100644 website/solutions/z3-js/4.10.1/999bf5fd0b7cce57b4b5ae6371fd8e4d2e59a44b/input.json delete mode 100644 website/solutions/z3-js/4.10.1/999bf5fd0b7cce57b4b5ae6371fd8e4d2e59a44b/output.json delete mode 100644 website/solutions/z3-js/4.10.1/9ae9ad60161b8106f420343ef151717ec00ed71d/input.json delete mode 100644 website/solutions/z3-js/4.10.1/9ae9ad60161b8106f420343ef151717ec00ed71d/output.json delete mode 100644 website/solutions/z3-js/4.10.1/a20a9ec1d64add1d969fa507522cebf35fd152fb/input.json delete mode 100644 website/solutions/z3-js/4.10.1/a20a9ec1d64add1d969fa507522cebf35fd152fb/output.json delete mode 100644 website/solutions/z3-js/4.10.1/b212b4a0cd87c65163c963e0c2c600db02567663/input.json delete mode 100644 website/solutions/z3-js/4.10.1/b212b4a0cd87c65163c963e0c2c600db02567663/output.json delete mode 100644 website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json delete mode 100644 website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json delete mode 100644 website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json delete mode 100644 website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/output.json delete mode 100644 website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/input.json delete mode 100644 website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/output.json delete mode 100644 website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json delete mode 100644 website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json delete mode 100644 website/solutions/z3-js/4.10.1/d4f060a97872ec1a74dca9e62eb920e920270d58/input.json delete mode 100644 website/solutions/z3-js/4.10.1/d4f060a97872ec1a74dca9e62eb920e920270d58/output.json delete mode 100644 website/solutions/z3-js/4.10.1/e3e11a5ab2dbe41c0b86925b87de881d5160974d/input.json delete mode 100644 website/solutions/z3-js/4.10.1/e3e11a5ab2dbe41c0b86925b87de881d5160974d/output.json delete mode 100644 website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json delete mode 100644 website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json delete mode 100644 website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json delete mode 100644 website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json delete mode 100644 website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json delete mode 100644 website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json diff --git a/website/solutions/z3-js/4.10.1/120348cdd1a33f7a5ea77ced9a49513bd9e42f98/input.json b/website/solutions/z3-js/4.10.1/120348cdd1a33f7a5ea77ced9a49513bd9e42f98/input.json deleted file mode 100644 index 2dbc97897..000000000 --- a/website/solutions/z3-js/4.10.1/120348cdd1a33f7a5ea77ced9a49513bd9e42f98/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// proves De Morgan's Law\nconst solver = new Z3.Solver();\nconst [x, y] = [Z3.Bool.const('x'), Z3.Bool.const('y')];\nconst conjecture = Z3.Eq(Z3.Not(Z3.And(x, y)), Z3.Or(Z3.Not(x), Z3.Not(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check();"} diff --git a/website/solutions/z3-js/4.10.1/120348cdd1a33f7a5ea77ced9a49513bd9e42f98/output.json b/website/solutions/z3-js/4.10.1/120348cdd1a33f7a5ea77ced9a49513bd9e42f98/output.json deleted file mode 100644 index dabad07fe..000000000 --- a/website/solutions/z3-js/4.10.1/120348cdd1a33f7a5ea77ced9a49513bd9e42f98/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"unsat","error":"","status":"z3-ran","hash":"120348cdd1a33f7a5ea77ced9a49513bd9e42f98"} diff --git a/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json b/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json deleted file mode 100644 index 1c80b9958..000000000 --- a/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// proves x = y implies g(x) = g(y)\n\nconst solver = new Z3.Solver();\nconst sort = Z3.Int.sort();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\nconst g = Z3.Function.declare('g', sort, sort);\n\nconst conjecture = Z3.Implies(x.eq(y), g.call(x).eq(g.call(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check(); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json b/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json deleted file mode 100644 index 7b8842b14..000000000 --- a/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"unsat","error":"","status":"z3-ran","hash":"16a515db3b88471d8f266b464b2344b2a30d00b7"} diff --git a/website/solutions/z3-js/4.10.1/179dd97050b2837e643e57ae48b71fafb961ded9/input.json b/website/solutions/z3-js/4.10.1/179dd97050b2837e643e57ae48b71fafb961ded9/input.json deleted file mode 100644 index 4109d72d7..000000000 --- a/website/solutions/z3-js/4.10.1/179dd97050b2837e643e57ae48b71fafb961ded9/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// non-linear arithmetic\n// TODO: setParam doesn't work with how with process JS inputs\n\nZ3.setParam('pp.decimal', true);\nZ3.setParam('pp.decimal_precision', 20);\n\nconst x = Z3.Real.const('x');\nconst y = Z3.Real.const('y');\nconst z = Z3.Real.const('z');\n\nconst solver = new Z3.Solver();\nsolver.add(x.mul(x).add(y.mul(y)).eq(1)); // x^2 + y^2 == 1\nsolver.add(x.mul(x).mul(x).add(z.mul(z).mul(z)).lt('1/2')); // x^3 + z^3 < 1/2\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/179dd97050b2837e643e57ae48b71fafb961ded9/output.json b/website/solutions/z3-js/4.10.1/179dd97050b2837e643e57ae48b71fafb961ded9/output.json deleted file mode 100644 index 63a12816d..000000000 --- a/website/solutions/z3-js/4.10.1/179dd97050b2837e643e57ae48b71fafb961ded9/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"","error":"Error: main.ts (4,4): Property 'setParam' does not exist on type 'Context<\"main\">'.\nmain.ts (5,4): Property 'setParam' does not exist on type 'Context<\"main\">'.","status":"z3-failed","hash":"179dd97050b2837e643e57ae48b71fafb961ded9"} diff --git a/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json b/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json deleted file mode 100644 index 099177988..000000000 --- a/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// numerals 1\nconst n1 = Z3.Real.val('1/2');\nconst n2 = Z3.Real.val('0.5');\nconst n3 = Z3.Real.val(0.5);\n\nconst conjecture = Z3.And(n1.eq(n2), n1.eq(n3));\n\nconst solver = new Z3.Solver();\nsolver.add(Z3.Not(conjecture));\nawait solver.check();"} diff --git a/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json b/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json deleted file mode 100644 index 0414391c4..000000000 --- a/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"unsat","error":"","status":"z3-ran","hash":"18db6515b197b55df72654ada88a28ab104776e0"} diff --git a/website/solutions/z3-js/4.10.1/22a00a9de953b65e266f7350f17c24335e578f1d/input.json b/website/solutions/z3-js/4.10.1/22a00a9de953b65e266f7350f17c24335e578f1d/input.json deleted file mode 100644 index 54de8ccf7..000000000 --- a/website/solutions/z3-js/4.10.1/22a00a9de953b65e266f7350f17c24335e578f1d/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// solves an equation\nconst x = Z3.BitVec.const('x', 32);\nconst y = Z3.BitVec.const('y', 32);\n\nconst solver = new Z3.Solver();\nconst conjecture = x.xor(y).sub(103).eq(x.mul(y));\nsolver.add(conjecture);\nawait solver.check(); // sat\n\nconst model = solver.model();\nconst xSol = model.get(x);\nconst ySol = model.get(y);\n\nZ3.isBitVecVal(xSol) && Z3.isBitVecVal(ySol); // true\n\nconst xv = xSol.asSignedValue();\nconst yv = ySol.asSignedValue();\n\n// this solutions wraps around so we need to check using modulo\n(xv ^ yv) - 103n === (xv * yv) % 2n ** 32n; // true"} diff --git a/website/solutions/z3-js/4.10.1/22a00a9de953b65e266f7350f17c24335e578f1d/output.json b/website/solutions/z3-js/4.10.1/22a00a9de953b65e266f7350f17c24335e578f1d/output.json deleted file mode 100644 index ab528a44b..000000000 --- a/website/solutions/z3-js/4.10.1/22a00a9de953b65e266f7350f17c24335e578f1d/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"","error":"Error: main.ts (16,17): Property 'asSignedValue' does not exist on type 'Expr<\"main\", AnySort<\"main\">, unknown>'.\nmain.ts (17,17): Property 'asSignedValue' does not exist on type 'Expr<\"main\", AnySort<\"main\">, unknown>'.\nmain.ts (20,1): Operator '-' cannot be applied to types 'number' and 'bigint'.\nmain.ts (20,22): Operator '%' cannot be applied to types 'number' and 'bigint'.","status":"z3-failed","hash":"22a00a9de953b65e266f7350f17c24335e578f1d"} diff --git a/website/solutions/z3-js/4.10.1/269fa052599ca1d51942cdfa717c1ffd572545a0/input.json b/website/solutions/z3-js/4.10.1/269fa052599ca1d51942cdfa717c1ffd572545a0/input.json deleted file mode 100644 index 07c9660da..000000000 --- a/website/solutions/z3-js/4.10.1/269fa052599ca1d51942cdfa717c1ffd572545a0/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// bitvectors\nconst x = Z3.BitVec.const('x', 32);\n\nconst sConj = x.sub(10).sle(0).eq(x.sle(10));\nconst sSolver = new Z3.Solver();\nsSolver.add(sConj);\nawait sSolver.check(); // sat\n\nconst sModel = sSolver.model();\nsModel.get(x) // signed\n\nconst uConj = x.sub(10).ule(0).eq(x.ule(10));\nconst uSolver = new Z3.Solver();\nuSolver.add(uConj);\nawait uSolver.check(); // sat\n\nconst uModel = uSolver.model();\nuModel.get(x) // unsigned"} diff --git a/website/solutions/z3-js/4.10.1/269fa052599ca1d51942cdfa717c1ffd572545a0/output.json b/website/solutions/z3-js/4.10.1/269fa052599ca1d51942cdfa717c1ffd572545a0/output.json deleted file mode 100644 index 1e063a252..000000000 --- a/website/solutions/z3-js/4.10.1/269fa052599ca1d51942cdfa717c1ffd572545a0/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"#x0000000a","error":"","status":"z3-ran","hash":"269fa052599ca1d51942cdfa717c1ffd572545a0"} diff --git a/website/solutions/z3-js/4.10.1/39954bcec86de152bbaba4b0c40e7e1449f7edf6/input.json b/website/solutions/z3-js/4.10.1/39954bcec86de152bbaba4b0c40e7e1449f7edf6/input.json deleted file mode 100644 index 73b84ee3e..000000000 --- a/website/solutions/z3-js/4.10.1/39954bcec86de152bbaba4b0c40e7e1449f7edf6/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// solves sudoku\nfunction toSudoku(data: string): (number | null)[][] {\n const cells: (number | null)[][] = Array.from({ length: 9 }, () => Array.from({ length: 9 }, () => null));\n\n const lines = data.trim().split('\\n');\n for (let row = 0; row < 9; row++) {\n const line = lines[row].trim();\n for (let col = 0; col < 9; col++) {\n const char = line[col];\n if (char !== '.') {\n cells[row][col] = Number.parseInt(char);\n }\n }\n }\n return cells;\n}\n\nconst INSTANCE = toSudoku(`\n....94.3.\n...51...7\n.89....4.\n......2.8\n.6.2.1.5.\n1.2......\n.7....52.\n9...65...\n.4.97....\n`);\n\nconst EXPECTED = toSudoku(`\n715894632\n234516897\n689723145\n493657218\n867231954\n152489763\n376148529\n928365471\n541972386\n`);\n\n\nconst cells: Z3.Arith[][] = [];\n// 9x9 matrix of integer variables\nfor (let i = 0; i < 9; i++) {\n const row = [];\n for (let j = 0; j < 9; j++) {\n row.push(Z3.Int.const(`x_${i}_${j}`));\n }\n cells.push(row);\n}\n\nconst solver = new Z3.Solver();\n\n// each cell contains a value 1<=x<=9\nfor (let i = 0; i < 9; i++) {\n for (let j = 0; j < 9; j++) {\n solver.add(cells[i][j].ge(1), cells[i][j].le(9));\n }\n}\n\n// each row contains a digit only once\nfor (let i = 0; i < 9; i++) {\n solver.add(Z3.Distinct(...cells[i]));\n}\n\n// each column contains a digit only once\nfor (let j = 0; j < 9; j++) {\n const column = [];\n for (let i = 0; i < 9; i++) {\n column.push(cells[i][j]);\n }\n solver.add(Z3.Distinct(...column));\n}\n\n// each 3x3 contains a digit at most once\nfor (let iSquare = 0; iSquare < 3; iSquare++) {\n for (let jSquare = 0; jSquare < 3; jSquare++) {\n const square = [];\n\n for (let i = iSquare * 3; i < iSquare * 3 + 3; i++) {\n for (let j = jSquare * 3; j < jSquare * 3 + 3; j++) {\n square.push(cells[i][j]);\n }\n }\n\n solver.add(Z3.Distinct(...square));\n }\n}\n\nfor (let i = 0; i < 9; i++) {\n for (let j = 0; j < 9; j++) {\n const digit = INSTANCE[i][j];\n if (digit !== null) {\n solver.add(cells[i][j].eq(digit));\n }\n }\n}\n\nawait solver.check(); // sat\n\nconst model = solver.model();\nmodel.sexpr();"} diff --git a/website/solutions/z3-js/4.10.1/39954bcec86de152bbaba4b0c40e7e1449f7edf6/output.json b/website/solutions/z3-js/4.10.1/39954bcec86de152bbaba4b0c40e7e1449f7edf6/output.json deleted file mode 100644 index a429f1ba2..000000000 --- a/website/solutions/z3-js/4.10.1/39954bcec86de152bbaba4b0c40e7e1449f7edf6/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"","error":"Error: main.ts (43,14): Cannot find namespace 'Z3'.","status":"z3-failed","hash":"39954bcec86de152bbaba4b0c40e7e1449f7edf6"} diff --git a/website/solutions/z3-js/4.10.1/441eb730296cbbd94ba5e98a26afabab0ec5f8ef/input.json b/website/solutions/z3-js/4.10.1/441eb730296cbbd94ba5e98a26afabab0ec5f8ef/input.json deleted file mode 100644 index 5aa8903b2..000000000 --- a/website/solutions/z3-js/4.10.1/441eb730296cbbd94ba5e98a26afabab0ec5f8ef/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// numerals 2\nconst n4 = Z3.Real.val('-1/3');\nconst n5 = Z3.Real.val('-0.3333333333333333333333333333333333');\n\nconst conjecture = n4.neq(n5);\n\nconst solver = new Z3.solver();\nsolver.add(Z3.Not(conjecture));\nawait solver.check();"} diff --git a/website/solutions/z3-js/4.10.1/441eb730296cbbd94ba5e98a26afabab0ec5f8ef/output.json b/website/solutions/z3-js/4.10.1/441eb730296cbbd94ba5e98a26afabab0ec5f8ef/output.json deleted file mode 100644 index cb9cb6c62..000000000 --- a/website/solutions/z3-js/4.10.1/441eb730296cbbd94ba5e98a26afabab0ec5f8ef/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"","error":"Error: main.ts (7,23): Property 'solver' does not exist on type 'Context<\"main\">'. Did you mean 'Solver'?","status":"z3-failed","hash":"441eb730296cbbd94ba5e98a26afabab0ec5f8ef"} diff --git a/website/solutions/z3-js/4.10.1/46f5403325bb369f1d3bcac2259b52351ed5c904/input.json b/website/solutions/z3-js/4.10.1/46f5403325bb369f1d3bcac2259b52351ed5c904/input.json deleted file mode 100644 index 692f3fd02..000000000 --- a/website/solutions/z3-js/4.10.1/46f5403325bb369f1d3bcac2259b52351ed5c904/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// proves De Morgan's Law\nasync function prove(conjecture: Bool): Promise {\n const solver = new conjecture.ctx.Solver();\n const { Not } = solver.ctx;\n solver.add(Not(conjecture));\n await solver.check();\n}\n\nconst [x, y] = [Z3.Bool.const('x'), Z3.Bool.const('y')];\nconst conjecture = Z3.Eq(Z3.Not(Z3.And(x, y)), Z3.Or(Z3.Not(x), Z3.Not(y)));\nawait prove(conjecture); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/46f5403325bb369f1d3bcac2259b52351ed5c904/output.json b/website/solutions/z3-js/4.10.1/46f5403325bb369f1d3bcac2259b52351ed5c904/output.json deleted file mode 100644 index 20efc3351..000000000 --- a/website/solutions/z3-js/4.10.1/46f5403325bb369f1d3bcac2259b52351ed5c904/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"","error":"Error: main.ts (2,34): Cannot find name 'Bool'.","status":"z3-failed","hash":"46f5403325bb369f1d3bcac2259b52351ed5c904"} diff --git a/website/solutions/z3-js/4.10.1/491bdd3231bd6dbc51757fc174481725a845729b/input.json b/website/solutions/z3-js/4.10.1/491bdd3231bd6dbc51757fc174481725a845729b/input.json deleted file mode 100644 index 439248a7b..000000000 --- a/website/solutions/z3-js/4.10.1/491bdd3231bd6dbc51757fc174481725a845729b/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"const { Solver, Int, Function, Implies, Not } = Z3.Context('main');\nconst solver = new Solver();\n\nconst sort = Int.sort();\nconst x = Int.const('x');\nconst y = Int.const('y');\nconst g = Function.declare('g', sort, sort);\n\nconst conjecture = Implies(x.eq(y), g.call(x).eq(g.call(y)));\nsolver.add(Not(conjecture));\nawait solver.check(); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/491bdd3231bd6dbc51757fc174481725a845729b/output.json b/website/solutions/z3-js/4.10.1/491bdd3231bd6dbc51757fc174481725a845729b/output.json deleted file mode 100644 index bc555df14..000000000 --- a/website/solutions/z3-js/4.10.1/491bdd3231bd6dbc51757fc174481725a845729b/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"","error":"Error: main.ts (1,52): Property 'Context' does not exist on type 'Context<\"main\">'.","status":"z3-failed","hash":"491bdd3231bd6dbc51757fc174481725a845729b"} diff --git a/website/solutions/z3-js/4.10.1/5678f357a9cf1468590dc55d53ebea50d2c9dee9/input.json b/website/solutions/z3-js/4.10.1/5678f357a9cf1468590dc55d53ebea50d2c9dee9/input.json deleted file mode 100644 index 695be5ab4..000000000 --- a/website/solutions/z3-js/4.10.1/5678f357a9cf1468590dc55d53ebea50d2c9dee9/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"const solver = new Z3.Solver();\n\nconst sort = Z3.Int.sort();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\nconst g = Z3.Function.declare('g', sort, sort);\n\nconst conjecture = Z3.Implies(x.eq(y), g.call(x).eq(g.call(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check(); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/5678f357a9cf1468590dc55d53ebea50d2c9dee9/output.json b/website/solutions/z3-js/4.10.1/5678f357a9cf1468590dc55d53ebea50d2c9dee9/output.json deleted file mode 100644 index 7ad06d296..000000000 --- a/website/solutions/z3-js/4.10.1/5678f357a9cf1468590dc55d53ebea50d2c9dee9/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"unsat","error":"","status":"z3-ran","hash":"5678f357a9cf1468590dc55d53ebea50d2c9dee9"} diff --git a/website/solutions/z3-js/4.10.1/5897541f97424f6c569b8e8535c7b14b92ddd4aa/input.json b/website/solutions/z3-js/4.10.1/5897541f97424f6c569b8e8535c7b14b92ddd4aa/input.json deleted file mode 100644 index 96d3cee55..000000000 --- a/website/solutions/z3-js/4.10.1/5897541f97424f6c569b8e8535c7b14b92ddd4aa/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// AstVector\nconst solver = new Z3.Solver();\n\nconst vector = new Z3.AstVector();\nfor (let i = 0; i < 5; i++) {\n vector.push(Int.const(`int__${i}`));\n}\n\nconst length = vector.length();\nfor (let i = 0; i < length; i++) {\n solver.add(vector.get(i).gt(1));\n}\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/5897541f97424f6c569b8e8535c7b14b92ddd4aa/output.json b/website/solutions/z3-js/4.10.1/5897541f97424f6c569b8e8535c7b14b92ddd4aa/output.json deleted file mode 100644 index c3de2ca5d..000000000 --- a/website/solutions/z3-js/4.10.1/5897541f97424f6c569b8e8535c7b14b92ddd4aa/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"","error":"Error: main.ts (4,33): Cannot find namespace 'Z3'.\nmain.ts (6,17): Cannot find name 'Int'. Did you mean 'init'?","status":"z3-failed","hash":"5897541f97424f6c569b8e8535c7b14b92ddd4aa"} diff --git a/website/solutions/z3-js/4.10.1/5b83b77d17625c0b87bf1d40c2f1c0ca124c52fa/input.json b/website/solutions/z3-js/4.10.1/5b83b77d17625c0b87bf1d40c2f1c0ca124c52fa/input.json deleted file mode 100644 index 10e05b381..000000000 --- a/website/solutions/z3-js/4.10.1/5b83b77d17625c0b87bf1d40c2f1c0ca124c52fa/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"const solver = new Z3.Solver();\nconst sort = Z3.Int.sort();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\nconst g = Z3.Function.declare('g', sort, sort);\nconst conjecture = Z3.Implies(x.eq(y), g.call(g.call(x)).eq(g.call(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check(); //sat"} diff --git a/website/solutions/z3-js/4.10.1/5b83b77d17625c0b87bf1d40c2f1c0ca124c52fa/output.json b/website/solutions/z3-js/4.10.1/5b83b77d17625c0b87bf1d40c2f1c0ca124c52fa/output.json deleted file mode 100644 index d4678591a..000000000 --- a/website/solutions/z3-js/4.10.1/5b83b77d17625c0b87bf1d40c2f1c0ca124c52fa/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"sat","error":"","status":"z3-ran","hash":"5b83b77d17625c0b87bf1d40c2f1c0ca124c52fa"} diff --git a/website/solutions/z3-js/4.10.1/5ecf8c91575f6ccd1d734229e481a083157c5691/input.json b/website/solutions/z3-js/4.10.1/5ecf8c91575f6ccd1d734229e481a083157c5691/input.json deleted file mode 100644 index 16db6cb7e..000000000 --- a/website/solutions/z3-js/4.10.1/5ecf8c91575f6ccd1d734229e481a083157c5691/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// solves sudoku\nfunction toSudoku(data: string): (number | null)[][] {\n const cells: (number | null)[][] = Array.from({ length: 9 }, () => Array.from({ length: 9 }, () => null));\n\n const lines = data.trim().split('\\n');\n for (let row = 0; row < 9; row++) {\n const line = lines[row].trim();\n for (let col = 0; col < 9; col++) {\n const char = line[col];\n if (char !== '.') {\n cells[row][col] = Number.parseInt(char);\n }\n }\n }\n return cells;\n}\n\nconst INSTANCE = toSudoku(`\n....94.3.\n...51...7\n.89....4.\n......2.8\n.6.2.1.5.\n1.2......\n.7....52.\n9...65...\n.4.97....\n`);\n\nconst EXPECTED = toSudoku(`\n715894632\n234516897\n689723145\n493657218\n867231954\n152489763\n376148529\n928365471\n541972386\n`);\n\n\nconst cells: Arith[][] = [];\n// 9x9 matrix of integer variables\nfor (let i = 0; i < 9; i++) {\n const row = [];\n for (let j = 0; j < 9; j++) {\n row.push(Z3.Int.const(`x_${i}_${j}`));\n }\n cells.push(row);\n}\n\nconst solver = new Z3.Solver();\n\n// each cell contains a value 1<=x<=9\nfor (let i = 0; i < 9; i++) {\n for (let j = 0; j < 9; j++) {\n solver.add(cells[i][j].ge(1), cells[i][j].le(9));\n }\n}\n\n// each row contains a digit only once\nfor (let i = 0; i < 9; i++) {\n solver.add(Z3.Distinct(...cells[i]));\n}\n\n// each column contains a digit only once\nfor (let j = 0; j < 9; j++) {\n const column = [];\n for (let i = 0; i < 9; i++) {\n column.push(cells[i][j]);\n }\n solver.add(Z3.Distinct(...column));\n}\n\n// each 3x3 contains a digit at most once\nfor (let iSquare = 0; iSquare < 3; iSquare++) {\n for (let jSquare = 0; jSquare < 3; jSquare++) {\n const square = [];\n\n for (let i = iSquare * 3; i < iSquare * 3 + 3; i++) {\n for (let j = jSquare * 3; j < jSquare * 3 + 3; j++) {\n square.push(cells[i][j]);\n }\n }\n\n solver.add(Z3.Distinct(...square));\n }\n}\n\nfor (let i = 0; i < 9; i++) {\n for (let j = 0; j < 9; j++) {\n const digit = INSTANCE[i][j];\n if (digit !== null) {\n solver.add(cells[i][j].eq(digit));\n }\n }\n}\n\nawait solver.check(); // sat\n\nconst model = solver.model();\nmodel.sexpr();"} diff --git a/website/solutions/z3-js/4.10.1/5ecf8c91575f6ccd1d734229e481a083157c5691/output.json b/website/solutions/z3-js/4.10.1/5ecf8c91575f6ccd1d734229e481a083157c5691/output.json deleted file mode 100644 index 1b2f700f3..000000000 --- a/website/solutions/z3-js/4.10.1/5ecf8c91575f6ccd1d734229e481a083157c5691/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"","error":"Error: main.ts (43,14): Cannot find name 'Arith'.","status":"z3-failed","hash":"5ecf8c91575f6ccd1d734229e481a083157c5691"} diff --git a/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json b/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json deleted file mode 100644 index e8242b702..000000000 --- a/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// solves an equation\nconst x = Z3.BitVec.const('x', 32);\nconst y = Z3.BitVec.const('y', 32);\n\nconst solver = new Z3.Solver();\nconst conjecture = x.xor(y).sub(103).eq(x.mul(y));\nsolver.add(conjecture);\nawait solver.check(); // sat\n\nconst model = solver.model();\nconst xSol = model.get(x);\nconst ySol = model.get(y);\n\nZ3.isBitVecVal(xSol) && Z3.isBitVecVal(ySol); // true\n\n// TODO: fix the remaining lines\nconst xv = xSol.asSignedValue();\nconst yv = ySol.asSignedValue();\n\n// this solutions wraps around so we need to check using modulo\n(xv ^ yv) - 103n === (xv * yv) % 2n ** 32n; // true"} diff --git a/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/output.json b/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/output.json deleted file mode 100644 index bec0415e7..000000000 --- a/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"","error":"Error: main.ts (17,17): Property 'asSignedValue' does not exist on type 'Expr<\"main\", AnySort<\"main\">, unknown>'.\nmain.ts (18,17): Property 'asSignedValue' does not exist on type 'Expr<\"main\", AnySort<\"main\">, unknown>'.\nmain.ts (21,1): Operator '-' cannot be applied to types 'number' and 'bigint'.\nmain.ts (21,22): Operator '%' cannot be applied to types 'number' and 'bigint'.","status":"z3-failed","hash":"672ab86ec9acaee1bb65f6ac564af7990d37ade5"} diff --git a/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json b/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json deleted file mode 100644 index 17a56b4bc..000000000 --- a/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// numerals 2\nconst n4 = Z3.Real.val('-1/3');\nconst n5 = Z3.Real.val('-0.3333333333333333333333333333333333');\n\nconst conjecture = n4.neq(n5);\n\nconst solver = new Z3.Solver();\nsolver.add(Z3.Not(conjecture));\nawait solver.check();"} diff --git a/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json b/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json deleted file mode 100644 index 0080905d3..000000000 --- a/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"unsat","error":"","status":"z3-ran","hash":"6de42c85389d4407f0925ad8638fbd9b5b071cb4"} diff --git a/website/solutions/z3-js/4.10.1/6e9d92ab87857e9183644de010f7ef6bdef562b8/input.json b/website/solutions/z3-js/4.10.1/6e9d92ab87857e9183644de010f7ef6bdef562b8/input.json deleted file mode 100644 index db0225dd6..000000000 --- a/website/solutions/z3-js/4.10.1/6e9d92ab87857e9183644de010f7ef6bdef562b8/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// non-linear arithmetic\nZ3.setParam('pp.decimal', true);\nZ3.setParam('pp.decimal_precision', 20);\n\nconst x = Z3.Real.const('x');\nconst y = Z3.Real.const('y');\nconst z = Z3.Real.const('z');\n\nconst solver = new Z3.Solver();\nsolver.add(x.mul(x).add(y.mul(y)).eq(1)); // x^2 + y^2 == 1\nsolver.add(x.mul(x).mul(x).add(z.mul(z).mul(z)).lt('1/2')); // x^3 + z^3 < 1/2\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/6e9d92ab87857e9183644de010f7ef6bdef562b8/output.json b/website/solutions/z3-js/4.10.1/6e9d92ab87857e9183644de010f7ef6bdef562b8/output.json deleted file mode 100644 index eeee1164c..000000000 --- a/website/solutions/z3-js/4.10.1/6e9d92ab87857e9183644de010f7ef6bdef562b8/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"","error":"Error: main.ts (2,4): Property 'setParam' does not exist on type 'Context<\"main\">'.\nmain.ts (3,4): Property 'setParam' does not exist on type 'Context<\"main\">'.","status":"z3-failed","hash":"6e9d92ab87857e9183644de010f7ef6bdef562b8"} diff --git a/website/solutions/z3-js/4.10.1/788b265b0e86a5cdd0ddcb82a35577b92065289d/input.json b/website/solutions/z3-js/4.10.1/788b265b0e86a5cdd0ddcb82a35577b92065289d/input.json deleted file mode 100644 index 558aaea89..000000000 --- a/website/solutions/z3-js/4.10.1/788b265b0e86a5cdd0ddcb82a35577b92065289d/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// numerals 1\nconst n1 = Z3.Real.val('1/2');\nconst n2 = Z3.Real.val('0.5');\nconst n3 = Z3.Real.val(0.5);\n\nconst conjecture = Z3.And(n1.eq(n2), n1.eq(n3));\n\nconst solver = new Z3.solver();\nsolver.add(Z3.Not(conjecture));\nawait solver.check();"} diff --git a/website/solutions/z3-js/4.10.1/788b265b0e86a5cdd0ddcb82a35577b92065289d/output.json b/website/solutions/z3-js/4.10.1/788b265b0e86a5cdd0ddcb82a35577b92065289d/output.json deleted file mode 100644 index fbca016ad..000000000 --- a/website/solutions/z3-js/4.10.1/788b265b0e86a5cdd0ddcb82a35577b92065289d/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"","error":"Error: main.ts (8,23): Property 'solver' does not exist on type 'Context<\"main\">'. Did you mean 'Solver'?","status":"z3-failed","hash":"788b265b0e86a5cdd0ddcb82a35577b92065289d"} diff --git a/website/solutions/z3-js/4.10.1/999bf5fd0b7cce57b4b5ae6371fd8e4d2e59a44b/input.json b/website/solutions/z3-js/4.10.1/999bf5fd0b7cce57b4b5ae6371fd8e4d2e59a44b/input.json deleted file mode 100644 index 7d44654cb..000000000 --- a/website/solutions/z3-js/4.10.1/999bf5fd0b7cce57b4b5ae6371fd8e4d2e59a44b/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":""} diff --git a/website/solutions/z3-js/4.10.1/999bf5fd0b7cce57b4b5ae6371fd8e4d2e59a44b/output.json b/website/solutions/z3-js/4.10.1/999bf5fd0b7cce57b4b5ae6371fd8e4d2e59a44b/output.json deleted file mode 100644 index 0ff9c9f6d..000000000 --- a/website/solutions/z3-js/4.10.1/999bf5fd0b7cce57b4b5ae6371fd8e4d2e59a44b/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"undefined","error":"","status":"z3-ran","hash":"999bf5fd0b7cce57b4b5ae6371fd8e4d2e59a44b"} diff --git a/website/solutions/z3-js/4.10.1/9ae9ad60161b8106f420343ef151717ec00ed71d/input.json b/website/solutions/z3-js/4.10.1/9ae9ad60161b8106f420343ef151717ec00ed71d/input.json deleted file mode 100644 index 550764d7f..000000000 --- a/website/solutions/z3-js/4.10.1/9ae9ad60161b8106f420343ef151717ec00ed71d/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// proves De Morgan's Law\nasync function prove(conjecture: Z3.Bool): Promise {\n const solver = new conjecture.ctx.Solver();\n const { Not } = solver.ctx;\n solver.add(Not(conjecture));\n await solver.check();\n}\n\nconst [x, y] = [Z3.Bool.const('x'), Z3.Bool.const('y')];\nconst conjecture = Z3.Eq(Z3.Not(Z3.And(x, y)), Z3.Or(Z3.Not(x), Z3.Not(y)));\nawait prove(conjecture); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/9ae9ad60161b8106f420343ef151717ec00ed71d/output.json b/website/solutions/z3-js/4.10.1/9ae9ad60161b8106f420343ef151717ec00ed71d/output.json deleted file mode 100644 index db5ac2c45..000000000 --- a/website/solutions/z3-js/4.10.1/9ae9ad60161b8106f420343ef151717ec00ed71d/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"","error":"Error: main.ts (2,34): Cannot find namespace 'Z3'.","status":"z3-failed","hash":"9ae9ad60161b8106f420343ef151717ec00ed71d"} diff --git a/website/solutions/z3-js/4.10.1/a20a9ec1d64add1d969fa507522cebf35fd152fb/input.json b/website/solutions/z3-js/4.10.1/a20a9ec1d64add1d969fa507522cebf35fd152fb/input.json deleted file mode 100644 index 40747db2b..000000000 --- a/website/solutions/z3-js/4.10.1/a20a9ec1d64add1d969fa507522cebf35fd152fb/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"const { Solver, Int, Function, Implies, Not } = api.Context('main');\nconst solver = new Solver();\n\nconst sort = Int.sort();\nconst x = Int.const('x');\nconst y = Int.const('y');\nconst g = Function.declare('g', sort, sort);\n\nconst conjecture = Implies(x.eq(y), g.call(x).eq(g.call(y)));\nsolver.add(Not(conjecture));\nawait solver.check(); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/a20a9ec1d64add1d969fa507522cebf35fd152fb/output.json b/website/solutions/z3-js/4.10.1/a20a9ec1d64add1d969fa507522cebf35fd152fb/output.json deleted file mode 100644 index e8755d2d7..000000000 --- a/website/solutions/z3-js/4.10.1/a20a9ec1d64add1d969fa507522cebf35fd152fb/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"","error":"Error: main.ts (1,49): Cannot find name 'api'.","status":"z3-failed","hash":"a20a9ec1d64add1d969fa507522cebf35fd152fb"} diff --git a/website/solutions/z3-js/4.10.1/b212b4a0cd87c65163c963e0c2c600db02567663/input.json b/website/solutions/z3-js/4.10.1/b212b4a0cd87c65163c963e0c2c600db02567663/input.json deleted file mode 100644 index a026451dd..000000000 --- a/website/solutions/z3-js/4.10.1/b212b4a0cd87c65163c963e0c2c600db02567663/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"const solver = new Z3.Solver();\nconst sort = Z3.Int.sort();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\nconst g = Z3.Function.declare('g', sort, sort);\nconst conjecture = Z3.Implies(x.eq(y), g.call(g.call(x)).eq(g.call(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check()); //sat"} diff --git a/website/solutions/z3-js/4.10.1/b212b4a0cd87c65163c963e0c2c600db02567663/output.json b/website/solutions/z3-js/4.10.1/b212b4a0cd87c65163c963e0c2c600db02567663/output.json deleted file mode 100644 index 80cadae50..000000000 --- a/website/solutions/z3-js/4.10.1/b212b4a0cd87c65163c963e0c2c600db02567663/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"","error":"Error: main.ts (8,21): ';' expected.","status":"z3-failed","hash":"b212b4a0cd87c65163c963e0c2c600db02567663"} diff --git a/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json b/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json deleted file mode 100644 index 4abe05b0d..000000000 --- a/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// disproves that x = y implies g(g(x)) = g(y)\n\nconst solver = new Z3.Solver();\nconst sort = Z3.Int.sort();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\nconst g = Z3.Function.declare('g', sort, sort);\nconst conjecture = Z3.Implies(x.eq(y), g.call(g.call(x)).eq(g.call(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check(); //sat"} diff --git a/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json b/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json deleted file mode 100644 index 1c5a5ffb3..000000000 --- a/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"sat","error":"","status":"z3-ran","hash":"c55e03a7cc02e5abf176f20763b498f989027b91"} diff --git a/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json b/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json deleted file mode 100644 index 5381d600f..000000000 --- a/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// non-linear arithmetic\n\nZ3.setParam('pp.decimal', true);\nZ3.setParam('pp.decimal_precision', 20);\n\nconst x = Z3.Real.const('x');\nconst y = Z3.Real.const('y');\nconst z = Z3.Real.const('z');\n\nconst solver = new Z3.Solver();\nsolver.add(x.mul(x).add(y.mul(y)).eq(1)); // x^2 + y^2 == 1\nsolver.add(x.mul(x).mul(x).add(z.mul(z).mul(z)).lt('1/2')); // x^3 + z^3 < 1/2\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/output.json b/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/output.json deleted file mode 100644 index e16193a6d..000000000 --- a/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"","error":"Error: main.ts (3,4): Property 'setParam' does not exist on type 'Context<\"main\">'.\nmain.ts (4,4): Property 'setParam' does not exist on type 'Context<\"main\">'.","status":"z3-failed","hash":"c777e5f62b2783f71dff077e516d20445f5331f3"} diff --git a/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/input.json b/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/input.json deleted file mode 100644 index 976fcfb60..000000000 --- a/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// AstVector\nconst solver = new Z3.Solver();\n\n// @ts-ignore: skipping typechecking for the following line for now, is there a better solution?\nconst vector = new Z3.AstVector();\nfor (let i = 0; i < 5; i++) {\n vector.push(Z3.Int.const(`int__${i}`));\n}\n\nconst length = vector.length();\nfor (let i = 0; i < length; i++) {\n solver.add(vector.get(i).gt(1));\n}\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/output.json b/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/output.json deleted file mode 100644 index 1976a3a28..000000000 --- a/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"sat","error":"","status":"z3-ran","hash":"c89957f5908b877b8ca28d23edd51ae55dc0f6bb"} diff --git a/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json b/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json deleted file mode 100644 index 4076aabbd..000000000 --- a/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// solves sudoku\nfunction toSudoku(data: string): (number | null)[][] {\n const cells: (number | null)[][] = Array.from({ length: 9 }, () => Array.from({ length: 9 }, () => null));\n\n const lines = data.trim().split('\\n');\n for (let row = 0; row < 9; row++) {\n const line = lines[row].trim();\n for (let col = 0; col < 9; col++) {\n const char = line[col];\n if (char !== '.') {\n cells[row][col] = Number.parseInt(char);\n }\n }\n }\n return cells;\n}\n\nconst INSTANCE = toSudoku(`\n....94.3.\n...51...7\n.89....4.\n......2.8\n.6.2.1.5.\n1.2......\n.7....52.\n9...65...\n.4.97....\n`);\n\nconst EXPECTED = toSudoku(`\n715894632\n234516897\n689723145\n493657218\n867231954\n152489763\n376148529\n928365471\n541972386\n`);\n\n\nconst cells = [];\n// 9x9 matrix of integer variables\nfor (let i = 0; i < 9; i++) {\n const row = [];\n for (let j = 0; j < 9; j++) {\n row.push(Z3.Int.const(`x_${i}_${j}`));\n }\n cells.push(row);\n}\n\nconst solver = new Z3.Solver();\n\n// each cell contains a value 1<=x<=9\nfor (let i = 0; i < 9; i++) {\n for (let j = 0; j < 9; j++) {\n solver.add(cells[i][j].ge(1), cells[i][j].le(9));\n }\n}\n\n// each row contains a digit only once\nfor (let i = 0; i < 9; i++) {\n solver.add(Z3.Distinct(...cells[i]));\n}\n\n// each column contains a digit only once\nfor (let j = 0; j < 9; j++) {\n const column = [];\n for (let i = 0; i < 9; i++) {\n column.push(cells[i][j]);\n }\n solver.add(Z3.Distinct(...column));\n}\n\n// each 3x3 contains a digit at most once\nfor (let iSquare = 0; iSquare < 3; iSquare++) {\n for (let jSquare = 0; jSquare < 3; jSquare++) {\n const square = [];\n\n for (let i = iSquare * 3; i < iSquare * 3 + 3; i++) {\n for (let j = jSquare * 3; j < jSquare * 3 + 3; j++) {\n square.push(cells[i][j]);\n }\n }\n\n solver.add(Z3.Distinct(...square));\n }\n}\n\nfor (let i = 0; i < 9; i++) {\n for (let j = 0; j < 9; j++) {\n const digit = INSTANCE[i][j];\n if (digit !== null) {\n solver.add(cells[i][j].eq(digit));\n }\n }\n}\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json b/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json deleted file mode 100644 index 49f9dcd44..000000000 --- a/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"sat","error":"","status":"z3-ran","hash":"d274fcbbef696d7b8023d37cf910015ab7ce9c12"} diff --git a/website/solutions/z3-js/4.10.1/d4f060a97872ec1a74dca9e62eb920e920270d58/input.json b/website/solutions/z3-js/4.10.1/d4f060a97872ec1a74dca9e62eb920e920270d58/input.json deleted file mode 100644 index 70469b092..000000000 --- a/website/solutions/z3-js/4.10.1/d4f060a97872ec1a74dca9e62eb920e920270d58/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// proves De Morgan's Law\n// @ts-ignore: TODO: how do we type check function arguments?\nasync function prove(conjecture: Z3.Bool): Promise {\n const solver = new conjecture.ctx.Solver();\n const { Not } = solver.ctx;\n solver.add(Not(conjecture));\n await solver.check();\n}\n\nconst [x, y] = [Z3.Bool.const('x'), Z3.Bool.const('y')];\nconst conjecture = Z3.Eq(Z3.Not(Z3.And(x, y)), Z3.Or(Z3.Not(x), Z3.Not(y)));\nawait prove(conjecture); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/d4f060a97872ec1a74dca9e62eb920e920270d58/output.json b/website/solutions/z3-js/4.10.1/d4f060a97872ec1a74dca9e62eb920e920270d58/output.json deleted file mode 100644 index 03bd88a34..000000000 --- a/website/solutions/z3-js/4.10.1/d4f060a97872ec1a74dca9e62eb920e920270d58/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"undefined","error":"","status":"z3-ran","hash":"d4f060a97872ec1a74dca9e62eb920e920270d58"} diff --git a/website/solutions/z3-js/4.10.1/e3e11a5ab2dbe41c0b86925b87de881d5160974d/input.json b/website/solutions/z3-js/4.10.1/e3e11a5ab2dbe41c0b86925b87de881d5160974d/input.json deleted file mode 100644 index 313d819fd..000000000 --- a/website/solutions/z3-js/4.10.1/e3e11a5ab2dbe41c0b86925b87de881d5160974d/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// proves De Morgan's Law\nasync function prove(conjecture): Promise {\n const solver = new conjecture.ctx.Solver();\n const { Not } = solver.ctx;\n solver.add(Not(conjecture));\n await solver.check();\n}\n\nconst [x, y] = [Z3.Bool.const('x'), Z3.Bool.const('y')];\nconst conjecture = Z3.Eq(Z3.Not(Z3.And(x, y)), Z3.Or(Z3.Not(x), Z3.Not(y)));\nawait prove(conjecture); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/e3e11a5ab2dbe41c0b86925b87de881d5160974d/output.json b/website/solutions/z3-js/4.10.1/e3e11a5ab2dbe41c0b86925b87de881d5160974d/output.json deleted file mode 100644 index 22aced0bb..000000000 --- a/website/solutions/z3-js/4.10.1/e3e11a5ab2dbe41c0b86925b87de881d5160974d/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"","error":"Error: main.ts (2,22): Parameter 'conjecture' implicitly has an 'any' type.","status":"z3-failed","hash":"e3e11a5ab2dbe41c0b86925b87de881d5160974d"} diff --git a/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json b/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json deleted file mode 100644 index 61b54e9ad..000000000 --- a/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// proves De Morgan's Law\nconst solver = new Z3.Solver();\nconst [x, y] = [Z3.Bool.const('x'), Z3.Bool.const('y')];\nconst conjecture = Z3.Eq(Z3.Not(Z3.And(x, y)), Z3.Or(Z3.Not(x), Z3.Not(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check(); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json b/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json deleted file mode 100644 index b3bd6b587..000000000 --- a/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"unsat","error":"","status":"z3-ran","hash":"e54e8215ee8788a22b2dcfca2420107f804c4de2"} diff --git a/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json b/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json deleted file mode 100644 index 7d9c2a291..000000000 --- a/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// bitvectors: simple proofs\nconst x = Z3.BitVec.const('x', 32);\n\nconst sConj = x.sub(10).sle(0).eq(x.sle(10));\nconst sSolver = new Z3.Solver();\nsSolver.add(sConj);\nawait sSolver.check(); // sat\n\nconst sModel = sSolver.model();\nsModel.get(x) // signed\n\nconst uConj = x.sub(10).ule(0).eq(x.ule(10));\nconst uSolver = new Z3.Solver();\nuSolver.add(uConj);\nawait uSolver.check(); // sat\n\nconst uModel = uSolver.model();\nuModel.get(x) // unsigned"} diff --git a/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json b/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json deleted file mode 100644 index 758681685..000000000 --- a/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"#x0000000a","error":"","status":"z3-ran","hash":"f3e627e0f970fbc7fa1f6650366db67e71053bbd"} diff --git a/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json b/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json deleted file mode 100644 index 4942ccb53..000000000 --- a/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// finds a model\nconst solver = new Z3.Solver();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\n\nsolver.add(x.ge(1)); // x >= 1\nsolver.add(y.lt(x.add(3))); // y < x + 3\n\nawait solver.check(); // sat\n\nconst model = solver.model();\nawait model.sexpr();"} diff --git a/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json b/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json deleted file mode 100644 index 78f01e626..000000000 --- a/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"(define-fun y () Int\n 3)\n(define-fun x () Int\n 1)","error":"","status":"z3-ran","hash":"f9dd66b1e430f36b7e955869f1646e0370ce0641"} From 8f4ab57546a0102d75db2a5bf410ddb23a5e5f0b Mon Sep 17 00:00:00 2001 From: rlisahuang Date: Wed, 27 Jul 2022 23:52:23 +0000 Subject: [PATCH 09/18] Apply automatic changes --- .../4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json | 1 + .../4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json | 1 + .../4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json | 1 + .../4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json | 1 + .../4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json | 1 + .../4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/output.json | 1 + .../4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json | 1 + .../4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json | 1 + .../4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json | 1 + .../4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json | 1 + .../4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json | 1 + .../4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/output.json | 1 + .../4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/input.json | 1 + .../4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/output.json | 1 + .../4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json | 1 + .../4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json | 1 + .../4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json | 1 + .../4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json | 1 + .../4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json | 1 + .../4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json | 1 + .../4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json | 1 + .../4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json | 1 + 22 files changed, 22 insertions(+) create mode 100644 website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json create mode 100644 website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json create mode 100644 website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json create mode 100644 website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json create mode 100644 website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json create mode 100644 website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/output.json create mode 100644 website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json create mode 100644 website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json create mode 100644 website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json create mode 100644 website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json create mode 100644 website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json create mode 100644 website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/output.json create mode 100644 website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/input.json create mode 100644 website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/output.json create mode 100644 website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json create mode 100644 website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json create mode 100644 website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json create mode 100644 website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json create mode 100644 website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json create mode 100644 website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json create mode 100644 website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json create mode 100644 website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json diff --git a/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json b/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json new file mode 100644 index 000000000..1c80b9958 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json @@ -0,0 +1 @@ +{"input":"// proves x = y implies g(x) = g(y)\n\nconst solver = new Z3.Solver();\nconst sort = Z3.Int.sort();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\nconst g = Z3.Function.declare('g', sort, sort);\n\nconst conjecture = Z3.Implies(x.eq(y), g.call(x).eq(g.call(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check(); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json b/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json new file mode 100644 index 000000000..7b8842b14 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json @@ -0,0 +1 @@ +{"output":"unsat","error":"","status":"z3-ran","hash":"16a515db3b88471d8f266b464b2344b2a30d00b7"} diff --git a/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json b/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json new file mode 100644 index 000000000..099177988 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json @@ -0,0 +1 @@ +{"input":"// numerals 1\nconst n1 = Z3.Real.val('1/2');\nconst n2 = Z3.Real.val('0.5');\nconst n3 = Z3.Real.val(0.5);\n\nconst conjecture = Z3.And(n1.eq(n2), n1.eq(n3));\n\nconst solver = new Z3.Solver();\nsolver.add(Z3.Not(conjecture));\nawait solver.check();"} diff --git a/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json b/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json new file mode 100644 index 000000000..0414391c4 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json @@ -0,0 +1 @@ +{"output":"unsat","error":"","status":"z3-ran","hash":"18db6515b197b55df72654ada88a28ab104776e0"} diff --git a/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json b/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json new file mode 100644 index 000000000..e8242b702 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json @@ -0,0 +1 @@ +{"input":"// solves an equation\nconst x = Z3.BitVec.const('x', 32);\nconst y = Z3.BitVec.const('y', 32);\n\nconst solver = new Z3.Solver();\nconst conjecture = x.xor(y).sub(103).eq(x.mul(y));\nsolver.add(conjecture);\nawait solver.check(); // sat\n\nconst model = solver.model();\nconst xSol = model.get(x);\nconst ySol = model.get(y);\n\nZ3.isBitVecVal(xSol) && Z3.isBitVecVal(ySol); // true\n\n// TODO: fix the remaining lines\nconst xv = xSol.asSignedValue();\nconst yv = ySol.asSignedValue();\n\n// this solutions wraps around so we need to check using modulo\n(xv ^ yv) - 103n === (xv * yv) % 2n ** 32n; // true"} diff --git a/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/output.json b/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/output.json new file mode 100644 index 000000000..bec0415e7 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/output.json @@ -0,0 +1 @@ +{"output":"","error":"Error: main.ts (17,17): Property 'asSignedValue' does not exist on type 'Expr<\"main\", AnySort<\"main\">, unknown>'.\nmain.ts (18,17): Property 'asSignedValue' does not exist on type 'Expr<\"main\", AnySort<\"main\">, unknown>'.\nmain.ts (21,1): Operator '-' cannot be applied to types 'number' and 'bigint'.\nmain.ts (21,22): Operator '%' cannot be applied to types 'number' and 'bigint'.","status":"z3-failed","hash":"672ab86ec9acaee1bb65f6ac564af7990d37ade5"} diff --git a/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json b/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json new file mode 100644 index 000000000..17a56b4bc --- /dev/null +++ b/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json @@ -0,0 +1 @@ +{"input":"// numerals 2\nconst n4 = Z3.Real.val('-1/3');\nconst n5 = Z3.Real.val('-0.3333333333333333333333333333333333');\n\nconst conjecture = n4.neq(n5);\n\nconst solver = new Z3.Solver();\nsolver.add(Z3.Not(conjecture));\nawait solver.check();"} diff --git a/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json b/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json new file mode 100644 index 000000000..0080905d3 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json @@ -0,0 +1 @@ +{"output":"unsat","error":"","status":"z3-ran","hash":"6de42c85389d4407f0925ad8638fbd9b5b071cb4"} diff --git a/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json b/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json new file mode 100644 index 000000000..4abe05b0d --- /dev/null +++ b/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json @@ -0,0 +1 @@ +{"input":"// disproves that x = y implies g(g(x)) = g(y)\n\nconst solver = new Z3.Solver();\nconst sort = Z3.Int.sort();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\nconst g = Z3.Function.declare('g', sort, sort);\nconst conjecture = Z3.Implies(x.eq(y), g.call(g.call(x)).eq(g.call(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check(); //sat"} diff --git a/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json b/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json new file mode 100644 index 000000000..1c5a5ffb3 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json @@ -0,0 +1 @@ +{"output":"sat","error":"","status":"z3-ran","hash":"c55e03a7cc02e5abf176f20763b498f989027b91"} diff --git a/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json b/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json new file mode 100644 index 000000000..5381d600f --- /dev/null +++ b/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json @@ -0,0 +1 @@ +{"input":"// non-linear arithmetic\n\nZ3.setParam('pp.decimal', true);\nZ3.setParam('pp.decimal_precision', 20);\n\nconst x = Z3.Real.const('x');\nconst y = Z3.Real.const('y');\nconst z = Z3.Real.const('z');\n\nconst solver = new Z3.Solver();\nsolver.add(x.mul(x).add(y.mul(y)).eq(1)); // x^2 + y^2 == 1\nsolver.add(x.mul(x).mul(x).add(z.mul(z).mul(z)).lt('1/2')); // x^3 + z^3 < 1/2\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/output.json b/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/output.json new file mode 100644 index 000000000..e16193a6d --- /dev/null +++ b/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/output.json @@ -0,0 +1 @@ +{"output":"","error":"Error: main.ts (3,4): Property 'setParam' does not exist on type 'Context<\"main\">'.\nmain.ts (4,4): Property 'setParam' does not exist on type 'Context<\"main\">'.","status":"z3-failed","hash":"c777e5f62b2783f71dff077e516d20445f5331f3"} diff --git a/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/input.json b/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/input.json new file mode 100644 index 000000000..976fcfb60 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/input.json @@ -0,0 +1 @@ +{"input":"// AstVector\nconst solver = new Z3.Solver();\n\n// @ts-ignore: skipping typechecking for the following line for now, is there a better solution?\nconst vector = new Z3.AstVector();\nfor (let i = 0; i < 5; i++) {\n vector.push(Z3.Int.const(`int__${i}`));\n}\n\nconst length = vector.length();\nfor (let i = 0; i < length; i++) {\n solver.add(vector.get(i).gt(1));\n}\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/output.json b/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/output.json new file mode 100644 index 000000000..1976a3a28 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/output.json @@ -0,0 +1 @@ +{"output":"sat","error":"","status":"z3-ran","hash":"c89957f5908b877b8ca28d23edd51ae55dc0f6bb"} diff --git a/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json b/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json new file mode 100644 index 000000000..4076aabbd --- /dev/null +++ b/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json @@ -0,0 +1 @@ +{"input":"// solves sudoku\nfunction toSudoku(data: string): (number | null)[][] {\n const cells: (number | null)[][] = Array.from({ length: 9 }, () => Array.from({ length: 9 }, () => null));\n\n const lines = data.trim().split('\\n');\n for (let row = 0; row < 9; row++) {\n const line = lines[row].trim();\n for (let col = 0; col < 9; col++) {\n const char = line[col];\n if (char !== '.') {\n cells[row][col] = Number.parseInt(char);\n }\n }\n }\n return cells;\n}\n\nconst INSTANCE = toSudoku(`\n....94.3.\n...51...7\n.89....4.\n......2.8\n.6.2.1.5.\n1.2......\n.7....52.\n9...65...\n.4.97....\n`);\n\nconst EXPECTED = toSudoku(`\n715894632\n234516897\n689723145\n493657218\n867231954\n152489763\n376148529\n928365471\n541972386\n`);\n\n\nconst cells = [];\n// 9x9 matrix of integer variables\nfor (let i = 0; i < 9; i++) {\n const row = [];\n for (let j = 0; j < 9; j++) {\n row.push(Z3.Int.const(`x_${i}_${j}`));\n }\n cells.push(row);\n}\n\nconst solver = new Z3.Solver();\n\n// each cell contains a value 1<=x<=9\nfor (let i = 0; i < 9; i++) {\n for (let j = 0; j < 9; j++) {\n solver.add(cells[i][j].ge(1), cells[i][j].le(9));\n }\n}\n\n// each row contains a digit only once\nfor (let i = 0; i < 9; i++) {\n solver.add(Z3.Distinct(...cells[i]));\n}\n\n// each column contains a digit only once\nfor (let j = 0; j < 9; j++) {\n const column = [];\n for (let i = 0; i < 9; i++) {\n column.push(cells[i][j]);\n }\n solver.add(Z3.Distinct(...column));\n}\n\n// each 3x3 contains a digit at most once\nfor (let iSquare = 0; iSquare < 3; iSquare++) {\n for (let jSquare = 0; jSquare < 3; jSquare++) {\n const square = [];\n\n for (let i = iSquare * 3; i < iSquare * 3 + 3; i++) {\n for (let j = jSquare * 3; j < jSquare * 3 + 3; j++) {\n square.push(cells[i][j]);\n }\n }\n\n solver.add(Z3.Distinct(...square));\n }\n}\n\nfor (let i = 0; i < 9; i++) {\n for (let j = 0; j < 9; j++) {\n const digit = INSTANCE[i][j];\n if (digit !== null) {\n solver.add(cells[i][j].eq(digit));\n }\n }\n}\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json b/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json new file mode 100644 index 000000000..49f9dcd44 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json @@ -0,0 +1 @@ +{"output":"sat","error":"","status":"z3-ran","hash":"d274fcbbef696d7b8023d37cf910015ab7ce9c12"} diff --git a/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json b/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json new file mode 100644 index 000000000..61b54e9ad --- /dev/null +++ b/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json @@ -0,0 +1 @@ +{"input":"// proves De Morgan's Law\nconst solver = new Z3.Solver();\nconst [x, y] = [Z3.Bool.const('x'), Z3.Bool.const('y')];\nconst conjecture = Z3.Eq(Z3.Not(Z3.And(x, y)), Z3.Or(Z3.Not(x), Z3.Not(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check(); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json b/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json new file mode 100644 index 000000000..b3bd6b587 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json @@ -0,0 +1 @@ +{"output":"unsat","error":"","status":"z3-ran","hash":"e54e8215ee8788a22b2dcfca2420107f804c4de2"} diff --git a/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json b/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json new file mode 100644 index 000000000..7d9c2a291 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json @@ -0,0 +1 @@ +{"input":"// bitvectors: simple proofs\nconst x = Z3.BitVec.const('x', 32);\n\nconst sConj = x.sub(10).sle(0).eq(x.sle(10));\nconst sSolver = new Z3.Solver();\nsSolver.add(sConj);\nawait sSolver.check(); // sat\n\nconst sModel = sSolver.model();\nsModel.get(x) // signed\n\nconst uConj = x.sub(10).ule(0).eq(x.ule(10));\nconst uSolver = new Z3.Solver();\nuSolver.add(uConj);\nawait uSolver.check(); // sat\n\nconst uModel = uSolver.model();\nuModel.get(x) // unsigned"} diff --git a/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json b/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json new file mode 100644 index 000000000..758681685 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json @@ -0,0 +1 @@ +{"output":"#x0000000a","error":"","status":"z3-ran","hash":"f3e627e0f970fbc7fa1f6650366db67e71053bbd"} diff --git a/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json b/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json new file mode 100644 index 000000000..4942ccb53 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json @@ -0,0 +1 @@ +{"input":"// finds a model\nconst solver = new Z3.Solver();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\n\nsolver.add(x.ge(1)); // x >= 1\nsolver.add(y.lt(x.add(3))); // y < x + 3\n\nawait solver.check(); // sat\n\nconst model = solver.model();\nawait model.sexpr();"} diff --git a/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json b/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json new file mode 100644 index 000000000..78f01e626 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json @@ -0,0 +1 @@ +{"output":"(define-fun y () Int\n 3)\n(define-fun x () Int\n 1)","error":"","status":"z3-ran","hash":"f9dd66b1e430f36b7e955869f1646e0370ce0641"} From b8ad91b2d0900a48e256179f86bf3182241273d4 Mon Sep 17 00:00:00 2001 From: "Ruanqianqian (Lisa) Huang" Date: Wed, 27 Jul 2022 17:01:15 -0700 Subject: [PATCH 10/18] fail the build for snippets without no-build or ignore-error --- website/src/remark/render-code-blocks.mjs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/website/src/remark/render-code-blocks.mjs b/website/src/remark/render-code-blocks.mjs index 84039a0a0..730e12f80 100644 --- a/website/src/remark/render-code-blocks.mjs +++ b/website/src/remark/render-code-blocks.mjs @@ -72,7 +72,7 @@ async function getOutput(config, input, lang, skipErr) { const errRegex = new RegExp(/(\(error)|(unsupported)|([eE]rror:)/g); const data = readJsonSync(pathOut, { throws: false }); // don't throw an error if file not exist if (data !== null) { - // console.log(`cache hit ${hash}`) + console.log(`cache hit ${hash}`) const errorToReport = checkRuntimeError(lang, langVersion, input, data.output, hash, errRegex, skipErr); // if this call fails an error will be thrown if (errorToReport !== "") { // we had erroneous code with ignore-error / no-build meta data.error = errorToReport; @@ -103,6 +103,11 @@ async function getOutput(config, input, lang, skipErr) { status = statusCodes.timeout; } + if (status === statusCodes.runError) { + throw new Error(`${lang} runtime error: ${hash}, ${status}, ${input}, ${error}`); + } + + console.log(`${lang} finished: ${hash}, ${status}, ${output}, ${error}`); From 9b7fddbb23b3ac6b507c116b2fcfa9c2e8ce4d33 Mon Sep 17 00:00:00 2001 From: "Ruanqianqian (Lisa) Huang" Date: Wed, 27 Jul 2022 17:02:20 -0700 Subject: [PATCH 11/18] fail the build for snippets without flags --- .../4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json | 1 - .../4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json | 1 - .../4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json | 1 - .../4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json | 1 - .../4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json | 1 - .../4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/output.json | 1 - .../4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json | 1 - .../4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json | 1 - .../4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json | 1 - .../4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json | 1 - .../4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json | 1 - .../4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/output.json | 1 - .../4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/input.json | 1 - .../4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/output.json | 1 - .../4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json | 1 - .../4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json | 1 - .../4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json | 1 - .../4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json | 1 - .../4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json | 1 - .../4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json | 1 - .../4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json | 1 - .../4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json | 1 - 22 files changed, 22 deletions(-) delete mode 100644 website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json delete mode 100644 website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json delete mode 100644 website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json delete mode 100644 website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json delete mode 100644 website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json delete mode 100644 website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/output.json delete mode 100644 website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json delete mode 100644 website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json delete mode 100644 website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json delete mode 100644 website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json delete mode 100644 website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json delete mode 100644 website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/output.json delete mode 100644 website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/input.json delete mode 100644 website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/output.json delete mode 100644 website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json delete mode 100644 website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json delete mode 100644 website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json delete mode 100644 website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json delete mode 100644 website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json delete mode 100644 website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json delete mode 100644 website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json delete mode 100644 website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json diff --git a/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json b/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json deleted file mode 100644 index 1c80b9958..000000000 --- a/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// proves x = y implies g(x) = g(y)\n\nconst solver = new Z3.Solver();\nconst sort = Z3.Int.sort();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\nconst g = Z3.Function.declare('g', sort, sort);\n\nconst conjecture = Z3.Implies(x.eq(y), g.call(x).eq(g.call(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check(); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json b/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json deleted file mode 100644 index 7b8842b14..000000000 --- a/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"unsat","error":"","status":"z3-ran","hash":"16a515db3b88471d8f266b464b2344b2a30d00b7"} diff --git a/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json b/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json deleted file mode 100644 index 099177988..000000000 --- a/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// numerals 1\nconst n1 = Z3.Real.val('1/2');\nconst n2 = Z3.Real.val('0.5');\nconst n3 = Z3.Real.val(0.5);\n\nconst conjecture = Z3.And(n1.eq(n2), n1.eq(n3));\n\nconst solver = new Z3.Solver();\nsolver.add(Z3.Not(conjecture));\nawait solver.check();"} diff --git a/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json b/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json deleted file mode 100644 index 0414391c4..000000000 --- a/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"unsat","error":"","status":"z3-ran","hash":"18db6515b197b55df72654ada88a28ab104776e0"} diff --git a/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json b/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json deleted file mode 100644 index e8242b702..000000000 --- a/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// solves an equation\nconst x = Z3.BitVec.const('x', 32);\nconst y = Z3.BitVec.const('y', 32);\n\nconst solver = new Z3.Solver();\nconst conjecture = x.xor(y).sub(103).eq(x.mul(y));\nsolver.add(conjecture);\nawait solver.check(); // sat\n\nconst model = solver.model();\nconst xSol = model.get(x);\nconst ySol = model.get(y);\n\nZ3.isBitVecVal(xSol) && Z3.isBitVecVal(ySol); // true\n\n// TODO: fix the remaining lines\nconst xv = xSol.asSignedValue();\nconst yv = ySol.asSignedValue();\n\n// this solutions wraps around so we need to check using modulo\n(xv ^ yv) - 103n === (xv * yv) % 2n ** 32n; // true"} diff --git a/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/output.json b/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/output.json deleted file mode 100644 index bec0415e7..000000000 --- a/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"","error":"Error: main.ts (17,17): Property 'asSignedValue' does not exist on type 'Expr<\"main\", AnySort<\"main\">, unknown>'.\nmain.ts (18,17): Property 'asSignedValue' does not exist on type 'Expr<\"main\", AnySort<\"main\">, unknown>'.\nmain.ts (21,1): Operator '-' cannot be applied to types 'number' and 'bigint'.\nmain.ts (21,22): Operator '%' cannot be applied to types 'number' and 'bigint'.","status":"z3-failed","hash":"672ab86ec9acaee1bb65f6ac564af7990d37ade5"} diff --git a/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json b/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json deleted file mode 100644 index 17a56b4bc..000000000 --- a/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// numerals 2\nconst n4 = Z3.Real.val('-1/3');\nconst n5 = Z3.Real.val('-0.3333333333333333333333333333333333');\n\nconst conjecture = n4.neq(n5);\n\nconst solver = new Z3.Solver();\nsolver.add(Z3.Not(conjecture));\nawait solver.check();"} diff --git a/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json b/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json deleted file mode 100644 index 0080905d3..000000000 --- a/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"unsat","error":"","status":"z3-ran","hash":"6de42c85389d4407f0925ad8638fbd9b5b071cb4"} diff --git a/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json b/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json deleted file mode 100644 index 4abe05b0d..000000000 --- a/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// disproves that x = y implies g(g(x)) = g(y)\n\nconst solver = new Z3.Solver();\nconst sort = Z3.Int.sort();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\nconst g = Z3.Function.declare('g', sort, sort);\nconst conjecture = Z3.Implies(x.eq(y), g.call(g.call(x)).eq(g.call(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check(); //sat"} diff --git a/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json b/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json deleted file mode 100644 index 1c5a5ffb3..000000000 --- a/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"sat","error":"","status":"z3-ran","hash":"c55e03a7cc02e5abf176f20763b498f989027b91"} diff --git a/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json b/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json deleted file mode 100644 index 5381d600f..000000000 --- a/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// non-linear arithmetic\n\nZ3.setParam('pp.decimal', true);\nZ3.setParam('pp.decimal_precision', 20);\n\nconst x = Z3.Real.const('x');\nconst y = Z3.Real.const('y');\nconst z = Z3.Real.const('z');\n\nconst solver = new Z3.Solver();\nsolver.add(x.mul(x).add(y.mul(y)).eq(1)); // x^2 + y^2 == 1\nsolver.add(x.mul(x).mul(x).add(z.mul(z).mul(z)).lt('1/2')); // x^3 + z^3 < 1/2\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/output.json b/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/output.json deleted file mode 100644 index e16193a6d..000000000 --- a/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"","error":"Error: main.ts (3,4): Property 'setParam' does not exist on type 'Context<\"main\">'.\nmain.ts (4,4): Property 'setParam' does not exist on type 'Context<\"main\">'.","status":"z3-failed","hash":"c777e5f62b2783f71dff077e516d20445f5331f3"} diff --git a/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/input.json b/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/input.json deleted file mode 100644 index 976fcfb60..000000000 --- a/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// AstVector\nconst solver = new Z3.Solver();\n\n// @ts-ignore: skipping typechecking for the following line for now, is there a better solution?\nconst vector = new Z3.AstVector();\nfor (let i = 0; i < 5; i++) {\n vector.push(Z3.Int.const(`int__${i}`));\n}\n\nconst length = vector.length();\nfor (let i = 0; i < length; i++) {\n solver.add(vector.get(i).gt(1));\n}\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/output.json b/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/output.json deleted file mode 100644 index 1976a3a28..000000000 --- a/website/solutions/z3-js/4.10.1/c89957f5908b877b8ca28d23edd51ae55dc0f6bb/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"sat","error":"","status":"z3-ran","hash":"c89957f5908b877b8ca28d23edd51ae55dc0f6bb"} diff --git a/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json b/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json deleted file mode 100644 index 4076aabbd..000000000 --- a/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// solves sudoku\nfunction toSudoku(data: string): (number | null)[][] {\n const cells: (number | null)[][] = Array.from({ length: 9 }, () => Array.from({ length: 9 }, () => null));\n\n const lines = data.trim().split('\\n');\n for (let row = 0; row < 9; row++) {\n const line = lines[row].trim();\n for (let col = 0; col < 9; col++) {\n const char = line[col];\n if (char !== '.') {\n cells[row][col] = Number.parseInt(char);\n }\n }\n }\n return cells;\n}\n\nconst INSTANCE = toSudoku(`\n....94.3.\n...51...7\n.89....4.\n......2.8\n.6.2.1.5.\n1.2......\n.7....52.\n9...65...\n.4.97....\n`);\n\nconst EXPECTED = toSudoku(`\n715894632\n234516897\n689723145\n493657218\n867231954\n152489763\n376148529\n928365471\n541972386\n`);\n\n\nconst cells = [];\n// 9x9 matrix of integer variables\nfor (let i = 0; i < 9; i++) {\n const row = [];\n for (let j = 0; j < 9; j++) {\n row.push(Z3.Int.const(`x_${i}_${j}`));\n }\n cells.push(row);\n}\n\nconst solver = new Z3.Solver();\n\n// each cell contains a value 1<=x<=9\nfor (let i = 0; i < 9; i++) {\n for (let j = 0; j < 9; j++) {\n solver.add(cells[i][j].ge(1), cells[i][j].le(9));\n }\n}\n\n// each row contains a digit only once\nfor (let i = 0; i < 9; i++) {\n solver.add(Z3.Distinct(...cells[i]));\n}\n\n// each column contains a digit only once\nfor (let j = 0; j < 9; j++) {\n const column = [];\n for (let i = 0; i < 9; i++) {\n column.push(cells[i][j]);\n }\n solver.add(Z3.Distinct(...column));\n}\n\n// each 3x3 contains a digit at most once\nfor (let iSquare = 0; iSquare < 3; iSquare++) {\n for (let jSquare = 0; jSquare < 3; jSquare++) {\n const square = [];\n\n for (let i = iSquare * 3; i < iSquare * 3 + 3; i++) {\n for (let j = jSquare * 3; j < jSquare * 3 + 3; j++) {\n square.push(cells[i][j]);\n }\n }\n\n solver.add(Z3.Distinct(...square));\n }\n}\n\nfor (let i = 0; i < 9; i++) {\n for (let j = 0; j < 9; j++) {\n const digit = INSTANCE[i][j];\n if (digit !== null) {\n solver.add(cells[i][j].eq(digit));\n }\n }\n}\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json b/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json deleted file mode 100644 index 49f9dcd44..000000000 --- a/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"sat","error":"","status":"z3-ran","hash":"d274fcbbef696d7b8023d37cf910015ab7ce9c12"} diff --git a/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json b/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json deleted file mode 100644 index 61b54e9ad..000000000 --- a/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// proves De Morgan's Law\nconst solver = new Z3.Solver();\nconst [x, y] = [Z3.Bool.const('x'), Z3.Bool.const('y')];\nconst conjecture = Z3.Eq(Z3.Not(Z3.And(x, y)), Z3.Or(Z3.Not(x), Z3.Not(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check(); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json b/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json deleted file mode 100644 index b3bd6b587..000000000 --- a/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"unsat","error":"","status":"z3-ran","hash":"e54e8215ee8788a22b2dcfca2420107f804c4de2"} diff --git a/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json b/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json deleted file mode 100644 index 7d9c2a291..000000000 --- a/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// bitvectors: simple proofs\nconst x = Z3.BitVec.const('x', 32);\n\nconst sConj = x.sub(10).sle(0).eq(x.sle(10));\nconst sSolver = new Z3.Solver();\nsSolver.add(sConj);\nawait sSolver.check(); // sat\n\nconst sModel = sSolver.model();\nsModel.get(x) // signed\n\nconst uConj = x.sub(10).ule(0).eq(x.ule(10));\nconst uSolver = new Z3.Solver();\nuSolver.add(uConj);\nawait uSolver.check(); // sat\n\nconst uModel = uSolver.model();\nuModel.get(x) // unsigned"} diff --git a/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json b/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json deleted file mode 100644 index 758681685..000000000 --- a/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"#x0000000a","error":"","status":"z3-ran","hash":"f3e627e0f970fbc7fa1f6650366db67e71053bbd"} diff --git a/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json b/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json deleted file mode 100644 index 4942ccb53..000000000 --- a/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json +++ /dev/null @@ -1 +0,0 @@ -{"input":"// finds a model\nconst solver = new Z3.Solver();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\n\nsolver.add(x.ge(1)); // x >= 1\nsolver.add(y.lt(x.add(3))); // y < x + 3\n\nawait solver.check(); // sat\n\nconst model = solver.model();\nawait model.sexpr();"} diff --git a/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json b/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json deleted file mode 100644 index 78f01e626..000000000 --- a/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"(define-fun y () Int\n 3)\n(define-fun x () Int\n 1)","error":"","status":"z3-ran","hash":"f9dd66b1e430f36b7e955869f1646e0370ce0641"} From 61c9dcee17293229cd57edd1a0f196862b535e4c Mon Sep 17 00:00:00 2001 From: "Ruanqianqian (Lisa) Huang" Date: Fri, 29 Jul 2022 15:56:07 -0700 Subject: [PATCH 12/18] attempt to fix the issue with --- website/built-scripts/eval-z3.js | 14 ++++++------- .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + .../input.json | 1 + .../output.json | 1 + website/src/eval-z3/eval-z3.ts | 21 ++++++++++++------- website/static/eval-z3.js | 14 ++++++------- 19 files changed, 44 insertions(+), 21 deletions(-) create mode 100644 website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json create mode 100644 website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json create mode 100644 website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json create mode 100644 website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json create mode 100644 website/solutions/z3-js/4.10.1/56189d20f2dbb1202f0fd8c607509eff52173d82/input.json create mode 100644 website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json create mode 100644 website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json create mode 100644 website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json create mode 100644 website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json create mode 100644 website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json create mode 100644 website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json create mode 100644 website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json create mode 100644 website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json create mode 100644 website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json create mode 100644 website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json create mode 100644 website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json diff --git a/website/built-scripts/eval-z3.js b/website/built-scripts/eval-z3.js index 22ad9b9ed..55ac32855 100644 --- a/website/built-scripts/eval-z3.js +++ b/website/built-scripts/eval-z3.js @@ -115,11 +115,11 @@ function compile(source, fixupErrorLocations) { } function compileZ3JS(src) { let imports = ` - import type { init as initT, Model, Solver } from 'z3-solver'; - declare let init: typeof initT; - declare let { Context }: Awaited>; - declare let Z3: ReturnType>; - `; + import type { init as initT, Model, Solver } from 'z3-solver'; + declare let init: typeof initT; + declare let Z3: Awaited>; + declare let { Context, setParam } = Z3; +`; let wrapped = ` ${imports} export = (async () => { @@ -157,14 +157,14 @@ async function evalZ3JS(Z3, src) { return Promise.reject(new Error(result.message)); } let wrapped = ` -(function (Z3) { +(function (Z3, setParam) { 'use strict'; let module = {}; ${result.result} return module.exports; }) `; - return await (0, eval)(wrapped)(Z3.Context("main")); + return await (0, eval)(wrapped)(Z3.Context("main"), Z3.setParam); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { diff --git a/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json b/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json new file mode 100644 index 000000000..1c80b9958 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/input.json @@ -0,0 +1 @@ +{"input":"// proves x = y implies g(x) = g(y)\n\nconst solver = new Z3.Solver();\nconst sort = Z3.Int.sort();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\nconst g = Z3.Function.declare('g', sort, sort);\n\nconst conjecture = Z3.Implies(x.eq(y), g.call(x).eq(g.call(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check(); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json b/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json new file mode 100644 index 000000000..7b8842b14 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/16a515db3b88471d8f266b464b2344b2a30d00b7/output.json @@ -0,0 +1 @@ +{"output":"unsat","error":"","status":"z3-ran","hash":"16a515db3b88471d8f266b464b2344b2a30d00b7"} diff --git a/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json b/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json new file mode 100644 index 000000000..099177988 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/input.json @@ -0,0 +1 @@ +{"input":"// numerals 1\nconst n1 = Z3.Real.val('1/2');\nconst n2 = Z3.Real.val('0.5');\nconst n3 = Z3.Real.val(0.5);\n\nconst conjecture = Z3.And(n1.eq(n2), n1.eq(n3));\n\nconst solver = new Z3.Solver();\nsolver.add(Z3.Not(conjecture));\nawait solver.check();"} diff --git a/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json b/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json new file mode 100644 index 000000000..0414391c4 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/18db6515b197b55df72654ada88a28ab104776e0/output.json @@ -0,0 +1 @@ +{"output":"unsat","error":"","status":"z3-ran","hash":"18db6515b197b55df72654ada88a28ab104776e0"} diff --git a/website/solutions/z3-js/4.10.1/56189d20f2dbb1202f0fd8c607509eff52173d82/input.json b/website/solutions/z3-js/4.10.1/56189d20f2dbb1202f0fd8c607509eff52173d82/input.json new file mode 100644 index 000000000..3446f8d45 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/56189d20f2dbb1202f0fd8c607509eff52173d82/input.json @@ -0,0 +1 @@ +{"input":"// non-linear arithmetic\n\nsetParam('pp.decimal', true);\nsetParam('pp.decimal_precision', 20);\n\nconst x = Z3.Real.const('x');\nconst y = Z3.Real.const('y');\nconst z = Z3.Real.const('z');\n\nconst solver = new Z3.Solver();\nsolver.add(x.mul(x).add(y.mul(y)).eq(1)); // x^2 + y^2 == 1\nsolver.add(x.mul(x).mul(x).add(z.mul(z).mul(z)).lt('1/2')); // x^3 + z^3 < 1/2\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json b/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json new file mode 100644 index 000000000..17a56b4bc --- /dev/null +++ b/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/input.json @@ -0,0 +1 @@ +{"input":"// numerals 2\nconst n4 = Z3.Real.val('-1/3');\nconst n5 = Z3.Real.val('-0.3333333333333333333333333333333333');\n\nconst conjecture = n4.neq(n5);\n\nconst solver = new Z3.Solver();\nsolver.add(Z3.Not(conjecture));\nawait solver.check();"} diff --git a/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json b/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json new file mode 100644 index 000000000..0080905d3 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/6de42c85389d4407f0925ad8638fbd9b5b071cb4/output.json @@ -0,0 +1 @@ +{"output":"unsat","error":"","status":"z3-ran","hash":"6de42c85389d4407f0925ad8638fbd9b5b071cb4"} diff --git a/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json b/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json new file mode 100644 index 000000000..4abe05b0d --- /dev/null +++ b/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/input.json @@ -0,0 +1 @@ +{"input":"// disproves that x = y implies g(g(x)) = g(y)\n\nconst solver = new Z3.Solver();\nconst sort = Z3.Int.sort();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\nconst g = Z3.Function.declare('g', sort, sort);\nconst conjecture = Z3.Implies(x.eq(y), g.call(g.call(x)).eq(g.call(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check(); //sat"} diff --git a/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json b/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json new file mode 100644 index 000000000..1c5a5ffb3 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/c55e03a7cc02e5abf176f20763b498f989027b91/output.json @@ -0,0 +1 @@ +{"output":"sat","error":"","status":"z3-ran","hash":"c55e03a7cc02e5abf176f20763b498f989027b91"} diff --git a/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json b/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json new file mode 100644 index 000000000..5381d600f --- /dev/null +++ b/website/solutions/z3-js/4.10.1/c777e5f62b2783f71dff077e516d20445f5331f3/input.json @@ -0,0 +1 @@ +{"input":"// non-linear arithmetic\n\nZ3.setParam('pp.decimal', true);\nZ3.setParam('pp.decimal_precision', 20);\n\nconst x = Z3.Real.const('x');\nconst y = Z3.Real.const('y');\nconst z = Z3.Real.const('z');\n\nconst solver = new Z3.Solver();\nsolver.add(x.mul(x).add(y.mul(y)).eq(1)); // x^2 + y^2 == 1\nsolver.add(x.mul(x).mul(x).add(z.mul(z).mul(z)).lt('1/2')); // x^3 + z^3 < 1/2\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json b/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json new file mode 100644 index 000000000..4076aabbd --- /dev/null +++ b/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/input.json @@ -0,0 +1 @@ +{"input":"// solves sudoku\nfunction toSudoku(data: string): (number | null)[][] {\n const cells: (number | null)[][] = Array.from({ length: 9 }, () => Array.from({ length: 9 }, () => null));\n\n const lines = data.trim().split('\\n');\n for (let row = 0; row < 9; row++) {\n const line = lines[row].trim();\n for (let col = 0; col < 9; col++) {\n const char = line[col];\n if (char !== '.') {\n cells[row][col] = Number.parseInt(char);\n }\n }\n }\n return cells;\n}\n\nconst INSTANCE = toSudoku(`\n....94.3.\n...51...7\n.89....4.\n......2.8\n.6.2.1.5.\n1.2......\n.7....52.\n9...65...\n.4.97....\n`);\n\nconst EXPECTED = toSudoku(`\n715894632\n234516897\n689723145\n493657218\n867231954\n152489763\n376148529\n928365471\n541972386\n`);\n\n\nconst cells = [];\n// 9x9 matrix of integer variables\nfor (let i = 0; i < 9; i++) {\n const row = [];\n for (let j = 0; j < 9; j++) {\n row.push(Z3.Int.const(`x_${i}_${j}`));\n }\n cells.push(row);\n}\n\nconst solver = new Z3.Solver();\n\n// each cell contains a value 1<=x<=9\nfor (let i = 0; i < 9; i++) {\n for (let j = 0; j < 9; j++) {\n solver.add(cells[i][j].ge(1), cells[i][j].le(9));\n }\n}\n\n// each row contains a digit only once\nfor (let i = 0; i < 9; i++) {\n solver.add(Z3.Distinct(...cells[i]));\n}\n\n// each column contains a digit only once\nfor (let j = 0; j < 9; j++) {\n const column = [];\n for (let i = 0; i < 9; i++) {\n column.push(cells[i][j]);\n }\n solver.add(Z3.Distinct(...column));\n}\n\n// each 3x3 contains a digit at most once\nfor (let iSquare = 0; iSquare < 3; iSquare++) {\n for (let jSquare = 0; jSquare < 3; jSquare++) {\n const square = [];\n\n for (let i = iSquare * 3; i < iSquare * 3 + 3; i++) {\n for (let j = jSquare * 3; j < jSquare * 3 + 3; j++) {\n square.push(cells[i][j]);\n }\n }\n\n solver.add(Z3.Distinct(...square));\n }\n}\n\nfor (let i = 0; i < 9; i++) {\n for (let j = 0; j < 9; j++) {\n const digit = INSTANCE[i][j];\n if (digit !== null) {\n solver.add(cells[i][j].eq(digit));\n }\n }\n}\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json b/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json new file mode 100644 index 000000000..49f9dcd44 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/d274fcbbef696d7b8023d37cf910015ab7ce9c12/output.json @@ -0,0 +1 @@ +{"output":"sat","error":"","status":"z3-ran","hash":"d274fcbbef696d7b8023d37cf910015ab7ce9c12"} diff --git a/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json b/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json new file mode 100644 index 000000000..61b54e9ad --- /dev/null +++ b/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/input.json @@ -0,0 +1 @@ +{"input":"// proves De Morgan's Law\nconst solver = new Z3.Solver();\nconst [x, y] = [Z3.Bool.const('x'), Z3.Bool.const('y')];\nconst conjecture = Z3.Eq(Z3.Not(Z3.And(x, y)), Z3.Or(Z3.Not(x), Z3.Not(y)));\nsolver.add(Z3.Not(conjecture));\nawait solver.check(); // unsat"} diff --git a/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json b/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json new file mode 100644 index 000000000..b3bd6b587 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/e54e8215ee8788a22b2dcfca2420107f804c4de2/output.json @@ -0,0 +1 @@ +{"output":"unsat","error":"","status":"z3-ran","hash":"e54e8215ee8788a22b2dcfca2420107f804c4de2"} diff --git a/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json b/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json new file mode 100644 index 000000000..4942ccb53 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/input.json @@ -0,0 +1 @@ +{"input":"// finds a model\nconst solver = new Z3.Solver();\nconst x = Z3.Int.const('x');\nconst y = Z3.Int.const('y');\n\nsolver.add(x.ge(1)); // x >= 1\nsolver.add(y.lt(x.add(3))); // y < x + 3\n\nawait solver.check(); // sat\n\nconst model = solver.model();\nawait model.sexpr();"} diff --git a/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json b/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json new file mode 100644 index 000000000..78f01e626 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/f9dd66b1e430f36b7e955869f1646e0370ce0641/output.json @@ -0,0 +1 @@ +{"output":"(define-fun y () Int\n 3)\n(define-fun x () Int\n 1)","error":"","status":"z3-ran","hash":"f9dd66b1e430f36b7e955869f1646e0370ce0641"} diff --git a/website/src/eval-z3/eval-z3.ts b/website/src/eval-z3/eval-z3.ts index 8c0986c2a..d922accf0 100644 --- a/website/src/eval-z3/eval-z3.ts +++ b/website/src/eval-z3/eval-z3.ts @@ -122,12 +122,18 @@ function compile( // - and strips types // successful output looks like `"use strict"; module.exports = (async () => { ... })();` export function compileZ3JS(src: string) { + // let imports = ` + // import type { init as initT, Model, Solver } from 'z3-solver'; + // declare let init: typeof initT; + // declare let { Context }: Awaited>; + // declare let Z3: ReturnType>; + // `; let imports = ` - import type { init as initT, Model, Solver } from 'z3-solver'; - declare let init: typeof initT; - declare let { Context }: Awaited>; - declare let Z3: ReturnType>; - `; + import type { init as initT, Model, Solver } from 'z3-solver'; + declare let init: typeof initT; + declare let Z3: Awaited>; + declare let { Context, setParam } = Z3; +`; let wrapped = ` ${imports} export = (async () => { @@ -174,16 +180,17 @@ ${src} export async function evalZ3JS(Z3: Awaited>, src: string): Promise { let result = compileZ3JS(src); if (!result.success) { + // @ts-ignore: `result.message` is guaranteed to exist if `result.success === false` return Promise.reject(new Error(result.message)); } // we need to `eval` a function so we can pass Z3 into it let wrapped = ` -(function (Z3) { +(function (Z3, setParam) { 'use strict'; let module = {}; ${result.result} return module.exports; }) `; - return await (0, eval)(wrapped)(Z3.Context('main')); + return await (0, eval)(wrapped)(Z3.Context('main'), Z3.setParam); } \ No newline at end of file diff --git a/website/static/eval-z3.js b/website/static/eval-z3.js index f7aa59b1a..590875d95 100644 --- a/website/static/eval-z3.js +++ b/website/static/eval-z3.js @@ -438,24 +438,24 @@ Verbose Debug Information: `+(typeof mr=="string"?mr:mr())),X(Ir,Ee||z))}G.asser `);return`${D.file.fileName} (${oe+1},${me+1}): ${y}`}else return ic.flattenDiagnosticMessageText(D.messageText,` `)});return h.length>0?{success:!1,message:h.join(` `)}:I.emitSkipped||!("main.js"in ee)?{success:!1,message:"typechecking failed with unknown error"}:{success:!0,result:ee["main.js"]}}function SE(e){let o=` - import type { init as initT, Model, Solver } from 'z3-solver'; - declare let init: typeof initT; - declare let { Context }: Awaited>; - declare let Z3: ReturnType>; - `,$=` + import type { init as initT, Model, Solver } from 'z3-solver'; + declare let init: typeof initT; + declare let Z3: Awaited>; + declare let { Context, setParam } = Z3; +`,$=` ${o} export = (async () => { ${e} })(); `,G=o.split(` `).length+2;function ee({line:h,column:D}){return{line:h-G,column:D}}let F=ic.createSourceFile(zD,$,ic.ScriptTarget.ES2021);if(F.statements.length!==5)throw new Error("failed to parse input: wrong number of statements");let ie=F.statements[4];if(!ic.isCallExpression(ie.expression)||!ic.isParenthesizedExpression(ie.expression.expression)||!ic.isArrowFunction(ie.expression.expression.expression))throw new Error("failed to parse input: last line is not call");let De=ie.expression.expression.expression;if(!ic.isBlock(De.body))throw new Error("failed to parse input: arrow body is not block");let I=De.body.statements.length;if(I>0){let h=De.body.statements[I-1];ic.isExpressionStatement(h)&&(De.body.statements[I-1]=ic.factory.createReturnStatement(h.expression))}return e7(F,ee)}async function r7(e,o){let $=SE(o);if(!$.success)return Promise.reject(new Error($.message));let G=` -(function (Z3) { +(function (Z3, setParam) { 'use strict'; let module = {}; ${$.result} return module.exports; }) - `;return await(0,eval)(G)(e.Context("main"))}return ZI(n7);})(); + `;return await(0,eval)(G)(e.Context("main"),e.setParam)}return ZI(n7);})(); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use From 9ea51569cf23f71025d399cf10486d208f38dbb5 Mon Sep 17 00:00:00 2001 From: "Ruanqianqian (Lisa) Huang" Date: Fri, 29 Jul 2022 16:01:02 -0700 Subject: [PATCH 13/18] roll back the working imports to fix other examples --- website/src/eval-z3/eval-z3.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/website/src/eval-z3/eval-z3.ts b/website/src/eval-z3/eval-z3.ts index d922accf0..bde760fe7 100644 --- a/website/src/eval-z3/eval-z3.ts +++ b/website/src/eval-z3/eval-z3.ts @@ -122,18 +122,18 @@ function compile( // - and strips types // successful output looks like `"use strict"; module.exports = (async () => { ... })();` export function compileZ3JS(src: string) { - // let imports = ` - // import type { init as initT, Model, Solver } from 'z3-solver'; - // declare let init: typeof initT; - // declare let { Context }: Awaited>; - // declare let Z3: ReturnType>; - // `; let imports = ` - import type { init as initT, Model, Solver } from 'z3-solver'; - declare let init: typeof initT; - declare let Z3: Awaited>; - declare let { Context, setParam } = Z3; -`; + import type { init as initT, Model, Solver } from 'z3-solver'; + declare let init: typeof initT; + declare let { Context }: Awaited>; + declare let Z3: ReturnType>; + `; +// let imports = ` +// import type { init as initT, Model, Solver } from 'z3-solver'; +// declare let init: typeof initT; +// declare let Z3: Awaited>; +// declare let { Context, setParam } = Z3; +// `; let wrapped = ` ${imports} export = (async () => { From 9046f0e275eb5f19a5c1ae29956457c04a11bc85 Mon Sep 17 00:00:00 2001 From: "Ruanqianqian (Lisa) Huang" Date: Fri, 29 Jul 2022 16:02:19 -0700 Subject: [PATCH 14/18] skip build for the setParam example --- .../02 - Z3 JavaScript/03 - more JS examples.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs-programming/02 - Z3 JavaScript/03 - more JS examples.md b/website/docs-programming/02 - Z3 JavaScript/03 - more JS examples.md index 177de7920..62b9fe07e 100644 --- a/website/docs-programming/02 - Z3 JavaScript/03 - more JS examples.md +++ b/website/docs-programming/02 - Z3 JavaScript/03 - more JS examples.md @@ -184,7 +184,7 @@ await solver.check(); ``` TODO: setParam doesn't work with how with process JS inputs -```z3-js +```z3-js no-build // non-linear arithmetic Z3.setParam('pp.decimal', true); From 4c67b06ef71ce3f57665f07e4d47cca90afd95d2 Mon Sep 17 00:00:00 2001 From: "Ruanqianqian (Lisa) Huang" Date: Fri, 29 Jul 2022 16:10:52 -0700 Subject: [PATCH 15/18] fix: skipErr when there is a compile error under the no-build flag --- website/built-scripts/eval-z3.js | 10 +++++----- website/src/remark/render-code-blocks.mjs | 2 +- website/static/eval-z3.js | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/website/built-scripts/eval-z3.js b/website/built-scripts/eval-z3.js index 55ac32855..67157b624 100644 --- a/website/built-scripts/eval-z3.js +++ b/website/built-scripts/eval-z3.js @@ -115,11 +115,11 @@ function compile(source, fixupErrorLocations) { } function compileZ3JS(src) { let imports = ` - import type { init as initT, Model, Solver } from 'z3-solver'; - declare let init: typeof initT; - declare let Z3: Awaited>; - declare let { Context, setParam } = Z3; -`; + import type { init as initT, Model, Solver } from 'z3-solver'; + declare let init: typeof initT; + declare let { Context }: Awaited>; + declare let Z3: ReturnType>; + `; let wrapped = ` ${imports} export = (async () => { diff --git a/website/src/remark/render-code-blocks.mjs b/website/src/remark/render-code-blocks.mjs index 730e12f80..e1a22b8ba 100644 --- a/website/src/remark/render-code-blocks.mjs +++ b/website/src/remark/render-code-blocks.mjs @@ -103,7 +103,7 @@ async function getOutput(config, input, lang, skipErr) { status = statusCodes.timeout; } - if (status === statusCodes.runError) { + if (status === statusCodes.runError && !skipErr) { throw new Error(`${lang} runtime error: ${hash}, ${status}, ${input}, ${error}`); } diff --git a/website/static/eval-z3.js b/website/static/eval-z3.js index 590875d95..93549fef4 100644 --- a/website/static/eval-z3.js +++ b/website/static/eval-z3.js @@ -438,11 +438,11 @@ Verbose Debug Information: `+(typeof mr=="string"?mr:mr())),X(Ir,Ee||z))}G.asser `);return`${D.file.fileName} (${oe+1},${me+1}): ${y}`}else return ic.flattenDiagnosticMessageText(D.messageText,` `)});return h.length>0?{success:!1,message:h.join(` `)}:I.emitSkipped||!("main.js"in ee)?{success:!1,message:"typechecking failed with unknown error"}:{success:!0,result:ee["main.js"]}}function SE(e){let o=` - import type { init as initT, Model, Solver } from 'z3-solver'; - declare let init: typeof initT; - declare let Z3: Awaited>; - declare let { Context, setParam } = Z3; -`,$=` + import type { init as initT, Model, Solver } from 'z3-solver'; + declare let init: typeof initT; + declare let { Context }: Awaited>; + declare let Z3: ReturnType>; + `,$=` ${o} export = (async () => { ${e} From 426a79cc64dc24f9eb7969c26990d70ecec7ca60 Mon Sep 17 00:00:00 2001 From: "Ruanqianqian (Lisa) Huang" Date: Fri, 29 Jul 2022 16:28:43 -0700 Subject: [PATCH 16/18] setParam fixed --- website/built-scripts/eval-z3.js | 8 ++++---- .../02 - Z3 JavaScript/03 - more JS examples.md | 6 +++--- .../output.json | 1 + .../input.json | 1 + .../input.json | 1 + .../output.json | 1 + website/src/eval-z3/eval-z3.ts | 14 ++++---------- website/static/eval-z3.js | 8 ++++---- 8 files changed, 19 insertions(+), 21 deletions(-) create mode 100644 website/solutions/z3-js/4.10.1/56189d20f2dbb1202f0fd8c607509eff52173d82/output.json create mode 100644 website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json create mode 100644 website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json create mode 100644 website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json diff --git a/website/built-scripts/eval-z3.js b/website/built-scripts/eval-z3.js index 67157b624..da445a912 100644 --- a/website/built-scripts/eval-z3.js +++ b/website/built-scripts/eval-z3.js @@ -115,10 +115,10 @@ function compile(source, fixupErrorLocations) { } function compileZ3JS(src) { let imports = ` - import type { init as initT, Model, Solver } from 'z3-solver'; - declare let init: typeof initT; - declare let { Context }: Awaited>; - declare let Z3: ReturnType>; + import type { init as initT, Model, Solver } from 'z3-solver'; + declare let init: typeof initT; + declare let { Context, setParam }: Awaited>; + declare let Z3: ReturnType>; `; let wrapped = ` ${imports} diff --git a/website/docs-programming/02 - Z3 JavaScript/03 - more JS examples.md b/website/docs-programming/02 - Z3 JavaScript/03 - more JS examples.md index 62b9fe07e..80a958c8e 100644 --- a/website/docs-programming/02 - Z3 JavaScript/03 - more JS examples.md +++ b/website/docs-programming/02 - Z3 JavaScript/03 - more JS examples.md @@ -184,11 +184,11 @@ await solver.check(); ``` TODO: setParam doesn't work with how with process JS inputs -```z3-js no-build +```z3-js // non-linear arithmetic -Z3.setParam('pp.decimal', true); -Z3.setParam('pp.decimal_precision', 20); +setParam('pp.decimal', true); +setParam('pp.decimal_precision', 20); const x = Z3.Real.const('x'); const y = Z3.Real.const('y'); diff --git a/website/solutions/z3-js/4.10.1/56189d20f2dbb1202f0fd8c607509eff52173d82/output.json b/website/solutions/z3-js/4.10.1/56189d20f2dbb1202f0fd8c607509eff52173d82/output.json new file mode 100644 index 000000000..08913cdc3 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/56189d20f2dbb1202f0fd8c607509eff52173d82/output.json @@ -0,0 +1 @@ +{"output":"sat","error":"","status":"z3-ran","hash":"56189d20f2dbb1202f0fd8c607509eff52173d82"} diff --git a/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json b/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json new file mode 100644 index 000000000..e8242b702 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/672ab86ec9acaee1bb65f6ac564af7990d37ade5/input.json @@ -0,0 +1 @@ +{"input":"// solves an equation\nconst x = Z3.BitVec.const('x', 32);\nconst y = Z3.BitVec.const('y', 32);\n\nconst solver = new Z3.Solver();\nconst conjecture = x.xor(y).sub(103).eq(x.mul(y));\nsolver.add(conjecture);\nawait solver.check(); // sat\n\nconst model = solver.model();\nconst xSol = model.get(x);\nconst ySol = model.get(y);\n\nZ3.isBitVecVal(xSol) && Z3.isBitVecVal(ySol); // true\n\n// TODO: fix the remaining lines\nconst xv = xSol.asSignedValue();\nconst yv = ySol.asSignedValue();\n\n// this solutions wraps around so we need to check using modulo\n(xv ^ yv) - 103n === (xv * yv) % 2n ** 32n; // true"} diff --git a/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json b/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json new file mode 100644 index 000000000..7d9c2a291 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/input.json @@ -0,0 +1 @@ +{"input":"// bitvectors: simple proofs\nconst x = Z3.BitVec.const('x', 32);\n\nconst sConj = x.sub(10).sle(0).eq(x.sle(10));\nconst sSolver = new Z3.Solver();\nsSolver.add(sConj);\nawait sSolver.check(); // sat\n\nconst sModel = sSolver.model();\nsModel.get(x) // signed\n\nconst uConj = x.sub(10).ule(0).eq(x.ule(10));\nconst uSolver = new Z3.Solver();\nuSolver.add(uConj);\nawait uSolver.check(); // sat\n\nconst uModel = uSolver.model();\nuModel.get(x) // unsigned"} diff --git a/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json b/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json new file mode 100644 index 000000000..758681685 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/f3e627e0f970fbc7fa1f6650366db67e71053bbd/output.json @@ -0,0 +1 @@ +{"output":"#x0000000a","error":"","status":"z3-ran","hash":"f3e627e0f970fbc7fa1f6650366db67e71053bbd"} diff --git a/website/src/eval-z3/eval-z3.ts b/website/src/eval-z3/eval-z3.ts index bde760fe7..f8d46bcac 100644 --- a/website/src/eval-z3/eval-z3.ts +++ b/website/src/eval-z3/eval-z3.ts @@ -123,17 +123,11 @@ function compile( // successful output looks like `"use strict"; module.exports = (async () => { ... })();` export function compileZ3JS(src: string) { let imports = ` - import type { init as initT, Model, Solver } from 'z3-solver'; - declare let init: typeof initT; - declare let { Context }: Awaited>; - declare let Z3: ReturnType>; + import type { init as initT, Model, Solver } from 'z3-solver'; + declare let init: typeof initT; + declare let { Context, setParam }: Awaited>; + declare let Z3: ReturnType>; `; -// let imports = ` -// import type { init as initT, Model, Solver } from 'z3-solver'; -// declare let init: typeof initT; -// declare let Z3: Awaited>; -// declare let { Context, setParam } = Z3; -// `; let wrapped = ` ${imports} export = (async () => { diff --git a/website/static/eval-z3.js b/website/static/eval-z3.js index 93549fef4..fc6ffc0c7 100644 --- a/website/static/eval-z3.js +++ b/website/static/eval-z3.js @@ -438,10 +438,10 @@ Verbose Debug Information: `+(typeof mr=="string"?mr:mr())),X(Ir,Ee||z))}G.asser `);return`${D.file.fileName} (${oe+1},${me+1}): ${y}`}else return ic.flattenDiagnosticMessageText(D.messageText,` `)});return h.length>0?{success:!1,message:h.join(` `)}:I.emitSkipped||!("main.js"in ee)?{success:!1,message:"typechecking failed with unknown error"}:{success:!0,result:ee["main.js"]}}function SE(e){let o=` - import type { init as initT, Model, Solver } from 'z3-solver'; - declare let init: typeof initT; - declare let { Context }: Awaited>; - declare let Z3: ReturnType>; + import type { init as initT, Model, Solver } from 'z3-solver'; + declare let init: typeof initT; + declare let { Context, setParam }: Awaited>; + declare let Z3: ReturnType>; `,$=` ${o} export = (async () => { From b44c4442189d8ca71c398df998090a42590ea95b Mon Sep 17 00:00:00 2001 From: "Ruanqianqian (Lisa) Huang" Date: Fri, 29 Jul 2022 16:40:07 -0700 Subject: [PATCH 17/18] fix: BitVecNum --- website/built-scripts/eval-z3.js | 2 +- .../02 - Z3 JavaScript/03 - more JS examples.md | 8 ++++---- .../2c45a772b28cc3baa937d93c8bf823df6136c83a/input.json | 1 + .../50b6802118bc332a2cf3a387516a47535ddb1a9b/input.json | 1 + .../50b6802118bc332a2cf3a387516a47535ddb1a9b/output.json | 1 + .../8afbf9561def1f1deff536642e71ea154eda3ac1/input.json | 1 + .../bb407c0d3bab6c8c46f4d9e4e6b706dbbd063cb4/input.json | 1 + website/src/eval-z3/eval-z3.ts | 2 +- website/static/eval-z3.js | 2 +- 9 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 website/solutions/z3-js/4.10.1/2c45a772b28cc3baa937d93c8bf823df6136c83a/input.json create mode 100644 website/solutions/z3-js/4.10.1/50b6802118bc332a2cf3a387516a47535ddb1a9b/input.json create mode 100644 website/solutions/z3-js/4.10.1/50b6802118bc332a2cf3a387516a47535ddb1a9b/output.json create mode 100644 website/solutions/z3-js/4.10.1/8afbf9561def1f1deff536642e71ea154eda3ac1/input.json create mode 100644 website/solutions/z3-js/4.10.1/bb407c0d3bab6c8c46f4d9e4e6b706dbbd063cb4/input.json diff --git a/website/built-scripts/eval-z3.js b/website/built-scripts/eval-z3.js index da445a912..5b136a2fd 100644 --- a/website/built-scripts/eval-z3.js +++ b/website/built-scripts/eval-z3.js @@ -115,7 +115,7 @@ function compile(source, fixupErrorLocations) { } function compileZ3JS(src) { let imports = ` - import type { init as initT, Model, Solver } from 'z3-solver'; + import type { init as initT, Model, Solver, BitVecNum, AstVector } from 'z3-solver'; declare let init: typeof initT; declare let { Context, setParam }: Awaited>; declare let Z3: ReturnType>; diff --git a/website/docs-programming/02 - Z3 JavaScript/03 - more JS examples.md b/website/docs-programming/02 - Z3 JavaScript/03 - more JS examples.md index 80a958c8e..1d1b9dd39 100644 --- a/website/docs-programming/02 - Z3 JavaScript/03 - more JS examples.md +++ b/website/docs-programming/02 - Z3 JavaScript/03 - more JS examples.md @@ -235,8 +235,9 @@ solver.add(conjecture); await solver.check(); // sat const model = solver.model(); -const xSol = model.get(x); -const ySol = model.get(y); +// need the following cast for `asSignedValue` to work +const xSol = model.get(x) as BitVecNum; +const ySol = model.get(y) as BitVecNum; Z3.isBitVecVal(xSol) && Z3.isBitVecVal(ySol); // true @@ -252,8 +253,7 @@ const yv = ySol.asSignedValue(); // AstVector const solver = new Z3.Solver(); -// @ts-ignore: skipping typechecking for the following line for now, is there a better solution? -const vector = new Z3.AstVector(); +const vector = new Z3.AstVector() as AstVector; for (let i = 0; i < 5; i++) { vector.push(Z3.Int.const(`int__${i}`)); } diff --git a/website/solutions/z3-js/4.10.1/2c45a772b28cc3baa937d93c8bf823df6136c83a/input.json b/website/solutions/z3-js/4.10.1/2c45a772b28cc3baa937d93c8bf823df6136c83a/input.json new file mode 100644 index 000000000..b9b41200c --- /dev/null +++ b/website/solutions/z3-js/4.10.1/2c45a772b28cc3baa937d93c8bf823df6136c83a/input.json @@ -0,0 +1 @@ +{"input":"// solves an equation\nconst x = Z3.BitVec.const('x', 32);\nconst y = Z3.BitVec.const('y', 32);\n\nconst solver = new Z3.Solver();\nconst conjecture = x.xor(y).sub(103).eq(x.mul(y));\nsolver.add(conjecture);\nawait solver.check(); // sat\n\nconst model = solver.model() as Model;\nconst xSol = model.get(x);\nconst ySol = model.get(y);\n\nZ3.isBitVecVal(xSol) && Z3.isBitVecVal(ySol); // true\n\n// TODO: fix the remaining lines\nconst xv = xSol.asSignedValue();\nconst yv = ySol.asSignedValue();\n\n// this solutions wraps around so we need to check using modulo\n(xv ^ yv) - 103n === (xv * yv) % 2n ** 32n; // true"} diff --git a/website/solutions/z3-js/4.10.1/50b6802118bc332a2cf3a387516a47535ddb1a9b/input.json b/website/solutions/z3-js/4.10.1/50b6802118bc332a2cf3a387516a47535ddb1a9b/input.json new file mode 100644 index 000000000..fbfa5ff58 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/50b6802118bc332a2cf3a387516a47535ddb1a9b/input.json @@ -0,0 +1 @@ +{"input":"// solves an equation\nconst x = Z3.BitVec.const('x', 32);\nconst y = Z3.BitVec.const('y', 32);\n\nconst solver = new Z3.Solver();\nconst conjecture = x.xor(y).sub(103).eq(x.mul(y));\nsolver.add(conjecture);\nawait solver.check(); // sat\n\nconst model = solver.model();\n// need the following cast for `asSignedValue` to work\nconst xSol = model.get(x) as BitVecNum;\nconst ySol = model.get(y) as BitVecNum;\n\nZ3.isBitVecVal(xSol) && Z3.isBitVecVal(ySol); // true\n\n// TODO: fix the remaining lines\nconst xv = xSol.asSignedValue();\nconst yv = ySol.asSignedValue();\n\n// this solutions wraps around so we need to check using modulo\n(xv ^ yv) - 103n === (xv * yv) % 2n ** 32n; // true"} diff --git a/website/solutions/z3-js/4.10.1/50b6802118bc332a2cf3a387516a47535ddb1a9b/output.json b/website/solutions/z3-js/4.10.1/50b6802118bc332a2cf3a387516a47535ddb1a9b/output.json new file mode 100644 index 000000000..37384d7e1 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/50b6802118bc332a2cf3a387516a47535ddb1a9b/output.json @@ -0,0 +1 @@ +{"output":"true","error":"","status":"z3-ran","hash":"50b6802118bc332a2cf3a387516a47535ddb1a9b"} diff --git a/website/solutions/z3-js/4.10.1/8afbf9561def1f1deff536642e71ea154eda3ac1/input.json b/website/solutions/z3-js/4.10.1/8afbf9561def1f1deff536642e71ea154eda3ac1/input.json new file mode 100644 index 000000000..675675055 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/8afbf9561def1f1deff536642e71ea154eda3ac1/input.json @@ -0,0 +1 @@ +{"input":"// solves an equation\nconst x = Z3.BitVec.const('x', 32);\nconst y = Z3.BitVec.const('y', 32);\n\nconst solver = new Z3.Solver();\nconst conjecture = x.xor(y).sub(103).eq(x.mul(y));\nsolver.add(conjecture);\nawait solver.check(); // sat\n\nconst model = solver.model();\n// need the following cast for `asSignedValue` to work\nconst xSol = model.get(x) as BitVecNumImpl;\nconst ySol = model.get(y) as BitVecNumImpl;\n\nZ3.isBitVecVal(xSol) && Z3.isBitVecVal(ySol); // true\n\n// TODO: fix the remaining lines\nconst xv = xSol.asSignedValue();\nconst yv = ySol.asSignedValue();\n\n// this solutions wraps around so we need to check using modulo\n(xv ^ yv) - 103n === (xv * yv) % 2n ** 32n; // true"} diff --git a/website/solutions/z3-js/4.10.1/bb407c0d3bab6c8c46f4d9e4e6b706dbbd063cb4/input.json b/website/solutions/z3-js/4.10.1/bb407c0d3bab6c8c46f4d9e4e6b706dbbd063cb4/input.json new file mode 100644 index 000000000..b6f0e5a1d --- /dev/null +++ b/website/solutions/z3-js/4.10.1/bb407c0d3bab6c8c46f4d9e4e6b706dbbd063cb4/input.json @@ -0,0 +1 @@ +{"input":"// AstVector\nconst solver = new Z3.Solver();\n\nconst vector = new Z3.AstVector() as AstVector;\nfor (let i = 0; i < 5; i++) {\n vector.push(Z3.Int.const(`int__${i}`));\n}\n\nconst length = vector.length();\nfor (let i = 0; i < length; i++) {\n solver.add(vector.get(i).gt(1));\n}\n\nawait solver.check(); // sat"} diff --git a/website/src/eval-z3/eval-z3.ts b/website/src/eval-z3/eval-z3.ts index f8d46bcac..957ebc35b 100644 --- a/website/src/eval-z3/eval-z3.ts +++ b/website/src/eval-z3/eval-z3.ts @@ -123,7 +123,7 @@ function compile( // successful output looks like `"use strict"; module.exports = (async () => { ... })();` export function compileZ3JS(src: string) { let imports = ` - import type { init as initT, Model, Solver } from 'z3-solver'; + import type { init as initT, Model, Solver, BitVecNum, AstVector } from 'z3-solver'; declare let init: typeof initT; declare let { Context, setParam }: Awaited>; declare let Z3: ReturnType>; diff --git a/website/static/eval-z3.js b/website/static/eval-z3.js index fc6ffc0c7..b83678968 100644 --- a/website/static/eval-z3.js +++ b/website/static/eval-z3.js @@ -438,7 +438,7 @@ Verbose Debug Information: `+(typeof mr=="string"?mr:mr())),X(Ir,Ee||z))}G.asser `);return`${D.file.fileName} (${oe+1},${me+1}): ${y}`}else return ic.flattenDiagnosticMessageText(D.messageText,` `)});return h.length>0?{success:!1,message:h.join(` `)}:I.emitSkipped||!("main.js"in ee)?{success:!1,message:"typechecking failed with unknown error"}:{success:!0,result:ee["main.js"]}}function SE(e){let o=` - import type { init as initT, Model, Solver } from 'z3-solver'; + import type { init as initT, Model, Solver, BitVecNum, AstVector } from 'z3-solver'; declare let init: typeof initT; declare let { Context, setParam }: Awaited>; declare let Z3: ReturnType>; From 2fa6e658d997f9958678b48f301ddb3c9470b559 Mon Sep 17 00:00:00 2001 From: "Ruanqianqian (Lisa) Huang" Date: Fri, 29 Jul 2022 16:57:50 -0700 Subject: [PATCH 18/18] fix: AstVector example --- website/built-scripts/eval-z3.js | 2 +- .../02 - Z3 JavaScript/03 - more JS examples.md | 4 ++-- .../38b83a5f2eaf18869b5eab64231fa5867fe54769/input.json | 1 + .../38b83a5f2eaf18869b5eab64231fa5867fe54769/output.json | 1 + .../4a02b460c8b3f629dc254ef4429fa3d3f8f05df5/input.json | 1 + .../a089c1a50d01df5798db479278dcf8c0b0ba8d17/input.json | 1 + .../b3ada1bb8d9a1b06561be7307ade38417b62e81b/input.json | 1 + .../bbceba380968f8379f143f7c07262b82cface3b6/input.json | 1 + .../bccf22541ee8e1d029930806603ff9205f27d24c/input.json | 1 + website/src/eval-z3/eval-z3.ts | 2 +- website/static/eval-z3.js | 2 +- 11 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 website/solutions/z3-js/4.10.1/38b83a5f2eaf18869b5eab64231fa5867fe54769/input.json create mode 100644 website/solutions/z3-js/4.10.1/38b83a5f2eaf18869b5eab64231fa5867fe54769/output.json create mode 100644 website/solutions/z3-js/4.10.1/4a02b460c8b3f629dc254ef4429fa3d3f8f05df5/input.json create mode 100644 website/solutions/z3-js/4.10.1/a089c1a50d01df5798db479278dcf8c0b0ba8d17/input.json create mode 100644 website/solutions/z3-js/4.10.1/b3ada1bb8d9a1b06561be7307ade38417b62e81b/input.json create mode 100644 website/solutions/z3-js/4.10.1/bbceba380968f8379f143f7c07262b82cface3b6/input.json create mode 100644 website/solutions/z3-js/4.10.1/bccf22541ee8e1d029930806603ff9205f27d24c/input.json diff --git a/website/built-scripts/eval-z3.js b/website/built-scripts/eval-z3.js index 5b136a2fd..e33d49ae3 100644 --- a/website/built-scripts/eval-z3.js +++ b/website/built-scripts/eval-z3.js @@ -115,7 +115,7 @@ function compile(source, fixupErrorLocations) { } function compileZ3JS(src) { let imports = ` - import type { init as initT, Model, Solver, BitVecNum, AstVector } from 'z3-solver'; + import type { init as initT, Model, Solver, BitVecNum, AstVector, Arith } from 'z3-solver'; declare let init: typeof initT; declare let { Context, setParam }: Awaited>; declare let Z3: ReturnType>; diff --git a/website/docs-programming/02 - Z3 JavaScript/03 - more JS examples.md b/website/docs-programming/02 - Z3 JavaScript/03 - more JS examples.md index 1d1b9dd39..3ffedf981 100644 --- a/website/docs-programming/02 - Z3 JavaScript/03 - more JS examples.md +++ b/website/docs-programming/02 - Z3 JavaScript/03 - more JS examples.md @@ -253,14 +253,14 @@ const yv = ySol.asSignedValue(); // AstVector const solver = new Z3.Solver(); -const vector = new Z3.AstVector() as AstVector; +const vector = new Z3.AstVector() as AstVector; for (let i = 0; i < 5; i++) { vector.push(Z3.Int.const(`int__${i}`)); } const length = vector.length(); for (let i = 0; i < length; i++) { - solver.add(vector.get(i).gt(1)); + solver.add((vector.get(i) as Arith).gt(1)); } await solver.check(); // sat diff --git a/website/solutions/z3-js/4.10.1/38b83a5f2eaf18869b5eab64231fa5867fe54769/input.json b/website/solutions/z3-js/4.10.1/38b83a5f2eaf18869b5eab64231fa5867fe54769/input.json new file mode 100644 index 000000000..d19957781 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/38b83a5f2eaf18869b5eab64231fa5867fe54769/input.json @@ -0,0 +1 @@ +{"input":"// AstVector\nconst solver = new Z3.Solver();\n\nconst vector = new Z3.AstVector() as AstVector;\nfor (let i = 0; i < 5; i++) {\n vector.push(Z3.Int.const(`int__${i}`));\n}\n\nconst length = vector.length();\nfor (let i = 0; i < length; i++) {\n solver.add((vector.get(i) as Arith).gt(1));\n}\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/38b83a5f2eaf18869b5eab64231fa5867fe54769/output.json b/website/solutions/z3-js/4.10.1/38b83a5f2eaf18869b5eab64231fa5867fe54769/output.json new file mode 100644 index 000000000..c2001a1df --- /dev/null +++ b/website/solutions/z3-js/4.10.1/38b83a5f2eaf18869b5eab64231fa5867fe54769/output.json @@ -0,0 +1 @@ +{"output":"sat","error":"","status":"z3-ran","hash":"38b83a5f2eaf18869b5eab64231fa5867fe54769"} diff --git a/website/solutions/z3-js/4.10.1/4a02b460c8b3f629dc254ef4429fa3d3f8f05df5/input.json b/website/solutions/z3-js/4.10.1/4a02b460c8b3f629dc254ef4429fa3d3f8f05df5/input.json new file mode 100644 index 000000000..b1e8e1c1b --- /dev/null +++ b/website/solutions/z3-js/4.10.1/4a02b460c8b3f629dc254ef4429fa3d3f8f05df5/input.json @@ -0,0 +1 @@ +{"input":"// AstVector\nconst solver = new Z3.Solver();\n\nconst vector = new Z3.AstVector() as AstVector;\nfor (let i = 0; i < 5; i++) {\n vector.push(Z3.Int.const(`int__${i}`));\n}\n\nconst length = vector.length();\nfor (let i = 0; i < length; i++) {\n solver.add((vector.get(i) as Arith).gt(1));\n}\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/a089c1a50d01df5798db479278dcf8c0b0ba8d17/input.json b/website/solutions/z3-js/4.10.1/a089c1a50d01df5798db479278dcf8c0b0ba8d17/input.json new file mode 100644 index 000000000..7323457ed --- /dev/null +++ b/website/solutions/z3-js/4.10.1/a089c1a50d01df5798db479278dcf8c0b0ba8d17/input.json @@ -0,0 +1 @@ +{"input":"// AstVector\nconst solver = new Z3.Solver();\n\nconst vector = new Z3.AstVector() as AstVector;\nfor (let i = 0; i < 5; i++) {\n vector.push(Z3.Int.const(`int__${i}`));\n}\n\nconst length = vector.length();\nfor (let i = 0; i < length; i++) {\n solver.add((vector.get(i) as Arith).gt(1));\n}\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/b3ada1bb8d9a1b06561be7307ade38417b62e81b/input.json b/website/solutions/z3-js/4.10.1/b3ada1bb8d9a1b06561be7307ade38417b62e81b/input.json new file mode 100644 index 000000000..d9d289b24 --- /dev/null +++ b/website/solutions/z3-js/4.10.1/b3ada1bb8d9a1b06561be7307ade38417b62e81b/input.json @@ -0,0 +1 @@ +{"input":"// AstVector\nconst solver = new Z3.Solver();\n\nconst vector = new Z3.AstVector() as AstVector;\nfor (let i = 0; i < 5; i++) {\n vector.push(Z3.Int.const(`int__${i}`));\n}\n\nconst length = vector.length();\nfor (let i = 0; i < length; i++) {\n solver.add((vector.get(i) as Arith).gt(1));\n}\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/bbceba380968f8379f143f7c07262b82cface3b6/input.json b/website/solutions/z3-js/4.10.1/bbceba380968f8379f143f7c07262b82cface3b6/input.json new file mode 100644 index 000000000..7b041a79b --- /dev/null +++ b/website/solutions/z3-js/4.10.1/bbceba380968f8379f143f7c07262b82cface3b6/input.json @@ -0,0 +1 @@ +{"input":"// AstVector\nconst solver = new Z3.Solver();\n\nconst vector = new Z3.AstVector() as AstVector;\nfor (let i = 0; i < 5; i++) {\n vector.push(Z3.Int.const(`int__${i}`));\n}\n\nconst length = vector.length();\nfor (let i = 0; i < length; i++) {\n solver.add((vector.get(i) as Arith).gt(1));\n}\n\nawait solver.check(); // sat"} diff --git a/website/solutions/z3-js/4.10.1/bccf22541ee8e1d029930806603ff9205f27d24c/input.json b/website/solutions/z3-js/4.10.1/bccf22541ee8e1d029930806603ff9205f27d24c/input.json new file mode 100644 index 000000000..59cf94bbd --- /dev/null +++ b/website/solutions/z3-js/4.10.1/bccf22541ee8e1d029930806603ff9205f27d24c/input.json @@ -0,0 +1 @@ +{"input":"// AstVector\nconst solver = new Z3.Solver();\n\nconst vector = new Z3.AstVector() as AstVector;\nfor (let i = 0; i < 5; i++) {\n vector.push(Z3.Int.const(`int__${i}`));\n}\n\nconst length = vector.length();\nfor (let i = 0; i < length; i++) {\n solver.add((vector.get(i) as Arith).gt(1));\n}\n\nawait solver.check(); // sat"} diff --git a/website/src/eval-z3/eval-z3.ts b/website/src/eval-z3/eval-z3.ts index 957ebc35b..e272be555 100644 --- a/website/src/eval-z3/eval-z3.ts +++ b/website/src/eval-z3/eval-z3.ts @@ -123,7 +123,7 @@ function compile( // successful output looks like `"use strict"; module.exports = (async () => { ... })();` export function compileZ3JS(src: string) { let imports = ` - import type { init as initT, Model, Solver, BitVecNum, AstVector } from 'z3-solver'; + import type { init as initT, Model, Solver, BitVecNum, AstVector, Arith } from 'z3-solver'; declare let init: typeof initT; declare let { Context, setParam }: Awaited>; declare let Z3: ReturnType>; diff --git a/website/static/eval-z3.js b/website/static/eval-z3.js index b83678968..c0a832f6e 100644 --- a/website/static/eval-z3.js +++ b/website/static/eval-z3.js @@ -438,7 +438,7 @@ Verbose Debug Information: `+(typeof mr=="string"?mr:mr())),X(Ir,Ee||z))}G.asser `);return`${D.file.fileName} (${oe+1},${me+1}): ${y}`}else return ic.flattenDiagnosticMessageText(D.messageText,` `)});return h.length>0?{success:!1,message:h.join(` `)}:I.emitSkipped||!("main.js"in ee)?{success:!1,message:"typechecking failed with unknown error"}:{success:!0,result:ee["main.js"]}}function SE(e){let o=` - import type { init as initT, Model, Solver, BitVecNum, AstVector } from 'z3-solver'; + import type { init as initT, Model, Solver, BitVecNum, AstVector, Arith } from 'z3-solver'; declare let init: typeof initT; declare let { Context, setParam }: Awaited>; declare let Z3: ReturnType>;