Section BOOLEAN_ALGEBRA. (* Reference: << Constructive Completeness Proofs and Delimited Control >> written by "Danko Ilik" *)
Context {B : Type} {BA : isBA B}.
#[local] Notation andB := (@andB B BA).
Definition andsB : list B -> B :=
fold_right andB trueB.
Context {SETOID : isSetoid B}.
Definition leB (lhs : B) (rhs : B) : Prop :=
andB lhs rhs == lhs.
Context {BOOLEAN_ALGEBRA_LAWS : BooleanAlgebraLaws BA}.
#[global]
Instance leB_PreOrder
: PreOrder leB.
#[global]
Instance leB_PartialOrder
: PartialOrder eqProp leB.
#[global]
Instance BA_isProset : isProset B :=
{ leProp lhs rhs := andB lhs rhs == lhs
; Proset_isSetoid := SETOID
; leProp_PreOrder := leB_PreOrder
; leProp_PartialOrder := leB_PartialOrder
}.
#[global]
Instance andB_compathWith_leProp
: isMonotonic2 andB.
#[local] Hint Resolve andsB_le_In : core.
Variant isFilter (F : ensemble B) : Prop :=
| isFilter_if
(CLOSED_andsB : forall xs, L.is_finsubset_of xs F -> andsB xs \in F)
(CLOSED_UPWARD : forall x, x \in F -> forall x', x =< x' -> x' \in F)
: isFilter F.
#[global]
Add Parametric Morphism
: isFilter with signature (eqProp ==> iff)
as isFilter_eqProp_iff.
Definition inconsistent X : Prop :=
exists botB, botB \in X /\ botB == falseB.
#[global]
Add Parametric Morphism :
inconsistent with signature (eqProp ==> iff)
as inconsistent_compatWith_eqProp.
Definition isProperFilter F : Prop :=
⟪ IS_FILTER : isFilter F ⟫ /\ ⟪ CONSISTENT : ~ inconsistent F ⟫.

Lemma isProperFilter_compatWith_eqProp F F'
(F_isProperFilter : isProperFilter F)
(F_eq_F' : F == F')
: isProperFilter F'.