py-aiger-discrete
Library for modeling functions over discrete sets using aiger circuits.
Installation
If you just need to use py-aiger-discrete, you can just run:
$ pip install py-aiger-discrete
For developers, note that this project uses the poetry python package/dependency management tool. Please familarize yourself with it and then run:
$ poetry install
About
This library helps with modeling functions over finite sets using circuits.
f : A → B₁ × B₂ × … × Bₘ
where A ⊆ A₁ × A₂ × … × Aₙ.
This is done by providing:
- A encoder/decoder pair for each set to and from (unsigned) integers.
- A circuit that uses the bit-vector representation of these integers
to compute
f. - A circuit that monitors if the input bit-vector sequence is
valid, i.e., a member ofA.
Functionally, the py-aiger-discrete library centers around the
aiger_discrete.FiniteFunc class which has 4 attributes an aiger_bv.AIGBV object.
- A string
valid_idindicating - A circuit,
circ, over named bit-vectors in the form of anaiger_bv.AIGBVobject. One of the outputs must be namedvalid_id. - A mapping from inputs to
aiger_discrete.Encodingobjects which encode/decode objects to integers. The standard bit-encoding of unsigned integers is feed intocirc. - A mapping from outputs to
aiger_discrete.Encodingobjects which encode/decode objects to integers. These encodings are used to decode the resulting bit-vectors ofcirc.
Usage
Below we provide a basic usage example. This example assumes basic
knowledge of the py-aiger ecosystem and particularly py-aiger-bv.
import aiger_bv as BV
from aiger_discrete import Encoding, from_aigbv
# Will assume inputs are in 'A', 'B', 'C', 'D', or 'E'.
ascii_encoder = Encoding(
decode=lambda x: chr(x + ord('A')), # Make 'A' map to 0.
encode=lambda x: ord(x) - ord('A'),
)
# Create function which maps: A -> B, B -> C, C -> D, D -> E.
x = BV.uatom(3, 'x') # need 3 bits to capture 5 input types.
update_expr = (x + 1) & 0b111
circ = update_expr.with_output('y').aigbv
# Need to assert that the inputs are less than 4.
circ |= (x <= 4).with_output('##valid').aigbv
func = from_aigbv(
circ,
input_encodings={'x': ascii_encoder},
output_encodings={'y': ascii_encoder},
valid_id='##valid',
)
assert func('A') == 'B'
assert func('B') == 'C'
assert func('C') == 'D'
assert func('D') == 'E'
assert func('E') == 'A'
Note that py-aiger-discrete implements most of the circuit API as aiger_bv.AIGBV.
For example, sequential composition:
func12 = func1 >> func2
or parallel composition:
func12 = func1 | func2
or unrolling:
func_unrolled = func1.unroll(5)
or feedback:
func_cycle = func1.loopback({
'input': 'x',
'output': 'y',
'keep_output': True,
`input_encoder`: True,
`init`: 'A',
})
Note that feedback now supports additional flag per wiring description
called input_encoder which determines if the input or output
encoding is used for initial latch value resp. The default is the
input encoding.
or renaming:
func_renamed = func1['i', {'x': 'z'}]
assert func1.inputs == {'z'}
Metadata
Release files for py-aiger-discrete 0.1.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py-aiger-discrete-0.1.10.tar.gz | 7.7 kB | Without provenance | Details for py-aiger-discrete-0.1.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_aiger_discrete-0.1.10-py3-none-any.whl | Python 3 | none | any | Details for py_aiger_discrete-0.1.10-py3-none-any.whl |
Total release size: 15.1 kB
Release files / py-aiger-discrete-0.1.10.tar.gz
| Download URL | py-aiger-discrete-0.1.10.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
89a3448c04d9629ff572e972442d15cf444beedc76f9b1670dd6be496d66ce99
|
|
BLAKE2b-256 checksum How to use checksums |
4377ccac681e91d148053c95cd44b3be6b494525b0b370c8f70d0a2e071f78a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.9.13 Linux/6.0.0
|
Release files / py_aiger_discrete-0.1.10-py3-none-any.whl
| Download URL | py_aiger_discrete-0.1.10-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
946999bed701458e0678680ed0bac9b49305cef3712c313344961c5d05905a65
|
|
BLAKE2b-256 checksum How to use checksums |
c271d6b7bcc357dcac67b0ff0861f60268f785f732e255bbbe33bcc9aab16902
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.9.13 Linux/6.0.0
|
Security for py-aiger-discrete 0.1.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.