def test_graft(self):
     with self.assertRaises(DerivationError):
         UnnamedOpetopicSet.graft(
             UnnamedOpetopicSet.Sequent(),
             UnnamedOpetopicSet.PastingDiagram.degeneratePastingDiagram(
                 UnnamedOpetope.OpetopicInteger(0), "x"))
     with self.assertRaises(DerivationError):
         UnnamedOpetopicSet.graft(
             UnnamedOpetopicSet.Sequent(),
             UnnamedOpetopicSet.PastingDiagram.nonDegeneratePastingDiagram(
                 UnnamedOpetope.Arrow(),
                 {UnnamedOpetope.Address.epsilon(0): "x"}))
     # Incorrect grafting: ab on top of cd
     with self.assertRaises(DerivationError):
         UnnamedOpetopicSet.graft(
             self.seq,
             UnnamedOpetopicSet.PastingDiagram.nonDegeneratePastingDiagram(
                 UnnamedOpetope.OpetopicInteger(2), {
                     UnnamedOpetope.Address.epsilon(1): "cd",
                     UnnamedOpetope.Address.epsilon(0).shift(): "ab"
                 }))
     # Correct grafting: ab on top of bc
     UnnamedOpetopicSet.graft(
         self.seq,
         UnnamedOpetopicSet.PastingDiagram.nonDegeneratePastingDiagram(
             UnnamedOpetope.OpetopicInteger(2), {
                 UnnamedOpetope.Address.epsilon(1): "bc",
                 UnnamedOpetope.Address.epsilon(0).shift(): "ab"
             }))
 def setUp(self):
     self.type_point = UnnamedOpetopicSet.Type(
         UnnamedOpetopicSet.PastingDiagram.point(), None)
     self.a = UnnamedOpetopicSet.Variable("a", UnnamedOpetope.Point())
     self.b = UnnamedOpetopicSet.Variable("b", UnnamedOpetope.Point())
     self.c = UnnamedOpetopicSet.Variable("c", UnnamedOpetope.Point())
     self.d = UnnamedOpetopicSet.Variable("d", UnnamedOpetope.Point())
     self.ab = UnnamedOpetopicSet.Variable("ab", UnnamedOpetope.Arrow())
     self.ac = UnnamedOpetopicSet.Variable("ac", UnnamedOpetope.Arrow())
     self.bc = UnnamedOpetopicSet.Variable("bc", UnnamedOpetope.Arrow())
     self.cd = UnnamedOpetopicSet.Variable("cd", UnnamedOpetope.Arrow())
     self.seq = UnnamedOpetopicSet.Sequent()
     self.seq.context = UnnamedOpetopicSet.Context() + \
         UnnamedOpetopicSet.Typing(self.a, self.type_point) + \
         UnnamedOpetopicSet.Typing(self.b, self.type_point) + \
         UnnamedOpetopicSet.Typing(self.c, self.type_point) + \
         UnnamedOpetopicSet.Typing(self.d, self.type_point) + \
         UnnamedOpetopicSet.Typing(
             self.ab, self.type_arrow("a", self.b)) + \
         UnnamedOpetopicSet.Typing(
             self.ac, self.type_arrow("a", self.c)) + \
         UnnamedOpetopicSet.Typing(
             self.bc, self.type_arrow("b", self.c)) + \
         UnnamedOpetopicSet.Typing(
             self.cd, self.type_arrow("c", self.d))
 def test_point(self):
     s = UnnamedOpetopicSet.point(UnnamedOpetopicSet.Sequent(), "x")
     s = UnnamedOpetopicSet.point(s, "y")
     self.assertEqual(len(s.context), 2)
     with self.assertRaises(DerivationError):
         UnnamedOpetopicSet.point(s, "x")
     s.pastingDiagram = UnnamedOpetopicSet.PastingDiagram.point()
     with self.assertRaises(DerivationError):
         UnnamedOpetopicSet.point(s, "z")
 def test_degen(self):
     s = UnnamedOpetopicSet.point(UnnamedOpetopicSet.Sequent(), "x")
     with self.assertRaises(DerivationError):
         UnnamedOpetopicSet.degen(s, "y")
     s = UnnamedOpetopicSet.degen(s, "x")
     self.assertIsNotNone(s.pastingDiagram.degeneracy)
     self.assertEqual(s.pastingDiagram.degeneracy, "x")
     self.assertIsNone(s.pastingDiagram.nodes)
     with self.assertRaises(DerivationError):
         UnnamedOpetopicSet.degen(s, "x")