Type/codomain of constant function f(x)=5












1














A function like $f(x) = 2x$ can be defined over the reals so its “type signature” or in set theory domain and codomain is $f: mathbb{R} rightarrow mathbb{R}$.



I want to define a function $f(x) = 5$ (or some other constant number) and restrict the codomain/return type to be a constant value. What is the (most restrictive) type signature of such a function? Does this require dependent types? Is it $f: mathbb{R} rightarrow 5$? I want to know the type signature for that specific function that returns 5 and the more general notion of a function that returns a constant value that does not depend on the input argument.



My motivation is that I want to be able to describe in a precise way functions that do not use/“delete” their input argument and return some other constant value. Eventually I want to formalize this in a proof assistant.










share|cite|improve this question
























  • $f$ goes from a set into a set, so write $f:mathbb{R}to{5}$
    – user376343
    Nov 27 '18 at 20:21










  • Since the actual value of 5 seems not to matter, why not $f : mathbb{R} to {ast}$, where ${ast}$ is a set containing a single element?
    – Xander Henderson
    Nov 27 '18 at 20:23












  • @XanderHenderson: your comment immediatley made me respond, that the OP is asking for the most restrictive type, but then I realised the question is unclear.
    – Rob Arthan
    Nov 27 '18 at 20:27












  • @RobArthan But they also seem, as per this comment, to be indicating that the actual value of the constant doesn't matter, hence my confusion.
    – Xander Henderson
    Nov 27 '18 at 20:31










  • @XanderHenderson: I agree: I edited my comment to point out the unclarity.
    – Rob Arthan
    Nov 27 '18 at 20:32


















1














A function like $f(x) = 2x$ can be defined over the reals so its “type signature” or in set theory domain and codomain is $f: mathbb{R} rightarrow mathbb{R}$.



I want to define a function $f(x) = 5$ (or some other constant number) and restrict the codomain/return type to be a constant value. What is the (most restrictive) type signature of such a function? Does this require dependent types? Is it $f: mathbb{R} rightarrow 5$? I want to know the type signature for that specific function that returns 5 and the more general notion of a function that returns a constant value that does not depend on the input argument.



My motivation is that I want to be able to describe in a precise way functions that do not use/“delete” their input argument and return some other constant value. Eventually I want to formalize this in a proof assistant.










share|cite|improve this question
























  • $f$ goes from a set into a set, so write $f:mathbb{R}to{5}$
    – user376343
    Nov 27 '18 at 20:21










  • Since the actual value of 5 seems not to matter, why not $f : mathbb{R} to {ast}$, where ${ast}$ is a set containing a single element?
    – Xander Henderson
    Nov 27 '18 at 20:23












  • @XanderHenderson: your comment immediatley made me respond, that the OP is asking for the most restrictive type, but then I realised the question is unclear.
    – Rob Arthan
    Nov 27 '18 at 20:27












  • @RobArthan But they also seem, as per this comment, to be indicating that the actual value of the constant doesn't matter, hence my confusion.
    – Xander Henderson
    Nov 27 '18 at 20:31










  • @XanderHenderson: I agree: I edited my comment to point out the unclarity.
    – Rob Arthan
    Nov 27 '18 at 20:32
















1












1








1







A function like $f(x) = 2x$ can be defined over the reals so its “type signature” or in set theory domain and codomain is $f: mathbb{R} rightarrow mathbb{R}$.



I want to define a function $f(x) = 5$ (or some other constant number) and restrict the codomain/return type to be a constant value. What is the (most restrictive) type signature of such a function? Does this require dependent types? Is it $f: mathbb{R} rightarrow 5$? I want to know the type signature for that specific function that returns 5 and the more general notion of a function that returns a constant value that does not depend on the input argument.



My motivation is that I want to be able to describe in a precise way functions that do not use/“delete” their input argument and return some other constant value. Eventually I want to formalize this in a proof assistant.










share|cite|improve this question















A function like $f(x) = 2x$ can be defined over the reals so its “type signature” or in set theory domain and codomain is $f: mathbb{R} rightarrow mathbb{R}$.



