(Context ctx, FuncDecl<R> f, int i)
| 99 | // / Where, <code>finv</code>is a fresh function declaration. |
| 100 | |
| 101 | public <R extends Sort> BoolExpr injAxiomAbs(Context ctx, FuncDecl<R> f, int i) |
| 102 | { |
| 103 | Sort[] domain = f.getDomain(); |
| 104 | int sz = f.getDomainSize(); |
| 105 | |
| 106 | if (i >= sz) |
| 107 | { |
| 108 | System.out.println("failed to create inj axiom"); |
| 109 | return null; |
| 110 | } |
| 111 | |
| 112 | /* declare the i-th inverse of f: finv */ |
| 113 | R finv_domain = f.getRange(); |
| 114 | Sort finv_range = domain[i]; |
| 115 | FuncDecl<Sort> finv = ctx.mkFuncDecl("f_fresh", finv_domain, finv_range); |
| 116 | |
| 117 | /* allocate temporary arrays */ |
| 118 | List<Expr<Sort>> xs = IntStream.range(0, sz).mapToObj(j -> ctx.mkConst(String.format("x_%d", j), domain[j])).collect(Collectors.toList()); |
| 119 | |
| 120 | /* fill types, names and xs */ |
| 121 | Expr<Sort> x_i = xs.get(i); |
| 122 | |
| 123 | /* create f(x_0, ..., x_i, ..., x_{n-1}) */ |
| 124 | Expr<R> fxs = f.apply(xs.toArray(new Expr[0])); |
| 125 | |
| 126 | /* create f_inv(f(x_0, ..., x_i, ..., x_{n-1})) */ |
| 127 | Expr<Sort> finv_fxs = finv.apply(fxs); |
| 128 | |
| 129 | /* create finv(f(x_0, ..., x_i, ..., x_{n-1})) = x_i */ |
| 130 | BoolExpr eq = ctx.mkEq(finv_fxs, x_i); |
| 131 | |
| 132 | /* use f(x_0, ..., x_i, ..., x_{n-1}) as the pattern for the quantifier */ |
| 133 | Pattern p = ctx.mkPattern(fxs); |
| 134 | |
| 135 | /* create & assert quantifier */ |
| 136 | return ctx.mkForall(xs.toArray(new Expr[0]), /* types of quantified variables */ |
| 137 | eq, /* names of quantified variables */ |
| 138 | 1, new Pattern[] { p } /* patterns */, null, null, null); |
| 139 | } |
| 140 | |
| 141 | // / Assert the axiom: function f is commutative. |
| 142 |
no test coverage detected