In the last lecture, we are talking about the modal spectral analysis. The modal spectral analysis is performed taking help of the mode shapes and frequencies of the structures as we do in the case of the deterministic analysis. The whole idea again is to convert the problem into a set of uncoupled single degree of fit on system and in that case one can write down the power spectral density function relationship for a single degree of fit on system and then the responses obtained from there are then combined with the help of the relationship that exists between the displacements in the structural coordinate system and the generalized displacements through the mode shape matrix. So the essence of the modal spectral analysis is that first we decouple the equation of motion and once we decouple the equation of motion then we obtain for each decoupled equation of motion the frequency domain equation which is shown in equation 4.97A and 4.97B, 4.97A and then from there one can write down and P i omega is written in this way and if R if it is a multi supported excitation case then R is the matrix of the coefficients which is used and J i t is the ith mode shape transpose of that M bar i is the ith modal mass. So once we are able to describe P i omega that is the ith generalized load then using that one can write down S z i z j that is the cross power spectral density function between the two modal displacements z i and z j as h i into h j star then j i t M r S x double dot g R t M t and j j and both i and j vary from 1 to R where R is the number of mode shapes that we consider. So using this expression one can write down the cross power spectral density function between any two modal coordinates and then with the help of this we can make the matrix S z z and the diagonal terms of course will be S z i z i and i varying from 1 to R then after we have obtained S z z then we can obtain the power spectral density function matrix of displacements in the structural coordinate using this formula it is coming from the above relationship that is x is equal to phi z and if it holds good then x x x will be equal to phi S z z phi t. Many a time we do not take all the modes into consideration for example here we are considering the modes 1 to R R is less than the number of degrees of freedom. So in that case the phi matrix will be equal to M into R where M is the number of degrees of freedom and R is the mode shapes that are considered. So using this matrix this truncated matrix of the mode shape one can obtain the power spectral density function of the responses in structural coordinate by considering not all modes but only in limited number of modes. An example problem is solved here to illustrate the modal spectral analysis technique. This problem is the problem that we had solved for the cable state bridge where we want the power spectral density function of the degree of freedom 1 that is the left hand tower top and degree of freedom it will not be 2 it will be 3 that is the center of deck and it is assumed that a uniform time lag of 5 second between the supports exist that is it is a multi support excitation case. So for this problem the K matrix is a 3 by 3 K matrix that is the 2 corresponding to the 2 displacements at the tower top and a vertical displacement at the center of the deck and this is the mass matrix corresponding to these degrees of freedom and this is the R matrix that is the coefficient matrix that is the displacements that occur at the non support degrees of freedom due to unit displacement at the supports at the 4 supports so that constitutes the R matrix. So with the help of that we try to obtain the power spectral density function matrix of the degree of freedom 1 and degree of freedom not to 3 and we proceed with the equations that we described before now in the case of this multi support excitation what we will require is the definition of the power spectral density function sx double dot g and the power spectral density function sx double dot g will be written in terms of the coherence function or the cross correlation function between 2 supports so between the first and the second support it will be minus 5 omega divided by 2 pi because the time lag is 5 second between the first and the third it will be minus 10 omega divided by 2 pi because the time lag is 10 second and between the first and the third support it will be minus 15 omega by 2 pi defining row 1 row 2 row 3 in this particular fashion one can write down the power spectral density function matrix for the excitation as in this particular form that is 1 by 1 row 1 row 2 row 3 so on and they they successively because between 2 and 3 support it will be the row 1 that will come into picture so once we have written down this power spectral density function then we can use this for finding out the power spectral density function of the load vector that we will see later sx double dot g over here is a single it is not a matrix is a single quantity the power spectral density function of say here we have taken the L central earthquake so this is the power spectral density function of the L central earthquake as sx double dot g in fact is multiplied with all of them so therefore we have taken it out the h1 and h2 we written with the help of the first frequency and the second frequency first frequency is 2.86 therefore it will be omega n square minus omega square that is the first term and the second term is i 2 eta omega n into omega so eta is 5 percent therefore it is 0.05 and omega 1 is 2.86 therefore we in place of omega n we write down 2.86 and we have the complex frequency response function for the first mode similarly one can write down the complex frequency response function for the second mode only thing that we do is that we replace the first frequency by the second frequency 5.85 and we get the frequency response function for the second mode similarly one can write down the frequency response functions for the third mode and taking the third frequency once we have obtained these h1 h2 h3 then one can plug in these frequency response function into this equation that is hi and hj star that now is known for any two modes and the jit and jj they are also known that is the mode shapes for any two modes and sx double dot g matrix has been now defined so we use you put here the sx double dot g matrix r matrix I have shown you already so you have the r matrix and the m matrix is known therefore s j di zj that is the cross power spectral density function between any two modal coordinates can be obtained with the help of the quantities that we have just now shown. Now when all the elements of the power spectral density function of s z z are obtained in this particular fashion then we construct the s z z matrix and then obtain the power spectral density function of sxx so using this particular technique we have obtained the values of the power spectral density function of the first displacement and the third displacement and the rms value for the first displacement that is the at the top of the left hand tower that is in the modal analysis is get 0.021 and from the direct analysis we obtain 0.021 so they are same because we have taken all the three modes into consideration similarly for degree of freedom it will not be 2 for degree of freedom 3 the modal analysis get 0.015 and the direct analysis also get 0.015 the shape of the power spectral density function for degree of freedom 1 that is shown over here and we can see that the power spectral density function is picking almost at the first frequency of the structure these shows the cross power spectral density function between the any two displacements that is between u1 and u2 and or rather u3 it will be u3 and this cross power spectral density function the real part is this and the imaginary part is this as we know that the cross power spectral density functions is generally complex in character therefore it has a real part and imaginary part and these shows the power spectral density function of the top of the left tower and these shows the power spectral density function at the center of the deck next we come to the spectral analysis in state space so when we perform a state space analysis then the equation that we use is szz and szz is equal to h sfgfg h star t now for this h is the frequency response function for the state space equation and you know now the what is the frequency response function for the state space equation so it is written as i cap that is a identity matrix of size 2n by 2n and omega is a frequency minus a a matrix that is again 2n by 2n and if you recall the equation in the state space is equal to z dot is equal to az plus fg a is a is of dimension 2n by 2n z is of dimension 2n into 1 and fg also is a vector of 2n by 1 first n values are zeros and second n values second set of n values are rx double dot g that will and show you later now what we have to obtain is that sfgfg matrix and once we are able to find out the sfgfg matrix that is a power spectral density function matrix of vector fg then we can plug in that matrix over here and h omega can be computed from this equation because a matrix is explicitly known and by inverting this matrix we can get the frf or the frequency response function matrix h so let us see how we obtain the sfgfg so this is the fg in the vector form that is the first n values are zeros and then we have minus rx double dot g so it is of sine 2n into 1 and z is defined as x and x dot that is the states of the system defined by the displacement and the velocity the sfgfg matrix obviously would be 0000 rsx double dot g rt because here this last term is equal to rsx double dot g so power spectral density function corresponding to this will be rsx double dot g into rt where xx double dot g is again the power spectral density function matrix of the excitation and now if this is partially correlated that is the there is a time lag between the excitations then say for the case of 3 supports you will have the sx double dot g matrix defined as 1 rho 1 rho 2 1 rho 1 and 1 and on this side it will be symmetric and sx double dot g will be a single quantity that is the power spectral density function of the L centre earthquake in this particular case and rho 1 and rho 2 depends upon the time lag so between the first 2 supports if the time lag is 5 second then rho 1 will be exponential of minus 5 omega by 2 pi that is what we have shown before and between the first and the third support it will be rho 2 and it will be equal to minus 10 omega divided by 2 pi exponential of that so that is how one can calculate sx double dot g matrix and one can plug in this into this expression and obtain the value of the sfg sfg and once sfg sfg is obtained then using the equation that we have described before one can get the values of sj sj now sj sj in fact contains sxx sx dot xx dot sx dot x and sxx dot because z is defined like this therefore from the sj z matrix which will be of 2n by 2n size this will be n by n size this will be n by n size so we will get 2n by 2n matrix so we can choose the appropriate terms from these matrix to obtain the power spectral density function of any response quantity in the structural coordinate that is x so and if we were wanting to know the velocity power spectral density function of velocity then we can select the appropriate terms from this matrix it is to be noted that if I add up sx dot x and xx dot if I add up these 2 then the addition would be equal to 0 because we know that the cross power spectral density function between the displacement and velocity the summation of these 2 quantities they turn out to be 0 that you have proved before. So in the state space formulation one can also obtain the response in this particular way we have solved a problem here this problem is the problem in which the top and the first floor these 2 displacements are considered and the power spectral density functions for these 2 displacements are the responses that we look for so here is the A matrix for the system and this A matrix we have generated before while solving the same problem for deterministic ground motion and then using the formulation that we just described we obtained the rms value of the degree of freedom 1 that is for the top floor displacement and degree of freedom 4 that is a first floor displacements. So we obtain this by 3 methods in which this one is the modal spectral analysis that we just described before this is the direct analysis in which we do not use the mode superposition technique but to take the entire K, M and C matrix to obtain the responses and this is the state space solution that we just described and we can see that the rms values obtained by the 3 different methods they are almost the same similarly for degree of freedom 4 that is a first floor displacement the rms values are again quite comparable they are close to each other. So thus we can see that one can obtain the power spectral density function of response of a particular structure by different methods for example one can use the direct method using the second order differential equation and they are the input that we required is M, K and C and once we know the matrices M, K, C then from there one can obtain the frequency response function matrix H and then obtain the power spectral density function matrix of excitation and it depends on whether the excitations are single support excitation or a multi support excitation if it is a multi support excitation then from Sx double dot G that is the power spectral density function of the special earthquake this what to call quantity and the time lag between the supports and using a coherence function one can construct the power spectral density function matrix of the excitations and once it is known then one can straight away obtain the power spectral density function matrix of the responses. In the case of modal analysis in addition to M, C, K matrix we must know also the mode shape matrix and using the mode shape matrix one can decouple the equation of motion into a single degree of freedom equation and then use the relevant expression for finding out the cross power spectral density function between any two generalized coordinates and with the help of those cross power spectral density function matrices defined one can obtain the power spectral density function matrix of the generalized coordinate that is HZZ matrix and in terms of the structural coordinate the power spectral density function is obtained by simply multiplying pre multiplying the SZZ matrix with phi and post multiplying with phi t. So that is the modal analysis technique and for the state space analysis the H matrix that is is different than the H matrix that we obtain for the second order differential equation and once we obtain the H matrix then one has to find out SFG SFG matrix how we obtain SFG SFG matrix that I have described and one can obtain the SZZ matrix that contains also the power spectral density function of velocity along with the power spectral density function of displacements and depending upon the requirement one can choose from the matrix the relevant terms to obtain the power spectral density function of any response quantity. For the previous problem this is the power spectral density function of the response of the top displacement and this is the cross power spectral density function between the top displacement and the first floor displacement the real part of this cross power spectral density function is shown similarly we have a imaginary part for this cross power spectral density function. Now the in the state space one can obtain the responses using a again modal analysis now for that say this is the A matrix in the state space formulation so we write down Z to be is equal to Phi into Q where Phi is the Eigen values and Eigen or other Eigen vectors of the matrix A so this will be of size 2n by m provided we consider the m number of the modes but if we consider all the modes then it will be 2n by 2n matrix. And Phi inverse Phi of course will be an identity matrix of size 2n by 2n so Phi inverse A Phi that is equal to a diagonal matrix of size 2n by 2n and the diagonal terms are the Eigen values of matrix A therefore using this relationship Phi inverse A into Phi we can decouple the equation of motion in this particular form that is Q i dot is equal to lambda i Q i plus f bar G i where the lambda i is the ith Eigen value of the matrix A and Q i is the generalized i h generalized coordinate and a bar G i is the ith generalized load vector or other load not vector so f bar G i is obtained like this Phi inverse f G and ith element of that is f bar G i and once we have these relationship that is the Phi f bar G i is equal to Phi inverse f G then one can find out the power spectral density function of f bar G i simply by finding out S f G S f G and multiply it pre-multiply it be Phi inverse and then post multiplied by Phi inverse t and once we do that we get f bar G i and once we get the f bar G i then Q i omega or Q j omega that means for a particular mode the generalized coordinate in frequency domain is related to the f bar G j through the frequency response function for the jth mode and frequency response function in jth mode is given as this i omega minus lambda j inverse where lambda j is the jth Eigen value of the A matrix so we know H j omega or in other words the frequency response function for any mode and once we know that then we can use simply for a single degree of freedom equation the power spectral density function relationship between the response and the excitation that is S Q is equal to H omega S f bar G j into H omega star this H omega is for the jth mode if this is the jth mode and S Q Q will be the quantity of the power spectral density function of the jth generalized coordinate and one can obtain the S Q i Q j by simply taking the ith mode for this frequency response function and jth mode for the this frequency response function for which we are obtaining the complex conjugate so that is how all the elements of the S Q Q matrix that is written over here can be obtained and once we know that S Q Q matrix then one can obtain the S j j matrix by simply pre and post multiplying by the mode shapes and the transpose of the mode shapes with S Q Q so that is how one can also obtain a modal spectral analysis using the state space formulation now we have seen that there are many ways that we can perform the spectral analysis and these spectral analysis is or can be obtained for a single support excitation and multi support excitation by carefully obtaining the power spectral density function matrix of the excitations whenever we have the multi support excitation case then coherence function must be defined the different methods that you have described can be programmed in MATLAB following a particular flow chart and using certain relevant inputs and at the end of the book that from which we have we have made all the slides in the end of the chapter of the spectral analysis the flow chart is given with the help of which one can obtain a or write down a program for the spectral analysis of structure by using all methods so let me explain that flow chart here so first what we do is that we consider or we take the structure and obtain the stiffness matrix of the structure considering all the degrees of freedom that is the rotations also are considered and from this matrix we obtain a K matrix which is a condensed stiffness matrix corresponding to the dynamic degrees of freedom which are generated the translations and at that time we store in the program this relationship that exists between the theta degrees of freedom and the displacement degrees of freedom which is related through a matrix A and this matrix A can be easily obtained from the condensation relationship and M is the diagonal generally the diagonal mass matrix but it need not be diagonal it can be also a matrix which is a coupled matrix depending upon the problem which you have seen before now from next we obtain once we obtain the stiffness matrix corresponding to all displacements then we obtain the R matrix and if it is a multi support excitation case then in this K matrix we consider also the degrees of freedom at the supports that is a translational degrees of freedom at the supports in the sway direction and once we have that matrix then from that matrix one can obtain a R matrix which is also stored and this R matrix is of the form of minus K s s inverse that is the inverse of the non support degrees of freedom the stiffness matrix corresponding to that and K s g that is the coupling matrix between the non support degrees of freedom and the support degrees of freedom so after we have obtained for the multi support excitation case this R and it is stored then we have the non support degrees of freedom and corresponding to that the stiffness matrix and the mass matrix that we use for the solution we obtain the phi matrix from these K s s and m and omega the natural frequencies then from this also we can obtain phi R that I have discussed before that is if you these phi is the mode shapes for displacements whereas phi R could be a mode shape matrix or mode shape vector for the response quantity of interest and how to obtain that that we have described before that is if I subject the structure to a force of m omega square where m is the matrix and omega i square is the ith frequency then we the response that we get displacement response that will correspond to phi and the solution for any response quantity that is bending moment shear force taken out from that solution that will give the mode shape coefficient for that response quantity so here depending upon the response quantities that we want we can have a phi R matrix and that can be stored from the frequencies one can obtain alpha and beta coefficient and then construct the required c matrix so once we have that then one can obtain h omega matrix that is required using K m and c if we are not interested in all the response then the reduced frequency response front turn matrix h bar omega that can be obtained then for each mode one can obtain h i omega and for that what will require is the modal mass at the at a particular mode and after we have obtained these two quantities then we can go for different kinds of analysis the first kind of analysis is the direct spectral analysis where h bar omega is the complex frequency response function matrix for the degrees of freedom which are of interest that is we use the reduced complex frequency response function matrix sx double dot g matrix that is constructed with the help of the given power spectral density function of the ground motion and the coherence function from which we obtain rho 1 rho 2 etcetera and that is how sx double dot g matrix is determined and rho ij that must be expressed with the help of an expression for the coherence function taken from the literature which is appropriate for the particular site then one can obtain the sji zj that is the cross power spectral density function between any two generalized displacement and once we know the sji zj then one can obtain sj z matrix from that and if you use that sji z matrix then this particular equation uses the mode shapes to find out the sxx that is the power spectral density function matrix in the structural coordinate. So this constitute this one this one and this one sorry this one that these two constitute the Moodle spectral analysis part of it if we are interested in finding out the power spectral density function matrix for any other response quantities then the displacement response quantities then that can be also obtained by pre and post multiplying sji zj matrix with the phi r matrix phi r matrix is the mode shape matrix for that response quantity that we have stored before. Then if you are wanting to obtain the power spectral density function matrix for absolute displacement which you again we had discussed before we have two kinds of displacement one is a relative displacement with respect to the base other is the total displacement by considering the support displacement also if you are interested in finding out that then what we required is an additional expression which is sx double dot g x that is the cross power spectral density function matrix between the excitations and the displacements and this is also given in the form of an equation which we have explained before. So we obtained that and also keep it in the memory if we are required to obtain the power spectral density function matrix of absolute displacement. Next if we are wanting to go for the state special analysis then a matrix must be first generated from the K, M and C matrix then we obtained the eigen values and eigen vectors of matrix A and obtain the frequency response function matrix using matrix A and an identity matrix I then we obtain sfg sfg matrix that is the power spectral density function matrix of fg vector which consists of 0 and minus rx double dot g and how to construct sfg matrix is that I have described just before. So we obtained that and stored it and then go for a direct analysis in which sjz is straight away obtained by using this power your frequency response function matrix and sfg sfg matrix and the transpose of the complex conjugate of each matrix. Note that sjz matrix contains sxx, sx dot x dot and cross spectral density function between displacement and velocity and velocity and displacement some of them is equal to 0 and depending upon whether you require the power spectral density function of displacement or velocity we can choose the appropriate quantities from these two matrices. So that is the direct state space analysis that is direct state space power spectral density function approach. If you are wanting to find out or use the modal state space analysis in the spectral analysis then we obtain for each mode the complex frequency response function and this will require the knowledge of the eigen value of the particular mode this eigen value is generally a complex quantity. So once we obtain this complex frequency response function for the jth mode then sqyqj that is the cross power spectral density function between any two generalized coordinate can be written in this particular fashion that is hi into aj star and sf bar gi f bar gj. Now this f bar gi and f bar gj is obtained in this particular fashion say f bar g is equal to phi inverse f g and sf bar g sf bar g matrix would be given by phi inverse 0 0 0 rx double dot g rt and how to obtain sx double dot g for a multi support excitation that I have described before in which you have the cross correlation function terms rho 1 rho 2 etc and from this one can choose this f bar g f bar g will be a 2n by 2n matrix and from this matrix one can choose any cross power spectral density function term between two generalized load f bar gi and f bar gj. So that is how one can obtain this term over here and this is of course stored before and this matrix also is stored and once we have the knowledge of sqyqj then we can form the sqq matrix that is the power spectral density function matrix in the generalized coordinate and obtain the power spectral density function matrix in the state space form that is sjz which will be equal to phi sqq and phi t and this sjz matrix will contain both x and x dot. So from that one can obtain all the power spectral density function of displacement velocity and any response quantity of interest. So we see that the frequency domain spectral analysis can be carried out in different ways and the method that one uses depends upon the response quantity of interest and the way one wants to solve the problem it can be obtained in the direct form in which either one can use a state space formulation or one can take the second order differential equation in both cases the c matrix is to be constructed by obtaining alpha and beta using two modes of the structure and once we obtain the c matrix then one can perform a direct spectral analysis. If we are wanting to obtain the spectral analysis in modal coordinates or what we call as the modal spectral analysis then we have to find out the mode shapes and frequencies of the structure and this is usually done for systems which has many degrees of freedom therefore inversion of the H matrix and construction of the H matrix that becomes somewhat tedious and therefore one can go for a modal spectral analysis and we can take only a limited number of modes that is may be the first 5 or 10 modes of the system. And then obtain the first the power spectral density function matrix in generalized coordinate using the complex frequency response function for each mode and constructing a matrix of the generalized forces and for that what one has to obtain is the first one matrix is the sx the whole dot g matrix that is the matrix of excitations if it is a multi support excitation and once we have obtained that then one can find out the power spectral density function or cross power spectral density function between any two supports in the generalized system and with the help of that one can obtain the cross power spectral density function between any two generalized coordinates and from that one can obtain the sqq matrix and once the sqq matrix that is the matrix of the power spectral density function matrix of the generalized coordinates that is known then one can obtain the corresponding power spectral density function matrix in the structural coordinate by using the modal transformation rule that is sxx will be equal to phi into szz into phi t. The state space formulation can be used in many cases where we may be interested in the velocity that is the power spectral density functions of the velocity of the degree of freedom then the state space formulation is advantageous and again in that case one can go for a direct state space analysis and when we obtain the state space analysis in the direct form for the spectral analysis then h omega matrix that is a complex matrix frequency response function matrix that is of different form than the complex frequency function matrix that we use for the second order differential equation here it uses simply the A matrix for obtaining the complex frequency response function matrix for the system. Once it is known then we again use the same formulation to obtain the szz matrix that is the psdf matrix of the state space of the states of the system x and x dot. So in the szz matrix we get sxx as well as sx dot x dot. And depending upon the requirement one can choose any term from these matrices to obtain the power spectral density function of the required response. In obtaining and doing this particular formulation one has to obtain a power spectral density function matrix of f bar g that is the generalized load which consists of the first n terms of that will be 0 and second n terms will be equal to minus rx double dot g and how we can obtain the sf bar g sf bar g that we have described before. Similarly one can also obtain a modal analysis in state space for performing the spectral analysis and in that case we use the mode shapes and frequencies of the matrix A and with the help of that one can obtain the responses in the generalized coordinate q and or in other words we obtain the cross power spectral density function between any to generalized coordinate from that we obtain sqq matrix and then we can obtain szz matrix.


