forked from coq/coq
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…in funind is a well-typed relation Reviewed-by: SkySkimmer Ack-by: ppedrot Co-authored-by: SkySkimmer <[email protected]>
- Loading branch information
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
...og/02-specification-language/19775-master+fix12417-check-typing-wf-relation.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- **Fixed:** | ||
Anomaly in :cmd:`Function` when a well-founded relation had not the expected type | ||
(`#19775 <https://github.com/coq/coq/pull/19775>`_, | ||
fixes `#12417 <https://github.com/coq/coq/issues/12417>`_, | ||
by Hugo Herbelin). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Declare ML Module "rocq-runtime.plugins.funind". | ||
|
||
Inductive tm := | ||
| E: nat -> tm | ||
| L: list tm -> tm. | ||
|
||
Definition T := list tm. | ||
|
||
Fixpoint max_list (p: nat) (l: list nat) : nat := | ||
match l with | ||
| nil => p | ||
| cons n l' => max_list (Init.Nat.max n p) l' | ||
end. | ||
|
||
Fixpoint map {A B} (f : A -> B) (l : list A) : list B := | ||
match l with | ||
| nil => nil | ||
| cons x l => cons (f x) (map f l) | ||
end. | ||
|
||
Fixpoint depth (t: tm) : nat := | ||
match t with | ||
| E _ => 0 | ||
| L l => 1 + max_list 0 (map depth l) | ||
end. | ||
|
||
Fixpoint sum_depth (l: T) : nat := | ||
match l with | ||
| nil => 0 | ||
| cons n l' => (depth n) + sum_depth l' | ||
end. | ||
|
||
Fail Function sum_total (l: T) {wf sum_depth l} : nat := | ||
match l with | ||
| nil => 0 | ||
| cons t l' => | ||
(match t with | ||
| E n => n | ||
| L li => sum_total li | ||
end) + sum_total l' | ||
end. |