After reading this question many times, I think the main question is as follows:
Why do implications and forall behave differently from other notations, for example in the info-view hover feature, the click-through to see the definition, and print settings like set_option pp.notation false
/set_option pp.all true
?
As I state in my comment above, implication and forall are special in dependent type theory. They are not defined, but instead built into the logic itself. They are just instances of dependent function types (Pi types). An implication p -> q
can be thought of as the type of functions which take "proofs" of p
to "proofs" of q. Similarly, ∀ (x : A), r x
can be thought of as the type of dependent functions which take x : A
to a "proof" of r x
. Lean prints the term with one of three notations depending on circumstance, but they are all internally represented the same as the following examples show:
import Mathlib
-- logical implication
axiom p : Prop
axiom q : Prop
#check p → q -- p → q : Prop
#check ∀ (a : p), q -- p → q : Prop
#check Π (a : p), q -- p → q : Prop
#check (a : p) → q -- p → q : Prop
theorem ex1 (a : p) : q := sorry
#print ex1 -- theorem ex1 : p → q
-- function types
axiom A : Type
axiom B : Type
#check A → B -- A → B : Type
#check ∀ (a : A), B -- A → B : Type
#check Π (a : A), B -- A → B : Type
#check (a : A) → B -- A → B : Type
def ex2 (a : A) : B := sorry
#print ex2 -- def ex2 : A → B
-- forall
axiom r : A -> Prop
#check ∀ (x : A), r x -- ∀ (x : A), r x : Prop
#check Π (x : A), r x -- ∀ (x : A), r x : Prop
#check (x : A) → r x -- ∀ (x : A), r x : Prop
theorem ex3 (x : A) : r x := sorry
#print ex3 -- theorem ex3 : ∀ (x : A), r x
-- dependent function types
axiom C : A -> Type
#check ∀ (x : A), C x -- (x : A) → C x : Type
#check Π (x : A), C x -- (x : A) → C x : Type
#check (x : A) → C x -- (x : A) → C x : Type
def ex4 (x : A) : C x := sorry
#print ex4 -- def ex4 : (x : A) → C x
Now, it is also probably true Lean 4 could be better at conveying this information in the hovers, info view, and print settings. There is no print setting I know of which prints these all the same.
Also, you mention forall or exists being defined in terms of the other. This is common in classical first order logic, but it isn't generally true of dependent type theory (even dependent type theory with classical logic). There are many advantages of defining forall and exists in the way Lean does, where Exists is defined as a structure and forall is a Pi type.
I highly recommand the first four sections of Theorem Proving in Lean 4 for an explanation on this.
P -> Q
is the same as\forall (h : P), Q
, which is the same as(h : P) -> Q
. In other words it is the type of functions which take proofs ofP
and return proofs ofQ
. $\endgroup$→
for∀
it does show the correct scope of the operator, and you can even see that for∀
in your image. $\endgroup$