简体   繁体   English

如何避免(不必要?)在Agda中重复使用公理?

[英]How to avoid (unnecessary?) repetitive use of axioms in Agda?

Is there a method to programmatically construct (sub)proofs in Agda? 有没有一种方法可以在Agda中以编程方式构造(子)证明? Because some proofs are very similar and it's better to simplify them... but i don't know how to do this. 因为一些证明非常相似,最好简化它们……但是我不知道该怎么做。 Consider for example the following code 例如考虑以下代码

{-
At first we reaname  Set to 𝓤 (as in Universe)
-}
𝓤 = Set

{-
  We define also a polymorphic idenity
-}
data _==_ {A : 𝓤} (a : A) : A → 𝓤 where
  definition-of-idenity : a == a
infix 30 _==_

{-
  The finite set Ω 
-}
data Ω : 𝓤 where
  A B : Ω

Operation = Ω → Ω → Ω

{-
 symmetry is a function that takes an Operation
 op and returns a proposition about this operation
-}

symmetry : Operation → 𝓤
symmetry op = ∀ x y → op x y == op y x

ope : Operation
ope A A = A
ope A B = B
ope B A = B
ope B B = B

proof-of-symmetry-of-operator-ope : symmetry ope
proof-of-symmetry-of-operator-ope A A = definition-of-idenity
proof-of-symmetry-of-operator-ope B B = definition-of-idenity
proof-of-symmetry-of-operator-ope A B = definition-of-idenity
proof-of-symmetry-of-operator-ope B A = definition-of-idenity

Why I cannot just use the following simplified one-line proof ? 为什么我不能只使用以下简化的单行证明?

proof-of-symmetry-of-operator-ope _ _ = definition-of-idenity

It seems that pattern matching is the cause of such behaviour. 模式匹配似乎是这种行为的原因。 But I don't understand why. 但是我不明白为什么。

You can programmatically generate proofs using Agda's reflection capability. 您可以使用Agda的反射功能以编程方式生成证明。

Here's an example of your problem solved with a reusable tactic. 这是您使用可重用策略解决问题的示例。 I threw this together for this question, so I'm not promising that it's the most robust tactic. 对于这个问题,我将其综合考虑,所以我不能保证这是最有效的策略。 It should give you a sense of how to tackle problems like this in Agda, however! 但是,它应该使您了解如何在Agda中解决此类问题!

The punchline is that you can write implementations like this: 最重要的是,您可以编写这样的实现:

proof-of-symmetry-of-operator-ope : symmetry ope
proof-of-symmetry-of-operator-ope = tactic exhaustive-tactic

http://www.galois.com/~emertens/exhaustive-tactic-example/Tactic.html http://www.galois.com/~emertens/exhaustive-tactic-example/Tactic.html

In Agda you can use quoteGoal g in e to reify the current goal type and environment as a value. 在阿格达(Agda)中,您可以quoteGoal g in e使用quoteGoal g in e将当前目标类型和环境确认为一个值。 g will be bound to the reified goal and will be in scope in e . g将绑定到确定的目标,并且将在e范围内。 Both of these should have type Term 这两个都应具有Term类型

You can convert a Term value back into Agda syntax with unquote . 您可以使用unquoteTerm值转换回Agda语法。

All of this can be bundled up using the tactic keyword. 所有这些都可以使用tactic关键字捆绑在一起。 You can read a bit of slightly outdated information about tactic in the changelog and presumably more somewhere on the wiki. 您可以在变更日志中阅读一些稍微过时的有关tactic信息,大概在Wiki上的某个地方可以阅读更多。 https://github.com/agda/agda/blob/master/CHANGELOG https://github.com/agda/agda/blob/master/CHANGELOG

The proof of symmetry goes by looking at all possible cases for the arguments of ope . 对称性的证明是通过考察ope的论点的所有可能情况来进行的。 In Agda, you do reasoning by cases via pattern matching. 在Agda中,您可以通过模式匹配按案例进行推理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何比较阿格达的Nats向量 - How to compare Vectors of Nats in Agda 一个人如何编写(和调试)一个依赖于两个参数的应用程序 apd2,并使用它来证明这种 ap 在 agda 中的功能性? - How does one write (and debug) a two arguement dependent application, apd2, and use this to prove functoriality of such ap in agda? 如何在 agda 中通过 W 类型进行编码? - How to encode via W-types in agda? 如何在Agda中构造一个可能非空的Set - How to construct a possibly nonempty Set in Agda 如何在 Agda 中定义归纳定义类型的子公式? - How to define a subformula of an inductively defined type in Agda? 如何使用函数依赖和存在量化来删除不必要的参数到我的类型 - How to use functional dependencies and existential quantification to remove an unnecessary parameter to my type 如何理解 agda 中的数据与记录功能? - How does one understand Data vs Record capabilities in agda? Agda:通常/花括号相对于彼此和“:”符号的使用方式 - Agda: How usual/curly braces are used relative to each other and to ':' sign 我怎样才能说服阿格达我的职能具有一定的价值? - How can I convince Agda that my function has a certain value? Agda 模式如何与相同类型的构造函数匹配? - How does agda pattern match with same typed constructors?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM