SlideShare a Scribd company logo
1 of 23
Program Derivation of
Matrix Operations in GF
Charles Southerland
Dr. Anita Walker
East Central University
The Galois Field
● A finite field is a finite set and two operators
(analogous to addition and multiplication)
over which certain properties hold.
● An important finding in Abstract Algebra is
that all finite fields of the same order are
isomorphic.
● A finite field is also called a Galois Field in
honor of Evariste Galois, a significant
French mathematician in the area of
Abstract Algebra who died at age 20.
History of Program Derivation
● Hoare's 1969 paper An Axiomatic Basis for
Computer Programming essentially
created the field of Formal Methods in CS.
● Dijkstra's paper Guarded Commands,
Nondeterminacy and Formal Derivation of
Programs introduced the idea of program
derivation.
● Gries' book The Science of Programming
brings Dijkstra's paper to a level undergrad
CS and Math majors can understand.
Guarded Command Language
This is part of the language that Dijkstra defined:
● S1
;S2
– Perform S1
, and then perform S2
.
● x:=e – Assign the value of e to the variable x.
● if[b1
S→ 1
][b2
S→ 2
]…fi – Execute exactly one of the
guarded commands (i.e. S1
, S2
, … ) whose
corresponding guard (i.e. b1
, b2
, … ) is true, if any.
● do[b1
S→ 1
][b2
S→ 2
]…od – Execute the command
if[b1
S→ 1
][b2
S→ 2
]…fi until none of the guards are
true.
The Weakest Precondition
Predicate Transformer wp
● Consider the mapping
wp: P⨯L   → L
where P is the set of all finite-length programs and L
is the set of all logical statements about the state of
a computer.
● For S∊P and R∊L, wp(S,R) yields the “weakest” Q∊L
such that execution of S from within any state
satisfying Q yields a state satisfying R.
● With regard to this definition, we say a statement A is
“weaker” than a statement B if and only if the set of
states satisfying B is a proper subset of the set of
states satisfying A.
Some Notable Properties of wp
● wp([S1
;S2
],R) = wp(S1
,wp(S2
,R))
● wp([x:=e],R) = R, substituting e for x
● wp([if[b1
S→ 1
][b2
S→ 2
]…fi],R)
= (b1
∨b2
…∨ )   (∧ b1
wp(S→ 1
,R))
    (∧ b2
wp(S→ 2
,R))   …∧
● wp([do[b1
S→ 1
][b2
S→ 2
]…od],R)
= (R ~b∧ 1
~b∧ 2
…∧ )   wp([if[b∨ 1
S→ 1
][b2
S→ 2
]…
fi],R)
    wp([if…],wp([if…],R))∨
    wp([if…],wp([if…],wp([if…],R)))∨
    …∨ (for finitely many recursions)
The Program Derivation Process
For precondition Q∊L and postcondition R∊L, find
S∊P such that Q=wp(S,R).
● Gather as much information as possible about the
precondition and postcondition.
● Reduce the problem to previously solved ones
whenever possible.
● Look for a loop invariant that gives clues on how to
implement the program.
● If you are stuck, consider alternative
representations of the data.
Conditions and Background for
the Multiplicative Inverse in GF
● The precondition is that a and b be coprime
natural numbers.
● The postcondition is that x be the
multiplicative inverse of a modulo b.
● Since the greatest common divisor of a and
b is 1, Bezout's Identity yields ax+by=1,
where x is the multiplicative inverse of a.
● Recall that
gcd(a,b)=gcd(a­b,b)=gcd(a,b­a).
Analyzing Properties of the
Multiplicative Inverse in GF
● Combining Bezout's Identity and the given property of
gcd, we get
ax+by = gcd(a,b)
      = gcd(a,b­a)
      = au+(b­a)v
      = au+bv­av
      = a(u­v)+bv
● Since ax differs from a(u­v) by a constant multiple of
b, we get x (u­v) mod b≡ .
● Solving for u, we see u (x+v) mod b≡ , which leads
us to wonder if u and v may be linear combinations
of x and y.
Towards a Loop Invariant for the
Multiplicative Inverse in GF
● Rewriting Bezout's Identity using this, we get
ax+by=a(1x+0y)+b(0x+1y)
     =a((1x+0y)+y­y)+b(0x+1y)
     =a(x+y­y)+by
     =a(x+y)­ay+by
     =a(x+y)+(b­a)y
     =au+(b­a)y
