Skip to content

Instantly share code, notes, and snippets.

@AlecsFerra
Created August 1, 2022 16:29
Show Gist options
  • Save AlecsFerra/bef379e4120d9974d4a05d5d12f7f8a6 to your computer and use it in GitHub Desktop.
Save AlecsFerra/bef379e4120d9974d4a05d5d12f7f8a6 to your computer and use it in GitHub Desktop.
Some proofs bout pairs
;; Some proofs about pairs
;; ∀ a b c. a = b → (a, c) = (b, c)
(claim a=b→ac=bc
(Π ([T U]
[K U]
[a T]
[b T]
[c K]
[_ (= T a b)])
(= (Pair T K) (cons a c) (cons b c))))
(define a=b→ac=bc
(λ (T K a b c a=b)
(replace a=b
(λ (b)
(= (Pair T K) (cons a c) (cons b c)))
(same (cons a c)))))
;; ∀ a b c d. a = b & c = d → (a, c) = (b, d)
(claim a=bc=d→ac=bd
(Π ([T U]
[K U]
[a T]
[b T]
[c K]
[d K]
[_ (= T a b)]
[_ (= K c d)])
(= (Pair T K) (cons a c) (cons b d))))
(define a=bc=d→ac=bd
(λ (T K a b c d a=b c=d)
(replace c=d
(λ (d)
(= (Pair T K) (cons a c) (cons b d)))
(a=b→ac=bc T K a b c a=b))))
;; ∀ a b c d. (a, c) = (b, d) → a = b & c = d
(claim ac=bd→a=bc=d
(Π ([T U]
[K U]
[a T]
[b T]
[c K]
[d K]
[_ (= (Pair T K) (cons a c) (cons b d))])
(Pair (= T a b) (= K c d))))
(define ac=bd→a=bc=d
(λ (T K a b c d ac=bd)
(cons
(replace ac=bd
(λ (bd)
(= T a (car bd)))
(same a))
(replace ac=bd
(λ (bd)
(= K c (cdr bd)))
(same c)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment