예제 #1
0
        public static Substitution Unify(ISentence sentence1, ISentence sentence2)
        {
            var res = new Substitution();

            res.Successful = false;
            switch (sentence1.GetSentenceType())
            {
            case SentenceType.Predicate:
                if (sentence2.GetSentenceType() == SentenceType.QuantifierVariableSentence)
                {
                    var qvs2 = sentence2 as QuantifierVariableSentence;
                    if (qvs2.Quantifier != Quantifier.Exists)
                    {
                        break;
                    }
                    return(Unify(sentence1, qvs2.Sentence));
                }
                if (sentence2.GetSentenceType() == SentenceType.SentenceConnectiveSentence)
                {
                    break;
                }
                var pred1 = sentence1 as Predicate;
                var pred2 = sentence2 as Predicate;
                return(PredicateUnify(pred1, pred2));

            case SentenceType.SentenceConnectiveSentence:
                if (sentence1.GetSentenceType() != sentence2.GetSentenceType())
                {
                    break;
                }
                var scs1 = sentence1 as SentenceConnectiveSentence;
                var scs2 = sentence1 as SentenceConnectiveSentence;
                return(Unify(scs1.Sentence1, scs2.Sentence1).Compose(Unify(scs1.Sentence2, scs2.Sentence2)));

            case SentenceType.QuantifierVariableSentence:
                var qvs1 = sentence1 as QuantifierVariableSentence;
                if (qvs1.Quantifier == Quantifier.Exists)
                {
                    return(Unify(qvs1.Sentence, sentence2));
                }
                break;

            default:
                return(res);
            }
            return(res);
        }
예제 #2
0
        public static ISentence DropOuterQuantifiers(ISentence sentence)
        {
            switch (sentence.GetSentenceType())
            {
            case SentenceType.Predicate:
                return(sentence);

            case SentenceType.SentenceConnectiveSentence:
                return(sentence);

            default:     //QuantifierVariableSentence
                var quantifiedSentence = sentence as QuantifierVariableSentence;
                if (quantifiedSentence.Quantifier == Quantifier.All)
                {
                    return(DropOuterQuantifiers(quantifiedSentence.Sentence));
                }
                else
                {
                    return(sentence);
                }
            }
        }