/// <summary> Tries to get a subset relation that is encoded in the specified rule as a rule (that is, its sub-out is the (proper) sub/superset relation and its sub-in is true (or the other way around). </summary> private SetRelation TryFindRelationAsRule(SemanticRule rule) { Contract.Requires(rule != null); if (rule.Antecedents.Count != 0)//TODO: consider whether it is required that there are no antecedents return null; //if the sub-in is just "true", which is assumed to be the case for trivial subset relationships such as T∈U (or the sub-out is, i.e. next if-statement) if (((Name)rule.SubIn).Notion == DefaultNotions.True && rule.SubOut is CompositeName) //if it is a composition sub-out return TryFindRelation((CompositeName)rule.SubOut); if (((Name)rule.SubOut).Notion == DefaultNotions.True && rule.SubIn is CompositeName) //if it is a composition sub-in return TryFindRelation((CompositeName)rule.SubIn); return null; }
private IEnumerable<SetRelation> FindAntecedentlessCorollaryRelations(SemanticRule rule) { if (rule.Antecedents.Count != 0) return null; return rule.Corollaries.OfType<CompositeName>().Select(TryFindRelation).Where(NotNull);//Note that this counters the behavior to defining multiple set relations as multiple corollaries }
/// <summary> Tries to find a (proper) subset relation in the specified rule, where a (proper) superset relation is regarded as an inverted (proper) subset relation. </summary> public IEnumerable<SetRelation> TryGetSubsetRelation(SemanticRule rule) { return FindAntecedentlessCorollaryRelations(rule).ConcatIfNotNull(TryFindRelationAsRule(rule)); }