(so we deduce that v=y)
● Note that assigning c:=b­a and z:=x+y
would yield ax+by=az+cy.
Finding the Loop Invariant for the
Multiplicative Inverse in GF
● Remembering that u and v are linear combinations
of x and y, we see that by reducing the values of
a and b as in the Euclidean Algorithm gives
a1
u1
+b1
v1
=a1
(ca1x
x+ca1y
y)
         +b1
(cb1x
x+cb1y
y)
       =a2
(ca1x
x+ca1y
y)
         +b1
((cb1x
­ca1x
)x
              +(cb1y
­ca1y
)y)
       = … 
● After the completion of the Euclidean algorithm, we
will have gcd(a,b)(cxf
x+cyf
y)=1.
Algorithm for the
Multiplicative Inverse in GF
multinv(a,b) {
x:=1; y:=0
do
a>b   a:=a­b; x:=x+y→
b>a   b:=b­a; y:=y+x→
od
return x
}
C Implementation of the
Multiplicative Inverse in GF
Conditions and Background
of the Matrix Product in GF
● The precondition is that the number of
columns of A and the number of rows of B
are equal.
● The postcondition is that C is the matrix
product of A and B.
● The definition of the matrix product allows
the elements of C be built one at a time,
which seems to be a particularly straight-
forward approach to the problem.
Loop Invariant of the
Matrix Product in GF
● A good loop invariant would be that all elements of
C which either have a row index less than i or
else have a row index equal to i and have a
column index less than or equal to j have the
correct value.
● The loop clearly heads toward termination given
that C is filled from left to right, from top to
bottom (which will occur if the value of j is
increased modulo the number of columns after
every calculation, increasing i by 1 every time j
returns to 0).
C Implementation of the
Matrix Product in GF
Conditions and Background of
the Determinant of a Matrix in GF
● The precondition is that the number of rows
and the number of columns of A are equal.
● The postcondition is that d is the
determinant of A.
● The naive approach to the problem is not
very efficient, but it is much easier to
explain and produces cleaner code.
The Loop Invariant of the
Determinant of a Matrix in GF
● The loop invariant of the naive determinant
algorithm is that d is equal to the sum for
all k<j of the product of A1k
and the
determinant of the matrix formed by all the
elements of A except those in the first row
and kth column.
● The loop progresses toward termination so
long as the difference between the number
of columns and j decreases.
Conditions and Background of
the Cofactor Matrix in GF
● The precondition is that the number of rows
and the number of columns of A are equal.
● The postcondition is that C is the cofactor
matrix of A.
● Like the matrix product, the cofactor matrix
can readily be generated one element at a
time.
The Loop Invariant of the
Cofactor Matrix in GF
● The loop invariant of the cofactor matrix
algorithm is, like the matrix multiplication
algorithm, that for all entries in C whose
row is less than I or whose row is equal to I
and whose column is less than j.
Conditions and Background
of the Matrix Inverse in GF
● The precondition is that the number of rows
and the number of columns of A are equal,
and that the determinant of A be coprime
to the order of GF.
● The postcondition is that B is the matrix
inverse of A.
● Like the matrix product and the cofactor
matrix, the matrix inverse can readily be
generated one element at a time
Loop Invariant of the
Matrix Inverse in GF
● The loop invariant of the matrix inverse
algorithm is, like the matrix multiplication
algorithm, that for all entries in C whose
row is less than I or whose row is equal to I
and whose column is less than j.
Applications
● Matrices over GF have many applications
within Information Theory, including
Compression, Digital Signal Processing,
and Cryptography.
● The classic Hill cipher is a well-known
example of a use of matrix operations over
GF.
● Most modern block ciphers also use
matrices over GF, specifically the S-boxes
of ciphers like Rijndael (a.k.a. AES).

More Related Content

What's hot (20)

