• Aucun résultat trouvé

Preuves Interactives et Applications

N/A
N/A
Protected

Academic year: 2022

Partager "Preuves Interactives et Applications"

Copied!
30
0
0

Texte intégral

(1)

10/12/16 B. Wolff - M2 - PIA 1

Preuves Interactives et Applications

HOL and its Specification Constructs

Université Paris-Saclay

Christine Paulin & Burkhart Wolff

http://www.lri.fr/ ̃paulin/PreuvesInteractives

(2)

Revisions

(3)

10/12/16 B. Wolff - M2 - PIA 3

Revision: Documents and Commands

!

Isabelle has (similar to Eclipse) a

„document-centric“ view of development:

there is a notion on an entire “project”

which is processed globally.

!

Documents (~ projects in Eclipse) consists of files (with potentially different file-type);

.thy files consists of headers commands.

(4)

What is Isabelle as a System ?

!

Global View of a “session“

cmd cmd cmd cmd cmd

cmd cmd cmd cmd cmd

cmd cmd

Document /

“Theory”

A

B

C

D

(5)

What is Isabelle as a System ?

!

Global View

token token token cmd

cmd cmd cmd cmd

cmd cmd cmd cmd cmd

cmd cmd

Document /

“Theory”

cmd

A

B

C

D

atom detailed view:

(6)

Revision: Documents and Commands

!

Each position in document corresponds – to a “global context”

Θ

– to a “local context”

Θ, Γ

!

There are specific „Inspection Commands“

that give access to information in the contexts

– thm, term, typ, value, prop : global context

– print_cases, facts, ... , thm : local context

(7)

What is Isabelle as a System ?

! Document “positions” were evaluated to an implicit state, the theory context T

Θ3 Θ0

Θ3 - 2 Θ3 - 1

“semantic”

evaluation as SML function

cmd cmd cmd cmd cmd

cmd cmd cmd cmd cmd

cmd cmd

Document /

“Theory”

cmd

A

B

C

D

(8)

Inspection Commands

!

Type-checking terms:

example: term “(a::nat) + b = b + a"

!

Evaluating terms:

example: term “(3::nat) + 4 = 7"

term “<hol-term>”

value “<hol-term>”

(9)

Simple Proof Commands

! Simple (Backward) Proofs:

There are different formats of proofs, we concentrate on the simplest one:

apply(<method1>) ... apply(<methodn>) done lemma <thmname> :

[<contextelem>+ shows] “<phi>”

<proof>

(10)

Exercise demo3.thy

!

Examples

lemma X1 : “A

B

C

(A B) C”

∧ ∧

(* output: A; B; C

⟦ ⟧ ⟹

(A B) C

∧ ∧

) *) lemma X2 : assume “A” and “B” and “C”

shows “(A B) C”

∧ ∧

lemma X2 : assume h1: “A” and h2: “B” and h3: “C”

shows “(A B) C”

∧ ∧

(11)

10/12/16 B. Wolff - M2 - PIA 11

How to built theories

in a logically safe manner ?

• Beyond the question:

Is the Kernel of Isabelle correct ? there is the question:

Is the HOL Library consistent ?

What guarantees can we have for

systems with 15000 rules ???

(12)

Isabelle Specification Constructs

!

Constant Definitions:

example: definition C::"bool bool"

where "C x

=

x"

!

Type Definitions:

example: typedef even = "{x::int. x mod 2 = 0}“

definition f::“<τ>”

where <name> : “f x1 … xn = <t>”

typedef ('α1..'αn) κ =

“<set-expr>” <proof>

(13)

10/12/16 B. Wolff - M2 - PIA 13

Isabelle Specification Constructs and

Theory Construction by

Conservative Extension

(14)

Semantics of „Constant Definition“

!

Constant definition:

(S, A) ” ∈ ”

T

(S ⊕ f

::

τ ! A ⊕ {

f_def

f x1 … xn = <expr>”

}) ”∈”

T'

• where f is “fresh” in T

• λ

