简体   繁体   English

了解Agda中的分配解决方案

[英]Understanding Assignment Solution in Agda

Consider the following extracted piece of code for proving the "Unicity of Typing" for variable in Agda: 考虑以下提取的代码段,以证明Agda中变量的“打字唯一性”:

unicity : ∀ {Γ₁ Γ₂ e τ₁ τ₂} →  (Γ₁ ⊢ e ∷ τ₁) → (Γ₂ ⊢ e ∷ τ₂) → (Γ₁ ≈ Γ₂) → (τ₁ ∼ τ₂)
unicity   (VarT here) (VarT here) (_ , ( τ∼ , _ ))   = τ∼ 
unicity (VarT here) (VarT (ski`p {α = α} lk2)) (s≡s' , ( _ , _ )) = ⊥-elim (toWitnessFalse α (toWitness` s≡s'))
unicity (VarT (skip {α = α} lk1)) (VarT here) (s'≡s , ( _ , _ )) = ⊥-elim (toWitnessFalse α (toWitness s'≡s))
unicity (VarT (skip lk1)) (VarT (skip lk2)) (_ ,( _ , Γ≈ ))     = unicity (VarT lk1) (VarT lk2) Γ≈

I need an explanation on the working of ⊥-elim , toWitnessFalse and toWitness . 我需要对⊥-elim toWitnessFalsetoWitnessFalsetoWitness的工作进行解释。 Also, what do the expressions and mean/stand for? 此外,什么做的表达平均值/代表什么?

is the empty type, so (in a total, consistent language) you can never construct a value of type . 是空类型,因此(从总体上来说,一致的语言)您永远无法构造类型的值。 But this also means that any proposition you can think of, follows from . 但是,这也意味着您能想到的任何命题都来自 This is what ⊥-elim witnesses: 这是⊥-elim见证:

⊥-elim : ∀ {w} {Whatever : Set w} → ⊥ → Whatever

This is very useful in practice because you might be writing proofs under some assumption, and some of those assumptions might be , or they might be negative statements ( A → ⊥ for some A ) and you can prove the A as well, etc. Then, what you find out is effectively that you don't have to care about that particular branch anymore, since it is impossible; 这在实践中非常有用,因为您可能在某些假设下编写证明,而其中一些假设可能是 ,或者它们可能是负面陈述(对于某些A A → ⊥ ),并且您也可以证明A等。然后,您发现实际上不再需要关心那个特定的分支,因为这是不可能的。 but then, just because you don't care, you still have to formally satisfy the result type somehow. 但是,只是因为您不在乎,您仍然必须以某种方式正式满足结果类型。 This is what ⊥-elim gives you. 这就是⊥-elim给您的。

toWitness 's type and related definitions are as follows: toWitness的类型和相关定义如下:

T : Bool → Set
T true  = ⊤
T false = ⊥

⌊_⌋ : ∀ {p} {P : Set p} → Dec P → Bool
⌊ yes _ ⌋ = true
⌊ no  _ ⌋ = false

True : ∀ {p} {P : Set p} → Dec P → Set
True Q = T ⌊ Q ⌋

toWitness : ∀ {p} {P : Set p} {Q : Dec P} → True Q → P

Given a Q : Dec P , True Q is either (if Q = yes _ ) or (if Q = no _ ). 给定一个Q : Dec P ,则True Q (如果Q = yes _ )或 (如果Q = no _ )。 The only way to call toWitness , then, is to have Q say that P is true and pass the trivial unit constructor tt : ⊤ ; 那么,调用toWitness的唯一方法是让Q表示P为真,并传递琐碎的单元构造函数tt : ⊤ ; the only other possibility would be to have Q say that P is false, and pass as an argument a but as we've seen, that's not possible. 唯一的可能是将有Q说, P是假的,并作为参数传递一个 ,但正如我们看到的,这是不可能的。 In summary, toWitness says that if Q tells us the decision that P holds, then we can get a proof of P from Q . 总而言之, toWitness说,如果Q告诉我们P成立的决定,那么我们可以从Q获得P的证明。

toWitnessFalse is exactly the same with the roles reversed: if Q tells us the decision that P doesn't hold, then we can get a proof of ¬ P from Q . toWitnessFalse是完全与角色相同的逆转:如果Q告诉我们,决定P不成立,那么我们可以得到证明¬ PQ

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM