Professional Documents
Culture Documents
Leibniz Ejercicios PDF
Leibniz Ejercicios PDF
Leibniz Ejercicios PDF
June 2015
Trinity College Dublin, IRELAND
Introduction to Logic
https://www.cs.tcd.ie/Rozenn.Dahyot/
Bogota, Colombia
Rozenn.Dahyot@cs.tcd.ie
M. Huggard & Mark Dukes, Trinity College textbook 2002.
Philosophy alphabet of human thought, then all that follows rationally from
different expressions). variables in E by their values in the state and simplifying the
expression.
Example:
3 × (x + 2) = 5 Example:
If we have E as x + y + z, then E evaluated in the state (x, 1), (y, 3) and
The constants are 2 and 5, the variable is x, the operators are ×, +
(z, 5) is simply 1 + 3 + 5 = 9.
and =. The parentheses bring together x and 2. 3 × (x + 2) denotes
the product of 3 and (x + 2).
Textual Substitution Exercise: Textual substitution
Textual Substitution. 1 Let the variables x, y, z be in the state (x, 1), (y, 42), (z, 5). Evaluate
If we have an expression E containing some variable x, then we can
the following expressions in this state:
replace every occurrence of x in E with the expression (R). This
operation, called textual substitution takes precedence over all (i) 2x + 3y − z (v) 5x − z + 1
other operations, and is written as E[x := R]. (ii) 2 + x + 4yz (vi) 7x2 + y − yz
(iii) 32 (vii) xyz
(iv) x + y(z − x) + z ÷ x (viii) (y − 2x) ÷ z
Example:
Let E be the expression (x + 1)(x − y) and let R = y + z. Then
2 Perform the following substitutions:
Similarily in textual substitution, E[x := R] means replace every x BODMAS rule http://www.calculator.org/rpn.html
in E with (R). The reason that we replace x by (R) rather than R
is for rigor. This way we avoid making mistakes when working
with the new expression.
E[x := R1 ][y := R2 ][z := R3 ] = (x + 2y + 3z)[x := 2y][y := z][z := 2] E[y := R2 ][x := R1 ][z := R3 ] = (x + 2y + 3z)[y := z][x := 2y][z := 2]
= ((2y) + 2y + 3z)[y := z][z := 2] = (x + 2(z) + 3z)[x := 2y][z := 2]
= ((2(z)) + 2(z) + 3z)[z := 2] = (x + 5z)[x := 2y][z := 2]
= ((2((2))) + 2((2)) + 3(2)) = ((2y) + 5z)[z := 2]
= (4 + 4 + 6) = 14 = (2y + 10)
Denition:
x := E evaluates expression E and stores the result in variable x.
Simultaneous (x + 2y)[x, y := y, x] =
Assignment x := E is read x becomes E.
d
Prece ence is t he characteristic of operators that indicates when
they will be evaluated when they appear in complex expressions
4 laws of Equality Using the Inference Rule Leibniz
Example:
Four laws of equality
Let X = 2x + 1, Y = y − 3x and E be the expression (z + 1)(z − 1). The
1 Reexivity x=x Inference Rule Leibniz gives
X=Y 2x + 1 = y − 3x
2 Symmetry (x = y) = (y = x) yielding
E[z := X] = E[z := Y] E[z := 2x + 1] = E[z := y − 3x]
Denition:
f .z is the new notation for f (z)
Example:
Let E be the expression 2x − y + m. Then we could dene
f (x) = 2x − y + m = E. Performing the substitution E[x := y] is the same
as f (y).
Example and exercises Reasoning using Leibniz
The purpose of this section is to
Example introduce a method for proving the equality of two expressions,
The Format:
1 Let f (x) = 2x − 1 and g(x) = x2 − 1. Evaluate the following Let us suppose that two expressions E0 and E1 are equal. A proof
Denitions:
Execution of the assignment statement x := E evaluates expression Example:
E and stores the result in the variable x. Let our statement be x := x + 1. If x > 0 (precondition) then the state
Let S be a statement. A precondition, P, of S is an assertion about in which the statement terminates must have x > 1. Hence one
the variables of S in which the statement S may be executed. A Hoare triple is:
postcondition, Q, of S is an assertion about the states in which S {x > 0} x := x + 1 {x > 1}
may terminate. This Hoare triple is said to be valid because the execution of
We represent this situation by a Hoare triple. in which x > 0 terminates in a state in which x > 1.
x := x + 1
{P} S {Q}
Assignement Statement Exercise: Assignement Statement
Example:
This Hoare triple 1 Decide whether the following triples are valid.
{x > 5} x := x + 1 {x > 6}