- C.MutInd (uri',i',exp_named_subst) as typ ->
- if U.eq uri uri' && i = i' then ([],[],exp_named_subst)
- else raise (TypeCheckerFailure (sprintf
- "Case analysys: analysed term type is %s, but is expected to be (an application of) %s#1/%d{_}"
- (CicPp.ppterm typ) (U.string_of_uri uri) i))
- | C.Appl ((C.MutInd (uri',i',exp_named_subst) as typ):: tl) as typ' ->
- if U.eq uri uri' && i = i' then
- let params,args =
- split tl (List.length tl - k)
- in params,args,exp_named_subst
- else raise (TypeCheckerFailure (sprintf
- "Case analysys: analysed term type is %s, but is expected to be (an application of) %s#1/%d{_}"
- (CicPp.ppterm typ') (U.string_of_uri uri) i))
- | _ ->
- raise (TypeCheckerFailure (sprintf
- "Case analysis: analysed term %s is not an inductive one"
- (CicPp.ppterm term)))
+ C.MutInd (uri',i',exp_named_subst) as typ ->
+ if U.eq uri uri' && i = i' then
+ ([],[],exp_named_subst),ugraph2
+ else
+ raise
+ (TypeCheckerFailure
+ (sprintf
+ ("Case analysys: analysed term type is %s, but is expected to be (an application of) %s#1/%d{_}")
+ (CicPp.ppterm typ) (U.string_of_uri uri) i))
+ | C.Appl
+ ((C.MutInd (uri',i',exp_named_subst) as typ):: tl) as typ' ->
+ if U.eq uri uri' && i = i' then
+ let params,args =
+ split tl (List.length tl - k)
+ in (params,args,exp_named_subst),ugraph2
+ else
+ raise
+ (TypeCheckerFailure
+ (sprintf
+ ("Case analysys: analysed term type is %s, "^
+ "but is expected to be (an application of) "^
+ "%s#1/%d{_}")
+ (CicPp.ppterm typ') (U.string_of_uri uri) i))
+ | _ ->
+ raise
+ (TypeCheckerFailure
+ (sprintf
+ ("Case analysis: "^
+ "analysed term %s is not an inductive one")
+ (CicPp.ppterm term)))
+*)
+ let (b, k) = guess_args context outsort in
+ if not b then (b, k - 1) else (b, k) in
+ let (parameters, arguments, exp_named_subst),ugraph2 =
+ let ty,ugraph2 = type_of_aux ~logger context term ugraph1 in
+ match R.whd ~subst context ty with
+ C.MutInd (uri',i',exp_named_subst) as typ ->
+ if U.eq uri uri' && i = i' then
+ ([],[],exp_named_subst),ugraph2
+ else raise
+ (TypeCheckerFailure
+ (sprintf
+ ("Case analysys: analysed term type is %s, but is expected to be (an application of) %s#1/%d{_}")
+ (CicPp.ppterm typ) (U.string_of_uri uri) i))
+ | C.Appl
+ ((C.MutInd (uri',i',exp_named_subst) as typ):: tl) as typ' ->
+ if U.eq uri uri' && i = i' then
+ let params,args =
+ split tl (List.length tl - k)
+ in (params,args,exp_named_subst),ugraph2
+ else raise
+ (TypeCheckerFailure
+ (sprintf
+ "Case analysys: analysed term type is %s, but is expected to be (an application of) %s#1/%d{_}"
+ (CicPp.ppterm typ') (U.string_of_uri uri) i))
+ | _ ->
+ raise
+ (TypeCheckerFailure
+ (sprintf
+ "Case analysis: analysed term %s is not an inductive one"
+ (CicPp.ppterm term)))