diff --git a/src/api/dotnet/ArithExpr.cs b/src/api/dotnet/ArithExpr.cs
index ac1e9200e..58d160900 100644
--- a/src/api/dotnet/ArithExpr.cs
+++ b/src/api/dotnet/ArithExpr.cs
@@ -41,231 +41,130 @@ namespace Microsoft.Z3
#region Operators
- private static ArithExpr MkNum(ArithExpr e, int i)
- {
- return (ArithExpr)e.Context.MkNumeral(i, e.Context.MkIntSort());
- }
+ private static ArithExpr MkNum(ArithExpr e, int i) => (ArithExpr)e.Context.MkNumeral(i, e.Context.MkIntSort());
- private static ArithExpr MkNum(ArithExpr e, double d)
- {
- return (ArithExpr)e.Context.MkNumeral(d.ToString(), e.Context.MkRealSort());
- }
+ private static ArithExpr MkNum(ArithExpr e, double d) => (ArithExpr)e.Context.MkNumeral(d.ToString(), e.Context.MkRealSort());
/// Operator overloading for arithmetical divsion operator (over reals)
- public static ArithExpr operator /(ArithExpr a, ArithExpr b)
- {
- return a.Context.MkDiv(a, b);
- }
+ public static ArithExpr operator /(ArithExpr a, ArithExpr b) => a.Context.MkDiv(a, b);
/// Operator overloading for arithmetical operator
- public static ArithExpr operator -(ArithExpr a, ArithExpr b)
- {
- return a.Context.MkSub(a, b);
- }
+ public static ArithExpr operator /(ArithExpr a, int b) => a / MkNum(a, b);
/// Operator overloading for arithmetical operator
- public static ArithExpr operator -(ArithExpr a, int b)
- {
- return a.Context.MkSub(a, MkNum(a, b));
- }
+ public static ArithExpr operator /(ArithExpr a, double b) => a / MkNum(a, b);
/// Operator overloading for arithmetical operator
- public static ArithExpr operator -(ArithExpr a, double b)
- {
- return a.Context.MkSub(a, MkNum(a, b));
- }
+ public static ArithExpr operator /(int a, ArithExpr b) => MkNum(b, a) / b;
/// Operator overloading for arithmetical operator
- public static ArithExpr operator -(int a, ArithExpr b)
- {
- return b.Context.MkSub(MkNum(b, a), b);
- }
+ public static ArithExpr operator /(double a, ArithExpr b) => MkNum(b, a) / b;
/// Operator overloading for arithmetical operator
- public static ArithExpr operator -(double a, ArithExpr b)
- {
- return b.Context.MkSub(MkNum(b, a), b);
- }
+ public static ArithExpr operator -(ArithExpr a, ArithExpr b) => a.Context.MkSub(a, b);
/// Operator overloading for arithmetical operator
- public static ArithExpr operator +(ArithExpr a, ArithExpr b)
- {
- return a.Context.MkAdd(a, b);
- }
+ public static ArithExpr operator -(ArithExpr a, int b) => a - MkNum(a, b);
/// Operator overloading for arithmetical operator
- public static ArithExpr operator +(ArithExpr a, int b)
- {
- return a.Context.MkAdd(a, MkNum(a, b));
- }
+ public static ArithExpr operator -(ArithExpr a, double b) => a - MkNum(a, b);
/// Operator overloading for arithmetical operator
- public static ArithExpr operator +(ArithExpr a, double b)
- {
- return a.Context.MkAdd(a, MkNum(a, b));
- }
+ public static ArithExpr operator -(int a, ArithExpr b) => MkNum(b, a) - b;
/// Operator overloading for arithmetical operator
- public static ArithExpr operator +(int a, ArithExpr b)
- {
- return b.Context.MkAdd(MkNum(b, a), b);
- }
+ public static ArithExpr operator -(double a, ArithExpr b) => MkNum(b, a) - b;
/// Operator overloading for arithmetical operator
- public static ArithExpr operator +(double a, ArithExpr b)
- {
- return b.Context.MkAdd(MkNum(b, a), b);
- }
+ public static ArithExpr operator +(ArithExpr a, ArithExpr b) => a.Context.MkAdd(a, b);
/// Operator overloading for arithmetical operator
- public static ArithExpr operator *(ArithExpr a, ArithExpr b)
- {
- return a.Context.MkMul(a, b);
- }
+ public static ArithExpr operator +(ArithExpr a, int b) => a + MkNum(a, b);
/// Operator overloading for arithmetical operator
- public static ArithExpr operator *(ArithExpr a, int b)
- {
- return a.Context.MkMul(a, MkNum(a, b));
- }
+ public static ArithExpr operator +(ArithExpr a, double b) => a + MkNum(a, b);
+
+ /// Operator overloading for arithmetical operator
+ public static ArithExpr operator +(int a, ArithExpr b) => MkNum(b, a) + b;
/// Operator overloading for arithmetical operator
- public static ArithExpr operator *(ArithExpr a, double b)
- {
- return a.Context.MkMul(a, MkNum(a, b));
- }
+ public static ArithExpr operator +(double a, ArithExpr b) => MkNum(b, a) + b;
/// Operator overloading for arithmetical operator
- public static ArithExpr operator *(int a, ArithExpr b)
- {
- return b.Context.MkMul(MkNum(b, a), b);
- }
+ public static ArithExpr operator *(ArithExpr a, ArithExpr b) => a.Context.MkMul(a, b);
/// Operator overloading for arithmetical operator
- public static ArithExpr operator *(double a, ArithExpr b)
- {
- return b.Context.MkMul(MkNum(b, a), b);
- }
+ public static ArithExpr operator *(ArithExpr a, int b) => a * MkNum(a, b);
/// Operator overloading for arithmetical operator
- public static BoolExpr operator <=(ArithExpr a, ArithExpr b)
- {
- return a.Context.MkLe(a, b);
- }
+ public static ArithExpr operator *(ArithExpr a, double b) => a * MkNum(a, b);
/// Operator overloading for arithmetical operator
- public static BoolExpr operator <=(ArithExpr a, int b)
- {
- return a <= MkNum(a, b);
- }
+ public static ArithExpr operator *(int a, ArithExpr b) => MkNum(b, a) * b;
/// Operator overloading for arithmetical operator
- public static BoolExpr operator <=(ArithExpr a, double b)
- {
- return a <= MkNum(a, b);
- }
+ public static ArithExpr operator *(double a, ArithExpr b) => MkNum(b, a) * b;
/// Operator overloading for arithmetical operator
- public static BoolExpr operator <=(int a, ArithExpr b)
- {
- return MkNum(b, a) <= b;
- }
+ public static BoolExpr operator <=(ArithExpr a, ArithExpr b) => a.Context.MkLe(a, b);
/// Operator overloading for arithmetical operator
- public static BoolExpr operator <=(double a, ArithExpr b)
- {
- return MkNum(b, a) <= b;
- }
+ public static BoolExpr operator <=(ArithExpr a, int b) => a <= MkNum(a, b);
/// Operator overloading for arithmetical operator
- public static BoolExpr operator <(ArithExpr a, ArithExpr b)
- {
- return a.Context.MkLt(a, b);
- }
+ public static BoolExpr operator <=(ArithExpr a, double b) => a <= MkNum(a, b);
/// Operator overloading for arithmetical operator
- public static BoolExpr operator <(ArithExpr a, int b)
- {
- return a < MkNum(a, b);
- }
+ public static BoolExpr operator <=(int a, ArithExpr b) => MkNum(b, a) <= b;
/// Operator overloading for arithmetical operator
- public static BoolExpr operator <(ArithExpr a, double b)
- {
- return a < MkNum(a, b);
- }
+ public static BoolExpr operator <=(double a, ArithExpr b) => MkNum(b, a) <= b;
/// Operator overloading for arithmetical operator
- public static BoolExpr operator <(int a, ArithExpr b)
- {
- return MkNum(b, a) < b;
- }
+ public static BoolExpr operator <(ArithExpr a, ArithExpr b) => a.Context.MkLt(a, b);
/// Operator overloading for arithmetical operator
- public static BoolExpr operator <(double a, ArithExpr b)
- {
- return MkNum(b, a) < b;
- }
+ public static BoolExpr operator <(ArithExpr a, int b) => a < MkNum(a, b);
/// Operator overloading for arithmetical operator
- public static BoolExpr operator >=(ArithExpr a, ArithExpr b)
- {
- return a.Context.MkGe(a, b);
- }
+ public static BoolExpr operator <(ArithExpr a, double b) => a < MkNum(a, b);
/// Operator overloading for arithmetical operator
- public static BoolExpr operator >=(ArithExpr a, int b)
- {
- return a >= MkNum(a, b);
- }
+ public static BoolExpr operator <(int a, ArithExpr b) => MkNum(b, a) < b;
/// Operator overloading for arithmetical operator
- public static BoolExpr operator >=(ArithExpr a, double b)
- {
- return a >= MkNum(a, b);
- }
+ public static BoolExpr operator <(double a, ArithExpr b) => MkNum(b, a) < b;
/// Operator overloading for arithmetical operator
- public static BoolExpr operator >=(int a, ArithExpr b)
- {
- return MkNum(b, a) >= b;
- }
+ public static BoolExpr operator >(ArithExpr a, ArithExpr b) => a.Context.MkGt(a, b);
/// Operator overloading for arithmetical operator
- public static BoolExpr operator >=(double a, ArithExpr b)
- {
- return MkNum(b, a) >= b;
- }
+ public static BoolExpr operator >(ArithExpr a, int b) => a > MkNum(a, b);
/// Operator overloading for arithmetical operator
- public static BoolExpr operator >(ArithExpr a, ArithExpr b)
- {
- return a.Context.MkGt(a, b);
- }
+ public static BoolExpr operator >(ArithExpr a, double b) => a > MkNum(a, b);
/// Operator overloading for arithmetical operator
- public static BoolExpr operator >(ArithExpr a, int b)
- {
- return a > MkNum(a, b);
- }
+ public static BoolExpr operator >(int a, ArithExpr b) => MkNum(b, a) > b;
/// Operator overloading for arithmetical operator
- public static BoolExpr operator >(ArithExpr a, double b)
- {
- return a > MkNum(a, b);
- }
+ public static BoolExpr operator >(double a, ArithExpr b) => MkNum(b, a) > b;
/// Operator overloading for arithmetical operator
- public static BoolExpr operator >(int a, ArithExpr b)
- {
- return MkNum(b, a) > b;
- }
+ public static BoolExpr operator >=(ArithExpr a, ArithExpr b) => a.Context.MkGe(a, b);
/// Operator overloading for arithmetical operator
- public static BoolExpr operator >(double a, ArithExpr b)
- {
- return MkNum(b, a) > b;
- }
+ public static BoolExpr operator >=(ArithExpr a, int b) => a >= MkNum(a, b);
+
+ /// Operator overloading for arithmetical operator
+ public static BoolExpr operator >=(ArithExpr a, double b) => a >= MkNum(a, b);
+
+ /// Operator overloading for arithmetical operator
+ public static BoolExpr operator >=(int a, ArithExpr b) => MkNum(b, a) >= b;
+
+ /// Operator overloading for arithmetical operator
+ public static BoolExpr operator >=(double a, ArithExpr b) => MkNum(b, a) >= b;
+
#endregion
}
}
diff --git a/src/api/dotnet/BoolExpr.cs b/src/api/dotnet/BoolExpr.cs
index 4d5a43074..5bac65243 100644
--- a/src/api/dotnet/BoolExpr.cs
+++ b/src/api/dotnet/BoolExpr.cs
@@ -36,21 +36,19 @@ namespace Microsoft.Z3
#endregion
#region Operators
- ///
- /// Disjunction of Boolean expressions
- ///
- public static BoolExpr operator|(BoolExpr a, BoolExpr b)
- {
- return a.Context.MkOr(a, b);
- }
+ /// Disjunction of Boolean expressions
+ public static BoolExpr operator|(BoolExpr a, BoolExpr b) => a.Context.MkOr(a, b);
///
/// Conjunction of Boolean expressions
///
- public static BoolExpr operator &(BoolExpr a, BoolExpr b)
- {
- return a.Context.MkAnd(a, b);
- }
+ public static BoolExpr operator &(BoolExpr a, BoolExpr b) => a.Context.MkAnd(a, b);
+
+ /// Xor of Boolean expressions
+ public static BoolExpr operator ^(BoolExpr a, BoolExpr b) => a.Context.MkXor(a, b);
+
+ /// Negation
+ public static BoolExpr operator !(BoolExpr a) => a.Context.MkNot(a);
#endregion
}