SlideShare a Scribd company logo
Formal Methods in
Software
Lecture 1. Introduction
Vlad Patryshev
SCU
2014
Content of this course
• FSM, deterministic/non-deterministic; (P/NP); regexp; code sample (the
one-liner), problem with the code; p!=np
• Stack machine, context-free languages; general languages; Turing
machine; some Turing stuff, examples of Turing machine
• Z specification language
• Pi calculus and its fate;
• Monoid, Group, Groupoid, Category, Monomorphisms, Epimorphisms,
Isomorphisms, show it on sets and monoids; Scala (Java) category
• terminal object, initial object; products, unions; show code samples;
equalizers, code samples; notation {x|f(x)==g(x)}; pullbacks, sql
• functors examples (diagrams; product; exponentiations); currying/yoneda
lemma; example with integers/rationals; monad?
What you have to know
• first-order logic; quantifiers (see COEN260 slides)
• some set theory; binary relationships, currying;
injection/surjection/bijection (see COEN260 slides)
• some intro to intuitionistic logic (see COEN260 slides)
• javascript or java or scala
Formal Methods
• Need them in:
o medical devices
o space
o military
o communications
• Don’t need them in:
o social networks
o ads and sales
o startups
Example of Algorithm Proof
Euclidean Algorithm:
Find GCD(a,b), where a and b are two natural numbers.
1. If a < b, use the fact that GCD(a,b)=GCD(b,a)
2. GCD(a,0) = a; done.
3. GCD(a,b) = GCD(a-b,a)
4. Repeat until done.
Proof:
A. Prove that GCD(a,b)=GCD(b,a)
B. Prove that GCD(a,0) = a
C. Prove that GCD(a,b) = GCD(a-b,a)
D. Prove that it takes not more than 2*max(a,b) steps.
You are asked to double a cube
Have a cube, V=x3
Build a cube of size 2*V, using a divider and a ruler
Informally: approximate; we only have doubles in Java.
Formally: have to calculate √3(2)
The thing is: You Can’t
A similar problem
Need an algorithm to find roots of a 5th degree polynomial
Explanation: 5 roots, S5 is the group of all permutations,
and it cannot be represented via a chain of +/-
symmetries.
x5-x+1 = 0
Gödel’s First Theorem
Meaning, if we have a theory T, we can always come up with a statement in T
that cannot be proved.
How?
• enumerate all sentences; then all proofs.
• isProvable(n) ≡ ∃F (n=#(F) ∧ F is provable)
• (diagonal lemma) ∀F ∃p (p ↔ F(#(p))
• how about p ↔ ¬isProvable(#(p))
A theory that contains arithmetics cannot be
at the same time consistent and complete.
Entscheidungsproblem
Is there an algorithm that, given a first-order theory, takes a statement
and checks whether the statement is true?
(The essence of the proof of program validity.)
The answer is: NO
Church proved that there is no computable function which decides for two
given λ calculus expressions whether they are equivalent or not.
Turing proved that it reduces to Halting Problem
Halting Problem
Given a program, can we decide if it ever ends?
Answer: NO
http://ro-che.info/ccc/03
Collatz Conjecture
function(n) {
while (n > 1) {
println(n);
n = n%2==0 ? n/2 : (3*n+1)
}
}
E.g. 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1
Will it ever stop?
Nobody Knows.
So, what can we do?
• limit ourselves by only provable algorithms
• count on the finiteness of the universe (is it finite?)
• count on the finiteness of time (is it finite?)
• write some unittests and pray (is it a formal method?!)
Unittests
• You cannot prove the program is right, but you can find errors
• Can cover main and corner cases
• Can check behavior independently from environment
• Can feel safe doing refactorings
Some people tried to formalize unittest creation (agitar.com) (see e.g. halting
problem)
Question: can you write a unittest for random numbers generator?
Formal methods   1 - introduction

More Related Content

What's hot

P versus NP
P versus NPP versus NP
P versus NP
Farid El Hajj
 
P vs NP
P vs NP P vs NP
P vs NP
Mikel Qafa
 
Np Completeness
Np CompletenessNp Completeness
Np Completeness
Rajan Shah
 
Algorithm chapter 10
Algorithm chapter 10Algorithm chapter 10
Algorithm chapter 10chidabdu
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
Animesh Chaturvedi
 
the halting_problem
the halting_problemthe halting_problem
the halting_problem
Rajendran
 
Np completeness h4
Np completeness  h4Np completeness  h4
Np completeness h4
Rajendran
 
Thoery of Computaion and Chomsky's Classification
Thoery of Computaion and Chomsky's ClassificationThoery of Computaion and Chomsky's Classification
Thoery of Computaion and Chomsky's Classification
PrafullMisra
 
Class 36: Halting Problem
Class 36: Halting ProblemClass 36: Halting Problem
Class 36: Halting Problem
David Evans
 
NFA to DFA
NFA to DFANFA to DFA
NFA to DFA
Animesh Chaturvedi
 
9. chapter 8 np hard and np complete problems
9. chapter 8   np hard and np complete problems9. chapter 8   np hard and np complete problems
9. chapter 8 np hard and np complete problems
Jyotsna Suryadevara
 
Lecture: Automata
Lecture: AutomataLecture: Automata
Lecture: Automata
Marina Santini
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
Ratnakar Mikkili
 
Teori pnp
Teori pnpTeori pnp
Np completeness
Np completenessNp completeness
Np completeness
Rajendran
 
Finite automata
Finite automataFinite automata
Finite automata
Bipul Roy Bpl
 
Introduction to fa and dfa
Introduction to fa  and dfaIntroduction to fa  and dfa
Introduction to fa and dfa
deepinderbedi
 
Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5
Srimatre K
 
Automata Theory
Automata TheoryAutomata Theory

What's hot (20)

P versus NP
P versus NPP versus NP
P versus NP
 
P vs NP
P vs NP P vs NP
P vs NP
 
Np Completeness
Np CompletenessNp Completeness
Np Completeness
 
Algorithm chapter 10
Algorithm chapter 10Algorithm chapter 10
Algorithm chapter 10
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
 
the halting_problem
the halting_problemthe halting_problem
the halting_problem
 
Np completeness h4
Np completeness  h4Np completeness  h4
Np completeness h4
 
Thoery of Computaion and Chomsky's Classification
Thoery of Computaion and Chomsky's ClassificationThoery of Computaion and Chomsky's Classification
Thoery of Computaion and Chomsky's Classification
 
Class 36: Halting Problem
Class 36: Halting ProblemClass 36: Halting Problem
Class 36: Halting Problem
 
NFA to DFA
NFA to DFANFA to DFA
NFA to DFA
 
9. chapter 8 np hard and np complete problems
9. chapter 8   np hard and np complete problems9. chapter 8   np hard and np complete problems
9. chapter 8 np hard and np complete problems
 
Lecture: Automata
Lecture: AutomataLecture: Automata
Lecture: Automata
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
 
Teori pnp
Teori pnpTeori pnp
Teori pnp
 
Np completeness
Np completenessNp completeness
Np completeness
 
Finite automata
Finite automataFinite automata
Finite automata
 
Introduction to fa and dfa
Introduction to fa  and dfaIntroduction to fa  and dfa
Introduction to fa and dfa
 
Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5
 
Automata Theory
Automata TheoryAutomata Theory
Automata Theory
 
np complete
np completenp complete
np complete
 

Viewers also liked

Formal Methods
Formal MethodsFormal Methods
Formal Methods
HendMuhammad
 
Formal Methods lecture 01
Formal Methods lecture 01Formal Methods lecture 01
Formal Methods lecture 01Sidra Ashraf
 
Formal Specification in Software Engineering SE9
Formal Specification in Software Engineering SE9Formal Specification in Software Engineering SE9
Formal Specification in Software Engineering SE9koolkampus
 
Using formal methods in Industrial Software Development
Using formal methods in Industrial Software DevelopmentUsing formal methods in Industrial Software Development
Using formal methods in Industrial Software Development
Robert van Lieshout
 
Industrial use of formal methods
Industrial use of formal methodsIndustrial use of formal methods
Industrial use of formal methods
Jonathan Bowen
 
Ten Commandments of Formal Methods: A decade later
Ten Commandments of Formal Methods: A decade laterTen Commandments of Formal Methods: A decade later
Ten Commandments of Formal Methods: A decade later
Jonathan Bowen
 
#1 formal methods – introduction for software engineering
#1 formal methods – introduction for software engineering#1 formal methods – introduction for software engineering
#1 formal methods – introduction for software engineering
Sharif Omar Salem
 

Viewers also liked (8)

Formal Methods
Formal MethodsFormal Methods
Formal Methods
 
Formal Methods lecture 01
Formal Methods lecture 01Formal Methods lecture 01
Formal Methods lecture 01
 
Formal Specification in Software Engineering SE9
Formal Specification in Software Engineering SE9Formal Specification in Software Engineering SE9
Formal Specification in Software Engineering SE9
 
Using formal methods in Industrial Software Development
Using formal methods in Industrial Software DevelopmentUsing formal methods in Industrial Software Development
Using formal methods in Industrial Software Development
 
Industrial use of formal methods
Industrial use of formal methodsIndustrial use of formal methods
Industrial use of formal methods
 
Ten Commandments of Formal Methods: A decade later
Ten Commandments of Formal Methods: A decade laterTen Commandments of Formal Methods: A decade later
Ten Commandments of Formal Methods: A decade later
 
#1 formal methods – introduction for software engineering
#1 formal methods – introduction for software engineering#1 formal methods – introduction for software engineering
#1 formal methods – introduction for software engineering
 
Software quality
Software qualitySoftware quality
Software quality
 

Similar to Formal methods 1 - introduction

2009 CSBB LAB 新生訓練
2009 CSBB LAB 新生訓練2009 CSBB LAB 新生訓練
2009 CSBB LAB 新生訓練
Abner Huang
 
UNIT-V.pdf daa unit material 5 th unit ppt
UNIT-V.pdf daa unit material 5 th unit pptUNIT-V.pdf daa unit material 5 th unit ppt
UNIT-V.pdf daa unit material 5 th unit ppt
JyoReddy9
 
Basic_concepts_NP_Hard_NP_Complete.pdf
Basic_concepts_NP_Hard_NP_Complete.pdfBasic_concepts_NP_Hard_NP_Complete.pdf
Basic_concepts_NP_Hard_NP_Complete.pdf
Arivukkarasu Dhanapal
 
tutorial.ppt
tutorial.ppttutorial.ppt
tutorial.ppt
GuioGonza2
 
Discrete Math Lecture 02: First Order Logic
Discrete Math Lecture 02: First Order LogicDiscrete Math Lecture 02: First Order Logic
Discrete Math Lecture 02: First Order Logic
IT Engineering Department
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-Hard
Animesh Chaturvedi
 
Tutorial - Introduction to Rule Technologies and Systems
Tutorial - Introduction to Rule Technologies and SystemsTutorial - Introduction to Rule Technologies and Systems
Tutorial - Introduction to Rule Technologies and Systems
Adrian Paschke
 
NP completeness
NP completenessNP completeness
NP completeness
Amrinder Arora
 
How Hard Can a Problem Be ?
How Hard Can a Problem Be ?How Hard Can a Problem Be ?
How Hard Can a Problem Be ?
Ahmed Saeed
 
Presentation of GetTogether on Functional Programming
Presentation of GetTogether on Functional ProgrammingPresentation of GetTogether on Functional Programming
Presentation of GetTogether on Functional ProgrammingFilip De Sutter
 
GDSC SSN - solution Challenge : Fundamentals of Decision Making
GDSC SSN - solution Challenge : Fundamentals of Decision MakingGDSC SSN - solution Challenge : Fundamentals of Decision Making
GDSC SSN - solution Challenge : Fundamentals of Decision Making
GDSCSSN
 
It's All About Morphisms
It's All About MorphismsIt's All About Morphisms
It's All About Morphisms
Uberto Barbini
 
App a
App aApp a
Incompleteness without Godel Numberings
Incompleteness without Godel NumberingsIncompleteness without Godel Numberings
Incompleteness without Godel NumberingsSatvik Beri
 
Scala design pattern
Scala design patternScala design pattern
Scala design patternKenji Yoshida
 
MACHINE LEARNING-LEARNING RULE
MACHINE LEARNING-LEARNING RULEMACHINE LEARNING-LEARNING RULE
MACHINE LEARNING-LEARNING RULE
DrBindhuM
 
Algorithms and Complexity: Cryptography Theory
Algorithms and Complexity: Cryptography TheoryAlgorithms and Complexity: Cryptography Theory
Algorithms and Complexity: Cryptography Theory
Alex Prut
 
Turbo prolog 2.0 basics
Turbo prolog 2.0 basicsTurbo prolog 2.0 basics
Turbo prolog 2.0 basics
Soham Kansodaria
 

Similar to Formal methods 1 - introduction (20)

2009 CSBB LAB 新生訓練
2009 CSBB LAB 新生訓練2009 CSBB LAB 新生訓練
2009 CSBB LAB 新生訓練
 
UNIT-V.pdf daa unit material 5 th unit ppt
UNIT-V.pdf daa unit material 5 th unit pptUNIT-V.pdf daa unit material 5 th unit ppt
UNIT-V.pdf daa unit material 5 th unit ppt
 
Basic_concepts_NP_Hard_NP_Complete.pdf
Basic_concepts_NP_Hard_NP_Complete.pdfBasic_concepts_NP_Hard_NP_Complete.pdf
Basic_concepts_NP_Hard_NP_Complete.pdf
 
tutorial.ppt
tutorial.ppttutorial.ppt
tutorial.ppt
 
Discrete Math Lecture 02: First Order Logic
Discrete Math Lecture 02: First Order LogicDiscrete Math Lecture 02: First Order Logic
Discrete Math Lecture 02: First Order Logic
 
UNIT -IV DAA.pdf
UNIT  -IV DAA.pdfUNIT  -IV DAA.pdf
UNIT -IV DAA.pdf
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-Hard
 
Tutorial - Introduction to Rule Technologies and Systems
Tutorial - Introduction to Rule Technologies and SystemsTutorial - Introduction to Rule Technologies and Systems
Tutorial - Introduction to Rule Technologies and Systems
 
NP completeness
NP completenessNP completeness
NP completeness
 
How Hard Can a Problem Be ?
How Hard Can a Problem Be ?How Hard Can a Problem Be ?
How Hard Can a Problem Be ?
 
Presentation of GetTogether on Functional Programming
Presentation of GetTogether on Functional ProgrammingPresentation of GetTogether on Functional Programming
Presentation of GetTogether on Functional Programming
 
GDSC SSN - solution Challenge : Fundamentals of Decision Making
GDSC SSN - solution Challenge : Fundamentals of Decision MakingGDSC SSN - solution Challenge : Fundamentals of Decision Making
GDSC SSN - solution Challenge : Fundamentals of Decision Making
 
It's All About Morphisms
It's All About MorphismsIt's All About Morphisms
It's All About Morphisms
 
App a
App aApp a
App a
 
Incompleteness without Godel Numberings
Incompleteness without Godel NumberingsIncompleteness without Godel Numberings
Incompleteness without Godel Numberings
 
Scala design pattern
Scala design patternScala design pattern
Scala design pattern
 
MACHINE LEARNING-LEARNING RULE
MACHINE LEARNING-LEARNING RULEMACHINE LEARNING-LEARNING RULE
MACHINE LEARNING-LEARNING RULE
 
Algorithms and Complexity: Cryptography Theory
Algorithms and Complexity: Cryptography TheoryAlgorithms and Complexity: Cryptography Theory
Algorithms and Complexity: Cryptography Theory
 
Big o
Big oBig o
Big o
 
Turbo prolog 2.0 basics
Turbo prolog 2.0 basicsTurbo prolog 2.0 basics
Turbo prolog 2.0 basics
 

More from Vlad Patryshev

Formal methods 8 - category theory (last one)
Formal methods   8 - category theory (last one)Formal methods   8 - category theory (last one)
Formal methods 8 - category theory (last one)
Vlad Patryshev
 
Formal methods 6 - elements of algebra
Formal methods   6 - elements of algebraFormal methods   6 - elements of algebra
Formal methods 6 - elements of algebra
Vlad Patryshev
 
Formal methods 5 - Pi calculus
Formal methods   5 - Pi calculusFormal methods   5 - Pi calculus
Formal methods 5 - Pi calculus
Vlad Patryshev
 
Formal methods 4 - Z notation
Formal methods   4 - Z notationFormal methods   4 - Z notation
Formal methods 4 - Z notation
Vlad Patryshev
 
Formal methods 3 - languages and machines
Formal methods   3 - languages and machinesFormal methods   3 - languages and machines
Formal methods 3 - languages and machines
Vlad Patryshev
 
Formal methods 2 - languages and machines
Formal methods   2 - languages and machinesFormal methods   2 - languages and machines
Formal methods 2 - languages and machines
Vlad Patryshev
 
Formal methods 7 - category theory
Formal methods   7 - category theoryFormal methods   7 - category theory
Formal methods 7 - category theory
Vlad Patryshev
 
Truth, deduction, computation lecture i (last one)
Truth, deduction, computation   lecture i (last one)Truth, deduction, computation   lecture i (last one)
Truth, deduction, computation lecture i (last one)
Vlad Patryshev
 
Truth, deduction, computation lecture h
Truth, deduction, computation   lecture hTruth, deduction, computation   lecture h
Truth, deduction, computation lecture h
Vlad Patryshev
 
Truth, deduction, computation lecture g
Truth, deduction, computation   lecture gTruth, deduction, computation   lecture g
Truth, deduction, computation lecture g
Vlad Patryshev
 
Truth, deduction, computation lecture f
Truth, deduction, computation   lecture fTruth, deduction, computation   lecture f
Truth, deduction, computation lecture f
Vlad Patryshev
 
Truth, deduction, computation lecture e
Truth, deduction, computation   lecture eTruth, deduction, computation   lecture e
Truth, deduction, computation lecture e
Vlad Patryshev
 
Truth, deduction, computation lecture d
Truth, deduction, computation   lecture dTruth, deduction, computation   lecture d
Truth, deduction, computation lecture d
Vlad Patryshev
 
Truth, deduction, computation lecture c
Truth, deduction, computation   lecture cTruth, deduction, computation   lecture c
Truth, deduction, computation lecture c
Vlad Patryshev
 
Truth, deduction, computation lecture b
Truth, deduction, computation   lecture bTruth, deduction, computation   lecture b
Truth, deduction, computation lecture b
Vlad Patryshev
 
Truth, deduction, computation lecture a
Truth, deduction, computation   lecture aTruth, deduction, computation   lecture a
Truth, deduction, computation lecture a
Vlad Patryshev
 
Truth, deduction, computation lecture 9
Truth, deduction, computation   lecture 9Truth, deduction, computation   lecture 9
Truth, deduction, computation lecture 9
Vlad Patryshev
 
Truth, deduction, computation lecture 8
Truth, deduction, computation   lecture 8Truth, deduction, computation   lecture 8
Truth, deduction, computation lecture 8
Vlad Patryshev
 
Truth, deduction, computation lecture 7
Truth, deduction, computation   lecture 7Truth, deduction, computation   lecture 7
Truth, deduction, computation lecture 7
Vlad Patryshev
 
Truth, deduction, computation lecture 6
Truth, deduction, computation   lecture 6Truth, deduction, computation   lecture 6
Truth, deduction, computation lecture 6
Vlad Patryshev
 

More from Vlad Patryshev (20)

Formal methods 8 - category theory (last one)
Formal methods   8 - category theory (last one)Formal methods   8 - category theory (last one)
Formal methods 8 - category theory (last one)
 
Formal methods 6 - elements of algebra
Formal methods   6 - elements of algebraFormal methods   6 - elements of algebra
Formal methods 6 - elements of algebra
 
Formal methods 5 - Pi calculus
Formal methods   5 - Pi calculusFormal methods   5 - Pi calculus
Formal methods 5 - Pi calculus
 
Formal methods 4 - Z notation
Formal methods   4 - Z notationFormal methods   4 - Z notation
Formal methods 4 - Z notation
 
Formal methods 3 - languages and machines
Formal methods   3 - languages and machinesFormal methods   3 - languages and machines
Formal methods 3 - languages and machines
 
Formal methods 2 - languages and machines
Formal methods   2 - languages and machinesFormal methods   2 - languages and machines
Formal methods 2 - languages and machines
 
Formal methods 7 - category theory
Formal methods   7 - category theoryFormal methods   7 - category theory
Formal methods 7 - category theory
 
Truth, deduction, computation lecture i (last one)
Truth, deduction, computation   lecture i (last one)Truth, deduction, computation   lecture i (last one)
Truth, deduction, computation lecture i (last one)
 
Truth, deduction, computation lecture h
Truth, deduction, computation   lecture hTruth, deduction, computation   lecture h
Truth, deduction, computation lecture h
 
Truth, deduction, computation lecture g
Truth, deduction, computation   lecture gTruth, deduction, computation   lecture g
Truth, deduction, computation lecture g
 
Truth, deduction, computation lecture f
Truth, deduction, computation   lecture fTruth, deduction, computation   lecture f
Truth, deduction, computation lecture f
 
Truth, deduction, computation lecture e
Truth, deduction, computation   lecture eTruth, deduction, computation   lecture e
Truth, deduction, computation lecture e
 
Truth, deduction, computation lecture d
Truth, deduction, computation   lecture dTruth, deduction, computation   lecture d
Truth, deduction, computation lecture d
 
Truth, deduction, computation lecture c
Truth, deduction, computation   lecture cTruth, deduction, computation   lecture c
Truth, deduction, computation lecture c
 
Truth, deduction, computation lecture b
Truth, deduction, computation   lecture bTruth, deduction, computation   lecture b
Truth, deduction, computation lecture b
 
Truth, deduction, computation lecture a
Truth, deduction, computation   lecture aTruth, deduction, computation   lecture a
Truth, deduction, computation lecture a
 
Truth, deduction, computation lecture 9
Truth, deduction, computation   lecture 9Truth, deduction, computation   lecture 9
Truth, deduction, computation lecture 9
 
Truth, deduction, computation lecture 8
Truth, deduction, computation   lecture 8Truth, deduction, computation   lecture 8
Truth, deduction, computation lecture 8
 
Truth, deduction, computation lecture 7
Truth, deduction, computation   lecture 7Truth, deduction, computation   lecture 7
Truth, deduction, computation lecture 7
 
Truth, deduction, computation lecture 6
Truth, deduction, computation   lecture 6Truth, deduction, computation   lecture 6
Truth, deduction, computation lecture 6
 

Recently uploaded

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 

Recently uploaded (20)

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 

Formal methods 1 - introduction

  • 1. Formal Methods in Software Lecture 1. Introduction Vlad Patryshev SCU 2014
  • 2. Content of this course • FSM, deterministic/non-deterministic; (P/NP); regexp; code sample (the one-liner), problem with the code; p!=np • Stack machine, context-free languages; general languages; Turing machine; some Turing stuff, examples of Turing machine • Z specification language • Pi calculus and its fate; • Monoid, Group, Groupoid, Category, Monomorphisms, Epimorphisms, Isomorphisms, show it on sets and monoids; Scala (Java) category • terminal object, initial object; products, unions; show code samples; equalizers, code samples; notation {x|f(x)==g(x)}; pullbacks, sql • functors examples (diagrams; product; exponentiations); currying/yoneda lemma; example with integers/rationals; monad?
  • 3. What you have to know • first-order logic; quantifiers (see COEN260 slides) • some set theory; binary relationships, currying; injection/surjection/bijection (see COEN260 slides) • some intro to intuitionistic logic (see COEN260 slides) • javascript or java or scala
  • 4. Formal Methods • Need them in: o medical devices o space o military o communications • Don’t need them in: o social networks o ads and sales o startups
  • 5. Example of Algorithm Proof Euclidean Algorithm: Find GCD(a,b), where a and b are two natural numbers. 1. If a < b, use the fact that GCD(a,b)=GCD(b,a) 2. GCD(a,0) = a; done. 3. GCD(a,b) = GCD(a-b,a) 4. Repeat until done. Proof: A. Prove that GCD(a,b)=GCD(b,a) B. Prove that GCD(a,0) = a C. Prove that GCD(a,b) = GCD(a-b,a) D. Prove that it takes not more than 2*max(a,b) steps.
  • 6. You are asked to double a cube Have a cube, V=x3 Build a cube of size 2*V, using a divider and a ruler Informally: approximate; we only have doubles in Java. Formally: have to calculate √3(2) The thing is: You Can’t
  • 7. A similar problem Need an algorithm to find roots of a 5th degree polynomial Explanation: 5 roots, S5 is the group of all permutations, and it cannot be represented via a chain of +/- symmetries. x5-x+1 = 0
  • 8. Gödel’s First Theorem Meaning, if we have a theory T, we can always come up with a statement in T that cannot be proved. How? • enumerate all sentences; then all proofs. • isProvable(n) ≡ ∃F (n=#(F) ∧ F is provable) • (diagonal lemma) ∀F ∃p (p ↔ F(#(p)) • how about p ↔ ¬isProvable(#(p)) A theory that contains arithmetics cannot be at the same time consistent and complete.
  • 9. Entscheidungsproblem Is there an algorithm that, given a first-order theory, takes a statement and checks whether the statement is true? (The essence of the proof of program validity.) The answer is: NO Church proved that there is no computable function which decides for two given λ calculus expressions whether they are equivalent or not. Turing proved that it reduces to Halting Problem
  • 10. Halting Problem Given a program, can we decide if it ever ends? Answer: NO http://ro-che.info/ccc/03
  • 11. Collatz Conjecture function(n) { while (n > 1) { println(n); n = n%2==0 ? n/2 : (3*n+1) } } E.g. 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 Will it ever stop? Nobody Knows.
  • 12. So, what can we do? • limit ourselves by only provable algorithms • count on the finiteness of the universe (is it finite?) • count on the finiteness of time (is it finite?) • write some unittests and pray (is it a formal method?!)
  • 13. Unittests • You cannot prove the program is right, but you can find errors • Can cover main and corner cases • Can check behavior independently from environment • Can feel safe doing refactorings Some people tried to formalize unittest creation (agitar.com) (see e.g. halting problem) Question: can you write a unittest for random numbers generator?