1
0
Fork
You've already forked infeR
0
forked from KRRR-Lab/infeR
Reimplementation of Inference tool InfOCF-Lib in Rust.
Rust 71.8%
TeX 22.2%
HTML 4.8%
Typst 1.2%
2024年12月29日 14:22:52 +01:00
.woodpecker use alpine image for building 2024年12月29日 14:22:52 +01:00
conditional_logic fix: #15,#16,#17, rm prolog stuff, implement z3-driven inference 2024年12月28日 11:25:08 +01:00
interfaces feat: #3 , rm usage of splitter in public api 2024年12月16日 00:03:02 +01:00
logger feat: #2 , kind of documentation, but just a simple readme file 2024年12月05日 17:40:04 +01:00
logic chore: Release 2024年12月28日 11:25:40 +01:00
logical_builders feat: Consolidate methods and trait implementations for PropositionalFormula 2024年12月23日 21:11:26 +01:00
preferential_logic tidy ( #19 ) 2024年12月28日 17:26:54 +00:00
propositional_logic fix: more sensible test 2024年12月26日 17:20:56 +01:00
syntax_splitting feat: #15 , refine error handling in tests 2024年12月21日 21:19:14 +01:00
writing small modifications, skeleton stage Nr. 03 2024年12月26日 17:12:33 +01:00
.gitignore small modifications, skeleton stage Nr. 03 2024年12月26日 17:12:33 +01:00
bacon.toml feat: refine clippy usage 2024年12月16日 00:03:20 +01:00
benchmark_results first benchmarking of parallelisation 2024年11月09日 15:35:38 +01:00
Cargo.toml feat: #15 , basic reimpl 2024年12月10日 21:32:02 +01:00
LICENSE Initial commit 2022年12月24日 17:21:17 +00:00
README.md fix : #2 , update to integrate z3 2024年12月17日 19:46:02 +01:00
rustfmt.toml fmt 2024年10月26日 18:25:45 +02:00
times.md update measures 2024年12月24日 14:00:39 +01:00

infeR

infeR is a Rust-based reimplementation of the Inference tool InfOCF-Lib, focusing on foundational components for signature creation, formula manipulation, and syntax splitting of total preorders. This project serves as a robust base for developing advanced algorithms in propositional and preferential logic.

Basic and Advanced Propositional Logic Crate

This Rust crate provides tools for constructing, manipulating, and reasoning with propositional Logic formulas, supporting canonical forms, formula builders, and the Quine-McCluskey algorithm for minimization. It also provides the capabilities to construct total preorders on propositional interpretations and perform syntax splitting on those total preorders.

Due to the increasing size of functionalities in this crate, i have modularized the README.md into each submodule. So while i will give a small high level example of how to use the crate in here, i will give more detailled examples in the according sub-readme.

Overview

The repository is organized into multiple subcrates, each addressing specific aspects of logical inference and manipulation:

  • Propositional Logic: Tools for constructing, manipulating, and reasoning with propositional logic formulas. Features include canonical forms, formula builders, and the Quine-McCluskey algorithm for formula minimization.
  • Preferential Logic: Utilities for building and managing total preorders, ranking functions, and performing syntax splitting. This subcrate leverages propositional signatures and interpretations to facilitate complex logical operations.
  • Logical Builders: A suite of builder utilities for incrementally constructing logical components such as formulas, signatures, variable lists, layer mappings, and total preorders. Ensures robust error handling and ease of use through a fluent API.
  • Syntax Splitting: Functionality for decomposing propositional signatures into independent subsets, enabling modular reasoning and analysis within logical frameworks.
  • Interfaces: Play with the components using a user-friendly interface of your choice ### WORK IN PROGRESS ###

Features

  • Formula Construction: Build complex propositional formulas with logical operators using builder patterns.
  • Signature Management: Define and manipulate propositional signatures and variable lists with ergonomic APIs.
  • Canonical Forms & Minimization: Generate canonical disjunctive normal forms and minimize formulas using the Quine-McCluskey algorithm.
  • Total Preorders: Create and manage total preorders over propositional interpretations, essential for preferential logic.
  • Syntax Splitting: Decompose total preorders into independent variable subsets for modular analysis.
  • Conditional Compilation: Enable or disable specific functionalities via Cargo features to customize your build.

Conditional Compilation

The project leverages Rust's conditional compilation to provide flexibility and modularity. Optional features can be enabled or disabled in your Cargo.toml to include or exclude specific functionalities:

  • preferentials: Integrates the preferential_logic crate, enabling preferential logic capabilities.
  • splitting: Enables the syntax_splitting crate for syntax splitting functionalities.
  • builders: Enables the logical_builders crate for ergonomically building logical structures.
  • interface: Enables the interfaces crate for using the logical structures provided in this project with a convenient web interface, a CLI, or a TUI.

Example Cargo.toml Configuration:

[dependencies]
propositional_logic = "0.0.0"
preferential_logic = { version = "0.0.0", features = ["preferentials"] }
syntax_splitting = { version = "0.0.0", features = ["splitting"] }
logical_builders = "0.0.0"

Getting Started

Prerequesites

  • Rust: Install the Rust toolchain from rust-lang.org.
  • z3-Solver: Install the z3 Theorem Solver from z3, libclang and export the evironment variable, e.g. for ubuntu:
apt-get update && apt-get install -y clang z3
export LIBCLANG_PATH=/usr/lib/llvm-14/lib/

Installation

  1. Clone the repository:
git clone https://codeberg.org/Ypman/infeR.git
cd infeR
  1. Build the project in release mode:
cargo b --release
  1. Run main.rs:
cargo r

High Level Usage

After setting up the project, you can utilize the various subcrates to build and manipulate logical structures.

Example: Building a Propositional Formula with Syntax Splitting Enabled

To include preferential_logic exclusively:

[dependencies]
propositional_logic = "0.0.0"
logical_builders = { default-features = false, features = ["preferentials"] }
// main.rs
uselogical_builders::{SignatureBuilder,LayerMappingBuilder,TotalPreOrderBuilder};fn main(){letsignature=SignatureBuilder::new().parse_from_literals("p, q").unwrap().build().unwrap();letlayer_mapping=LayerMappingBuilder::new().parse_from_literals("0,1,0,2").unwrap().build().unwrap();lettotal_preorder=TotalPreOrderBuilder::new().signature(signature).layer_mapping(layer_mapping).build().unwrap();println!("Constructed Total PreOrder: {}",total_preorder);// {(¬p ∧ ¬q)}, {(p ∧ ¬q)} ≺ {(¬p ∧ q)} ≺ {(p ∧ q)}
}

Pitfalls

  • Signature Compatibility: Ensure that all variables used in formulas are included in the PropositionalSignature. Missing variables can lead to interpretation errors and unexpected behavior.
  • Algorithm Complexity: Some algorithms, such as the Quine-McCluskey minimization, can be computationally intensive for formulas with a large number of variables. Optimize usage accordingly.
  • Conditional Features: Be mindful of the features enabled in your Cargo.toml. Enabling multiple features might increase compile times and binary sizes.

TODO

  • Enhance Documentation: Provide more comprehensive examples and detailed explanations for each subcrate.
  • Optimize Algorithms: Improve the performance of computationally intensive algorithms like Quine-McCluskey.
  • Expand Syntax Splitting: Implement more advanced syntax splitting techniques to handle complex logical structures.
  • Integrate Testing Frameworks: Develop extensive test suites to cover edge cases and ensure robustness.
  • Continuous Integration: Set up CI pipelines to automate testing and deployment processes.
  • User-Friendly CLI: Develop a command-line interface to interact with the library functionalities more easily.

Contributing

Contributions are welcome! Please ensure:

  • New code is well documented.
  • Tests cover edge case and expected functionality.
  1. Fork the project
  2. Create a feature branch: git checkout -b feature/<YourFeature>
  3. Commit changes: git commit -m 'Cause of your feature'
  4. Push to the branch: git push origin feature/<YourFeature>
  5. Open a pull request

License

This project is licensed under the GNU License.


Subcrates Overview

Below is a brief overview of each subcrate within the repository. For detailed information, refer to each subcrate's respective README.md.

Propositional Logic

propositional_logic provides tools for constructing, manipulating, and reasoning with propositional logic formulas. Supports canonical forms, formula builders, and minimization algorithms.

Preferential Logic

preferential_logic offers utilities for building and managing total preorders and ranking functions. Facilitates syntax splitting on total preorders to identify independent variable subsets.

Logical Builders

logical_builders provides collection of builder utilities for incrementally constructing logical components such as formulas, signatures, and total preorders. Ensures robust error handling and ease of use.

Syntax Splitting

syntax_splitting enables decomposition of propositional signatures into independent subsets, promoting modular reasoning and analysis within logical frameworks.

Interfaces

interfaces enables playing with logic in ergonomic interfaces like a web interface, a CLI (Command-Line Interface) or a TUI (Terminal-Line Interface). WORK IN PROGRESS!