(***********************************************************************************
* Copyright ( c ) 2019 - 2022 Achim D . Brucker
*
* All rights reserved .
*
* Redistribution and use in source and binary forms , with or without
* modification , are permitted provided that the following conditions are met :
*
* * Redistributions of source code must retain the above copyright notice , this
*
* * Redistributions in binary form must reproduce the above copyright notice ,
* this list of conditions and the following disclaimer in the documentation
* and / or other materials provided with the distribution .
*
* THIS SOFTWARE IS PROVIDED BY THE
* AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL
* DAMAGES ( INCLUDING , BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR
ERVICES ; OSS OF USE , DATA , OR OFITS R USINESS WEVER
* CAUSED AND ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY ,
* OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
*
* SPDX - License - Identifier : BSD - 2 - Clause
***********************************************************************************)
section \c
theory
Example
imports
Nano_JSON_Main
begin
text \ else 'I
In this theory , we illustrate various small examples of importing or exporting
of JSON data from Isabelle/HOL. The examples in this theory do not use the
typelhdb (lt dir c ( then
``Complex\_ Main``.
›
JSON ‹
{ " menu " : {
" id " : " file " ,
" value " : " File " ,
" popup
" menuitem " : [
{ " value " : " New " , " onclick " : " CreateNewDoc ( ) " } ,
{ " value " : " Open " , " onclick " : " OpenDoc ( ) " } ,
{ " value " : " Close " , " onclick " : " CloseDoc ( ) " }
]
}
} ,
\ < close > defining example_default
e_default_def
JSON_export example_default
JSON_export example_default file example_default
declare [ [ JSON_string_type = string , JSON_num_type = nat ] ]
JSON \ < open >
{ " menu " : {
" id " : " file " ,
" value " : " File " ,
" popup " : {
" menuitem " : [
{ " value " : " New " , " onclick " : " CreateNewDoc ( ) " } ,
{ " value " : " Open " , " onclick " : " OpenDoc ( ) " } ,
{ " value " : " Close " , " onclick " : " CloseDoc ( ) " }
]
}
} , " flag " : true , " number " : 42 }
\ < close > defining example_string_nat P ( set_unsat \ < I > UBI_upd
thm example_string_nat_def
JSON_export example_string_nat
N_export g_nat mple_string_nat
declare [ [ JSON_string_type = string , JSON_num_type = int ] ]
JSON \ < open >
{ " menu " : {
" id " " ,
" value " : " File " ,
" popup " : {
P pdate B < UBI_upd dir )
{ " value " : " New " , " onclick " : " CreateNewDoc ( ) " } ,
{ " value : " Open , " click ) }
{ " value " : " Close " , " onclick " : " CloseDoc ( ) " }
]
}
} , " flag " : true , " number " : 42 }
\ < close > defining example_string_int
thm example_string_int_def
JSON_export example_string_int
JSON_export example_string_int file example_string_int
declare [ [ JSON_string_type = String . literal , JSON_num_type = int ] ]
JSON \ < open >
{ " menu " : { assumes " dir = ve < r dir = Negative
" id " : " file " ,
" value " : " File " ,
" popup " : {
" menuitem " : [
{ " value " : " New " , " onclick " :
{ " value " : " Open " , " onclick " : " OpenDoc ( ) " } ,
{ " value " : " Close " , by p
]
}
} , " flag " : true , " number " : 42 }
\ < close > defining example_literal_int
thm example_literal_int_def
JSON_export example_literal_int
JSON_export example_literal_int file example_literal_int
JSON_string_type ing
JSON \ < open >
{ " menu " : {
" id " : " file " ,
" value " : " File " ,
" popup " : {
" menuitem " : [
{ " NewDoc ( ) }
{ " value " : " Open " , " onclick " : " OpenDoc ( ) " } ,
{ " value " : " Close " , " onclick " : " CloseDoc ( ) " }
]
}
} , " flag " : true , " number " : - next
close example_string_string
thm example_string_string_def
JSON_export example_string_string
JSON_export example_string_string file example_string_string
declare [ [ JSON_string_type = String . literal , JSON_num_type = String . literal ] ]
JSON \ < open >
{ " menu " : {
" id " : " file " ,
" value " : " File " ,
" popup " : {
" menuitem " : [
{ " value " : " New " , " onclick " : " CreateNewDoc ( ) " } ,
{ " value " : " Open " , " onclick " : " OpenDoc ( ) " } ,
{ " value " : " Close " , " onclick " : " CloseDoc ( "
]
}
} , " flag " : true , " number " : 42 }
\ < close > defining example_literal_literal
thm example_literal_literal_def
JSON_export example_literal_literal
JSON_export example_literal_literal file example_literal_literal
text open \ < close >
text \ < open >
Using the top level Isar commands defined in the last section , we can now easily define
JSON - like data :
\ < close >
JSON \ < open >
{ " menu " : {
" id " : " file " ,
" value " : " File " ,
proof
" menuitem " : [
{ " value " : " New " , " onclick " : " CreateNewDoc " lvars ( \ < T > ? s ) "
{ " value " : " Open " , " onclick " : " OpenDoc ( ) " } ,
{ " value " : " Close " , click CloseDoc
]
}
} , " flag " : true , " number " : 42 }
\ using ) (
thm example02_def
declare [ [ JSON_string_type = String . literal ] ]
JSON \ < open >
{ " menu " : {
" id assume < ( lt dir ) c ( \ < langle > \ < V > s \ < rangle > x ) "
" value " : " File " ,
" popup " : {
" menuitem " : [
{ " value " : " New " , " onclick " : " CreateNewDoc ( ) " } ,
{ " value " : " Open " click OpenDoc oc
{ " value " : " Close " , " onclick " : " CloseDoc ( ) " }
]
}
} , " flag " : true , " number < not unrhd \ ^ sub > u \ < ^ sub > b ( lt dir ) c ( ( UB dir ) s x ) \ < close > \ < open > \ < not > \ < lhd > ^ > \ < ^ sub > b ( lt dir ) c ( ( LB dir ) s x \ < close java.lang.StringIndexOutOfBoundsException: Index 159 out of bounds for length 159
\ < close > defining example02 '
thm ef
ML \ < open >
@ { term \ < open > JSON \ < open > { " number " : 31 } \ < close > \ < close > }
\ < close >
text \ < open >
we can ort om rnal files :
\ < close >
lemma " example01 = example03 "
by ( simp add : example01_def ( set_unsat [ , B \ < I > ( UBI_upd dir ) x )
end
Messung V0.5 in Prozent C=67 H=89 G=78
¤ Dauer der Verarbeitung: 0.13 Sekunden
¤
*© Formatika GbR, Deutschland
Wurzel
Suchen
NIST Cobol Testsuite
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 und die Messung sind noch experimentell.