Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3979502
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:10:41+00:00 2026-05-20T05:10:41+00:00

I am having trouble understanding the principles of what a constructor is and how

  • 0

I am having trouble understanding the principles of what a constructor is and how it works.

For example, in Coq, we have been taught to define the natural numbers like this:

Inductive nat : Type :=
   | O : nat
   | S : nat -> nat.

And have been told that S is a constructor, but what exactly does that mean?

If I then do:

Check (S (S (S (S O)))).

I get that it is 4 and of type nat.

How does this work, and how does Coq know that (S (S (S (S O)))) represents 4?

I guess the answer to this is some extremely clever background magic in Coq.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:10:42+00:00Added an answer on May 20, 2026 at 5:10 am
    Inductive naturals : Type :=
       | Z : naturals
       | N : naturals -> naturals.
    

    says the following things:

    1. Z is a term of type naturals

    2. when e is a term of type naturals, N e is a term of type naturals.

    3. Applying Z or N are the only two ways to create a natural. When given an arbitrary natural, you know that it was either made from one or from the other.

    4. two terms e1 and e2 of type naturals are equal if and only if they are both Z or if they are respectively N t1 and N t2 with t1 equal to t2.

    You can see how these rules would generalize to arbitrary inductive type definitions. In general, in an arbitrary inductive type definition for the type t:

    • applying a constructor to arguments of the correct types produces a term of type t;
    • any term of type t is the result of applying one of the constructors that were associated with the type t when it was defined; in other words, given a term of type t, one can assume that it is the result of applying one of the constructors of t;
    • two terms of type t are equal only if they result from applying the same constructors to the same arguments.

    (Side note: when the type definition is for constructors of the shape of Z and N, these properties correspond more or less exactly Peano’s axioms for natural numbers. This is why a type named nat is pre-defined in Coq with constructors of these shapes to be used to represent natural numbers. This type receives special treatment because it gets tiring very quickly to manipulate the raw form, but the special treatments are only there for convenience.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble understanding how QT works. Can somebody show me an example, where
I am having trouble understanding how layering is performed within Xcode. I have a
I'm having trouble understanding why I have to place the button triggering the getJSON
I am having trouble understanding how escaping works inside html tag attribute values that
I'm having trouble understanding why the Foo move constructor tries to invoke ~ptr in
I'm having trouble understanding how QGraphicsItemAnimation's setScaleAt function works. Here's the code I'm using:
Im having trouble understanding exactly how JSP works in terms of sessions...basically I am
I'm having trouble understanding how to solve this issue, essentially I have two arrays
I'm having trouble understanding why java secure coding is important. For example, why is
I'm having trouble understanding how this method works. From the documentation, it specifies: canOpenURL:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.