• 검색 결과가 없습니다.

ƒ Syntax of Datalog Rules

N/A
N/A
Protected

Academic year: 2022

Share "ƒ Syntax of Datalog Rules"

Copied!
39
0
0

로드 중.... (전체 텍스트 보기)

전체 글

(1)

Advanced DB

CHAPTER 5

DATALOG

(2)

Datalog

ƒ Basic Structure

ƒ Syntax of Datalog Rules

ƒ Semantics of Nonrecursive Datalog

ƒ Safety

ƒ Relational Operations in Datalog

ƒ Recursion in Datalog

ƒ The Power of Recursion

ƒ A More Theoretic View

(3)

Basic Structure

ƒ Prolog-like logic-based language based on first-order logic

ƒ A D t log progr m

ƒ A Datalog program

à consists of a set of rules that define views.

ƒ Example:p

à define a view relation v1 containing account numbers and balances for accounts at the Perryridge branch with a balance of over $700.

v1(A B ) :account(APerryridge” B ) B > 700 v1(A, B ) : account(A, Perryridge , B ), B > 700.

à Retrieve the balance of account number “A-217” in the view relation v1.

? v1(A-217”, B).

à To find account number and balance of all accounts in v1 that have a balance greater than 80.

? v1(A, B), B > 800.

(4)

Examples

v1(A, B ) :account(A,Perryridge”, B ), B > 700

ƒ Each rule defines a set of tuples that a view relation must contain

Ab l i d

ƒ Above rule is read as

for all A, B

if (A “P id ” B ) d B 700

if (A, “Perryridge”, B )∈account and B > 700 then (A, B )∈v1

ƒ The set of tuples in a view relation

ƒ The set of tuples in a view relation

à is then defined as the union of all the sets of tuples defined by the rules for the view relation.

interest_rate(A, 5) :– account(A, N, B), B < 10000 interest_rate(A, 6) :– account(A, N, B), B >= 10000

(5)

Negation in Datalog

ƒ Define a view relation c that

i h f ll h h d i

à contains the names of all customers who have a deposit à but no loan at the bank:

c(N) :– depositor(N, A), not is borrower(N).

c(N) : depositor(N, A), not is_borrower(N).

is_borrower (N) :– borrower(N, L).

ƒ NOTE:

à The following definition results in a different meaning.

c(N) :– depositor(N, A), not borrower(N, L).

à Namely, there is some loan L for which N is not a borrower

à To prevent such confusion we require all variables in negated predicate to à To prevent such confusion, we require all variables in negated predicate to

also be present in non-negated predicates

(6)

Formal Syntax and Semantics of Datalog

ƒ Steps in defining the syntax and semantics (meaning) of Datalog programs

programs

1. We define the syntax of predicates, and then the syntax of rules 2. We define the semantics of individual rules

2. We define the semantics of individual rules

3. We define the semantics of non-recursive programs, based on a layering of rules

4. We define what rules are safe, because it is possible to write rules that can generate an infinite number of tuples in the view relation.

5. It is possible to write recursive programs whose meaning is unclear. We 5. It is possible to write recursive programs whose meaning is unclear. We

define what recursive programs are acceptable, and define their meaning.

(7)

Syntax of Datalog Rules

ƒ A positive literal has the form p(t

1

, t

2

..., t

n

)

i h f l i i h ib

à p is the name of a relation with n attributes

à each ti is a term (i.e., either a constant or variable)

ƒ A negative literal has the form not p(t t t )

ƒ A negative literal has the form not p(t

1

, t

2

..., t

n

)

ƒ i.e., a literal is an atom or a negated atom

ƒ C i ti t t d iti di t

ƒ Comparison operations are treated as positive predicates

à E.g. X >Y is treated as a predicate >(X,Y )

à “>” is conceptually an (infinite) relation that contains all pairs of values> is conceptually an (infinite) relation that contains all pairs of values such that the first value is greater than the second value

ƒ Arithmetic operations are also treated as predicates

à E.g. A = B + C is treated as +(B, C, A),

where the relation “+” contains all triples such that the third value is the m f th fir t t

sum of the first two

(8)

Syntax of Datalog Rules (Cont.)

ƒ Rules

b il f li l d h h f

à are built out of literals and have the form:

p(t

1

, t

2

, ..., t

n

) :– L

1

