Skip to main content

Parser for the Universal Variability Language (UVL) with conversion support to CNF/SMT

Project description

uvllang logo

uvllang

A Python parser for the Universal Variability Language (UVL). Supports conversion to CNF (DIMACS), SMT-LIB 2, and recovery of UVL models from DIMACS files.

Two parser backends are available: Lark (default, pure Python) and ANTLR.

Installation

pip install uvllang

# With ANTLR parser support
pip install uvllang[antlr]

CLI tools

uvl2cnf — UVL to DIMACS CNF

uvl2cnf model.uvl                 # writes model.dimacs
uvl2cnf model.uvl output.dimacs   # explicit output path
uvl2cnf model.uvl -v              # list ignored non-Boolean constraints
uvl2cnf model.uvl --antlr         # use ANTLR parser

uvl2smt — UVL to SMT-LIB 2

uvl2smt model.uvl                 # writes model.smt2
uvl2smt model.uvl output.smt2
uvl2smt model.uvl -v              # show model statistics
uvl2smt model.uvl --antlr

any2uvl — DIMACS CNF to UVL

Recovers a UVL feature model from a DIMACS file. Hierarchy is reconstructed via a spanning-tree heuristic; remaining clauses become cross-tree constraints.

any2uvl model.dimacs              # writes model_recovered.uvl
any2uvl model.dimacs output.uvl
any2uvl --optimize model.dimacs   # run CTC-reduction optimiser after recovery
any2uvl --byname model.dimacs     # break hierarchy tie-breaks by feature name similarity

The --optimize pass groups features that share common implied parents and moves them into the hierarchy, reducing cross-tree constraints where valid (verified by DIMACS equivalence check).

--byname affects the initial spanning-tree construction: when two candidate parents are at equal depth, the one whose name is most similar to the child (by edit-distance ratio) wins. Combine with --optimize for best results.

Python API

from uvllang import UVL

model = UVL(from_file="model.uvl")

# CNF (PySAT CNF object)
cnf = model.to_cnf()
cnf.to_file("output.dimacs")

# SMT-LIB 2
smt = model.to_smt()
with open("output.smt2", "w") as f:
    f.write(smt)

# DIMACS → UVL recovery
UVL.from_cnf("model.dimacs", "recovered.uvl", optimize=True, by_name=True)

Dependencies

  • lark — default parser
  • python-sat — CNF handling
  • sympy — Boolean constraint processing
  • antlr4-python3-runtime — optional, required for --antlr
  • z3-solver — optional, for solving SMT output

Testing

pip install -e .[dev]
pytest tests/

Citation

@article{UVL2024,
  title   = {UVL: Feature modelling with the Universal Variability Language},
  journal = {Journal of Systems and Software},
  volume  = {225},
  pages   = {112326},
  year    = {2025},
  doi     = {https://doi.org/10.1016/j.jss.2024.112326},
  author  = {David Benavides and Chico Sundermann and Kevin Feichtinger and José A. Galindo and Rick Rabiser and Thomas Thüm}
}

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uvllang-0.3.1.tar.gz (55.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uvllang-0.3.1-py3-none-any.whl (50.2 kB view details)

Uploaded Python 3

File details

Details for the file uvllang-0.3.1.tar.gz.

File metadata

  • Download URL: uvllang-0.3.1.tar.gz
  • Upload date:
  • Size: 55.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for uvllang-0.3.1.tar.gz
Algorithm Hash digest
SHA256 49c3201ff547bc4164abe766bada0bd511a15d005be23094693e9486740f15f1
MD5 b815141617c05278122e7a98ba0afa42
BLAKE2b-256 29d8b8cac6d96b10b22ec07988e386fb3782f270bebc891d1fd0631aeb3c43a6

See more details on using hashes here.

File details

Details for the file uvllang-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: uvllang-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 50.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for uvllang-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4afca64b320f3c684f12af113dc9c57fa2c48da99e4e9c19272815234c167188
MD5 b4a5b6699220cfa642e6a02e2f01501e
BLAKE2b-256 74f9bdcbe02f3023b2767d9fb00d81fa3af14c8cc419533cb4955d4617f21061

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page