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)

Topological Sort
Topological SortTopological Sort
Topological Sort
 
Ppt 1
Ppt 1Ppt 1
Ppt 1
 
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

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 

Recently uploaded (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 

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).