, L

2

, ..., L

m

.

head body

à each Lii is a literal

à head: the literal p(t1, t2, ..., tn ) à body: the rest of the literals

ƒ A fact

à is a rule with an empty body, written in the form: p(v1, v2, ..., vn).

à indicates that tuple (v1, v2, ..., vn ) is in relation p à A base relation is actually a set of facts

(9)

Examples

ƒ

Example 1:

parent(X Y) : father(X Y) parent(X, Y) :- father(X, Y) parent(X, Y) :- mother(X, Y)

sibling(X, Y) :- parent(X, Z), parent(Y, Z), X<>Y sibling(X, Y) : parent(X, Z), parent(Y, Z), X Y

ƒ

Example 2: p

v1(A, B ) :account(A,Perryridge”, B ), B > 700

c(N) :– depositor(N, A), not is_borrower(N).

i b (N) b (N L)

is_borrower (N) :– borrower(N, L).

interest(A, I) :– perryridge_account(A, B),

interest_rate(A, R), I = B*R/100. ( )

perryridge_account(A, B) :– account (A, “Perryridge”, B).

interest_rate(A, 5) :– account (N, A, B), B<10000.

interest rate(A, 6) :– account (N, A, B), B>=10000. n e e _ e( , 6) n (N, , ), 0000.

(10)

Semantics of a Rule

ƒ Ground instantiation (or simply instantiation) of a rule

l i h i bl i h l b

à replacing each variable in the rule by some constant

à E.g., an instantiation of v1(A,B) :– account (A,“Perryridge”, B ), B>700.

v1 (A-217”, 750) :–account(“A-217”, “Perryridge”, 750), 750>700.

ƒ For an instantiation R’ (of rule R)

The body of rule is satisfied in a set of facts (database instance) I if

1 F h p iti lit l ( ) i th b d f RI t i th

1. For each positive literal qi (vi,1, ..., vi,ni) in the body of R , I contains the fact qi(vi,1, ..., vi,ni ).

2. For each negative literal not qjj j,(vj,1, ..., vj,njj, j) in the body of R, I does not contain the fact qj (vj,1, ..., vj,nj).

(11)

Semantics of a Rule (cont.)

ƒ Set of facts that can be inferred from a given set of facts I using r le R ( ie definition)

rule R (view definition)

infer(R, I) = { p(t1, ..., tn) | there is a ground instantiation Rof R where p(tp( 11, ..., t, , nn) is the head of R), and ,

the body of Ris satisfied in I }

ƒ Example

R1: interest_rate(A, 5) :– account(A, N, B), B<10000 infer(R1, I) = { interest_rate(a, 5) | a is a constant and

∃ constants n, b such that,

<a, n, b>∈account and b<10000 in I }

(12)

Semantics of a Rule (cont.)

ƒ Given a set of rules ℜ = {R1, ..., Rn},

i f (ℜ I) = i f (R I) ∪ ∪ i f (R I ) infer(ℜ, I) = infer (R1, I) ∪ ... ∪ infer (Rn, I )

ƒ ExampleExample

R1: interest_rate(A, 5) :– account(A, N, B), B<10000 R2: interest_rate(A, 6) :– account(A, N, B), B >=10000

{

infer(ℜ, l) = { interest_rate(a, 5) | a is a constant and

∃ constants n, b such that

<a n b>∈account and b<10000 in I }

<a, n, b>∈account and b<10000 in I }

{ interest_rate(a, 6) | a is a constant and

∃ constants n, b such that

<a, n, b>∈account and b>=10000 in I }

(13)

Layering of Rules

ƒ Define the interest on each account in Perryridge

interest(A, I) :– perryridge_account(A, B),

interest_rate(A, R), I = B*R/100.

id (A B) (A “P id ” B)

perryridge_account(A, B) :– account (A, “Perryridge”, B).

interest_rate(A, 5) :– account (N, A, B), B<10000.

interest rate(A, 6) :– account (N A B) B>=10000 interest_rate(A, 6) : account (N, A, B), B> 10000.

ƒ Layering of the view relations

interest

perryridge_account Interest rate

account Interest_rate

(14)

Layering Rules (cont.)

ƒ A relation is a layer 1

if ll l i d i h b di f l d fi i i d i h

à if all relations used in the bodies of rules defining it are stored in the database.

ƒ A relation is a layer 2 A relation is a layer 2

à if all relations used in the bodies of rules defining it are either stored in the database, or are in layer 1.

ƒ A relation p is in layer i + 1 if

à it is not in layers 1, 2, ..., i

à all relations used in the bodies of rules defining a p are either stored in the database, or are in layers 1, 2, ..., i

(15)

Semantics of a Program

ƒ Let the layers in a given program be 1, 2, ..., n. Let ℜ

i

denote the set of all r les defining ie relations in la er i

set of all rules defining view relations in layer i.

ƒ Define I

0

= set of facts stored in the database.

R i l d fi I I i f (ℜ I )

ƒ Recursively define I

i+1

= I

i

∪ infer (ℜ

i+1

, I

i

)

ƒ The set of facts in the view relations defined by the program

( l ll d th ti f th ) i i b th t f

(also called the semantics of the program) is given by the set of facts I

n

corresponding to the highest layer n.

Note: Can instead define semantics using view expansion like in relational algebra, but above definition is better for handling

relational algebra, but above definition is better for handling

extensions such as recursion.

(16)

Examples

interest(A, lR) :– perryridge_account(A, B), interest rate(A R) lR = B*R/100

parent(X, Y) :- father(X, Y)

(X Y) h (X Y)

interest_rate(A,R), lR B R/100.

perryridge_account(A,B) :–

account (A, “Perryridge”, B).

parent(X, Y) :- mother(X, Y)

sibling(X, Y) :- parent(X, Z), parent(Y, Z), X<>Y

interest_rate(A,5) :–

account (N, A, B), B<10000.

i (A 6)

father(X, Y) :- emp(X, _, _, Y) mother(X, Y) :- emp(X, _, Y, _) interest_rate(A,6) :–

account (N, A, B), B>=10000.

I0: set of facts defined in the database;

I0: set of facts defined in the database;

account

I1 : I0 ∪ set of facts inferred for

emp

I1 : I0 ∪ set of facts inferred for father and mother

I1 : I0 ∪ set of facts inferred for interest_rate and perryridge_account I2 : I1 ∪ set of facts inferred for

interest

I2 : I1 ∪ set of facts inferred for parent I : I ∪ set of facts inferred for sibling

(17)

Safety

ƒ It is possible to write rules that generate an infinite number of ans ers

answers.

gt(X, Y) :– X >Y

not_in_loan (B, L) :– not loan(B, L)( ) ( ) loves(X, Y) :- lover(X)

ƒ To avoid this, Datalog rules must be safe

ƒ A rule is safe if all its variables are limited.

à Any variable that appears as an argument in a non-negated DB (view or base) predicate of the body is limited.

à Any variable equated to a constant is limited (X=a).

à Any variable equated to a limited variable is limited à Any variable equated to a limited variable is limited.

‚ This condition can be weakened in special cases based on the semantics of arithmetic predicates, for example to permit the rule

p (A ) : q (B) A = B + 1 p (A ) :- q (B), A = B + 1

(18)

Relational Operations in Datalog

ƒ Select: query(A, N, B) :– account(A, N, B ), B>10000

ƒ Project: query(A) :– account(A, N, B ).

ƒ Cartesian product:

query(X

1

, ..., X

n

, Y

1

, ..., Y

m

) :– r

1

(X

1

, ..., X

n

), r

2

(Y

1

, ..., Y

m

).

ƒ Union: query(X

1

, ..., X

n

) :–r

1

(X

1

, ..., X

n

).

query(X

1

, ..., X

n

) :–r

2

(X

1

, ..., X

n

).

ƒ Set difference:

query( X

1

, ..., X

n

) :–r

1

(X

1

, ..., X

n

), not r

2

(X

1

, ..., X

n

).

ƒ Rename: new_name(X _ (

11

, ..., X , ,

nn

) :– r(X ) (

11

, ..., X , ,

nn

). )

ƒ Join? Intersection?

(19)

Recursion in Datalog

manager (X, Y) /* X’s direct manager is Y */

ƒ Each manager may have direct employees, as well as indirect l

employees

ƒ We wish to find all (direct and indirect) employees of manager

‘ J Jones . ’

empl_jones(X ) :- manager (X, Jones’).

pl j (X ) (X Y ) pl j (Y )

empl_jones(X ) :- manager (X, Y ), empl_jones (Y ).

(20)

Semantics of Recursion in Datalog

ƒ Assumption (for now): program contains no negative literals

ƒ The view relations of a recursive program ℜ are defined to contain exactly the set of facts I computed as follows

d D l Fi i

procedure Datalog-Fixpoint

I = set of facts in the database repeat

Old_I= I

I= I ∪ infer(, I ) until I = Old I

until I Old_I

ƒ At the end of the procedure, infer(, I) ⊆ I

à Infer(f ( , ), I ) = I if we consider the database to be a set of facts that are part p of the program

ƒ I is called a fixed point (fixpoint) of the program.

(21)

Example of Datalog-FixPoint Iteration

(22)

Example: a more general definition of empl

ƒ empl (X, Y ): X is directly or indirectly managed by Y empl (X, Y ) :– manager (X, Y ).

empl (X, Y ) :– manager (X, Z ), empl (Z, Y )

Fi d h di d i di l f J

ƒ Find the direct and indirect employees of Jones.

? empl (X, “Jones”).

ƒ Another way to define view empl empl (X, Y ) :– manager (X, Y ).

empl (X, Y ) :– empl (X, Z ), manager (Z, Y ).

(23)

The Power of Recursion

ƒ Recursive views make it possible to write queries, such as transiti e clos re q eries

transitive closure queries

à cannot be written without recursion or iteration.

ƒ Intuition:

ƒ Intuition:

à Without recursion, a non-recursive non-iterative program can perform only a fixed number of joins of manager with itself

à This can give only a fixed number of levels of managers

‚ Given a program we can construct a database with a greater number of levels of managers on which the program will not work

managers on which the program will not work

(24)

Recursion in SQL

ƒ Starting with SQL:1999, SQL permits recursive view definition

ƒ E.g. query to find all employee-manager pairs with recursive empl (emp mgr ) as

with recursive empl (emp, mgr ) as ( select emp, mgr

from manager from manager union

select manager.emp, empl.mgr from manager, empl

where manager.mgr = empl.emp ) select *

from empl

(25)

Another view of Fixpoint

ƒ Fixpoint of a single view relation

pl (X Y ) (X Y )

empl (X, Y ) :– manager (X, Y ).

empl (X, Y ) :– manager (X, Z ), empl (Z, Y ) Evaluation

empl(X, Y) = mn(X, Y) ∪ (mn(X, W)

empl(W, Y)) empl0 = {}

empl1 = mn ∪ (mn

empl0) = mn

empl2 = mn ∪ (mn

empl1) = mn ∪ (mn

mn)

empl3 = mn ∪ (mn

empl2) = mn ∪ (mn

mn) ∪ (mn

mn

mn)

At some point, emplp , p k = emplp k+1 => Fixpoint!!!p

(26)

Recursion mixed with Negation

ƒ Example

(X) (X) (X)

p(X) :- r(X), not q(X) q(X) :- r(X), not p(X) Let, r = {a, b, c}

Let, r {a, b, c}

ƒ Fixpoints

Case1: p = r – q = {a, b, c} – {} = {a, b, c}p q { , , } {} { , , } q = r – p = {a, b, c} – {a, b, c} = {}

Case2: q = r – p = {a, b, c} – {} = {a, b, c}

p = r – q = {a, b, c} – {a, b, c} = {}

ƒ Two different meanings (fixed points) of the same database.

(27)

Rules must be Stratified

ƒ Layered

h h i i i d i h i i hi h

à such that negation is not mixed with recursion within the same stratum

ƒ Whenever there is a rule

à p : not q à p :- … not q,…

à we should be able to compute q completely before having to compute p.

à q should be in a lower stratum than pq p

ƒ Example: the following set of rules is not stratified Example: the following set of rules is not stratified

p(X) :- r(X), not q(X) q(X) :- r(X), not p(X)

(28)

Logic & Relational Algebra

ƒ Theorem (from Relational Algebra to Logic)

Every query expressible in Relational Algebra is expressible as a nonrecursive datalog program.

ƒ Theorem (from Logic to Relational Algebra)

L t R b ll ti f f i d t l l p ibl ith

Let R be a collection of safe, nonrecursive datalog rules, possibly with

negation. Then for each predicate p of R, there is an expression of relational algebra that computes the relation for p.

algebra that computes the relation for p.

(29)

A MORE THEORETIC VIEW

(30)

Language of First Order Logic

ƒ Symbols

à Variables constants function symbols predicate symbols:Variables, constants, function symbols, predicate symbols:

à X, Y, Z, …, a, b, c, …, f, g, h, …, p, q, r, …

à Logical connectives: ∧, ∨, ¬, ←, →

à Quantifiers: ∀, ∃

à Parentheses: ( )

ƒ TermsTerms

à represent individual elements of a domain

à constants, variables, functions with terms as arguments

à a, b, c, …, X, Y, Z, …, f(a), g(b, c), …

ƒ Atom

à Represents a statement (predicate)Represents a statement (predicate)

à p(t1, …, tn), where p is an n-place predicate and ti is a term, 1≤i≤n

à note: t1 < t2 can be written as <(t1, t2) or lessThan(t1, t2)

(31)

Language of First Order Logic (cont.)

ƒ (Well formed) Formula

1 An atom is a formula (atomic formula)

1. An atom is a formula (atomic formula)

2. If f1 and f2 are formulas then (f1), f1∧f2, f1∨f2, ¬f1, f1→ f2, and f1← f2 are formulas

3. If X is a free variable in formula f, ∀Xf, ∃Xf are formulas

4. Formulas are generated only by a finite number of applications of rules 1 ~ 3.

ƒ Scope of a quantifier

à (sub)formula to which the quantifier applies(sub)formula to which the quantifier applies

à Examples

‚ ∀Xp(X, Y) ∧ ∃Yq(X, Y)

∀X( (X Y) ∃Y (X Y))

‚ ∀X(p(X,Y) ∧ ∃Yq(X,Y))

‚ ∀X∃Y(p(X,Y) ∧ q(X,Y))

‚ ∀X∃Y loves(X,Y)

∃Y∀X l (X Y)

‚ ∃Y∀X loves(X,Y)

(32)

Language of First Order Logic (cont.)

ƒ Free and bound variables

A f i bl i f l i b d if i i i hi h

à An occurrence of a variable in a formula is bound if it is within the scope of a quantifier employing the variable.

à Otherwise the occurrence is free.

ƒ Open formula

à A formula is open if at least one occurrence of a variable is free.

à Otherwise the formula is closed.

‚ Closed formula: sentence

‚ Theory: set of sentences

‚ Theory: set of sentences

‚ Open formula: query

(33)

Semantics (Meaning) of First Order Formula

ƒ Example: Are the following statements true?

‚ ∀X(p(X) → q(X))∀X(p(X) → q(X))

‚ ∀X(man(X) → dies(X))

‚ ∀X∃Y(book(X) → man(X) ∧ read(X,Y))

‚ ∀X∃Y(p(X) → s(X) ∧ q(X Y))∀X∃Y(p(X) → s(X) ∧ q(X,Y))

ƒ Interpretation I

à D: domain

à Map each constant to an element in D

à each n-place function to a mapping: Dn → D

à each n-place predicate to a mapping: Deach n place predicate to a mapping: D → {T, F}n → {T F}

à ∧, ∨, ¬, ←, → : as usual

à ∀Xf : T if f is T for every d in D, otherwise F

à ∃Xf : T if f is T for any d in D, otherwise F

à (open formula cannot be evaluated)

(34)

Semantics of First Order Formula (cont.)

ƒ Example1: { ∀Xp(X), ∃Y¬p(Y) }

à I1: D = {1, 2}, p(1): T, p(2):T { , }, p( ) , p( )

=> ∀Xp(X):T, ∃Y¬p(Y):F

à I2: D = {tom, sam, jim, NY}, p:person’s name

=> ∀Xp(X):F ∃Y¬p(Y):T> ∀Xp(X):F, ∃Y¬p(Y):T

ƒ Example 2: ∀X(p(X) → q(f(X), a)) I

à I1:

‚ D = { tom, sam, jim, thesis1, …, thesis4, pass, fail, … }

‚ a=pass p: PhD: p(tom), p(sam) f(X) X’ h i f(t ) th1 f( ) th2 f(ji ) th3

‚ f(X): X’s thesis: f(tom)=th1, f(sam)=th2, f(jim)=th3

‚ q: result of thesis exam

=> “every PhD must have passed her thesis exam”

I2

