1.6 KiB
1.6 KiB
statement logic !!!
things you can do with this:
general things
- parse string -> statement
- parse L (the formal language) string -> statement
- serialize a statement to plaintext, LaTeX, L (the formal language)
semantic things (statements have meaning I guess)
- evaluate statements
- from a statement generate a LaTeX truth table
- match/replace patterns in statements (e.g. logical laws)
- verify logical-law equivalence of statements (TODO)
- find logical-law equivalence of statements with breadth-first search
syntactic things (statements are strings of symbols)
- implement formal languages (symbols, axioms schemas, and inference rules): https://en.wikipedia.org/wiki/Post_canonical_system
- verify derivations in formal languages
formal languages implemented
- the MIU system (from "Gödel, Escher, Bach")
- L
Requirements
a haskell compiler e.g. GHC
Compile it
make
or look in Makefile
Usage
only this has been implemented in the main function:
echo '((p->q)<->(!q->!p))' | ./logic
Output
Iff (Implies (Atom "p") (Atom "q")) (Implies (Not (Atom "q")) (Not (Atom "p")))
Tautology
\begin{tabular}{cc||cccccc|c|cccccccc}
$p$ & $q$ & $($ & $($ & $p$ & $\to $ & $q$ & $)$ & $\leftrightarrow $ & $($ & $\neg $ & $q$ & $\to $ & $\neg $ & $p$ & $)$ & $)$ \\
\hline
0 & 0 & & & 0 & 1 & 0 & & \textbf 1 & & 1 & 0 & 1 & 1 & 0 & & \\
0 & 1 & & & 1 & 0 & 0 & & \textbf 1 & & 1 & 0 & 0 & 0 & 1 & & \\
1 & 0 & & & 0 & 1 & 1 & & \textbf 1 & & 0 & 1 & 1 & 1 & 0 & & \\
1 & 1 & & & 1 & 1 & 1 & & \textbf 1 & & 0 & 1 & 1 & 0 & 1 & & \\
\end{tabular}