I want to define a function $f(x) = 5$ (or some other constant number) and restrict the codomain/return type to be a constant value. What is the (most restrictive) type signature of such a function? Does this require dependent types? Is it $f: mathbb{R} rightarrow 5$? I want to know the type signature for that specific function that returns 5 and the more general notion of a function that returns a constant value that does not depend on the input argument.



My motivation is that I want to be able to describe in a precise way functions that do not use/“delete” their input argument and return some other constant value. Eventually I want to formalize this in a proof assistant.







functions elementary-set-theory






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Nov 27 '18 at 20:58







Brandon Brown

















asked Nov 27 '18 at 20:13









Brandon BrownBrandon Brown

30317




30317












  • $f$ goes from a set into a set, so write $f:mathbb{R}to{5}$
    – user376343
    Nov 27 '18 at 20:21










  • Since the actual value of 5 seems not to matter, why not $f : mathbb{R} to {ast}$, where ${ast}$ is a set containing a single element?
    – Xander Henderson
    Nov 27 '18 at 20:23












  • @XanderHenderson: your comment immediatley made me respond, that the OP is asking for the most restrictive type, but then I realised the question is unclear.
    – Rob Arthan
    Nov 27 '18 at 20:27












  • @RobArthan But they also seem, as per this comment, to be indicating that the actual value of the constant doesn't matter, hence my confusion.
    – Xander Henderson
    Nov 27 '18 at 20:31










  • @XanderHenderson: I agree: I edited my comment to point out the unclarity.
    – Rob Arthan
    Nov 27 '18 at 20:32




















  • $f$ goes from a set into a set, so write $f:mathbb{R}to{5}$
    – user376343
    Nov 27 '18 at 20:21










  • Since the actual value of 5 seems not to matter, why not $f : mathbb{R} to {ast}$, where ${ast}$ is a set containing a single element?
    – Xander Henderson
    Nov 27 '18 at 20:23












  • @XanderHenderson: your comment immediatley made me respond, that the OP is asking for the most restrictive type, but then I realised the question is unclear.
    – Rob Arthan
    Nov 27 '18 at 20:27












  • @RobArthan But they also seem, as per this comment, to be indicating that the actual value of the constant doesn't matter, hence my confusion.
    – Xander Henderson
    Nov 27 '18 at 20:31










  • @XanderHenderson: I agree: I edited my comment to point out the unclarity.
    – Rob Arthan
    Nov 27 '18 at 20:32


















$f$ goes from a set into a set, so write $f:mathbb{R}to{5}$
– user376343
Nov 27 '18 at 20:21




$f$ goes from a set into a set, so write $f:mathbb{R}to{5}$
– user376343
Nov 27 '18 at 20:21












Since the actual value of 5 seems not to matter, why not $f : mathbb{R} to {ast}$, where ${ast}$ is a set containing a single element?
– Xander Henderson
Nov 27 '18 at 20:23






Since the actual value of 5 seems not to matter, why not $f : mathbb{R} to {ast}$, where ${ast}$ is a set containing a single element?
– Xander Henderson
Nov 27 '18 at 20:23














@XanderHenderson: your comment immediatley made me respond, that the OP is asking for the most restrictive type, but then I realised the question is unclear.
– Rob Arthan
Nov 27 '18 at 20:27






@XanderHenderson: your comment immediatley made me respond, that the OP is asking for the most restrictive type, but then I realised the question is unclear.
– Rob Arthan
Nov 27 '18 at 20:27














@RobArthan But they also seem, as per this comment, to be indicating that the actual value of the constant doesn't matter, hence my confusion.
– Xander Henderson
Nov 27 '18 at 20:31




@RobArthan But they also seem, as per this comment, to be indicating that the actual value of the constant doesn't matter, hence my confusion.
– Xander Henderson
Nov 27 '18 at 20:31












@XanderHenderson: I agree: I edited my comment to point out the unclarity.
– Rob Arthan
Nov 27 '18 at 20:32






@XanderHenderson: I agree: I edited my comment to point out the unclarity.
– Rob Arthan
Nov 27 '18 at 20:32












2 Answers
2






active

oldest

votes


















1














The answer to this really depends on your type theory. The type theories of proof assistants like Coq or Agda will let you express any of the following classes as types:



