/// <summary> /// Initializes a new instance of the <see cref="T:ShefferMultioperationRank4.ArrSet4"/> class. /// Creates an algebra with nullary multioperations (tetha, epsilon, pi) and op /// </summary> /// <param name="op">Multioperation op</param> public ArrSet4(Multioperation4 op) { Add(Multioperation4.Zero); Add(Multioperation4.E); Add(Multioperation4.All); Add(op); }
public static bool IsFourthType(Multioperation4 op) { var first = op & Multioperation4.E; if (first != Multioperation4.E) { return(false); } var second = (!op) & op; if (second != Multioperation4.E) { return(false); } var third1 = op * (!op); var third2 = (!op) * op; if (third1 != Multioperation4.All || third2 != Multioperation4.All) { return(false); } var fourth = op * op; if (fourth != Multioperation4.All) { return(false); } return(true); }
public static bool IsSecondType(Multioperation4 op) { var set = new ArrSet4(op); if (set.Count <= 3 || set.Count > 4) { return(false); } var first = op & Multioperation4.E; if (first != Multioperation4.E) { return(false); } var mu = !op; if (mu != op) { return(false); } var op2 = op * op; if (op2 != Multioperation4.All) { return(false); } return(true); }
public int Add(Multioperation4 op) { var prev = Interlocked.CompareExchange(ref opFlags[op.Value], 1, 0); if (prev != 0) { return(prev); } opList[_count] = op; Interlocked.Add(ref _count, 1 - prev); return(prev); }
public static bool IsFifthType(Multioperation4 op) { var first = op & Multioperation4.E; if (first != Multioperation4.Zero) { return(false); } if (!op != op) { return(false); } var third = op * op; if (third != Multioperation4.All) { return(false); } return(true); }
/// <summary> /// Generate the whole algebra /// </summary> /// <returns>Number of multioperations in algebra</returns> /// <param name="op">Multioperation generator</param> public static int CheckOp4Arr(Multioperation4 op) { var set = new ArrSet4(op); if (set.Count <= 3) { return(set.Count); } var prevCount = 0; // generate new multioperation while it is possible while (set.Count < 65536 && prevCount != set.Count) { prevCount = set.Count; // add mu(f) multioperations for (int i = 0; i < set.Count; i++) { set.Add(!set[i]); } for (int i = 0; i < set.Count; i++) { var op1 = set[i]; // For multioperation tetha: (tetha * x)(x) = (tetha) // and (tetha intersection f)(x) = (tetha) // so we could skip this step if (op1 == Multioperation4.Zero) { continue; } for (int j = 0; j < set.Count; j++) { var op2 = set[j]; // For multioperation tetha: (f * tetha)(x) = (tetha) // and (f intersection tetha)(x) = (tetha) // so we could skip this step too if (op2 == Multioperation4.Zero) { continue; } // (f * g)(x) var opSup = op1 * op2; // (f intersection g)(x) var opUn = op1 & op2; set.Add(opSup); set.Add(opUn); if (op1 == op2) { continue; } // (g * f)(x) opSup = op2 * op1; set.Add(opSup); } } } return(set.Count); }
public bool Contains(Multioperation4 op) { return(opFlags[op.Value] == 1); }