Challenge on Alphabet and Formal Grammar and Language - set

We know set A is countable if A is finite or in a one-to-one mapping to natural numbers.
Suppose ALPH be an arbitrary finite alphabet.
I summarize my inference:
a) Each arbitrary Language on ALPH is Countable. (I think this is True)
b) the set of all language from ALPH is Countable.(I think this is False)
c) for Each arbitrary Language on ALPH we have a generative formal grammar. (I think this is False)
d) Each arbitrary Language on ALPH that can be generated by formal grammar, is recursive. (I think this is True)
anyone could help me, and maybe correct me?

Without loss of generality, we can assume that ALPH is merely the set {0,1}. (Any other finite language can of course be encoded using the set {0,1}). Assuming that by a language L that you intend some arbitrary subset of ALPH*, we can assume that L is an arbitrary subset of {0,1}*.
Let S = {0,1}*.
a) The set S is countable. Since L is a subset of S, L is countable.
b) The set of all languages over S then is the powerset of S, which can be put into 1-1 correspondence with the Real numbers. Hence, not countable.
c) I believe that this is false, agreeing with your supposition. However, it depends on your definition of a 'generative formal grammar'. If you allow for formal grammars where individual rules of the grammar are undecidable, and/or allow for infinite generation rules, this becomes less clear. For any particular definition for 'generative formal grammar', where the collection of 'generative formal grammars' is enumerable, then of course, the answer is false.
d) In general, I believe that the answer to this is false. If you restrict yourself to formal grammars corresponding to context-free languages, then of course, your answer is true. However, consider http://en.wikipedia.org/wiki/Post_correspondence_problem The problem is undecidable, yet the generation rules are pretty clear.

Related

Show that the language is undecidable

Consider the language
Consider the language
Aabb = {< M > | M is a TM, and M accepts abb}
a) What is the computational problem that is represented by Aabb?
b) Show that Aabb is undecidable.
I tried proving it but didn't know what to do.
You can use Rice's theorem directly and correctly prove the claim by noting that some TMs accept aab, some don't, and acceptance of abb is a semantic property of languages (it has to do only with the strings accepted, not the manner of accepting them). Rice guarantees this language is undecidable.
If you want another kind of proof, consider the following. There's nothing special about the string abb. If this problem is decidable, we'd expect the problem to be decidable for any arbitrary string. If it were decidable for any arbitrary string, we could use dovetailing to decide whether the language of the TM were empty. If we could decide whether the language of a TM were empty, we could take any TM, change all instances of halt-reject to halt-accept, and then decide whether the TM halts on at least one input. Etc. Etc. Basically, you can construct a chain of implications as long as you want but you quickly find known undecidable problems you can reduce to.

How to define set in coq without defining set as a list of elements

I am trying to define (1,2,3) as a set of elements in coq. I can define it using list as (1 :: (2 :: (3 :: nil))). Is there any way to define set in coq without using list.
The are basically four possible choices to be made when defining sets in Coq depending on your constraints on the base type of the set and computation needs:
If the base type doesn't have decidable equality, it is common to use:
Definition Set A := A -> Prop
Definition cup A B := fun x => A x /\ B x.
...
basically, Coq's Ensembles. This representation cannot "compute", as we can't even decide if two elements are equal.
If the base data type has decidable equality, then there are two choices depending if extensionality is wanted:
Extensionality means that two sets are equal in Coq's logic iff they have the same elements, formally:
forall (A B : set T), (A = B) <-> (forall x, x \in A <-> x \in B).
If extensionality is wanted, sets should be represented by a canonically-sorted duplicate-free structure, usually a list. A good example is Cyril's Cohen finmap library. This representation however is very inefficient for computing as re-sorting is needed every time a set is modified.
If extensionality is not needed (usually a bad idea if proofs are wanted), you can use representations based on binary trees such as Coq's MSet, which are similar to standard Functional Programming set implementations and can work efficiently.
Finally, when the base type is finite, the set of all sets is a finite type too. The best example of this approach is IMO math-comp's finset, which encodes finite sets as the space of finitely supported membership functions, which is extensional, and forms a complete lattice.
The standard library of coq provides the following finite set modules:
Coq.MSets abstracts away the implementation details of the set. For instance, there is an implementation that uses AVL trees and another based on lists.
Coq.FSets abstracts away the implementation details of the set; it is a previous version of MSets.
Coq.Lists.ListSet is an encoding of lists as sets, which I am including for the sake of completeness
Here is an example on how to define a set with FSets:
Require Import Coq.Structures.OrderedTypeEx.
Require Import Coq.FSets.FSetAVL.
Module NSet := FSetAVL.Make Nat_as_OT.
(* Creates a set with only element 3 inside: *)
Check (NSet.add 3 NSet.empty).
There are many encodings of sets in Coq (lists, function, trees, ...) which can be finite or not. You should have a look at Coq's standard library. For example the 'simplest' set definition I know is this one

