Example #1
0
def degen(seq: Sequent, name: str) -> Sequent:
    """
    The :math:`\\textbf{OptSet${}^?$}` :math:`\\texttt{degen}` rule.
    """
    if seq.pastingDiagram is not None:
        raise DerivationError("degen rule",
                              "Sequent cannot have a pasting diagram")
    res = deepcopy(seq)
    res.pastingDiagram = PastingDiagram.degeneratePastingDiagram(
        UnnamedOpetope.Degen(seq.context[name].variable.shapeProof), name)
    return res
Example #2
0
 def test_OpetopicTree(self):
     self.assertEqual(
         UnnamedOpetope.OpetopicTree(None).eval(),
         UnnamedOpetope.Degen(UnnamedOpetope.Arrow()).eval())
     for i in range(5):
         self.assertEqual(
             UnnamedOpetope.OpetopicTree([None] * i).eval(),
             UnnamedOpetope.Shift(UnnamedOpetope.OpetopicInteger(i)).eval())
     for i in range(5):
         tree = [None] * i + [[None]] + [None] * (4 - i)
         self.assertEqual(
             UnnamedOpetope.OpetopicTree(tree).eval(),
             UnnamedOpetope.Graft(
                 UnnamedOpetope.Shift(UnnamedOpetope.OpetopicInteger(5)),
                 UnnamedOpetope.OpetopicInteger(1),
                 UnnamedOpetope.address([['*'] * i], 2)).eval())
 def test___eq__(self):
     self.assertEqual(
         UnnamedOpetopicSet.pastingDiagram(
             UnnamedOpetope.OpetopicInteger(0), "a"),
         UnnamedOpetopicSet.pastingDiagram(
             UnnamedOpetope.OpetopicInteger(0), "a"))
     self.assertNotEqual(
         UnnamedOpetopicSet.pastingDiagram(
             UnnamedOpetope.OpetopicInteger(0), "a"),
         UnnamedOpetopicSet.pastingDiagram(
             UnnamedOpetope.OpetopicInteger(0), "b"))
     self.assertNotEqual(
         UnnamedOpetopicSet.pastingDiagram(
             UnnamedOpetope.OpetopicInteger(0), "a"),
         UnnamedOpetopicSet.pastingDiagram(
             UnnamedOpetope.Degen(UnnamedOpetope.Arrow()), "a"))
     self.assertNotEqual(
         UnnamedOpetopicSet.pastingDiagram(
             UnnamedOpetope.OpetopicInteger(1),
             {UnnamedOpetope.address([], 1): "a"}),
         UnnamedOpetopicSet.pastingDiagram(
             UnnamedOpetope.OpetopicInteger(1),
             {UnnamedOpetope.address([], 1): "b"}))
     self.assertNotEqual(
         UnnamedOpetopicSet.pastingDiagram(
             UnnamedOpetope.OpetopicInteger(1),
             {UnnamedOpetope.address([], 1): "a"}),
         UnnamedOpetopicSet.pastingDiagram(
             UnnamedOpetope.OpetopicInteger(2), {
                 UnnamedOpetope.address([], 1): "a",
                 UnnamedOpetope.address(['*']): "a"
             }))
     self.assertEqual(
         UnnamedOpetopicSet.pastingDiagram(
             UnnamedOpetope.OpetopicInteger(2), {
                 UnnamedOpetope.address([], 1): "a",
                 UnnamedOpetope.address(['*']): "b"
             }),
         UnnamedOpetopicSet.pastingDiagram(
             UnnamedOpetope.OpetopicInteger(2), {
                 UnnamedOpetope.address(['*']): "b",
                 UnnamedOpetope.address([], 1): "a"
             }))