An Introduction to Elleptic Curve Cryptography
An Introduction to Elleptic Curve CryptographyAn Introduction to Elleptic Curve Cryptography
An Introduction to Elleptic Curve Cryptography
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
 
Programacion Cuadratica
Programacion CuadraticaProgramacion Cuadratica
Programacion Cuadratica
 
11 - Programming languages
11 - Programming languages11 - Programming languages
11 - Programming languages
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
 
Vector
VectorVector
Vector
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Shortest path problem
Shortest path problemShortest path problem
Shortest path problem
 
CSE633
CSE633CSE633
CSE633
 
Midterm assign 2
Midterm assign 2Midterm assign 2
Midterm assign 2
 
Rules of block diagram
Rules of block diagramRules of block diagram
Rules of block diagram
 
14 - 08 Feb - Dynamic Programming
14 - 08 Feb - Dynamic Programming14 - 08 Feb - Dynamic Programming
14 - 08 Feb - Dynamic Programming
 
All pairs shortest path algorithm
All pairs shortest path algorithmAll pairs shortest path algorithm
All pairs shortest path algorithm
 
Dijkstra algorithm
Dijkstra algorithmDijkstra algorithm
Dijkstra algorithm
 
OpenGL Transformations
OpenGL TransformationsOpenGL Transformations
OpenGL Transformations
 

Similar to Program Derivation of Matrix Operations in GF

Chap10 slides
Chap10 slidesChap10 slides
Chap10 slidesHJ DS
 
CBSE Class 12 Mathematics formulas
CBSE Class 12 Mathematics formulasCBSE Class 12 Mathematics formulas
CBSE Class 12 Mathematics formulasParth Kshirsagar
 
Big oh Representation Used in Time complexities
Big oh Representation Used in Time complexitiesBig oh Representation Used in Time complexities
Big oh Representation Used in Time complexitiesLAKSHMITHARUN PONNAM
 
Linear_Algebra.pptx
Linear_Algebra.pptxLinear_Algebra.pptx
Linear_Algebra.pptxSuhasL11
 
Matrix representation of graph
Matrix representation of graphMatrix representation of graph
Matrix representation of graphRounak Biswas
 
How to design a linear control system
How to design a linear control systemHow to design a linear control system
How to design a linear control systemAlireza Mirzaei
 
Lecture 2 data structures and algorithms
Lecture 2 data structures and algorithmsLecture 2 data structures and algorithms
Lecture 2 data structures and algorithmsAakash deep Singhal
 
Electromagnetic theory Chapter 1
Electromagnetic theory Chapter 1Electromagnetic theory Chapter 1
Electromagnetic theory Chapter 1Ali Farooq
 
Nondeterministic Finite Automata AFN.pdf
Nondeterministic Finite Automata AFN.pdfNondeterministic Finite Automata AFN.pdf
Nondeterministic Finite Automata AFN.pdfSergioUlisesRojasAla
 
Data structure - traveling sales person and mesh algorithm
Data structure - traveling sales person and mesh algorithmData structure - traveling sales person and mesh algorithm
Data structure - traveling sales person and mesh algorithmlavanya marichamy
 
ABSTRACT GRAPH MACHINE: MODELING ORDERINGS IN ASYNCHRONOUS DISTRIBUTED-MEMORY...
ABSTRACT GRAPH MACHINE: MODELING ORDERINGS IN ASYNCHRONOUS DISTRIBUTED-MEMORY...ABSTRACT GRAPH MACHINE: MODELING ORDERINGS IN ASYNCHRONOUS DISTRIBUTED-MEMORY...
ABSTRACT GRAPH MACHINE: MODELING ORDERINGS IN ASYNCHRONOUS DISTRIBUTED-MEMORY...Thejaka Amila Kanewala, Ph.D.
 

Similar to Program Derivation of Matrix Operations in GF (20)

Ppt 1
Ppt 1Ppt 1
Ppt 1
 
Topological Sort
Topological SortTopological Sort
Topological Sort
 
Emfbook
EmfbookEmfbook
Emfbook
 
graph theory
graph theorygraph theory
graph theory
 
Chap10 slides
Chap10 slidesChap10 slides
Chap10 slides
 
