草庐IT

javascript - 如何使用算法 W 键入检查递归定义?

我正在实现AlgorithmW(Hindley-Milnertypesystem)在JavaScript中:实现上述规则的函数是typecheck,它有如下签名:typecheck::(Context,Expr)->Monotype定义如下:functiontypecheck(context,expression){switch(expression.type){case"Var":varname=expression.name;vartype=context[name];returninst(type);case"App":varfun=typecheck(context,expre

如何在COQ中证明不消除类型的COQ时如何在道具上进行匹配

我试图证明,分类列表的尾巴是在COQ中排序的,使用模式匹配而不是策略:RequireImportCoq.Sorting.Sorted.Definitiontail_also_sorted{A:Prop}{R:relationA}{h:A}{t:listA}(H:SortedR(h::t)):SortedRt:=matchHinSorted_(h::t)returnSorted_twith|Sorted_nil_=>Sorted_nilR|Sorted_consrest_sorted_=>rest_sortedend.但是,这失败了:Error:Incorrecteliminationof"H"

COQ中SIG类型元素的平等性

使用SIG类型的省点,例如:InductiveA:Set:=mkA:nat->A.FunctiongetId(a:A):nat:=matchawithmkAn=>nend.Functionfilter(a:A):bool:=if(beq_nat(getIda)0)thentrueelsefalse.Coercionis_true:bool>->Sortclass.DefinitionsubsetA:Set:={a:A|filtera}.我试图证明其投影是注射的:Lemmaprojection_injective:forallt1t2:subsetA,proj1_sigt1=proj1_sigt