Flattening quantification over relations

I have a Relation f defined as f: A -> B × C. I would like to write a firsr-order formula to constrain this relation to be a bijective function from A to B × C?
To be more precise, I would like the first order counter part of the following formula (actually conjunction of the three):
∀a: A, ∃! bc : B × C, f(a)=bc -- f is function
∀a1,a2: A, f(a1)=f(a2) → a1=a2 -- f is injective
∀(b, c) : B × C, ∃ a : A, f(a)=bc -- f is surjective
As you see the above formulae are in Higher Order Logic as I quantified over the relations. What is the first-order logic equivalent of these formulae if it is ever possible?
PS:
This is more general (math) question, rather than being more specific to any theorem prover, but for getting help from these communities --as I think there are mature understanding of mathematics in these communities-- I put the theorem provers tag on this question.
(Update: Someone's unhappy with my answer, and SO gets me fired up in general, so I say what I want here, and will probably delete it later, I suppose.
I understand that SO is not a place for debates and soapboxes. On the other hand, the OP, qartal, whom I assume is the unhappy one, wants to apply the answer from math.stackexchange.com, where ZFC sets dominates, to a question here which is tagged, at this moment, with isabelle and logic.
First, notation is important, and sloppy notation can result in a question that's ambiguous to the point of being meaningless.
Second, having a B.S. in math, I have full appreciation for the logic of ZFC sets, so I have full appreciation for math.stackexchange.com.
I make the argument here that the answer given on math.stackexchange.com, linked to below, is wrong in the context of Isabelle/HOL. (First hmmm, me making claims under ill-defined circumstances can be annoying to people.)
If I'm wrong, and someone teaches me something, the situation here will be redeemed.
The answerer says this:
First of all in logic B x C is just another set.
There's not just one logic. My immediate reaction when I see the symbol x is to think of a type, not a set. Consider this, which kind of looks like your f: A -> BxC:
definition foo :: "nat => int × real" where "foo x = (x,x)"
I guess I should be prolific in going back and forth between sets and types, and reading minds, but I did learn something by entering this term:
term "B × C" (* shows it's of type "('a × 'b) set" *)
Feeling paranoid, I did this to see if had fallen into a major gotcha:
term "f : A -> B × C"
It gives a syntax error. Here I am, getting all pedantic, and our discussion is ill-defined because the notation is ill-defined.
The crux: the formula in the other answer is not first-order in this context
(Another hmmm, after writing what I say below, I'm full circle. Saying things about stuff when the context of the stuff is ill-defined.)
Context is everything. The context of the other site is generally ZFC sets. Here, it's HOL. That answerer says to assume these for his formula, wich I give below:
Ax is true iff x∈A
Bx is true iff x∈B×C
Rxy is true iff f(x)=y
Syntax. No one has defined it here, but the tag here is isabelle, so I take it to mean that I can substitute the left-hand side of the iff for the right-hand side.
Also, the expression x ∈ A is what would be in the formula in a typical set theory textbook, not Rxy. Therefore, for the answerer's formula to have meaning, I can rightfully insert f(x) = y into it.
This then is why I did a lot of hedging in my first answer. The variable f cannot be in the formula. If it's in the formula, then it's a free variable which is implicitly quantified. Here's the formula in Isar syntax:
term "∀x. (Ax --> (∃y. By ∧ Rxy ∧ (∀z. (Bz ∧ Rxz) --> y = z)))"
Here it is with the substitutions:
∀x. (x∈A --> (∃y. y∈B×C ∧ f(x)=y ∧ (∀z. (z∈B×C ∧ f(x)=z) --> y = z)))
In HOL, f(x) = f x, and so f is implicitly, universally quantified. If this is the case, then it's not first-order.
Really, I should dig deep to recall what I was taught, that f(x)=y means:
(x,f(x)) = (x,y) which means we have to have (x,y)∈(A, B×C)
which finally gets me:
∀x. (x∈A -->
(∃y. y∈B×C ∧ (x,y)∈(A,B×C) ∧ (∀z. (z∈B×C ∧ (x,z)∈(A,B×C)) --> y = z)))
Finally, I guess it turns out that in the context of math.stackexchange.com, it's 100% on.
Am I the only one who feels compulsive about questioning what this means in the context of Isabelle/HOL? I don't accept that everything here is defined well enough to show that it's first order.
Really, qartal, your notation should be specific to a particular logic.
First answer
With Isabelle, I answer the question based on my interpretation of your
f: A -> B x C, which I take as a ZFC set, in particular a subset of the
Cartesian product A x (B x C)
You're sort of mixing notation from the two logics, that of ZFC
sets and that of HOL. Consequently, I might be off on what I think you're
asking.
You don't define your relation, so I keep things simple.
I define a simple ZFC function, and prove the first
part of your first condition, that f is a function. The second part would be
proving uniqueness. It can be seen that f satisfies that, so once a
formula for uniqueness is stated correctly, auto might easily prove it.
Please notice that the
theorem is a first-order formula. The characters ! and ? are ASCII
equivalents for \<forall> and \<exists>.
(Clarifications must abound when
working with HOL. It's first-order logic if the variables are atomic. In this
case, the type of variables are numeral. The basic concept is there. That
I'm wrong in some detail is highly likely.)
definition "A = {1,2}"
definition "B = A"
definition "C = A"
definition "f = {(1,(1,1)), (2,(1,1))}"
theorem
"!a. a \<in> A --> (? z. z \<in> (B × C) & (a,z) \<in> f)"
by(auto simp add: A_def B_def C_def f_def)
(To completely give you an example of what you asked for, I would have to redefine my function so its bijective. Little examples can take a ton of work.)
That's the basic idea, and the rest of proving that f is a function will
follow that basic pattern.
If there's a problem, it's that your f is a ZFC set function/relation, and
the logical infrastructure of Isabelle/HOL is set up for functions as a type.
Functions as ordered pairs, ZFC style, can be formalized in Isabelle/HOL, but
it hasn't been done in a reasonably complete way.
Generalizing it all is where the work would be. For a particular relation, as
I defined above, I can limit myself to first-order formulas, if I ignore that
the foundation, Isabelle/HOL, is, of course, higher-order logic.

language over {1} which is recognizable but not decidable?

What is an example of a language over the alphabet {1}* which is recognizable but not decidable?
I have troubles finding an example of this. After a long search, I am still curious for the answer though.
A hint would be very welcome.
Since the universe of strings over any finite alphabet is countable, every language can be mapped to a subset of the natural numbers. So you just have to take a Recursively enumerable language wich is not decidable and map it into a subset of {1}*.
For example, in the classic version of the halting problem we enumerate every turing machine into a binary string; you can now sort all the turing machines and define a map f : TM -> N from Turing machines to integers where f(TM) = n if TM is the nth turing machine in the ordered list of all TM.
Now, the halting problem for turing machines coded as unary numbers is r.e. but not decidable.
Imagine a machine that given two machines whose alphabets are {1}*, accepts if the first can generate all strings that the second can generate.
Our machine halts if it accepts. But for strings not in the language (the first given machine cannot generate all the strings the second one can), our machine may halt and reject, or may never halt. This means that our Turing Machine is Recognizable, but it is not decidable.
See the Encyclopedia of Mathematics for more on recognizable and undecidable languages (specifically page 56).
The only subset that is not decidable in {1}* is the empty set.
We can define a Language over {1}* in terms of a TM:
L = { < M > | M is a TM and L(M) = empty }
So we can show that L is not decidable, because a TM U that receive L as a input need to test all elements over {1}* and then decide to accept in case of M rejected all of them, so it will never halt and it means that L is not decidable, implies that the empty Language is not decidable

Exhibiting an algorithm that determines if L = L*, given any regular language L

I am studying membership algorithms and I am working on this particular problem which says the following:
Exhibit an algorithm that, given any regular language L, determines whether or not L = L*
So, my first thought was, we have L* which is Kleene star of L and to determine if L = L*, well couldn't we just say that since L is regular, we know L* is by definition which states that the family of regular languages is closed under star-closure.
Therefore L will always be equal to L*?
I feel like there is definitely a lot more to it, there is probably something I am missing. Any help would be appreciated. Thanks again.
since L is regular, we know L* is by definition which states that the family of regular languages is closed under star-closure. Therefore L will always be equal to L*?
No. Regular(L) --> Regular(L*), but that does not mean that L == L*. Just because two languages are both regular does not mean that they are the same regular language. For instance, a* and b* are both regular languages, but this does not make them the same language.
A example of L != L* would be the language L = a*b*, and thus L* = (a*b*)*. The string abab is part of L* but not part of L.
As far as an algorithm goes, let me remind you that the concept of a regular language is one that can be parsed by a DFA - and for any given DFA, there is a single optimal reduction of that DFA.
The implication that you stated is wrong. Closedness under the Kleene star means only that L* is again regular, if L is regular.
One possibility to check whether L = L* is to compute the minimal automaton for both and then checking for equivalence.

Resources