コード例 #1
0
ファイル: FType.cs プロジェクト: hwacha/SemInC
    public FType(ISemanticType basetype, LogicalForm formula)
    {
        if (!formula.IsFormula() || formula.IsClosed())
        {
            System.Console.WriteLine("FType failed: not a formula, or not free");
            return;
            // error
        }
        HashSet <Variable> .Enumerator vars = formula.GetFreeVariables().GetEnumerator();
        vars.MoveNext();
        Variable first = vars.Current;

        if (vars.MoveNext())
        {
            System.Console.WriteLine("FType failed: more than one free variable");
            return;
            // error (more than one free variable)
        }

        if (!first.GetSemanticType().Equals(basetype))
        {
            System.Console.WriteLine(first.GetSemanticType());
            System.Console.WriteLine(basetype);

            System.Console.WriteLine("FType failed: types aren't equal");
            return;
            // error
        }
        this.basetype = basetype;
        this.formula  = formula;
    }
コード例 #2
0
ファイル: ToDesirability.cs プロジェクト: hwacha/SemInC
 public ToDesirability(LogicalForm sentence) : base(new W())
 {
     if (sentence.GetType() != typeof(TWG))
     {
         // error!
     }
     this.sentence      = sentence;
     this.isFormula     = true;
     this.freeVariables = sentence.GetFreeVariables();
 }
コード例 #3
0
ファイル: Not.cs プロジェクト: hwacha/SemInC
 public Not(LogicalForm sub) : base(sub.GetSemanticType())
 {
     if (!sub.IsFormula())
     {
         // error!
         return;
     }
     this.sub           = sub;
     this.isFormula     = true;
     this.freeVariables = sub.GetFreeVariables();
 }
コード例 #4
0
    public HashSet <Variable> MergeVariables(LogicalForm l)
    {
        HashSet <Variable> newVs = new HashSet <Variable>();

        if (freeVariables != null)
        {
            foreach (Variable v in freeVariables)
            {
                newVs.Add(v);
            }
        }

        if (l.GetFreeVariables() != null)
        {
            foreach (Variable v in l.GetFreeVariables())
            {
                newVs.Add(v);
            }
        }

        return(newVs);
    }
コード例 #5
0
ファイル: Model.cs プロジェクト: hwacha/SemInC
    // Super compatible
    private HashSet <int> GetDomain(ISemanticType t)
    {
        Model currentModel = super;

        if (t.GetType() == typeof(FType))
        {
            FType       fType   = (FType)t;
            LogicalForm formula = fType.GetFormula();
            int         varID   = formula.GetFreeVariables().Single <Variable>().GetID();

            ISemanticType baseType = fType.GetBaseType();

            // populating the set with all semantic values
            // (including those in super models)
            // possible error: basetype is undefined in M
            Dictionary <int, ISemanticValue> .KeyCollection baseSet = model[baseType].Keys;

            while (currentModel != null)
            {
                // possible error: basetype is undefined in M
                baseSet.Union <int>(currentModel.model[baseType].Keys);
            }

            HashSet <int> finalSet = new HashSet <int>();

            foreach (int i in baseSet)
            {
                if (Satisfies(formula.Bind(varID, new Constant(baseType, i))))
                {
                    finalSet.Add(i);
                }
            }
            return(finalSet);
        }

        HashSet <int> theSet = new HashSet <int>();

        foreach (int i in model[t].Keys)
        {
            theSet.Add(i);
        }

        while (currentModel != null)
        {
            // possible error: t is undefined in M
            theSet.UnionWith(currentModel.model[t].Keys);
        }

        return(theSet);
    }
コード例 #6
0
 public ToTruth(LogicalForm sentence) : base(new T())
 {
     this.sentence      = sentence;
     this.isFormula     = true;
     this.freeVariables = sentence.GetFreeVariables();
 }