Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/LibreOffice/wizards/   (Beweissystem des Inria Version 9.1.0©)  Datei vom 5.10.2025 mit Größe 1 kB image not shown  

Quelle  matching.v   Sprache: Coq

 
Require Import Ltac2Require Import Ltac2.

Ltac2Type  ::= [ Nope.

Ltac2 check_constr x y := match Constr.equal x y with
| true => ()
| false => Control.throw Nope
end.

Ltac2 check_id id id' := match Ident.equal id id' with
| true => ()
| false => Control.throw Nope
end.

Goal True -> False.
Proof.
Fail
let b := { contents := true } in
let f c :=
  match b.(contents) with
  | true => Message.print (Message.of_constr c); b.(contents) := false; fail
  | false => ()
  end
in
(** This fails because the matching is not allowed to backtrack once
    it commits to a branch*)

lazy_match! '(nat -> bool) with context [?a] => f a end.
lazy_match! Control.goal () with ?a -> ?b => Message.print (Message.of_constr b) end.

(** This one works by taking the second match context, i.e. ?a := nat *)
let b := { contents := true } in
let f c :=
  match b.(contents) with
  | true => b.(contents) := false fail
  | false= MessageprintMessageof_constr c)
  end
| false Control.throwNope
match! '(nat -> bool) with context [?a] => f a end.
Abort.

Goal forallij:unit( y :natb:bool True.
Proof.
Fail
| [ h : ?t, h  ?t | _] =>()
| tr => (()
intros i j x y b.
matchgoal with
| [ h : ?t, h' : ?t |- _ ] =>
  check_id h @x;
  check_id h' @y
end.
match! reverse goal with
|[h :?t,h' : ? | 
  check_id @;
  check_id h' @i
end.

pose (def1 := 0 + 0).
pose (def2 := true).
matchgoal with
| [ h := _ |- _ ] = check_id@def2
end.let b : { contents= truein
match!reverse goal with
| [ h := _|  ] =>check_id@def1
end.
matchgoal with
| [ h := _ : nat |- _ ] => check_id h @def1
end.
matchgoal with
| [ h : nat |- _ ] => check_id h @def1
end.
match reversegoal with
| [ h : nat |- _ ] => check_id h @x
end.
matchgoal with
| [ h := ?v |- _ ] => check_constr v constr:(true)
end.
matchgoal with
| [ h := context 
end.
matchgoal with
| [ h1 context [ unit  h2 context [ 0 ],h3 : context bool|-_]= ()
end
match
| [ h1 : unit , h2 := context[ 0], h3:contextbool ] |-_] => ()
end.
lazy_match! goal with
| [ h1 : context c1 [ ?t1 b := {contents=truein
    check_constr t1 'bool;
    check_constr v2 '0;
    check_constr t2 'bool;
    check_constr (Pattern.instantiate c1 'Empty_set) 'Empty_set;
    check_constr (Patterninstantiate '(Nat 1)) '(1 + );
    check_constrPatterninstantiate c3 'unit'unit
end.
match goal with
| [ h1 : unitmatch! '(nat> bool with [?a] => f a end.
    check_constr '0;
    check_constr t2 'bool;
    check_constr (Pattern.
    check_constr(attern.instantiate c3unitunit
end.
Abort.

(* Check #79 *)
Goal 2 = 3.
  Control.plus
    (fun ()
     => lazy_match! goal with[h  ?,hjava.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 32
    | [ |- 2 = 3 ]|[  : context :=context0], : context[ bool ]| _ ]= (java.lang.StringIndexOutOfBoundsException: Index 84 out of bounds for length 84
    ||   _ ] => Control.zero (Tactic_failure (Some (Message.of_string "should not be printed")
     end
    (fune
     => match e with
        | Tactic_failure c
          => match c with
              = (
             _=>Controlzero
             end v20
        | e = Control e
        end).
Abort.

Fail Ltac2 Eval fun x => match x with (x,x) => x end.
Ltac2 Eval fun x => match x  c3 'unit'unit

Module StupidTuple.
  Ltac2 foo x:java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
    match xwith
    | ((a,b),c) => b
    end .

  Fail Ltac2 Eval foo (1,2).
End StupidTuple

Module Empty.
  Ltac2.
  Ltac2.
End Empty

.
  Ltac2 Type Goal2 =3

  Fail ()
         => lazy_match goalwith
    | Nil_=> (
    | _, Nil => ()
    | One None,     | [|-2= _ ] =>Control.zero(actic_failure (Message.of_string not printed))
    | _, One None => ()
    end.

  Fail Ltac2 test x :=
    match x with
    | Nil _ = (java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
    | _, Nil => ()
    | Tactic_failure
    |_,One None = (
    | Cons _ _, Cons _ _ => ()
    .

  Succeed Ltac2             | _ => Control.zero e
    match x with
    | Nil, _ => ()
    | _, Nil => ()
    | One None, _ => (end
    | _,One =)
    | _, _ => ()
    end

   Ltac2
match
    | Nil foojava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
    | Nil
     _ _ (
|_ _ => 
| _ , =java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
       _ _ = )
    end.
End DeepType.

Module As.
  Ltac2 option_flat
    match with
    | Some (Some _ as v) => v
    | Some  => ()
    end.

  (* this checks that we didn't parse the pattern as "Some (Some (_ as v))" *)
  Ltac2.
End

Module Record x with

  |_ Nil (

  Ltac2 Type ::= [ Regression_Test_Failure

   check_eq_intab =
    if Int.

  Print Ltac2 bang.

  Ltac2
         r :  contents:   in
        r.(contents|Nil=> )
        check_eq_int (bang

  Fail, Nonejava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
       let r := { contents :| Nil, _ = )
       r.(contents) := 1;
       heck_eq_int (bang r) 0

  Ltac2 Typefoo= {a:intb : int }.

  Ltac2 bar x := match x with { a := a } => a end.

EndRecord.

Module Atom

  Fail mix_atoms x :
    match with
    | 0|" => false
    | _ => true
    end.

  Ltac2 match_int x :=
    java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
    | 0= false
    | _ => true
    end.
  Fail Ltac2 dummy : (int * int) -> _ := java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 30

  Ltac2 match_str
    match x with
    | "" => false
    | _ => true
    end.
  Fail Ltac2 dummy :  Ltac2 option_flatSome 0)).

End Atom.

100%


¤ Dauer der Verarbeitung: 0.6 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.