Proof involving functions, ordered pairs and the graphs of functions

elementary-set-theorysolution-verification

I just finished Exercise 3.5.9 from Analysis I by Terrence Tao and would like to know if my approach is valid as it appeared to be a simple definition unpacking. The question is as follows

If $f : X → Y$ is a function, define the graph of $f$ to be the subset of $X \times Y$ defined by $\{(x, f(x)) : x ∈ X\}$. Show that two functions
$f : X → Y$ , $ \tilde{f} : X → Y$ are equal if and only if they have the same graph.

My proof is as follows:

Assume that $f$ and $\tilde{f}$ have the same graph. Let $x \in X$. We wish to show that $f(x)=\tilde{f}(x)$. As their graphs are equal and the functions are defined on the same domain and two sets are only equal iff all elements are equal we know that $(x,f(x))=(x,\tilde{f}(x))$. Therefore by definition of equality of ordered pairs we get that $f(x)=\tilde{f}(x)$.

Now to show the converse we assume that $f=\tilde{f}$. We wish to prove that their graphs are also equal. By definition the graph of $f$ is the set $\{(x, f(x)) : x ∈ X\}$. and the graph of the other function is $\{(x, f(x)) : x ∈ X\}$. Since these are subsets of $X \times Y$ we know that they are also sets by Exercise 3.5.1. Now let $x \in X$ therefore we have $f(x)=\tilde{f}(x)$ by definition of function equality so we know that the $(x,f(x))=(x,\tilde{f}(x))$ as two ordered pairs are only equal if and only if both their components match. Therefore we have shown that all elements of the graph of $f$ are also elements of the graph of $\tilde{f}$ and vice versa so we are done.

Best Answer

This problem essentially boils down to proving this lemma:

Lemma: Let $ A,B $ be sets and let $f,g: A \rightarrow B$. Then $f = g$ if and only if, $\forall a\in A, f(a)=g(a)$

If $\forall a\in A, f(a)=g(a)$, then let $z=(x,y)\in f$. In other words, $y=f(x)$. But by the assumption above, f(x)=g(x)$, so $y=g(x)$, or $(x,y)\in g$. The other inclusion is analogous.

If $f=g$, then let $x\in A$. Since $f,g$ are functions with domain $A$, by definition, there are some $w,y\in B$ such that $y=f(x)$ and $w=g(x)$. But $f=g$, so by the definition of function, $w=y$.