public SATVariable(Proposition proposition) { Proposition = proposition; PositiveClauses = new List <ushort>(); NegativeClauses = new List <ushort>(); PredeterminedValue = false; DeterminationStatus = DeterminationState.Floating; }
/// <summary> /// Creates a Literal representing the negation of the proposition /// </summary> /// <param name="p">Proposition to negate</param> public static Literal Not(Proposition p) { if (p.IsConstant) { return((bool)p ? Proposition.False : Proposition.True); } return(Problem.Current.Negation(p)); }
/// <summary> /// Make a symmetric predicate /// This will enforce that predicate(a, b) == predicate(b, a) /// </summary> /// <typeparam name="T">Argument type</typeparam> /// <param name="name">Name of the predicate</param> /// <returns>The predicate object, i.e. a function from arguments to Propositions</returns> public static Func <T, T, Proposition> SymmetricPredicate <T>(string name) where T : IComparable { return((arg1, arg2) => { if (arg1.CompareTo(arg2) > 0) { return Proposition.MakeProposition(Call.FromArgs(Problem.Current, name, arg2, arg1)); } return Proposition.MakeProposition(Call.FromArgs(Problem.Current, name, arg1, arg2)); }); }
/// <summary> /// Make a symmetric, reflexive predicate /// This will enforce that predicate(a, b) == predicate(b, a) /// </summary> /// <typeparam name="T">Argument type</typeparam> /// <param name="name">Name of the predicate</param> /// <returns>The predicate object, i.e. a function from arguments to Propositions</returns> // ReSharper disable once UnusedMember.Global public static Func <T, T, Proposition> SymmetricTransitiveRelation <T>(string name) where T : IComparable { return((arg1, arg2) => { var diff = arg1.CompareTo(arg2); if (diff > 0) { return Proposition.MakeProposition(Call.FromArgs(Problem.Current, name, arg2, arg1)); } if (diff == 0) { return Proposition.True; } // diff < 0 return Proposition.MakeProposition(Call.FromArgs(Problem.Current, name, arg1, arg2)); }); }
/// <summary> /// Creates a Literal representing the negation of the proposition /// </summary> /// <param name="proposition">Proposition to negate</param> public Negation(Proposition proposition) { this.Proposition = proposition; }
/// <summary> /// Test the truth of the specified literal within the model /// </summary> public bool this[Proposition p] { get => IsTrue(p);
/// <summary> /// Make a binary predicate /// </summary> /// <typeparam name="T1">Type for argument 1</typeparam> /// <typeparam name="T2">Type for argument 2</typeparam> /// <param name="name">Name of the predicate</param> /// <returns>The predicate object, i.e. a function from arguments to Propositions</returns> public static Func <T1, T2, Proposition> Predicate <T1, T2>(string name) { return((arg1, arg2) => Proposition.MakeProposition(Call.FromArgs(Problem.Current, name, arg1, arg2))); }
/// <summary> /// Make a 5-argument predicate /// </summary> /// <typeparam name="T1">Type for argument 1</typeparam> /// <typeparam name="T2">Type for argument 2</typeparam> /// <typeparam name="T3">Type for argument 3</typeparam> /// <typeparam name="T4">Type for argument 4</typeparam> /// <typeparam name="T5">Type for argument 5</typeparam> /// <param name="name">Name of the predicate</param> /// <returns>The predicate object, i.e. a function from arguments to Propositions</returns> // ReSharper disable once UnusedMember.Global public static Func <T1, T2, T3, T4, T5, Proposition> Predicate <T1, T2, T3, T4, T5>(string name) { return((arg1, arg2, arg3, arg4, arg5) => Proposition.MakeProposition(Call.FromArgs(Problem.Current, name, arg1, arg2, arg3, arg4, arg5))); }
internal NonTightProblemException(Proposition offender) : base($"{offender} is inferrable from itself!") { Offender = offender; }