Download presentation

Presentation is loading. Please wait.

Published byRylee Colebank Modified about 1 year ago

1
Computing Fundamentals 1 Lecture 8 Functions Lecturer: Patrick Browne Room K308 Based on Chapter 14. A Logical approach to Discrete Math By David Gries and Fred B. Schneider

2
Given two countries Aland and Bland. We can travel from Aland to Bland using AtoB airways. Cities in Aland are called a i and cities in Bland are called b i. a1a2a3a1a2a3 Aland b1b2b3b1b2b3 AtoB Bland b4

3
From any given city a i in Aland AtoB airways provide one and only one flight to one city b i in Bland. In other words, you can travel from every city in Aland but cannot travel to more than one city in Bland from that Aland city. We can consider the flights offered by AtoB as function called FAtoB. a1a2a3a1a2a3 Aland b1b2b3b1b2b3 FAtoB Bland b4

4
There are some cities in Bland, such as b 4, that are not served by AtoB airways, therefore they cannot be reached from Aland. Obviously, if you cannot get to b 4 then you cannot come back to Aland from b 4. (no return tickets) a1a2a3a1a2a3 Aland b1b2b3b1b2b3 AtoB Bland b4

5
If for every city that AtoB airways flies into in Bland they supply a return ticket, then AtoB supply a pair of functions, FAtoB and FBtoA. We call FAtoB an injective function because it has a left inverse (a return ticket). a1a2a3a1a2a3 Aland b1b2b3b1b2b3 FAtoB Bland b4

6
If AtoB airways flies into every city in Bland, still using the original rule that only one flight can leave an Aland city, then there may be more than one way back to Aland. For example, from b 2 you can fly to a 1 or a 3. Then FAtoB is called a surjective function. It has a right inverse (but you may not get back to where you started). a1a2a3a1a2a3 Aland b1b2b1b2 FAtoB Bland

7
If a function is both injective and surjective it is then called bijective, it has both a left and right inverse. a1a2a3a1a2a3 Aland b 1 b 2 b3 FAtoB Bland

8
We apply function to argument (function application) Function definition (dot notation) g.x = 3 x + 6 Function application g(5) Gives the value of 3 5+6 To reduce brackets we can write function.argument. We evaluate this function g.5 = 3 = 21 Functions

9
Functions can be considered as a restricted form of relation. This is useful because the terminology and theory of relations carries over to function. In programming languages like C or CafeOBJ a function can have a signature, which includes its name, type of argument and the type of the expected return value. Functions

10
Fibonacci Function in C and CafeOBJ mod* FIBO-NAT { pr(NAT) op fib : Nat -> Nat var N : Nat eq fib(0) = 0. eq fib(1) = 1. ceq fib(N) = fib(p(N)) + fib(p(p(N))) if N > 1.} int fib(int n) { if (n <= 1) return n; else return fib(n-1) + fib(n-2); } Signature of a function consists of a name, argument(s) type, and return type Function Name Argument type p is a predecessor function Argument variable

11
Fibonacci Function in Python and CafeOBJ mod* FIBO-NAT { pr(NAT) op fib : Nat -> Nat var N : Nat eq fib(0) = 0. eq fib(1) = 1. ceq fib(N) = fib(p(N)) + fib(p(p(N))) if N > 1.} def fib(n): a, b = 0, 1 while b < n: print(b, end=' ') a, b = b, a+b print() Signature of a function consists of a name, argument(s) type, and return type Function Name Argument type p is a predecessor function Argument variable

12
Fibonacci Function in C and CafeOBJ mod* FIBO-NAT { pr(NAT) op fib : Nat -> Nat var N : Nat eq fib(0) = 0. eq fib(1) = 1. ceq fib(N) = fib(p(N)) + fib(p(p(N))) if N > 1.} int fib(int n) { if (n <= 1) return n; else return fib(n-1) + fib(n-2); } Signature of a function consists of a name, argument(s) type, and return type. Return type Argument constraints

13
Functions A function f is a rule for computing a value v from another value w, so that the application f(w) or f.w denotes a value v:f.w = v. The fundamental property of function application, stated in terms of inference rule Leibniz is: This property allows us to conclude theorems like f(b+b)= f(2 b) and f.b + f.b = 2 f.b.

14
Functions and programming In programming functions can have ‘side effects’ i.e. they can change a parameter or a global variable. For example, if b is changed by the function f then f.b + f.b = 2 f.b no longer holds. This makes it difficult to reason or prove properties about a program. By prohibiting side-effects we can use mathematical laws for reasoning about programs involving function application.

15
Functions as relations While we can consider functions as a rule we can also think of functions as a binary relation B C, that contains all pairs such that f.b=c. A relation can have distinct values c and c’ that satisfy bfc and bfc’, but a function cannot. b c c’ Allowed for relations but not allowed for functions

16
Function application can be defined as textual substitution. If g.z:Expression Defines a function g then function application g.X for any argument X is defined by g.X = Expression[z := X] Functions Textual Substitution

17
Function Def. & Types A binary relation f on B C, is called a function iff it is determinate. Determinate (no fan out): ( b,c,c’| b f c b f c’ : c=c’) A function f on B C is total if Total: B = Dom.f Otherwise it is partial. We write f:B C for the type of f if f is total and f:B C if f is partial.

18
Functions This close correspondence between function application and textual substitution suggests that Leibniz (1.5) links equality and function application. So, we can reformulate Leibniz for functions.

19
Functions & Types In Computer Science many types are needed. –Simple types like integers and natural numbers –Complex types like sets, lists, sequences. Each function has a type which describes the types of its parameters and the type of its result: (8.1) f: t 1 t 1... t 1 r

20
Functions & their types Are the following functions? plus: (plus(1,3)or 1+3) not : (not(true) or true) less: (less(1,3)or 1<3)

21
Functions & Types Certain restrictions are need to insure expression are type correct. During textual substitution E[x := F], x and F must have the same type. Equality b=c is defined only if b and c have the same type. Treating equality as an infix function: _=_ :t t For any type t.

22
14.41 Theorem Total function f:B C is surjective (or onto ) if Ran.f = C. Total function f:B C is injective (or one-to- one) if ( b,b’:B,c:C| bfc b’fc b=b’) A function is bijective if it is injective and surjective. Compare injective with determinate: ( b,c,c’| b f c b f c’ : c=c’)

23
14.41 Theorem Total function f is injective,one-to-one if ( b,b’:B,c:C| bfc b’fc b=b’) Total function f:B C is surjective, onto if Ran.f = C. A function is bijective if it is injective and surjective.

24
An Injective function can : f: A ->B ={f:A ->B | f -1 B ->A : f} (have inverse) f: A->B ={f:A ->B | dom f = A : f} (be total) a1a2a3a1a2a3 A b 1 b 4 b 2 b 3 f dom f ran f B Source Target

