如何解决∀a:布尔→布尔,∀b:布尔,a(a(a b))= a b在精益

时间:2020-11-03 21:00:23

标签: boolean lean

我尝试解决此问题,但没有任何帮助吗?到目前为止,我的解决方案:

example : ∀ a : bool → bool, ∀ b : bool, a (a (a b)) = a b :=
begin
     assume a b,
     cases a:b,
     cases b,
     cases a,
     have c : tt ≠ ff,
     contradiction,
     sorry,
end

3 个答案:

答案 0 :(得分:0)

这对我来说是一个非常不寻常的问题(我是数学家,所以bool对我而言并不存在),因此我可能缺少有效的方法,但是您当然可以轻描淡写a tta ffb的所有可能性。

example : ∀ a : bool → bool, ∀ b : bool, a (a (a b)) = a b :=
begin
     assume a b,
     cases h₁ : a tt ; 
     cases h₂ : a ff ;  
     cases b,
     repeat { rw h₁ <|> rw h₂ },
end

(在编辑中略有简化)

不要犹豫,问一下语法的一部分是否不清楚(或者更好,请在Zulip上提问)。

我不确定自己尝试做的事情。但是您的行cases a:b在您的上下文中创建了一个称为a的新事物,这很可能引起混乱。 contradiction策略成功的事实是不幸的事故,在这里使用trivial会更清楚。

答案 1 :(得分:0)

使用战术风格:

ERROR_INVALID_PARAMETER

并采用case-bash变体,仍然没有战术:

example : ∀ a : bool → bool, ∀ b : bool, a (a (a b)) = a b :=
begin
  assume a b,
  -- split reasoning into b as ff or tt
  cases hb : b,
  { -- in this case, all b is now ff
    -- so let's split what (a ff) is into ff and tt
    -- since we have two (a ff) expressions in our goal
    cases hf : a ff,
    { -- this case is where (a ff) = ff,
      -- so we use it directly twice
      exact hf.symm ▸ hf },
    { -- in this case, (a ff) = tt, so now we have
      -- the expression (a tt) in our goal
      -- we split it into the cases ff and tt
      cases ht : a tt,
      { -- in this case, we already have the goal, use it
        exact hf },
      { -- in this case, we already have the goal, use it
        exact ht } } },
  { -- in this case, all b is now ff
    -- so let's split what (a tt) is into ff and tt
    -- since we have two (a tt) expressions in our goal
    cases ht : a tt,
    { -- in this case, (a tt) = ff, so now we have
      -- the expression (a ff) in our goal
      -- we split it into the cases ff and tt
      cases hf : a ff,
      { -- in this case, we already have the goal, use it
        exact hf },
      { -- in this case, we already have the goal, use it
         exact ht } },
    { -- this case is where (a tt) = tt,
      -- so we use it directly twice
      exact ht.symm ▸ ht } },
end

最后,使用简单的策略:

example : ∀ a : bool → bool, ∀ b : bool, a (a (a b)) = a b :=
begin
  intros a b,
  -- split reasoning into b as ff or tt
  cases hb : b;
  -- and for all cases, split reasoning of the (a ff) expression
  cases hf : a ff;
  -- and for all cases, split reasoning of the (a tt) expression
  cases ht : a tt,
  -- now deal with all cases
  { exact hf.symm ▸ hf },
  { exact hf.symm ▸ hf },
  { exact hf },
  { exact ht },
  { exact hf.symm ▸ hf },
  { exact ht.symm ▸ ht },
  { exact hf.symm ▸ ht },
  { exact ht.symm ▸ ht },
end

答案 2 :(得分:0)

这是一种作弊解决方案:

import tactic.fin_cases                                                                                                                 
                                                                                                                                        
example : ∀ a : bool → bool, ∀ b : bool, a (a (a b)) = a b :=                                                                           
begin                                                                                                                                   
  intros a b,                                                                                                                           
  fin_cases a; fin_cases b; refl                                                                                                        
end

fin_casesmathlib的一种战术。如果可以找到可计算的a : α,它将对[fintype α]进行案例分析。因此,该解决方案在数学上说:考虑所有情况,并验证每种情况下我们都具有定义上的相等性。