Metadata-Version: 2.4
Name: logic-asts
Version: 1.1.2
Summary: Grammars and parsers for various logic
Author-email: Anand Balakrishnan <anandbala1597@gmail.com>
License: BSD 2-Clause License
        
        Copyright (c) 2025, Anand Balakrishnan
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: attrs>=25.3.0
Requires-Dist: lark>=1.2.2
Requires-Dist: typing-extensions>=4.13.0
Description-Content-Type: text/markdown

# Logic ASTs: Abstract Syntax Trees for Logical Specifications

A collection of grammars, parsers, and abstract syntax trees (ASTs) for various
logical formalisms.

The goal is to serve as a reusable foundation for academics and developers
building tools that require logical expression parsing and manipulation,
eliminating the need to create new parsers for each application.

## Supported Logics

The library implements complete support for four logical systems:

1. **Propositional Logic (base)**:
   Classical Boolean logic with conjunction, disjunction, negation, implication,
   equivalence, and exclusive-or operators.

2. **Linear Temporal Logic (ltl)**:
   Temporal extension adding operators for reasoning about sequences of states
   over time.
   Includes Next (X), Eventually (F), Always (G), and Until (U) operators with
   optional time constraints.

3. **Spatio-Temporal Reach-Escape Logic (strel)**:
   Combines temporal and spatial reasoning for multi-agent and distributed
   systems.
   Adds spatial operators (Everywhere, Somewhere, Reach, Escape) with distance
   constraints.

4. **Signal Temporal Logic with Graph Operators (stl_go)**:
   Extends temporal logic with graph-based operators for specifying properties
   over multi-agent communication networks.
   Includes incoming and outgoing edge quantifiers with weight and count
   constraints.

## Installation

Install from the repository:

```bash
pip install git+https://github.com/yourusername/logic-asts.git
```

Or, once available on PyPI:

```bash
pip install logic-asts
```

## Quick Start

Parse logical expressions:

```python
import logic_asts

# Propositional logic
prop = logic_asts.parse_expr("(p & q) | ~r", syntax="base")

# Linear temporal logic
ltl = logic_asts.parse_expr("G(request -> F response)", syntax="ltl")

# Spatio-temporal logic
strel = logic_asts.parse_expr("G everywhere[0,5] ~obstacle", syntax="strel")

# Graph-based temporal logic
stl_go = logic_asts.parse_expr("in^[0,1]{E}_{c}[1,n] consensus", syntax="stl_go")
```

Create expressions programmatically:

```python
from logic_asts.base import Variable, And, Or, Not
from logic_asts.ltl import Eventually, TimeInterval

p = Variable("p")
q = Variable("q")

# (p & q) | ~p
formula = (p & q) | ~p

# F[0,10] (p & q)
temporal = Eventually(p & q, TimeInterval(0, 10))
```

Evaluate propositional formulas:

```python
from logic_asts.base import simple_eval

p = Variable("p")
q = Variable("q")
formula = p & q

# Evaluate: p=true, q=true -> Result: true
result = simple_eval(formula, {"p", "q"})

# Evaluate: p=true, q=false -> Result: false
result = simple_eval(formula, {"p"})
```

## Contributing

Contributions are welcome.
Please ensure all tests pass and documentation is updated for new features.

## License

This project is licensed under the BSD 2-clause license.