25
Injective function in CafeOBJ(*) module INJ { [ A B ] op f_ : A -> B op g_ : B -> A var a : A vars a b' : B eq [linv] : g f a = a. ceq [inj] : b = b' if g b == g b'. }

26
Injective function in CafeOBJ(*) eq [linv] : g f A = A. [linv] represents an axiom for a left inverse taking an A to a B and back to the same A. The [linv] equation says that g is a left inverse of f (i.e. g(f(a)) = a ). ceq [inj] : B = B' if g B == g B'. The conditional equation [inj] represents the injective property, that two B ’s are the same if they map to the same A. The [inj] equation expresses the injective (or one-to-one) property.

27
CafeOBJ Injective Function left inverse mod* INJ { [ A B ] op f_ : A -> B op g_ : B -> A var a : A vars b0 b1 : B eq [linv] : g f a = a. ceq [inj] : b0 = b1 if g b0 == g b1.} a1a2a3a1a2a3 A b1b2b3b1b2b3 f dom f ran f B Not in range of f. b4

28
Surjective Function Total function f:A B is surjective, onto if Ran.f = B. Total function f is injective,one-to-one if ( b,b’:B,c:C| bfc b’fc b=b’). a1a2a3a1a2a3 b1b2b1b2 f a1a2a3a1a2a3 A b 1 b 4 b 2 b 3 f B

29

30
14.42 Theorem Let f:B C be a total function, and let f -1 is its relational inverse. If f is not injective (one-to-one) then f -1 is not a determinate function. Function f not injective The inverse ( f -1 ) is not determinate B C C B

31
14.42 Theorem Let f:B C be a total function, and let f -1 be its relational inverse. Then f -1 is a (i.e. determinate) function iff f is injective (one- to-one). And, f -1 is total if f is surjective (onto). Function not total Inverse not surjective (onto) ? BCC B

32
14.42 Theorem Let f:B C be a total function, and let f -1 be its relational inverse. Then f -1 is total iff f is surjective (onto). Function not total Inverse not surjective (onto) ? BCC B

33
Total & Partial functions Dealing with partial functions can be difficult. What’s the value of ( f.b=f.b) if b Dom.f ? The choice of value must be such that the rules of manipulations that we use in the propositional and predicate calculus hold even in the presence of undefined values, and this is not easy to achieve. However, for partial function f:B C one can always restrict attention to its total counterpart, f:Dom.f C

34
Functions The binary relation < is not a function because 1 < 2 and 1 < 3 both hold. Identity relation i B over B is a total function, i B :B B ; i b =b for all b in B. Total function f: is defined by f(n)=n+1 is the relation {,,…}. Partial function f: is defined by f(n) = 1/n is the relation {,, …}. It is partial because f.0 is not defined. Note is a natural number, is a rational number.

35
Functions is an integer, + is a positive integer, - is a negative integer. Function f: + is defined by f(b)=1/b is total, since f.b is defined for all elements of +. However, g: is defined by g.b =1/b is partial because g.0 is not defined.

36
Functions The partial function f takes each lower case character to the next character can be defined by a finite number of pairs {,,.., } It is partial because there is no component whose first component is ‘z’.

37
Functions When partial and total functions are viewed as binary relations, functions can inherit operations and properties of binary relations. Two functions are equal when their sets of pairs are equal. Similar to relations, we can have the product and powers (or composition see later) of functions.

38
Inverses of Total Functions Every relation has an inverse relation. However, the inverse of a function does not have to be a function. For example: f: defined as f(b)=b 2. f(-2)=4 and f(2)=4 f -1 (4)= 2, two values (inverse is sq. rt).

39
Inverse of Total Functions Partial functions Total functions Injective or on-to-one Surjective or onto Bijective has inverse

40
Functions Products We can have the product of two relations. We now look at the product (f g) of two total functions. (f g).b = d = b(f g)b = ( |: bfc cgd) = ( |: f.b=c g.c=d) = ( |: c = f.b : g.c=d) = g(f.b) = d

41
Functions Products (f g).b = d = b(f g)b = ( |: bfc cgd) = ( |: f.b=c g.c=d) = ( |: c = f.b : g.c=d) = g(f.b) = d Hence (f g).b = g(f.b). This illustrates the difference between relational notation and functional notation.

42
Functions Products Hence (f g).b = g(f.b). This illustrates the difference between relational notation and functional notation, particularly for products. Functions possess an asymmetry between input and output. Expression f(arg) stands for the value of the function for the argument. On the other hand a relational expression r(a,b) is a statement that may be true or false. The product operation for relations is legal when the range of the first relation is the same as the domain of the second relation.

43
Functions Products We would prefer f(g.b) instead of g(f.b). So we have the new symbol for composition of functions, defined as: f g g f

44
Composition of Functions 1 g o f, the composition of f and g

45
Composition of Functions 1 The functions f:X→Y and g:Y→Z can be composed by first applying f to an argument x and then applying g to the result. Thus one obtains a function: gof: X → Z defined by (gof)(x) = g(f(x)) for all x in X. The notation gof is read as "g circle f" or "g composed with f“. The composition of functions is always associative. That is, if f, g, and h are three functions with suitably chosen domains and codomains, then f o (g o h) = (f o g) o h.

46
A function in C int addTwo(int arg) Example of usage {return (arg+2);} y = addTwo(7); arg 1 arg 2 Argument:int return 1 return 2 Return value:int addTwo(arg1) addTwo(arg2)

47
A function is a relation A function is a special case of a relation in which there is at most one value in the range for each value in the domain. A function with a finite domain is also known as a mapping. Note in diagram no diverging lines from left to right. x1x2x4x6x1x2x4x6 X y1y2y1y2 f Dom.f Ran.f Y x5x5 x3x3

48
A function is a relation The function f:X Y ‘the function f, from X to Y’ Is equivalent to relation X f Y with the restriction that for each x in the domain of f, f relates x to at most one y; x1x2x4x6x1x2x4x6 X y1y2y1y2 f Dom.f Ran.f Y x5x5 x3x3

49
Functions The relation between persons and their identity numbers –identityNo or –Person identityNo is a function if there is a rule that a person may only have one identity number. It could be defined: identityNo: Person Perhaps there should also be a rule that only one identity number may be associated with any one person, but that is not indicated here.

50
Functions A functions source and target can be the same ‘domain’ or type: hasMother: Person Person any person can have only one mother and several people could have the same mother.

51
Function Application All the concepts which pertain to relations apply to functions. In addition a function may be applied. Since there will be at most only one value in the range for a given x it is possible to designate that value directly. The value of f applied to x is the value in the range of function of the function f corresponding to the value of x in its domain.

52
Function Application The application is undefined if the value of x is not in the domain of f. It is important to check that the value of x is in the domain of the function f before attempting to apply f to x. The application of the function to the value x (the argument) is written: f.x or f(x)

53
Function Application We can check the applicability of f by writing: x dom f f.x = y These predicates must be true if f(x)=y is a function.

54
Partial and Total Functions If the identyNo function is a partial function there may be values in the source that are not in the domain (some people may have no identity number). A total function is one where there is a is a value for every possible value of x, so f.x is always defined. It is written f: X Y Because: Dom f = X (or source) function application can always be used with a total function.

55
Total Functions The function age, from Person to natural number, is total since every person has an age: age: Person The function hasMother, is total since every person has one mother (including a mother!): hasMother : Person Person

56
Injective Function An injective function may be partial or total. The functions identityNo and MonogamousMarriage are injective.

57
Isomorphism Given two functions: f:A->B, g:B->A f is isomorphism or invertible map iif gf=I A and fg=I B. Where I A, I B are the identity functions of A and B respectively. A left inverse of f is a function g such that –g(f(x)) = x. – or using alternative notation –g f x = x

58
Isomorphism Let f:A->A and g:B->B be two functions on A and B respectively. If there is a mapping t that converts all x in A to some u=t(x) in B such that g(t(x))=t(f(x)), then the two functions f and g are homomorphic and t is a homomorphism If also if t is bijective, then the two functions are isomorphic and t is an isomorphism with respect to f and g.

59
Isomorphism x t u y t z Arabic f g Roman

60
An Injective functions 1. Two injective functions A non-injective function.

61
Injective Function f Using the INJ module and the CafeOBJ apply command we will prove that an injective function with a right inverse is an isomorphism. For f:A->B, g:B->A is isomorphism or invertible map iif gf=I A and fg=I B A function f has at least one left inverse if it is an injection. A left inverse is a function g such that g f a = a or g(f(a)) = a See lab 6 for details

62
Injective Function f module INJ { -- module name [ A B ] -- two sorts op f_ : A -> B -- a function from A to B op g_ : B -> A -- a function from B to A var a : A -- variables vars b b' : B -- equation for left inverse equation of f eq [linv] : g f a = a. -- conditional equation for injective property ceq [inj] : b = b' if g b == g b'. } The [Linv] equation says that g(f(x)) = x, i.e. g is a left inverse of f. The [inj] equation expresses the injective (or one-to-one) property. A function f has at least one "left inverse" if and only if it is an injection.

63
Injective Function f open INJ. op b : > B. -- make a constant b -- make a right inverse as the term to which the equation(s) will be applied to. start f g b. -- substitute B = f g b (our term) and B' = b in [inj] apply.inj with B' = b at term. -- normal evaluation will execute [linv] apply red at term. result b : B

64
Injective Function f In CafeOBJ equations are written declaratively and interpreted operationally as rewrite rules, which replace substitution instances of the LHS by the corresponding substitutions instances of the RHS. The operational semantics normally require that the least sort of the LHS is greater that or equal to the least sort of the RHS. The [Linv] equation says that g(f(x)) = x (or g is a left inverse of f ). The [inj] equation expresses the injective (or one-to-one) property.

65
Right Inverse module* GROUP { [ G ] op 0 : -> G op _+_ : G G -> G { assoc } op -_ : G -> G var X : G eq [EQ1] : 0 + X = X. eq [EQ2] : (-X) + X = 0. }

66
Right Inverse manual Proof We want to prove that –X is a right inverse of +. A standard proof goes as follows: 1.X + ( X) = X + ( X) = 3.( ( X)) + ( X) + X + ( X) = 4.( ( X)) ( X) = 5.( ( X)) + ( X) = 6.0

67
Right inverse CafeOBJ proof open GROUP op a : > G. -- a constant start a + ( a). – the term apply .1 at (1). apply .2 with X = a at [1]. apply reduce at term.

68
Injective composition.

69
An Surjective functions 1. Two surjective functions A non-surjective function

70
An Surjective Composition 1. Surjective composition: the first function need not be surjective

71
A bijection 1. Composition gof of two functions is bijective, we can only say that f is injective and g is surjective. A bijective function

72
A function is called a bijection, if it is onto and one-to-one. A bijective function has an inverse Function Application Some examples, range on the left domain on the right A function f from X to Y is a relation from X to Y having the properties: 1. The domain of f is in X. 2. If (x,y),(x,y’) f, then y=y’ (no fan out from domain). A total function from X to Y is denoted f: X Y.

73
Injective Surjective

74
Functions Which of the following sets P, Q, and R represents a partial, surjective, injective or bijective function from X={1,2,3,4} to Y={a,b,c,d}?

75
Functions X={1,2,3,4} to Y={a,b,c,d} P = {,,, } It is a function from X to Y. Domain = X, range = {a,b,c}. The function neither injective (both 1 and 2 map to a) nor surjective(nothing maps to d)

76
Functions X={1,2,3,4} to Y={a,b,c,d} P = {,,, } Q = {,,,, } It is not a function from X to Y, because 2 maps to both a and d. R = {,,, } It is a function from X to Y. Domain = X, range =Y. The function both injective and surjective.

77
CafeOBJ Error sorts The idea of error sorts is to add new elements to the models of a specification and to let the result of a function be one of the error elements, whenever the function is not defined for an input. Error sorts can be included in the definition of the function, specifying for which inputs the result will be an error.

78
CafeOBJ Error sorts From CafeOBJ Manual An error sort is automatically declared for each connected component of the sort graph, and has an internal name that starts with ?. 2 rules for error sorts. (1) If a term is ill-formed but potentially well-formed, it is regarded as a well-formed term of questionable sort. (2) On evaluation, the potential is investigated. If the result is a term which is unquestionably well-formed, it acquires a full citizenship. Otherwise it remains an outcast (i.e. an error sort).

79
CafeOBJ parse and errors Factorial (!) and division (/) are def defined in the FACT and RAT modules respectively. Division is not defined for zero. parse in FACT + RAT : (4 / 2). parse in FACT + RAT : (4 / 0). parse in FACT + RAT : (4 / 2) !. A \/ B \/ C The principle of contradiction – that a thing cannot be and not be at the same time and in the same respect- is an axiom of thought, a law of reason of greater certitude than any law of science.

80
CafeOBJ Error sorts Above the error super-sort ?Elt for the Elt. Every sort has an error super-sort (or super set).

81
A Function Given Side = left right the function driveON Country Side Representing the side of the road vehicles drive on is a surjection, because the range includes all the values of the type Side. It would usually be considered total because driveOn should be defined in all countries.

82
What is a Hash Function? A hash function takes a data item to be stored or retrieved (say to/from disk) and computes the first choice for a storage location for the item. For example assume StudentNumber is the key field of a student record, and one record is stored on one disk block. To store or retrieve the record for student number n in a choice of 11 disk locations numbered 0 to 10 we might use the hash function. h(n) = n mod 11

83
Describe the steps needed to store a record for student number 257 using in locations disk 0-10 using h(n) = n mod Steps to store 257 using h(n)=n mod 11 into locations Calculate h(257) giving Note location is already occupied, a collision has occurred. 3. Search for next free space, with 0 assumed to follow If no free space then array is full, otherwise store 257 in next free space

84
Exercise 1 Only one person can book a room. A system records the booking of hotel rooms on one night. Given the domain of discourse consists of: Rooms the set of all rooms in hotel Person the set of all possible persons The state of the hotel’s bookings can be represented by the following: bookedTo: Room Person

85
Exercise 1 Solution (a) Explain why bookedTo is a function. bookedTo is a function since it maps rooms to persons and for any given room(domain) at most one person (range) can book it. A person can book any number of rooms. b) Explain why bookedTo is partial. The function is partial since not all rooms have been booked.

86
Example Which of the following sets P, Q, and R represents a partial, surjective, injective or bijective function from X={1,2,3,4} to Y={a,b,c,d} ? In each case explain your reasoning. P = {,,, } Q = {,,,, } R = {,,, }

87
Example Which of the following sets P, Q, and R represents a partial, surjective, injective or bijective function from X={1,2,3,4} to Y={a,b,c,d} ? In each case explain your reasoning. P = {,,, } P is a total function from X to Y. Domain = X, range= {a,b,c}. The function neither injective (both 1 and 2 map to a ) nor surjective (nothing maps to d ).

88
Example Which of the following sets P, Q, and R represents a partial, surjective, injective or bijective function from X={1,2,3,4} to Y={a,b,c,d} ? In each case explain your reasoning. Q = {,,,, } Q is not a function from X to Y, because 2 maps to both a and d.

89
Example Which of the following sets P, Q, and R represents a partial, surjective, injective or bijective function from X={1,2,3,4} to Y={a,b,c,d} ? In each case explain your reasoning. R = {,,, } R is a total function from X to Y. Domain = X, range = Y. The function both injective and surjective.

90
Exercise Which of the following sets represents a functions from {1,2,3} to {4,5,6} ? If it is a functions, what type of function is it?. P = {,, } Q = {, } R = {,, }

91
Exercise Which of the following sets represents a functions from X = {1,2,3,4} to Y={a,b,c,d} ? If it is a functions, what type of function is it? P = {,,, } Q = {,,,, } R = {,,, } R = {,, } R = {,,, }

92
Exercise-Solution 1 Does P represents a functions from X = {1,2,3,4} to Y={a,b,c,d} ? If it is a functions, what type of function is it? P = {,,, } It is a function from X to Y. Domain = X, range = {a,b,c}. The function neither injective nor surjective.

93
Exercise-Solution 2 Does Q represents a functions from X = {1,2,3,4} to Y={a,b,c,d} ? If it is a functions, what type of function is it? Q = {,,,, } It is not a function from X to Y.

94
Exercise-Solution 3 Does R represents a functions from X = {1,2,3,4} to Y={a,b,c,d} ? If it is a functions, what type of function is it? R = {,,, } It is a function from X to Y. Domain = X, range = Y. The function both injective and surjective, therefore bijective.

95
Function on Sets Determine whether the set P represents a function from X={e,f,g,h} to Y={a,b,c,d}. P = {,,, } It is a function from X to Y. Domain = X, range = {a,b,c}. The function neither injective nor surjective. Why?

96
Function on Sets Determine whether the set Q represents a function from X={e,f,g,h} to Y={a,b,c,d}. Q={,,,, } It is not a function from X to Y. Why?

97
Function on Sets Determine whether the set R represents a function from X={e,f,g,h} to Y={a,b,c,d}. R = {,,, } It is a function from X to Y. Domain = X, range =Y. The function both injective and surjective, therefore bijective.

98
Identifying Functions Which of the following are functions? Explain why they are or are not functions? 1.parent(child:Person)->parent:Person 2.mother(child:Person) -> parent:Person 3.oldestChild(parent:Person) -> child:Person 4.allChilderenOf(parent:Person) -> (Person)

99
Identifying Functions(*) Let the sort Person represent the set of all people and the sort PPerson represent the power set of Person. [Person < PPerson ] Which of the following are total functions: 1) Returns the parents of the argument op parentOf : Person -> Person 2) Returns the oldest child of the argument op oldestChildOf : Person -> Person 3) Returns all the children of the argument op allChildrenOf : Person -> PPerson

