Download benchmarks/Algorithms/longest_increasing_subsequence/rocq/solution_spec.c from PV-SJTU/PV-Bench: direct link, hf CLI and curl.
- Browser
- Download file 962 Bytes
-
https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Algorithms/longest_increasing_subsequence/rocq/solution_spec.c
- Command line
-
hf download hf://datasets/PV-SJTU/PV-Bench/benchmarks/Algorithms/longest_increasing_subsequence/rocq/solution_spec.c
-
curl -L -o solution_spec.c https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Algorithms/longest_increasing_subsequence/rocq/solution_spec.c
962 Bytes
| /*@ Extern Coq | |
| (Forall : {A} -> (A -> Prop) -> list A -> Prop) | |
| (Z::le : Z -> Z -> Prop) | |
| (Z::ge : Z -> Z -> Prop) | |
| (LISLength : list Z -> Z -> Prop) | |
| */ | |
| /*@ Import Coq Require Import PVbench.Algorithms.longest_increasing_subsequence.rocq.spec_lib */ | |
| int lengthOfLIS(int *nums, int numsSize) | |
| /*@ With (l : list Z) | |
| Require | |
| 1 <= numsSize && numsSize <= 100000 && | |
| Zlength(l) == numsSize && | |
| Forall(Z::le(-10000), l) && Forall(Z::ge(10000), l) && | |
| IntArray::full(nums, numsSize, l) | |
| Ensure | |
| LISLength(l, __return) && | |
| IntArray::full(nums, numsSize, l) | |
| */ | |
| { | |
| int dp[100000]; | |
| int ans = 1; | |
| for (int i = 0; i < numsSize; ++i) { | |
| dp[i] = 1; | |
| for (int j = 0; j < i; ++j) { | |
| if (nums[j] < nums[i]) { | |
| int candidate = dp[j] + 1; | |
| if (candidate > dp[i]) { | |
| dp[i] = candidate; | |
| } | |
| } | |
| } | |
| if (dp[i] > ans) { | |
| ans = dp[i]; | |
| } | |
| } | |
| return ans; | |
| } | |