Beispiel #1
0
 /// <summary>
 /// The predicate used to represent concept in the CatSAT problem
 /// </summary>
 private Func <Individual, Proposition> PredicateOf(MonadicConcept c)
 {
     if (predicates.TryGetValue(c, out Func <Individual, Proposition> p))
     {
         return(p);
     }
     return(predicates[c] = Predicate <Individual>(c.StandardName.Untokenize()));
 }
Beispiel #2
0
 /// <summary>
 /// True if concept applies to individual in the current Model.
 /// </summary>
 /// <param name="i">Individual to test</param>
 /// <param name="c">Concept to test the truth of</param>
 /// <returns>True if i is an instance of c in the current Model</returns>
 public bool IsA(Individual i, MonadicConcept c)
 {
     if (c is CommonNoun n)
     {
         // In case we're doing a test for a noun that the generator had already determined
         // at compile time could not be an instance.
         return(Generator.CanBeA(i, n) && Model[Generator.IsA(i, c)]);
     }
     return(Model[Generator.IsA(i, c)]);
 }
Beispiel #3
0
    /// <summary>
    /// The proposition representing that concept k applies to individual i
    /// </summary>
    public Proposition IsA(Individual i, MonadicConcept k)
    {
        if (k is CommonNoun n && !CanBeA(i, n))
        {
            return(false);
        }

        var p = PredicateOf(k)(i);

        p.InitialProbability = k.InitialProbability;
        return(p);
    }
Beispiel #4
0
 /// <summary>
 /// True if concept applies to individual in the current Model.
 /// </summary>
 /// <param name="i">Individual to test</param>
 /// <param name="c">Concept to test the truth of</param>
 /// <returns>True if i is an instance of c in the current Model</returns>
 public bool IsA(Individual i, MonadicConcept c) => Model[Generator.IsA(i, c)];
 /// <summary>
 /// True if concept applies to individual in the current Model.
 /// </summary>
 /// <param name="c">Concept to test the truth of</param>
 /// <returns>True if i is an instance of c in the current Model</returns>
 public bool IsA(MonadicConcept c) => Invention.IsA(Individual, c);
Beispiel #6
0
 /// <summary>
 /// Add clause to Problem stating that consequent(i) follow from antecedent(i)
 /// </summary>
 /// <param name="i">Individual for which this implication holds</param>
 /// <param name="antecedents">A set of conditions on i</param>
 /// <param name="consequent">A concept that must be true of i when the antecedents are true.</param>
 private void AddImplication(Individual i, IEnumerable <MonadicConcept> antecedents, MonadicConcept consequent)
 {
     AddClause(antecedents.Select(a => Not(IsA(i, a))).Append(IsA(i, consequent)));
 }
Beispiel #7
0
 public MonadicConceptLiteral(MonadicConcept concept, bool isPositive = true)
 {
     Concept    = concept;
     IsPositive = isPositive;
 }
Beispiel #8
0
 private void SetIsA(Individual i, MonadicConcept n, bool truth) => Problem.Initialize(IsA(i, n), truth);
 /// <summary>
 /// Add this name and concept to the trie of all known names of all known monadic concepts.
 /// </summary>
 /// <param name="tokens">Name to add for the concept</param>
 /// <param name="c">Concept to add</param>
 /// <param name="isPlural">True when concept is a common noun and the name is its plural.</param>
 public static void Store(string[] tokens, MonadicConcept c, bool isPlural = false) => Trie.Store(tokens, c, isPlural);