সেট এবং প্রকারের মধ্যে অর্থগত পার্থক্যটি ঠিক কী?


33

সম্পাদনা: আমি এখন বিভাগ এবং সেটগুলির মধ্যে পার্থক্য সম্পর্কে একই ধরণের প্রশ্ন জিজ্ঞাসা করেছি

আমি যখনই টাইপ থিওরি সম্পর্কে পড়েছি (যা স্বতন্ত্রভাবে অনানুষ্ঠানিক) তখন আমি সেট টিওর থেকে কীভাবে আলাদা তা বুঝতে পারি না, কংক্রিটলি

আমি বুঝতে পেরেছি যে "x একটি সেট এক্স এর সাথে সম্পর্কযুক্ত" এবং "এক্স টাইপ এক্স এর টাইপ" এর মধ্যে একটি ধারণাগত পার্থক্য রয়েছে, কারণ স্বজ্ঞাতভাবে, একটি সেট কেবলমাত্র বস্তুর একটি সংগ্রহ, যখন কোনও ধরণের নির্দিষ্ট "বৈশিষ্ট্য" থাকে। তবুও, সেটগুলি প্রায়শই পাশাপাশি সম্পত্তি হিসাবেও সংজ্ঞায়িত করা হয়, এবং যদি সেগুলি হয়, তবে এই পার্থক্যটি কোনওভাবেই কীভাবে গুরুত্বপূর্ণ তা বুঝতে আমার সমস্যা হচ্ছে।

তাই বেশিরভাগ কংক্রিট পথ সম্ভব, ঠিক আছে কি এটা পরোক্ষভাবে সম্পর্কে x বলতে চাই যে এটা ধরনের হয় T যাতে বলা হয় এটি সেট একটি উপাদান তুলনায় S ?

(আপনি যে কোনও ধরণের চয়ন করতে পারেন এবং সেটটি তুলনাটিকে সর্বাধিক স্পষ্ট করে তোলে)।


What's the context in which you're using/hearing the word "type"? Is it, as your name suggests, programming languages? Because I think the answers below assume otherwise.
einpoklum - reinstate Monica

@einpoklum, I'm not 100% sure how to describe what the "context" is, but basically something like: I'm trying to understand the role of types in mathematics. Essentially, sets (as I see it) have two contexts: firstly they are used as collections of objects to do everyday mathematics in. Secondly, they are objects in axiomatic set theory, where they are mostly used as a very weird but helpful tool to talk about mathematics in first order logic, by letting sets correspond to functions and numbers and so forth. I'm mainly interested in the relation between "set" in the first sense and "type".
user56834

কোন ধরণের ভূমিকা? আপনি গণিতের কাগজপত্র / পাঠ্যপুস্তকগুলিতে যে প্রকারগুলি দেখেন বা কম্পিউটার প্রোগ্রামগুলিতে ভেরিয়েবলের প্রকারগুলি?
আইনপোকলম - মনিকা

1
@ আইনপোকলুম, এই প্রশ্নটি গণিতের কাগজপত্রগুলির বিষয়ে। (যদিও আমি আসলে গণিতের প্রকারের এবং প্রোগ্রামিং ভাষাগুলির প্রকারের মধ্যে মৌলিক পার্থক্যটি জানতে আগ্রহী, তবে যদি এই প্রশ্নটি আসে তবে তা ছিল না)।
ব্যবহারকারী56834

উত্তর:


29

সেট এবং প্রকারের মধ্যে পার্থক্য বুঝতে, এগুলি "সংগ্রহ" এবং "নির্মাণ" এর প্রাক- গাণিতিক ধারণাগুলিতে ফিরে যেতে হবে এবং সেটগুলি এবং প্রকারগুলি এগুলিকে কীভাবে গণিত করে তা দেখুন।

