Beispiel #1
0
        private bool ApplyGammaRules()
        {
            string         rule  = "Gamma rule";
            HashSet <Node> nodes = new HashSet <Node>();

            foreach (Node n in propositions)
            {
                if (n is UniversalQuantifier)
                {
                    UniversalQuantifier quantifier = (UniversalQuantifier)n;
                    //add predicates for existing variables
                    foreach (char var in ActiveVariables)
                    {
                        try
                        {
                            UniversalQuantifier newQuantifier = (UniversalQuantifier)quantifier.Copy().ReplaceObjectVariableNewNode(quantifier.Variable, var);
                            if (quantifier != null)
                            {
                                nodes.Add(newQuantifier.Proposition);
                            }
                        }
                        catch (Exception ex) { DirectMessage.ShowError(ex.Message); }
                    }
                }
                else if (n is NegationSign && ((NegationSign)n).ReturnChildNode() is ExistentialQuantifier)
                {
                    ExistentialQuantifier quantifier = (ExistentialQuantifier)((NegationSign)n).ReturnChildNode();
                    //add predicates for existing variables
                    foreach (char var in ActiveVariables)
                    {
                        try
                        {
                            ExistentialQuantifier newQuantifier = (ExistentialQuantifier)quantifier.Copy().ReplaceObjectVariableNewNode(quantifier.Variable, var);
                            if (quantifier != null)
                            {
                                nodes.Add(new NegationSign(newQuantifier.Proposition));
                            }
                        }
                        catch (Exception ex) { DirectMessage.ShowError(ex.Message); }
                    }
                }
                else
                {
                    continue;
                }
            }
            if (nodes.Count > 0 && !nodes.IsSubsetOf(propositions))
            {
                nodes.UnionWith(propositions);
                leftNode = new STElement(nodes, ActiveVariables, rule);
                SimplifyChild(leftNode);
                return(true);
            }
            return(false);
        }
Beispiel #2
0
        private bool ApplyDeltaRules()
        {
            string rule = "Delta rule";

            foreach (Node n in propositions)
            {
                if (n is ExistentialQuantifier)
                {
                    HashSet <Node> props = new HashSet <Node>(propositions);
                    props.Remove(n);
                    //change variable
                    List <char> newVariables = AddNewVariable();
                    try
                    {
                        ExistentialQuantifier quantifier = (ExistentialQuantifier)n.Copy();
                        quantifier.ReplaceObjectVariable(quantifier.Variable, newVariables[newVariables.Count - 1]);
                        HashSet <Node> nodes = new HashSet <Node> {
                            quantifier.Proposition
                        };
                        props.UnionWith(nodes);
                        leftNode = new STElement(props, newVariables, rule);
                        SimplifyChild(leftNode);
                        return(true);
                    }
                    catch (Exception ex) { DirectMessage.ShowError(ex.Message); }
                }
                else if (n is NegationSign && ((NegationSign)n).ReturnChildNode() is UniversalQuantifier)
                {
                    HashSet <Node> props = new HashSet <Node>(propositions);
                    props.Remove(n);
                    //change variable
                    List <char> newVariables = AddNewVariable();
                    try
                    {
                        UniversalQuantifier quantifier = (UniversalQuantifier)((NegationSign)n).ReturnChildNode().Copy();
                        quantifier.ReplaceObjectVariable(quantifier.Variable, newVariables[newVariables.Count - 1]);
                        HashSet <Node> nodes = new HashSet <Node> {
                            new NegationSign(quantifier.Proposition)
                        };
                        props.UnionWith(nodes);
                        leftNode = new STElement(props, newVariables, rule);
                        SimplifyChild(leftNode);
                        return(true);
                    }
                    catch (Exception ex) { DirectMessage.ShowError(ex.Message); }
                }
                else
                {
                    continue;
                }
            }
            return(false);
        }