在精益

时间:2017-08-11 00:40:12

标签: dependent-type formal-verification lean

我想在使用精简的拓扑中做一些工作。

作为一个良好的开端,我想证明一些关于sets in lean的简单引理。

例如

def inter_to_union (H : a ∈ set.inter A B) : a ∈ set.union A B :=
    sorry

def set_deMorgan : a ∈ set.inter A B → a ∈ set.compl (set.union (set.compl A) (set.compl B)) :=
sorry

或者,或许更有趣的是

def set_deMorgan2 : set.inter A B = set.compl (set.union (set.compl A) (set.compl B)) :=
sorry

但我无法找到set.unionset.inter的任何消除规则,因此我不知道如何使用它们。

  1. 如何证明引理?
  2. 另外,看definition of sets in lean,我可以看到一些语法,看起来非常像纸质数学,但我不了解依赖类型理论的水平,例如:

    protected def sep (p : α → Prop) (s : set α) : set α :=
    {a | a ∈ s ∧ p a}
    
    1. 如何将上述示例分解为简单的依赖/归纳类型概念?

1 个答案:

答案 0 :(得分:2)

该模块识别具有某种类型α的谓词的集合(α通常称为“宇宙”):

def set (α : Type u) := α → Prop

如果您有一组s : set α而某些x : α可以证明s a,则会将其解释为&x; x属于s'。

在这种情况下,x ∈ Aset.mem x A的符号(我们暂不考虑现在的类型类),其定义如下:

protected def mem (a : α) (s : set α) :=
s a

以上解释了为什么空集表示为始终返回false的<= p>的谓词

instance : has_emptyc (set α) :=
⟨λ a, false⟩

而且,宇宙的表现并不令人惊讶:

def univ : set α :=
λ a, true

我将展示如何证明第一个引理:

def inter_to_union {α : Type} {A B : set α} {a : α} : A ∩ B ⊆ A ∪ B :=
  assume (x : α) (xinAB : x ∈ A ∩ B),        -- unfold the definition of `subset`
  have xinA : x ∈ A, from and.left xinAB,
  @or.inl _ (x ∈ B) xinA

这就像通常的&#34;有点&#34;基本集理论中这些属性的证明。

关于sep的问题 - 你可以看到这样的符号:

set_option pp.notation false
#print set.sep

这是输出:

protected def set.sep : Π {α : Type u}, (α → Prop) → set α → set α :=
λ {α : Type u} (p : α → Prop) (s : set α),
  set_of (λ (a : α), and (has_mem.mem a s) (p a))