Construct the truth table for the statement
\[\begin{equation*} P \implies Q \> \equiv \> \lnot P \lor Q. \end{equation*} \]
(define (boolean-product length) "Return a list of all Boolean sequences of LENGTH." (let more-rows ((row (- (expt 2 length) 1))) (if (< row 0) (list) (cons (let more-columns ((column (- length 1))) (if (< column 0) (list) (cons (even? (quotient row (expt 2 column))) (more-columns (- column 1))))) (more-rows (- row 1)))))) (define (truth-table procedure arity) "Return a truth table for PROCEDURE with ARITY." (map (lambda (inputs) (append inputs (list (apply procedure inputs)))) (boolean-product arity))) (define (org-truth-table procedure headers) (append (list (map (lambda (header) (string-append "\\(" header "\\)")) headers)) (list (list)) (list (append (list "/") (make-list (- (length headers) 2) "") (list "<"))) (map (lambda (row) (map (lambda (value) (if value "true" "false")) row)) (truth-table procedure (- (length headers) 1))))) (org-truth-table (lambda (p q) (or (not p) q)) '("P" "Q" "P \\implies Q"))
\(P\) | \(Q\) | \(P \implies Q\) |
---|---|---|
false | false | true |
false | true | true |
true | false | false |
true | true | true |