But we could, if I loose everybody, we could just stop at the end of Hindu Miller and just skip the higher end extension part. And if you have been familiar with this topic, please be patient that just think it like us away if it could be a good tutorial for newcomer because I know this topic would be an interesting one for those people interested into the type system.  Maybe you go to visit the HMM store then you will find it and you just can't get at what does it say. And if you zoom in a little bit you will notice that there are a lot of mathematical logic symbol and it's to you it's kind of elvish you can't understand any single bit of it. So I sum up a few of reason that why it is so hard for people that is not from a similar background. That because the language used for describe this whole system is the language used in academy and its purpose is for being sat and no mistake but not easy for comprehension. And for people inside academy they use it frequently so you have to pick up the jargon and intuition to know that. And sometimes you bump into the form that is not the form that you could read out an algorithm. That's not the syntax the regular form that driven by syntax. And even you look at the language that allow tutorial just for a simplified formal language but doesn't look very similar to Hasco and you don't understand why I have to learn this simplified language but not Hasco. And the answer is that the Hasco type system is much much more complicated. But as a foundation that you learn this simplified formal language that you could get the basic and you can eventually get the idea of what the Hasco is doing. And the next question is clear why we need hingling meter types. And it just bummed out at some previous time and you don't understand why we use it now. But you could trace it back to the early 20th century that the whole type theory is developed around that time. And at a certain point that PL community are aware that it could be used for programming language theory and it's quite useful for prevent programmer to get some mistake in programming. So in this talk I'm going to derive trying to start from an intuition example and training of examines for easier comprehension and that starts from a simplified one. So if you're going to a McDonald's supposing that burners make up breath and beef then how could you express a make burner function that we so to define such a function that we have to define a simplified formal language which is like this is I would like to call it because the example is McDonald's I would like to call it system MC which is McDonald's but actually it's lambda calculus then the make function could be expressed like this with a little icon like you could put two things like breath and meat then the output would be a burger then in tax form would be the following. But it's unsafe you could put anything to make a burger. So therefore we have to extend the language a little bit to annotate with type that like with double column burger so that with annotation we could just think it like a label you could tag a label on it. So with the building rules that we the programmer know that claim that burger making is like breath and beef then making a burger is that because the carry heart for us fathers that would call it hamburger making theory then we could type check this program with the rule of the theory that we have two things and return a burger then give it its input. But if you think it backward that it's not only for type checking because the above formula is that all things are given if we miss something that we could like infer back to those missing part like is guessing look at what the value is but then guess is type what is type is. So if we know the rule that makes breath and getting a breath and beef and getting a burger then if we have missing two things then what are these question mark would be. So let's start with a fuzzy idea that if we want to have an inference algorithm what the function would be like it's like it's a function with infer row that row is the type name and because the inference involves some states and we have to put it into a model called PC's type check for means type checking. And so with this function that we know that because we have to push eventually we need to get some type variable it's still empty but we need to do some magic and put the final result into that. So we allocate a reference and calling something else and eventually read that reference back which should be the answer for the inference result then what would be the next. So if you debug some intubation that we first want to reformulate our problem is if you put it like this and you think like it should be two formula come by and solve it like a high school algebra so is this observation correct? The answer is yes. The essence of the typing for this is to walk the whole abstract syntax tree and collect the constraint look like this and solve the missing part as you would do for high school algebra and this problem is called unification problem. So with a tiny example is like the unification problem is an equation left hand side should equal to the right hand side then we fill out t1 with int and t2 with int then both sides should be equivalent. So then with the example previously mentioned that with these two equations given then solving the equation should give us b equal to b and a equal to graph. So with this set of solution we call it unifier in academic terminology so with the problem reformulated then but one thing still missing is that we want the eventual type result with a lot of error probably with some error embedded in science and those things still missing and so it's not in the syntax or the part abstract syntax tree. So we still have to figure out that how to generate the type level grammar syntax thing. So I just name it like a type expression with a grammar generation like a type level generation like this. So with a row which is the function I name it infer row right. If I want to infer it eventually int to int to int then the process will be like row be rewrite by grammar to expand it to tau to tau then another time tau to tau to tau then and substitute by some constant type which could be int then all of them could be int. So with this grammar I call it the row and tau as meta variable for expanding the type expression. The row is the what is the row we name it infer row. So with this grammar then transform it into the Haskell type then would be like this. The type is quite obvious like function is function type is one of type to another type which is algebraic and could be itself or is constant or is type variable which should be the variable we should fill and another is meta variable is merely for expansion that the meta type variable is the row thing. So and we use a trick for type variable it's using a reference. It could be reference to some actual realized tau which could be some tree but we use reference to point to that place so it could be also be empty still not expanded or it could be expanded to something that is point to. Then with all the basic setting done we could start walking the actual AST. So with the example expression then the tree would look like this which is top level application for the beef and another application for the bread and inside is an annotation and underline is lambda calculus I use lambda symbol for that which first layer because only one single argument right so first layer is X then second layer is Y and I use beef as a short term short hand for burger. So with this thing then the inferred row we call another type checking row thing for that the expression is this expression and we run it with inferred interest mode the reference should eventually get the answer. So the first step is application. Then the next step in the TC row for application case is called a unified function with supposing that we have inferred the function body and get its result we wanted to get to something like argument and result but what is that? Actually it's the unification algorithm we mentioned before that this algorithm is for solving unification problem that depends on the problem you solve could be a little modification for management so this function does two things one is for type spreading tension for like extend one single meta variable into some kind of long tree and with arrow embedded and unified trying to make both side of equation at least structurally be equivalent so the unified tau and the function type which is a1 to a2 then this constant would be like this the tau be equal to this function a1 to a2 so with if we write it into program it would be like if it's already a function type then okay then it's just returned it otherwise then we want to first allocate a type variable for the argument which is the right hand side a1 and result type allocate another one for a2 so then with this thing assuming that unified is doing the type checking thing to check both sides of the equation be equivalent then we call this thing to check if it results any error if both sides doesn't unify then it should get some error and abort the program if it's fine then we get the structurally expanded type into rty error of rty and result dy so inside the unified we would do even further for a function that we want both sides we know both sides to look like this but we still don't know what's inside the a and what's inside the b so we have to recursively call itself to unify the argument with the right hand side argument left hand side result to right hand side result which sounds reasonable so that's for the function case and the following another following is that for the meta variable as I said this could be reference to other things so if we're hitting to a case that the unified function that both of them are meta variable then we have to check if the thing they point to are equal or not if they aren't equal then it's not okay if they are equal then it's fine if only one of them are meta variable then we have another case to handle because it's a reference so the reference we just take out the thing inside the reference if it's a thing then okay then we unify the thing inside the reference and the other thing is normal thing which is TY if another meta is happening and handled by this case so if there's something already bound for the meta variable then it's okay if it's still unbound then what's happening we still have to cover that case that means like a row still unbind to something then we have to handle this case is like we already know that TV1 is nothing it's meta variable with nothing inside so we know that TV1 is unbound then we have to check with TV2 which is inside the second meta variable if there's a thing inside then it could still be another meta variable inside so we unify the first thing meta variable to the thing inside the second meta variable and if the second thing is nothing then okay then we just save what's the thing it points to into the meta variable TV1 to point TV1 to what TV1 is located at so here the unbound variable means the meta variable is unbound then another case is that TV2 is like either function or type variable type constant then we have to check if it doesn't actually capture any variable if it doesn't actually capture any of we use the same name variable then if that's okay then we just simply save it to TV1 then the rest of them is trivial case like for constant and constant then we just compare them to see if they are equal right if we are unifying burger and burger then result should be fine and one thing to be extremely careful about is that the type variable here is not the variable we usually refer to when we are developing if their names are different then they are not the same so A1 is A1 but A1 is not A2 because their names are not the same so it's quite confusing that if you are new to this field and the rest of the case is like TV1 to TV1 and both of the arguments are TV1 then we just simply compare it as we do for the type constant and that's above all of the case we have to handle if we fall through them just are able to unify them which means the type checking failed okay so the unification algorithm is the essence of the hindrometer type system and although we are just in this example we are doing for simply type number calculus but in general the whole algorithm the layout is pretty similar just with a few little modifications so getting back to walking the abstract syntax tree we have done the application with the unify function right so with argument it's expected to by the function definition this is the type we inferred and we split it to expected argument and type and result type then at the application case we have to check if the inputs and argument are they the same that's for simply type number calculus case so we just call the check row for checking which is doing the TC row call itself in the type checking mode and the last one statement is just simply save it back to the return value which is a reference we pass in to the TC row we just put the result into the stack type and I call it for each row in this case in the single type number calculus it's trivial but for the later extension for hindrometer type system it's just we just needed this abstract layer for easy comprehension so walking down a level is another application which they do the same thing and the next level is our annotation that we know the annotation is this thing then we still do the checking as we have done for application right we check the body if the body type if it match the annotation and save the annotation back to the thing we returned then the next level is lambda lambda have the input and body and so we first allocate a type variable for the input then with the given symbol is variable right that we put it into an environment that's like this we just save it like thinking like a hash table and we know that this variable name corresponds to the type which is bar TY we allocate then for the later inference in the body then we could use this for inference and after that we write the function which because this is a lambda line it's a function type to the reference where it returned then if it runs in type in the check the above is for the inference mode and if it's in the type checking mode which could be called by the check flow function then we still call unified font to expand the static type and do the further checking for the body in the lambda to see if they are structurally equivalent then for the argument because we have allocated the variable right saving somewhere in the environment could be a hash table then we just look up the environment then save it into the return value which is at a TY this is simple and understandable then another level of lambda which doing the exact thing again but now we have two things in the variable environment which X should be the type of bar TY1 and Y to be the bar TY2 then doing the same thing again that we know that Y type should be in the environment then we get the right hand side's burger type which is trivial it's just saving the burger type into the return value then going back to the annotation because of the calling we know that we get the constraint that the body should be equal to the right hand side looking like this and so we have an annotation here should be looked like this then unify algorithm like unify the left hand side to the right hand side rather to beef and burger then should be split out to some like only the right hand side left with bar TY2 to burger and beef to burger then eventually only three unify union okay then after calling TY it's another constant type which is trivial then going back to the application so we check the check row arc making sure that it's okay for the brand as input then save beef burger to its return value with its row beef burger to burger key Y then another is constant then we basically finish all of that thing this is the tree walking is that okay? okay how can you be so sure that the type of the previous ones like the variables how can you be sure that beef and burger like I wonder if you have something like instant burger which you could put in water to make burger then you basically have two ways to make burger and so how do you know it's bread and beef and not instant burger plus water does that make any sense? you are referring to the rule itself because we have write it down the rule for bread and burger so we are oracle to claim that rule to be true all the thing is based on that that's only one way to make a burger right? yeah yeah that's the when you're programming in class or you write a type that's the thing you claim that should be the theory should be the truth and what you program is proof to prove that theory and the thing you claim okay so we finish all of the algorithm which although I think there should be still a lot of things to figure out if you are new to this but in general you get some general idea for how the thing works right but the problem is the type system is too simple the simply type lambda calculus no generalization in how the burger is made so that's the thing you refer to that we want to generalize the thing to incorporate something else that the burger should not be just meat it could be brown like you go to a mosque burger it could be rice burger so if you're calling this thing then it should work right so the trick of discovered by him and Miller independently is to add a last syntax into the grammar to add these things so that from the syntax you could tell where should the type should be generalized so the first thing is that for the language simplify language itself we have to extend above the thing we defined we have to add some polytypes like the for all in Costco so as a matter of thinking it's no longer just a label for burger it's a blank label that you could put on anything or draw anything on the label and the type would look like this it's a for all AB and become a burger and the syntax with the lab added would look like this we add a lab name turn turn case here which is correspond the name and turn and turn so but notice that for the him and Miller type this isn't the only half allowed to happen at the outer most it's not in the arrow but at the outer most should always have the left side then we could see that we just need a few extend to the previous structure defined then we could get the him and Miller so the grammar to expand the type level expression we add a for all called Sigma Sigma type is the polytype we called and bound is for the for all bound variable is for the for inside this so Sigma would be a lot of form level and a simple row of thing here could be a lot of thing inside so the only thing we added is like for type row here other thing should be the same so with the polytype introduced a concept, a corresponding concept is also introduced called instantiation it's replacing the type variable captured by for all with another fresh type variable or type concept so if you take a look at the example the left hand side instantiates the right hand side so for all A instantiate burger and this A to A instantiate burger to burger and B1 without for should be something although I call it type variable but it's not that variable it's just something empty that we should feel but it's not exactly as the variable as you saw in C or C++ then you could instantiate the blank label with a pen draw it to a burger king label so it's work like this then with the instantiate function we just replace every type variable in the topmost form with a newly instantiate type variable with a unique name so that with that unique name you could apply the same trick as we define a similar type lambda calculus so with this thing if the sigma type is for all case then we just knew a lot of meta variable for various actions and then substitute the body in the type with this newly allocated meta variable with the example like this like for all A1 A2 then we just allocate some tau 1 tau 2 which is also type variable but not for all type variable which still you have to fill in something into tau 1 and tau 2 but they are not the same as for all A1 and A2 then I said previously instantiate row if we just save it right then now we call the instantiation then save the result of what happened instantiated so that should be the instantiating or the burger being right for the various simple case then with another case introduce this generalization which is also a key part for him it's replacing a simple type variable as you saw in the tau 1 tau 2 with for all variable so with a I write poly type here but thinking like replace a normal C plus function and add a template declaration above it so it may get to a C plus a template function it works quite similar to that so thinking like that way then we could extend the infer row further to the version of infer sigma so what infer sigma do is that with knowing that we just first do the infer row for the expression passing then we just add a for all at the head of the type level expression but we have to exclude the single that only happened in the right hand side of type variable but not at the left hand side otherwise we just make the for all capture extra variable because what's happening outside should not to the outside what's happening inside should not for inside so quantify this for all statement just close like a gate just close it for the inside of the body okay so with a few of example with like this suppose that we have variable type variable B1 to A1 then we use a for all to close it like we close it for B and we just assume that because just for demonstration that A1 is done by outer scope so we just skip it and then we just kind of for generalization is wipe out the use and use ratio to wipe out the Burger King label into a black label sticker okay for the generalization case one case to handle is that it's tricky to compare two poly types for the single type lambda calculates is obvious right because it's just only what could happen is only Burger or meat but that like for all A not like that so for comparing Burger to Burger it's simple but for comparing poly types it needs some special trick so saying that the right hand side is the annotated type and the left hand side is the inferred type then this operator means more polymorphic so the left hand side is more polymorphic than the right hand side which is obvious and so a trick for comparing two poly types is that just drop the fall for the right hand side and replace it with unique thing which is previous unseen and see if the left hand side could instantiate the right hand side so then right into the program then the previous check row would become check sigma the check sigma first split the sigma into the fall variable and the variable for the type expression I wrote it for a special name because it's for the essential rank in the latter half of this talk but the thing it does is just like instantiation we write all those fall things into some unique name type variable name so allocate a lot of unique type variable and substitute for the fall so with this thing done then we guess for all type variable and row then we can just the trick we previously demonstrated we could just use the previous defined check row for the simple row head because it's no longer fall it's a little bit difficult to understand it but it's how it works so the rest is to do some checking so it doesn't accidentally capture extra variable but it's just for checking but the essence is for the above with another tree walking then with this type expression I just skip the left hand side because we have already made it we just at the top level it's a lat so when we bump into the lat we use infer sigma but not infer row and the infer sigma would generalize the type expression with and for so this lat we would put it into the environment so in our environment the type is no longer simple case like burger or meat but with something with fall it's poly type so then inside the right hand side the lat body we could use this fall to freely instantiate the new type variable for inside the lat body so when we walk into the right bump into an app we no longer use check row or instantiate row then we use the sigma version so we check if the argument type could subsume the function argument type then using the check sigma which is defined before we check it to compare two poly types to see if one of them could it's more polymorphic than the other so comparing to the simply type is just simply comparing the check simple equal or not then in station sigma instantiate the result infer back to the thing we should return okay so another app which is the same an app is also the same just looking up an app when we looking up the app what storing size is poly type then we instantiate this poly type into something actualize that could be like a bread, burger and back to the thing to return then the constant type which in this case is not that different because it's a constant but in general we just call the instant sigma version to back to the thing we return and for annotation we check if the which is also the same thing we should do for the application checking for the function argument it's the same first do checking then instantiate okay but for the unification argument just nothing needed to be done so the only thing we have all of the things we do is just make extend the role to make it incorporate the sigma the poly type for the form that for a single type comparison that we we can't just naively do it we have to do some trick to make two poly type compare that's the thing you have to think it through so that you could get a handle of how definitely the type works so what's the defect of the millimeter type system which is going I'm going to talk about higher rank so everyone follows that I should keep going or we should stop here that is I lose everybody okay so even with the addition of leds it only tells with the same text we only tell the system to generalize at the place where the lab should happen so but for the case that we have a generalized function passing in which like callback function that we want to call ID to passing in then we can handle that because the lab polymorphism doesn't generalize the argument place but in this case it's happening everywhere so we should make type system to incorporate this case so the forward should pass through the type chapter like make burgers we just want to passing the main function into another function accepting make which is polymorphic function and make two burgers which is red burger and rice burger which is sound reasonable right so then it's so here comes the higher end type system it's more the following is more mathematical simple so it could be hard to understand but trying hard so to solve the problem of lab polymorphism is it's not generalized at the argument so a trade-off is that we don't want to make the type system another big change like we don't want to overhaul the whole type system we just want to make a slight modification and maybe asking programmer to add a little annotation for that it wouldn't cause a lot of burden but in general could make the case pass the type checking so for the simplified language we define is like we add an annotation at the argument we add a firewall for the passing function so this is the previous research to write what has been implemented in Costco the answer we should do okay so we have to do another modification for the type expression which adding annotated lambda okay so which is making the argument with an annotated like burger okay so another thing keep the same and and make the row could derive sigma to sigma which is poly type to poly type that previously is only row to sigma right now it could be tau or sigma to sigma so now the type level expression could be anything that forward could happen not only at the left at the most left place but could be the like after the first arrow or the argument, the dysfunction in the argument okay so for the type level expression it's okay should be the first one of these two examples now are you okay I know I know it's I just make the grammar as an example that's okay that's the same because in fact if you want for all a two to eight ways yeah okay probably I can still get something wrong but okay just keep going and then what's the most difficult thing extending to higher range is like when comparing to two poly types since we allow for to be put at anywhere that but it's the thing it's the case we have to handle but apart from that few things we have to share with the previous layout we defined so the question in the paper the question should be asked is whether the two type expression are equivalent but they have annotated logic derivation in the paper but I didn't write it because it's hard to understand but in general with I call it intuitive but it's not that intuitive but I want to prove it that the second one could be rewrote rewritten to the first one but but not vice versa so for the second one could be first be by remove the four things into some actualized type variable and add the four as the last mode so could be rewrote into the first one which is an issue is that we could the programmer could annotate the type into in the second case but but the system algorithm inferred to be the first one then they are not the same by the mechanics so our goal is that we would like them to be asomorphic okay so then the following should be type chat that is the following two should hold okay which is that left hand side should be more polymorphic than the right hand side right hand side should be also polymorphic than the left hand side then in the paper it define a form called prenext form that is using I think it like a hack you way that to lift the four into the top level that just flows out the four be into the into the latter form so that they could be compared so that then we could see that if one is more generalized than the other okay so the scholar mice we've seen before which should have been extended from only the case one which is doing the flowing out thing to making sure that the type system sorry type expression to make it to the second one okay then it just do all the flowing out making the ball in the right hand side to to be at the most left okay then we have another subject for compared to polytypes then the trick is that we just scholar mice one and do the subs subsumption checking for the subschecking then the annotation six mark two become is supposing that is four to four and the third type is four AB and A to B then the scholar type variable is is is AB and row two is A to B then then we could see that for AB A to B could instantiate to AB then we also need some checking for not accidentally capture free variable okay then so with the subsumption checking we have done the sigma part because we have do the floating out to make the second sigma into the row the normal just with normal type variable then with another function to handle that case with second as row then we do apply the same trick which is we try to see if the first sigma one could instantiate the could be instantiate then do the two row checking then with both of them are row then we could do the unified if the second is function then we have to first made them structurally equivalent then do the function checking and vice versa if the first one is function then the second one and do it in reverse otherwise both of them are row then for the function case then we recursively call itself with the argument of sigma we have to call the subsumption checking in normal and for row result for simple row checking okay and that's that's for further extension the above all is for the extension of the instantiation to make it compare at the argument annotation to make argument annotation at what in first could be compared at the application case but now for the walking through the tree I skipped for the graphing but with those things subsumption row added we just need to add two cases which is make it structurally equivalent then do the checking which which is floating out things and checking if the argument at what passing into the as the lambda could be equivalent in the in the poly type case yeah okay yeah middle type is the foundation of Haskell 98 standard with an introduction of it that you could understand the basic of Haskell or early version of Haskell and higher rank corresponds to Haskell's extension which is rank n types and with this add on then we could handle the case which the previous example we take care and the slides keep a lot of mathematical logical deduction for better combination but if you want to look at anything beyond then you still have to pick up the jargon yeah and thank you and probably get something from this general comments and if you think it's a this implementation right circumstances over the place which makes sense for performance considerations yeah however you can implement the unilaterary type chapter yeah using pure yeah and I am aware of that just but I'm getting somewhere with this but if you do it in pure way you can also find out that it's not necessarily monadic I it's enough if you have an applicative which is a source of fresh hyper-equals because if you have that rest you can build a code that and then you can get an applicative type chapter and it should generalize with the higher higher ranking files so everything will monadic approaches build a code from a theoretical point of view yeah yeah I noticed that there are things discussed about this it's basically like basically it's basically like like it's basically like it's basically like it's basically like it's basically like put into attention yeah and the other thing is that one property the theme is that it is not positional meaning if you have two ! and it can't take the type of first especially second and then just to which means you can get type errors where we have two well-tyed sum expressions. I mean, you have the programs that replace your program with just that sum expression in the type check, and then the other one also in the type check. But if you practice them together, you get a type error from one of them. It doesn't make much sense if you go and set it bigger than your height. Why isn't this not well-tyed? I mean, it's perfectly well-tyed to expression. So there's a whole area of compositional types, which is something where this property that we can just negate the types of sum expression and compile them into the type of expression at least for the task log, we have this property that we get back to the error recipes because the errors will pinpoint that it's the composition of these two, or the combination of these two expressions where they are the sum, from or not from any of the two type sum. Yeah. I would love to hear about that. Well, I need to master some of these, but... I'm not pressing now. It's possible something goes wrong. It's possible something goes wrong is your finger. Is it? I think so. That's a bit sad because I didn't do that machine stuff. I mean, if you don't repeat the error before, I think that the chances that somebody will do new stuff on it are a population of people that will do new stuff on it. It's less. Jason, after that, I was actually with the right from casual conversation with somebody about union texts and intersection texts were supposed to be presented. I learned about union texts when they were in traffic.


