Coq Idris是否支持展开函数定义?

Coq Idris是否支持展开函数定义?,coq,dependent-type,idris,type-theory,Coq,Dependent Type,Idris,Type Theory,对于依赖类型,可以为排序列表定义归纳类型,例如: data IsSorted : {a: Type} -> (ltRel: (a -> a -> Type)) -> List a -> Type where IsSortedZero : IsSorted {a=a} ltRel Nil IsSortedOne : (x: a) -> IsSorted ltRel [x] IsSortedMany : (x: a) -> (y: a) ->

对于依赖类型,可以为排序列表定义归纳类型,例如:

data IsSorted : {a: Type} -> (ltRel: (a -> a -> Type)) -> List a -> Type where
  IsSortedZero : IsSorted {a=a} ltRel Nil
  IsSortedOne : (x: a) -> IsSorted ltRel [x]
  IsSortedMany : (x: a) -> (y: a) -> .IsSorted rel (y::ys) -> .(rel x y) -> IsSorted rel (x::y::ys)
然后,这可以用于对排序列表进行推理

在Coq中,我们还可以编写一个函数
Fixpoint is_sorted:{a:Type}(l:List a):bool
,然后利用类似
is_sorted someList=true
的类型,通过
展开
is_sorted
的定义来证明事情。后一种方法在Idris中是可行的,还是只支持前一种方法


此外,根据我自己的理解:后一种情况是“反思证明”的例子吗?是否存在后一种方法比前一种方法更可取的情况?

我认为以下部分满足了您的要求(我要补充一点,我没有使用Coq的经验):

重要的细节是,如果函数定义是一组简单的方程,那么在需要时,统一会神奇地用方程的一侧替换另一侧。(我使用了一个效率较低的非短路版本的逻辑“and”操作符,因为标准的“&&”或“if/then/else”操作符引入了懒惰的复杂性。)

理想情况下,应该有一些简单的方法来展开定义,其中包括基于“with”的模式匹配,但我不知道如何实现这一点,例如:

is_sorted : {a: Type} -> (ltRel: a -> a -> Bool) -> List a -> Bool
is_sorted ltRel [] = True
is_sorted ltRel (x :: []) = True
is_sorted ltRel (x :: y :: xs) with (ltRel x y)
  | True = is_sorted ltRel (y :: xs)
  | False = False

is_sorted_true_elim : {x : a} -> is_sorted ltRel (x :: y :: xs) = True -> (ltRel x y = True, 
                                                                           is_sorted ltRel (y :: xs) = True)
is_sorted_true_elim {x} {y} {xs} {ltRel} is_sorted_x_y_xs with (ltRel x y) proof x_lt_y_value
  | True = ?hole
  | False = ?hole2
可能重复的
is_sorted : {a: Type} -> (ltRel: a -> a -> Bool) -> List a -> Bool
is_sorted ltRel [] = True
is_sorted ltRel (x :: []) = True
is_sorted ltRel (x :: y :: xs) with (ltRel x y)
  | True = is_sorted ltRel (y :: xs)
  | False = False

is_sorted_true_elim : {x : a} -> is_sorted ltRel (x :: y :: xs) = True -> (ltRel x y = True, 
                                                                           is_sorted ltRel (y :: xs) = True)
is_sorted_true_elim {x} {y} {xs} {ltRel} is_sorted_x_y_xs with (ltRel x y) proof x_lt_y_value
  | True = ?hole
  | False = ?hole2