Sub matrices - Circuit Matrix
Sub matrices - Circuit MatrixSub matrices - Circuit Matrix
Sub matrices - Circuit Matrix
 
Algorithms Design Exam Help
Algorithms Design Exam HelpAlgorithms Design Exam Help
Algorithms Design Exam Help
 
CBSE Class 12 Mathematics formulas
CBSE Class 12 Mathematics formulasCBSE Class 12 Mathematics formulas
CBSE Class 12 Mathematics formulas
 
Algorithms Design Assignment Help
Algorithms Design Assignment HelpAlgorithms Design Assignment Help
Algorithms Design Assignment Help
 
Optimisation random graph presentation
Optimisation random graph presentationOptimisation random graph presentation
Optimisation random graph presentation
 
Big oh Representation Used in Time complexities
Big oh Representation Used in Time complexitiesBig oh Representation Used in Time complexities
Big oh Representation Used in Time complexities
 
Linear_Algebra.pptx
Linear_Algebra.pptxLinear_Algebra.pptx
Linear_Algebra.pptx
 
09_DS_MCA_Graphs.pdf
09_DS_MCA_Graphs.pdf09_DS_MCA_Graphs.pdf
09_DS_MCA_Graphs.pdf
 
Matrix representation of graph
Matrix representation of graphMatrix representation of graph
Matrix representation of graph
 
How to design a linear control system
How to design a linear control systemHow to design a linear control system
How to design a linear control system
 
Lecture 2 data structures and algorithms
Lecture 2 data structures and algorithmsLecture 2 data structures and algorithms
Lecture 2 data structures and algorithms
 
Electromagnetic theory Chapter 1
Electromagnetic theory Chapter 1Electromagnetic theory Chapter 1
Electromagnetic theory Chapter 1
 
Nondeterministic Finite Automata AFN.pdf
Nondeterministic Finite Automata AFN.pdfNondeterministic Finite Automata AFN.pdf
Nondeterministic Finite Automata AFN.pdf
 
Data structure - traveling sales person and mesh algorithm
Data structure - traveling sales person and mesh algorithmData structure - traveling sales person and mesh algorithm
Data structure - traveling sales person and mesh algorithm
 
ABSTRACT GRAPH MACHINE: MODELING ORDERINGS IN ASYNCHRONOUS DISTRIBUTED-MEMORY...
ABSTRACT GRAPH MACHINE: MODELING ORDERINGS IN ASYNCHRONOUS DISTRIBUTED-MEMORY...ABSTRACT GRAPH MACHINE: MODELING ORDERINGS IN ASYNCHRONOUS DISTRIBUTED-MEMORY...
ABSTRACT GRAPH MACHINE: MODELING ORDERINGS IN ASYNCHRONOUS DISTRIBUTED-MEMORY...
 

More from Charles Southerland (11)

hextime (OKC LUGnuts 5C393C35)
hextime (OKC LUGnuts 5C393C35)hextime (OKC LUGnuts 5C393C35)
hextime (OKC LUGnuts 5C393C35)
 
HTTPS Sucks
HTTPS SucksHTTPS Sucks
HTTPS Sucks
 
Authentication Concepts
Authentication ConceptsAuthentication Concepts
Authentication Concepts
 
Linux Users are People, Too!
Linux Users are People, Too!Linux Users are People, Too!
Linux Users are People, Too!
 
RSA
RSARSA
RSA
 
Passwords
PasswordsPasswords
Passwords
 
Program Derivation of Operations in Finite Fields of Prime Order
Program Derivation of Operations in Finite Fields of Prime OrderProgram Derivation of Operations in Finite Fields of Prime Order
Program Derivation of Operations in Finite Fields of Prime Order
 
Logs And Backups
Logs And BackupsLogs And Backups
Logs And Backups
 
C Is Not Dead Yet
C Is Not Dead YetC Is Not Dead Yet
C Is Not Dead Yet
 
All Your Password Are Belong To Us
All Your Password Are Belong To UsAll Your Password Are Belong To Us
All Your Password Are Belong To Us
 
