Skip to content

Latest commit

 

History

History
42 lines (35 loc) · 3.17 KB

README.md

File metadata and controls

42 lines (35 loc) · 3.17 KB

DeMorgan.jl

Classical logic truth table magma algebra

Truth table expressed as an algebraic magma with operations ¬, , , , , or alternatively !, &, |, -->, <--, <-->. Based on classical logic with TruthValues{N} and TruthTable{N,M}, the @truthtable macro assigns named variable propositional projections as generators of the truth. When using DeMorgan together with PrettyTables, the output is automatically formatted.

julia> using DeMorgan, PrettyTables

julia> @truthtable p q

julia> (p-->q)<-->(¬q-->¬p)
┌───┬───┬───────────┬──────┬──────┬───────────────────┐
│ p │ q │       pq │ ¬(q) │ ¬(p) │                 ⊤ │
│   │   │ ¬(q)¬(p) │      │      │ (pq)(¬(q)¬(p)) │
├───┼───┼───────────┼──────┼──────┼───────────────────┤
│ 111001 │
│ 100101 │
│ 011011 │
│ 001111 │
└───┴───┴───────────┴──────┴──────┴───────────────────┘

julia> @truthtable p q r

julia> ((p-->q)(q-->r))-->(p-->r)
┌───┬───┬───┬─────┬─────┬─────────────┬─────┬─────────────────────┐
│ p │ q │ r │ pq │ qr │ (pq)(qr) │ pr │                   ⊤ │
│   │   │   │     │     │             │     │ ((pq)(qr))(pr) │
├───┼───┼───┼─────┼─────┼─────────────┼─────┼─────────────────────┤
│ 11111111 │
│ 11010001 │
│ 10101011 │
│ 10001001 │
│ 01111111 │
│ 01010011 │
│ 00111111 │
│ 00011111 │
└───┴───┴───┴─────┴─────┴─────────────┴─────┴─────────────────────┘

With finitely generated truth basis, equivalence classes of truth expressions are formed and kept track of, including contradiction and tautology class expressions.