name | set-fold |
version | 1.7 |
description | A fold operation on finite sets |
author | Joe Hurd <joe@gilith.com> |
license | MIT |
show | Data.Bool Set |
⊦ ∀f b.
(∀x y s. ¬(x = y) ⇒ f x (f y s) = f y (f x s)) ⇒
fold f ∅ b = b ∧
∀x s.
finite s ⇒
fold f (insert x s) b =
if x ∈ s then fold f s b else f x (fold f s b)
⊦ ∀f b.
(∀x y s. ¬(x = y) ⇒ f x (f y s) = f y (f x s)) ⇒
fold f ∅ b = b ∧
∀x s.
finite s ⇒
fold f s b =
if x ∈ s then f x (fold f (delete s x) b) else fold f (delete s x) b
⊦ ∀s f g b.
finite s ∧ (∀x. x ∈ s ⇒ f x = g x) ∧
(∀x y s. ¬(x = y) ⇒ f x (f y s) = f y (f x s)) ∧
(∀x y s. ¬(x = y) ⇒ g x (g y s) = g y (g x s)) ⇒
fold f s b = fold g s b
⊦ T
⊦ finite ∅
⊦ F ⇔ ∀p. p
⊦ ∀x. ¬(x ∈ ∅)
⊦ ∀t. t ∨ ¬t
⊦ (~) = λp. p ⇒ F
⊦ (∃) = λP. P ((select) P)
⊦ ∀t. (∀x. t) ⇔ t
⊦ ∀t. (∃x. t) ⇔ t
⊦ ∀t. (λx. t x) = t
⊦ (∀) = λp. p = λx. T
⊦ ∀x. x = x ⇔ T
⊦ ∀n. ¬(Number.Natural.suc n = 0)
⊦ (⇒) = λp q. p ∧ q ⇔ p
⊦ ∀t. (t ⇔ T) ∨ (t ⇔ F)
⊦ ∀p x. p x ⇒ p ((select) p)
⊦ (¬T ⇔ F) ∧ (¬F ⇔ T)
⊦ ∀x y. x = y ⇒ y = x
⊦ ∀t1 t2. t1 ∨ t2 ⇔ t2 ∨ t1
⊦ ∀s x. finite s ⇒ finite (delete s x)
⊦ ∀s x. finite (delete s x) ⇔ finite s
⊦ ∀s x. finite (insert x s) ⇔ finite s
⊦ (∧) = λp q. (λf. f p q) = λf. f T T
⊦ (∃) = λP. ∀q. (∀x. P x ⇒ q) ⇒ q
⊦ ∀x s. x ∈ s ⇔ insert x s = s
⊦ ∀m n. Number.Natural.suc m = Number.Natural.suc n ⇔ m = n
⊦ ∀x s. delete s x = s ⇔ ¬(x ∈ s)
⊦ (∨) = λp q. ∀r. (p ⇒ r) ⇒ (q ⇒ r) ⇒ r
⊦ ∀x s. x ∈ s ⇒ insert x (delete s x) = s
⊦ ∀x s. delete (insert x s) x = s ⇔ ¬(x ∈ s)
⊦ ∀P Q. (∀x. P ⇒ Q x) ⇔ P ⇒ ∀x. Q x
⊦ ∀P Q. (∃x. P x) ⇒ Q ⇔ ∀x. P x ⇒ Q
⊦ ∀x y s. delete (delete s x) y = delete (delete s y) x
⊦ ∀p q r. p ∧ q ⇒ r ⇔ p ⇒ q ⇒ r
⊦ ∀s t. s = t ⇔ ∀x. x ∈ s ⇔ x ∈ t
⊦ ∀t1 t2. (if T then t1 else t2) = t1 ∧ (if F then t1 else t2) = t2
⊦ ∀P. P 0 ∧ (∀n. P n ⇒ P (Number.Natural.suc n)) ⇒ ∀n. P n
⊦ (∀t. ¬¬t ⇔ t) ∧ (¬T ⇔ F) ∧ (¬F ⇔ T)
⊦ ∀x y s. x ∈ insert y s ⇔ x = y ∨ x ∈ s
⊦ ∀s x y. x ∈ delete s y ⇔ x ∈ s ∧ ¬(x = y)
⊦ ∀e f. ∃fn. fn 0 = e ∧ ∀n. fn (Number.Natural.suc n) = f (fn n) n
⊦ ∀P c x y. P (if c then x else y) ⇔ (c ⇒ P x) ∧ (¬c ⇒ P y)
⊦ ∀t1 t2. (¬(t1 ∧ t2) ⇔ ¬t1 ∨ ¬t2) ∧ (¬(t1 ∨ t2) ⇔ ¬t1 ∧ ¬t2)
⊦ ∀t. ((T ⇔ t) ⇔ t) ∧ ((t ⇔ T) ⇔ t) ∧ ((F ⇔ t) ⇔ ¬t) ∧ ((t ⇔ F) ⇔ ¬t)
⊦ ∀P.
P ∅ ∧ (∀x s. P s ∧ ¬(x ∈ s) ∧ finite s ⇒ P (insert x s)) ⇒
∀s. finite s ⇒ P s
⊦ ∀t. (T ∧ t ⇔ t) ∧ (t ∧ T ⇔ t) ∧ (F ∧ t ⇔ F) ∧ (t ∧ F ⇔ F) ∧ (t ∧ t ⇔ t)
⊦ ∀t. (T ∨ t ⇔ T) ∧ (t ∨ T ⇔ T) ∧ (F ∨ t ⇔ t) ∧ (t ∨ F ⇔ t) ∧ (t ∨ t ⇔ t)
⊦ ∀t. (T ⇒ t ⇔ t) ∧ (t ⇒ T ⇔ T) ∧ (F ⇒ t ⇔ T) ∧ (t ⇒ t ⇔ T) ∧ (t ⇒ F ⇔ ¬t)