100
INJ Explained 1.eq [linv] : g f a = a. 2.ceq [inj]: b0 = b1 if g b0 == g b1. 3.open INJ. 4.op b : > B. 5.start f g b. – right inverse 6.apply.inj with b1 = b at term 7.apply red at term. Print out notes section slides 90-95, run slide show Try to relate notes to slide show.

101
INJ Explained 1.eq [linv] : g f a = a 2.ceq [inj]: b0 = b1 if g b0 == g b1 3.open INJ. 4.op b : > B. 5.start f g b. – right inverse 6.apply.inj with b1 = b at term 7.apply red at term. Substitutions are : f g b b f g b b

102
INJ Explained 1.eq [linv] : g f a = a 2.ceq [inj]: b0 = b1 if g b0 == g b1 3.open INJ. 4.op b : > B. 5.start f g b. – right inverse 6.apply.inj with b1 = b at term 7.apply red at term. giving : ceq [ injNew ] : f g b = b if g f g b == g b

103
INJ Explained 1.eq [linv] : g f a = a 2.ceq [inj]: b0 = b1 if g b0 == g b1 3.open INJ. 4.op b : > B. 5.start f g b. – right inverse 6.apply.inj with b1 = b at term 7.apply red at term. Eval : ceq [injNew] : f g b = b if g f g b == g b evaluate

