Function composition: the permitted inputs of a restricted composition, evaluation order and non-commutativity

On this page
  1. Goal and scope
  2. Givens and symbols
  3. Rules and sources
  4. Main derivation
  5. Substeps and lemmas
  6. Reverse audits
  7. Error controls and negative controls
  8. Result and limitations
  9. Verification and source binding

← Guide index · Original MKO

derivation-mko-composition-01 · production-20261019-adopted-96

Goal and scope

Let f:ℝ→ℝ, f(x)=x−3, and g:[0,∞)→ℝ, g(u)=√u. (1) Find the permitted inputs D={x∈dom(f) ∣ f(x)∈dom(g)} of g∘f and prove D=[3,∞); (2) evaluate (g∘f)(7) and (g∘f)(4) by 'f first, then g', and explain why (g∘f)(1) is undefined; (3) show that f∘g is a total composition on [0,∞), and conclude g∘f≠f∘g from (f∘g)(4)=−1≠1=(g∘f)(4); (4) show that composition is not multiplication of function values.

Inside the MKO's scope: the functions and their domains and codomains are stated explicitly (assumption a1), and a restricted composition is evaluated only on its explicitly permitted set (assumption a2). Only the definition of the principal square root and the order of the reals are used. It does not treat associativity of composition in general, inverse functions or type-conversion conditions, and does not change the canonical MKO or its English edition.

Givens and symbols

  • composition_def
  • function_def
  • set_builder
  • set_extensionality
  • sqrt_def
  • order_basics
  • numeric_evaluation
  • G1 — f:ℝ→ℝ with f(x)=x−3; dom(f)=ℝ.
  • G2 — g:[0,∞)→ℝ with g(u)=√u; dom(g)=[0,∞)={u∈ℝ ∣ u≥0}.
  • G3 — For expressions with different domains, the permitted inputs of the composition are D={x∈dom(f) ∣ f(x)∈dom(g)}, and (g∘f)(x)=g(f(x)) for x∈D (MKO).
  • f,\ g — the two given functions
  • g\circ f — the composition 'f first, then g', (g∘f)(x)=g(f(x))
  • D — the set of permitted inputs of g∘f
  • \mathrm{dom}(f) — the domain of f
  • [a,\infty) — {x∈ℝ ∣ x≥a}
  • \sqrt{u} — the principal square root of u≥0

Rules and sources

  • composition_def · prerequisite — Composition: for f:A→B and g:B→C, g∘f:A→C is defined by (g∘f)(a)=g(f(a)).
  • function_def · prerequisite — Function: f:A→B assigns to each a∈A exactly one f(a)∈B. Two functions are equal ⇔ they have the same domain and codomain and agree at every a.
  • set_builder · prerequisite — Set-builder notation: x∈{y∈A ∣ P(y)} if and only if x∈A and P(x).
  • set_extensionality · prerequisite — Set equality: A=B if and only if A⊆B and B⊆A, i.e. they have the same elements.
  • sqrt_def · prerequisite — Principal square root: for a≥0, √a is the unique real b with b≥0 and b²=a. Negative numbers have no real square root.
  • order_basics · prerequisite — Order of the reals: exactly one of u<v, u=v, u>v holds; u<v and v<w give u<w; u<v gives u+w<v+w; u<v and w>0 give uw<vw; u<v and w<0 give uw>vw.
  • numeric_evaluation · prerequisite — Exact evaluation of an explicit integer or rational expression; independently recomputable.
  • def_unfold · prerequisite — Unfolding a definition: replacing a defined term by its definition (or folding it back) does not change whether a statement is true.
  • add_inverse · prerequisite — Additive inverse: every u has −u with u+(−u)=0; u−v means u+(−v).
  • add_assoc · prerequisite — Associativity of addition: (u+v)+w=u+(v+w).
  • add_zero · prerequisite — Additive identity: u+0=u.
  • square_nonneg · prerequisite — Squares are nonnegative: for every real u, u²≥0, and u²=0 ⇔ u=0.
  • and_intro_elim · prerequisite — Conjunction: from P and Q infer P∧Q; from P∧Q infer P and infer Q.
  • mko_comp_def · cited — If f:A→B and g:B→C are total functions, then g∘f:A→C is defined by (g∘f)(x)=g(f(x)). For expressions with different domains, the permitted inputs of the composition are {x∈dom(f):f(x)∈dom(g)}. · mko-composition
  • L_shift3 · lemma — For a real x: x−3≥0 ⇔ x≥3.
  • L_sqrt_sq · lemma — For a real b≥0: √(b²)=b.

Main derivation

S01 · definition

Before

g\circ f

After

