private string NormalizedPrefix(TruthTableRow rowParameter) { string x = ""; string row = ""; for (int i = 0; i < rowParameter.OutputValues.Count; i++) { if (rowParameter.OutputValues[i] == "0") { row = $"~({Description[i]})"; } else { row = Description[i]; } if (i == 0) { x = row; } else { x = $"&({x}, {row})"; } } return(x); }
public TruthTableRow CompareRow(TruthTableRow anotherRow) { List <string> finalResult = new List <string>(); int count = 0; for (int i = 0; i < this.OutputValues.Count; i++) { if (this.OutputValues[i] == anotherRow.OutputValues[i]) { finalResult.Add(this.OutputValues[i]); } else { finalResult.Add("*"); count++; } } if (count == 1) { return(new TruthTableRow("1", finalResult)); } else { return(null); } }
public bool CheckEquality(TruthTableRow other) { for (int i = 0; i < this.OutputValues.Count; i++) { if (this.OutputValues[i] != other.OutputValues[i]) { return(false); } } return(true); }
private void GetSimplifiedRows(ref List <List <TruthTableRow> > groupList) { List <List <TruthTableRow> > temporaryList = new List <List <TruthTableRow> >(); int com = 0; for (int i = 0; i < groupList.Count - 1; i++) { List <TruthTableRow> rows = new List <TruthTableRow>(); foreach (var x in groupList[i]) { int counter = 0; foreach (var y in groupList[i + 1]) { TruthTableRow mixRow = x.CompareRow(y); if (mixRow != null) { mixRow.IsSimplified = true; if (!rows.Any(r => r.CheckEquality(mixRow))) { rows.Add(mixRow); } if (rows.Any(r => r.CheckEquality(mixRow)) && !mixRow.CheckEquality(y) && !rows.Any(r => r.CheckEquality(x))) { counter++; } } } if (counter == 0 && !rows.Any(r => r.CheckEquality(x)) && x.IsSimplified) { rows.Add(x); } com += counter; } temporaryList.Add(rows); } IsSimplified = com == 0; if (!IsSimplified) { groupList = temporaryList; } }