bool check(SmallSet cur, List<Concept> a) { for (int i = 0; i < a.Count; i++) if ((a[i].Int <= cur)&&(a[i].Int.body!=0)) return true; return false; }
private void AddToListOfConcepts(int ind, List<Concept> L, List<SmallSet> u) { int n = L.Count; for (int i = 0; i < n; i++) { if (L[i].Int <= u[ind]) { Concept c = L[i]; SmallSet a = new SmallSet(ind); c.Ext = L[i].Ext + a; L[i] = c; } else { SmallSet z = L[i].Int * u[ind]; if (RelCanonic(ind, u, L[i].Ext, z)) { Concept c = new Concept(); SmallSet a = new SmallSet(ind); c.Ext = L[i].Ext + a; c.Int = z; L.Add(c); } } } if (Canonic(ind, u)) { Concept c = new Concept(); SmallSet a = new SmallSet(ind); c.Ext = a; c.Int = u[ind]; L.Add(c); } }
public Context(System.Windows.Forms.DataGridView d, System.Windows.Forms.DataGridView obj, System.Windows.Forms.DataGridView atr) { m = d.RowCount; int n = d.ColumnCount; this.body = new List<SmallSet>(); for (int i = 0; i < m; i++) this[i] = new SmallSet(d, i); unObj = new List<string>(); for (int i = 0; i < obj.RowCount; i++) unObj.Add(Convert.ToString(obj[0, i].Value)); unAtr = new List<string>(); for (int i = 0; i < atr.ColumnCount; i++) unAtr.Add(Convert.ToString(atr[i, 0].Value)); }
public SmallSet this[int i] { get { return body[i]; } set { if (body.Count < i+1) { SmallSet a = new SmallSet(); a = value; body.Add(a); } else body[i] = value; } }
private int set_indexOf(SmallSet x, List<SmallSet> u) { for (int i = 0; i < u.Count; i++) { if (x == u[i]) { return i; } } return -1; }
private void setBtn_Click(object sender, EventArgs e) { SmallSet a = new SmallSet(dataGridView4); SmallSet b = new SmallSet(dataGridView5); SmallSet c = new SmallSet(dataGridView6); c.n = a.n; if (plus.Checked) { c = a + b; c.ToDataGridView(this.dataGridView6); } if (minus.Checked) { c = a - b; c.ToDataGridView(this.dataGridView6); } if (mult.Checked) { c = a * b; c.ToDataGridView(this.dataGridView6); } if (div.Checked) { System.Windows.Forms.MessageBox.Show("one doesn't simply divide sets!!111!1"); } if (compl.Checked) { c = a.compl(a); c.ToDataGridView(this.dataGridView6); } }
private bool RelCanonic(int ind, List<SmallSet> u, SmallSet Y, SmallSet z) { for (int i = 0; i < ind; i++) { if (!indexSet_IsIn(i, Y) && (z * u[i]) == z) { return false; } } return true; }
private bool indexSet_IsIn(int ind, SmallSet y) { return y[ind]; }
private void dsm_btn_Click(object sender, EventArgs e) { int counter = 0; Context plus = new Context(In_Sets, objects, attributes); Context minus = new Context(Out_Sets, attributes1, objects1); List<SmallSet> L = new List<SmallSet>(); for (int i = 0; i < tau.RowCount; i++) { SmallSet a = new SmallSet(tau, i); L.Add(a); } List<String> Obj=new List<String>(); for (int i=0; i<objects2.RowCount; i++) { String a=Convert.ToString(objects2[0, i].Value); Obj.Add(a); } List<Concept> plus_hyp = new List<Concept>(); List<Concept> minus_hyp = new List<Concept>(); bool diff = true; while (diff) { counter++; int d = 0; plus_hyp = Norris(plus.body); minus_hyp = Norris(minus.body); string str = NorrisToString(plus_hyp, plus); string str1 = NorrisToString(minus_hyp, minus); str1 += "||||||"; str1 += str; hyp_out.Text = str1; for (int j = 0; j < L.Count; j++) { bool ind_plus = check(L[j], plus_hyp); bool ind_minus = check(L[j], minus_hyp); if (ind_plus && !ind_minus) { plus.body.Add(L[j]); plus.unObj.Add(Obj[j]); d++; } if (!ind_plus && ind_minus) { minus.body.Add(L[j]); minus.unObj.Add(Obj[j]); d++; } if (ind_plus || ind_minus) { L.Remove(L[j]); Obj.Remove(Obj[j]); j--; d++; } } if (d == 0) diff = false; } plus.toDataGridView(In_Sets, objects); minus.toDataGridView(Out_Sets, attributes1); norrisout.Text = counter.ToString(); }
private void cardNum_btn_Click(object sender, EventArgs e) { SmallSet a = new SmallSet(dataGridView4); cardNum.Text = Convert.ToString(a.card_num()); }
private void button3_Click(object sender, EventArgs e) { int un = this.dataGridView7.RowCount; String[] st = new String[un]; for (int i = 0; i < un; i++) st[i] = Convert.ToString(this.dataGridView7[0, i].Value); SmallSet b = new SmallSet(dataGridView4); SmallSet c = new SmallSet(dataGridView5); SmallSet d = new SmallSet(dataGridView6); b.ToStringView(st, setA); c.ToStringView(st, setB); d.ToStringView(st, setC); }
public List<SmallSet> ColumnsToSets() { int n=this[0].n; List<SmallSet> a=new List<SmallSet>(); for (int j = 0; j < n; j++) { SmallSet temp = new SmallSet(); temp.n = m; for (int i = 0; i < m; i++) temp[i] = this[i][j]; a.Add(temp); } return a; }
public static SmallSet operator -(SmallSet a) { SmallSet r = new SmallSet(); r.body = ~a.body; return r; }
public static SmallSet operator -(SmallSet a, SmallSet b) { SmallSet r = new SmallSet(); r.body = a.body & ~b.body; return r; }
public bool IsASubSet(SmallSet a, SmallSet b) { if (a * b == a) return true; else return false; }
public SmallSet compl(SmallSet a) { SmallSet r = new SmallSet(); r.n = a.n; for (int i = 0; i < a.n; i++) { if (a[i] == true) r[i] = false; else r[i] = true; } return r; }