(g\circ f)(x)=g(f(x)),\ \ x\in D=\{x\in\mathrm{dom}(f)\mid f(x)\in\mathrm{dom}(g)\}

Conditions: none

Rule: mko_comp_def · Uses: G3, mko_comp_def

Leaf basis: mko_comp_def + composition_def

State the composition from the MKO: first compute the inner value f(x), then hand it to g. In the symbol g∘f the g is written on the left, but f is evaluated first; the written order is the reverse of the order of evaluation. Because f and g have different domains, only the x whose intermediate value f(x) lies in the domain of g are permitted inputs.

S02 · equivalent

Before

D=\{x\in\mathrm{dom}(f)\mid f(x)\in\mathrm{dom}(g)\}

After

D=\{x\in\mathbb{R}\mid x-3\geq 0\}

Conditions: none

Rule: set_builder · Uses: S01, G1, G2, set_builder

Leaf basis: set_builder + def_unfold

Substitute dom(f)=ℝ, f(x)=x−3 and dom(g)={u ∣ u≥0}: the condition f(x)∈dom(g) becomes x−3≥0. Both descriptions impose the same condition on every x, so the sets agree.

S03 · equivalent

Before

x-3\geq 0

After

x\geq 3

Conditions: none

Rule: L_shift3 · Uses: S02, L_shift3

Leaf basis: L_shift3

By Lemma L_shift3, x−3≥0 ⇔ x≥3. The lemma is proved in S03.1.

S04 · equivalent

Before

D=\{x\in\mathbb{R}\mid x-3\geq 0\}

After

D=[3,\infty)

Conditions: none

Rule: set_extensionality · Uses: S02, S03, set_extensionality

Leaf basis: set_extensionality + set_builder

By S03 the condition x−3≥0 may be replaced by the equivalent x≥3, so D={x∈ℝ ∣ x≥3}=[3,∞). D is smaller than dom(f)=ℝ: f accepts every real, but g accepts only nonnegative intermediate values.

S05 · implies

Before

x\in D

After

(g\circ f)(x)=\sqrt{x-3},\ \ g\circ f:[3,\infty)\to\mathbb{R}

Conditions: x\geq 3

Rule: composition_def · Uses: S01, S04, composition_def

Leaf basis: composition_def + function_def

For x∈D, f(x)=x−3∈dom(g), so g(f(x))=√(x−3) is defined. Restricted to D, f is a total function D→[0,∞) and g is a total function [0,∞)→ℝ; the intermediate types match, so composition_def gives the total function g∘f:[3,∞)→ℝ.

S06 · implies

Before

x=7

After

f(7)=7-3=4\in\mathrm{dom}(g),\ \ 7\in D

Conditions: none

Rule: numeric_evaluation · Uses: G1, S04

Leaf basis: numeric_evaluation + set_builder

To evaluate (g∘f)(7), do the inner step first: f(7)=7−3=4. Since 4≥0, 4∈dom(g), so 7∈D (consistent with 7≥3). The domain check on the intermediate value must be done before applying g.

S07 · implies

Before

g(4)

After

(g\circ f)(7)=g(4)=\sqrt{4}=\sqrt{2^2}=2

Conditions: 2\geq 0

Rule: L_sqrt_sq · Uses: S06, G2, L_sqrt_sq

Leaf basis: L_sqrt_sq + numeric_evaluation

Outer step: g(4)=√4. Since 4=2² and 2≥0, Lemma L_sqrt_sq gives √4=2. So (g∘f)(7)=2.

S08 · implies

Before

x=4

After

(g\circ f)(4)=g(f(4))=g(1)=\sqrt{1}=1

Conditions: 4\geq 3

Rule: composition_def · Uses: G1, G2, S04, L_sqrt_sq

Leaf basis: composition_def + L_sqrt_sq + numeric_evaluation

4≥3, so 4∈D. Inner step: f(4)=4−3=1, and the intermediate value 1 lies in dom(g) because 1≥0; outer step: g(1)=√1=√(1²)=1 by L_sqrt_sq with 1≥0. So (g∘f)(4)=1.

S09 · implies

Before

x=1

After

f(1)=-2\notin\mathrm{dom}(g),\ \text{so}\ 1\notin D\ \text{and}\ (g\circ f)(1)\ \text{is undefined}

Conditions: none

Rule: set_builder · Uses: G1, G2, S04, sqrt_def

Leaf basis: set_builder + sqrt_def + order_basics + numeric_evaluation

1 belongs to dom(f)=ℝ and f(1)=1−3=−2. But −2<0 is not in dom(g); by sqrt_def a negative number has no real square root, so g(−2) is undefined. Hence 1∉D and (g∘f)(1) is undefined. Looking only at 1∈dom(f) and skipping the check on the intermediate value is a mistake.