104
1.eq [linv] : g f a = a 2.ceq [inj]: b0 = b1 if g b0 == g b1 3.open INJ. 4.op b : > B. 5.start f g b. – right inverse 6.apply.inj with b1 = b at term 7.apply red at term. giving : ceq [injNew] : f g b = b if g f g b == g b Substitutions g b g b INJ Explained

105
1.eq [linv] : g f a = a 2.ceq [inj]: b0 = b1 if g b0 == g b1 3.open INJ. 4.op b : > B. 5.start f g b. – right inverse 6.apply.inj with b1 = b at term 7.apply red at term. giving : ceq [injNew] : f g b = b if g f g b == g b Giving new equation eq [linvNew] : g f g b = g b INJ Explained

106

107

108
Algebra with two sorts mod! TWOSORTS { [ T V ] op f : T -> T op g : T -> V -- Specific elements of T ops t1 t2 t3 t4 t5 : -> T -- Specific elements of V ops v1 v2 v3 v4 : -> V -- equations for f eq f(t1) = t3. eq f(t3) = t4. eq f(t4) = t5. -- equations for g eq g(t1) = v1. eq g(t2) = v2. eq g(t4) = v4. eq g(t5) = v4. } open TWOSORTS **> Some reductions red f(t1). red f(f(f(t1))). red g(t4) == g(t5).

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google