Zulip Chat Archive
Stream: general
Topic: Formalizing St. Anselm's ontological argument
Bulhwi Cha (Oct 26 2023 at 12:33):
This might be the first second attempt in the Lean community to formalize an ontological argument for the existence of God in Lean. It's a modified version of the formulation of St. Anselm's ontological argument by Alvin Plantinga. (See 9.1 Formulation 1 of the SEP entry "Ontological Arguments.")
- God exists in the understanding but not in reality. (Assumption for reductio)
- Existence in reality is greater than existence in the understanding alone. (Premise)
- There exists a being in reality that can be conceived. (Modified premise)
- A being that exists in reality and can be conceived is greater than God. (From (1) and (2).)
- There exists a being that can be conceived and is greater than God. (From (3) and (4).)
- No being greater than God can be conceived. (From the definition of “God”.)
- Hence, it is false that God exists in the understanding but not in reality. (From (1), (5), (6).)
- God exists in the understanding. (Premise, to which even the Fool agrees.)
- Hence God exists in reality. (From (7), (8).)
- Git repository: https://git.sr.ht/~chabulhwi/lean-notes
- Lean code: https://git.sr.ht/~chabulhwi/lean-notes/tree/master/item/Notes/Anselm.lean
- English documentation: https://git.sr.ht/~chabulhwi/lean-notes/tree/master/item/docs/en/Anselm.md
- Korean documentation: https://git.sr.ht/~chabulhwi/lean-notes/tree/master/item/docs/ko/Anselm.md
Lean code (flawed)
Reference
Oppy, Graham, "Ontological Arguments", The Stanford Encyclopedia of Philosophy (Fall 2023 Edition), Edward N. Zalta & Uri Nodelman (eds.), URL = <https://plato.stanford.edu/archives/fall2023/entries/ontological-arguments/>.
Bulhwi Cha (Oct 26 2023 at 12:35):
I'll write more messages later. I don't think St. Anselm's demonstrates shows God's existence.
Eric Wieser (Oct 26 2023 at 12:43):
Unfortunately this argument is contradictory as formalized:
example : False :=
letI : Conceivable Unit := ⟨fun _ => True⟩
letI : InUnderstanding Unit := ⟨fun _ => False⟩
isGod_inUnderstanding (x := ()) ⟨trivial, fun _ => trivial⟩
Damiano Testa (Oct 26 2023 at 12:48):
Rather than "unfortunately", I guess you meant "and hence the proof of existence of God is complete", right?
Eric Wieser (Oct 26 2023 at 12:51):
Of course, what I should have said is "here's a much shorter proof":
def key :=
letI : Conceivable Unit := ⟨fun _ => True⟩
letI : InUnderstanding Unit := ⟨fun _ => False⟩
isGod_inUnderstanding (x := ()) ⟨trivial, fun _ => trivial⟩
theorem isGod_inReality : ∀ {x : Being}, isGod x → inReality x := key.elim
theorem not_isGod_inReality : ∀ {x : Being}, isGod x → ¬inReality x := key.elim
Bulhwi Cha (Oct 26 2023 at 12:57):
@Eric Wieser What if I remove variable {Being : Type u}
and add the axiom axiom Being.{u} : Type u
?
Fixed code (still flawed)
Eric Wieser (Oct 26 2023 at 13:00):
Nope:
def key : False :=
letI : Conceivable Being.{0} := ⟨fun _ => False⟩
letI : InReality Being := ⟨fun _ => False⟩
let ⟨b, h⟩ := exists_conceivable_and_inReality
h.2.elim
theorem isGod_inReality : ∀ {x : Being}, isGod x → inReality x := key.elim
theorem not_isGod_inReality : ∀ {x : Being}, isGod x → ¬inReality x := key.elim
Bulhwi Cha (Oct 26 2023 at 13:02):
Hmm, I should understand how letI
works. After all, It's just an exercise. Thanks anyway.
Damiano Testa (Oct 26 2023 at 13:03):
Gödel also had a proof of existence of God: maybe we should have a God
folder in Mathlib.
Eric Wieser (Oct 26 2023 at 13:03):
letI
is irrelevant here, this works fine without it:
def key : False :=
let ⟨b, h⟩ := @exists_conceivable_and_inReality.{0} ⟨fun _ => False⟩ ⟨fun _ => False⟩
h.2.elim
Bulhwi Cha (Oct 26 2023 at 13:06):
I actually want to make a counterargument to St. Anselm's argument. But I guess I can't formalize the modified version of the proof correctly in Lean.
Bulhwi Cha (Oct 26 2023 at 13:10):
Will replacing type classes with axioms fix my formalization?
Eric Wieser (Oct 26 2023 at 13:11):
I think so, but it would probably be better to put the axioms in a typeclass instead
Eric Wieser (Oct 26 2023 at 13:12):
If you use axioms, then if they're false you can prove anything. If you use a typeclass and get something wrong, you can prove that the typeclass cannot exist but it doesn't break trust anywhere else
Bulhwi Cha (Oct 26 2023 at 13:12):
Eric Wieser said:
I think so, but it would probably be better to put the axioms in a typeclass instead
Okay, I'll try that!
Bulhwi Cha (Oct 26 2023 at 13:47):
I made a new type class, Anselm
:
class Anselm (Being : Type u) extends LinearOrder Being where
conceivable : Being → Prop
inUnderstanding : Being → Prop
inReality : Being → Prop
lt_of_inUnderstanding_not_inReality_inReality {x y : Being} : inUnderstanding x → ¬ inReality x →
inReality y → x < y
isMax_conceivable_inUnderstanding {x : Being} : isMax x conceivable → inUnderstanding x
exists_conceivable_and_inReality : ∃ (x : Being), conceivable x ∧ inReality x
Fixed code (final)
Bulhwi Cha (Oct 26 2023 at 14:44):
Bulhwi Cha said:
- There exists a being in reality that can be conceived. (Modified premise)
Step 3 of the original formulation by Alvin Plantinga is the following premise: "A being having all of God’s properties plus existence in reality can be conceived." This premise is redundant. Since God is the greatest being that can be conceived, God itself can be conceived. Therefore, a being having all of God's properties can be conceived.
theorem isGod_conceivable {x : Being} : isGod x → conceivable x := And.left
Bulhwi Cha (Oct 26 2023 at 15:09):
I think we can only conclude from St. Anselm's argument that the following statement is true:
theorem isGod_inReality {x : Being} : isGod x → inReality x
This theorem doesn't state that God exists in reality. It merely says that if a being is God, it exists in reality. In order to prove the existence of God in reality, you need to show that ∃ (x : Being), isGod x ∧ inReality x
.
For this reason, I think St. Anselm's argument doesn't show God's existence. Of course, I might have formalized it wrong.
Chris Hughes (Oct 26 2023 at 16:44):
The existence of god has been proven in Isabelle. Google shows me a couple of formalisations. But IIRC, there was some problem with the hypotheses being inconsistent, similar to what Eric found.
Bulhwi Cha (Oct 26 2023 at 17:29):
Thanks. I'll check those out when I have more time. I hope we see a future where more philosophers try out Lean and use it to formalize subdisciplines of philosophy.
Ruben Van de Velde (Oct 26 2023 at 17:35):
I have a feeling we already have plenty of doctors of philosophy here
Alistair Tucker (Oct 26 2023 at 19:33):
Bulhwi Cha said:
Step 3 of the original formulation by Alvin Plantinga is the following premise: "A being having all of God’s properties plus existence in reality can be conceived." This premise is redundant. Since God is the greatest being that can be conceived, God itself can be conceived. Therefore, a being having all of God's properties can be conceived.
The way I see it, we are being asked to conceive of beings with a separated property of existence/nonexistence in reality, for which we may use a Bool
. Then premise 3 does have content:
class Anselm (Being : Type u) extends LinearOrder (Being × Bool) where
Conceivable : Being × Bool → Prop
premise3 : ∀ x : Being × Bool, IsMax x Conceivable → Conceivable (x.1, true)
Alistair Tucker (Oct 26 2023 at 19:38):
The ordering on Being × Bool
also makes it possible to transcribe premise 2 more faithfully
premise2 : ∀ x : Being, (x, false) < (x, true)
Bulhwi Cha (Oct 27 2023 at 05:15):
@Alistair Tucker If we adopt your view, inReality
should also be a predicate on Being × Bool
, not Being
.
def inReality (x : Being × Bool) := x.2 = true
Then we can't say that "Bulhwi exists in reality," since I'm not a pair of a being and its existence property. I'm a being. So I think inReality
should be a predicate on Being
.
Alistair Tucker (Oct 27 2023 at 06:37):
Bulhwi Cha said:
Then we can't say that "Bulhwi exists in reality," since I'm not a pair of a being and its existence property. I'm a being. So I think
inReality
should be a predicate onBeing
.
I don't understand this point. You may well be a hallucination of mine i.e. (bulhwi, false)
. If not then (bulhwi, true)
.
Bulhwi Cha (Oct 27 2023 at 07:05):
My point is that Bulhwi
is neither ⟨Bulhwi, true⟩
nor ⟨Bulhwi, false⟩
. I'm a being, not a pair of a being and its existence property. Bulhwi
's type is and should be Being
, not Being × Bool
.
Alistair Tucker (Oct 27 2023 at 07:09):
Well you need some way to map between an object not having the existence property to one that does, which currently you don't have.
Bulhwi Cha (Oct 27 2023 at 07:11):
How would you do that?
Alistair Tucker (Oct 27 2023 at 07:11):
I have outlined one way. I'm sure there are others.
Bulhwi Cha (Oct 27 2023 at 07:30):
I don't feel like creating a type, say, BeingNoExist
, of "beings separated from their existence properties" and considering the type Being
to be equal to BeingNoExist × Bool
. It presupposes that ∃ (α : Type u), Being = α × Bool
.
Hypatia du Bois-Marie (Oct 27 2023 at 23:04):
I was thinking of something similar this week! https://github.com/analytic-bias/agora
Hypatia du Bois-Marie (Oct 27 2023 at 23:07):
Eric Wieser said:
Unfortunately this argument is contradictory as formalized:
example : False := letI : Conceivable Unit := ⟨fun _ => True⟩ letI : InUnderstanding Unit := ⟨fun _ => False⟩ isGod_inUnderstanding (x := ()) ⟨trivial, fun _ => trivial⟩
I think that's exactly the point: formal methods yielding fierce recognition of human fallacies.
Bulhwi Cha (Oct 28 2023 at 07:12):
Bulhwi Cha said:
I think we can only conclude from St. Anselm's argument that the following statement is true:
theorem isGod_inReality {x : Being} : isGod x → inReality x
A user of a Korean-speaking philosophy discussion forum said, "You didn't prove that ∃ (x : Being), isGod x ∧ inReality x
is not a theorem of a theory whose axioms are the premises of St. Anselm's argument (and the axioms of Lean's type theory)."
Bulhwi Cha (Oct 28 2023 at 07:15):
That's true. So I'll rephrase my opinion:
I think the conclusion of St. Anselm's argument is the following statement:
theorem isGod_inReality {x : Being} : isGod x → inReality x
Uranus Testing (Oct 28 2023 at 16:08):
Interesting to see another approach to the ontological proof. I tried once (original version was written in Lean 3, later ported to 4) “classical” modal version: https://github.com/forked-from-1kasper/ground_zero/blob/9f83f7c6224eee8905b16aeebc4c234b4b216031/GroundZero/Theorems/Ontological.lean#L520-L521
Uranus Testing (Oct 28 2023 at 16:12):
Chris Hughes said:
The existence of god has been proven in Isabelle. Google shows me a couple of formalisations. But IIRC, there was some problem with the hypotheses being inconsistent, similar to what Eric found.
There are actually several versions of original Gödel’s proof that correct this issue.
David Michael Roberts (Oct 30 2023 at 08:25):
Cf https://arxiv.org/abs/2202.06264
Matt Diamond (Jan 18 2024 at 00:41):
Neat paper! I put together a proof that combines some ideas in there:
import Mathlib
opaque individual : Type
abbrev property : Type := individual → Prop
abbrev metaproperty : Type := property → Prop
-- Positive
opaque P : metaproperty
-- God-like
opaque G : property
notation "~" p => Not ∘ p
-- Either a property or its negation is positive, but not both
axiom axiom_1 : ∀ (ϕ : property), P (~ϕ) ↔ ¬P ϕ
-- A property entailed by a positive property is positive
axiom axiom_2 : ∀ ϕ ψ, (P ϕ ∧ (∀ x, (ϕ x → ψ x))) → P ψ
-- being God-like is a Positive property
axiom axiom_3 : P G
lemma not_top_eq_bot : (¬⊤) = ⊥ :=
by rw [Prop.top_eq_true, Prop.bot_eq_false, not_true_eq_false]
theorem empty_property_not_positive : ¬P (fun _ => ⊥) :=
by
intro h1
have h2 : P (fun _ => ⊤)
· apply axiom_2 (fun _ => ⊥) _
use h1
intros
trivial
have h3 := axiom_1 (fun _ => ⊤)
rw [Function.comp_def, not_top_eq_bot] at h3
rw [h3] at h1
exact h1 h2
theorem all_positive_properties_exemplified : P ϕ → ∃ x, ϕ x := by
intro ϕ_pos
by_contra h
apply empty_property_not_positive
apply axiom_2 ϕ _
use ϕ_pos
intros x hx
exact (h ⟨x, hx⟩).elim
theorem god_exists : ∃ x, G x := all_positive_properties_exemplified axiom_3
Matt Diamond (Jan 18 2024 at 00:41):
axiom_2
is pretty obviously the weak point... this shouldn't convince anyone but it was a fun little exercise
Kyle Miller (Jan 18 2024 at 03:15):
@Matt Diamond That's fun. I've switched it over to the language of sets. There, it's sort of like that P
has most of the axioms of an ultrafilter. axiom_2
is "upwards closed", axiom_3
is "nonempty", and axiom_1
is the ultrafilter property. What's missing is that pairwise intersections of positive properties are still positive. Even without it, the point is that the ultrafilter property implies that the empty set can't be in it, since it contradicts upwards closure applied to nonemptiness. Hence the G
set is nonempty.
import Mathlib
opaque individual : Type
abbrev property : Type := Set individual
abbrev metaproperty : Type := Set property
-- Positive
opaque P : metaproperty
-- God-like
opaque G : property
-- Either a property or its negation is positive, and not both
axiom axiom_1 : ∀ (ϕ : property), P ϕᶜ ↔ ¬P ϕ
-- A property entailed by a positive property is positive
axiom axiom_2 : ∀ ϕ ψ, ϕ ⊆ ψ → P ϕ → P ψ
-- being God-like is a Positive property
axiom axiom_3 : P G
theorem univ_positive : P Set.univ :=
axiom_2 G _ (Set.subset_univ _) axiom_3
theorem empty_property_not_positive : ¬P ∅ := by
rw [← axiom_1, Set.compl_empty]
exact univ_positive
theorem all_positive_properties_exemplified {ϕ : property} (hϕ : P ϕ) : ϕ.Nonempty := by
by_contra! h
cases h
exact empty_property_not_positive hϕ
theorem god_exists : G.Nonempty := all_positive_properties_exemplified axiom_3
Matt Diamond (Jan 18 2024 at 03:19):
nice!
Johan Commelin (Jan 18 2024 at 17:33):
In the paper, it seems that G
is a definition, instead of an axiom.
David Michael Roberts (Jan 19 2024 at 04:46):
I was thinking about how this works in constructive logic and you get a "not-not-exists" in that setting.
Matt Diamond (Jan 19 2024 at 04:49):
so constructively we can't prove God exists, but we can disprove atheism :big_smile:
Matt Diamond (Jan 19 2024 at 04:50):
@Johan Commelin re: the definition, that's true... I left it out because it was irrelevant to the proof
Johan Commelin (Jan 19 2024 at 06:56):
Fair enough. The benefit of defining it, is that it is one less axiom to dispute.
Johan Commelin (Jan 19 2024 at 07:01):
Matt Diamond said:
so constructively we can't prove God exists, but we can disprove atheism :big_smile:
Fun fact: there is a subfield of theology known as apophatic theology or negative theology (https://en.wikipedia.org/wiki/Apophatic_theology). It focuses on describing what God is not, as opposed to describing what God is.
For we explain not what God is but candidly confess that we have not exact knowledge concerning Him. For in what concerns God to confess our ignorance is the best knowledge
(Quoting Saint Cyril of Jerusalem, via the Wiki page.)
Johan Commelin (Jan 19 2024 at 07:04):
(Full disclosure: I believe in God. I also think that ontological arguments and existence-of-God proofs are missing the point.)
Jeremy Tan (Jan 19 2024 at 08:54):
(I believe that God does not exist)
David Michael Roberts (Jan 19 2024 at 09:03):
Amusingly, Anselm used the phrase "it cannot be nonexistent" (albeit not in English, of course....)
Kyle Miller (Jan 19 2024 at 10:54):
Matt Diamond said:
I left it out because it was irrelevant to the proof
I just looked at the paper, and it seems that this formalization is dropping the modal operators. This might be the proof if your modal operators have "modal collapse"?
If I understand it right, then this formalization is essentially adding in the additional hypothesis that we only care about this world and no other possible worlds.
Last updated: May 02 2025 at 03:31 UTC