S10 · implies

Before

f\circ g

After

\{x\in\mathrm{dom}(g)\mid g(x)\in\mathrm{dom}(f)\}=[0,\infty),\ \ (f\circ g)(x)=\sqrt{x}-3

Conditions: none

Rule: composition_def · Uses: G1, G2, composition_def, set_builder

Leaf basis: composition_def + set_builder + function_def

The other order, f∘g: first g, then f. Every value √x of g is real and dom(f)=ℝ, so the condition g(x)∈dom(f) holds for every x∈[0,∞), and the permitted set is [0,∞). The codomain ℝ of g is exactly the domain of f, so the intermediate types match and f∘g:[0,∞)→ℝ is a total composition with (f∘g)(x)=√x−3.

S11 · implies

Before

x=4

After

(f\circ g)(4)=f(g(4))=f(2)=2-3=-1

Conditions: 4\geq 0

Rule: composition_def · Uses: S10, L_sqrt_sq

Leaf basis: composition_def + L_sqrt_sq + numeric_evaluation

4∈[0,∞). Inner step g(4)=√4=2 (S07), outer step f(2)=2−3=−1. So (f∘g)(4)=−1.

S12 · implies

Before

(g\circ f)(4)=1,\ (f\circ g)(4)=-1

After

g\circ f\neq f\circ g

Conditions: none

Rule: function_def · Uses: S04, S08, S10, S11, function_def

Leaf basis: function_def + numeric_evaluation

Equal functions need the same domain and the same value at every point. Here even the domains differ ([3,∞) and [0,∞)), and at the common input 4 the values are 1≠−1. So g∘f≠f∘g: composition is not commutative in general.

S13 · implies

Before

f(4)\cdot g(4)

After

f(4)\cdot g(4)=1\cdot 2=2\neq 1=(g\circ f)(4)

Conditions: none

Rule: numeric_evaluation · Uses: G1, G2, S07, S08

Leaf basis: numeric_evaluation

The product of values is f(4)·g(4)=1·2=2, while the composition gives (g∘f)(4)=1. They differ, so g(f(x)) may not be rewritten as f(x)g(x); composition feeds the output of one function into another and is not multiplication.

S14 · implies

Before

S04,\ S07,\ S08,\ S09,\ S12,\ S13

After

D=[3,\infty);\ (g\circ f)(7)=2,\ (g\circ f)(4)=1,\ 1\notin D;\ g\circ f\neq f\circ g;\ \exists x\in D:\ g(f(x))\neq f(x)g(x)

Conditions: none

Rule: and_intro_elim · Uses: S04, S07, S08, S09, S12, S13

Leaf basis: and_intro_elim

Goal (1) is completed by S04, (2) by S07 to S09, (3) by S10 to S12, and (4) by S13.

Substeps and lemmas

S03.1 · equivalent

Before

x-3\geq 0

After

x\geq 3

Conditions: none

Rule: order_basics · Uses: order_basics, add_inverse

Leaf basis: order_basics + add_inverse + add_assoc + add_zero

⇒: add 3 to both sides; (x−3)+3=x and 0+3=3, giving x≥3. ⇐: add −3 to both sides, giving x−3≥0. Adding the same number to both sides keeps the direction of ≥ (the strict case by order_basics, the equality case trivially). This sub-step proves Lemma L_shift3.

S07.1 · implies

Before

b\geq 0

After

\sqrt{b^2}=b

Conditions: b\geq 0

Rule: sqrt_def · Uses: sqrt_def

Leaf basis: sqrt_def + square_nonneg

By sqrt_def, for a≥0, √a is the unique real c with c≥0 and c²=a. Take a=b² (which is ≥0); c=b satisfies b≥0 and b²=b², so uniqueness gives √(b²)=b. This sub-step proves Lemma L_sqrt_sq.

