• Aucun résultat trouvé

Proof assistants TD 4- Monads and Modules

N/A
N/A
Protected

Academic year: 2022

Partager "Proof assistants TD 4- Monads and Modules"

Copied!
1
0
0

Texte intégral

(1)

Proof assistants

TD 4- Monads and Modules

1 Monades

1.1 Exceptions

Consider the type of binary trees with leaves labelled by natural numbers:

Inductive tree : Type :=

Leaf : nat -> tree | Node : tree -> tree -> tree.

1- Write a function expecting a tree as argument and returning eitherSome n wheren is the product of all leaves if its greater than 0, or Noneif one of the leaves is null.

2- Define the exception monad. Beside the usual monad operations, it should have 2 opera- tions: raise to raise an exception, andtry to catch it. Hint: use theoption type.

3- Rewrite the fonction computing the product of leaves, this time using the exception mechanism to return0 as soon as a leaf is null.

1.2 Non determinism

Write the non-determinism monad, that lets you execute non deterministically a task among a finite number of possible tasks. Beside the usual monad operations, it should have one operation par of type M(A) → M(A) → M(A) such that par e1 e2 executes non deter- ministically either e1 or e2.

2 Modules

1- Write a module signature representing a carrier type and a preorder on that type.

2- Write a module signature representing a functor expecting as argument a carrier type and a boolean-valued order, and producing a finite set structure implementing the following operations: membership, empty set, adding an element, removing an element, together with the basic properties of these operations.

3- Implement this functor signature using lists to represent finite sets.

1

Références

Documents relatifs

The documents may come from teaching and research institutions in France or abroad, or from public or private research centers.. L’archive ouverte pluridisciplinaire HAL, est

problem in the framework of Aubin viability theory as expounded in [11], enabling us to determine immunotherapy feedback protocol (control) laws by using the technical aid of

Next, by using a property that holds the contingent derivative in checking local uniqueness, we prove a new result, characterizing local observability in terms of sequences..

1 The problem of identifying logics is not only of interest for proof theory, but for the whole area of logic, including mathematical logic as well as philosophical logic.. This

One usually views the edges of a graph as vertex doubletons; 4 but various ways of representing graphs can be devised (as quickly surveyed in [5, Sec. Thanks to a convenient choice

We show the relation between fault length and the first eigenvalue that governs the duration of initiation duration. The value of the weakening rate can be evaluated from the

— For the purposes of this section, say that an artinian functor has a type one filtration if it has a finite filtration of which the filtration quotients are non-finite simple

In addition, one has also to take into account the internal support governments need (or which might force them to act) in order to purse a consistent prevention strategy, in