গণিত সম্পর্কে যা আছে তা নিয়ে সম্ভাবনার একটি বর্ণালী রয়েছে। এর মধ্যে দুটি হ'ল:

  1. আমরা গণিতকে এমন একটি ক্রিয়াকলাপ হিসাবে ভাবি যেখানে কিছু বিধি অনুসারে গাণিতিক অবজেক্টগুলি নির্মিত হয় (কোনও শাসক এবং একটি কম্পাসের সাথে পয়েন্ট, লাইন এবং বৃত্ত তৈরির কার্যকলাপ হিসাবে জ্যামিতিকে ভাবেন) of সুতরাং গাণিতিক বস্তু কিভাবে তারা হয় অনুযায়ী সংগঠিত নির্মাণ , এবং ভিন্ন ধরনের নির্মাণ। একটি গাণিতিক অবজেক্ট সর্বদা কিছু অনন্য উপায়ে নির্মিত হয়, যা এটির অনন্য প্রকারটি নির্ধারণ করে।

  2. আমরা গণিতকে প্রাক-বিদ্যমান গাণিতিক বস্তুগুলিতে পূর্ণ একটি বিশাল মহাবিশ্ব হিসাবে মনে করি (প্রদত্ত জ্যামিতিক বিমানটি ভাবেন)। আমরা এই বিষয়গুলি আবিষ্কার করি, বিশ্লেষণ করি এবং চিন্তা করি (আমরা লক্ষ্য করি যে বিমানে পয়েন্ট, লাইন এবং চেনাশোনা রয়েছে)। আমরা তাদের সেট মধ্যে সংগ্রহ । সাধারণত আমরা এমন উপাদানগুলি সংগ্রহ করি যা কিছু সাধারণ থাকে (উদাহরণস্বরূপ, একটি নির্দিষ্ট বিন্দুর মধ্য দিয়ে সমস্ত রেখাগুলি) তবে নীতিগতভাবে একটি সেট বস্তুর একটি স্বেচ্ছাসেবী নির্বাচন একসাথে ধরে রাখতে পারে। একটি সেট তার উপাদানগুলি দ্বারা নির্দিষ্ট করা হয় এবং কেবল তার উপাদানগুলির দ্বারা। একটি গাণিতিক বস্তু অনেকগুলি সেটের সাথে সম্পর্কিত হতে পারে।

আমরা বলছি না যে উপরোক্ত সম্ভাবনাগুলি কেবল দুটি, বা এর মধ্যে যে কোনও একটি গণিত কী তা সম্পূর্ণরূপে বর্ণনা করে। তবুও, প্রত্যেকে দেখতে পাচ্ছেন যে সাধারণ গাণিতিক তত্ত্বের জন্য একটি কার্যকর সূচনার পয়েন্ট হিসাবে পরিবেশন করতে পারেন যা গাণিতিক ক্রিয়াকলাপগুলির বিস্তৃত পরিসীমা বর্ণনা করে।

এটা একটা টাইপ নেওয়া স্বাভাবিক আর তিনি সব কিছু যে আমরা নিয়ম ব্যবহার গঠন করা যেতে পারে সংগ্রহ কল্পনা টি । এই এক্সটেনশন এর টি , এবং এটা না টি নিজেই। উদাহরণস্বরূপ, এখানে দুটি ধরণের যা নির্মাণের বিভিন্ন বিধি রয়েছে, তবে তাদের একই বিস্তৃতি রয়েছে:TTT T

  1. জোড়গুলির ধরণ যেখানে এন একটি প্রাকৃতিক সংখ্যা হিসাবে নির্মিত হয় , এবং p প্রমাণ হিসাবে প্রমাণিত হয় যে এন 3 এর চেয়ে বড় সংখ্যার বড় সংখ্যা ।(n,p)npn3

  2. জোড় এর ধরণ যেখানে এম প্রাকৃতিক সংখ্যা হিসাবে নির্মিত হয় এবং Q প্রমাণ হিসাবে প্রমাণিত হয় যে এম 2 এর চেয়ে ছোট একটি অদ্ভুত প্রধান ।(m,q)mqm2

হ্যাঁ, এগুলি নির্লজ্জ তুচ্ছ উদাহরণ, তবে মূল বক্তব্য: উভয় প্রকারের বর্ধনে কিছুই নেই , তবে তাদের নির্মাণের বিভিন্ন বিধি রয়েছে। বিপরীতে, সেটগুলি  চেয়ে বড় বড়  এবং { m Nm  একটি বিজোড় প্রাইম 2 } এর চেয়ে কম ছোট  কারণ তাদের উপাদানগুলি একই।

{nNn is an even prime larger than 3}
{mNm is an odd prime smaller than 2}

