File size: 593 Bytes
bff4ec7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Require Import Coq.ZArith.ZArith.
Require Import Coq.Lists.List.
From AUXLib Require Import ListLib.
From MaxMinLib Require Import MaxMin Interface.

Import ListNotations.
Local Open Scope Z_scope.
Local Open Scope list_scope.

Definition MaxSubarraySumPrefix (l : list Z) (i ans : Z) : Prop :=
  max_value_of_subset Z.le
    (fun p : Z * Z =>
       let '(lo, hi) := p in
       0 <= lo /\ lo < hi /\ hi <= i)
    (fun p : Z * Z =>
       let '(lo, hi) := p in
       sum (sublist lo hi l))
    ans.

Require Import Coq.micromega.Lia.
Require Import SetsClass.SetsClass.
Import SetsNotation.