Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
YouTube Security VideosNeil Patel: How to Start an AI Marketing Agency (Step-by-Step)(30.09.2026 um 14:00 Uhr)
•
YouTube Security VideosNeil Patel: Stop Being the Brand Police #shorts(30.09.2026 um 14:03 Uhr)
•
Windows Tipps & SecurityMicrosoft adds native Linux container support directly to Windows 11(30.09.2026 um 13:45 Uhr)
••
Windows Tipps & SecurityThe next version of Windows drops support the Snapdragon 850(30.09.2026 um 14:06 Uhr)
••••••
YouTube Security VideosNeil Patel: How to Start an AI Marketing Agency (Step-by-Step)(30.09.2026 um 14:00 Uhr)
•
YouTube Security VideosNeil Patel: Stop Being the Brand Police #shorts(30.09.2026 um 14:03 Uhr)
•
Windows Tipps & SecurityMicrosoft adds native Linux container support directly to Windows 11(30.09.2026 um 13:45 Uhr)
••
Windows Tipps & SecurityThe next version of Windows drops support the Snapdragon 850(30.09.2026 um 14:06 Uhr)
••••••
Intelligence View
⚡ tsecurity.de Intelligence

HPR3057: Formal verification with Coq

Coq is interactive theorem prover, which comes with its own programming language Gallina. If we wanted to write function that calculates resulting blood type based on two gene alleles, we could do it as following. Start by defining types…

0
↗ Quelle (hackerpublicradio.org)
Reagiere als Erste:r — dein Feedback zählt!

Coq is interactive theorem prover, which comes with its own programming language Gallina.


If we wanted to write function that calculates resulting blood type based on two gene alleles, we could do it as following.


Start by defining types that represents alleles and resulting blood type:


Inductive BloodTypeAllele : Type :=
| BloodTypeA
| BloodTypeB
| BloodTypeO.

Inductive BloodType : Type :=
| TypeA
| TypeB
| TypeAB
| TypeO.

Mapping between them is defined as follows:


Definition bloodType (a b : BloodTypeAllele) : BloodType :=
match a, b with
| BloodTypeA, BloodTypeA => TypeA
| BloodTypeA, BloodTypeO => TypeA
| BloodTypeA, BloodTypeB => TypeAB
| BloodTypeB, BloodTypeB => TypeB
| BloodTypeB, BloodTypeA => TypeAB
| BloodTypeB, BloodTypeO => TypeB
| BloodTypeO, BloodTypeA => TypeA
| BloodTypeO, BloodTypeB => TypeB
| BloodTypeO, BloodTypeO => TypeO
end.

Notice that the only way of getting TypeO blood is for both alleles to be BloodTypeO.


We can state theorems about the code:


Theorem double_O_results_O_type :
bloodType BloodTypeO BloodTypeO = TypeO.
Proof.
reflexivity.
Qed.

double_O_results_O_type states that bloodType BloodTypeO BloodTypeO will have value of TypeO. There’s also attached proof for this theorem.


Second theorem is longer:


Theorem not_double_O_does_not_result_O_type :
forall (b1 b2 : BloodTypeAllele),
b1 <> BloodTypeO \/ b2 <> BloodTypeO ->
bloodType b1 b2 <> TypeO.
Proof.
intros.
destruct b1.
- destruct b2.
+ discriminate.
+ discriminate.
+ discriminate.
- destruct b2.
+ discriminate.
+ discriminate.
+ discriminate.
- destruct b2.
+ discriminate.
+ discriminate.
+ destruct H.
* simpl. contradiction.
* simpl. contradiction.
Qed.

It states that if bloodType is applied with anything else than two BloodTypeO, the result will not be TypeO. Proof for this is longer. It goes through each and every combination of parameters and proves that the result isn’t TypeO. Mathematician could write this as: ∀ b1 b2, b1 ≠ BloodTypeO ∨ b2 ≠ BloodTypeO → bloodType b1 b2 ≠ TypeO.


If code above is in module called Genes, we can add following at the end to instruct compiler to emit Haskell code:


Extraction Language Haskell.
Extraction Genes.

Resulting code is as follows:


data BloodTypeAllele =
BloodTypeA
| BloodTypeB
| BloodTypeO

data BloodType =
TypeA
| TypeB
| TypeAB
| TypeO

bloodType :: BloodTypeAllele -> BloodTypeAllele -> BloodType
bloodType a b =
case a of {
BloodTypeA -> case b of {
BloodTypeB -> TypeAB;
_ -> TypeA};
BloodTypeB -> case b of {
BloodTypeA -> TypeAB;
_ -> TypeB};
BloodTypeO ->
case b of {
BloodTypeA -> TypeA;
BloodTypeB -> TypeB;
BloodTypeO -> TypeO}}

Now we have Haskell code that started in Coq, has two properties formally verified and is ready to be integrated with rest of the system.


Further reading:


Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten HPR3057: Formal verification with Coq

Thematisch verwandte Begriffe: HPR3057, Formal, verification, with · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-97150 | When converting baserCMS4-style addons to baserCMS5-style ones, BcAddon…
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag