真理表

「決定不能の論理パズル ゲーデルの定理と様相論理」レイモンド・スマリヤン、が本棚から出てきた。めちゃめちゃに面白いんだけど最後まで読み切れていない本の一つ。

思いつきで真理表を出力してみた。

(use util.combinations)
(use util.match)

(define (table)
  (print "p q (p ∧ q) (p ∨ q) (p ⊃ q) (p ≡ q)")
  (for-each (match-lambda
		((p q)
		 (format #t "~5a ~5a ~5a ~5a ~5a ~5a ~%" p q
			 (and p q)
			 (or p q)
			 (if p q #t)
			 (if (or (and p q) (and (not p) (not q)))
			     #t
			     #f))))
	    (cartesian-product '((#t #f) (#t #f)))))
gosh> (table)
p q (p  q) (p  q) (p  q) (p  q)
#t    #t    #t    #t    #t    #t    
#t    #f    #f    #t    #f    #f    
#f    #t    #f    #t    #t    #f    
#f    #f    #f    #f    #t    #t