নোট করুন যে প্রকারের তত্ত্বটি সিনট্যাক্স সম্পর্কিত নয়। এটি নির্মাণের গাণিতিক তত্ত্ব, ঠিক যেমন সেট তত্ত্বটিও সংগ্রহের গাণিতিক তত্ত্ব। এটা ঠিক যে টাইপ তত্ত্বের স্বাভাবিক উপস্থাপনা সিনট্যাক্স জোর দেওয়া, এবং এর ফলে মানুষ চিন্তা টাইপ তত্ত্ব শেষ হয় সিনট্যাক্স। এই ক্ষেত্রে না হয়. গাণিতিক অবজেক্ট (নির্মাণ) কে এমন সিন্ট্যাকটিক এক্সপ্রেশন দিয়ে বিভ্রান্ত করা যা এটি প্রতিনিধিত্ব করে (পূর্বের একটি শব্দ) এটি একটি মৌলিক বিভাগের ভুল যা দীর্ঘকাল ধরে লজিস্টদেরকে বিস্মিত করেছে, তবে আর নয়।


1
Beautiful, thank you! Could you clarify one detail? when you list the two types whose extension are both empty, you say that "the type whose elements are ...". Purely for my clarity, is this a 100% correct way of saying it? You said in the previous sentence that a type is not a collection, so it seems like it cannot have "elements" (which I associate with sets). Essentially, the way you've written it now, it is as if you're defining the Type according to the set that is its extention. If you didn't intend this, could you rephrase them more precisely to capture their idea as types?
user56834

The extension of a type is a very useful concept, and since it is a kind of collection, we can say "element of the extension of a type". This is cumbersome so it often gets abbreviated to just "element of a type". I removed the phrasing to decrease the possibility of confusion, but beware, it's common terminology.
Andrej Bauer

Thank you, this clarifies. So to follow up, is it correct to say the following? To say that an object is "of type T" means the same thing as, the object is "an element of the extension of T", so that there is a natural surjection from types to sets. But the converse does not hold, because any set can be constructed in multiple ways. Essentially, the difference between set and type is not important from the perspective of a particular object x, in the sense that x:T and xXT (where XT is the extension of T) give us the exact same information about x. However,
user56834

The difference is relevant when we want to talk about types and sets, and their properties and relations. So in other words, the information that we lose when we say xXT rather than x:T does not tell us anything relevant about x, but the same may not hold if we e.g. want to talk about superset-subset or type-subtype relations? Is that correct?
user56834

4
Yeah, one wonders where these books are. Someone should write them.
Andrej Bauer

11

To start, sets and types aren't even in the same arena. Sets are the objects of a first-order theory, such as ZFC set theory. While types are like overgrown sorts. To put it a different way, a set theory is a first-order theory within first-order logic. A type theory is an extension of logic itself. Martin-Löf Type Theory, for example, is not presented as a first-order theory within first-order logic. It's not that common to talk about sets and types at the same time.

SVscale:S×VV. This lets us know that scale(scale(s,v),v) is simply not a well-formed term. In a type theoretic context, an expression like f(x) requires f to have a type XY for some types X and Y. If f does not have the type of a function, then f(x) is simply not a well-formed expression. Whether an expression is of some sort or has some type is a meta-logical statement. It makes no sense to write something like: (x:X)y=3. First, x:X is simply not a formula, and second, it doesn't even conceptually make sense as sorts/types are what let us know which formulas are well-formed. We only consider the truth value of well-formed formulas, so by the time we're considering whether some formula holds, we better already know that it is well-formed!

In set theory, and particularly ZFC, the only non-logical symbol at all is the relation symbol for set membership, . So xy is a well-formed formula with a truth value. There are no terms other than variables. All the usual notation of set theory is a definitional extension to this. For example, a formula like f(x)=y is often taken to be shorthand for (x,y)f which itself may be taken as shorthand for p.pfp=(x,y) which is shorthand for