x1 … xn = <expr>

is closed [and type-closed]

• f does not occur in

<expr>

definition f::“<τ>”

where <name> : “f x1 … xn = <expr>”

(15)

10/12/16 B. Wolff - M2 - PIA 15

Semantics of a „Type Definition“

!

Idea: Similar to constant definitions; we define

the new entity (“a type”) by an old one.

!

For Type Definitions, we define the new type to be isomorphic to a (non-empty) subset of an old one.

!

The Isomorphism is stated by three

(conservative) axioms.

(16)

Semantics of a „Type Definition“

!

Idea: Similar to constant definitions; we define

the new entity (“a type”) by an old one.

('α1..'αn)

τ

(('α1..'αn)

τ

) set

('α1..'αn) κ

Abs_κ Rep_κ

(17)

10/12/16 B. Wolff - M2 - PIA 17

Isabelle Specification Constructs

! Type definition:

(S, A) ”∈” T

(S('α1..'αn) κAbs_κ::('α1..'αn)τ ('α1..'αn Rep_κ::('α1..'αn)κ ('α1..'αn)τ

A {Rep_κ_inverse Abs_κ (Rep_κ x) = x }

{Rep_κ_inject (Rep_κ x = Rep_κ y) = (x = y) } {Rep_κ Rep_κ x {x. expr x}) ”∈” T'

where the type-constructor κ is “fresh” in T

expr is closed

<expr:: ('α1..'αn)τ set> is non-empty (to be proven by a witness) typedef ('α1..'αn) κ =

“<expr:: (('α1..'αn)

τ

) set>” <proof>

(18)

Isabelle Specification Constructs

!

Major example:

The introduction of the cartesian product:

subsubsection {* Type definition *}

definition Pair_Rep :: "'a 'b 'a 'b bool"

where "Pair_Rep a b = (λx y. x = a y = b)"∧

definition "prod = {f.

a b. f = Pair_Rep (a 'a) (b 'b)}"∷ ∷

typedef ('a, 'b) prod (infixr "*" 20) = "prod :: ('a 'b bool) set"

unfolding prod_def by auto

(19)

10/12/16 B. Wolff - M2 - PIA 19

Specification Mechanism Commands

! Datatype Definitions (similar SML):

(Machinery behind : complex series of const and typedefs !)

! Recursive Function Definitions:

(Machinery behind: Veeery complex series of const and typedefs and automated proofs!)

datatype ('a1..'an) T =

<c> :: “<τ>” | … | <c> :: “<τ>”

fun <c> ::“<

τ

>” where

“<c> <pattern> = <t>”

| ...

| “<c> <pattern> = <t>”

(20)

10/12/16 B. Wolff - M2 - PIA 20

Specification Mechanism Commands

!

Datatype Definitions (similar SML):

(Machinery behind : complex !)

!

Recursive Function Definitions:

(Machinery behind: Veeery complex!)

datatype ('a1..'an) T =

<c> :: “<τ>” | … | <c> :: “<τ>”

fun <c> ::“<

τ

>” where

“<c> <pattern> = <t>”

| ...

| “<c> <pattern> = <t>”

NO TE : I sab ell e H OL co mp ile s t his int ern all y t o a xio ma tic de fin itio ns,

i.e. a “m od el” in HO L!! !

(21)

10/12/16 B. Wolff - M2 - PIA 21

Specification Mechanism Commands

!

Datatype Definitions (similar SML):

Examples:

datatype mynat = ZERO | SUC mynat datatype 'a list = MT | CONS "'a" "'a list"

(22)

Specification Mechanism Commands

!

Inductively Defined Sets:

example: inductive path for rel ::"'a 'a bool"

where base : “path rel x x”

| step : “rel x y ⟹ path rel y z ⟹ path rel x z”

inductive <c> [ for <v>:: “<τ>” ] where <thmname> : “<φ>”

| ...

| <thmname> = <φ>

(23)

10/12/16 B. Wolff - M2 - PIA 23

Specification Mechanism Commands

!

Inductively Defined Sets:

example: inductive path for rel ::"'a 'a bool"

where base : “path rel x x”

| step : “rel x y ⟹ path rel y z ⟹ path rel x z”

inductive <c> [ for <v>:: “<τ>” ] where <thmname> : “<φ>”

| ...

| <thmname> = <φ>

NO TE : I sab ell e H OL co mp ile s t his int ern all y t o a xio ma tic de fin itio ns,

i.e. a “m od el” in HO L!! !

(24)

Specification Mechanism Commands

! Extended Notation for Cartesian Products: records (as in SML or OCaml; gives a slightly OO-flavor)

! ... introduces also semantics and syntax for

selectors : tag1 x

constructors : tag1 = x1, ... , tagn = xn update-functions : x tag1 := xn

record <c> = [<record> + ] tag1 :: “<τ1>”

...

tagn :: “<τn>”

(25)

10/12/16 B. Wolff - M2 - PIA 25

More on Proof Methods

(26)

10/12/16 B. Wolff - M2 - PIA 26

More on Proof-Methods

!

Some composed methods

(internally based on assumption, erule_tac and rule_tac + tactic code that constructs the

substitutions)

– subst <equation>

(one step left-to-right rewrite, choose any redex) – subst <equation>[symmetric]

(one step right-to-left rewrite, choose any redex) – subst (<n>) <equation>

(one step left-to-right rewrite, choose n-th redex)

(27)

10/12/16 B. Wolff - M2 - PIA 27

More on Proof-Methods

!

Some composed methods

(internally based on assumption, erule_tac and rule_tac + tactic code that constructs the

substitutions)

– simp

(arbitrary number of left-to-right rewrites, assumption or rule refl attepted at the end; a global simpset

in the background is used.)

– simp add: <equation> ... <equation>

(28)

10/12/16 B. Wolff - M2 - PIA 28

More on Proof-Methods

!

Some composed methods

(internally based on assumption, erule_tac and rule_tac + tactic code that constructs the

substitutions)

– auto

(apply in exaustive, non-deterministic manner:

all introduction rules, elimination rules and – auto intro: <rule> ... <rule>

elim: <erule> ... <erule>

simp: <equation> ... <equation>

(29)

10/12/16 B. Wolff - M2 - PIA 29

More on Proof-Methods

! Some composed methods

(internally based on assumption, erule_tac and rule_tac + tactic code that constructs the

substitutions)

cases „<formula>“

(split top goal into 2 cases:

<formula> is true or <formula> is false) cases „<variable>“

(- precondition : <variable> has type t which is a data-type) search for splitting rule and do case-split over this variable.

induct_tac „<variable>“

(- precondition : <variable> has type t which is a data-type) search for induction rule and do induction over this variable.

(30)

Screenshot with Examples

Références

Documents relatifs

Certaines procédures d'évaluation citées ci-dessus peuvent être également utilisées par des formateurs ou enseignants afin de mieux déterminer l'impact de l'utilisation d'un

Pour restaurer la classe, il faut utiliser un brosseur de fichier (icone double dossier avec la loupe dans cette version), pointer sur votre fi- chier, et appeler File in dans le

In this paper, we present an alternative formalization based on state- exception monads that allows for direct derivations of path conditions from program presentations in them;

L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des

On supposera donc que pour les applications qui nous int´eressent, le comportement d’une source peut ˆetre repr´esent´e par celui d’une source ponctuelle `a laquelle on ajoute

Par rapport au sch´ema pr´ec´edent, il y a un gain important dans la partie constante dans l’instanciation sous DLin (dans des groupes sym´etriques) grˆ ace ` a nos Smooth

La  première  partie  du  mémoire présente  un  état  de  l'art descendant de  la  Qualité  de Service  des  systèmes  actuels.  En  partant  du  haut  de 

Comme nous avons dit dans le Chapitre 1, l’adaptation dans notre contexte consiste à adapter l’exécution d’une application à base de situations par une analyse des choix