Exemplo n.º 1
0
        private static bool InverseRecursiveMatch(TableauxNode root, Func <TableauxNode, bool> predicate)
        {
            if (predicate(root))
            {
                return(true);
            }

            return(InverseRecursiveMatch(root.Father, predicate));
        }
Exemplo n.º 2
0
        public static TableauxNode Generate(INode root, TableauxNode father)
        {
            if (root is NotNode && root.Children[0] is VariableNode)
            {
                return(new TableauxNode(root.Prettify(), father)
                {
                    State = false,
                    Representative = root,
                    Closed = InverseRecursiveMatch(father, node =>
                                                   node.Children.Any(c => c.Representative is VariableNode &&
                                                                     ((VariableNode)c.Representative).Key == ((VariableNode)root.Children[0]).Key)),
                });
            }

            if (root is LiteralNode || root is VariableNode)
            {
                return(new TableauxNode(root.Prettify(), father)
                {
                    State = true,
                    Representative = root,
                    Closed = InverseRecursiveMatch(father, node =>
                                                   node.Children.Any(c => c.Representative is NotNode && c.Representative.Children[0] is VariableNode &&
                                                                     ((VariableNode)c.Representative.Children[0]).Key == ((VariableNode)root.Children[0]).Key)),
                });
            }

            if (root is AndNode)
            {
                TableauxNode node = new TableauxNode(root.Prettify(), father);
                node.Children.Add(Generate(root.Children[0], node));
                node.Children.Add(Generate(root.Children[1], node));
                node.Disyuntive = false;
                return(node);
            }

            if (root is OrNode)
            {
                TableauxNode node = new TableauxNode(root.Prettify(), father);
                node.Children.Add(Generate(root.Children[0], node));
                node.Children.Add(Generate(root.Children[1], node));
                node.Disyuntive = true;
                return(node);
            }

            return(null);
        }
Exemplo n.º 3
0
 public TableauxNode(string text, TableauxNode father)
 {
     Children = new List <TableauxNode>();
     Father   = father;
     Text     = text;
 }