示例#1
0
 public static bool unify(Dictionary <Monomorphic, Monomorphic> m, Monomorphic s, Monomorphic t)
 {
     if (s is Slot && t is Slot && s.applySub(m).Equals(t.applySub(m)))
     {
         return(true);
     }
     else if (s is Primitive && t is Primitive && ((Primitive)s).Name == ((Primitive)t).Name)
     {
         return(true);
     }
     else if (s is Composite && t is Composite)
     {
         var s_ = (Composite)s;
         var t_ = (Composite)t;
         return(unify(m, s_.Ctor, t_.Ctor) && unify(m, s_.Argument, t_.Argument));
     }
     else if (s is Slot)
     {
         m.Add(s, t);
         return(true);
     }
     else if (t is Slot)
     {
         m.Add(t, s);
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#2
0
 public Composite(Monomorphic ctor, Monomorphic argument)
 {
     Ctor     = ctor;
     Argument = argument;
 }
示例#3
0
 public static Composite Arrow(Monomorphic p, Monomorphic q)
 {
     return(ct(ct(pm("[->]"), p), q));
 }
示例#4
0
 public static Composite Product(Monomorphic p, Monomorphic q)
 {
     return(ct(ct(pm("[*]"), p), q));
 }
示例#5
0
 public static Composite ct(Monomorphic ctor, Monomorphic argument)
 {
     return(new Composite(ctor, argument));
 }