<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.event-b.org/index.php?action=history&amp;feed=atom&amp;title=Serializing_Mathematical_Formulas</id>
	<title>Serializing Mathematical Formulas - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.event-b.org/index.php?action=history&amp;feed=atom&amp;title=Serializing_Mathematical_Formulas"/>
	<link rel="alternate" type="text/html" href="https://wiki.event-b.org/index.php?title=Serializing_Mathematical_Formulas&amp;action=history"/>
	<updated>2026-05-04T21:09:40Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://wiki.event-b.org/index.php?title=Serializing_Mathematical_Formulas&amp;diff=9306&amp;oldid=prev</id>
		<title>imported&gt;Mathieu at 11:02, 10 November 2008</title>
		<link rel="alternate" type="text/html" href="https://wiki.event-b.org/index.php?title=Serializing_Mathematical_Formulas&amp;diff=9306&amp;oldid=prev"/>
		<updated>2008-11-10T11:02:07Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 11:02, 10 November 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This article explains how to serialize and de-serialize typed mathematical formulas,&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This article explains how to serialize and de-serialize typed mathematical formulas, that is instances of class {{class|org.eventb.core.ast.Formula}} which have been type-checked.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;that is instances of class {{class|org.eventb.core.ast.Formula}} which have been type-checked.&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Serialization==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Serialization==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>imported&gt;Mathieu</name></author>
	</entry>
	<entry>
		<id>https://wiki.event-b.org/index.php?title=Serializing_Mathematical_Formulas&amp;diff=9305&amp;oldid=prev</id>
		<title>imported&gt;Mathieu at 11:01, 10 November 2008</title>
		<link rel="alternate" type="text/html" href="https://wiki.event-b.org/index.php?title=Serializing_Mathematical_Formulas&amp;diff=9305&amp;oldid=prev"/>
		<updated>2008-11-10T11:01:53Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 11:01, 10 November 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This article explains how to serialize and de-serialize typed mathematical formulas,&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This article explains how to serialize and de-serialize typed mathematical formulas,&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;that is instances of class {{org.eventb.core.ast.Formula}} which have been type-checked.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;that is instances of class {{&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;class|&lt;/ins&gt;org.eventb.core.ast.Formula}} which have been type-checked.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Serialization==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Serialization==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>imported&gt;Mathieu</name></author>
	</entry>
	<entry>
		<id>https://wiki.event-b.org/index.php?title=Serializing_Mathematical_Formulas&amp;diff=9304&amp;oldid=prev</id>
		<title>imported&gt;Mathieu: From http://rodin-b-sharp.wiki.sourceforge.net/Serializing+Mathematical+Formulas</title>
		<link rel="alternate" type="text/html" href="https://wiki.event-b.org/index.php?title=Serializing_Mathematical_Formulas&amp;diff=9304&amp;oldid=prev"/>
		<updated>2008-11-10T11:01:29Z</updated>

		<summary type="html">&lt;p&gt;From http://rodin-b-sharp.wiki.sourceforge.net/Serializing+Mathematical+Formulas&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This article explains how to serialize and de-serialize typed mathematical formulas,&lt;br /&gt;
that is instances of class {{org.eventb.core.ast.Formula}} which have been type-checked.&lt;br /&gt;
&lt;br /&gt;
==Serialization==&lt;br /&gt;
&lt;br /&gt;
To serialize a typed formula, it is not sufficient to only serialize the formula. One also needs to serialize its type environment. Hopefully, this is quite easy to do. Suppose you want to save a formula as an array of strings. Here is the code to do it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        final List&amp;lt;String&amp;gt; strings = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
&lt;br /&gt;
        // Serialize predicate&lt;br /&gt;
        assert foo.isTypeChecked();&lt;br /&gt;
        strings.add(foo.toStringWithTypes());&lt;br /&gt;
&lt;br /&gt;
        // Serialize type environment&lt;br /&gt;
        for (final FreeIdentifier i : foo.getFreeIdentifiers()) {&lt;br /&gt;
            strings.add(i.getName());&lt;br /&gt;
            strings.add(i.getType().toString());&lt;br /&gt;
        }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==De-serialization==&lt;br /&gt;
&lt;br /&gt;
To de-serialize a typed formula, one just performs the same steps in the reverse order. Here we assume that the formula is a predicate and has been serialized to an array of strings.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        // De-serialize type environment&lt;br /&gt;
        final FormulaFactory ff = FormulaFactory.getDefault();&lt;br /&gt;
        final ITypeEnvironment typenv = ff.makeTypeEnvironment();&lt;br /&gt;
        final int size = strings.size();&lt;br /&gt;
        for (int i = 1; i &amp;lt; size; i += 2) {&lt;br /&gt;
            final String name = strings.get(i);&lt;br /&gt;
            final Type type = ff.parseType(strings.get(i + 1)).getParsedType();&lt;br /&gt;
            typenv.addName(name, type);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        // De-serialize predicate&lt;br /&gt;
        final Predicate bar = ff.parsePredicate(strings.get(0))&lt;br /&gt;
                .getParsedPredicate();&lt;br /&gt;
        bar.typeCheck(typenv);&lt;br /&gt;
        assert bar.isTypeChecked();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer documentation]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Mathieu</name></author>
	</entry>
</feed>