Example #1
0
        /// <summary>
        /// 数式($で囲まれた部分)を解釈して_definedMorphismDictionaryに格納する
        /// </summary>
        /// <param name="text">数式($は含まない)</param>
        private void ReadMathText(string text)
        {
            foreach (var mor in Morphism.Create(text, _line))
            {
                if (mor.Name.ToString().Contains("#") || mor.Source.ToString().Contains("#") || mor.Target.ToString().Contains("#"))
                {
                    _parameterizedMorphisms.Add(mor);
                }
                else
                {
                    if (IsNaturalTransformation(mor))
                    {
                        mor.SetNaturalTransformation();
                    }
                    _definedMorphismDictionary[mor.Name.ToTokenString()] = mor;
                }
            }

            var func = Functor.Create(text);

            if (func != null)
            {
                _functors.Add(func);
                OutputResult(new CheckResult(_line, func.ToString(), false, true));
            }
        }
Example #2
0
 private IEnumerable <Morphism> CreateDefaultMorphisms()
 {
     foreach (var item in Config.Instance.Morphisms)
     {
         foreach (var mor in Morphism.Create(item))
         {
             yield return(mor);
         }
     }
 }
Example #3
0
        private bool IsNaturalTransformation(Morphism mor)
        {
            if (mor.Type != MorphismType.TwoMorphism)
            {
                return(false);
            }

            if (_definedMorphismDictionary.TryGetValue(mor.Source.ToTokenString(), out var source) && source.IsFunctor)
            {
                return(true);
            }

            if (_definedMorphismDictionary.TryGetValue(mor.Target.ToTokenString(), out var target) && target.IsFunctor)
            {
                return(true);
            }

            return(false);
        }