Skip to content

Commit

Permalink
misc lemmas
Browse files Browse the repository at this point in the history
  • Loading branch information
fredokun committed Dec 1, 2023
1 parent f08ae41 commit fe6867a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/latte_prelude/equal.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

[latte.utils :refer [decomposer set-opacity!]]
[latte.core :as latte :refer [definition defthm defimplicit defimplicit*
assume have qed proof]]
assume have qed proof try-proof]]

[latte-prelude.utils :as pu]
[latte-prelude.prop :as p :refer [<=> and or not]]
Expand Down Expand Up @@ -102,6 +102,21 @@ Proves `(equal y x)` from `eq-proof` by symmetry of equality, cf. [[eq-sym-thm]]

(alter-meta! #'eq-sym update-in [:arglists] (fn [_] (list '[[eq-proof (equal x y)]])))

(defthm not-eq-sym
[?T :type, x T, y T]
(==> (not (equal x y))
(not (equal y x))))

(proof 'not-eq-sym-thm
(assume [Heq (not (equal x y))]
(assume [Hcontra (equal y x)]
(have <a> (equal x y) :by (eq-sym Hcontra))
(have <b> p/absurd :by (Heq <a>))))

(qed <b>))



(defthm eq-trans-thm
"The transitivity property of equality."
[T :type, [x y z T]]
Expand Down
20 changes: 19 additions & 1 deletion src/latte_prelude/fun.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ as objects and functions as arrows in the so-called *LaTTe category*."
(:refer-clojure :exclude [and or not identity])

(:require [latte.core :as latte :refer [definition defaxiom defthm defnotation
proof assume have pose qed
proof try-proof assume have pose qed
forall lambda]]
[latte-prelude.prop :as p :refer [and or not]]
[latte-prelude.equal :as eq :refer [equal]]
Expand Down Expand Up @@ -222,6 +222,24 @@ as objects and functions as arrows in the so-called *LaTTe category*."
(==> (equal (f x) (f y))
(equal x y))))

(defthm injective-contra
"The contrapositive of [[injective]]."
[[?T ?U :type], f (==> T U)]
(==> (injective f)
(forall [x y T]
(==> (not (equal x y))
(not (equal (f x) (f y)))))))

(proof 'injective-contra-thm
(assume [Hinj _]
(assume [x T y T
Hneq (not (equal x y))]
(assume [Hcontra (equal (f x) (f y))]
(have <a> (equal x y) :by (Hinj x y Hcontra))
(have <b> p/absurd :by (Hneq <a>)))))

(qed <b>))

(definition surjective
"A surjective function."
[[?T ?U :type], f (==> T U)]
Expand Down

0 comments on commit fe6867a

Please sign in to comment.