示例#1
0
文件: expSemantics.py 项目: nrc/N
 def subst(self, new, old, env, symbols):
     result = Concat(None)
     result.elements = map(lambda x: x.subst(new, old, env, symbols),
                           self.elements)
     types = map(lambda x: x.type(symbols), result.elements)
     result.typeF = util.maxListType(types, symbols)
     return result
示例#2
0
  def exec_inconcat(self, envr, pm):
    result = ProofResult("")
    result.source = self
    
    if len(self.args) != 1:
      raise ProofError("inconcat takes one argument, found: " + str(len(self.args)))
    arg = self.resolveOrDont(self.args[0])

    if isinstance(arg, expSemantics.Or) and arg.elements:
      nt = False
    elif isinstance(arg, expSemantics.And) and arg.elements:
      nt = True
    else:
      raise ProofError("inconcat expects a non-empty conjuntion or disjuntion, found: " + arg.shortString())
    fail = []
    lhs = arg.elements[0].lhs
    for e in arg.elements:
      if not isinstance(e, judge.InTest) or e.nt != nt or e.lhs != lhs:
        fail.append(e)
    if fail:
      raise ProofError("inconcat expects homogenous contains assertions, found: " + "; ".join(map(lambda e: e.shortString(), fail)))
      
    r = judge.InTest(None)
    r.nt = nt
    r.lhs = lhs
    r.rhs = expSemantics.Concat(None)
    r.rhs.elements = map(lambda e: e.rhs, arg.elements)
    r.rhs.typeF = util.maxListType(map(lambda x: x.rhs.type(pm.world.symList), arg.elements), pm.world.symList)

    self.results = [r]
    result.verbose = pm.getIndent() + self.results[0].shortString()
    return result
示例#3
0
文件: expSemantics.py 项目: nrc/N
 def dom(self, envr, symbols):
   for sym in symbols:
     for case in sym.cases:
       m = self.isSuperType(case, symbols)
       #print self, case, m
       if m and sym.maps:
         l = symbol.List(None)
         l.arg = sym.maps[0]
         mm = m.match(l)
         if mm:
           return mm
           
   result = Concat(None)
   result.elements = map(lambda x: x.dom(envr, symbols), self.elements)
   result.typeF = util.maxListType(map(lambda x: x.type(symbols), result.elements), symbols)
   return result
示例#4
0
文件: expSemantics.py 项目: nrc/N
    def dom(self, envr, symbols):
        for sym in symbols:
            for case in sym.cases:
                m = self.isSuperType(case, symbols)
                #print self, case, m
                if m and sym.maps:
                    l = symbol.List(None)
                    l.arg = sym.maps[0]
                    mm = m.match(l)
                    if mm:
                        return mm

        result = Concat(None)
        result.elements = map(lambda x: x.dom(envr, symbols), self.elements)
        result.typeF = util.maxListType(
            map(lambda x: x.type(symbols), result.elements), symbols)
        return result
示例#5
0
文件: expSemantics.py 项目: nrc/N
 def type(self, symbols):
     return util.maxListType([self.lhs, self.rhs], symbols)
示例#6
0
文件: expSemantics.py 项目: nrc/N
 def type(self, symbols):
     return util.maxListType(self.elements, symbols)
示例#7
0
文件: expSemantics.py 项目: nrc/N
 def type(self, symbols):
   return util.maxListType([self.lhs, self.rhs], symbols) 
示例#8
0
文件: expSemantics.py 项目: nrc/N
 def type(self, symbols):
   return util.maxListType(self.elements, symbols) 
示例#9
0
文件: expSemantics.py 项目: nrc/N
 def subst(self, new, old, env, symbols):
   result = Concat(None)
   result.elements = map(lambda x: x.subst(new, old, env, symbols), self.elements)
   types = map(lambda x: x.type(symbols), result.elements)
   result.typeF = util.maxListType(types, symbols)
   return result