public UpdateInfo update(ISemanticValue that)
    {
        if (!(that.GetType() == typeof(TruthValue)))
        {
            return(UpdateInfo.NoChange);
        }
        TruthValue other = (TruthValue)that;

        if (other.IsTrue())
        {
            return(Add(true));
        }
        if (other.IsFalse())
        {
            return(Add(false));
        }
        return(UpdateInfo.NoChange);
    }
Example #2
0
File: App.cs Project: hwacha/SemInC
    public override ISemanticValue Denotation(Model m)
    {
        if (!IsClosed())
        {
            return(null);
        }

        if (f.GetType() == typeof(Lambda))
        {
            return(this.Reduce().Denotation(m));
        }

        ISemanticValue d = f.Denotation(m);

        if (d.GetType() == typeof(Function))
        {
            return(((Function)d).Apply(x.Denotation(m)));
        }

        return(null);
    }
Example #3
0
 // super compatible
 public bool Satisfies(LogicalForm l)
 {
     if (l.IsClosed() && l.IsFormula())
     {
         ISemanticValue s = l.Denotation(this);
         if (s.GetType() == typeof(TruthValue))
         {
             TruthValue t = (TruthValue)s;
             if (t.IsUnknown() && (super != null))
             {
                 return(super.Satisfies(l));
             }
             return(t.IsTrue());
         }
         if (super != null)
         {
             return(super.Satisfies(l));
         }
         return(false);
     }
     return(false);
 }
Example #4
0
    // Adds a semantic value to the model, associating both
    // a semantic type and an ID number to it.
    public UpdateInfo Add(ISemanticType t, int id, ISemanticValue v)
    {
        // if the semantic type isn't currently in the model,
        // add an entry for it.
        if (!model.ContainsKey(t))
        {
            model[t] = new Dictionary <int, ISemanticValue>();
        }
        // get all the semantic values in the model with the
        // semantic type, t.
        Dictionary <int, ISemanticValue> modelByType = model[t];

        // if the ID is already defined for the semantic type t,
        // then don't change the model at all!
        if (modelByType.ContainsKey(id))
        {
            return(UpdateInfo.NoChange);
        }
        // otherwise, set the ID to the semantic value.
        modelByType[id] = v;

        // if there are formula rules with the given semantic type,
        // then we want to generate a sentence rule that refers
        // to the new semantic value.
        if (formulaRules.ContainsKey(t))
        {
            foreach (Rule fr in formulaRules[t])
            {
                HashSet <Rule> srs = GetSentenceRules(fr);
                foreach (Rule sr in srs)
                {
                    sentenceRules.Add(sr);
                }
            }
        }
        // if we're here, then we've updated the model!
        return(UpdateInfo.Updated);
    }
Example #5
0
 public ISemanticValue Apply(ISemanticValue input)
 {
     return(map[input]);
 }
Example #6
0
 public bool HasInput(ISemanticValue v)
 {
     return(map.ContainsKey(v));
 }
Example #7
0
 public void Set(ISemanticValue input, ISemanticValue output)
 {
     map[input] = output;
 }
 public bool Update(ISemanticValue that)
 {
     throw new NotImplementedException();
 }
 public bool Update(ISemanticValue that)
 {
     return(false);
 }
Example #10
0
File: Not.cs Project: hwacha/SemInC
    public override ISemanticValue Denotation(Model m)
    {
        ISemanticValue subDenotation = sub.Denotation(m);

        return(new TruthValue(Negate(((TruthValue)subDenotation).Get())));
    }