Opened 7 years ago

Closed 6 years ago

#12193 closed defect (fixed)

Dimension of Polyhedron is not well defined

Reported by: jipilab Owned by: mhampton
Priority: major Milestone: sage-5.6
Component: geometry Keywords: dimension, polytope, polyhedron
Cc: Merged in: sage-5.6.beta3
Authors: Volker Braun Reviewers: David Loeffler
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: #11634, #13638, #11763 Stopgaps:

Description (last modified by vbraun)

Given a vector space V and a polyhedron P, the dimension of P is the dimension of its affine hull, i.e. the smallest affine subspace of V in which P can live. (For a reference, see G.M. Ziegler's book "Lectures on Polytopes" p.5)

Right now, the dimension of a Polyhedron is defined as:

    def dim(self):
        """
        Return the dimension of the polyhedron.

        EXAMPLES::

            sage: simplex = Polyhedron(vertices = [[1,0,0,0],[0,0,0,1],[0,1,0,0],[0,0,1,0]])
            sage: simplex.dim()
            3
            sage: simplex.ambient_dim()
            4
       """
        return self.ambient_dim() - self.n_equations()

But this is obviously not the truthful definition. With the way things are now, this leads to various problems such as:

sage: P1=Polyhedron(vertices=[[1,0,0],[0,1,0],[0,0,1]])
sage: P2=Polyhedron(vertices=[[2,0,0],[0,2,0],[0,0,2]])
sage: Inter=P1.intersection(P2)
sage: Inter
The empty polyhedron in QQ^3.
sage: Inter.dim()
1

While the right answer should be -1.

One can produce many other examples...

Apply trac_12193_fix_dimension.patch

Attachments (1)

trac_12193_fix_dimension.patch (1.4 KB) - added by vbraun 6 years ago.
Updated patch

Download all attachments as: .zip

Change History (17)

comment:1 Changed 7 years ago by vbraun

  • Authors set to Volker Braun
  • Dependencies set to #11763
  • Description modified (diff)
  • Status changed from new to needs_review

Fixed by attached patch.

comment:2 Changed 7 years ago by davidloeffler

I've added a new patch which will stop the patchbot whining about trailing whitespace and commit messages.

Apply trac_12193_fix_dimension-v2.patch

comment:3 Changed 7 years ago by vbraun

I'm fine with your changes :-)

comment:4 Changed 7 years ago by davidloeffler

  • Status changed from needs_review to positive_review

comment:5 Changed 7 years ago by jdemeyer

  • Dependencies changed from #11763 to #11634, #11763
  • Milestone changed from sage-5.0 to sage-pending

comment:6 Changed 7 years ago by vbraun

Rediffed for sage-5.0.beta11, nothing of interest changed.

comment:7 Changed 7 years ago by jdemeyer

Please fill in your real name as Reviewer.

comment:8 Changed 7 years ago by vbraun

Rebased for #11763

comment:9 Changed 7 years ago by vbraun

  • Milestone changed from sage-pending to sage-5.5

comment:10 Changed 7 years ago by jdemeyer

  • Dependencies changed from #11634, #11763 to #11634, #13638, #11763
  • Milestone changed from sage-5.5 to sage-pending

comment:11 Changed 7 years ago by vbraun

  • Reviewers set to David Loeffler

comment:12 Changed 7 years ago by vbraun

For the patchbot: apply trac_12193_fix_dimension.patch only

comment:13 Changed 7 years ago by vbraun

The patchbot found a machine-dependent issue in a cmp() doctest, fixed now.

Changed 6 years ago by vbraun

Updated patch

comment:14 Changed 6 years ago by vbraun

Updated patch to push one patch hunk down to #11763.

comment:15 Changed 6 years ago by jdemeyer

  • Milestone changed from sage-pending to sage-5.6

comment:16 Changed 6 years ago by jdemeyer

  • Merged in set to sage-5.6.beta3
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.