propositional 0.1.0-alpha.2

Propositional Logic
Documentation
  • Coverage
  • 1.85%
    1 out of 54 items documented1 out of 37 items with examples
  • Size
  • Source code size: 16.62 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 4.13 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • PawelJastrzebski/propositional
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • PawelJastrzebski

Propositional Logic

This crate offers tools for defining and manipulating logical propositions using symbols and connectives like and, or, and implies. It simplifies the creation of logical expressions and the evaluation of their truth values within defined logical contexts.

Useful for educational purposes, AI projects, and any application requiring formal logical reasoning.

Examples

use propositional::prelude::*;

let rain = symbol!("it's raining");
let cloud = symbol!("it's cloudy");

let world = and!(
    implies!(rain, cloud),
    rain
);

println!("It is cloudy? {:?}", check(&world, &cloud));
//-> It is cloudy? Some(true)

Source: wikipedia.org

use propositional::prelude::*;

let rain = symbol!("It is raining.");
let hagrid = symbol!("Harry visited Hagrid.");
let dumbledore = symbol!("Harry visited Dumbledore.");

let knowledge = and!(
    implies!(not!(rain), hagrid),
    or!(hagrid, dumbledore),
    not!(and!(hagrid, dumbledore)),
    dumbledore
);

println!("It is raining? {:?}", check(&knowledge, &rain));
//-> It is raining? Some(true)

Source: CS50

Acknowledgments

Based on: CS50’s Introduction to Artificial Intelligence with Python.