The federal lawmaker representing Obudu, Obanliku Bekwara, federal constituency of Cross River State Honorable Peter Apankke, in the House of Representatives on Tuesday urged the federal government to urgently rehabilitate the abandoned Obudu Dam Resort project in Obudu Cross River State. Honorable Apankke urged the federal ministry of water resources to resume the immediate rehabilitation of the Obudu Dam project and provide funds to relevant financial authorities as well as mandate the committee on water resources when constituted to investigate why the contract was abandoned in the first place and make other recommendations. That the Obudu Dam Resort, a multi proposed facility which provides water to over 60,000 people as well as serves as a recreational center was flooded in 2005. This prompted the cross river state government to assess a facility from the independent development agency IDA to finance its rehabilitation. Recall that on August 14, 2012, the federal government awarded a contract worth $1.16 billion to Consolidated Construction Limited CCL for the rehabilitation of the dam resort. Worried that failure of the federal government to complete the Obudu Dam project has contributed to the further dwindling of revenues to the country. Tretending the livelihood of over 60,000 Nigerians who depend on the dam for water, sanitation and hygiene as well as economic purposes. Also worried that if urgent attention is not taken, actions is not taken by the federal government to rehabilitate the dam and outbreak of another disease is inevitable in Obudu Obanuku Bekwara federal constituency. Consent that the continuous loss of lives occasioned by preventable action has become a norm that must be checked. The house resolved to ask the Federal Minister of Water Resources to resume the immediate rehabilitation of the Obudu Dam project and provide funds to relevant financial authorities. The notification button so you get notified about fresh news updates.


