问题标签 [automata]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
839 浏览

computer-science - PDA 问题 > 需要帮助

我的任务是构建识别语言A= {a^mb^n |的 PDA m > n} with ∑ = {a, b} ..我有点困惑怎么做..你们能帮我解决这个问题吗?谢谢

0 投票
6 回答
5893 浏览

java - Fixing unescaped XML entities in Java with Regex?

I have some badly formatted XML that I must parse. Fixing the problem upstream is not possible.

The (current) problem is that ampersand characters are not always escaped properly, so I need to convert & into &

If &amp; is already there, I don't want to change it to &amp;amp;. In general, if any well-formed entity is already there, I don't want to destroy it. I don't think that it's possible, in general, to know all entities that could appear in any particular XML document, so I want a solution where anything like &<characters>; is preserved.

Where <characters> is some set of characters defining an entity between the initial & and the closing ;. In particular, < and > are not literals that would otherwise denote an XML element.

Now, when parsing, if I see &<characters> I don't know whether I'll run into a ;, a (space), end-of-line, or another &. So I think that I have to remember <characters> as I look ahead for a character that will tell me what to do with the original &.

I think that I need the power of a Push Down Automaton to do this, I don't think that a Finite State Machine will work because of what I think is a memory requirement - is that correct? If I need a PDA, then a regular expression in a call to String.replaceAll(String, String) won't work. Or is there a Java regex that can solve this problem?

Remember: there could be multiple replacements per line.

(I'm aware of this question, but it does not provide the answer that I am looking for.)

0 投票
3 回答
437 浏览

algorithm - 使用元胞自动机对图中的顶点进行可达性分析

测试图中节点的可达性(有向),可以使用 cellualr Automata 来完成吗?实际上要考虑的是实现一种算法,使用 CA 检查从指定顶点到节点的可达性。甚至可能吗?CA有能力做到这一点吗?

任何想法?

0 投票
1 回答
1523 浏览

recursion - 如何证明加法是原始递归的?

我如何在带有数字的示例中显示加法是原始递归的。

我通过证明理解为什么它是原始递归的,但我无法想象它如何以原始递归方式处理数字。

0 投票
1 回答
527 浏览

regex - 查找其他描述的语言的正则表达式

令 {ab} 为字母集,写一个正则表达式:

1)a和b的个数都是奇数的所有单词的语言;

2) 所有长度为奇数且包含子串 ab 的单词的语言。

另外,如果可能的话,请帮我找到两个不同的表达方式,以帮助加强我对如何解决这些问题的理解。

0 投票
0 回答
81 浏览

automata - 我必须优先考虑什么?(no.of.states)还是(模块化<->可读性)?

正如我在这个问题中所说,我正在使用 DFA 来跟踪所有评论、字符串等。我完成了这个具有 11 个状态的 DFA。

现在我要编写 DFA 来识别 java 中的关键字。

主意:

最初,pos=0。pos 每次转换都加 1。

iskeyword() 是我自己的函数。

isalnum() 可以被任何用户定义的函数替换,这取决于未来的需求。

(许多不相关的转换和自循环虽然存在于实际的 DFA 中,但并未提供)。

(q0) -- !isalnum(pos)-------> (q1) ---iskeyword(pos,pos+len)---> (pos+=len)(q2)----- ! isalnum(pos)-------->(q3[使读取的关键字加粗])---iskeyword(pos,pos+len)-->(q2)。

它至少需要 4 个状态。上述方法与 DFA 的正常实现有很大不同。

我的问题是……

  1. 我可以按照上述方法吗?这样做是对的吗?(如果有效)
  2. 如果我必须以上述方式实现这一点,我该怎么做?构建单独的 DFA 以提高可读性?或者我可以将此 DFA 与识别评论、字符串的 DFA 结合起来(以减少状态数)
0 投票
3 回答
12988 浏览

java - 如何将 NFA/DFA 转换为 java?

我有一个场景,我设计了 NFA 并使用 JFLAP 将其转换为 DFA。

我需要知道,如何用 Java 编写代码?

基本上如何在 Java 中实现这些状态转换。我已经看到了一些使用 switch 和 if 语句执行此操作的示例,但我看不到与 DFA/NFA 设计以及如何使用它在 Java 中实现的任何关系。

0 投票
1 回答
3110 浏览

finite-automata - 计算平方根的图灵机

我想我接近这个答案,但仍然要确认我们是否可以创建一个可以进行实数计算并给出准确结果的图灵机(至少在原则上)?**例如找到整数的平方根。(其输出将是一个实数)我认为我们不能开发这种机器的逻辑是,实数是不可数无限的,对于不可数无限的语言,我们无法创建图灵机。

0 投票
1 回答
791 浏览

theory - 下推自动机

为语言 a^nbc^n+2, n>0 设计下推自动机我被要求为上述语言实现自动机..请帮忙?

每次我将 (a) 压入堆栈时,我都尝试弹出 2 (c)s,但它似乎不适用于奇数个 (a)s ....

0 投票
1 回答
5066 浏览

computer-science - 有限自动机在计算机科学中的应用

我必须从有限自动机的应用程序中选择一个主题来进行演示。有限自动机在计算机科学中有哪些应用?他们可能在编程。