是否有用于提供证明/推导的 Mathematica 软件包?
当我在纸上写下证明或推导时,当我从一个步骤移动到下一步时,我经常会犯符号错误或删除术语。我想使用 Mathematica 来避免这些愚蠢的错误。我不想让 Mathematica 求解表达式,我只想用它执行并显示一系列代数运算。对于一个(简单的)例子,
In[111]:= MultBothSides[Equal[a_, b_], c_] := Equal[c a, c b];
In[112]:= expression = 2 a == a b
Out[112]= 2 a == a b
In[113]:= MultBothSides[expression, 1/a]
Out[113]= 2 == b
任何人都可以向我指出一个支持这种操作的包吗?
编辑
感谢您的输入,但不完全是我想要的。符号操作并不是真正的问题。我真的在寻找能够明确推导每一步的代数或数学论证的东西。我在这里的目标确实是教学性的。
When I write out a proof or derivation on paper I frequently make sign errors or drop terms as I move from one step to the next. I'd like to use Mathematica to save myself from these silly mistakes. I don't want Mathematica to solve the expression, I just want to use it carry out and display a series of algebraic manipulations. For a (trivial) example
In[111]:= MultBothSides[Equal[a_, b_], c_] := Equal[c a, c b];
In[112]:= expression = 2 a == a b
Out[112]= 2 a == a b
In[113]:= MultBothSides[expression, 1/a]
Out[113]= 2 == b
Can anyone point me to a package that would support this kind of manipulation?
Edit
Thanks for the input, not quite what I'm looking for though. The symbol manipulation isn't really the problem. I'm really looking for something that will make explicit the algebraic or mathematical justification of each step of a derivation. My goal here is really pedagogical.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Mathematica 还提供了许多用于处理代数的高级函数。其中包括
Expand
、Apart
和Together
以及Cancel
,不过还有很多。此外,对于对方程两边应用相同转换的具体示例(即,带有头部
Equal
的表达式),您可以使用Thread
函数,它的工作原理与您的MultBothSides
函数类似,但具有更多的通用性。在所提出的任一解决方案中,应该相对容易看出该步骤需要做什么。如果您想要更明确的东西,您可以编写自己的函数,如下所示:
它是
MultBothSides
函数的泛化,利用了Map
在表达式上工作的事实任何头部,而不仅仅是头部List
。如果您尝试与不熟悉 Mathematica 的受众进行交流,使用此类名称可以帮助您更清晰地进行交流。与此相关,如果您想按照 Ira Baxter 的建议使用替换规则,则写出 Replace 或 ReplaceAll 而不是使用/.
语法糖可能会有所帮助。如果您认为在输入中使用实际方程而不是变量名称
表达式
会更清晰,并且您使用的是笔记本界面,请突出显示单词表达式
> 用鼠标调出上下文菜单,然后选择“就地评估”。笔记本界面也是进行“文学编程”的一个非常愉快的环境,因此您还可以解释任何文字上不明显的步骤。我相信在编写数学证明时,无论使用何种媒介,这都是一个很好的做法。
Mathematica also provides a number of high-level functions for manipulating algebraic. Among these are
Expand
,Apart
andTogether
, andCancel
, though there are quite a few more.Also, for your specific example of applying the same transformation to both sides of an equation (that is, and expression with the head
Equal
), you can use theThread
function, which works just like yourMultBothSides
function, but with a great deal more generality.In either of the presented solutions, it should be relatively easy to see what the step entailed. If you want something a little more explicit, you can write your own function like so:
It's a generalization of your
MultBothSides
function that takes advantage of the fact thatMap
works on expressions with any head, not just headList
. If you're trying to communicate with an audience that is unfamiliar with Mathematica, using these sorts of names can help you communicate more clearly. In a related vein, if you want to use replacement rules as suggested by Ira Baxter, it may be helpful to write out Replace or ReplaceAll instead of using the/.
syntactic sugar.If you think it would be clearer to have the actual equation, instead of the variable name
expression
, in your input, and you're using the notebook interface, highlight the wordexpression
with your mouse, call up the contextual menu, and select "Evaluate in Place".The notebook interface is also a very pleasant environment for doing "literate programming", so you can also explain any steps that are not immediately obvious in words. I believe this is a good practice when writing mathematical proofs regardless of the medium.
我认为你不需要包裹。你要做的就是根据推理规则来操作每个公式。在 MMa 中,您可以使用转换对公式的推理规则进行建模。因此,如果您有一个公式 f,您可以通过执行(我的 MMa 语法已经 15 年了)来应用推理规则 I
来生成序列中的下一个公式。
如果公式包含标准代数运算符和术语,例如常数和算术运算符,MMa 当然会尝试简化您的公式。您可以通过将公式包含在 Hold[...] 表单中来防止 MMa 应用其自己的“推理”规则。
I don't think you need a package. What you want to do is to manipulate each formula according to an inference rule. In MMa, you can model inference rules on a formula using transformations. So, if you have a formula f, you can apply an inference rule I by executing (my MMa syntax is 15 years rusty)
to produce the next formula in your sequence.
MMa will of course try to simplify your formulas if they contain standard algebraic operators and terms, such as constant numbers and arithmetic operators. You can prevent MMa from applying its own "inference" rules by enclosing your formula in a Hold[...] form.