コード例 #1
0
        private void btnExtract_Click(object sender, EventArgs e)
        {
            ANFEquation eq1 = new ANFEquation(tbOut.Text);
            ANFEquation eq2 = new ANFEquation(tbExtract.Text);

            eq1 = eq1.Extract(eq2);
            tbOut.Text = eq1.ToString();
        }
コード例 #2
0
        public void ReduceEncryptionEquations()
        {
            if (encryptedMsg.GetBitState(0) == true)
            {
                string id1 = "".PadLeft(VariableIDLength, '0');
                string id2 = (dataSize).ToString().PadLeft(VariableIDLength, '0');
                for (int i = 0; i < encriptionEqs.Count(); i++)
                {
                    encriptionEqs[i].SubIn(id1, true);
                    encriptionEqs[i].SubIn(id2, true);
                }
            }
            if (encryptedMsg.GetBitState(dataSize * 2 - 2) == true)
            {
                string id1 = (dataSize - 1).ToString().PadLeft(VariableIDLength, '0');
                string id2 = (dataSize * 2 - 1).ToString().PadLeft(VariableIDLength, '0');
                for (int i = 0; i < encriptionEqs.Count(); i++)
                {
                    encriptionEqs[i].SubIn(id1, true);
                    encriptionEqs[i].SubIn(id2, true);
                }
            }

            for (int i = 1; i < dataSize; i++)
            {
                for (int j = i + 1; j < dataSize * 2 - 1; j++)
                {
                    Minterm mt = new Minterm();
                    ANFEquation a = new ANFEquation();
                    mt.AddAtom(encriptionEqs[i].DeepCopy());
                    mt.AddAtom(encriptionEqs[j].DeepCopy());
                    a.AddAtom(mt);
                    a = a.Extract(encriptionEqs[i]);
                    if (a != null)
                    {
                        encriptionEqs[j] = a;
                    }
                }
            }

            for (int i = dataSize * 2 - 2; i >= dataSize; i--)
            {
                for (int j = i - 1; j >= 0; j--)
                {
                    Minterm mt = new Minterm();
                    ANFEquation a = new ANFEquation();
                    mt.AddAtom(encriptionEqs[i].DeepCopy());
                    mt.AddAtom(encriptionEqs[j].DeepCopy());
                    a.AddAtom(mt);
                    a = a.Extract(encriptionEqs[i]);
                    if (a != null)
                    {
                        encriptionEqs[j] = a;
                    }
                }
            }
        }