Skip to content

Classical logic truth table magma algebra

License

Notifications You must be signed in to change notification settings

chakravala/DeMorgan.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.