簡體   English   中英

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

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

有沒有一種方法可以在Agda中以編程方式構造(子)證明? 因為一些證明非常相似,最好簡化它們……但是我不知道該怎么做。 例如考慮以下代碼

{-
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

為什么我不能只使用以下簡化的單行證明?

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

模式匹配似乎是這種行為的原因。 但是我不明白為什么。

您可以使用Agda的反射功能以編程方式生成證明。

這是您使用可重用策略解決問題的示例。 對於這個問題,我將其綜合考慮,所以我不能保證這是最有效的策略。 但是,它應該使您了解如何在Agda中解決此類問題!

最重要的是,您可以編寫這樣的實現:

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

在阿格達(Agda)中,您可以quoteGoal g in e使用quoteGoal g in e將當前目標類型和環境確認為一個值。 g將綁定到確定的目標,並且將在e范圍內。 這兩個都應具有Term類型

您可以使用unquoteTerm值轉換回Agda語法。

所有這些都可以使用tactic關鍵字捆綁在一起。 您可以在變更日志中閱讀一些稍微過時的有關tactic信息,大概在Wiki上的某個地方可以閱讀更多。 https://github.com/agda/agda/blob/master/CHANGELOG

對稱性的證明是通過考察ope的論點的所有可能情況來進行的。 在Agda中,您可以通過模式匹配按案例進行推理。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM