Overview of Logic and Set Theory Basics Robert B. France Logic - - PDF document
Overview of Logic and Set Theory Basics Robert B. France Logic - - PDF document
1/5/2012 Overview of Logic and Set Theory Basics Robert B. France Logic Logic is concerned with mechanized reasoning. Reasoning, as used here, involves determining the truth of some statement (the conclusions) based on assumed truths
1/5/2012 2
Form vs Content
If the program syntax is faulty (p)
- r if
program execution results in division by 0, (q) then an error message will be generated. (r) Therefore, if the computer does not generate an error message, (not r) then the program syntax is correct (not p) and its execution does not result in division by 0. (not q) Logical Form: If p or q, then r. Therefore, if not r, then not p and not q.
Propositional logic
A proposition is a statement that is true or false but not both. Examples:
–The Acorn reactor system is in shut‐down mode. –The Company A Employee file has been created.
The following are not propositions:
– He is a student. (truth varies depending on who “He” is) – You will be a logician at the end of this course. (same as above)
1/5/2012 3
Boolean expressions
Boolean expressions are constructed from the constants true and false, boolean variables (e.g. p, q, r, s), and boolean operators (e.g. , , , ). Boolean expressions are used to represent the form of simple and compound propositions. Example: If the mixer is activated and the inlet valve is
- pen, the reactor is working normally.
p : the mixer is activated q: the inlet valve is open r : the reactor is working normally Form: (p q) r
Model‐based semantics for propositional logic
A state is an assignment of truth values (true, false) to boolean variables. The value of a boolean expression in a state is determined by truth tables. A boolean expression is satisfied in a state if its value is true in that state. A boolean expression is satisfiable if there is a state in which it is satisfied. A boolean expression is valid if it is satisfied in every
- state. A valid boolean expression is called a tautology.
1/5/2012 4
Identifying problems in specifications
- Formalizing helps identify ambiguities:
If the inlet valve is open, then the system is switched to OPEN and the outlet valve is closed if the monitoring system is functioning.
Form1: invalveopen (sysfunct open outletclosed) Form2: invalveopen (open (sysfunct outletclose))
- Specifications can help frame questions:
Alertstate NormalAlert practice NormalAlert MontitorTyped error1 Practice MonitorTyped error1
Q: If the system is in alert state and the operator typed in MONITOR command, would an error 1 occur? Q: What events cause an error 1?
Identifying problems in specifications
- Identifying inconsistencies:
The system is in alert state only when it is waiting for an intruder and is on practice alert.
Alert waiting practice
If the system is in teaching mode and is on practice alert, then it is in alert state. The system will be in teaching mode and on practice alert and not waiting for an intruder.
teaching practice alert teaching practice ~ waiting
Using truth tables one can show that the above statements are contradictory.
1/5/2012 5
Formal logic systems
A logic consists of
- a set of symbols,
- a set of formulas constructed from the symbols,
- a set of distinguished formulas called axioms, and
- a set of inference rules.
Inference rule form:
H1,H2,…,Hn
C
Theorems and proofs
A formula is a theorem of a logic if:
- it is an axiom, or
- it can be generated from the axioms and proven
theorems using the inference rules. A proof that a formula is a theorem is an argument that shows how the inference rules are used to generate the formula.
1/5/2012 6
A propositional logic system
Language: boolean expressions axioms: true q q ~(p q) ~p q p q ~p q … Inference rules: E [r := P] means that the variable r is replaced by the expression P everywhere in the expression E.
P=Q
E[r := P] = E[r :=Q]
P=Q, Q=R
P = R
P
P[r := Q]
Consistency of logics
A logic is useful only if it makes some distinctions among formulas. A logic is consistent if at least one of its formulas is a theorem, and at least one is not; otherwise the logic is inconsistent. A logic is sound iff every theorem is valid. A logic is complete iff every valid formula is a theorem.
1/5/2012 7
Predicate logic
Propositional logic cannot be used to reason about classes of objects. For example, from the statements: All monitoring computers are ready. X12 is a monitoring computer. One cannot infer that X12 is ready. Using propositional logic. Predicate logic provides notation for expressing properties involving classes of
- bjects such as:
–Cubes of integers are never even. –Some integer is a prime number. –A student receives a grade for every course in which they enroll.
Predicates, functions, and formulas
A function maps objects to other objects. Example: + : N x N N The above is called the signature of a funciton. A predicate is a function that returns a true or false value. Example: : N x N boolean Predicate logic formulas include boolean expressions, and formulas
- f the form:
- a : A • P (unrestricted universal quantifier)
- a : A | R • P (restricted universal quantifier)
- a : A • P (unrestricted existential quantifier)
- a : A | R • P (restricted existential quantifier)
1/5/2012 8
A small example
Every senior must take one maths course and pass one programming course to graduate.
s : student | senior (s) • graduate (s) ( c1, c2 : course | math (c1) prog (c2) • take (s, c1) pass (s, c2))
Predicate logic system
The language elements are:
- individual variables (representing objects),
- boolean expressions (representing propositions),
- (uninterpreted) function symbols, and
- (uninterpreted) predicate symbols.
A theory is obtained by providing interpretations for some
- f the predicate and function symbols. For example, the
theory of integers consists of predicate logic together with axioms characterizing integer arithmetic functions (e.g., +, ‐, *, , ).
1/5/2012 9
Sets
Typed sets: elements in a set must be of the same kind, i.e., elements must come from a previously defined set. Examples:
- Set of even natural numbers: {2, 4, 6, …}
- Set of cats with black fur.
- Set of dogs that bark.
Representing sets
Two ways of representing sets: Set enumeration: explicitly give elements of set.
Example: set of even numbers between 3 and 7 is {4, 6}
Set comprehension: elements of set characterized by a predicate.
Example set of even numbers between 3 and 7
- {n : N | n > 1 n < 4 • 2 * n }
- {n : N | n 3 n 7 ( e : N • n = 2 * e)}