/// <summary>
/// Assert the axiom: function f is commutative.
/// </summary>
/// <remarks>
/// This example uses the SMT-LIB parser to simplify the axiom construction.
/// </remarks>
private static BoolExpr CommAxiom(Context ctx, FuncDecl f)
{
Sort t = f.Range;
Sort[] dom = f.Domain;
if (dom.Length != 2 ||
!t.Equals(dom[0]) ||
!t.Equals(dom[1]))
{
Console.WriteLine("{0} {1} {2} {3}", dom.Length, dom[0], dom[1], t);
throw new Exception("function must be binary, and argument types must be equal to return type");
}
string bench = string.Format("(benchmark comm :formula (forall (x {0}) (y {1}) (= ({2} x y) ({3} y x))))",
t.Name, t.Name, f.Name, f.Name);
ctx.ParseSMTLIBString(bench, new Symbol[] { t.Name }, new Sort[] { t }, new Symbol[] { f.Name }, new FuncDecl[] { f });
return ctx.SMTLIBFormulas[0];
}