# Diff of Examples

#author("2017-03-17T17:32:29+09:00","default:Uedalab","Uedalab")
#author("2017-03-17T17:42:45+09:00","default:Uedalab","Uedalab")
#noattach
* Bouncing particle [#p560bc2f]
>

// y stands for the height of the ball
INIT   <=> y = 10 & y' = 0. // initial state
FALL   <=> [](y'' = -10).   // falling
BOUNCE <=> [](y- = 0 => y' = -4/5*y'-).
// if the ball reaches the ground, it bounces
INIT, FALL << BOUNCE.     // FALL is weaker than BOUNCE
<

&ref(./Bouncing_Particle.png,50%);
----
* Bouncing particle with a parametric initial height [#z5246173]
>

INIT   <=> 5 < y < 15 & y' = 0. // the initial height is uncertain
FALL   <=> [](y'' = -10).
BOUNCE <=> [](y- = 0 => y' = -4/5 * y'-).

INIT, FALL << BOUNCE.
<

&ref(./Bouncing_Particle_with_a_Parameter.png,100%);
----
* Bouncing particle in a parabolic vase [#j8167ade]
>

/**
*  bouncing particle on a curve of f(x) = (1/2) * x^2
*/

INIT <=> x = 1/2 & y = 10 & x' = 0 & y' = 0 & [](k = 1).
A    <=> [](x'' = 0 & y'' = -98/10).
/**
*     sin = f'(x) / (1+f'(x))^(1/2)
*     cos =     1 / (1+f'(x))^(1/2)
*  new x' = (-k * sin^2 + cos^2) * x' + (k+1) * sin * cos      * y'
*  new y' = (k+1) * sin * cos    * x' + (sin^2 + (-k) * cos^2) * y'
*/

SC <=> [](s = (x-)/(1+(x-)^2)^(1/2)
& c = 1   /(1+(x-)^2)^(1/2)).

BOUNCE <=> [](y- = (1/2) * (x-)^2 =>
x' = ( (-k) * s^2 + c^2 ) * x'- + ( (k+1) * s * c ) * y'-
& y' = ( (k+1) * s * c ) * x'- + ( s^2 + (-k) * c^2 ) * y'- ).

INIT, SC, A << BOUNCE.
<

&ref(./Bouncing_Paticle_on_a_Curve.png,70%);
----
* Bouncing particle in a circle [#xbf24e18]
>

INIT   <=> x = 0 /\ 0.5 < y < 0.6 /\ x' = 2 /\ y' = 1.
// the initial position is uncertain
RUN    <=> [](x'' = 0 /\ y'' = 0).
BOUNCE <=> []((x-)^2 + (y-)^2 = 1 =>
x' = x'- - (x- * x'- + y- * y'-) * 2 * (x-)
/\ y' = y'- - (x- * x'- + y- * y'-) * 2 * (y-)
).
INIT, RUN<<BOUNCE.
<

&ref(./Bouncing_Particle_in_a_Circle.png,70%);
----
* Hot-Air Balloon with multiple parameters [#tf906f5e]
>

/* A program for a hot-air balloon that repeats rising and falling */
// The initial condition of the balloon and the timer
// h: height of the balloon
// timer: timer variable to repeat rising and falling
INIT <=> h = 10 /\ h' = 0 /\ timer = 0.

// parameters
// duration: duration of falling
// riseT: duration of rising
PARAM<=> 1 < fallT < 4 /\ 1 < riseT < 3
/\ [](riseT' = 0 /\ fallT' = 0).

// increasing of timer
TIMER <=> [](timer' = 1).

// rising of the balloon
RISE <=> [](timer- < riseT =>h'' = 1).

// falling of the balloon
FALL <=> [](timer- >= riseT => h'' = -2).

// reset the timer to repeat rising and falling
RESET <=> [](timer- >= riseT + fallT => timer=0).

// assertion for bounded model checking
ASSERT(h > 0).

// constraint hierarchies
INIT, PARAM, FALL, RISE, TIMER<<RESET.
<

&ref(./Hot-Air_Balloon.png,70%);
----
* Bouncing particle with magnetic force [#a6ea3f5c]
>

INIT <=> y=10 & y'=0 & mag=0 & timer=0.
FALL <=> [](y''=-10+mag).
BOUNCE <=> [](y-=0=>y'=-y'-).
TRUE <=> [](1=1).
TIMER <=> [](mag'=0&timer'=1).
SWITCHON  <=> [](timer-=1=>mag=12&timer=0).
// The magnetic force may be switched on at every one second
SWITCHOFF <=> [](timer-=1=>mag=0&timer=0).
// The magnetic force may be switched off at every one second

INIT,TIMER<<(SWITCHOFF,SWITCHON)<<TRUE,FALL<<BOUNCE.
<

&ref(./Bouncing_Particle_with_Magnetic_Force.png,70%);
----
* Bouncing particle thrown toward a ceiling [#e682ba1f]
>

INIT  <=> 9 < y < 11 & y' = 10.
FALL  <=> [](y'' = -10).
BOUNCE <=> [](y- = 15 => y' = -(4/5)*y'-).

INIT, FALL << BOUNCE.
<

#mathjax
- In this program, the trajectories change qualitatively dependent on the initial height $$y_0$$.
-- If $$9 < y_0 < 10$$, the ball doesn't reach the ceiling.~
-- If $$y_0 = 10$$, the ball touches the ceiling, but the velocity remains continuous.~
-- If $$10 < y_0 < 11$$, the ball bounces on the ceiling.~
- HyLaGI performs such a case analysis automatically.~
#norelated
&ref(./Bouncing_Particle_thrown_toward a_ceiling.png,100%);
----
{"ft_lang_label":"__label__en","ft_lang_prob":0.56659955,"math_prob":0.99950814,"size":3865,"snap":"2019-51-2020-05","text_gpt3_token_len":1445,"char_repetition_ratio":0.13157213,"word_repetition_ratio":0.09052925,"special_character_ratio":0.4965071,"punctuation_ratio":0.15395683,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9998485,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-12-15T00:33:22Z\",\"WARC-Record-ID\":\"<urn:uuid:64a56717-d3e4-4299-95f8-750cc2fa91cf>\",\"Content-Length\":\"12192\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:f470b44d-7a48-4720-a282-f0677ba8a52d>\",\"WARC-Concurrent-To\":\"<urn:uuid:88df8740-543e-428d-9b2d-f9bbb6fe2c4d>\",\"WARC-IP-Address\":\"133.9.237.10\",\"WARC-Target-URI\":\"https://www.ueda.info.waseda.ac.jp/hydla/index.php?cmd=diff&page=Examples\",\"WARC-Payload-Digest\":\"sha1:AH2SJI4SHY767LCS2CGZRDZFBP4FKKRV\",\"WARC-Block-Digest\":\"sha1:AXZ72QFWK6RYDFJQ7FM6JAHO4R4GGFPW\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-51/CC-MAIN-2019-51_segments_1575541297626.61_warc_CC-MAIN-20191214230830-20191215014830-00319.warc.gz\"}"}