eq_nat is recursively defined to test equality of two natural numbers n and m by pattern matching on their constructions. It returns true if both are 0, or if their successors S n' and S m' are recursively equal; otherwise it returns false. Evaluating eq_nat 3 3 returns true since 3 is constructed by applying S twice to 0, and both arguments have the same construction.
The document discusses optimization techniques for deep learning frameworks on Intel CPUs and Fugaku aimed architectures. It introduces oneDNN, a performance library for deep learning operations on Intel CPUs. It discusses issues with C++ implementation, and how just-in-time assembly generation using Xbyak can address these issues by generating optimal code depending on parameters. It also introduces Xbyak_aarch64 for generating optimized code for Fugaku's Scalable Vector Extension instructions.
Coq is a proof assistant based on type theory that can be used to formally verify programs and proofs. It supports program extraction to OCaml and can be used to prove properties of programs written in languages like OCaml, Java, C, and Assembly. Coq has been used to verify high assurance systems like the seL4 microkernel and TLS and JavaCard implementations. Formal verification in Coq is based on the Curry-Howard correspondence where types correspond to propositions and programs correspond to proofs. Tactics and rewriting rules are used to interactively prove goals in Coq.
This document summarizes a discussion about formalizing Kleene algebra and Brzozowski's derivatives in the Coq proof assistant. It describes how regular expressions and their derivatives were defined inductively in Coq, and how properties like Kleene's star were proved using tactics like setoid rewriting. It also provides instructions for Coq users to contribute formalizations by packaging files into a tar archive and submitting it to the Coq user contributions website.
The document discusses optimization techniques for deep learning frameworks on Intel CPUs and Fugaku aimed architectures. It introduces oneDNN, a performance library for deep learning operations on Intel CPUs. It discusses issues with C++ implementation, and how just-in-time assembly generation using Xbyak can address these issues by generating optimal code depending on parameters. It also introduces Xbyak_aarch64 for generating optimized code for Fugaku's Scalable Vector Extension instructions.
Coq is a proof assistant based on type theory that can be used to formally verify programs and proofs. It supports program extraction to OCaml and can be used to prove properties of programs written in languages like OCaml, Java, C, and Assembly. Coq has been used to verify high assurance systems like the seL4 microkernel and TLS and JavaCard implementations. Formal verification in Coq is based on the Curry-Howard correspondence where types correspond to propositions and programs correspond to proofs. Tactics and rewriting rules are used to interactively prove goals in Coq.
This document summarizes a discussion about formalizing Kleene algebra and Brzozowski's derivatives in the Coq proof assistant. It describes how regular expressions and their derivatives were defined inductively in Coq, and how properties like Kleene's star were proved using tactics like setoid rewriting. It also provides instructions for Coq users to contribute formalizations by packaging files into a tar archive and submitting it to the Coq user contributions website.
This document discusses the Coq proof assistant. It provides examples of defining concepts like booleans, natural numbers, and functions in Coq. It demonstrates tactics for proving properties like De Morgan's laws. It also shows how to define recursive functions over natural numbers like addition and equality testing. The document aims to introduce basic concepts and usage of the Coq system through examples.
This document discusses type classes in Coq. It begins by introducing polymorphism and monads. It then defines the Monad type class in Coq, with return, bind, and other laws. Instances are given for the identity, maybe, list, and cont monads. The MonadPlus type class is also defined, with instances for maybe and list.
- The document discusses several papers and tools related to parsing and regular expressions, including Brzozowski's derivative approach to parsing context-free grammars and a Scala library that implements regular expression matching in under 100 lines of code.
- It also mentions "Yacc is Dead", a paper arguing that LR parsing techniques provide a better alternative to Yacc than general parser generators due to being smaller and easier to implement.
- Additionally, the document recommends resources for learning more about formal language theory, parsing, and regular expressions.
This document defines integers as pairs of natural numbers (Z') in Coq, proves it forms a setoid, and defines addition on Z' as a morphism. Properties of addition like commutativity and identities are proven. Tactics for rewriting and replacing in setoids like setoid_rewrite and setoid_replace are introduced.
Maude is a programming language based on rewriting logic that allows both declarative and concurrent programming. It has applications in formal specification, model checking, and programming domains like DSL development. The document provides examples of defining natural numbers and a cigarette smoking simulation in Maude. It also describes using Maude's model checking capabilities to analyze a river crossing puzzle.
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc
How does your privacy program stack up against your peers? What challenges are privacy teams tackling and prioritizing in 2024?
In the fifth annual Global Privacy Benchmarks Survey, we asked over 1,800 global privacy professionals and business executives to share their perspectives on the current state of privacy inside and outside of their organizations. This year’s report focused on emerging areas of importance for privacy and compliance professionals, including considerations and implications of Artificial Intelligence (AI) technologies, building brand trust, and different approaches for achieving higher privacy competence scores.
See how organizational priorities and strategic approaches to data security and privacy are evolving around the globe.
This webinar will review:
- The top 10 privacy insights from the fifth annual Global Privacy Benchmarks Survey
- The top challenges for privacy leaders, practitioners, and organizations in 2024
- Key themes to consider in developing and maintaining your privacy program
In the rapidly evolving landscape of technologies, XML continues to play a vital role in structuring, storing, and transporting data across diverse systems. The recent advancements in artificial intelligence (AI) present new methodologies for enhancing XML development workflows, introducing efficiency, automation, and intelligent capabilities. This presentation will outline the scope and perspective of utilizing AI in XML development. The potential benefits and the possible pitfalls will be highlighted, providing a balanced view of the subject.
We will explore the capabilities of AI in understanding XML markup languages and autonomously creating structured XML content. Additionally, we will examine the capacity of AI to enrich plain text with appropriate XML markup. Practical examples and methodological guidelines will be provided to elucidate how AI can be effectively prompted to interpret and generate accurate XML markup.
Further emphasis will be placed on the role of AI in developing XSLT, or schemas such as XSD and Schematron. We will address the techniques and strategies adopted to create prompts for generating code, explaining code, or refactoring the code, and the results achieved.
The discussion will extend to how AI can be used to transform XML content. In particular, the focus will be on the use of AI XPath extension functions in XSLT, Schematron, Schematron Quick Fixes, or for XML content refactoring.
The presentation aims to deliver a comprehensive overview of AI usage in XML development, providing attendees with the necessary knowledge to make informed decisions. Whether you’re at the early stages of adopting AI or considering integrating it in advanced XML development, this presentation will cover all levels of expertise.
By highlighting the potential advantages and challenges of integrating AI with XML development tools and languages, the presentation seeks to inspire thoughtful conversation around the future of XML development. We’ll not only delve into the technical aspects of AI-powered XML development but also discuss practical implications and possible future directions.
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Speck&Tech
ABSTRACT: A prima vista, un mattoncino Lego e la backdoor XZ potrebbero avere in comune il fatto di essere entrambi blocchi di costruzione, o dipendenze di progetti creativi e software. La realtà è che un mattoncino Lego e il caso della backdoor XZ hanno molto di più di tutto ciò in comune.
Partecipate alla presentazione per immergervi in una storia di interoperabilità, standard e formati aperti, per poi discutere del ruolo importante che i contributori hanno in una comunità open source sostenibile.
BIO: Sostenitrice del software libero e dei formati standard e aperti. È stata un membro attivo dei progetti Fedora e openSUSE e ha co-fondato l'Associazione LibreItalia dove è stata coinvolta in diversi eventi, migrazioni e formazione relativi a LibreOffice. In precedenza ha lavorato a migrazioni e corsi di formazione su LibreOffice per diverse amministrazioni pubbliche e privati. Da gennaio 2020 lavora in SUSE come Software Release Engineer per Uyuni e SUSE Manager e quando non segue la sua passione per i computer e per Geeko coltiva la sua curiosità per l'astronomia (da cui deriva il suo nickname deneb_alpha).
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfMalak Abu Hammad
Discover how MongoDB Atlas and vector search technology can revolutionize your application's search capabilities. This comprehensive presentation covers:
* What is Vector Search?
* Importance and benefits of vector search
* Practical use cases across various industries
* Step-by-step implementation guide
* Live demos with code snippets
* Enhancing LLM capabilities with vector search
* Best practices and optimization strategies
Perfect for developers, AI enthusiasts, and tech leaders. Learn how to leverage MongoDB Atlas to deliver highly relevant, context-aware search results, transforming your data retrieval process. Stay ahead in tech innovation and maximize the potential of your applications.
#MongoDB #VectorSearch #AI #SemanticSearch #TechInnovation #DataScience #LLM #MachineLearning #SearchTechnology
Your One-Stop Shop for Python Success: Top 10 US Python Development Providersakankshawande
Simplify your search for a reliable Python development partner! This list presents the top 10 trusted US providers offering comprehensive Python development services, ensuring your project's success from conception to completion.
Best 20 SEO Techniques To Improve Website Visibility In SERPPixlogix Infotech
Boost your website's visibility with proven SEO techniques! Our latest blog dives into essential strategies to enhance your online presence, increase traffic, and rank higher on search engines. From keyword optimization to quality content creation, learn how to make your site stand out in the crowded digital landscape. Discover actionable tips and expert insights to elevate your SEO game.
Introduction of Cybersecurity with OSS at Code Europe 2024Hiroshi SHIBATA
I develop the Ruby programming language, RubyGems, and Bundler, which are package managers for Ruby. Today, I will introduce how to enhance the security of your application using open-source software (OSS) examples from Ruby and RubyGems.
The first topic is CVE (Common Vulnerabilities and Exposures). I have published CVEs many times. But what exactly is a CVE? I'll provide a basic understanding of CVEs and explain how to detect and handle vulnerabilities in OSS.
Next, let's discuss package managers. Package managers play a critical role in the OSS ecosystem. I'll explain how to manage library dependencies in your application.
I'll share insights into how the Ruby and RubyGems core team works to keep our ecosystem safe. By the end of this talk, you'll have a better understanding of how to safeguard your code.
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceIndexBug
Imagine a world where machines not only perform tasks but also learn, adapt, and make decisions. This is the promise of Artificial Intelligence (AI), a technology that's not just enhancing our lives but revolutionizing entire industries.
Building Production Ready Search Pipelines with Spark and MilvusZilliz
Spark is the widely used ETL tool for processing, indexing and ingesting data to serving stack for search. Milvus is the production-ready open-source vector database. In this talk we will show how to use Spark to process unstructured data to extract vector representations, and push the vectors to Milvus vector database for search serving.
GraphRAG for Life Science to increase LLM accuracyTomaz Bratanic
GraphRAG for life science domain, where you retriever information from biomedical knowledge graphs using LLMs to increase the accuracy and performance of generated answers
Main news related to the CCS TSI 2023 (2023/1695)Jakub Marek
An English 🇬🇧 translation of a presentation to the speech I gave about the main changes brought by CCS TSI 2023 at the biggest Czech conference on Communications and signalling systems on Railways, which was held in Clarion Hotel Olomouc from 7th to 9th November 2023 (konferenceszt.cz). Attended by around 500 participants and 200 on-line followers.
The original Czech 🇨🇿 version of the presentation can be found here: https://www.slideshare.net/slideshow/hlavni-novinky-souvisejici-s-ccs-tsi-2023-2023-1695/269688092 .
The videorecording (in Czech) from the presentation is available here: https://youtu.be/WzjJWm4IyPk?si=SImb06tuXGb30BEH .
Driving Business Innovation: Latest Generative AI Advancements & Success StorySafe Software
Are you ready to revolutionize how you handle data? Join us for a webinar where we’ll bring you up to speed with the latest advancements in Generative AI technology and discover how leveraging FME with tools from giants like Google Gemini, Amazon, and Microsoft OpenAI can supercharge your workflow efficiency.
During the hour, we’ll take you through:
Guest Speaker Segment with Hannah Barrington: Dive into the world of dynamic real estate marketing with Hannah, the Marketing Manager at Workspace Group. Hear firsthand how their team generates engaging descriptions for thousands of office units by integrating diverse data sources—from PDF floorplans to web pages—using FME transformers, like OpenAIVisionConnector and AnthropicVisionConnector. This use case will show you how GenAI can streamline content creation for marketing across the board.
Ollama Use Case: Learn how Scenario Specialist Dmitri Bagh has utilized Ollama within FME to input data, create custom models, and enhance security protocols. This segment will include demos to illustrate the full capabilities of FME in AI-driven processes.
Custom AI Models: Discover how to leverage FME to build personalized AI models using your data. Whether it’s populating a model with local data for added security or integrating public AI tools, find out how FME facilitates a versatile and secure approach to AI.
We’ll wrap up with a live Q&A session where you can engage with our experts on your specific use cases, and learn more about optimizing your data workflows with AI.
This webinar is ideal for professionals seeking to harness the power of AI within their data management systems while ensuring high levels of customization and security. Whether you're a novice or an expert, gain actionable insights and strategies to elevate your data processes. Join us to see how FME and AI can revolutionize how you work with data!
Monitoring and Managing Anomaly Detection on OpenShift.pdfTosin Akinosho
Monitoring and Managing Anomaly Detection on OpenShift
Overview
Dive into the world of anomaly detection on edge devices with our comprehensive hands-on tutorial. This SlideShare presentation will guide you through the entire process, from data collection and model training to edge deployment and real-time monitoring. Perfect for those looking to implement robust anomaly detection systems on resource-constrained IoT/edge devices.
Key Topics Covered
1. Introduction to Anomaly Detection
- Understand the fundamentals of anomaly detection and its importance in identifying unusual behavior or failures in systems.
2. Understanding Edge (IoT)
- Learn about edge computing and IoT, and how they enable real-time data processing and decision-making at the source.
3. What is ArgoCD?
- Discover ArgoCD, a declarative, GitOps continuous delivery tool for Kubernetes, and its role in deploying applications on edge devices.
4. Deployment Using ArgoCD for Edge Devices
- Step-by-step guide on deploying anomaly detection models on edge devices using ArgoCD.
5. Introduction to Apache Kafka and S3
- Explore Apache Kafka for real-time data streaming and Amazon S3 for scalable storage solutions.
6. Viewing Kafka Messages in the Data Lake
- Learn how to view and analyze Kafka messages stored in a data lake for better insights.
7. What is Prometheus?
- Get to know Prometheus, an open-source monitoring and alerting toolkit, and its application in monitoring edge devices.
8. Monitoring Application Metrics with Prometheus
- Detailed instructions on setting up Prometheus to monitor the performance and health of your anomaly detection system.
9. What is Camel K?
- Introduction to Camel K, a lightweight integration framework built on Apache Camel, designed for Kubernetes.
10. Configuring Camel K Integrations for Data Pipelines
- Learn how to configure Camel K for seamless data pipeline integrations in your anomaly detection workflow.
11. What is a Jupyter Notebook?
- Overview of Jupyter Notebooks, an open-source web application for creating and sharing documents with live code, equations, visualizations, and narrative text.
12. Jupyter Notebooks with Code Examples
- Hands-on examples and code snippets in Jupyter Notebooks to help you implement and test anomaly detection models.
Taking AI to the Next Level in Manufacturing.pdfssuserfac0301
Read Taking AI to the Next Level in Manufacturing to gain insights on AI adoption in the manufacturing industry, such as:
1. How quickly AI is being implemented in manufacturing.
2. Which barriers stand in the way of AI adoption.
3. How data quality and governance form the backbone of AI.
4. Organizational processes and structures that may inhibit effective AI adoption.
6. Ideas and approaches to help build your organization's AI strategy.
6. 2. Coq
Proof General : emacs
Proof General ~/.emacs
(load-file "***/ProofGeneral/generic/proof-site.el")
proof-site.el
Coq (*.v) Proof General
@tmiya : Coq , 6
7. 3. Coq
Coq < Definition x := 1. (* x *)
x is defined (* := *)
Coq < Check x. (* x *)
x
: nat (* nat = *)
Coq < Print x. (* x *)
x = 1
: nat
Coq < Definition x := 2. (* x *)
Error: x already exists (* --> *)
Reset x.
Module ( )
@tmiya : Coq , 7
8. 3. Coq
1 2
Coq < Definition f x y := x - y. (* f *)
f is defined
Coq < Check f.
f
: nat -> nat -> nat (* nat->(nat->nat) *)
Coq < Definition f’ := f 3. (* f’ y = f 3 y *)
f’ is defined
Coq < Check f’.
f’
: nat -> nat (* nat nat *)
Coq < Eval compute in (f’ 1). (* f’ 1 = f 3 1 = 2 *)
= 2
: nat
(
@tmiya : Coq , 8
9. 3. Coq
Coq < Check (fun x => 2 * x). (* *)
fun x : nat => 2 * x
: nat -> nat
Coq < Eval compute in ((fun x => 2 * x) 3).
= 6
: nat
Coq < Definition double := (fun x => 2 * x).
double is defined (* double *)
Coq .
@tmiya : Coq , 9
10. 3. Coq
Coq < Definition twice(f:nat->nat):nat->nat :=
Coq < fun x => f (f x).
twice is defined
Coq < Definition add5(x:nat) := x + 5.
add5 is defined
Coq < Definition twice_add5 := twice add5.
twice_add5 is defined
Coq < Eval compute in (twice_add5 2).
= 12
: nat
@tmiya : Coq , 10
11. 3.1.
int, float
Coq nat
( )
Weekday
Coq < Inductive Weekday : Set :=
Coq < Sun | Mon | Tue | Wed | Thr | Fri | Sat.
Coq < Check Sun.
Sun (* Sun *)
: Weekday (* Weekday *)
Coq < Check Weekday.
Weekday (* *)
: Set (* Set *)
Set
@tmiya : Coq , 11
12. 3.1.
(
)
Coq < Definition nextday d :=
Coq < match d with
Coq < | Sun => Mon
: (* *)
Coq < | Sat => Sun
Coq < end.
nextday is defined
Coq < Check nextday.
nextday (* *)
: Weekday -> Weekday
Coq < Eval compute in (nextday Mon).
(* *)
prevday
@tmiya : Coq , 12
13. 3.1.
Bool
Coq < Inductive Bool : Set :=
Coq < | tru : Bool
Coq < | fls : Bool.
Coq < Definition And(b1 b2:Bool):Bool :=
Coq < match b1,b2 with
Coq < | tru,tru => tru
Coq < | _,_ => fls
Coq < end.
Or, Not Eval
@tmiya : Coq , 13
15. 3.1.
De Morgan (1)
Coq < Theorem De_Morgan_1 : forall b1 b2,
Coq < Not (And b1 b2) = Or (Not b1) (Not b2).
1 subgoal
============================
forall b1 b2 : Bool,
Not (And b1 b2) = Or (Not b1) (Not b2)
De_Morgan_1 < intros.
1 subgoal (* b1 b2 *)
b1 : Bool
b2 : Bool
============================
Not (And b1 b2) = Or (Not b1) (Not b2)
@tmiya : Coq , 15
16. 3.1.
De Morgan (2)
De_Morgan_1 < destruct b1; destruct b2.
4 subgoals (* b1 b2 *)
============================
Not (And tru tru) = Or (Not tru) (Not tru)
subgoal 2 is:
Not (And tru fls) = Or (Not tru) (Not fls)
subgoal 3 is:
Not (And fls tru) = Or (Not fls) (Not tru)
subgoal 4 is:
Not (And fls fls) = Or (Not fls) (Not fls)
@tmiya : Coq , 16
17. 3.1.
De Morgan (3)
De_Morgan_1 < simpl.
4 subgoals (* *)
============================
fls = fls
(* *)
De_Morgan_1 < reflexivity.
3 subgoals (* = *)
============================
Not (And tru fls) = Or (Not tru) (Not fls)
subgoal 2 is:
Not (And fls tru) = Or (Not fls) (Not tru)
subgoal 3 is:
Not (And fls fls) = Or (Not fls) (Not fls)
@tmiya : Coq , 17
18. 3.1.
De Morgan (4)
De_Morgan_1 < simpl; reflexivity.
De_Morgan_1 < simpl; reflexivity.
De_Morgan_1 < simpl; reflexivity.
Proof completed.
De_Morgan_1 < Qed.
intros.
destruct b1; destruct b2.
simpl in |- *.
reflexivity.
simpl in |- *; reflexivity.
simpl in |- *; reflexivity.
simpl in |- *; reflexivity.
De_Morgan_1 is defined
Not (Or b1 b2) = And (Not b1) (Not b2)
@tmiya : Coq , 18
19. 3.1.
1. Yes, Maybe, No Bool3
2. Bool3 And3, Or3, Not3
3. ( ) De Morgan
@tmiya : Coq , 19
20. 3.2.
nat
nat ( )
Coq < Print nat.
Inductive nat : Set :=
O : nat
| S : nat -> nat
O( O) 0 S nat nat
Peano
Coq < Eval compute in (S (S (S O))).
= 3
: nat
S (S (S O)) Coq 3
@tmiya : Coq , 20
21. 3.2.
nat n
Coq < Fixpoint add(n m:nat):nat :=
Coq < match n with
Coq < | O => m
Coq < | S n’ => S (add n’ m)
Coq < end.
add is recursively defined (decreasing on 1st argument)
Fixpoint (
O) 0 S nat 1 nat
Peano
Coq < Eval compute in (add (S (S O)) (S O)).
= 3
: nat
(call-by-value)
@tmiya : Coq , 21
22. 3.2.
nat _,_
OK
Coq < Fixpoint eq_nat(n m:nat):bool :=
Coq < match n,m with
Coq < | O,O => true
Coq < | S n’, S m’ => eq_nat n’ m’
Coq < | _,_ => false
Coq < end.
Coq < Eval compute in (eq_nat 3 3).
le_nat le_nat n m n≤m
Coq
( )
@tmiya : Coq , 22
23. 3.2.
Coq ( )
n
({struct n} Coq )
Coq < Fixpoint add’(n m:nat){struct n} :=
Coq < match n with
Coq < | O => m
Coq < | S n’ => S (add’ n’ m)
Coq < end.
add’ is recursively defined (decreasing on 1st argument)
add’ 2 3 add’
add’ (S (S O)) 3
= S (add’ (S O) 3)
= S (S (add’ O 3)) = S (S 3) = 5.
@tmiya : Coq , 23
25. 3.2.
1. mul add
2. mul fact
3. sub n=0
sub 0 m = 0
4. div3 Eval
Fixpoint div3(n:nat) :=
match n with
| S (S (S n’)) => S (div3 n’)
| _ => O
end.
sub
div n m Coq
( )
@tmiya : Coq , 25
26. 3.3.
cond c vt vf c:bool true
vt false vf vt, vf Set A
Coq < Definition cond{A:Set}(c:bool)(vt vf:A) :=
Coq < match c with
Coq < | true => vt
Coq < | false => vf
Coq < end.
Coq < Eval compute in (cond true 2 3).
= 2 : nat
Coq < Eval compute in (cond false false true).
= true : bool
{A:Set} cond A
( )
Coq < Eval compute in (@cond nat false 2 3).
@tmiya : Coq , 26
27. 3.3.
option
( ) null
option (Haskell Maybe
) ( Coq
sumor )
Coq < Print option.
Inductive option (A : Type) : Type :=
Some : A -> option A
| None : option A
Definition option_map {A B:Type} (f:A->B)(o:option A) :=
match o with
| Some a => Some (f a)
| None => None
end.
Coq < Eval compute in (option_map (fun x => x + 1) (Some 1)).
@tmiya : Coq , 27
28. 3.3.
prod sum
prod A B A B
prod A B A * B ( x , y , .. , z )
(pair .. (pair x y) .. z)
Coq < Check (2,true,3).
(2, true, 3) : nat * bool * nat
prod fst, snd
sum A B A B
Coq < Definition test_sum (s:sum nat bool) :=
Coq < match s with
Coq < | inl n => n
Coq < | inr true => 1
Coq < | inr false => 0
Coq < end.
prod, sum Curry-Howard
@tmiya : Coq , 28
29. 3.3.
List
List List
:: cons
Type Set (Check Set.
)
Coq < Require Import List.
Coq < Print list.
Inductive list (A : Type) : Type :=
nil : list A
| cons : A -> list A -> list A
Coq < Check (1::2::nil).
1 :: 2 :: nil : list nat
@tmiya : Coq , 29
30. 3.3.
List
List List nil x::xs
Coq < Fixpoint append{A:Type}(xs ys:list A):=
Coq < match xs with
Coq < | nil => ys
Coq < | x::xs’ => x::(append xs’ ys)
Coq < end.
Coq < Eval compute in (append (1::2::nil) (3::4::nil)).
Coq < Fixpoint olast{A:Type}(xs:list A):option A :=
Coq < match xs with
Coq < | nil => None
Coq < | a::nil => Some a
Coq < | _::xs’ => olast xs’
Coq < end.
Coq < Eval compute in (olast (1::2::3::nil)).
@tmiya : Coq , 30
31. 3.3.
List
1. len{A:Type}(xs:list A):nat
Eval compute in (len (1::2::3::nil)).
2. list bool true true
all_true(xs:list bool):bool nil
true
3. x Some x
None ohead{A:Type}(xs:list A):option A
4. s, n s :: s+1 :: ... :: (s+n-1) :: nil
nat_list(s n:nat):list nat
5. reverse{A:Type}(xs:list A):list A
append
@tmiya : Coq , 31
32. 4.
Bool De Morgan
P Q ¬(P ∧ Q) ¬P ∨ ¬Q
F F T T
F T T T
T F T T
T T F F
Bool, nat Inductive
(nat O
S n )
Coq Prop
(
)
@tmiya : Coq , 32
33. 4.
P P ¬P
( )
ab a, b
√
√ √ 2
1. a = b = 2 a, b ab = 2
√ √2 √
2. ab √
a = √2 , b = 2
√
a, b
√ 2 √2 √ 2 2 √ 2
ab = ( 2 ) = 2 = 2 =2
√
√ 2
2 (P) (~P)
ab a, b
ab a, b
@tmiya : Coq , 33
34. 4.
( )
Modus Ponens
A A B
B (Γ = (
) )
Γ A Γ A → B (→ )
Γ B
( )→
Coq
B Hab : A → B apply Hab. tactic
A Ha : A
exact Ha.
@tmiya : Coq , 34
35. 4.
Coq tactic
tactic assumption.
exact H. trivial.
...
H : A
...
------------------------
A
exact .
A∈Γ
( )
Γ A
@tmiya : Coq , 35
36. 4.1. →
→
A → B (CUI A -> B )
A intro Ha. tactic
Ha : A B
Coq
...
Γ, A B
(→ )
Γ A→B
H1 → H2 → · · · → Hn → B intros H1 H2 ... Hn.
intro intro. intros.
Coq
→ Modus Ponens
tactic apply .
@tmiya : Coq , 36
37. 4.1. →
→ (1)
tactic
Set P Prop
P P P p : P
( Set, Prop
Type )
Section imp_sample.
Variables P Q R : Prop.
Theorem imp_sample : (P -> (Q -> R)) -> (P -> Q) -> P -> R.
1 subgoal
============================
(P -> Q -> R) -> (P -> Q) -> P -> R
=== tactic
→ intro(s)
@tmiya : Coq , 37
38. 4.1. →
→ (2)
→ intros tactic
intro(s)
imp_sample < intros pqr pq p.
1 subgoal
pqr : P -> Q -> R
pq : P -> Q
p : P
============================
R
R pqr
apply pqr.
@tmiya : Coq , 38
39. 4.1. →
→ (3)
R apply pqr. pqr
P -> Q -> P Q
imp_sample < apply pqr.
2 subgoals
pqr : P -> Q -> R
pq : P -> Q
p : P
============================
P
subgoal 2 is:
Q
P assumption.
@tmiya : Coq , 39
40. 4.1. →
→ (4)
P assumption. Q
imp_sample < assumption.
1 subgoal
pqr : P -> Q -> R
pq : P -> Q
p : P
============================
Q
Q
@tmiya : Coq , 40
41. 4.1. →
→ (5)
imp_sample < apply pq.
1 subgoal
pqr : P -> Q -> R
pq : P -> Q
p : P
============================
P
imp_sample < assumption.
Proof completed.
imp_sample < Qed.
Qed.
@tmiya : Coq , 41
42. 4.2. ∧
∧ (1)
P ∧Q P Q
pq : P / Q destruct pq as [p q].
tactic p : P q : Q
destruct pq. p,q Coq
P ∧Q P Q
P ∧Q split. tactic
P / Q P, Q
Coq < Variable P Q R:Prop.
Coq < Theorem and_assoc : (P/Q)/R -> P/(Q/R).
1 subgoal
============================
(P / Q) / R -> P / Q / R
@tmiya : Coq , 42
43. 4.2. ∧
∧ (2)
intro → ∧
and_assoc < intro pqr.
1 subgoal
pqr : (P / Q) / R
============================
P / Q / R
and_assoc < destruct pqr as [[p q] r].
1 subgoal
p : P
q : Q
r : R
============================
P / Q / R
@tmiya : Coq , 43
45. 4.3. ∨
∨ (1)
P ∨Q P Q
pq : P / Q
destruct pq as [pq].— tactic
p : P q : Q
destruct pq. p,q Coq
P ∨Q P Q
P ∨Q left. right. tactic
P Q
Coq < Variable P Q R:Prop.
Coq < Theorem or_assoc : (P/Q)/R -> P/(Q/R).
1 subgoal
============================
(P / Q) / R -> P / Q / R
@tmiya : Coq , 45
46. 4.3. ∨
∨ (2)
intro → ∨
and_assoc < intro pqr.
or_assoc < destruct pqr as [[p|q]|r].
3 subgoals
p : P
============================
P / Q / R
subgoal 2 is:
P / Q / R
subgoal 3 is:
P / Q / R
@tmiya : Coq , 46
47. 4.3. ∨
∨ (3)
assumption
or_assoc < left.
3 subgoals
p : P
============================
P
or_assoc < assumption.
2 subgoals
q : Q
============================
P / Q / R
or_assoc < right; left.
2 subgoals
q : Q
============================
Q
OK
@tmiya : Coq , 47
48. 4.4. ¬
¬ (1)
¬P P → False False
Inductive False : Prop :=
~P intro p. p : P
False
H : False elim H.
np : ~P elim np.
P
(¬¬P P ) (
)
@tmiya : Coq , 48
50. 4.4. ¬
¬ (3)
neg_sample < destruct H as [p np].
1 subgoal
p : P
np : ~ P
============================
False
neg_sample < elim np.
p : P
np : ~ P
============================
P
neg_sample < assumption.
Proof completed.
@tmiya : Coq , 50
51. 4.4. ¬
Variable A B C D:Prop.
Theorem ex4_1 : (A -> C) / (B -> D) / A / B -> C / D.
Theorem ex4_2 : ~~~A -> ~A.
Theorem ex4_3 : (A -> B) -> ~B -> ~A.
Theorem ex4_4 : ((((A -> B) -> A) -> A) -> B) -> B.
Theorem ex4_5 : ~~(A/~A).
@tmiya : Coq , 51
52. 5. Curry-Howard
Curry-Howard (1)
Theorem imp_sample’ : (P -> (Q -> R)) -> (P -> Q) -> P -> R.
imp_sample’ < intros pqr pq p.
imp_sample’ < Check pq.
pq
: P -> Q
imp_sample’ < Check (pq p).
pq p
: Q
pq P -> Q P
Q pq p
Q
@tmiya : Coq , 52
53. 5. Curry-Howard
Curry-Howard (2)
pqr, pq, p R
exact tactic
imp_sample’ < Check (pqr p (pq p)).
pqr p (pq p)
: R
imp_sample’ < exact (pqr p (pq p)).
Proof completed.
imp_sample Print
Coq < Print imp_sample.
imp_sample =
fun (pqr : P -> Q -> R) (pq : P -> Q) (p : P) => pqr p (pq p)
: (P -> Q -> R) -> (P -> Q) -> P -> R
@tmiya : Coq , 53
54. 5. Curry-Howard
Curry-Howard (3)
P P
P→Q P -> Q
Γ P ΓP→Q
(→ ) pq p
Γ Q
Γ, P Q
(→ ) pq (p:P):Q
Γ P→Q
P ∧Q prod { (P,Q)
inl P
P ∨Q sum
inr Q
Curry-Howard
Curry-Howard
=
Coq
@tmiya : Coq , 54
55. 5. Curry-Howard
Curry-Howard (4)
Coq ( )
Java
(P → Q → R) → (P → Q) → P → R
interface Fun<A,B> {
public B apply(A a);
}
public class P {}
public class Q {}
public class R {}
public class Proof {
public R imp_sample(Fun<P,Fun<Q,R>> pqr, Fun<P,Q> pq, P p) {
return pqr.apply(p).apply(pq.apply(p));
}
}
(Java prod sum
¬ Java
)
@tmiya : Coq , 55
56. 6.
a:A P a (∀a : A, P a) : forall (a:A), P a
a:A P a (∃a : A, P a) : exists (a:A), P a
Coq P a:A P a:Prop
A -> Prop
Coq
a:A P : A → Prop
Coq < Definition iszero(n:nat):Prop :=
Coq < match n with
Coq < | O => True
Coq < | _ => False
Coq < end.
iszero is defined
@tmiya : Coq , 56
57. 6.
∀ (1)
forall intro(s) forall x:X
x:X ->
Coq < Theorem sample_forall : forall (X:Type)(P Q:X->Prop)(x:X),
P x -> (forall y:X, Q y) -> (P x / Q x).
============================
forall (X : Type) (P Q : X -> Prop) (x : X),
P x -> (forall y : X, Q y) -> P x / Q x
sample_forall < intros X P Q x px Hqy.
X : Type
P : X -> Prop
Q : X -> Prop
x : X
px : P x
Hqy : forall y : X, Q y
============================
P x / Q x
@tmiya : Coq , 57
58. 6.
∀ (2)
forall y:X y X
sample_forall < split. (* P x Q x *)
sample_forall < assumption. (* P x px *)
1 subgoal
X : Type
P : X -> Prop
Q : X -> Prop
x : X
px : P x
Hqy : forall y : X, Q y
============================
Q x
sample_forall < apply (Hqy x). (* Hqy y x *)
Proof completed.
@tmiya : Coq , 58
59. 6.2. ∃
∃ (1)
Coq < Theorem sample_exists : forall (P Q:nat->Prop),
Coq < (forall n, P n) -> (exists n, Q n) ->
Coq < (exists n, P n / Q n).
sample_exists < intros P Q Hpn Hqn.
1 subgoal
P : nat -> Prop
Q : nat -> Prop
Hpn : forall n : nat, P n
Hqn : exists n : nat, Q n
============================
exists n : nat, P n / Q n
@tmiya : Coq , 59
60. 6.2. ∃
∃ (2)
exists destruct
sample_exists < intros P Q Hpn Hqn.
P : nat -> Prop
Q : nat -> Prop
Hpn : forall n : nat, P n
Hqn : exists n : nat, Q n
============================
exists n : nat, P n / Q n
sample_exists < destruct Hqn as [n’ qn’].
P : nat -> Prop
Q : nat -> Prop
Hpn : forall n : nat, P n
n’ : nat
qn’ : Q n’
============================
exists n : nat, P n / Q n
@tmiya : Coq , 60
61. 6.2. ∃
∃ (3)
exists x:X x:X
exists x.
sample_exists < destruct Hqn as [n’ qn’].
:
Hpn : forall n : nat, P n
n’ : nat
qn’ : Q n’
============================
exists n : nat, P n / Q n
sample_exists < exists n’.
:
Hpn : forall n : nat, P n
n’ : nat
qn’ : Q n’
============================
P n’ / Q n’ (* *)
@tmiya : Coq , 61
62. 6.2. ∃
Theorem ex5_1 : forall (A:Set)(P:A->Prop),
(~ exists a, P a) -> (forall a, ~P a).
Theorem ex5_2 : forall (A:Set)(P Q:A->Prop),
(exists a, P a / Q a) ->
(exists a, P a) / (exists a, Q a).
Theorem ex5_3 : forall (A:Set)(P Q:A->Prop),
(exists a, P a) / (exists a, Q a) ->
(exists a, P a / Q a).
Theorem ex5_4 : forall (A:Set)(R:A->A->Prop),
(exists x, forall y, R x y) -> (forall y, exists x, R x y).
Theorem ex5_5 : forall (A:Set)(R:A->A->Prop),
(forall x y, R x y -> R y x) ->
(forall x y z, R x y -> R y z -> R x z) ->
(forall x, exists y, R x y) -> (forall x, R x x).
@tmiya : Coq , 62
63. 6.3. =
= (1)
eq (= )
Inductive eq (A : Type) (x : A) : A -> Prop :=
refl_equal : x = x
Coq
(nat bool )
(nat O Sn )
(S m Sn m=n )
============================
n = n
apply (refl_equal n).
tactic reflexivity.
@tmiya : Coq , 63
64. 6.3. =
= (2)
plus Print plus.
tactic simpl.
Coq < Theorem plus_0_l : forall n, 0 + n = n.
plus_0_l < intro n.
n : nat
============================
0 + n = n
plus_0_l < simpl.
n : nat
============================
n = n
plus_0_l < reflexivity.
Proof completed.
@tmiya : Coq , 64
65. 6.4.
(1)
∀n : nat, n + 0 = n simpl.
============================
n + 0 = n
plus_0_r < simpl.
============================
n + 0 = n
plus n m n
n
1. n = 0 n+0=n
2. n = n n+0=n n=Sn
n+0=n
@tmiya : Coq , 65
66. 6.4.
(2)
n induction n as [|n’].
induction n. tactic Coq nat_ind
(P )
Coq < Check nat_ind.
nat_ind : forall P : nat -> Prop, P 0 ->
(forall n : nat, P n -> P (S n)) ->
forall n : nat, P n
nat_ind nat O : nat S : nat -> nat
Inductive
bool bool_ind
bool_ind : forall P : bool -> Prop,
P true -> P false ->
forall b : bool, P b
@tmiya : Coq , 66
67. 6.4.
(3)
induction n as [|n’]. n 0 S n’
reflexivity. OK (simpl.
)
Coq < Theorem plus_0_r : forall n:nat, n + 0 = n.
plus_0_r < induction n as [|n’].
2 subgoals
============================
0 + 0 = 0
subgoal 2 is:
S n’ + 0 = S n’
plus_0_r < reflexivity.
1 subgoal
n’ : nat
IHn’ : n’ + 0 = n’
============================
S n’ + 0 = S n’
@tmiya : Coq , 67
68. 6.4.
(4)
n = S n’ n = n’ IHn’
S n’ + 0 = S n’ simpl. plus
S (n’ + 0)= S n’ IHn’ n’ + 0 n’
rewrite IHn’. rewrite
============================
S n’ + 0 = S n’
plus_0_r < simpl.
IHn’ : n’ + 0 = n’
============================
S (n’ + 0) = S n’
plus_0_r < rewrite IHn’.
IHn’ : n’ + 0 = n’
============================
S n’ = S n’
@tmiya : Coq , 68
69. 6.4.
:m + n = n + m
SearchAbout
Coq < SearchAbout plus.
plus_n_O: forall n : nat, n = n + 0
plus_O_n: forall n : nat, 0 + n = n
plus_n_Sm: forall n m : nat, S (n + m) = n + S m
plus_Sn_m: forall n m : nat, S n + m = S (n + m)
mult_n_Sm: forall n m : nat, n * m + n = n * S m
rewrite (
rewrite <- plus_n_Sm n’ m. rewrite H. H
rewrite <- H. )
Theorem plus_comm : forall m n:nat, m + n = n + m.
@tmiya : Coq , 69
70. 6.4.
(5)
nat list A
Theorem length_app : forall (A:Type)(l1 l2:list A),
length (l1 ++ l2) = length l1 + length l2.
list cons
induction l1 as [|a l1’]. (
induction l1.)
induction
( l2) intro
1. intros A l1 l2. induction l1 as [|a l1’].
2. intros A l1. induction l1 as [|a l1’]. intro l2.
IHl1’
(Coqtop Undo.
)
@tmiya : Coq , 70
71. 6.4.
: (1)
List append reverse
Require Import List.
Fixpoint append{A:Type}(l1 l2:list A):=
match l1 with
| nil => l2
| a::l1’ => a::(append l1’ l2)
end.
Fixpoint reverse{A:Type}(l:list A):=
match l with
| nil => nil
| a::l’ => append (reverse l’) (a::nil)
end.
Theorem reverse_reverse : forall (A:Type)(l:list A),
reverse (reverse l) = l.
@tmiya : Coq , 71
73. 7.
(1)
Coq
nat minus(n m:nat) n≤m
0
n−m+m =n ( )
sub
Definition sub(m n:nat)(H:le n m) : {x:nat|x+n=m}.
1. H n≤m n≤m
2. x = m−n x +n = m
(
)
@tmiya : Coq , 73
74. 7.
(2)
Coq
nat Arith
Require Import Arith. (* Arith *)
Definition sub(m n:nat)(H:le n m) : {x:nat|x+n=m}.
1 subgoal
m : nat
n : nat
H : n <= m
============================
{x : nat | x + n = m}
m, n intro generalize dependent
sub < generalize dependent m.
sub < generalize dependent n.
============================
forall n m : nat, n <= m -> {x : nat | x + n = m}
@tmiya : Coq , 74
75. 7.
(3)
eapply, erewrite
apply, rewrite Qed. Defined.
induction n as [|n’].
(* n=0 *)
intros m H. exists m. eapply plus_0_r.
(* n=S n’ *)
induction m as [|m’]; intro H.
(* m=0 *)
assert(H’: ~(S n’ <= 0)). eapply le_Sn_0.
elim H’. assumption.
(* m=S m’ *)
assert(H’: n’ <= m’). eapply le_S_n. assumption.
assert(IH: {x:nat|x+n’=m’}). eapply IHn’. assumption.
destruct IH as [x IH]. exists x.
erewrite <- plus_n_Sm. rewrite IH. reflexivity.
Defined.
@tmiya : Coq , 75
76. 7.
(4)
sub Print sub.
sub OCaml
minus
Coq < Extraction sub.
(** val sub : nat -> nat -> nat **)
let rec sub m = function
| O -> m
| S n0 ->
(match m with
| O -> assert false (* absurd case *)
| S n1 -> let iH = sub n1 n0 in Obj.magic iH)
OCaml H
@tmiya : Coq , 76
77. 7.
(5)
H
Theorem le_2_5 : le 2 5.
Proof. repeat eapply le_n_S. repeat constructor. Qed.
Eval compute in (sub 5 2 le_2_5). (* *)
Eval compute in (proj1_sig (sub 5 2 le_2_5)).
(* = 3:nat *)
{x|x+n=m} x
proj1_sig
@tmiya : Coq , 77
78. 7.
minus
sub minus
Definition sub’(m n:nat)(H:le n m) : {x:nat|x+n=m}.
Proof.
(* minus *)
Defined.
Coq
1. minus minus
2. minus sub’
3. refine tactic
(refine )
4. sub
@tmiya : Coq , 78
80. 8.
Interactive Theorem Proving and Program Development. Coq’Art:
The Calculus of Inductive Constructions, Yves Berrot and Pierre
Casteran (Springer-Verlag) : Coq
Certified Programming with Dependent Types, Adam Chlipala
(http://adam.chlipala.net/cpdt/) : Coq
2010 III
(http://www.math.nagoya-u.ac.jp/~garrigue/lecture/
2010_AW/index.html) : Garrigue
PDF
Coq in a Hurry, Yves Bertot
(http://cel.archives-ouvertes.fr/docs/00/47/
58/07/PDF/coq-hurry.pdf) :
2nd Asian-Pacific Summer School on Formal Methods
(http://formes.asia/cms/coqschool/2010) :
@tmiya : Coq , 80
82. 8.
Formal Methods Forum
Coq ( )
( )
Google group
Coq
2010 Certified Programming with Dependent Types
Coq
Google group
(http://groups.google.co.jp/group/fm-forum)
Coq
@tmiya : Coq , 82