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