à I2:

‚ D = {1, 2}, a=1, f(1)=2, f(2)=1,

‚ p(1):T, p (2):T, q(1,1):T, q(1,2):T, q(2,1):F, q(2,2):T

(35)

Model

ƒ Model of a formula

à an interpretation in which the formula is truep

ƒ Partial ordering of interpretations

à Let I1 and I2 be interpretations of a formula and R1 and R2 be the corresponding database instances

database instances.

I1⊆ I2 if R1⊆R2 (each relation-wise)

ƒ Minimal model

à M0 is a minimal model of a formula F if there is no model M of F such that M0⊆M (minimal number of truth assignments (tuples) )

ƒ Logical consequence ( Fㅑf ) iff f is true in every model of F.

(i.e., for every interpretation I of F, f is true in I whenever F is true in I)

(i.e., if we accept (interpret) that F is true, then we can conclude f is true also)

( p ( p ) f )

ƒ F1 and F2 are equivalent (≡) if F1ㅑ F2 and F2ㅑ F1.

(36)

Semantics of a Datalog Program

ƒ Model Theoretic View

à Datalog program (Datalog program ( II) is a theory) is a theory

à Facts in a minimal model of this theory are the only true facts

ƒ Theory ( I)

à ℜ = {R1, ..., Rn}

à For each base relation q with m tuples, we have m atomic clauses qi(vi1, ..., vini).

ƒ A possible model for (poss b e ode o (ℜℜ I))

à Predicates correspond to either DB predicates (table names) or built-in predicates (=, <, …).

à D: active domain

à Each constant to itselfEach constant to itself

à No functions

à Built-in predicates: as usual

à Base DB predicates: T iff corresponding tuple is in respective table

à Base DB predicates: T iff corresponding tuple is in respective table

à View DB predicates: T for all combinations of values (not minimal)

(37)

Horn clauses

ƒ CNF, C1 ∧ … ∧ Cn

à each Cii = pp11 ∨ … ∨ ppmm ∨ ¬qq11 ∨ … ∨ ¬qqkk (clause)( )

à Any formula can be represented in CNF

ƒ Ci is a Horn clause

à h ( b f p iti lit l ) ≤ 1

à when m (number of positive literals) ≤ 1

à p1 ← q1, …, qk

ƒ Significance

à Unique minimal model

à Definite answers

‚ Example: p(a) ∨ p(b) In a model of the formula, is p(a) true?

ƒ Datalog

à A logic-based data model

à Function-free: no function symbolsFunction free: no function symbols

à Horn clauses: p1 ← q1, …, qk r

(38)

Three formal meanings

ƒ Model-theoretic view (meaning)

à Datalog program ( I) is a theory

à Datalog program ( I) is a theory

à Facts in a minimal model are the only true facts

ƒ Proof-theoretic view (meaning)( g)

à Facts that are derivable (can be proved) from the program ( I) are the only true facts.

à This is the view that we adopted so far (e g fixpoint)

à This is the view that we adopted so far (e.g., fixpoint)

à For Horn DB (including Datalog), Proof-t-v ≡ Model-t-v

ƒ Operational semantics (meaning)

à Define an algorithm (rules of computation)

à All the facts that the algorithm says true are true

à Important for implementation considerations

à Important for implementation considerations

à Example: Prolog

(39)

END OF CHAPTER 5

참조

관련 문서

If a path is possible (i.e. , has positive probability), we want the hedge to work along that path. The actual value of the probability is irrelevant. There are no

The promise of Bitcoin is best understood in relation to traditional financial systems, which rely on centrally controlled institutions that enforce the rules,

(Note that when the number of scored questions for a given test is greater than the range of possible scaled scores, it is likely that two or more raw scores will convert to

In order to make it possible for the flow control of the vane pump to be applied in an automatic transmission, it is very necessary to analyze the variation in

In this way, it is possible to shorten the time of accident restoration and maintenance by minimizing the expression error of the high-strength facial

„ Query optimizers use equivalence rules to systematically generate expressions equivalent to the given expression.. „ Can generate all equivalent

ƒ Performing the selection as early as possible reduces the size of Performing the selection as early as possible reduces the size of the relation to be joined... number of

Note that the number of adjacent cells is the same as the number of input variables since it is equal to the number of bits... If we don’t use DC terms, the logic function f