如何证明这两种类型的等价性-算法和算法''?

时间:2020-10-18 15:08:35

标签: coq

我在这里做错了什么(我没有足够的经验来完成证明,还是之前有一些错误)?我无法完全证明这两种类型之间的等效性。任何帮助表示赞赏。

这是我为证明log_2(n!)进行排序所必需的一部分(特定于n = 8)。 var data = [{ values: [], labels: ['Bank Accounts', 'Savings Accounts', 'Cash-on-Hand'], type: 'pie' }]; var layout = { height: 400, width: 500 }; function testPER() { var netSalaryPER = Number($("input#netSalary").val()) / Number($("input#totalIncomeValue").val()) * 100; var bonusSalaryPER = Number($("input#bonusSalary").val()) / Number($("input#totalIncomeValue").val()) * 100; var gigSalaryPER = Number($("input#gigSalary").val()) / Number($("input#totalIncomeValue").val()) * 100; data[0].values[0] = netSalaryPER; data[0].values[1] = bonusSalaryPER data[0].values[2] = gigSalaryPER /* TESTING PURPOSES $("input#netSalaryPER").val(netSalaryPER); */ Plotly.newPlot('incomePieChart', data, layout); } 类型对应于决策树。

algorithm''

1 个答案:

答案 0 :(得分:3)

您的陈述似乎是错误的。这是一个反例。

Definition mya1 : algorithm' 2 := 
  conditional' (GT x0 x1)
     ((assign (num x0) (num x2)) :: (assign (num x1) (num x3)) :: nil)
     ((assign (num x0) (num x4)) :: (assign (num x1) (num x5)) :: nil)
   (conditional' (GT x2 x3)
     ((assign (num x2) (num x6)) :: (assign (num x3) (num x7)) :: nil)
     ((assign (num x0) (num x4)) :: (assign (num x1) (num x5)) :: nil)
     leaf' leaf')
   (conditional' (GT x3 x0)
     ((assign (num x2) (num x7)) :: (assign (num x3) (num x6)) :: nil)
     ((assign (num x0) (num x4)) :: (assign (num x1) (num x5)) :: nil)
     leaf' leaf').

Definition myi x := 
         if variable_eq_dec x (num x0) then 3 else 
         if variable_eq_dec x (num x1) then 4 else 
         if variable_eq_dec x (num x2) then 6 else
         if variable_eq_dec x (num x3) then 5 else 
         if variable_eq_dec x (num x4) then 7 else 
         if variable_eq_dec x (num x5) then 8 else 
         if variable_eq_dec x (num x6) then 9 else 
         0.

以下命令返回6

 Compute run_algorithm' mya1 myi (num x2).

以下内容返回0

 Compute run_algorithm'' (algorithm'_to_algorithm'' mya1) myi (num x2).

我通过尝试对a进行归纳证明来找到反例。这是我的脚本。

Theorem algorithm'_algorithm''_equiv n (a: algorithm' n):
  forall (i: instantation) (x: variable), 
 run_algorithm' a i x  = run_algorithm'' (algorithm'_to_algorithm'' a) i x.
Proof.
induction a.
  easy.
simpl.
intros i x.
destruct c.
destruct (Compare_dec.gt_dec (i (num more)) (i (num less))) as [cmp1 | cmp2].
  rewrite IHa1.

这将我引向一个与append_assigmentsrun_assignment_list有关的目标,我以这种方式陈述了这一观点。

Lemma algorithm''_list n (a : algorithm'' n) (l: list assignment) i x :
  run_algorithm'' a (run_assignment_list l i) x =
  run_algorithm'' (append_assignments a l) i x.

在做这个证明的过程中,通过对a的归纳,我可以看到在平等的两个方面之间存在执行不匹配的情况。对其进行进一步分析得出了反例。