p.pf(z.zp[z=x(w.wzw=y)])
At any rate, any set can take the place of f and everything is a set! As I pointed out in a different question recently, π(7)=3 where π is the real number is a completely legitimate and meaningful (and potentially even true) set theoretic expression. Basically, anything you write that parses in set theory can be given some meaning. It may be a completely spurious meaning, but it has one. Sets are also "first-class" objects in set theory. (They better be as they are the only objects usually.) A function like
f(x)={N,if x=17,if x=QxRR,if x=(Z,N)
is a completely legitimate function in set theory. There is nothing even remotely analogous to this in type theory. The closest would be to use codes for a Tarskian universe. Sets are the objects of set theory; types are not the object of type theory.

A type is not a collection of things (neither is a set for that matter...), and it is not defined by a property. A type is a syntactic category that lets you know what operations are applicable to terms of that type and which expressions are well-formed. From a propositions-as-types perspective, what types are classifying are the valid proofs of the proposition to which the type corresponds. That is, the well-formed (i.e. well-typed) terms of a given type correspond to the valid proofs (which are also syntactic objects) of the corresponding proposition. Nothing like this is happening in set theory.

Set theory and type theory are really not anything alike.


1
It is false that types are only syntactic entities.
Andrej Bauer

1
This is very helpful, but one main point in your answer bugs me. It seems to me that it is a mistake (which many people make, or alternatively it is not a mistake and I'm wrong), to say that "a set is not a collection of things". I would say that a set IS a collection of things. That is the most basic essential property of a set. In fact, how would we possibly know that e.g. ZFC are the right axioms to choose (rather than completely arbitrary formulas), without being able to tell that they are true given that sets are collections of objects? Of course, I understand that ...
user56834

Axiomatic set theory treats sets as objects, and as just a symbol, because axiomatic set theory is not a mathematical structure in the mathematical logic sense.
user56834

1
@Programmer2134 To answer that, we would have to get into the semantic meaning of the word "collection." We can't be sure they are "right" unless you take the time to precisely define what "right" means. However, what we can say is that "set" is the result of over a hundred years of mathematicians beating on the concept of a collection, seeking a consistent system which matches the intuitive concept of a collection. To achieve that consistency, they had to make decisions. For example, sets aren't the only collection in mathematics. A "class" also describes a collection.
Cort Ammon - Reinstate Monica

1
@AndrejBauer I'm taking a (mostly) non-philosophical stance and not trying to explain what types "really" are but more how they're used. (I say "serves as" and "behaves as" at the beginning but I did slip into an "is" at the end.) There is a risk of thinking that a variable x being of type T means that the only "values" that x can "take" are the (presumably closed) terms of type T. This isn't true and is not implied by anything I say above. I agree that you can see types as more than syntactic entities, but I think the different syntactic role types play makes a clear contrast to sets.
Derek Elkins

9

In practice, claiming that x being of type T usually is used to describe syntax, while claiming that x is in set S is usually used to indicate a semantic property. I will give some examples to clarify this difference in usage of types and sets. For the difference in what types and sets actually are, I refer to Andrej Bauer's answer.

An example

To clarify this distinction, I will use the example given in Herman Geuvers' lecture notes. First, we look at an example of inhabiting a type:

3+(78)5:Nat,
and an example of being member of a set:
3{nNx,y,zN+(xn+ynzn)}

The main difference here is that to test whether the first expression is a natural number, we don't have to compute some semantic meaning, we merely have to 'read off' the fact that all literals are of type Nat and that all operators are closed on the type Nat.

However, for the second example of the set, we have to determine the semantic meaning of the 3 in the context of the set. For this particular set, this is quite hard: the membership of 3 for this set is equivalent to proving Fermat's last theorem! Do note that, as stated in the notes, the distinction between syntax and semantics cannot always be drawn that clearly. (and you might even argue that even this example is unclear, as Programmer2134 mentions in the comments)

Algorithms vs Proofs

To summarize, types are often used for 'simple' claims on the syntax of some expression, such that membership of a type can be checked by an algorithm, while to test membership of a set, we would in usually require a proof.

To see why this distinction is useful, consider a compiler of a typed programming language. If this compiler has to create a formal proof to 'check types', the compiler is asked to do an almost impossible task (automated theorem proving is, in general, hard). If on the other hand the compiler can simply run an (efficient) algorithm to check the types, then it can realistically perform the task.

A motivation for a strict(er) interpretation

There are multiple interpretations of the semantic meaning of sets and types. While under the distinction made here extensional types and types with undecidable type-checking (such as those used in NuPRL, as mentioned in the comments) would not be 'types', others are of course free to call them as such (just as free as they are as to call them something else, as long as their definitions fit).

However, we (Herman Geuvers and I), prefer to not throw this interpretation out of the window, for which I (not Herman, although he might agree) have the following motivation:

First of all, the intention of this interpretation isn't that far from that of Andrej Bauer. The intention of a syntax is usually to describe how to construct something and having an algorithm to actually construct it is generally useful. Furthermore, the features of a set are usually only needed when we want a semantic description, for which undecidability is allowed.

So, the advantage of our more stricter description is to keep the separation simpler, to get a distinction more directly related to common practical usage. This works well, as long as you don't need or want to loosen your usage, as you would for, e.g. NuPRL.


3
Type checking doesn't need to be decidable (though it is certainly desirable). NuPRL, for instance, does require the user to provide a proof that a term inhabits a type.
Derek Elkins

3
Thank you. Things are becoming more clear. Heres what I'm wondering still: isn't there a semantic element to type theory and a syntactic element to set theory? For example, we can instead of seeing your "3..." statement as a semantic statement, see it as a proposition in axiomatic set theory, no? Also, doesn't the type "Nat" have a semantic meaning, namely that whatever precedes it is a natural number? So it still confuses me to say rhat sets are semantic and types syntactic properties.
user56834

1
@DerekElkins I'm not familiar with NuPRL, but e.g. the proof assistant Coq most certainly does type checking by itself (i.e, is the provided term of the 'type of my theorem'). How does NuPRL verify the proof if the user has to 'prove' the fact that a term of a certain type? (in other words, this sounds like NuPRL doesn't use the Curry-Howard correspondence, so what does it use?)
Discrete lizard

1
@Discretelizard I'm not saying NuPRL is typical. It is definitely the usual case for type checking to be decidable. I highly recommend becoming familiar with it just because it takes a fairly different path. NuPRL is a Curry-style rather than Church-style calculus which makes it more of a type refinement system. At any rate, instead of just writing terms (or tactics that produce terms), you have essentially an LCF-style proof system for typing derivations themselves. Arguably, the derivations are what's important, and it's a bit of a "fluke" that we can infer them from terms.
Derek Elkins

3
I elaborated in my answer why it is detrimental to think of type theory as "syntactic". Your first sentence is the offeding one, when you say that "inhabiting a type is a syntactic property". There's as much truth in that as in saying that "being an element of a set is to stand on the left of the symbol ".
Andrej Bauer

4

I believe that one of the most concrete differences about sets and types is the difference in the way the "things" in your mind are encoded into the formal language.

Both sets and types allow you to speak about things, and collections of things. The main difference is that with sets, you can ask any question you want about things and it will maybe be true, maybe not; while with types, you first have to prove that the question makes sense.

For example, if you have booleans B={true,false} and natural numbers N={0,1,}, with types, you can not ask if true=1 which you can with sets.

One way to interpret this is that with sets, everything is encoded into a single collection: the collection of all sets. 0 is encoded as [0]={}, n+1 is encoded as [n+1]={[n]}[n] and true and false can be encoded by any two distinct sets. So that it actually makes sense to ask if true=1, as it can be understood as asking if "the encoding chosen for true is the same as the encoding chosen for 1". But the answer to this question could change if we chose another encoding: it is about the encodings and not really about the things.

You can then think of types as describing the encoding of the things inside it. With types, to ask the question of whether a=b, you first have to show that a and b have the same type, i.e. that they were encoded in the same way, which prohibits questions such as true=1. You could still want to have a big type S in which both B and N could be encoded, and then given two encodings ιB:BS and ιN:NS, you could ask whether ιB(true)=ιN(1) but the fact that this question depends on the encodings (and the choice of encodings) is now explicit.

Note that in those cases, whether the question made sense was actually easy to see but it could be much harder as in, for example, (ifvery_hard_questionthen1elsetrue)=1.

In summary, sets let you ask any question you want, but types force you to make encodings explicit when the answer may depend on them.


You are probably thinking of one specific kind of set theory (something along a single-sorted theory a la ZFC). However, there are other kinds of set theory which require lots of checking that it makes sense. And the way set theory is used in practice is much closer to these other set theories. Do you think a student could ask "Is R an element of sin(2)?" without being scolded? The distinction between type theory and set theory is not in the formalism, it's in the meaning.
Andrej Bauer

@AndrejBauer Right. Would you agree that this answer gives a differences between single-sorted theories (including most set theories, or at least the most common ones), and multi-sorted theories (including all (?) type theories)?
xavierm02

Even in a single-sorted theory you have to distinguish terms from formulas...
Andrej Bauer

@AndrejBauer I don't understand your second comment.
xavierm02

A single-sorted first-order theory has two syntactic categories: logical formulas and terms. One has to make sure they're not mixed up, or else you could end up writing "(xX.ϕ(x))N".
Andrej Bauer
আমাদের সাইট ব্যবহার করে, আপনি স্বীকার করেছেন যে আপনি আমাদের কুকি নীতি এবং গোপনীয়তা নীতিটি পড়েছেন এবং বুঝতে পেরেছেন ।
Licensed under cc by-sa 3.0 with attribution required.