{"id":17946576,"url":"https://github.com/khaledhosseini/propositional-logic","last_synced_at":"2025-03-24T20:32:47.777Z","repository":{"id":259674566,"uuid":"866968212","full_name":"KhaledHosseini/propositional-logic","owner":"KhaledHosseini","description":"propositional logic evaluator that creates truth tables for propositional expressions, written in rust.","archived":false,"fork":false,"pushed_at":"2024-10-28T16:54:56.000Z","size":6362,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-19T04:14:14.995Z","etag":null,"topics":["boolean-expression","boolean-logic","propositional-logic","rust","rust-lang","truth-table","truth-table-generator"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/boolean-logic","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KhaledHosseini.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-03T08:02:09.000Z","updated_at":"2025-03-04T15:38:38.000Z","dependencies_parsed_at":"2024-10-27T09:07:10.079Z","dependency_job_id":null,"html_url":"https://github.com/KhaledHosseini/propositional-logic","commit_stats":null,"previous_names":["khaledhosseini/propositional-logic"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhaledHosseini%2Fpropositional-logic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhaledHosseini%2Fpropositional-logic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhaledHosseini%2Fpropositional-logic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhaledHosseini%2Fpropositional-logic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KhaledHosseini","download_url":"https://codeload.github.com/KhaledHosseini/propositional-logic/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245348304,"owners_count":20600623,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boolean-expression","boolean-logic","propositional-logic","rust","rust-lang","truth-table","truth-table-generator"],"created_at":"2024-10-29T07:06:27.757Z","updated_at":"2025-03-24T20:32:46.356Z","avatar_url":"https://github.com/KhaledHosseini.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Propositional logic evaluator.\nSupported operators and symbols:\n- Not: `not`, `¬`, `!`, `∼`\n- And: `and`, `\u0026`, `\u0026\u0026`, `∧`\n- Or: `or`, `|`, `||`, `∨`\n- XOr: `xor`, `⊕`\n- Implication: `-\u003e`, `=\u003e`, `⇒`, `→`, `⊃`\n- Biconditional: `\u003c-\u003e`, `\u003c=\u003e`, `⇔`, `↔`, `iff`, `xnor`\n- Logical equivalence: `=`, `==`, `eq`, `≡`\n- Not equal: `!=`, `≠`\n- parentheses: `()`, `{}`, `[]`\n- True: `1`, `true`, `True`\n- False: `0`, `false`, `False`\n- Variables: `a-z`, `A-Z`\n\n**Note**: the order of evaluation of operators are: `not`, `and`, `or`, `xor`, `→`, `↔`, `≡` and `≠`. Please use parentheses in order to adjust the operator priorities. incorrect expressions result in wrong tables.\u003c/br\u003e\n\n**Note**: Characters are case sensetive. for example `q` is not the same as `Q`.\n\nExample: \u003c/br\u003e\n- Truth table for `P ∨ (Q ∧ R) ≡ (P ∨ Q) ∧ (P ∨ R)` or `P or (Q and R) == (P or Q) and (P or R)`\n\n| P     | Q     | R     | (Q ∧ R) | (P ∨ (Q ∧ R)) | (P ∨ Q) | (P ∨ R) | ((P ∨ Q) ∧ (P ∨ R)) | ((P ∨ (Q ∧ R)) ≡ ((P ∨ Q) ∧ (P ∨ R))) |\n|-------|-------|-------|---------|---------------|---------|---------|---------------------|---------------------------------------|\n| true  | true  | true  | true    | true          | true    | true    | true                | true                                  |\n| true  | true  | false | false   | true          | true    | true    | true                | true                                  |\n| true  | false | true  | false   | true          | true    | true    | true                | true                                  |\n| true  | false | false | false   | true          | true    | true    | true                | true                                  |\n| false | true  | true  | true    | true          | true    | true    | true                | true                                  |\n| false | true  | false | false   | false         | true    | false   | false               | true                                  |\n| false | false | true  | false   | false         | false   | true    | false               | true                                  |\n| false | false | false | false   | false         | false   | false   | false               | true                                  |\n\n\n- Truth table for `(P ∧ (∼ Q)) ⇔ (P ⇒ Q)` or `(P and (not Q) \u003c-\u003e (P -\u003e Q))`\n\n| P     | Q     | ¬Q    | (P ∧ ¬Q) | (P → Q) | ((P ∧ ¬Q) ↔ (P → Q)) |\n|-------|-------|-------|----------|---------|----------------------\n| true  | true  | false | false    | true    | false                |\n| true  | false | true  | true     | false   | false                |\n| false | true  | false | false    | true    | false                |\n| false | false | true  | false    | true    | false                |\n\n- Truth table for `not true or not false`\n\n| P     | Q    | ¬P   | ¬Q    | (¬P ∨ ¬Q) |\n|-------|------|------|-------|-----------\n| false | true | true | false | true      |\n\n# How to run\n1. install `rust`. see [here](https://www.rust-lang.org/tools/install) for the instructions.\n2. run `cargo run` to run the app.\n3. run `cargo test` to run the tests.\n\n# How to use\nYou can export the truth tables to one of the following formats or print it to terminal.\n- csv\n- html\n- pdf (at the moment, does not support displaying some math characters)\n\n```rust\n    let s = \"(P and not Q) \u003c-\u003e (P -\u003e Q)\";//\"(P ∧ (∼ Q)) ⇔ (P ⇒ Q)\";\n    let tokens = Tokens::from_text(s);\n    match Evaluator::new(tokens) {\n        Ok(evaluator) =\u003e {\n            match evaluator.evaluate_all() {\n                Ok(result) =\u003e {\n                    print!(\"{}\\n\",result);\n                    // result.save_to_html(\"test.html\");\n                    // result.save_to_csv(\"test.csv\");\n                    // result.save_to_pdf(\"test.pdf\");\n                },\n                Err(error) =\u003e {\n                    println!(\"{}\",error);\n                },\n            }\n        },\n        Err(er) =\u003e {\n            println!(\"{}\",er);\n        },\n    }\n```\n\nOr you can evaluate for specific values for `P` and `Q` only.\n\n```rust\n    let s = \"(∼ P) ∨ (∼ Q)\";\n    let tokens = Tokens::from_text(s);\n    let evaluator = Evaluator::new(tokens).unwrap();\n    let mut values = IndexMap::\u003cchar,bool\u003e::new();\n    values.insert('P', false);\n    values.insert('Q', true);\n    let mut result = evaluator.evaluate(\u0026values).unwrap();\n    for v in values.iter().rev() {\n        result.insert_before(0, (*v.0).into(), *v.1);\n    }\n    let result = evaluator_result::EvaluatorResult{result:vec![result]};\n    println!(\"{}\",result);\n    // result.save_to_html(\"test.html\");\n    // result.save_to_csv(\"test.csv\");\n    // result.save_to_pdf(\"test.pdf\");\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhaledhosseini%2Fpropositional-logic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkhaledhosseini%2Fpropositional-logic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhaledhosseini%2Fpropositional-logic/lists"}