AlloyTools / org.alloytools.alloy

Alloy is a language for describing structures and a tool for exploring them. It has been used in a wide range of applications from finding holes in security mechanisms to designing telephone switching networks. This repository contains the code for the tool.
Other
695 stars 124 forks source link

Ordered signatures can not have "exactly 0" instances #143

Open edmcman opened 3 years ago

edmcman commented 3 years ago
module Foo

// Uncommenting the following line results in no instance being found
open util/ordering[ZeroSig]

sig ZeroSig {}

// Sat
run {} for 3 but exactly 1 ZeroSig
// Unsat
run {} for 3 but exactly 0 ZeroSig

This is affecting me because I have an ordered Sig that I occasionally need to be empty (i.e., exactly 0).

pkriens commented 2 years ago

@dnjackson could you comment?

alcinocunha commented 1 year ago

The ordering module uses directly the total order definition from Kodkod, which requires that at least one element exists: first and last are always defined. We could have a different implementation of the ordering module that allowed empty sigs, but then we could not rely directly on the Kodkod implementation, and we would loose on efficiency. Maybe we need to add a note to the documentation of the module clarifying that the scope must be at least 1.

grayswandyr commented 1 year ago

After discussion: just update the documentation.