Reverse audits

  • S14 · sufficient_goal_reduction · S04, S07, S08, S09, S12, S13, and_intro_elim — Goal G: (1) to (4). Sufficient condition H: the listed steps hold; H⇒G by conjunction introduction. H is proved forwards from the definitions, lemmas and exact computation; G is never used as a premise.
  • S13 · premise_audit · S08, numeric_evaluation — A difference at one input is enough to refute the general claim that composition equals the product.
  • S12 · premise_audit · S08, S11, function_def — One common input with different values suffices to refute equality; it is not claimed that no pair of functions commutes.
  • S11 · premise_audit · S10, L_sqrt_sq, numeric_evaluation — This time the inner function is g; the order is fixed by the symbol f∘g: the g on the right acts first.
  • S10 · premise_audit · composition_def, G1, G2 — It needs the codomain of g to be contained in the domain of f; here both are ℝ.
  • S09 · premise_audit · S04, set_builder, sqrt_def — The conclusion is only that 1 is not a permitted input; no value is assigned to (g∘f)(1).
  • S08 · premise_audit · S04, L_sqrt_sq, composition_def — Again f(4) is checked to lie in the domain of g before g is applied.
  • S07.1 · premise_audit · sqrt_def, square_nonneg — It needs b≥0; for b<0, for example b=−2, √((−2)²)=2≠−2.
  • S07 · premise_audit · L_sqrt_sq, S06 — It needs 2≥0; −2 also satisfies (−2)²=4 but is not the principal square root.
  • S06 · premise_audit · G1, S04, numeric_evaluation — This step computes only the inner value and checks the domain; the outer step is S07.
  • S05 · premise_audit · S04, composition_def — The formula is claimed only on D; no value is claimed outside D (assumption a2).
  • S04 · inverse_equivalence · S03, set_extensionality — The conditions are equivalent pointwise, so by extensionality the sets are equal.
  • S03.1 · inverse_equivalence · order_basics, add_inverse — Adding 3 and adding −3 undo each other and are possible for every real x (N10).
  • S03 · inverse_equivalence · L_shift3 — Both directions of the lemma are proved.
  • S02 · inverse_equivalence · set_builder, G1, G2 — Only the domains and the rule are substituted; the conditions are equivalent pointwise, so the step is two-way.
  • S01 · premise_audit · G3, mko_comp_def — This step only states the definition and derives no new fact.

Error controls and negative controls

g∘f means f first, then g

The first mistake named by the MKO is reading g∘f as 'g first, then f'. At x=4 the correct value is (g∘f)(4)=g(f(4))=g(1)=1; doing g first gives f(g(4))=f(2)=−1, which is (f∘g)(4). At x=7 the correct value is 2, while g first gives √7−3, a completely different number. Read the symbol from right to left.

The intermediate value must lie in the domain of g

The second mistake named by the MKO is skipping the domain check on the intermediate value. 1∈dom(f), but f(1)=−2∉dom(g), so 1 is not a permitted input of g∘f; the permitted set is [3,∞), not ℝ. Another trap is simplifying the formula first: if k(u)=(√u)² with domain [0,∞), then k(f(x)) seems to simplify to x−3, defined for every real, but the permitted inputs of k∘f are still only [3,∞), because the permitted set is fixed by f(x)∈dom(k), not by the simplified expression.

Composition is neither commutative nor multiplication

The third paragraph of the MKO says that rewriting as f(g(x)) or f(x)g(x) needs extra conditions. Here (g∘f)(4)=1, (f∘g)(4)=−1 and f(4)g(4)=2 are pairwise different, and even the domains of g∘f and f∘g differ.

  • (g∘f)(4) is computed as g(4)=2 first, then f(2)=−1 → reject — That is (f∘g)(4); (g∘f)(4)=g(f(4))=g(1)=1.
  • The permitted inputs of g∘f are dom(f)=ℝ → reject — 1∈ℝ but f(1)=−2∉dom(g); the permitted set is [3,∞).
  • g∘f=f∘g → reject — Their domains differ, and their values at 4 are 1 and −1.
  • (g∘f)(4)=f(4)·g(4)=2 → reject — (g∘f)(4)=1; composition is not multiplication of values.
  • With k(u)=(√u)² for u≥0, k(f(x)) simplifies to x−3, so k∘f is defined on all reals → reject — The permitted inputs are fixed by f(x)∈dom(k) and are still [3,∞).

Result and limitations

The permitted inputs of g∘f are D=[3,∞), with (g∘f)(x)=√(x−3); (g∘f)(7)=2 and (g∘f)(4)=1, while (g∘f)(1) is undefined because f(1)=−2 is outside the domain of g. f∘g:[0,∞)→ℝ, (f∘g)(x)=√x−3, is a total composition with (f∘g)(4)=−1≠1, so g∘f≠f∘g; and f(4)g(4)=2≠1, so composition is not multiplication.

  • N11 and N12 are finite checks at integer points (x from 3 to 30 and from −30 to 2) and support only those points; the general statement D=[3,∞) comes from S02 to S04.

Verification and source binding

13 declared checks for this guide; only the listed expressions are covered.

  • source commit: b28a5edbd46279b1db2a3f3f48bb3f447e18899f
  • adopted source SHA-256: 7475978339b2e04ee6e4e8518b063519655f472a46543961b2bfa1e7094d567b
  • original source SHA-256: 95339f2c0130b538225fee6de95859d69ec9ec89bcf1a08c5079782ad73dbc7a
  • Lean: NOT_RUN · independent AI: NOT_MEASURED

Same-source full JSON (formulas, ASTs, controls and revision log)