CADiZ

Reference manual / Extended toolkit / section bagkit


section bagkit parents toolkit

Bags

Name

bag -- Bags
count, \bcount -- Multiplicity
\otimes -- Bag scaling

Definition

generic (bag _)

bag X == X \pfun \nat1

count [X] == \lambda B: bag X @ (\lambda x: X @ 0) \oplus B

function 50 leftassoc (_ \bcount _)

_ \bcount _ [X] == \lambda B: bag X; x: X @ count B x

function 40 leftassoc (_ \otimes _)

_ \otimes _ [X] == \lambda n: \nat; B: bag X @ (\lambda x: X @ n * (B \bcount x)) \nrres { 0 }

function (\lbag ,, \rbag)

\lbag ,, \rbag [X] == \lambda x: seq X @ items x

Description

Laws

scaleOldDef ==

[ X ] \vdash? \forall n: \nat; B: bag X; x: X @ (n \otimes B) \bcount x = n * (B \bcount x)

L202 ==

[X] \vdash? \forall n: \nat; B: bag X @ n \otimes \lbag\rbag = 0 \otimes B = \lbag\rbag

L203 ==

[X] \vdash? \forall B: bag X @ 1 \otimes B = B

L204 ==

[X] \vdash? \forall m, n: \nat; B: bag X @ (n * m) \otimes B = n \otimes (m \otimes B)

Name

\inbag -- Bag membership
\subbageq -- Sub-bag relation

Definition

relation (_ \inbag _)

_ \inbag _ [X] == { x: X; B: bag X | x \in dom B }

relation (_ \subbageq _)

_ \subbageq _ [X] == { B, C: bag X | \forall x: X @ B \bcount x \leq C \bcount x }

Description

Laws

L207 ==

[X] \vdash? \forall x: X; B: bag X @ x \inbag B \iff B \bcount x > 0

L208 ==

[X] \vdash? \forall B, C: bag X | B \subbageq C @ dom B \subseteq dom C

L209 ==

[X] \vdash? \forall B: bag X @ \lbag\rbag \subbageq B

L210 ==

[X] \vdash? \forall B: bag X @ B \subbageq B

L211 ==

[X] \vdash? \forall B, C: bag X | B \subbageq C \land C \subbageq B @ B = C

L212 ==

[X] \vdash? \forall B, C, D: bag X | B \subbageq C \land C \subbageq D @ B \subbageq D

Name

\uplus -- Bag sum
\uminus -- Bag difference

Definition

function 30 leftassoc (_ \uplus _)

_ \uplus _ [X] == \lambda B, C: bag X @ (\lambda x: X @ B \bcount x + C \bcount x) \nrres { 0 }

function 30 leftassoc (_ \uminus _)

_ \uminus _ [X] == \lambda B, C: bag X @ (\lambda x: X @ max { B \bcount x - C \bcount x,0 }) \nrres { 0 }

Description

Laws

L213 ==

[X] \vdash? \forall s, t: seq X @ items (s \cat t) = items s \uplus items t

L214 ==

[X] \vdash? \forall B, C: bag X @ dom (B \uplus C) = dom B \cup dom C

L215 ==

[X] \vdash? \forall B: bag X @ \lbag\rbag \uplus B = B \uplus \lbag\rbag = B

L216 ==

[X] \vdash? \forall B, C: bag X @ B \uplus C = C \uplus B

L217 ==

[X] \vdash? \forall B, C, D: bag X @ (B \uplus C) \uplus D = B \uplus (C \uplus D)

L218 ==

[X] \vdash? \forall B: bag X @ B \uminus \lbag\rbag = B

L219 ==

[X] \vdash? \forall B: bag X @ \lbag\rbag \uminus B = \lbag\rbag

L220 ==

[X] \vdash? \forall B, C: bag X @ (B \uplus C) \uminus C =B

L221 ==

[X] \vdash? \forall m, n: \nat; B: bag X @ (n+m) \otimes B = n \otimes B \uplus m \otimes B

L222 ==

[X] \vdash? \forall m, n: \nat; B: bag X | n \geq m @ (n - m) \otimes B = n \otimes B \uminus m \otimes B

L223 ==

[X] \vdash? \forall n: \nat; B, C: bag X @ n \otimes (B \uplus C) = n \otimes B \uplus n \otimes C

L224 ==

[X] \vdash? \forall n: \nat; B, C: bag X @ n \otimes (B \uminus C) = n \otimes B \uminus n \otimes C

IT 5-Jan-2002