Make 'MonotonicPredicate' into another typeclass
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
parent
7571cb7451
commit
2f91ca113e
|
@ -93,9 +93,8 @@ Both P Q = (λ { s (t₁ , t₂) → (P s t₁ × Q s t₂) })
|
|||
-- states'. We call such predicates monotonic as well, since they respect the
|
||||
-- ordering relation.
|
||||
|
||||
MonotonicPredicate : ∀ {T : S → Set s} {{ _ : Relaxable T }} →
|
||||
DependentPredicate T → Set s
|
||||
MonotonicPredicate {T} {{r}} P = ∀ (s₁ s₂ : S) (t₁ : T s₁) (s₁≼s₂ : s₁ ≼ s₂) →
|
||||
record MonotonicPredicate {T : S → Set s} {{ r : Relaxable T }} (P : DependentPredicate T) : Set s where
|
||||
field relaxPredicate : ∀ (s₁ s₂ : S) (t₁ : T s₁) (s₁≼s₂ : s₁ ≼ s₂) →
|
||||
P s₁ t₁ → P s₂ (Relaxable.relax r s₁≼s₂ t₁)
|
||||
|
||||
-- A MonotonicState "monad" m has a certain property if its ouputs satisfy that
|
||||
|
@ -106,11 +105,12 @@ always P m = ∀ s₁ → let (s₂ , t , _) = m s₁ in P s₂ t
|
|||
|
||||
⟨⊗⟩-reason : ∀ {T₁ T₂ : S → Set s} {{ _ : Relaxable T₁ }}
|
||||
{P : DependentPredicate T₁} {Q : DependentPredicate T₂}
|
||||
{P-Mono : MonotonicPredicate P}
|
||||
{{P-Mono : MonotonicPredicate P}}
|
||||
{m₁ : MonotonicState T₁} {m₂ : MonotonicState T₂} →
|
||||
always P m₁ → always Q m₂ → always (Both P Q) (m₁ ⟨⊗⟩ m₂)
|
||||
⟨⊗⟩-reason {P-Mono = P-Mono} {m₁ = m₁} {m₂ = m₂} aP aQ s
|
||||
⟨⊗⟩-reason {{P-Mono = P-Mono}} {m₁ = m₁} {m₂ = m₂} aP aQ s
|
||||
with p ← aP s
|
||||
with (s' , (t₁ , s≼s')) ← m₁ s
|
||||
with q ← aQ s'
|
||||
with (s'' , (t₂ , s'≼s'')) ← m₂ s' = (P-Mono _ _ _ s'≼s'' p , q)
|
||||
with (s'' , (t₂ , s'≼s'')) ← m₂ s' =
|
||||
(MonotonicPredicate.relaxPredicate P-Mono _ _ _ s'≼s'' p , q)
|
||||
|
|
Loading…
Reference in New Issue
Block a user