One-Time Pad Encryption
One-Time Pad EncryptionOne-Time Pad Encryption
One-Time Pad Encryption
 

Recently uploaded

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 

Recently uploaded (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 

Program Derivation of Matrix Operations in GF

  • 1. Program Derivation of Matrix Operations in GF Charles Southerland Dr. Anita Walker East Central University
  • 2. The Galois Field ● A finite field is a finite set and two operators (analogous to addition and multiplication) over which certain properties hold. ● An important finding in Abstract Algebra is that all finite fields of the same order are isomorphic. ● A finite field is also called a Galois Field in honor of Evariste Galois, a significant French mathematician in the area of Abstract Algebra who died at age 20.
  • 3. History of Program Derivation ● Hoare's 1969 paper An Axiomatic Basis for Computer Programming essentially created the field of Formal Methods in CS. ● Dijkstra's paper Guarded Commands, Nondeterminacy and Formal Derivation of Programs introduced the idea of program derivation. ● Gries' book The Science of Programming brings Dijkstra's paper to a level undergrad CS and Math majors can understand.
  • 4. Guarded Command Language This is part of the language that Dijkstra defined: ● S1 ;S2 – Perform S1 , and then perform S2 . ● x:=e – Assign the value of e to the variable x. ● if[b1 S→ 1 ][b2 S→ 2 ]…fi – Execute exactly one of the guarded commands (i.e. S1 , S2 , … ) whose corresponding guard (i.e. b1 , b2 , … ) is true, if any. ● do[b1 S→ 1 ][b2 S→ 2 ]…od – Execute the command if[b1 S→ 1 ][b2 S→ 2 ]…fi until none of the guards are true.
  • 5. The Weakest Precondition Predicate Transformer wp ● Consider the mapping wp: P⨯L   → L where P is the set of all finite-length programs and L is the set of all logical statements about the state of a computer. ● For S∊P and R∊L, wp(S,R) yields the “weakest” Q∊L such that execution of S from within any state satisfying Q yields a state satisfying R. ● With regard to this definition, we say a statement A is “weaker” than a statement B if and only if the set of states satisfying B is a proper subset of the set of states satisfying A.
  • 6. Some Notable Properties of wp ● wp([S1 ;S2 ],R) = wp(S1 ,wp(S2 ,R)) ● wp([x:=e],R) = R, substituting e for x ● wp([if[b1 S→ 1 ][b2 S→ 2 ]…fi],R) = (b1 ∨b2 …∨ )   (∧ b1 wp(S→ 1 ,R))     (∧ b2 wp(S→ 2 ,R))   …∧ ● wp([do[b1 S→ 1 ][b2 S→ 2 ]…od],R) = (R ~b∧ 1 ~b∧ 2 …∧ )   wp([if[b∨ 1 S→ 1 ][b2 S→ 2 ]… fi],R)     wp([if…],wp([if…],R))∨     wp([if…],wp([if…],wp([if…],R)))∨     …∨ (for finitely many recursions)
  • 7. The Program Derivation Process For precondition Q∊L and postcondition R∊L, find S∊P such that Q=wp(S,R). ● Gather as much information as possible about the precondition and postcondition. ● Reduce the problem to previously solved ones whenever possible. ● Look for a loop invariant that gives clues on how to implement the program. ● If you are stuck, consider alternative representations of the data.
  • 8. Conditions and Background for the Multiplicative Inverse in GF ● The precondition is that a and b be coprime natural numbers. ● The postcondition is that x be the multiplicative inverse of a modulo b. ● Since the greatest common divisor of a and b is 1, Bezout's Identity yields ax+by=1, where x is the multiplicative inverse of a. ● Recall that gcd(a,b)=gcd(a­b,b)=gcd(a,b­a).
  • 9. Analyzing Properties of the Multiplicative Inverse in GF ● Combining Bezout's Identity and the given property of gcd, we get ax+by = gcd(a,b)       = gcd(a,b­a)       = au+(b­a)v       = au+bv­av       = a(u­v)+bv ● Since ax differs from a(u­v) by a constant multiple of b, we get x (u­v) mod b≡ . ● Solving for u, we see u (x+v) mod b≡ , which leads us to wonder if u and v may be linear combinations of x and y.
  • 10. Towards a Loop Invariant for the Multiplicative Inverse in GF ● Rewriting Bezout's Identity using this, we get ax+by=a(1x+0y)+b(0x+1y)      =a((1x+0y)+y­y)+b(0x+1y)      =a(x+y­y)+by      =a(x+y)­ay+by      =a(x+y)+(b­a)y      =au+(b­a)y (so we deduce that v=y) ● Note that assigning c:=b­a and z:=x+y would yield ax+by=az+cy.
  • 11. Finding the Loop Invariant for the Multiplicative Inverse in GF ● Remembering that u and v are linear combinations of x and y, we see that by reducing the values of a and b as in the Euclidean Algorithm gives a1 u1 +b1 v1 =a1 (ca1x x+ca1y y)          +b1 (cb1x x+cb1y y)        =a2 (ca1x x+ca1y y)          +b1 ((cb1x ­ca1x )x               +(cb1y ­ca1y )y)        = …  ● After the completion of the Euclidean algorithm, we will have gcd(a,b)(cxf x+cyf y)=1.
  • 12. Algorithm for the Multiplicative Inverse in GF multinv(a,b) { x:=1; y:=0 do a>b   a:=a­b; x:=x+y→ b>a   b:=b­a; y:=y+x→ od return x }
  • 13. C Implementation of the Multiplicative Inverse in GF
  • 14. Conditions and Background of the Matrix Product in GF ● The precondition is that the number of columns of A and the number of rows of B are equal. ● The postcondition is that C is the matrix product of A and B. ● The definition of the matrix product allows the elements of C be built one at a time, which seems to be a particularly straight- forward approach to the problem.
  • 15. Loop Invariant of the Matrix Product in GF ● A good loop invariant would be that all elements of C which either have a row index less than i or else have a row index equal to i and have a column index less than or equal to j have the correct value. ● The loop clearly heads toward termination given that C is filled from left to right, from top to bottom (which will occur if the value of j is increased modulo the number of columns after every calculation, increasing i by 1 every time j returns to 0).
  • 16. C Implementation of the Matrix Product in GF
  • 17. Conditions and Background of the Determinant of a Matrix in GF ● The precondition is that the number of rows and the number of columns of A are equal. ● The postcondition is that d is the determinant of A. ● The naive approach to the problem is not very efficient, but it is much easier to explain and produces cleaner code.
  • 18. The Loop Invariant of the Determinant of a Matrix in GF ● The loop invariant of the naive determinant algorithm is that d is equal to the sum for all k<j of the product of A1k and the determinant of the matrix formed by all the elements of A except those in the first row and kth column. ● The loop progresses toward termination so long as the difference between the number of columns and j decreases.
  • 19. Conditions and Background of the Cofactor Matrix in GF ● The precondition is that the number of rows and the number of columns of A are equal. ● The postcondition is that C is the cofactor matrix of A. ● Like the matrix product, the cofactor matrix can readily be generated one element at a time.
  • 20. The Loop Invariant of the Cofactor Matrix in GF ● The loop invariant of the cofactor matrix algorithm is, like the matrix multiplication algorithm, that for all entries in C whose row is less than I or whose row is equal to I and whose column is less than j.
  • 21. Conditions and Background of the Matrix Inverse in GF ● The precondition is that the number of rows and the number of columns of A are equal, and that the determinant of A be coprime to the order of GF. ● The postcondition is that B is the matrix inverse of A. ● Like the matrix product and the cofactor matrix, the matrix inverse can readily be generated one element at a time
  • 22. Loop Invariant of the Matrix Inverse in GF ● The loop invariant of the matrix inverse algorithm is, like the matrix multiplication algorithm, that for all entries in C whose row is less than I or whose row is equal to I and whose column is less than j.
  • 23. Applications ● Matrices over GF have many applications within Information Theory, including Compression, Digital Signal Processing, and Cryptography. ● The classic Hill cipher is a well-known example of a use of matrix operations over GF. ● Most modern block ciphers also use matrices over GF, specifically the S-boxes of ciphers like Rijndael (a.k.a. AES).