coso


Namecoso JSON
Version 1.1.5 PyPI version JSON
download
home_pagehttps://github.com/PietroTotis/CoSo
SummaryA solver for combinatorics math word problems.
upload_time2023-05-28 16:42:16
maintainer
docs_urlNone
authorPietro Totis
requires_python
licenseGNU General Public License (GPL)
keywords combinatorics automated reasoning
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # About 

This repository contains the code associated to the paper [Lifted Reasoning for Combinatorical Counting](https://jair.org/index.php/jair/article/view/14062). 

## Installation 

``install.sh`` installs the python environment with all the requirements listed in ``requirements.txt``.

``install-tools.sh`` installs optional third-party tools used in the experiments of the paper, but they are not a necessary requirement to run CoSo.

## Run

Activate the python environment pyenv and run
``python coso.py [filename]``, where ``filename`` is a file containing a CoLa problem (see below).

Add the option ``-v`` to generate a visual representation of the reasoning in CoSo. You can specify a filename (.html) if you want to save the output in a custom location.

# CoSo
CoSo is a lifted solver for combinatorics problems expressed in CoLa. Lifted reasoning is a form of automated reasoning which is based on the manipulation of groups of objects and their sizes to answer counting-related queries. CoSo can thus answer efficiently to problems expressed in CoLa such as:

> A kit of toy shapes contains five triangles and two squares. One triangle and one square are red. Another triangle and the other square are blue, and the remaining triangles are green. In how many different rows of four objects can the shapes be arranged if the two squares are included and the second object is green?

> Given the same set of shapes, in how many ways can the objects be divided into three(non-empty) groups such that the green objects all belong to the same group?

# CoLa
The input language for the solver is CoLa: a CoLa program is defined by a multiset of objects, a configuration, and optional constraints. 

The multiset of objects, the universe, can be expressed by enumeration, for example:
``shapes ={square_red, square_blue, triangle_red, triangle_blue, triangle_green, triangle_green, triangle_green};``.
Indistinguishable elements are denoted by the repetition of the same label as for ``triangle_green``.
Objects can have properties, which make them distinguishable: 
``property red ={triangle_red, square_red};``

``property blue ={triangle_blue, square_blue};``

``property green ={triangle_green};``

``property triangle ={triangle_red, triangle_blue, triangle_green};``

``property square ={square_blue square_red};``

Alternatively, the universe can be declared by listing the different properties and the corresponding number of objects with that property:

``property red;  property blue;  property green;``

``#red=2;  #blue=2;  #green=3;``

``property triangle; property square;#triangle=7; #square=2;``

``#square&red=1; #square&blue=1; #triangle&red=1;``

``#triangle&blue=1;  #triangle&green=3;``


Set formulas allow us to refer to combinations of property according to the usual set-operations: ``¬prop`` is the complement of a property or a set formula ``prop`` with respect to the universe. ``prop1 & prop2`` expresses the intersection, ``prop1 + prop2`` expresses the union of set formulas/properties. 

The keyword ``labelled`` can be prepended to the property declaration as a shortcut for expressingthat all objects having the property can be distinguished from one another, for instance:
``labelled property people;``
``#people=4;``



### Configuration.
A configuration is declared by using the following notation:
- ``[universe]`` denotes the set of all *permutations* of the universe.
- ``[repeated universe]`` denotes the set of all *sequences* of the universe.
- ``{universe}`` denotes the set of all *subsets* of the universe.
- ``{repeated universe}`` denotes the set of all *multisubsets* of the universe.
- ``[{universe}]`` denotes the set of all *compositions* of the universe.
- ``{{universe}}`` denotes the set of all *partitions* of the universe.

The set ``universe`` can be replaced with any name of a declared property.
To refer to a valid configuration, a label is associated with the keyword ``in``, for instance:

``row in [shapes];``

``groups in {{shapes}};``

## Constraints

Constraints restrict the set of valid configurations according to some additional requirement. In CoLa there are currently three types of constraints: size constraints, positional constraints, and counting constraints.

### Size Constraints
Size constraints define either the size of a configuration or a part (a subset in a partition/composition):

``#row = 4``

defines that only the rows of length 4 are valid. Any arithmetic comparison can be used: ``=,!=,<,<=,>,>=``.

### Positional Constraints.
Positional constraints are expressed with ``name[i] = prop`` where ``name`` is the name of the configuration, ``i`` is the position, ``prop`` is a property for example:

``row[2] = green;``

### Counting Constraints.
Counting constraints count either entities or parts that satisfy some property in the configuration. For example:

``#row & squares = 2``

states that the number of squares in a row is 2. Here we can also use any of ``=,!=,<,<=,>,>=``.
Counting constraints can be nested in partitions and compositions:

`` #(#part & green = 3) = 1;``

the keyword ``part`` denotes a generic subset of a partition/configuration.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/PietroTotis/CoSo",
    "name": "coso",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "combinatorics automated reasoning",
    "author": "Pietro Totis",
    "author_email": "pietro.totis@kuleuven.be",
    "download_url": "https://files.pythonhosted.org/packages/99/f7/4eb788ee15b8fca4f73cae893c8274caf254ebc615175d840d2d93de78df/coso-1.1.5.tar.gz",
    "platform": null,
    "description": "# About \n\nThis repository contains the code associated to the paper [Lifted Reasoning for Combinatorical Counting](https://jair.org/index.php/jair/article/view/14062). \n\n## Installation \n\n``install.sh`` installs the python environment with all the requirements listed in ``requirements.txt``.\n\n``install-tools.sh`` installs optional third-party tools used in the experiments of the paper, but they are not a necessary requirement to run CoSo.\n\n## Run\n\nActivate the python environment pyenv and run\n``python coso.py [filename]``, where ``filename`` is a file containing a CoLa problem (see below).\n\nAdd the option ``-v`` to generate a visual representation of the reasoning in CoSo. You can specify a filename (.html) if you want to save the output in a custom location.\n\n# CoSo\nCoSo is a lifted solver for combinatorics problems expressed in CoLa. Lifted reasoning is a form of automated reasoning which is based on the manipulation of groups of objects and their sizes to answer counting-related queries. CoSo can thus answer efficiently to problems expressed in CoLa such as:\n\n> A kit of toy shapes contains five triangles and two squares. One triangle and one square are red. Another triangle and the other square are blue, and the remaining triangles are green. In how many different rows of four objects can the shapes be arranged if the two squares are included and the second object is green?\n\n> Given the same set of shapes, in how many ways can the objects be divided into three(non-empty) groups such that the green objects all belong to the same group?\n\n# CoLa\nThe input language for the solver is CoLa: a CoLa program is defined by a multiset of objects, a configuration, and optional constraints. \n\nThe multiset of objects, the universe, can be expressed by enumeration, for example:\n``shapes ={square_red, square_blue, triangle_red, triangle_blue, triangle_green, triangle_green, triangle_green};``.\nIndistinguishable elements are denoted by the repetition of the same label as for ``triangle_green``.\nObjects can have properties, which make them distinguishable: \n``property red ={triangle_red, square_red};``\n\n``property blue ={triangle_blue, square_blue};``\n\n``property green ={triangle_green};``\n\n``property triangle ={triangle_red, triangle_blue, triangle_green};``\n\n``property square ={square_blue square_red};``\n\nAlternatively, the universe can be declared by listing the different properties and the corresponding number of objects with that property:\n\n``property red;  property blue;  property green;``\n\n``#red=2;  #blue=2;  #green=3;``\n\n``property triangle; property square;#triangle=7; #square=2;``\n\n``#square&red=1; #square&blue=1; #triangle&red=1;``\n\n``#triangle&blue=1;  #triangle&green=3;``\n\n\nSet formulas allow us to refer to combinations of property according to the usual set-operations: ``\u00acprop`` is the complement of a property or a set formula ``prop`` with respect to the universe. ``prop1 & prop2`` expresses the intersection, ``prop1 + prop2`` expresses the union of set formulas/properties. \n\nThe keyword ``labelled`` can be prepended to the property declaration as a shortcut for expressingthat all objects having the property can be distinguished from one another, for instance:\n``labelled property people;``\n``#people=4;``\n\n\n\n### Configuration.\nA configuration is declared by using the following notation:\n- ``[universe]`` denotes the set of all *permutations* of the universe.\n- ``[repeated universe]`` denotes the set of all *sequences* of the universe.\n- ``{universe}`` denotes the set of all *subsets* of the universe.\n- ``{repeated universe}`` denotes the set of all *multisubsets* of the universe.\n- ``[{universe}]`` denotes the set of all *compositions* of the universe.\n- ``{{universe}}`` denotes the set of all *partitions* of the universe.\n\nThe set ``universe`` can be replaced with any name of a declared property.\nTo refer to a valid configuration, a label is associated with the keyword ``in``, for instance:\n\n``row in [shapes];``\n\n``groups in {{shapes}};``\n\n## Constraints\n\nConstraints restrict the set of valid configurations according to some additional requirement. In CoLa there are currently three types of constraints: size constraints, positional constraints, and counting constraints.\n\n### Size Constraints\nSize constraints define either the size of a configuration or a part (a subset in a partition/composition):\n\n``#row = 4``\n\ndefines that only the rows of length 4 are valid. Any arithmetic comparison can be used: ``=,!=,<,<=,>,>=``.\n\n### Positional Constraints.\nPositional constraints are expressed with ``name[i] = prop`` where ``name`` is the name of the configuration, ``i`` is the position, ``prop`` is a property for example:\n\n``row[2] = green;``\n\n### Counting Constraints.\nCounting constraints count either entities or parts that satisfy some property in the configuration. For example:\n\n``#row & squares = 2``\n\nstates that the number of squares in a row is 2. Here we can also use any of ``=,!=,<,<=,>,>=``.\nCounting constraints can be nested in partitions and compositions:\n\n`` #(#part & green = 3) = 1;``\n\nthe keyword ``part`` denotes a generic subset of a partition/configuration.\n",
    "bugtrack_url": null,
    "license": "GNU General Public License (GPL)",
    "summary": "A solver for combinatorics math word problems.",
    "version": "1.1.5",
    "project_urls": {
        "Homepage": "https://github.com/PietroTotis/CoSo"
    },
    "split_keywords": [
        "combinatorics",
        "automated",
        "reasoning"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c7004624a8c6bb0a5091b9668aa03c179181673e334713da4958adc6df1e2d2a",
                "md5": "1edc12421d3205d438513dcaea0f4541",
                "sha256": "8e1f62b66b80d0f70845d183e61974c9c9622f21621e04219db48f1251bd279b"
            },
            "downloads": -1,
            "filename": "coso-1.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1edc12421d3205d438513dcaea0f4541",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 96950,
            "upload_time": "2023-05-28T16:42:13",
            "upload_time_iso_8601": "2023-05-28T16:42:13.737936Z",
            "url": "https://files.pythonhosted.org/packages/c7/00/4624a8c6bb0a5091b9668aa03c179181673e334713da4958adc6df1e2d2a/coso-1.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "99f74eb788ee15b8fca4f73cae893c8274caf254ebc615175d840d2d93de78df",
                "md5": "4d6ac029671bfdbbb65200e92af98a8d",
                "sha256": "65ef230a0707ecaa18ba56a06d652028072341e66c7a5c305da77dafbe937226"
            },
            "downloads": -1,
            "filename": "coso-1.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "4d6ac029671bfdbbb65200e92af98a8d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 89389,
            "upload_time": "2023-05-28T16:42:16",
            "upload_time_iso_8601": "2023-05-28T16:42:16.399774Z",
            "url": "https://files.pythonhosted.org/packages/99/f7/4eb788ee15b8fca4f73cae893c8274caf254ebc615175d840d2d93de78df/coso-1.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-28 16:42:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "PietroTotis",
    "github_project": "CoSo",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "coso"
}
        
Elapsed time: 0.10939s