foo
: ∀(P: Nat -> *)
∀(f: ∀{n} -> ∀(x: (P n)) -> (P (n * 3)))
∀(g: ∀{n} -> ∀(x: (P n)) -> (P (n * 2)))
∀(h: ∀{n} -> ∀(x: (P n)) -> (P (n + 5)))
∀(z: (P 1))
(P 17)
= λP λf λg λh λz
(h (h (h (h (h (h (h (h (g (g (g (g (g (g (g (f z)))))))))))))))))))))))
Explanation:
The function foo takes four function arguments f, g, h, and z, all of which are dependent function types. The input function P is also a dependent function type. The output of foo is also a dependent function type.
To complete the function, we need to find a way to apply the input functions f, g, and h to the input z in such a way that the resulting function satisfies the output type (P 17).
Here's how we can do it:
-
Apply h to z to get a function that takes an argument of type (P (1 + 5)) which is (P 6).
-
Apply h to the result obtained in step 1 to get a function that takes an argument of type (P (6 + 5)) which is (P 11).
-
Repeat step 2 until we get a function that takes an argument of type (P 16).
-
Apply g to the function obtained in step 3 to get a function that takes an argument of type (P (16 * 2)) which is (P 32).
-
Apply g to the result obtained in step 4 to get a function that takes an argument of type (P (32 * 2)) which is (P 64).
-
Apply f to the function obtained in step 5 to get a function that takes an argument of type (P (64 * 3)) which is (P 192).
-
Repeat step 6 until we get a function that takes an argument of type (P 576).
-
Apply g to the function obtained in step 7 to get a function that takes an argument of type (P (576 * 2)) which is (P 1152).
-
Apply g to the result obtained in step 8 to get a function that takes an argument of type (P (1152 * 2)) which is (P 2304).
-
Apply f to the function obtained in step 9 to get a function that takes an argument of type (P (2304 * 3)) which is (P 6912).
-
Repeat step 10 until we get a function that takes an argument of type (P 53248).
-
Apply g to the function obtained in step 11 to get a function that takes an argument of type (P (53248 * 2)) which is (P 106496).
-
Apply g to the result obtained in step 12 to get a function that takes an argument of type (P (106496 * 2)) which is (P 212992).
-
Apply f to the function obtained in step 13 to get a function that takes an argument of type (P (212992 * 3)) which is (P 6384608).
-
Repeat step 14 until we get a function that takes an argument of type (P 19660800).
-
Apply h to the function obtained in step 1