$$
{f : Bbb{R} to Bbb{R} mid forall x:Bbb{R}cdot f(x) = 5} \
{f : Bbb{R} to Bbb{R} mid exists c:Bbb{R}cdot forall x:Bbb{R}cdot f(x) = c} \
bigcup_Y {f : Bbb{R} to Y mid exists c:Ycdot forall x:Bbb{R}cdot f(x) = c} \
bigcup_{X, Y} {f : X to Y mid exists c:Ycdot forall x:Xcdot f(x) = c}
$$

and many variations on this kind of theme. Weaker type theories might not be able to deal with some of the above.






share|cite|improve this answer





























    0














    Define the type $mathsf{Five}$ as the singleton type populated by the type axiom $E vdash 5 : mathsf{Five}$. Then the type of $f$ is $f : mathbb{R} rightarrow mathsf{Five}$.






    share|cite|improve this answer





















    • Thanks! What if I want a more general form that will cover any constant value from $mathbb{R}$. Something like $f : mathbb{R} rightarrow c$ where $c$ is a constant value that does not depend on the input variable $x$.
      – Brandon Brown
      Nov 27 '18 at 20:22










    • You can define a singleton type $mathsf{T}_x$ for any element $x$.
      – Hans Hüttel
      Nov 27 '18 at 20:35











    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "69"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3016252%2ftype-codomain-of-constant-function-fx-5%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    The answer to this really depends on your type theory. The type theories of proof assistants like Coq or Agda will let you express any of the following classes as types:



    $$
    {f : Bbb{R} to Bbb{R} mid forall x:Bbb{R}cdot f(x) = 5} \
    {f : Bbb{R} to Bbb{R} mid exists c:Bbb{R}cdot forall x:Bbb{R}cdot f(x) = c} \
    bigcup_Y {f : Bbb{R} to Y mid exists c:Ycdot forall x:Bbb{R}cdot f(x) = c} \
    bigcup_{X, Y} {f : X to Y mid exists c:Ycdot forall x:Xcdot f(x) = c}
    $$

    and many variations on this kind of theme. Weaker type theories might not be able to deal with some of the above.






    share|cite|improve this answer


























      1














      The answer to this really depends on your type theory. The type theories of proof assistants like Coq or Agda will let you express any of the following classes as types:



      $$
      {f : Bbb{R} to Bbb{R} mid forall x:Bbb{R}cdot f(x) = 5} \
      {f : Bbb{R} to Bbb{R} mid exists c:Bbb{R}cdot forall x:Bbb{R}cdot f(x) = c} \
      bigcup_Y {f : Bbb{R} to Y mid exists c:Ycdot forall x:Bbb{R}cdot f(x) = c} \
      bigcup_{X, Y} {f : X to Y mid exists c:Ycdot forall x:Xcdot f(x) = c}
      $$

      and many variations on this kind of theme. Weaker type theories might not be able to deal with some of the above.






      share|cite|improve this answer
























        1












        1








        1






        The answer to this really depends on your type theory. The type theories of proof assistants like Coq or Agda will let you express any of the following classes as types:



        $$
        {f : Bbb{R} to Bbb{R} mid forall x:Bbb{R}cdot f(x) = 5} \
        {f : Bbb{R} to Bbb{R} mid exists c:Bbb{R}cdot forall x:Bbb{R}cdot f(x) = c} \
        bigcup_Y {f : Bbb{R} to Y mid exists c:Ycdot forall x:Bbb{R}cdot f(x) = c} \
        bigcup_{X, Y} {f : X to Y mid exists c:Ycdot forall x:Xcdot f(x) = c}
        $$

        and many variations on this kind of theme. Weaker type theories might not be able to deal with some of the above.






        share|cite|improve this answer












        The answer to this really depends on your type theory. The type theories of proof assistants like Coq or Agda will let you express any of the following classes as types:



        $$
        {f : Bbb{R} to Bbb{R} mid forall x:Bbb{R}cdot f(x) = 5} \
        {f : Bbb{R} to Bbb{R} mid exists c:Bbb{R}cdot forall x:Bbb{R}cdot f(x) = c} \
        bigcup_Y {f : Bbb{R} to Y mid exists c:Ycdot forall x:Bbb{R}cdot f(x) = c} \
        bigcup_{X, Y} {f : X to Y mid exists c:Ycdot forall x:Xcdot f(x) = c}
        $$

        and many variations on this kind of theme. Weaker type theories might not be able to deal with some of the above.







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Nov 27 '18 at 20:51









        Rob ArthanRob Arthan

        29.1k42866




        29.1k42866























            0














            Define the type $mathsf{Five}$ as the singleton type populated by the type axiom $E vdash 5 : mathsf{Five}$. Then the type of $f$ is $f : mathbb{R} rightarrow mathsf{Five}$.






            share|cite|improve this answer





















            • Thanks! What if I want a more general form that will cover any constant value from $mathbb{R}$. Something like $f : mathbb{R} rightarrow c$ where $c$ is a constant value that does not depend on the input variable $x$.
              – Brandon Brown
              Nov 27 '18 at 20:22










            • You can define a singleton type $mathsf{T}_x$ for any element $x$.
              – Hans Hüttel
              Nov 27 '18 at 20:35
















            0














            Define the type $mathsf{Five}$ as the singleton type populated by the type axiom $E vdash 5 : mathsf{Five}$. Then the type of $f$ is $f : mathbb{R} rightarrow mathsf{Five}$.






            share|cite|improve this answer





















            • Thanks! What if I want a more general form that will cover any constant value from $mathbb{R}$. Something like $f : mathbb{R} rightarrow c$ where $c$ is a constant value that does not depend on the input variable $x$.
              – Brandon Brown
              Nov 27 '18 at 20:22










            • You can define a singleton type $mathsf{T}_x$ for any element $x$.
              – Hans Hüttel
              Nov 27 '18 at 20:35














            0












            0








            0






            Define the type $mathsf{Five}$ as the singleton type populated by the type axiom $E vdash 5 : mathsf{Five}$. Then the type of $f$ is $f : mathbb{R} rightarrow mathsf{Five}$.






            share|cite|improve this answer












            Define the type $mathsf{Five}$ as the singleton type populated by the type axiom $E vdash 5 : mathsf{Five}$. Then the type of $f$ is $f : mathbb{R} rightarrow mathsf{Five}$.







            share|cite|improve this answer












            share|cite|improve this answer



            share|cite|improve this answer










            answered Nov 27 '18 at 20:20









            Hans HüttelHans Hüttel

            3,1972921




            3,1972921












            • Thanks! What if I want a more general form that will cover any constant value from $mathbb{R}$. Something like $f : mathbb{R} rightarrow c$ where $c$ is a constant value that does not depend on the input variable $x$.
              – Brandon Brown
              Nov 27 '18 at 20:22










            • You can define a singleton type $mathsf{T}_x$ for any element $x$.
              – Hans Hüttel
              Nov 27 '18 at 20:35


















            • Thanks! What if I want a more general form that will cover any constant value from $mathbb{R}$. Something like $f : mathbb{R} rightarrow c$ where $c$ is a constant value that does not depend on the input variable $x$.
              – Brandon Brown
              Nov 27 '18 at 20:22










            • You can define a singleton type $mathsf{T}_x$ for any element $x$.
              – Hans Hüttel
              Nov 27 '18 at 20:35
















            Thanks! What if I want a more general form that will cover any constant value from $mathbb{R}$. Something like $f : mathbb{R} rightarrow c$ where $c$ is a constant value that does not depend on the input variable $x$.
            – Brandon Brown
            Nov 27 '18 at 20:22




            Thanks! What if I want a more general form that will cover any constant value from $mathbb{R}$. Something like $f : mathbb{R} rightarrow c$ where $c$ is a constant value that does not depend on the input variable $x$.
            – Brandon Brown
            Nov 27 '18 at 20:22












            You can define a singleton type $mathsf{T}_x$ for any element $x$.
            – Hans Hüttel
            Nov 27 '18 at 20:35




            You can define a singleton type $mathsf{T}_x$ for any element $x$.
            – Hans Hüttel
            Nov 27 '18 at 20:35


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Mathematics Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3016252%2ftype-codomain-of-constant-function-fx-5%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Plaza Victoria

            Brian Clough

            Cáceres