Evelyn Glennie, mae'n cael ei bach yn ei gwasio. That's an opportunity to participate in Time for Reflection. Certainly Reflection is an activity that, I hope, we're all encouraged to participate as part of our daily medicine. I wonder what you feel the universal language of the world is, and in my mind it is listening. listening belongs to us all, and although hearing gets old, listening does not. And as I go through my life, I've come to realise that it's the participation of listening that's at the heart of every decision, action and experience encountered. Listening in a way is a super glue of life, and listening is the bridge builder and connector. And hearing has a beginning and an end, but listening is continuous. Now, hearing can bring about the illusion of isolation and silence, because we measure the experience by what we hear or what we cannot hear. But listening, on the other hand, cannot be measured. It's a sort of mysterious sixth sense that connects all of our other senses together, and no one learns how to listen. We're all born with an innate sense of listening. However, unfortunately, we're inadvertently taught more on how not to listen whilst thinking we're cultivating better listening skills. Now, we know that nothing in the world really happens in isolation, and my career is the first ever full-time solo percussionist in the world did not happen in isolation. And the most solo part, if my journey, has been listening to myself and recognising how listening ignites plasticity and purity. So true listening really has no motives. And through my foundation's mission to teach the world to listen, it's my aim to allow us all to be unselfish listeners so that we can assist and support each other to interpret self to self.  And we all have an opportunity to make what we express through whichever platforms part of our tapestry, our story and our journey. So listening to ourselves and each other allows a platform of curiosity to exist. And that leads to inquiring about things and questioning things about yourself and your surroundings and what's right in front of you. And listening helps us to learn and progress and open ourselves up to opportunities. It also helps bring different minds together and really cements the power in partnerships. So listening to our own spoken thoughts is a precious and necessary activity. And when listening is silenced, anything can happen. So listening demonstrates compassion towards yourself and others and it helps dissolve stigmas. And from this, clarity can emerge, thus igniting conviction, choice and decision. And this will leave room in the tank to build constructive listening bridges with all who we encounter. Thank you again for allowing me to speak with you as part of Time for Reflection.


Hi my name is Ray Abalaya, I'm an activist with Code Pink Women for Peace, and I take my hat off to the courageous women of Saudi Arabia for exercising your freedoms and driving. Nancy, and I'm Melanie, and we support! Tawassun bi hukuk siyaka