MCPcopy Create free account
hub / github.com/Z3Prover/z3 / injAxiomAbs

Method injAxiomAbs

examples/java/JavaExample.java:104–148  ·  view source on GitHub ↗
(Context ctx, FuncDecl f, int i)

Source from the content-addressed store, hash-verified

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

Callers 1

quantifierExample4Method · 0.95

Calls 11

applyMethod · 0.95
getDomainSizeMethod · 0.80
mkFuncDeclMethod · 0.80
mkConstMethod · 0.80
mkEqMethod · 0.80
mkPatternMethod · 0.80
mkForallMethod · 0.80
toStringMethod · 0.65
applyMethod · 0.65
getDomainMethod · 0.45
getRangeMethod · 0.45

Tested by

no test coverage detected