public static void InitializeDefaultSemanticRules() { //constructs the following expression: Booleans = { True, False } var notions = new Notion[] { Booleans, EqualityOperator, SetBuilderOpeningBraces, True, SetBuilderEnumerationDelimiters, False, SetBuilderClosingBraces }; var names = notions.Select(GetDefaultName).ToReadOnlyList(); var expression = new CompositeName(names, RootPosition.Instance, Booleans); //states that that expression is true new SemanticRule2(True.GetDefaultName(), expression, null, null); }
private static CompositeName AsRootNodes(params char[] chars) { var charPositions = chars.Select((s, i) => new LinearPosition(i)); //var charNameInstances = Enumerable.Zip(chars, charPositions, (c, p) => new AtomicNameInstance(c, p)).ToReadOnlyList<NameInstance>(); var charForms = Enumerable.Zip(chars, charPositions, ToAtomicName).ToReadOnlyList(); //var charNameInstances = charForms.Select(charForm => (Name)charForm.ResultingType).ToList<NameInstance>(); var cni = new CompositeName(charForms, new LinearPosition(0), dummyNotion); //cni.SetParent(null); return cni; }
/// <summary> Tries to convert to composite name to a subset relation. It regards the "proper" sub/superset as identical to sub/superset, and regards the superset as inverted subset relation. </summary> private SetRelation TryFindRelation(CompositeName potentialRelation) { Contract.Requires(potentialRelation != null); //if it is a linear notation if (potentialRelation.Notation.GetType().GetInterfaces().Any(i => i.Name == "ILinearForm`1")) { if (potentialRelation.Elements.Count.IsAnyOf(3, 5) && potentialRelation.Elements[0].Notion is Set && potentialRelation.Elements[2].Notion is Set) { Set leftOperand = (Set) potentialRelation.Elements[0].Notion; Set rightOperand = (Set) potentialRelation.Elements[2].Notion; //if it has the three elements {set, ⊆ or ⊂ or ⊃ or ⊇, set} denoting the subset-relation if (potentialRelation.Elements.Count == 3) { if (potentialRelation.Elements[1].Notion.IsAnyOf(DefaultNotions.ProperSubset, DefaultNotions.Subset)) return new SetRelation(leftOperand, rightOperand, Relation.Containment); if (potentialRelation.Elements[1].Notion.IsAnyOf(DefaultNotions.ProperSuperset, DefaultNotions.Superset)) return new SetRelation(rightOperand, leftOperand, Relation.Containment); } //if it has the 5 elements {set, ∩, set, =, ∅ }, then the two sets are disjoint. If the 5 elements {set, ∩, set, ≠, ∅ } or the 5 elements {set, ∩, set, =, non-empty set }, then the first two sets have overlap if (potentialRelation.Elements.Count == 5 && potentialRelation.Elements[1].Notion == DefaultNotions.Intersect && potentialRelation.Elements[4].Notion is Set) { if (potentialRelation.Elements[3].Notion == DefaultNotions.EqualityOperator && potentialRelation.Elements[4].Notion == DefaultNotions.EmptySet) return new SetRelation(leftOperand, rightOperand, Relation.None); if (potentialRelation.Elements[3].Notion == DefaultNotions.InequalityOperator && potentialRelation.Elements[4].Notion == DefaultNotions.EmptySet) return new SetRelation(leftOperand, rightOperand, Relation.Overlap); if (potentialRelation.Elements[3].Notion == DefaultNotions.EqualityOperator && potentialRelation.Elements[4].Notion != DefaultNotions.EmptySet) return new SetRelation(leftOperand, rightOperand, Relation.Overlap); } //TODO: search for more possible (but less likely) ways of denoting a set relation, such as {∅, =, set, ∩, set } } } return null; }
private static CompositeName ToScriptPersistentTreeNode(char[] chars, IEnumerable<IEnumerable<Script>> scripts) { Contract.Requires(chars != null); Contract.Requires(scripts != null); Contract.Requires(scripts.Count() == chars.Length); var scriptPositions = scripts.Select(s => new RelativeScriptPosition(s)); var scriptForms = Enumerable.Zip(chars, scriptPositions, ToAtomicName).ToReadOnlyList(); //var scriptNameInstances = scriptForms.Select(charForm => (Name)charForm.ResultingType).ToList<NameInstance>(); //var scriptsNameInstances = Enumerable.Zip(chars, scriptPositions, (c, p) => new AtomicName(c, p)).ToReadOnlyList(); //var scriptsForms = scriptsNameInstances.Select(scriptNameInstance => new ElementaryForm<NameInstance>(scriptNameInstance)); //var scriptForms = scriptsNameInstances.Select(scriptNameInstance => scriptNameInstance.Notation); var cni = new CompositeName(scriptForms, new LinearPosition(0), dummyNotion); //var result = new ScriptNotation<NameInstance>(scriptNameInstances, scriptPositions, cni, 0); //cni.SetParent(null); //cni.Notation = result; //return result; return cni; }
//internal static Name eAcute = ToScriptDiacritic('é'); private static Name encapsulate(Name form) { var result = new CompositeName(form.ToSingletonReadOnlyList(), form.ResultingDomain.Position, dummyNotion); result.SetParent(null); return result; }
public ImportDefinition(CompositeName @namespace) { Namespace = @namespace; }
public void Set(CompositeName name) { this.compositeName = name; }