Skip to content

Instantly share code, notes, and snippets.

@florence
Created February 14, 2014 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save florence/8996545 to your computer and use it in GitHub Desktop.
Save florence/8996545 to your computer and use it in GitHub Desktop.
logic is silly
#lang racket
(require redex)
(current-cache-all? #t)
(define-language L
(e x t f (e ∧ e) (e ∨ e) (¬ e) (e → e))
(x variable-not-otherwise-mentioned))
(define-extended-language LC L
(C hole
(C ∧ e) (e ∧ C)
(C ∨ e) (e ∨ C)
(¬ C)
(C → e)
(e → C)))
(define R
(reduction-relation
LC
#:domain e
;; true and false
(--> (in-hole C (e ∧ (¬ e)))
(in-hole C f))
(--> (in-hole C ((¬ e) ∧ e))
(in-hole C f))
(--> (in-hole C (e ∨ (¬ e)))
(in-hole C t))
(--> (in-hole C ((¬ e) ∨ e))
(in-hole C t))
(--> (in-hole C (e ∧ (¬ e)))
(in-hole C f))
(--> (in-hole C ((¬ e) ∧ (¬ e)))
(in-hole C f))
(--> (in-hole C ((¬ e) ∧ e))
(in-hole C f))
(--> (in-hole C ((¬ e) ∨ e))
(in-hole C t))
;; commutitivity of and and or
(--> (in-hole C (e_1 ∧ (e_2 ∧ e_3)))
(in-hole C ((e_1 ∧ e_2) ∧ e_3)))
(--> (in-hole C ((e_1 ∧ e_2) ∧ e_3))
(in-hole C (e_1 ∧ (e_2 ∧ e_3))))
#;(--> (in-hole C (e_1 ∨ (e_2 ∨ e_3)))
(in-hole C ((e_1 ∨ e_2) ∨ e_3)))
#;(--> (in-hole C ((e_1 ∨ e_2) ∨ e_3))
(in-hole C (e_1 ∨ (e_2 ∨ e_3))))
;; double ands and ors
(--> (in-hole C (e ∧ e))
(in-hole C e))
(--> (in-hole C (e ∨ e))
(in-hole C e))
;; demorgan is silly
(--> (in-hole C (¬ (e_1 ∧ e_2)))
(in-hole C ((¬ e_1) ∨ (¬ e_2)))
δ_∧)
(--> (in-hole C (¬ (e_1 ∨ e_2)))
(in-hole C ((¬ e_1) ∧ (¬ e_2)))
δ_∨)
;; basics
(--> (in-hole C (¬ (¬ e_1)))
(in-hole C e_1)
¬¬s)
(--> (in-hole C (e_1 → e_2))
(in-hole C ((¬ e_1) ∨ e_2))
i)))
(apply-reduction-relation* R (term (¬ (¬ x))))
(apply-reduction-relation* R (term ((a ∨ (¬ b)) → ((c ∧ a) ∨ b))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment