propositional

Crates.iopropositional
lib.rspropositional
version0.1.0-alpha.2
sourcesrc
created_at2024-06-28 09:23:22.23026
updated_at2024-07-01 19:25:49.010197
descriptionPropositional Logic
homepage
repositoryhttps://github.com/PawelJastrzebski/propositional
max_upload_size
id1286580
size16,939
Paweł Jastrzebski (PawelJastrzebski)

documentation

README

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.

Commit count: 3

cargo fmt